Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
diff FrmMainWindow.cs @ 33:441cfc410987
Re #86: Complete GTK# UI
* Make save buttons enable when a change has been made, whether the file was saved or not
* Make the Save button default to "Save As" behaviour if the file hasn't been saved before
* Make sure that loaded file path is kept and that it is wiped on file load
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 26 Sep 2009 11:06:34 +0000 |
parents | eab45344cd56 |
children | d68992a831df |
line wrap: on
line diff
--- a/FrmMainWindow.cs Mon Sep 21 19:17:27 2009 +0000 +++ b/FrmMainWindow.cs Sat Sep 26 11:06:34 2009 +0000 @@ -391,7 +391,7 @@ protected virtual void OnSaveArmyActivated(object sender, System.EventArgs e) { - SaveCurrentArmy(); + SaveCurrentArmyOrSaveAs(); } protected virtual void OnAddUnitActivated(object sender, System.EventArgs e) @@ -498,6 +498,7 @@ miCloseArmy.Sensitive = newArmy!=null; miSaveArmyAs.Sensitive = newArmy!=null; miExportArmy.Sensitive = newArmy!=null; + loadedArmyPath = null; //New army has no changes, so we can't save it miSaveArmy.Sensitive = false; saveArmyButton.Sensitive = false; @@ -677,18 +678,13 @@ //undoMenuButton.Tooltip = CommandStack.PeekUndoCommand().UndoDescription; } - saveArmyButton.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null && CanSave(); - miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null && CanSave(); - } - - private bool CanSave() - { - return loadedArmyPath!=null && WarFoundryCore.CurrentArmy!=null && WarFoundrySaver.GetSaver()!=null; + saveArmyButton.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null; + miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null; } private bool SaveCurrentArmyOrSaveAs() { - if (CanSave()) + if (loadedArmyPath != null) { return SaveCurrentArmy(); } @@ -727,8 +723,8 @@ { logger.Debug("Loaded army " + army.ID); success = true; + WarFoundryCore.CurrentArmy = army; loadedArmyPath = filePath; - WarFoundryCore.CurrentArmy = army; logger.Debug("Army loading complete"); } else @@ -753,7 +749,7 @@ { bool success = false; - if (CanSave()) + if (loadedArmyPath!=null) { success = SaveArmyToPath(WarFoundryCore.CurrentArmy, loadedArmyPath); } @@ -917,7 +913,7 @@ protected virtual void saveTBButtonActivated (object sender, System.EventArgs e) { - SaveCurrentArmy(); + SaveCurrentArmyOrSaveAs(); } protected virtual void openTBButtonActivated (object sender, System.EventArgs e)