Skip to content

Commit

Permalink
Merge pull request #12780 from riverwanderer/12755-fixes-for-wizard-h…
Browse files Browse the repository at this point in the history
…andling-of-window-title

Correctly adjust Player window title to reflect actions taken in Welcome Wizard
  • Loading branch information
uckelman authored Oct 8, 2023
2 parents a6671ba + c2056db commit 14435a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion vassal-app/src/main/java/VASSAL/build/GameModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
}

Expand Down
15 changes: 11 additions & 4 deletions vassal-app/src/main/java/VASSAL/build/module/WizardSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -519,13 +520,16 @@ 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();
}
// FIXME: review error message
catch (IOException e1) {
controller.setProblem(Resources.getString("WizardSupport.UnableToLoad"));
}
// Predefined Scenarios are files too...
g.setGameFile(setup.getFileName(), GameModule.GameFileMode.LOADED_GAME);
}
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand All @@ -854,4 +861,4 @@ public Wizard newWizard(Dimension logoSize) {
return createWizard();
}
}
}
}

0 comments on commit 14435a4

Please sign in to comment.