diff --git a/vassal-app/src/main/java/VASSAL/build/GameModule.java b/vassal-app/src/main/java/VASSAL/build/GameModule.java index 32532001b4..f403267c25 100644 --- a/vassal-app/src/main/java/VASSAL/build/GameModule.java +++ b/vassal-app/src/main/java/VASSAL/build/GameModule.java @@ -408,7 +408,7 @@ public void setLocationKeyCommand(KeyCommand kc) { * Our finder of the resources, for translation of images. */ private final ResourcePathFinder resourceFinder; - + /** * The user preferences */ @@ -1737,6 +1737,7 @@ public String getGameFile() { */ public void setGameFileMode(GameFileMode mode) { gameFileMode = Objects.requireNonNull(mode); + if (mode == GameFileMode.NEW_GAME) gameFile = ""; // reset title bar in event of a new game updateTitleBar(); } diff --git a/vassal-app/src/main/java/VASSAL/build/module/WizardSupport.java b/vassal-app/src/main/java/VASSAL/build/module/WizardSupport.java index a752c9461e..b405f8ddeb 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/WizardSupport.java +++ b/vassal-app/src/main/java/VASSAL/build/module/WizardSupport.java @@ -191,6 +191,7 @@ protected Void doInBackground() { if (Boolean.TRUE.equals(showWizard) && g.shutDown()) { System.exit(0); } + g.setGameFileMode(GameModule.GameFileMode.NEW_GAME); // reset gameFile and title g.getPlayerWindow().setVisible(true); } } @@ -519,6 +520,7 @@ public Component getListCellRendererComponent(JList list, Object value, int i } protected void loadSetup(PredefinedSetup setup, final WizardController controller, final Map settings) { + final GameModule g = GameModule.getGameModule(); try { new SavedGameLoader(controller, settings, new BufferedInputStream(setup.getSavedGameContents()), POST_PLAY_OFFLINE_WIZARD, true).start(); } @@ -526,6 +528,8 @@ protected void loadSetup(PredefinedSetup setup, final WizardController controlle catch (IOException e1) { controller.setProblem(Resources.getString("WizardSupport.UnableToLoad")); } + // Predefined Scenarios are files too... + g.setGameFile(setup.getFileName(), GameModule.GameFileMode.LOADED_GAME); } } @@ -712,6 +716,7 @@ else if (!processing.contains(f)) { // Sometimes the FileConfigurer fires more t @Override public void run() { final GameModule g = GameModule.getGameModule(); + // FIXME: The following default save/load attempt does not work (on MacOS at least the default is left "unknown"; please confirm for other platforms before fixing). g.getFileChooser().setSelectedFile(f); //BR// When loading a saved game from Wizard, put it appropriately into the "default" for the next save/load/etc. g.setGameFile(f.getName(), GameModule.GameFileMode.LOADED_GAME); //BR// ... aaaand put it in the app window description. super.run(); @@ -836,9 +841,11 @@ protected JComponent createPanel(WizardController controller, String id, Map set @Override public boolean cancel(Map settings) { - GameModule.getGameModule().setGameFileMode(GameModule.GameFileMode.NEW_GAME); - GameModule.getGameModule().getGameState().setup(false); - GameModule.getGameModule().getGameState().freshenStartupGlobalKeyCommands(GameModule.getGameModule()); + final GameModule g = GameModule.getGameModule(); + g.setGameFileMode(GameModule.GameFileMode.NEW_GAME); + g.getGameState().setup(false); + g.getGameState().freshenStartupGlobalKeyCommands(GameModule.getGameModule()); + return true; } @@ -854,4 +861,4 @@ public Wizard newWizard(Dimension logoSize) { return createWizard(); } } -} +} \ No newline at end of file