Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
annotate FrmMainWindow.cs @ 153:87fda1e6d4d3
* Merge accidental new head
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 08 May 2012 21:01:57 +0100 |
parents | 83b19b57cba1 |
children | 2d1dd73a3289 |
rev | line source |
---|---|
19
a191d0655f55
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
18
diff
changeset
|
1 // This file (FrmMainWindow.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2008, 2009 IBBoard. |
0 | 2 // |
19
a191d0655f55
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
18
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
0 | 4 using System; |
103
1bd748721040
* Resolve conflict of System.Action vs Gtk.Action
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
5 using System.Collections; |
0 | 6 using System.Collections.Generic; |
7 using System.Configuration; | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
8 using System.IO; |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
9 using GLib; |
13 | 10 using Gtk; |
11 using IBBoard; | |
0 | 12 using IBBoard.Commands; |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
13 using IBBoard.CustomMath; |
12
685532d43a96
Re #88: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
10
diff
changeset
|
14 using IBBoard.GtkSharp; |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
15 using IBBoard.GtkSharp.Translatable; |
0 | 16 using IBBoard.IO; |
13 | 17 using IBBoard.Lang; |
18 using IBBoard.Logging; | |
0 | 19 using IBBoard.WarFoundry.API; |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
20 using IBBoard.WarFoundry.API.Commands; |
28 | 21 using IBBoard.WarFoundry.API.Exporters; |
0 | 22 using IBBoard.WarFoundry.API.Factories; |
13 | 23 using IBBoard.WarFoundry.API.Factories.Xml; |
24 using IBBoard.WarFoundry.API.Objects; | |
0 | 25 using IBBoard.WarFoundry.API.Savers; |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
26 using IBBoard.WarFoundry.GUI.GTK.Widgets; |
0 | 27 using IBBoard.Xml; |
28 using log4net; | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
29 using WFObjects = IBBoard.WarFoundry.API.Objects; |
108 | 30 using IBBoard.WarFoundry.API.Savers.Xml; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
31 using IBBoard.WarFoundry.API.Objects.Requirement; |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
32 using System.Text; |
0 | 33 |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
34 namespace IBBoard.WarFoundry.GUI.GTK |
21 | 35 { |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
36 public partial class FrmMainWindow: TranslatableWindowWithActions |
0 | 37 { |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
38 private static readonly string VALIDATION_RESULTS_KEY = "WarFoundryValidationFailureMessages"; |
0 | 39 private static readonly string AppTitle = "WarFoundry"; |
13 | 40 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6; |
41 private Preferences preferences; | |
42 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow)); | |
0 | 43 private CommandStack commandStack; |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
44 private Dictionary<WFObjects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<WFObjects.Unit,UnitDisplayWidget>(); |
13 | 45 private ObjectAddDelegate UnitAddedMethod; |
46 private ObjectRemoveDelegate UnitRemovedMethod; | |
47 private DoubleValChangedDelegate PointsValueChangedMethod; | |
0 | 48 private StringValChangedDelegate UnitNameChangedMethod; |
49 private GameSystem system; | |
50 private string loadedArmyPath; | |
51 private MenuToolButton undoMenuButton, redoMenuButton; | |
21 | 52 |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
53 public static void Main(string[] args) |
21 | 54 { |
13 | 55 try |
0 | 56 { |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
57 ExceptionManager.UnhandledException += HandleUnhandledException; |
0 | 58 Application.Init(); |
59 FrmMainWindow win = new FrmMainWindow(args); | |
60 win.Show(); | |
61 Application.Run(); | |
13 | 62 LogManager.GetLogger(typeof(FrmMainWindow)).Debug("Application ended"); |
63 } | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
64 catch (Exception ex) |
13 | 65 { |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
66 HandleUnhandledException(ex); |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
67 } |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
68 } |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
69 |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
70 private static void HandleUnhandledException(UnhandledExceptionArgs args) |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
71 { |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
72 object obj = args.ExceptionObject; |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
73 Exception ex = null; |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
74 |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
75 if (obj is Exception) |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
76 { |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
77 ex = (Exception)obj; |
0 | 78 } |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
79 else |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
80 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
81 ex = new Exception("GLib returned unexpected exception object type " + obj.GetType()); |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
82 } |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
83 |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
84 HandleUnhandledException(ex); |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
85 } |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
86 |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
87 private static void HandleUnhandledException(Exception ex) |
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
88 { |
57
293d204e40db
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
89 string msg = String.Format("({0}) {1}", ex.GetType().FullName, ex.Message); |
293d204e40db
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
90 LogManager.GetLogger(typeof(FrmMainWindow)).Fatal(msg, ex); |
47
07fd9f7b0dd1
Re #79: Make use of GTK# callback for exceptions
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
91 MessageDialog dialog = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, "An unhandled exception occurred. Please check the log for more details."); |
57
293d204e40db
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
92 dialog.Run(); |
64
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
93 dialog.Hide(); |
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
94 dialog.Dispose(); |
0 | 95 } |
21 | 96 |
0 | 97 public FrmMainWindow() : this(new string[0]) |
98 { | |
99 //Do nothing extra | |
100 } | |
21 | 101 |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
102 public FrmMainWindow(string[] args) : base(Gtk.WindowType.Toplevel) |
0 | 103 { |
104 logger.Info("Opening FrmMainWindow"); | |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
105 Build(); |
0 | 106 //Replace the undo/redo buttons with menu versions, which Monodevelop's GUI editor doesn't currently support |
107 redoMenuButton = new MenuToolButton("gtk-redo"); | |
82
fb16ca1cb52b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
81
diff
changeset
|
108 redoMenuButton.Name = "bttnRedo"; |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
109 redoMenuButton.Clicked += redoTBButtonActivated; |
78
e63209ab2cfa
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
110 redoMenuButton.Sensitive = false; |
0 | 111 toolbar.Insert(redoMenuButton, CATEGORY_BUTTON_SEPARATOR_INDEX); |
112 undoMenuButton = new MenuToolButton("gtk-undo"); | |
82
fb16ca1cb52b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
81
diff
changeset
|
113 undoMenuButton.Name = "bttnUndo"; |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
114 undoMenuButton.Clicked += undoTBButtonActivated; |
78
e63209ab2cfa
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
115 undoMenuButton.Sensitive = false; |
0 | 116 toolbar.Insert(undoMenuButton, CATEGORY_BUTTON_SEPARATOR_INDEX); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
117 toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX - 1]); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
118 toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX - 2]); |
0 | 119 toolbar.ShowAll(); |
21 | 120 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
121 TreeViewColumn mainColumn = new TreeViewColumn(); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
122 CellRendererText mainCell = new CellRendererText(); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
123 mainColumn.PackStart(mainCell, true); |
0 | 124 treeUnits.AppendColumn(mainColumn); |
125 mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderCategoryTreeObjectName)); | |
126 treeUnits.Model = new TreeStore(typeof(WarFoundryObject)); | |
127 logger.Debug("Loading preferences"); | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
128 Preferences = new Preferences("WarFoundry-GTK"); |
0 | 129 logger.Debug("Loading translations"); |
21 | 130 |
8
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
131 try |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
132 { |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
133 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString()); |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
134 } |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
135 catch (TranslationLoadException ex) |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
136 { |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
137 logger.Error(ex); |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
138 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, ex.Message); |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
139 dialog.Title = "Translation loading failed"; |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
140 dialog.Run(); |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
141 dialog.Destroy(); |
20c5fd0bb79d
Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents:
6
diff
changeset
|
142 } |
21 | 143 |
13 | 144 logger.Debug("Initialising"); |
145 commandStack = new CommandStack(); | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
146 commandStack.CommandStackUpdated += new MethodInvoker(commandStack_CommandStackUpdated); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
147 WarFoundryCore.GameSystemChanged += new GameSystemChangedDelegate(OnGameSystemChanged); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
148 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(OnArmyChanged); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
149 Destroyed += new EventHandler(OnWindowDestroyed); |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
150 Translation.TranslationChanged += Retranslate; |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
151 Translate(); |
13 | 152 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded); |
153 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved); | |
154 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged); | |
0 | 155 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged); |
32
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
156 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished; |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
157 SetStatusBarText(); |
21 | 158 |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
159 LoadFilesFromArgs(args); |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
160 } |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
161 |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
162 private void LoadFilesFromArgs(string[] args) |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
163 { |
15
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
164 logger.Debug("Initialising complete - seeing if we can load default army or system"); |
0 | 165 if (args.Length == 1) |
166 { | |
21 | 167 logger.Debug("Attempting to load from file"); |
0 | 168 FileInfo file = new FileInfo(args[0]); |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
169 |
0 | 170 try |
171 { | |
5 | 172 ICollection<IWarFoundryObject> objects = WarFoundryLoader.GetDefault().LoadFile(file); |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
173 |
5 | 174 if (objects.Count == 1) |
0 | 175 { |
5 | 176 List<IWarFoundryObject> objectList = new List<IWarFoundryObject>(); |
177 objectList.AddRange(objects); | |
178 IWarFoundryObject loadedObject = objectList[0]; | |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
179 |
5 | 180 if (loadedObject is Army) |
181 { | |
182 WarFoundryCore.CurrentArmy = (Army)loadedObject; | |
183 logger.InfoFormat("Loaded army from {0}", file.FullName); | |
184 } | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
185 else |
5 | 186 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
187 if (loadedObject is GameSystem) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
188 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
189 WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
190 logger.InfoFormat("Loaded game system from {0}", file.FullName); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
191 } |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
192 |
5 | 193 } |
0 | 194 } |
195 } | |
196 catch (InvalidFileException ex) | |
197 { | |
198 //TODO: show error dialog | |
199 logger.Error(ex); | |
200 } | |
201 } | |
202 else | |
203 { | |
204 string gameSystemID = Preferences.GetStringProperty("currSystem"); | |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
205 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
206 if (gameSystemID != null && !"".Equals(gameSystemID)) |
0 | 207 { |
208 logger.Debug("Attempting to load current game system from properties"); | |
209 GameSystem sys = WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID); | |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
210 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
211 if (sys != null) |
0 | 212 { |
213 WarFoundryCore.CurrentGameSystem = sys; | |
214 logger.InfoFormat("Loaded game system {0} from properties", gameSystemID); | |
215 } | |
216 } | |
217 } | |
218 } | |
21 | 219 |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
220 protected override void Translate() |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
221 { |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
222 base.Translate(); |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
223 SetAppTitle(); |
82
fb16ca1cb52b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
81
diff
changeset
|
224 treeUnits.GetColumn(0).Title = Translation.GetTranslation("armyCategoryColumnTitle", "categories"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
225 RebuildUndoRedoMenus(); |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
226 } |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
227 |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
228 private void Retranslate() |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
229 { |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
230 Translate(); |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
231 } |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
232 |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
233 public override void Dispose() |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
234 { |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
235 Translation.TranslationChanged -= Retranslate; |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
236 base.Dispose(); |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
237 } |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
95
diff
changeset
|
238 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
239 private void FileLoadingFinished(List<FileLoadFailure> failures) |
32
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
240 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
241 foreach (FileLoadFailure failure in failures) |
32
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
242 { |
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
243 logger.Warn("Failed to load " + failure.FailedFile.FullName + ": " + failure.Message); |
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
244 } |
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
245 } |
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
246 |
0 | 247 private void RenderCategoryTreeObjectName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) |
248 { | |
249 object o = model.GetValue(iter, 0); | |
21 | 250 |
0 | 251 if (o is ArmyCategory) |
252 { | |
253 ArmyCategory c = (ArmyCategory)o; | |
254 string name = ""; | |
21 | 255 |
32
eab45344cd56
Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
30
diff
changeset
|
256 if (!Preferences.GetBooleanProperty("ShowCatPercentage")) |
0 | 257 { |
135
fda46380dd68
Re #329: "Points" system should be used in UI
IBBoard <dev@ibboard.co.uk>
parents:
125
diff
changeset
|
258 name = Translation.GetTranslation("categoryTreeCatName", "{0} - {1}{2}", c.Name, c.Points, WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(c.Points)); |
0 | 259 } |
260 else | |
261 { | |
135
fda46380dd68
Re #329: "Points" system should be used in UI
IBBoard <dev@ibboard.co.uk>
parents:
125
diff
changeset
|
262 name = Translation.GetTranslation("categoryTreeCatNamePercentage", "{0} - {1}{3} ({2}%)", c.Name, c.Points, (c.ParentArmy.Points > 0 ? Math.Round((c.Points / c.ParentArmy.Points) * 100) : 0), WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(c.Points)); |
0 | 263 } |
21 | 264 |
0 | 265 (cell as CellRendererText).Text = name; |
266 } | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
267 else |
0 | 268 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
269 if (o is WFObjects.Unit) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
270 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
271 WFObjects.Unit u = (WFObjects.Unit)o; |
135
fda46380dd68
Re #329: "Points" system should be used in UI
IBBoard <dev@ibboard.co.uk>
parents:
125
diff
changeset
|
272 string name = Translation.GetTranslation("unitTreeCatName", "{0} - {1}{2}", u.Name, u.Points, WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(u.Points)); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
273 (cell as CellRendererText).Text = name; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
274 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
275 |
0 | 276 } |
277 } | |
21 | 278 |
0 | 279 private void OnWindowDestroyed(object source, EventArgs args) |
280 { | |
281 logger.Info("Exiting"); | |
282 Application.Quit(); | |
283 } | |
21 | 284 |
0 | 285 private void OnUnitNameChanged(WarFoundryObject val, string oldValue, string newValue) |
286 { | |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
287 WFObjects.Unit unit = (WFObjects.Unit)val; |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
288 logger.DebugFormat("Unit name changed for {0} - now called {1}", unit.ID, unit.Name); |
0 | 289 UnitDisplayWidget widget; |
290 unitToWidgetMap.TryGetValue(unit, out widget); | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
291 |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
292 if (widget != null) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
293 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
294 unitsNotebook.SetTabLabel(widget, NotebookUtil.CreateNotebookTabLabelWithClose(unitsNotebook, widget, unit.Name)); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
295 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
296 |
41
a32b6bb7f1eb
Fixes #129: Change notifications are slow in GTK app
IBBoard <dev@ibboard.co.uk>
parents:
36
diff
changeset
|
297 treeUnits.QueueDraw(); |
0 | 298 } |
21 | 299 |
0 | 300 private void OnUnitAdded(WarFoundryObject val) |
301 { | |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
302 WFObjects.Unit unit = (WFObjects.Unit)val; |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
303 unit.NameChanged += UnitNameChangedMethod; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
304 unit.PointsValueChanged += HandleUnitPointsValueChanged; |
0 | 305 AddUnitToTree(unit); |
306 } | |
21 | 307 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
308 private void HandleUnitPointsValueChanged(WarFoundryObject obj, double oldValue, double newValue) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
309 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
310 treeUnits.QueueDraw(); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
311 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
312 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
313 private void AddUnitToTree(WFObjects.Unit unit) |
0 | 314 { |
315 TreeStore model = (TreeStore)treeUnits.Model; | |
316 TreeIter iter; | |
317 model.GetIterFirst(out iter); | |
21 | 318 |
0 | 319 do |
320 { | |
321 object obj = model.GetValue(iter, 0); | |
21 | 322 |
0 | 323 if (obj is ArmyCategory) |
324 { | |
325 ArmyCategory cat = (ArmyCategory)obj; | |
21 | 326 |
0 | 327 if (cat.Equals(unit.Category)) |
328 { | |
329 model.AppendValues(iter, unit); | |
330 TreePath path = model.GetPath(iter); | |
331 treeUnits.ExpandToPath(path); | |
332 } | |
333 } | |
334 } | |
335 while (model.IterNext(ref iter)); | |
336 } | |
21 | 337 |
0 | 338 private void OnUnitRemoved(WarFoundryObject obj) |
339 { | |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
340 WFObjects.Unit unit = (WFObjects.Unit)obj; |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
341 unit.NameChanged -= UnitNameChangedMethod; |
0 | 342 RemoveUnitFromTree(unit); |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
343 RemoveUnitTab(unit); |
0 | 344 } |
21 | 345 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
346 private void RemoveUnitFromTree(WFObjects.Unit unit) |
0 | 347 { |
348 TreeStore model = (TreeStore)treeUnits.Model; | |
349 TreeIter iter; | |
350 model.GetIterFirst(out iter); | |
351 bool removed = false; | |
21 | 352 |
0 | 353 do |
354 { | |
355 object obj = model.GetValue(iter, 0); | |
21 | 356 |
0 | 357 if (obj is ArmyCategory) |
358 { | |
359 ArmyCategory cat = (ArmyCategory)obj; | |
21 | 360 |
0 | 361 if (unit.Category == null || cat.Equals(unit.Category)) |
362 { | |
363 TreeIter innerIter; | |
364 model.IterChildren(out innerIter, iter); | |
21 | 365 |
0 | 366 do |
367 { | |
368 object innerObj = model.GetValue(innerIter, 0); | |
21 | 369 |
0 | 370 if (unit.Equals(innerObj)) |
371 { | |
372 model.Remove(ref innerIter); | |
373 removed = true; | |
374 break; | |
375 } | |
376 } | |
377 while (model.IterNext(ref innerIter)); | |
21 | 378 |
0 | 379 if (removed) |
380 { | |
381 break; | |
382 } | |
383 } | |
384 } | |
385 } | |
386 while (model.IterNext(ref iter)); | |
387 } | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
388 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
389 private void RemoveUnitTab(WFObjects.Unit unit) |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
390 { |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
391 UnitDisplayWidget widget = DictionaryUtils.GetValue(unitToWidgetMap, unit); |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
392 |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
393 if (widget != null) |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
394 { |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
395 unitsNotebook.Remove(widget); |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
396 } |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
397 } |
21 | 398 |
0 | 399 private void OnPointsValueChanged(WarFoundryObject obj, double before, double after) |
400 { | |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
401 SetStatusBarText(); |
0 | 402 } |
21 | 403 |
0 | 404 public Preferences Preferences |
405 { | |
406 get { return preferences; } | |
21 | 407 set { preferences = value; } |
0 | 408 } |
21 | 409 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
410 protected void OnDeleteEvent(object sender, DeleteEventArgs a) |
0 | 411 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
412 Application.Quit(); |
0 | 413 a.RetVal = true; |
414 } | |
415 | |
416 protected virtual void OnExitActivated(object sender, System.EventArgs e) | |
417 { | |
418 Application.Quit(); | |
419 } | |
420 | |
421 protected virtual void OnCreateArmyActivated(object sender, System.EventArgs e) | |
422 { | |
423 CreateNewArmy(); | |
424 } | |
425 | |
426 protected virtual void OnReloadFilesActivated(object sender, System.EventArgs e) | |
427 { | |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
428 WarFoundryLoader.GetDefault().LoadFiles(); |
0 | 429 } |
430 | |
431 protected virtual void OnSaveArmyAsActivated(object sender, System.EventArgs e) | |
432 { | |
433 SaveCurrentArmyAs(); | |
434 } | |
435 | |
436 protected virtual void OnCloseArmyActivated(object sender, System.EventArgs e) | |
437 { | |
438 CloseCurrentArmy(); | |
439 } | |
440 | |
441 protected virtual void OnOpenArmyActivated(object sender, System.EventArgs e) | |
442 { | |
443 OpenArmy(); | |
444 } | |
445 | |
446 protected virtual void OnSaveArmyActivated(object sender, System.EventArgs e) | |
447 { | |
33 | 448 SaveCurrentArmyOrSaveAs(); |
0 | 449 } |
21 | 450 |
0 | 451 protected virtual void OnAddUnitActivated(object sender, System.EventArgs e) |
452 { | |
453 if (sender is ToolButton) | |
454 { | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
455 ToolButton toolButton = (ToolButton)sender; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
456 Category cat = (Category)toolButton.Data["Category"]; |
21 | 457 |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
458 if (cat != null) |
0 | 459 { |
460 logger.DebugFormat("Show FrmNewUnit for {0}", cat.Name); | |
461 FrmNewUnit newUnit = new FrmNewUnit(WarFoundryCore.CurrentArmy.Race, cat, WarFoundryCore.CurrentArmy); | |
462 ResponseType response = (ResponseType)newUnit.Run(); | |
463 newUnit.Hide(); | |
21 | 464 |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
465 if (response == ResponseType.Ok) |
0 | 466 { |
14
abbf8a3ac431
Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
467 CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, WarFoundryCore.CurrentArmy.GetCategory(cat)); |
0 | 468 commandStack.Execute(cmd); |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
469 ShowUnitWidget(cmd.Unit); |
0 | 470 } |
21 | 471 |
0 | 472 newUnit.Dispose(); |
473 } | |
474 } | |
475 } | |
21 | 476 |
13 | 477 public CommandStack CommandStack |
478 { | |
479 get { return commandStack; } | |
0 | 480 } |
21 | 481 |
0 | 482 private void SetAppTitle() |
483 { | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
484 if (WarFoundryCore.CurrentArmy != null) |
0 | 485 { |
486 Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name + " - " + WarFoundryCore.CurrentArmy.Name; | |
487 } | |
488 else | |
489 { | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
490 if (WarFoundryCore.CurrentGameSystem != null) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
491 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
492 Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
493 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
494 else |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
495 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
496 Title = AppTitle; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
497 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
498 |
0 | 499 } |
500 } | |
21 | 501 |
0 | 502 private void OnGameSystemChanged(GameSystem oldSys, GameSystem newSys) |
503 { | |
504 system = newSys; | |
505 SetAppTitle(); | |
506 RemoveCategoryButtons(); | |
21 | 507 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
508 if (system != null) |
0 | 509 { |
510 AddCategoryButtons(system.Categories); | |
151
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
511 logger.DebugFormat("Game system set to {0} with ID {1}", system.Name, system.ID); |
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
512 } |
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
513 else |
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
514 { |
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
515 logger.Debug("Game system set to null"); |
0 | 516 } |
517 } | |
21 | 518 |
0 | 519 private void OnArmyChanged(Army oldArmy, Army newArmy) |
520 { | |
521 loadedArmyPath = null; | |
522 SetAppTitle(); | |
523 SetArmyTree(newArmy); | |
21 | 524 |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
525 if (oldArmy != null) |
13 | 526 { |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
527 oldArmy.UnitAdded -= UnitAddedMethod; |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
528 oldArmy.UnitRemoved -= UnitRemovedMethod; |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
529 oldArmy.PointsValueChanged -= PointsValueChangedMethod; |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
530 oldArmy.NameChanged -= OnArmyNameChanged; |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
531 oldArmy.MaxPointsValueChanged -= OnMaxPointsValueChanged; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
532 oldArmy.ArmyCompositionChanged -= HandleArmyCompositionChanged; |
0 | 533 } |
21 | 534 |
0 | 535 unitToWidgetMap.Clear(); |
21 | 536 |
0 | 537 while (unitsNotebook.NPages > 0) |
538 { | |
539 unitsNotebook.RemovePage(0); | |
540 } | |
21 | 541 |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
542 if (newArmy == null) |
13 | 543 { |
544 DisableCategoryButtons(); | |
545 } | |
546 else | |
547 { | |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
548 newArmy.UnitAdded += UnitAddedMethod; |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
549 newArmy.UnitRemoved += UnitRemovedMethod; |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
550 newArmy.PointsValueChanged += PointsValueChangedMethod; |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
551 newArmy.NameChanged += OnArmyNameChanged; |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
552 newArmy.MaxPointsValueChanged += OnMaxPointsValueChanged; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
553 newArmy.ArmyCompositionChanged += HandleArmyCompositionChanged; |
13 | 554 //TODO: Clear all buttons |
555 EnableCategoryButtons(); | |
556 | |
557 if (newArmy.Race.HasCategoryOverrides()) | |
558 { | |
559 RemoveCategoryButtons(); | |
560 AddCategoryButtons(newArmy.Race.Categories); | |
561 } | |
0 | 562 } |
21 | 563 |
43
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
564 bool nonNullNewArmy = (newArmy != null); |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
565 miCloseArmy.Sensitive = nonNullNewArmy; |
4e127ce8682f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
42
diff
changeset
|
566 miSaveArmyAs.Sensitive = nonNullNewArmy; |
81
3ff8e10de45a
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
567 miExportArmyAs.Sensitive = nonNullNewArmy; |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
568 miEditArmy.Sensitive = nonNullNewArmy; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
569 treeUnits.Visible = nonNullNewArmy; |
33 | 570 loadedArmyPath = null; |
0 | 571 //New army has no changes, so we can't save it |
572 miSaveArmy.Sensitive = false; | |
82
fb16ca1cb52b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
81
diff
changeset
|
573 bttnSaveArmy.Sensitive = false; |
13 | 574 |
575 CommandStack.Reset(); | |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
576 SetStatusBarText(); |
0 | 577 } |
21 | 578 |
151
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
579 private void OnArmyNameChanged(WarFoundryObject obj, string oldValue, string newValue) |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
580 { |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
581 SetAppTitle(); |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
582 } |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
583 |
151
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
584 private void OnMaxPointsValueChanged(WarFoundryObject obj, int oldValue, int newValue) |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
585 { |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
586 SetStatusBarText(); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
587 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
588 |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
589 private void HandleArmyCompositionChanged() |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
590 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
591 SetStatusBarText(); |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
592 } |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
593 |
0 | 594 private void SetArmyTree(Army army) |
595 { | |
596 logger.Debug("Resetting tree"); | |
597 TreeStore store = (TreeStore)treeUnits.Model; | |
598 store.Clear(); | |
599 TreeIter iter; | |
21 | 600 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
601 if (army != null) |
0 | 602 { |
603 logger.Debug("Loading in categories to tree"); | |
21 | 604 |
0 | 605 foreach (ArmyCategory cat in army.Categories) |
606 { | |
607 logger.DebugFormat("Append category {0}", cat.Name); | |
608 iter = store.AppendValues(cat); | |
21 | 609 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
610 foreach (WFObjects.Unit unit in cat.GetUnits()) |
0 | 611 { |
612 store.AppendValues(iter, unit); | |
21 | 613 } |
0 | 614 } |
21 | 615 |
0 | 616 logger.Debug("Finished loading tree categories"); |
617 } | |
618 } | |
21 | 619 |
0 | 620 private void DisableCategoryButtons() |
621 { | |
622 SetCategoryButtonsSensitive(false); | |
623 } | |
21 | 624 |
0 | 625 private void EnableCategoryButtons() |
626 { | |
627 SetCategoryButtonsSensitive(true); | |
628 } | |
21 | 629 |
0 | 630 private void SetCategoryButtonsSensitive(bool state) |
631 { | |
632 int toolbarButtonCount = toolbar.Children.Length - 1; | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
633 logger.Debug("Last button index: " + toolbarButtonCount); |
21 | 634 |
0 | 635 for (int i = toolbarButtonCount; i > CATEGORY_BUTTON_SEPARATOR_INDEX; i--) |
636 { | |
637 logger.DebugFormat("Setting button {0} state to {1}", i, state); | |
638 toolbar.Children[i].Sensitive = state; | |
639 } | |
640 } | |
21 | 641 |
0 | 642 private void RemoveCategoryButtons() |
643 { | |
644 int toolbarButtonCount = toolbar.Children.Length - 1; | |
21 | 645 |
0 | 646 for (int i = toolbarButtonCount; i > CATEGORY_BUTTON_SEPARATOR_INDEX; i--) |
647 { | |
648 toolbar.Remove(toolbar.Children[i]); | |
649 } | |
650 } | |
21 | 651 |
0 | 652 private void AddCategoryButtons(Category[] cats) |
653 { | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
654 if (cats != null && cats.Length > 0) |
0 | 655 { |
656 logger.DebugFormat("Toolbar button count: {0}. Adding {1} categories.", toolbar.Children.Length, cats.Length); | |
21 | 657 |
0 | 658 foreach (Category cat in cats) |
659 { | |
660 ToolButton button = new ToolButton("gtk-add"); | |
661 button.Label = cat.Name; | |
83
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
662 button.TooltipText = Translation.GetTranslation("bttnCreateFromCat", "{0}", cat.Name); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
663 button.Data["Category"] = cat; |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
664 button.Clicked += new System.EventHandler(OnAddUnitActivated); |
0 | 665 toolbar.Insert(button, -1); |
666 } | |
667 } | |
21 | 668 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
669 toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX].Visible = cats != null && cats.Length > 0; |
21 | 670 |
0 | 671 toolbar.ShowAll(); |
672 } | |
21 | 673 |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
674 private void SetStatusBarText() |
0 | 675 { |
99
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
676 if (WarFoundryCore.CurrentArmy != null) |
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
677 { |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
678 statusbar.Push(1, GetPointsText()); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
679 SetValidationText(); |
99
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
680 } |
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
681 else |
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
682 { |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
683 statusbar.Push(1, ""); |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
684 SetBlankValidationText(); |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
685 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
686 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
687 |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
688 private string GetPointsText() |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
689 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
690 int maxPts = WarFoundryCore.CurrentArmy.MaxPoints; |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
691 string maxPtsAbbrev = WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(WarFoundryCore.CurrentArmy.MaxPoints); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
692 double points = WarFoundryCore.CurrentArmy.Points; |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
693 string ptsAbbrev = WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(WarFoundryCore.CurrentArmy.Points); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
694 return Translation.GetTranslation("statusPanelPoints", "{0}{2} of {1}{3}", points, maxPts, ptsAbbrev, maxPtsAbbrev); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
695 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
696 |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
697 private void SetValidationText() |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
698 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
699 if (WarFoundryCore.CurrentGameSystem != null && WarFoundryCore.CurrentGameSystem.WarnOnError) |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
700 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
701 SetValidationTextAndColour(); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
702 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
703 else |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
704 { |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
705 SetBlankValidationText(); |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
706 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
707 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
708 |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
709 private void SetValidationTextAndColour() |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
710 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
711 ICollection<string> failureMessages; |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
712 Validation result = RequirementHandler.ValidateArmy(WarFoundryCore.CurrentArmy, out failureMessages); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
713 string pluralHack = (failureMessages.Count == 1 ? "" : "s"); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
714 lblValidationWarning.Text = String.Format("{0} validation warning{1}", failureMessages.Count, pluralHack); |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
715 lblValidationWarning.Data[VALIDATION_RESULTS_KEY] = failureMessages; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
716 |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
717 if (Validates.AsOkay(result)) |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
718 { |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
719 lblValidationWarning.ModifyFg(StateType.Normal, Gdk.Color.Zero); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
720 } |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
721 else |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
722 { |
149
45c2485f37c0
* Initialise variable - xbuild is more picky than MonoDevelop
IBBoard <dev@ibboard.co.uk>
parents:
142
diff
changeset
|
723 Gdk.Color red = Gdk.Color.Zero; |
140
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
724 Gdk.Color.Parse("#cc0000", ref red); |
2b9fabd65309
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
138
diff
changeset
|
725 lblValidationWarning.ModifyFg(StateType.Normal, red); |
99
8777e4f64d8e
Fixes #335: Show current points total in status bar
IBBoard <dev@ibboard.co.uk>
parents:
98
diff
changeset
|
726 } |
0 | 727 } |
21 | 728 |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
729 private void SetBlankValidationText() |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
730 { |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
731 lblValidationWarning.Text = ""; |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
732 lblValidationWarning.Data[VALIDATION_RESULTS_KEY] = new string[0]; |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
733 lblValidationWarning.ModifyFg(StateType.Normal, Gdk.Color.Zero); |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
734 } |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
735 |
13 | 736 private void commandStack_CommandStackUpdated() |
737 { | |
738 undoMenuButton.Sensitive = commandStack.CanUndo(); | |
739 miUndo.Sensitive = undoMenuButton.Sensitive; | |
740 redoMenuButton.Sensitive = commandStack.CanRedo(); | |
741 miRedo.Sensitive = redoMenuButton.Sensitive; | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
742 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
743 RebuildUndoRedoMenus(); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
744 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
745 bttnSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy != null; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
746 miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy != null; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
747 } |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
748 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
749 private void RebuildUndoRedoMenus() |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
750 { |
0 | 751 int redoLength = commandStack.RedoLength; |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
752 int maxRedo = Math.Min(10, redoLength); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
753 |
13 | 754 if (redoLength > 0) |
755 { | |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
756 Menu menu = new Menu(); |
13 | 757 Command com; |
758 MenuItem mi; | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
759 |
13 | 760 for (int i = 0; i < maxRedo; i++) |
761 { | |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
762 com = commandStack.PeekRedoCommand(i + 1); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
763 |
13 | 764 if (com == null) |
765 { | |
21 | 766 break; |
13 | 767 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
768 |
13 | 769 mi = new MenuItem(com.Description); |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
770 mi.Activated += new EventHandler(RedoMenuActivated); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
771 menu.Append(mi); |
13 | 772 } |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
773 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
774 menu.ShowAll(); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
775 redoMenuButton.Menu = menu; |
13 | 776 } |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
777 else |
13 | 778 { |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
779 redoMenuButton.Menu = null; |
13 | 780 } |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
781 |
13 | 782 int undoLength = commandStack.UndoLength; |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
783 int maxUndo = Math.Min(10, undoLength); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
784 |
13 | 785 if (undoLength > 0) |
786 { | |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
787 Menu menu = new Menu(); |
13 | 788 Command com; |
789 MenuItem mi; | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
790 |
13 | 791 for (int i = 0; i < maxUndo; i++) |
792 { | |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
793 com = commandStack.PeekUndoCommand(i + 1); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
794 |
13 | 795 if (com == null) |
796 { | |
21 | 797 break; |
13 | 798 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
799 |
13 | 800 mi = new MenuItem(com.UndoDescription); |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
801 mi.Activated += new EventHandler(UndoMenuActivated); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
802 menu.Add(mi); |
13 | 803 } |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
804 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
805 menu.ShowAll(); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
806 undoMenuButton.Menu = menu; |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
807 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
808 else |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
809 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
810 undoMenuButton.Menu = null; |
13 | 811 } |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
812 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
813 |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
814 private void RedoMenuActivated(object sender, EventArgs e) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
815 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
816 if (sender is MenuItem) |
13 | 817 { |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
818 MenuItem item = (MenuItem)sender; |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
819 //we know it's an redo menu item so find it's index and redo everything |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
820 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
821 int max = Arrays.IndexOf(((Menu)redoMenuButton.Menu).Children, item); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
822 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
823 if (max >= 0) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
824 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
825 for (int i = 0; i <= max; i++) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
826 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
827 commandStack.Redo(); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
828 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
829 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
830 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
831 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
832 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
833 private void UndoMenuActivated(object sender, EventArgs e) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
834 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
835 if (sender is MenuItem) |
0 | 836 { |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
837 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
838 MenuItem item = (MenuItem)sender; |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
839 //we know it's an undo menu item so find it's index and undo everything |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
840 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
841 int max = Arrays.IndexOf(((Menu)undoMenuButton.Menu).Children, item); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
842 |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
843 if (max >= 0) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
844 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
845 for (int i = 0; i <= max; i++) |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
846 { |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
847 commandStack.Undo(); |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
848 } |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
849 } |
0 | 850 } |
13 | 851 } |
852 | |
853 private bool SaveCurrentArmyOrSaveAs() | |
854 { | |
33 | 855 if (loadedArmyPath != null) |
13 | 856 { |
857 return SaveCurrentArmy(); | |
858 } | |
21 | 859 else |
13 | 860 { |
861 return SaveCurrentArmyAs(); | |
862 } | |
0 | 863 } |
21 | 864 |
0 | 865 private bool OpenArmy() |
866 { | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
867 string title = Translation.GetTranslation("openArmyDialog", "open army"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
868 string cancelText = Translation.GetTranslation("bttnCancel", "cancel"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
869 string openText = Translation.GetTranslation("bttnOpen", "open"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
870 FileChooserDialog fileDialog = new FileChooserDialog(title, this, FileChooserAction.Open, cancelText, ResponseType.Cancel, openText, ResponseType.Accept); |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
871 FileFilter filter = new FileFilter(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
872 filter.AddPattern("*.army"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
873 filter.Name = Translation.GetTranslation("armyFileFilter", "WarFoundry .army files"); |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
874 fileDialog.AddFilter(filter); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
875 int response = fileDialog.Run(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
876 string filePath = null; |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
877 |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
878 if (response == (int)ResponseType.Accept) |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
879 { |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
880 filePath = fileDialog.Filename; |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
881 } |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
882 |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
883 fileDialog.Hide(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
884 fileDialog.Dispose(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
885 |
0 | 886 bool success = false; |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
887 |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
888 if (filePath != null) |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
889 { |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
890 FileInfo file = new FileInfo(filePath); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
891 Army army = null; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
892 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
893 try |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
894 { |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
895 army = WarFoundryLoader.GetDefault().LoadArmy(file); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
896 } |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
897 catch (Exception ex) |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
898 { |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
899 logger.Error("Error while loading army file " + filePath, ex); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
900 } |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
901 |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
902 if (army != null) |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
903 { |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
904 logger.Debug("Loaded army " + army.ID); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
905 success = true; |
33 | 906 WarFoundryCore.CurrentArmy = army; |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
907 loadedArmyPath = filePath; |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
908 logger.Debug("Army loading complete"); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
909 } |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
910 else |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
911 { |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
912 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Translation.GetTranslation("OpenFailed", "File open failed. Please check log file")); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
913 dialog.Title = Translation.GetTranslation("OpenFailedTitle", "File open failed"); |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
914 dialog.Run(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
915 dialog.Hide(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
916 dialog.Dispose(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
917 } |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
918 } |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
919 else |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
920 { |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
921 logger.Debug("Army open requested but cancelled"); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
922 } |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
923 |
0 | 924 return success; |
13 | 925 } |
926 | |
927 private bool SaveCurrentArmy() | |
0 | 928 { |
929 bool success = false; | |
21 | 930 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
931 if (loadedArmyPath != null) |
0 | 932 { |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
933 success = SaveArmyToPath(WarFoundryCore.CurrentArmy, loadedArmyPath); |
0 | 934 } |
21 | 935 |
13 | 936 return success; |
937 } | |
938 | |
939 private bool SaveCurrentArmyAs() | |
940 { | |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
941 string title = Translation.GetTranslation("saveArmyDialog", "save army"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
942 string cancelText = Translation.GetTranslation("bttnCancel", "cancel"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
943 string saveText = Translation.GetTranslation("bttnSave", "save"); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
944 FileChooserDialog fileDialog = new FileChooserDialog(title, this, FileChooserAction.Save, cancelText, ResponseType.Cancel, saveText, ResponseType.Accept); |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
945 FileFilter filter = new FileFilter(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
946 filter.AddPattern("*.army"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
947 filter.Name = Translation.GetTranslation("armyFileFilter", "WarFoundry .army files"); |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
948 fileDialog.AddFilter(filter); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
949 int response = fileDialog.Run(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
950 string filePath = null; |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
951 |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
952 if (response == (int)ResponseType.Accept) |
13 | 953 { |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
954 filePath = fileDialog.Filename; |
13 | 955 } |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
956 |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
957 fileDialog.Hide(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
958 fileDialog.Dispose(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
959 |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
960 return SaveArmyToPath(WarFoundryCore.CurrentArmy, filePath); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
961 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
962 |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
963 private bool SaveArmyToPath(Army army, string filePath) |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
964 { |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
965 bool success = false; |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
966 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
967 if (filePath != null) |
13 | 968 { |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
969 bool saveSuccess = false; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
970 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
971 try |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
972 { |
106
41e82ba675dc
Re #324: Add saving of Race and System data to files
IBBoard <dev@ibboard.co.uk>
parents:
105
diff
changeset
|
973 saveSuccess = WarFoundrySaver.GetSaver().Save(filePath, WarFoundryCore.CurrentArmy); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
974 } |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
975 catch (Exception ex) |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
976 { |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
977 logger.Error("Error while saving army file to " + filePath, ex); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
978 } |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
979 |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
980 if (saveSuccess) |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
981 { |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
982 miSaveArmy.Sensitive = false; |
82
fb16ca1cb52b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
81
diff
changeset
|
983 bttnSaveArmy.Sensitive = false; |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
984 CommandStack.setCleanMark(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
985 loadedArmyPath = filePath; |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
986 success = true; |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
987 } |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
988 else |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
989 { |
151
83b19b57cba1
Re #58: Remove LogNotifier from API
IBBoard <dev@ibboard.co.uk>
parents:
150
diff
changeset
|
990 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, Translation.GetTranslation("SaveFailed", "File save failed. Please check log file")); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
991 dialog.Title = Translation.GetTranslation("SaveFailedTitle", "File save failed"); |
25
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
992 dialog.Run(); |
01ddadfa9653
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
23
diff
changeset
|
993 dialog.Hide(); |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
994 dialog.Dispose(); |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
995 } |
21 | 996 } |
23
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
997 //else user cancelled |
d661cb257511
Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents:
21
diff
changeset
|
998 |
21 | 999 return success; |
0 | 1000 } |
21 | 1001 |
13 | 1002 private bool CloseCurrentArmy() |
1003 { | |
42
35ad26ac59c0
Fixes #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents:
41
diff
changeset
|
1004 if (WarFoundryCore.CurrentArmy != null) |
13 | 1005 { |
1006 bool canClose = false; | |
1007 | |
1008 if (CommandStack.IsDirty()) | |
0 | 1009 { |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1010 string message = Translation.GetTranslation("SaveChangesQuestion", "Save changes to army before closing?", WarFoundryCore.CurrentArmy.Name); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1011 MessageDialog dia = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.None, message); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1012 dia.AddButton(Translation.GetTranslation("bttnDiscard", "lose changes"), ResponseType.No); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1013 Button button = (Button)dia.AddButton(Translation.GetTranslation("bttnCancel", "cancel"), ResponseType.Cancel); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1014 button.Image = new Image("gtk-cancel", IconSize.Button); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1015 button = (Button)dia.AddButton(Translation.GetTranslation("bttnSave", "save"), ResponseType.Yes); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1016 button.Image = new Image("gtk-save", IconSize.Button); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
1017 dia.Title = Translation.GetTranslation("SaveChangesTitle", "Save changes?"); |
0 | 1018 ResponseType dr = (ResponseType)dia.Run(); |
27
83c8945edac2
Re #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents:
26
diff
changeset
|
1019 dia.Hide(); |
83c8945edac2
Re #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents:
26
diff
changeset
|
1020 dia.Dispose(); |
0 | 1021 |
13 | 1022 if (dr == ResponseType.Yes) |
0 | 1023 { |
1024 //They want to save so try to save it or prompt for save as | |
13 | 1025 //If they cancel the save as then assume they don't want to close |
1026 canClose = SaveCurrentArmyOrSaveAs(); | |
1027 } | |
0 | 1028 else |
1029 { | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1030 if (dr == ResponseType.No) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1031 { |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1032 //They don't care about their changes |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1033 canClose = true; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1034 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1035 else |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1036 { |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1037 //Assume cancel or close with the X button |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1038 canClose = false; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1039 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1040 |
0 | 1041 } |
13 | 1042 } |
1043 else | |
1044 { | |
1045 //Nothing has changed so we can safely close | |
1046 canClose = true; | |
1047 } | |
1048 | |
1049 if (canClose) | |
0 | 1050 { |
13 | 1051 //do close |
1052 WarFoundryCore.CurrentArmy = null; | |
1053 return true; | |
1054 } | |
1055 else | |
1056 { | |
1057 return false; | |
1058 } | |
1059 } | |
1060 else | |
1061 { | |
1062 //pretend we succeeded | |
1063 return true; | |
1064 } | |
1065 } | |
1066 | |
1067 private void CreateNewArmy() | |
0 | 1068 { |
1069 logger.Debug("Create new army"); | |
1070 FrmNewArmy newArmy = new FrmNewArmy(WarFoundryCore.CurrentGameSystem); | |
1071 ResponseType type = (ResponseType)newArmy.Run(); | |
1072 newArmy.Hide(); | |
21 | 1073 |
0 | 1074 if (type == ResponseType.Ok) |
13 | 1075 { |
1076 if (CloseCurrentArmy()) | |
0 | 1077 { |
1078 WarFoundryCore.CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize); | |
1079 } | |
1080 } | |
1081 else | |
1082 { | |
1083 logger.Debug("Create new army cancelled"); | |
1084 } | |
21 | 1085 |
13 | 1086 newArmy.Destroy(); |
0 | 1087 } |
21 | 1088 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1089 protected virtual void undoTBButtonActivated(object sender, System.EventArgs e) |
0 | 1090 { |
1091 CommandStack.Undo(); | |
1092 } | |
1093 | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1094 protected virtual void redoTBButtonActivated(object sender, System.EventArgs e) |
0 | 1095 { |
1096 CommandStack.Redo(); | |
1097 } | |
1098 | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1099 protected virtual void saveTBButtonActivated(object sender, System.EventArgs e) |
0 | 1100 { |
33 | 1101 SaveCurrentArmyOrSaveAs(); |
0 | 1102 } |
1103 | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1104 protected virtual void openTBButtonActivated(object sender, System.EventArgs e) |
0 | 1105 { |
1106 OpenArmy(); | |
1107 } | |
1108 | |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1109 protected virtual void newTBButtonActivated(object sender, System.EventArgs e) |
0 | 1110 { |
1111 CreateNewArmy(); | |
1112 } | |
1113 | |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1114 protected virtual void ArmyRowActivated(object o, Gtk.RowActivatedArgs args) |
0 | 1115 { |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1116 object obj = TreeUtils.GetItemAtPath(treeUnits, args.Path); |
21 | 1117 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1118 if (obj is WFObjects.Unit) |
0 | 1119 { |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1120 WFObjects.Unit unit = (WFObjects.Unit)obj; |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1121 ShowUnitWidget(unit); |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1122 } |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1123 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1124 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1125 private void ShowUnitWidget(WFObjects.Unit unit) |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1126 { |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1127 UnitDisplayWidget widget; |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1128 unitToWidgetMap.TryGetValue(unit, out widget); |
21 | 1129 |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1130 if (widget != null) |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1131 { |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1132 logger.DebugFormat("Selecting existing page for " + unit.Name); |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1133 unitsNotebook.Page = unitsNotebook.PageNum(widget); |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1134 } |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1135 else |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1136 { |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1137 widget = new UnitDisplayWidget(unit, CommandStack); |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1138 logger.Debug("Adding page for " + unit.Name); |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1139 unitToWidgetMap[unit] = widget; |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1140 int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name); |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1141 logger.Debug("Page added at index " + pageNum); |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1142 unitsNotebook.ShowAll(); |
46
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1143 unitsNotebook.CurrentPage = pageNum; |
3314f6a46661
Fixes #138: Re-implement menu for undo/redo
IBBoard <dev@ibboard.co.uk>
parents:
45
diff
changeset
|
1144 unitsNotebook.SetTabReorderable(widget, true); |
15
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
1145 } |
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
1146 } |
28 | 1147 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1148 protected virtual void OnMiExportAsBasicHtmlActivated(object sender, System.EventArgs e) |
28 | 1149 { |
83
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1150 string exportArmyTitle = Translation.GetTranslation("exportBasicHtmlDialogTitle", "export army"); |
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1151 string cancelText = Translation.GetTranslation("exportBasicHtmlCancel", "cancel"); |
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1152 string exportText = Translation.GetTranslation("exportBasicHtmlExport", "export"); |
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1153 FileChooserDialog fileDialog = new FileChooserDialog(exportArmyTitle, this, FileChooserAction.Save, cancelText, ResponseType.Cancel, exportText, ResponseType.Accept); |
28 | 1154 FileFilter filter = new FileFilter(); |
1155 filter.AddPattern("*.html"); | |
83
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1156 filter.Name = Translation.GetTranslation("exportBasicHtmlHtmlFilter", "HTML pages (*.html)"); |
28 | 1157 fileDialog.AddFilter(filter); |
1158 int response = fileDialog.Run(); | |
1159 string filePath = null; | |
1160 | |
1161 if (response == (int)ResponseType.Accept) | |
1162 { | |
1163 filePath = fileDialog.Filename; | |
1164 } | |
1165 | |
1166 fileDialog.Hide(); | |
1167 fileDialog.Dispose(); | |
1168 | |
1169 if (filePath != null) | |
1170 { | |
1171 Army army = WarFoundryCore.CurrentArmy; | |
1172 logger.DebugFormat("Exporting {0} to {1} as basic HTML", army.Name, filePath); | |
1173 WarFoundryHtmlExporter.GetDefault().ExportArmy(army, filePath); | |
1174 } | |
1175 } | |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1176 |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1177 protected virtual void OnTreeUnitsPopupMenu(object o, Gtk.PopupMenuArgs args) |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1178 { |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1179 object selectedItem = TreeUtils.GetSelectedItem(treeUnits); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1180 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1181 if (selectedItem is WFObjects.Unit) |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1182 { |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1183 Menu menu = new Menu(); |
83
678e9a0392fc
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1184 ImageMenuItem delete = new ImageMenuItem(Translation.GetTranslation("menuRemoveUnit", "remove unit")); |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1185 delete.Image = new Gtk.Image(Stock.Delete, IconSize.Menu); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1186 delete.Activated += new EventHandler(OnUnitDelete); |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1187 delete.Data["unit"] = selectedItem; |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1188 menu.Append(delete); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1189 menu.ShowAll(); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1190 menu.Popup(); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1191 } |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1192 } |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1193 |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1194 private void OnUnitDelete(object o, EventArgs args) |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1195 { |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1196 RemoveUnitCommand command = new RemoveUnitCommand((WFObjects.Unit)((ImageMenuItem)o).Data["unit"]); |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1197 commandStack.Execute(command); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1198 } |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1199 |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1200 [GLib.ConnectBefore] |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
64
diff
changeset
|
1201 |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1202 protected virtual void UnitTreeButtonPressed(object o, Gtk.ButtonPressEventArgs args) |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1203 { |
44
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1204 TreePath path; |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1205 treeUnits.GetPathAtPos((int)args.Event.X, (int)args.Event.Y, out path); |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1206 |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1207 if (!treeUnits.Selection.PathIsSelected(path)) |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1208 { |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1209 treeUnits.Selection.SelectPath(path); |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1210 } |
44e6833bb41a
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
43
diff
changeset
|
1211 |
30
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1212 if (args.Event.Type == Gdk.EventType.ButtonPress && args.Event.Button == 3) |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1213 { |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1214 OnTreeUnitsPopupMenu(o, null); |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1215 } |
5fafbb1b4592
Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
29
diff
changeset
|
1216 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1217 |
45
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1218 protected virtual void NotebookPageRemoved(object o, Gtk.RemovedArgs args) |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1219 { |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1220 Widget widget = args.Widget; |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1221 |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1222 if (widget is UnitDisplayWidget) |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1223 { |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1224 unitToWidgetMap.Remove(((UnitDisplayWidget)widget).Unit); |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1225 } |
5584860fb44b
Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents:
44
diff
changeset
|
1226 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1227 |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1228 protected virtual void HelpAboutActivated(object sender, System.EventArgs e) |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1229 { |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1230 FrmAbout form = FrmAbout.GetForm(); |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1231 form.Run(); |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1232 form.Hide(); |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
74
diff
changeset
|
1233 } |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1234 |
95
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1235 protected virtual void miPreferencesClicked(object sender, System.EventArgs e) |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1236 { |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1237 FrmPreferences form = new FrmPreferences(Preferences); |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1238 form.Run(); |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1239 form.Hide(); |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1240 } |
ea4069bbe6e9
Re #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
83
diff
changeset
|
1241 |
103
1bd748721040
* Resolve conflict of System.Action vs Gtk.Action
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
1242 public override ICollection<Gtk.Action> Actions |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1243 { |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1244 get |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1245 { |
103
1bd748721040
* Resolve conflict of System.Action vs Gtk.Action
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
1246 List<Gtk.Action> actions = new List<Gtk.Action>(); |
79
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1247 |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1248 foreach (ActionGroup actionGroup in this.UIManager.ActionGroups) |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1249 { |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1250 actions.AddRange(actionGroup.ListActions()); |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1251 } |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1252 |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1253 return actions; |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1254 } |
592930d28da4
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
78
diff
changeset
|
1255 } |
123
f58f69ea2435
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
110
diff
changeset
|
1256 |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1257 protected void OnTransformedXmlActionActivated(object sender, System.EventArgs e) |
123
f58f69ea2435
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
110
diff
changeset
|
1258 { |
125
42d2aa87dfa7
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
123
diff
changeset
|
1259 FrmExportXml form = new FrmExportXml(WarFoundryCore.CurrentArmy); |
142
f23e5b40ca9d
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
141
diff
changeset
|
1260 form.ParentWindow = this.GdkWindow; |
125
42d2aa87dfa7
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
123
diff
changeset
|
1261 form.Run(); |
42d2aa87dfa7
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
123
diff
changeset
|
1262 form.Hide(); |
42d2aa87dfa7
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
123
diff
changeset
|
1263 form.Dispose(); |
123
f58f69ea2435
Re #361: Add XML export UI to GTK#
IBBoard <dev@ibboard.co.uk>
parents:
110
diff
changeset
|
1264 } |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1265 |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1266 protected void OnMiEditArmyActivated(object sender, System.EventArgs e) |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1267 { |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1268 FrmEditArmy form = new FrmEditArmy(commandStack, WarFoundryCore.CurrentArmy); |
142
f23e5b40ca9d
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
141
diff
changeset
|
1269 form.TransientFor = this; |
f23e5b40ca9d
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
141
diff
changeset
|
1270 form.WindowPosition = WindowPosition.CenterOnParent; |
138
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1271 form.Run(); |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1272 form.Hide(); |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1273 form.Dispose(); |
33962c2ef550
Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
135
diff
changeset
|
1274 } |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1275 |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1276 protected void OnLblValidationWarningButtonReleaseEvent(object o, Gtk.ButtonReleaseEventArgs args) |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1277 { |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1278 if (args.Event.Button != (uint)MouseButton.Left) |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1279 { |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1280 return; |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1281 } |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1282 |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1283 ICollection<string> failureMessages = lblValidationWarning.Data[VALIDATION_RESULTS_KEY] as ICollection<string>; |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1284 |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1285 if (failureMessages != null && failureMessages.Count > 0) |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1286 { |
142
f23e5b40ca9d
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
141
diff
changeset
|
1287 ValidationFailureWidget failureWidget = new ValidationFailureWidget(failureMessages); |
f23e5b40ca9d
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
141
diff
changeset
|
1288 Dialog dialog = new SimpleDialog("Validation errors", this, DialogFlags.Modal, failureWidget); |
141
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1289 dialog.Run(); |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1290 dialog.Hide(); |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1291 dialog.Dispose(); |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1292 } |
1ce4fe9ae3c1
Re #344: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
140
diff
changeset
|
1293 } |
0 | 1294 } |
1295 } |