From: Frederick W. <fre...@us...> - 2012-02-17 17:32:42
|
LocalisedText.properties | 17 + data/Properties.xml | 1 data/profiles/default.profile | 2 data/profiles/root.profile | 1 images/icon/green_station.png |binary images/icon/green_track.png |binary images/icon/grey_station.png |binary images/icon/grey_track.png |binary images/icon/russet_station.png |binary images/icon/russet_track.png |binary images/icon/yellow_station.png |binary images/icon/yellow_track.png |binary rails/game/GameManager.java | 13 - rails/ui/swing/AbstractReportWindow.java | 9 rails/ui/swing/ConfigWindow.java | 11 rails/ui/swing/GameSetupWindow.java | 63 +++-- rails/ui/swing/GameUIManager.java | 99 +++++++- rails/ui/swing/ORWindow.java | 48 ++-- rails/ui/swing/SplashWindow.java | 356 ++++++++++++++++++++++++++++++ rails/ui/swing/StartRoundWindow.java | 10 rails/ui/swing/StatusWindow.java | 10 rails/ui/swing/StockChart.java | 10 rails/ui/swing/elements/DockingFrame.java | 6 rails/util/RunGame.java | 19 - 24 files changed, 582 insertions(+), 93 deletions(-) New commits: commit 0dd7547b2f850ea7e6e5b5c7ccf01c846ab5898c Author: Frederick Weld <fre...@gm...> Date: Fri Feb 17 18:30:28 2012 +0100 Added splash screen option to the root profile Default is on. Prior behavior cannot be restored anyway as the option only triggers whether the splash screen appears (and not whether window popup is occurs prematurely). diff --git a/data/profiles/root.profile b/data/profiles/root.profile index a553e4c..3e08d4d 100644 --- a/data/profiles/root.profile +++ b/data/profiles/root.profile @@ -34,6 +34,7 @@ or.window.dockablePanels=no report.window.type=dynamic report.window.open=yes report.window.editable=no +splash.window.open=yes stockchart.window.open=yes ### Panel Format commit 2d3fd85bfff93e46f42125bdc6fafd13bfd11e6c Author: Frederick Weld <fre...@gm...> Date: Fri Feb 17 17:55:22 2012 +0100 Visualized game initializing progress (splash) by tile upgrades Reused http://rails.sourceforge.net/ icons for this purpose. diff --git a/images/icon/green_station.png b/images/icon/green_station.png new file mode 100644 index 0000000..993e4f0 Binary files /dev/null and b/images/icon/green_station.png differ diff --git a/images/icon/green_track.png b/images/icon/green_track.png new file mode 100644 index 0000000..3d79ec5 Binary files /dev/null and b/images/icon/green_track.png differ diff --git a/images/icon/grey_station.png b/images/icon/grey_station.png new file mode 100644 index 0000000..9597307 Binary files /dev/null and b/images/icon/grey_station.png differ diff --git a/images/icon/grey_track.png b/images/icon/grey_track.png new file mode 100644 index 0000000..6c498f3 Binary files /dev/null and b/images/icon/grey_track.png differ diff --git a/images/icon/russet_station.png b/images/icon/russet_station.png new file mode 100644 index 0000000..625bcea Binary files /dev/null and b/images/icon/russet_station.png differ diff --git a/images/icon/russet_track.png b/images/icon/russet_track.png new file mode 100644 index 0000000..acddde2 Binary files /dev/null and b/images/icon/russet_track.png differ diff --git a/images/icon/yellow_station.png b/images/icon/yellow_station.png new file mode 100644 index 0000000..0bc7f8c Binary files /dev/null and b/images/icon/yellow_station.png differ diff --git a/images/icon/yellow_track.png b/images/icon/yellow_track.png new file mode 100644 index 0000000..1034612 Binary files /dev/null and b/images/icon/yellow_track.png differ diff --git a/rails/ui/swing/SplashWindow.java b/rails/ui/swing/SplashWindow.java index 618e677..8104a6d 100644 --- a/rails/ui/swing/SplashWindow.java +++ b/rails/ui/swing/SplashWindow.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Set; import javax.swing.BoxLayout; +import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; @@ -38,33 +39,33 @@ public class SplashWindow { /** * in millisecs */ - private static long PROGRESS_UPDATE_INTERVAL = 200; + private final static long PROGRESS_UPDATE_INTERVAL = 200; - private static String DUMMY_STEP_BEFORE_START = "-1"; - private static String DUMMY_STEP_START = "0"; - private static String DUMMY_STEP_END = "inf"; + private final static String DUMMY_STEP_BEFORE_START = "-1"; + private final static String DUMMY_STEP_START = "0"; + private final static String DUMMY_STEP_END = "inf"; - public static String STEP_LOAD_GAME = "Splash.step.loadGame"; - public static String STEP_INIT_UI = "Splash.step.initUI"; - public static String STEP_STOCK_CHART = "Splash.step.stockChart"; - public static String STEP_REPORT_WINDOW = "Splash.step.reportWindow"; - public static String STEP_OR_INIT_DOCKING_FRAME = "Splash.step.or.initDockingFrame"; - public static String STEP_OR_INIT_PANELS = "Splash.step.or.initPanels"; - public static String STEP_OR_INIT_TILES = "Splash.step.or.initTiles"; - public static String STEP_OR_APPLY_DOCKING_FRAME = "Splash.step.or.applyDockingFrame"; - public static String STEP_STATUS_WINDOW = "Splash.step.statusWindow"; - public static String STEP_INIT_NEW_GAME = "Splash.step.initNewGame"; - public static String STEP_CONFIG_WINDOW = "Splash.step.configWindow"; - public static String STEP_INIT_SOUND = "Splash.step.initSound"; - public static String STEP_INIT_LOADED_GAME = "Splash.step.initLoadedGame"; - public static String STEP_FINALIZE = "Splash.step.finalize"; + public final static String STEP_LOAD_GAME = "Splash.step.loadGame"; + public final static String STEP_INIT_UI = "Splash.step.initUI"; + public final static String STEP_STOCK_CHART = "Splash.step.stockChart"; + public final static String STEP_REPORT_WINDOW = "Splash.step.reportWindow"; + public final static String STEP_OR_INIT_DOCKING_FRAME = "Splash.step.or.initDockingFrame"; + public final static String STEP_OR_INIT_PANELS = "Splash.step.or.initPanels"; + public final static String STEP_OR_INIT_TILES = "Splash.step.or.initTiles"; + public final static String STEP_OR_APPLY_DOCKING_FRAME = "Splash.step.or.applyDockingFrame"; + public final static String STEP_STATUS_WINDOW = "Splash.step.statusWindow"; + public final static String STEP_INIT_NEW_GAME = "Splash.step.initNewGame"; + public final static String STEP_CONFIG_WINDOW = "Splash.step.configWindow"; + public final static String STEP_INIT_SOUND = "Splash.step.initSound"; + public final static String STEP_INIT_LOADED_GAME = "Splash.step.initLoadedGame"; + public final static String STEP_FINALIZE = "Splash.step.finalize"; - private static List<String> STEP_GROUP_LOAD = Arrays.asList(new String[] { + private final static List<String> STEP_GROUP_LOAD = Arrays.asList(new String[] { STEP_LOAD_GAME, STEP_INIT_LOADED_GAME }); - private static List<String> STEP_GROUP_DOCKING_LAYOUT = Arrays.asList(new String[] { + private final static List<String> STEP_GROUP_DOCKING_LAYOUT = Arrays.asList(new String[] { STEP_OR_INIT_DOCKING_FRAME, STEP_OR_INIT_TILES, STEP_OR_APPLY_DOCKING_FRAME, @@ -78,7 +79,7 @@ public class SplashWindow { this.labelConfigKey = labelConfigKey; } } - private static StepDuration[] stepDuration = { + private final static StepDuration[] stepDuration = { new StepDuration ( 0, DUMMY_STEP_BEFORE_START), // used to facilitate array border handling new StepDuration ( 0, DUMMY_STEP_START), // used to facilitate array border handling new StepDuration ( 6000, STEP_LOAD_GAME ), @@ -97,15 +98,22 @@ public class SplashWindow { new StepDuration ( 1000, STEP_FINALIZE), new StepDuration ( 0, DUMMY_STEP_END), // used to facilitate array border handling }; - + private long totalDuration = 0; private long[] cumulativeDuration = null; private Set<JFrame> framesRegisteredAsVisible = new HashSet<JFrame>(); private List<JFrame> framesRegisteredToFront = new ArrayList<JFrame>(); - private static Dimension iconSize = new Dimension(90,78); - + private final static String iconPath = "/images/icon/"; + + private final static String[][] icons = new String[][] { + { "yellow_track.png" , "yellow_station.png" }, + { "green_track.png" , "green_station.png" }, + { "russet_track.png" , "russet_station.png" }, + { "grey_track.png" , "grey_station.png" } + }; + private JWindow myWin = null; private JLabel leftIcon = null; private JLabel rightIcon = null; @@ -114,7 +122,8 @@ public class SplashWindow { private ProgressVisualizer progressVisualizer = null; - private int currentStep = 1; //the start step + private int currentStep = 0; + private int currentIconIndex = 0; public SplashWindow(boolean isLoad, String initDetailsText) { //quit directly when no visualization required @@ -139,16 +148,19 @@ public class SplashWindow { myWin = new JWindow(); leftIcon = new JLabel(); - leftIcon.setPreferredSize(iconSize); + setIcon(leftIcon,icons[currentIconIndex][0]); + leftIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder())); rightIcon = new JLabel(); - rightIcon.setPreferredSize(iconSize); + setIcon(rightIcon,icons[currentIconIndex][1]); + rightIcon.setBorder(new CompoundBorder(new EmptyBorder(5,5,5,5),new EtchedBorder())); progressBar = new JProgressBar(0,(int)totalDuration); progressBar.setStringPainted(true); progressBar.setMinimum(0); - stepLabel = new JLabel(); + stepLabel = new JLabel(" "); // needed in order to allocate vertical space stepLabel.setAlignmentX(Component.CENTER_ALIGNMENT); + stepLabel.setBorder(new EmptyBorder(5,5,5,5)); //set up static elements @@ -160,7 +172,7 @@ public class SplashWindow { String commandTextKey = isLoad ? "Splash.command.loadGame" : "Splash.command.newGame"; JLabel commandLabel = new JLabel( LocalText.getText(commandTextKey,initDetailsText)); - commandLabel.setFont(commandLabel.getFont().deriveFont(Font.ITALIC)); + commandLabel.setFont(commandLabel.getFont().deriveFont(Font.BOLD)); commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT); //plug elements together and set up layout @@ -169,12 +181,14 @@ public class SplashWindow { railsCommandPanel.setLayout(new BoxLayout(railsCommandPanel, BoxLayout.Y_AXIS)); railsCommandPanel.add(railsLabel); railsCommandPanel.add(commandLabel); + railsCommandPanel.setBorder(new EmptyBorder(3,3,3,3)); JPanel idPanel = new JPanel(); idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS)); idPanel.add(leftIcon); idPanel.add(railsCommandPanel); idPanel.add(rightIcon); + idPanel.setBorder(new EmptyBorder(3,3,3,3)); JComponent contentPane = (JComponent)myWin.getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); @@ -201,7 +215,7 @@ public class SplashWindow { } catch (Exception e) {} progressVisualizer = new ProgressVisualizer(); - progressVisualizer.setCurrentStep(currentStep); + notifyOfStep(DUMMY_STEP_START); progressVisualizer.start(); } @@ -218,10 +232,10 @@ public class SplashWindow { } /** - * @param elapsedDuration Refers to a duration normalized based on the expected durations + * @param elapsedTime Refers to a duration normalized based on the expected durations * of the process steps. */ - synchronized private void visualizeProgress(long elapsedDuration, int currentStep) { + synchronized private void visualizeProgress(long elapsedTime, int currentStep) { //update current step (including description) if (currentStep != this.currentStep) { this.currentStep = currentStep; @@ -232,13 +246,32 @@ public class SplashWindow { } } + //update icon + int newIconIndex = (int)(icons.length * elapsedTime / totalDuration); + newIconIndex = Math.max( Math.min(icons.length-1 , newIconIndex) , 0); + if (newIconIndex != currentIconIndex) { + currentIconIndex = newIconIndex; + setIcon(leftIcon,icons[newIconIndex][0]); + setIcon(rightIcon,icons[newIconIndex][1]); + } + //show progress - progressBar.setValue((int)elapsedDuration); + progressBar.setValue((int)elapsedTime); //ensure visibility of window myWin.toFront(); } + private void setIcon(JLabel iconLabel, String iconFileName) { + String path = iconPath + iconFileName; + java.net.URL imgURL = getClass().getResource(path); + if (imgURL != null) { + iconLabel.setIcon(new ImageIcon(imgURL)); + } else { + System.err.println("Couldn't find file: " + path); + } + } + /** * Remembers that this frame is to be put to visible at the end of the splash process */ commit 682539e88405e444c60fc0bc8649ed43c7c40dbd Author: Frederick Weld <fre...@gm...> Date: Fri Feb 17 17:25:17 2012 +0100 Added texts for game init steps (displayed in progress bar) diff --git a/LocalisedText.properties b/LocalisedText.properties index d5f8f37..ac4899b 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -642,6 +642,20 @@ SoldOutNoRaise={0} is sold out, but price stays at {1}({2}) SPECIAL=Special Splash.command.loadGame=Loading Game: {0} Splash.command.newGame=Starting New Game: {0} +Splash.step.loadGame=Replaying game... +Splash.step.initUI=Initializing user interface... +Splash.step.stockChart=Building stock chart... +Splash.step.reportWindow=Building report window... +Splash.step.or.initDockingFrame=Initializing docking framework for flexible panels... +Splash.step.or.initPanels=Building operating round window... +Splash.step.or.initTiles=Initializing tiles... +Splash.step.or.applyDockingFrame=Applying docking framework to operating round window... +Splash.step.statusWindow=Building status window... +Splash.step.initNewGame=Initializing new game... +Splash.step.configWindow=Building configuration window... +Splash.step.initSound=Initializing sound... +Splash.step.initLoadedGame=Initializing loaded game... +Splash.step.finalize=Finalizing... SPLIT=Split SRHelpText=Stock round help text goes here. START_COMPANY={0} starts {1} at {2}. diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java index 68f2ce5..89d037f 100644 --- a/rails/ui/swing/ORWindow.java +++ b/rails/ui/swing/ORWindow.java @@ -191,10 +191,6 @@ public class ORWindow extends DockingFrame implements ActionPerformer { if (isDockingFrameworkEnabled()) { initLayout(); - - //trigger early painting in order to parallelize OR window setup - //with other setup activities - repaint(); } } }); diff --git a/rails/ui/swing/SplashWindow.java b/rails/ui/swing/SplashWindow.java index 0d6ebdb..618e677 100644 --- a/rails/ui/swing/SplashWindow.java +++ b/rails/ui/swing/SplashWindow.java @@ -88,7 +88,7 @@ public class SplashWindow { new StepDuration ( 2600, STEP_OR_INIT_DOCKING_FRAME ), new StepDuration ( 1650, STEP_OR_INIT_PANELS ), new StepDuration ( 5000, STEP_OR_INIT_TILES ), - new StepDuration ( 1000, STEP_OR_APPLY_DOCKING_FRAME ), + new StepDuration ( 3000, STEP_OR_APPLY_DOCKING_FRAME ), new StepDuration ( 400, STEP_STATUS_WINDOW ), new StepDuration ( 300, STEP_INIT_NEW_GAME ), new StepDuration ( 1200, STEP_CONFIG_WINDOW ), @@ -214,6 +214,7 @@ public class SplashWindow { progressVisualizer.setCurrentStep(i); } } + } /** @@ -226,29 +227,19 @@ public class SplashWindow { this.currentStep = currentStep; //only display step description for non-dummy steps if (stepDuration[currentStep].expectedDurationInMillis > 0) { - stepLabel.setText(stepDuration[currentStep].labelConfigKey); - enforeGUIUpdate(stepLabel); + stepLabel.setText(LocalText.getText( + stepDuration[currentStep].labelConfigKey)); } } //show progress progressBar.setValue((int)elapsedDuration); - enforeGUIUpdate(progressBar); //ensure visibility of window myWin.toFront(); } /** - * ensure that progress is updated even if EDT is very busy - * CAUTION: paintImmediately is called outside of EDT - * works but not guideline-conform - */ - private void enforeGUIUpdate(JComponent c) { - c.paintImmediately(c.getBounds()); - } - - /** * Remembers that this frame is to be put to visible at the end of the splash process */ public void registerFrameForDeferredVisibility(JFrame frame,boolean setToVisible) { commit 116db12ebbaceffb1e5f112bfb3bd9c55a2d96d2 Author: Frederick Weld <fre...@gm...> Date: Fri Feb 17 17:13:01 2012 +0100 Added splash screen label for init operation New label indicates "Starting New Game: xyz" or "Loading Game: xyz". diff --git a/LocalisedText.properties b/LocalisedText.properties index ee7f6f5..d5f8f37 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -640,6 +640,8 @@ SharesPutInTreasury=The remaining {0}% shares of {1} are put in its treasury SoldOut={0} is sold out, price rises from {1}({2}) to {3}({4}) SoldOutNoRaise={0} is sold out, but price stays at {1}({2}) SPECIAL=Special +Splash.command.loadGame=Loading Game: {0} +Splash.command.newGame=Starting New Game: {0} SPLIT=Split SRHelpText=Stock round help text goes here. START_COMPANY={0} starts {1} at {2}. diff --git a/rails/ui/swing/GameSetupWindow.java b/rails/ui/swing/GameSetupWindow.java index 6a633a9..4d7e73d 100644 --- a/rails/ui/swing/GameSetupWindow.java +++ b/rails/ui/swing/GameSetupWindow.java @@ -228,7 +228,7 @@ public class GameSetupWindow extends JDialog implements ActionListener { */ private void loadAndStartGame(String filePath, String saveDirectory) { prepareGameUIInit(); - SplashWindow splashWindow = new SplashWindow(true); + SplashWindow splashWindow = new SplashWindow(true,filePath); splashWindow.notifyOfStep(SplashWindow.STEP_LOAD_GAME); if ((game = Game.load(filePath)) == null) { JOptionPane.showMessageDialog(this, @@ -500,7 +500,12 @@ public class GameSetupWindow extends JDialog implements ActionListener { } } - game = new Game(this.getSelectedGameInfo().getName(), playerNames, selectedOptions); + String gameName = getSelectedGameInfo().getName(); + + SplashWindow splashWindow = new SplashWindow(false,gameName); + + game = new Game(gameName, playerNames, selectedOptions); + if (!game.setup()) { JOptionPane.showMessageDialog(this, DisplayBuffer.get(), "", JOptionPane.ERROR_MESSAGE); @@ -517,7 +522,6 @@ public class GameSetupWindow extends JDialog implements ActionListener { System.exit(-1); } prepareGameUIInit(); - SplashWindow splashWindow = new SplashWindow(false); startGameUIManager (game, false, splashWindow); gameUIManager.gameUIInit(true); // true indicates new game completeGameUIInit(splashWindow); diff --git a/rails/ui/swing/SplashWindow.java b/rails/ui/swing/SplashWindow.java index 1e1201e..0d6ebdb 100644 --- a/rails/ui/swing/SplashWindow.java +++ b/rails/ui/swing/SplashWindow.java @@ -2,6 +2,7 @@ package rails.ui.swing; import java.awt.Component; import java.awt.Dimension; +import java.awt.Font; import java.awt.Toolkit; import java.util.ArrayList; import java.util.Arrays; @@ -21,6 +22,7 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; +import rails.common.LocalText; import rails.common.parser.Config; import rails.game.Game; @@ -114,7 +116,7 @@ public class SplashWindow { private int currentStep = 1; //the start step - public SplashWindow(boolean isLoad) { + public SplashWindow(boolean isLoad, String initDetailsText) { //quit directly when no visualization required //all visualization related attributes remain null then if ("no".equals(Config.get("splash.window.open"))) return; @@ -155,7 +157,10 @@ public class SplashWindow { (float)2.0 * railsLabel.getFont().getSize())); railsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); - JLabel commandLabel = new JLabel("Setting up new game / loading game"); + String commandTextKey = isLoad ? "Splash.command.loadGame" : "Splash.command.newGame"; + JLabel commandLabel = new JLabel( + LocalText.getText(commandTextKey,initDetailsText)); + commandLabel.setFont(commandLabel.getFont().deriveFont(Font.ITALIC)); commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT); //plug elements together and set up layout diff --git a/rails/util/RunGame.java b/rails/util/RunGame.java index 8206c25..3c08442 100644 --- a/rails/util/RunGame.java +++ b/rails/util/RunGame.java @@ -49,11 +49,12 @@ public class RunGame { static void loadGame (String[] args) { - SplashWindow splashWindow = new SplashWindow(true); - splashWindow.notifyOfStep(SplashWindow.STEP_LOAD_GAME); - Game game = null; String filepath = args[0]; + + SplashWindow splashWindow = new SplashWindow(true,filepath); + splashWindow.notifyOfStep(SplashWindow.STEP_LOAD_GAME); + System.out.println("Starting game from saved file "+filepath); if ((game = Game.load(filepath)) == null) { System.err.println("Loading file "+filepath+" was unsuccessful"); commit b28efc90ce9a591119f83d6613d16df57990917a Author: Frederick Weld <fre...@gm...> Date: Fri Feb 17 16:27:15 2012 +0100 Laid out splash screen (incl. rails version, progress bar) diff --git a/LocalisedText.properties b/LocalisedText.properties index 9c1ccd7..ee7f6f5 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -213,7 +213,7 @@ Config.label.route.colour.1=Route color for first train Config.label.route.colour.2=Route color for second train Config.label.route.colour.3=Route color for third train Config.label.route.colour.4=Route color for fourth train -Config.label.splash.window.open=Splash window open +Config.label.splash.window.open=Display splash screen Config.label.sound.backgroundMusic=Background Music Config.label.sound.backgroundMusic.endOfGameRound=End of Game Config.label.sound.backgroundMusic.gameSetup=Initial Game Setup diff --git a/rails/ui/swing/SplashWindow.java b/rails/ui/swing/SplashWindow.java index edb8cad..1e1201e 100644 --- a/rails/ui/swing/SplashWindow.java +++ b/rails/ui/swing/SplashWindow.java @@ -1,18 +1,28 @@ package rails.ui.swing; -import java.awt.Rectangle; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Toolkit; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; +import javax.swing.BoxLayout; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; import javax.swing.JWindow; import javax.swing.SwingUtilities; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; import rails.common.parser.Config; +import rails.game.Game; /** * Splash window shown during setup of game UI components and game loading. @@ -32,20 +42,20 @@ public class SplashWindow { private static String DUMMY_STEP_START = "0"; private static String DUMMY_STEP_END = "inf"; - public static String STEP_LOAD_GAME = "1"; - public static String STEP_INIT_UI = "2"; - public static String STEP_STOCK_CHART = "3"; - public static String STEP_REPORT_WINDOW = "4"; - public static String STEP_OR_INIT_DOCKING_FRAME = "5A"; - public static String STEP_OR_INIT_PANELS = "5B"; - public static String STEP_OR_INIT_TILES = "5C"; - public static String STEP_OR_APPLY_DOCKING_FRAME = "5D"; - public static String STEP_STATUS_WINDOW = "6"; - public static String STEP_INIT_NEW_GAME = "7"; - public static String STEP_CONFIG_WINDOW = "8"; - public static String STEP_INIT_SOUND = "9"; - public static String STEP_INIT_LOADED_GAME = "10"; - public static String STEP_FINALIZE = "11"; + public static String STEP_LOAD_GAME = "Splash.step.loadGame"; + public static String STEP_INIT_UI = "Splash.step.initUI"; + public static String STEP_STOCK_CHART = "Splash.step.stockChart"; + public static String STEP_REPORT_WINDOW = "Splash.step.reportWindow"; + public static String STEP_OR_INIT_DOCKING_FRAME = "Splash.step.or.initDockingFrame"; + public static String STEP_OR_INIT_PANELS = "Splash.step.or.initPanels"; + public static String STEP_OR_INIT_TILES = "Splash.step.or.initTiles"; + public static String STEP_OR_APPLY_DOCKING_FRAME = "Splash.step.or.applyDockingFrame"; + public static String STEP_STATUS_WINDOW = "Splash.step.statusWindow"; + public static String STEP_INIT_NEW_GAME = "Splash.step.initNewGame"; + public static String STEP_CONFIG_WINDOW = "Splash.step.configWindow"; + public static String STEP_INIT_SOUND = "Splash.step.initSound"; + public static String STEP_INIT_LOADED_GAME = "Splash.step.initLoadedGame"; + public static String STEP_FINALIZE = "Splash.step.finalize"; private static List<String> STEP_GROUP_LOAD = Arrays.asList(new String[] { STEP_LOAD_GAME, @@ -92,11 +102,15 @@ public class SplashWindow { private Set<JFrame> framesRegisteredAsVisible = new HashSet<JFrame>(); private List<JFrame> framesRegisteredToFront = new ArrayList<JFrame>(); + private static Dimension iconSize = new Dimension(90,78); + private JWindow myWin = null; - private ProgressVisualizer progressVisualizer = null; + private JLabel leftIcon = null; + private JLabel rightIcon = null; + private JProgressBar progressBar = null; + private JLabel stepLabel = null; - //TODO remove temp label - private JLabel tempL = null; + private ProgressVisualizer progressVisualizer = null; private int currentStep = 1; //the start step @@ -104,17 +118,7 @@ public class SplashWindow { //quit directly when no visualization required //all visualization related attributes remain null then if ("no".equals(Config.get("splash.window.open"))) return; - - myWin = new JWindow(); - myWin.setBounds(new Rectangle(200,200,400,200)); - - //TODO remove temp - tempL = new JLabel(""); - myWin.getContentPane().add(tempL); - tempL.setVisible(true); - //TODO set up frame (incl. title, icons, bar, status text) - myWin.setVisible(true); - + //calculate estimated duration for the respective steps cumulativeDuration = new long[stepDuration.length]; boolean isDockingLayout = "yes".equals(Config.get("or.window.dockablePanels")); @@ -128,6 +132,69 @@ public class SplashWindow { cumulativeDuration[i] = totalDuration; } + //set up dynamic elements + + myWin = new JWindow(); + + leftIcon = new JLabel(); + leftIcon.setPreferredSize(iconSize); + rightIcon = new JLabel(); + rightIcon.setPreferredSize(iconSize); + + progressBar = new JProgressBar(0,(int)totalDuration); + progressBar.setStringPainted(true); + progressBar.setMinimum(0); + + stepLabel = new JLabel(); + stepLabel.setAlignmentX(Component.CENTER_ALIGNMENT); + + //set up static elements + + JLabel railsLabel = new JLabel("Rails " + Game.getFullVersion()); + railsLabel.setFont(railsLabel.getFont().deriveFont( + (float)2.0 * railsLabel.getFont().getSize())); + railsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); + + JLabel commandLabel = new JLabel("Setting up new game / loading game"); + commandLabel.setAlignmentX(Component.CENTER_ALIGNMENT); + + //plug elements together and set up layout + + JPanel railsCommandPanel = new JPanel(); + railsCommandPanel.setLayout(new BoxLayout(railsCommandPanel, BoxLayout.Y_AXIS)); + railsCommandPanel.add(railsLabel); + railsCommandPanel.add(commandLabel); + + JPanel idPanel = new JPanel(); + idPanel.setLayout(new BoxLayout(idPanel, BoxLayout.X_AXIS)); + idPanel.add(leftIcon); + idPanel.add(railsCommandPanel); + idPanel.add(rightIcon); + + JComponent contentPane = (JComponent)myWin.getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(idPanel); + contentPane.add(progressBar); + contentPane.add(stepLabel); + contentPane.setBorder(new CompoundBorder(new EtchedBorder(),new EmptyBorder(5,5,5,5))); + + //perform layout within the EDT + //blocking call as further initialization requires the layout to be frozen + ... [truncated message content] |