Revision: 9225
http://sourceforge.net/p/vassalengine/svn/9225
Author: uckelman
Date: 2016-04-27 14:11:01 +0000 (Wed, 27 Apr 2016)
Log Message:
-----------
Fixed Bug 12527: "Save Game" behaves as "Save As", not "Save"
Modified Paths:
--------------
VASSAL-src/trunk/CHANGES
VASSAL-src/trunk/src/VASSAL/build/module/GameState.java
VASSAL-src/trunk/src/VASSAL/i18n/VASSAL.properties
VASSAL-src/trunk/src/VASSAL/launch/PlayerWindow.java
Modified: VASSAL-src/trunk/CHANGES
===================================================================
--- VASSAL-src/trunk/CHANGES 2016-04-18 00:24:30 UTC (rev 9224)
+++ VASSAL-src/trunk/CHANGES 2016-04-27 14:11:01 UTC (rev 9225)
@@ -1,5 +1,6 @@
3.2.17 - ???
+* 12527: "Save Game" behaves as "Save As"
* 12526: Switching desktop on Mac OS X 10.11.3 sometimes clones the currently
selected unit
Modified: VASSAL-src/trunk/src/VASSAL/build/module/GameState.java
===================================================================
--- VASSAL-src/trunk/src/VASSAL/build/module/GameState.java 2016-04-18 00:24:30 UTC (rev 9224)
+++ VASSAL-src/trunk/src/VASSAL/build/module/GameState.java 2016-04-27 14:11:01 UTC (rev 9225)
@@ -94,8 +94,9 @@
protected Map<String,GamePiece> pieces = new HashMap<String,GamePiece>();
protected List<GameComponent> gameComponents = new ArrayList<GameComponent>();
protected List<GameSetupStep> setupSteps = new ArrayList<GameSetupStep>();
- protected Action loadGame, saveGame, newGame, closeGame;
+ protected Action loadGame, saveGame, saveGameAs, newGame, closeGame;
protected String lastSave;
+ protected File lastSaveFile = null;
protected DirectoryConfigurer savedGameDirectoryPreference;
protected String loadComments;
@@ -129,6 +130,17 @@
// some languages
saveGame.putValue(Action.MNEMONIC_KEY, (int)Resources.getString("GameState.save_game.shortcut").charAt(0));
+ saveGameAs = new AbstractAction(Resources.getString("GameState.save_game_as")) {
+ private static final long serialVersionUID = 1L;
+
+ public void actionPerformed(ActionEvent e) {
+ saveGameAs();
+ }
+ };
+ // FIMXE: setting nmemonic from first letter could cause collisions in
+ // some languages
+ saveGameAs.putValue(Action.MNEMONIC_KEY, (int)Resources.getString("GameState.save_game_as.shortcut").charAt(0));
+
newGame = new AbstractAction(Resources.getString("GameState.new_game")) {
private static final long serialVersionUID = 1L;
@@ -157,9 +169,11 @@
mm.addAction("GameState.new_game", newGame);
mm.addAction("GameState.load_game", loadGame);
mm.addAction("GameState.save_game", saveGame);
+ mm.addAction("GameState.save_game_as", saveGameAs);
mm.addAction("GameState.close_game", closeGame);
saveGame.setEnabled(gameStarting);
+ saveGameAs.setEnabled(gameStarting);
closeGame.setEnabled(gameStarting);
}
@@ -290,6 +304,7 @@
newGame.setEnabled(!gameStarting);
saveGame.setEnabled(gameStarting);
+ saveGameAs.setEnabled(gameStarting);
closeGame.setEnabled(gameStarting);
if (gameStarting) {
@@ -310,6 +325,9 @@
gameStarted |= this.gameStarting;
lastSave = gameStarting ? saveString() : null;
+ if (!gameStarting) {
+ lastSaveFile = null;
+ }
}
/** Return true if a game is currently in progress */
@@ -393,6 +411,8 @@
else {
loadGameInBackground(f);
}
+
+ lastSaveFile = f;
}
catch (IOException e) {
ReadErrorDialog.error(e, f);
@@ -417,43 +437,76 @@
return GameModule.getGameModule().encode(getRestoreCommand());
}
+ protected boolean checkForOldSaveFile(File f) {
+ if (f.exists()) {
+ // warn user if overwriting a save from an old version
+ final AbstractMetaData md = MetaDataFactory.buildMetaData(f);
+ if (md != null && md instanceof SaveMetaData) {
+ if (Info.hasOldFormat(md.getVassalVersion())) {
+ return Dialogs.showConfirmDialog(
+ GameModule.getGameModule().getFrame(),
+ Resources.getString("Warning.save_will_be_updated_title"),
+ Resources.getString("Warning.save_will_be_updated_heading"),
+ Resources.getString(
+ "Warning.save_will_be_updated_message",
+ f.getPath(),
+ "3.2"
+ ),
+ JOptionPane.WARNING_MESSAGE,
+ JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION;
+ }
+ }
+ }
- /** Prompts the user for a file into which to save the game */
+ return true;
+ }
+
+ /** Saves the game to an existing file, or prompts for a new one. */
public void saveGame() {
final GameModule g = GameModule.getGameModule();
g.warn(Resources.getString("GameState.saving_game")); //$NON-NLS-1$
+ if (lastSaveFile != null) {
+ if (!checkForOldSaveFile(lastSaveFile)) {
+ return;
+ }
+
+ try {
+ saveGame(lastSaveFile);
+ g.warn(Resources.getString("GameState.game_saved")); //$NON-NLS-1$
+ }
+ catch (IOException e) {
+ WriteErrorDialog.error(e, lastSaveFile);
+/*
+ Logger.log(err);
+ GameModule.getGameModule().warn(Resources.getString("GameState.save_failed")); //$NON-NLS-1$
+*/
+ }
+ }
+ else {
+ saveGameAs();
+ }
+ }
+
+ /** Prompts the user for a file into which to save the game */
+ public void saveGameAs() {
+ final GameModule g = GameModule.getGameModule();
+
+ g.warn(Resources.getString("GameState.saving_game")); //$NON-NLS-1$
+
final File saveFile = getSaveFile();
if (saveFile == null) {
g.warn(Resources.getString("GameState.save_canceled")); //$NON-NLS-1$
}
else {
- if (saveFile.exists()) {
- // warn user if overwriting a save from an old version
- final AbstractMetaData md = MetaDataFactory.buildMetaData(saveFile);
- if (md != null && md instanceof SaveMetaData) {
- if (Info.hasOldFormat(md.getVassalVersion())) {
- if (Dialogs.showConfirmDialog(
- g.getFrame(),
- Resources.getString("Warning.save_will_be_updated_title"),
- Resources.getString("Warning.save_will_be_updated_heading"),
- Resources.getString(
- "Warning.save_will_be_updated_message",
- saveFile.getPath(),
- "3.2"
- ),
- JOptionPane.WARNING_MESSAGE,
- JOptionPane.OK_CANCEL_OPTION) == JOptionPane.CANCEL_OPTION)
- {
- return;
- }
- }
- }
+ if (!checkForOldSaveFile(saveFile)) {
+ return;
}
try {
saveGame(saveFile);
+ lastSaveFile = saveFile;
g.warn(Resources.getString("GameState.game_saved")); //$NON-NLS-1$
}
catch (IOException e) {
Modified: VASSAL-src/trunk/src/VASSAL/i18n/VASSAL.properties
===================================================================
--- VASSAL-src/trunk/src/VASSAL/i18n/VASSAL.properties 2016-04-18 00:24:30 UTC (rev 9224)
+++ VASSAL-src/trunk/src/VASSAL/i18n/VASSAL.properties 2016-04-27 14:11:01 UTC (rev 9225)
@@ -398,8 +398,10 @@
GameState.save_game_query=Save Game?
GameState.load_game=Load Game...
GameState.load_game.shortcut=L
-GameState.save_game=Save Game...
+GameState.save_game=Save Game
GameState.save_game.shortcut=S
+GameState.save_game_as=Save Game As...
+GameState.save_game_as.shortcut=A
GameState.close_game=Close Game
GameState.close_game.shortcut=C
GameState.load_error=Load Error
Modified: VASSAL-src/trunk/src/VASSAL/launch/PlayerWindow.java
===================================================================
--- VASSAL-src/trunk/src/VASSAL/launch/PlayerWindow.java 2016-04-18 00:24:30 UTC (rev 9224)
+++ VASSAL-src/trunk/src/VASSAL/launch/PlayerWindow.java 2016-04-27 14:11:01 UTC (rev 9225)
@@ -77,6 +77,7 @@
fileMenu.add(mm.addKey("GameState.new_game"));
fileMenu.add(mm.addKey("GameState.load_game"));
fileMenu.add(mm.addKey("GameState.save_game"));
+ fileMenu.add(mm.addKey("GameState.save_game_as"));
fileMenu.add(mm.addKey("GameState.close_game"));
fileMenu.addSeparator();
fileMenu.add(mm.addKey("BasicLogger.begin_logfile"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
vassalengine-svn mailing list
vas...@li...
https://lists.sourceforge.net/lists/listinfo/vassalengine-svn
|