annotate FrmMainWindow.cs @ 45:5584860fb44b

Fixes #145: Add UI to remove units from army * Remove tab on unit deletion * Remove tab from widget map on close Also: * Alias IBBoard.WarFoundry.API.Objects to make access easier (Unit clashes with a GTK class)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Aug 2010 15:43:30 +0000
parents 44e6833bb41a
children 3314f6a46661
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.IO;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Collections.Generic;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using System.Configuration;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
9 using Gtk;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
10 using IBBoard;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using IBBoard.Commands;
12
685532d43a96 Re #88: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
12 using IBBoard.GtkSharp;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 using IBBoard.IO;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
14 using IBBoard.Lang;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
15 using IBBoard.Logging;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 using IBBoard.CustomMath;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 using IBBoard.WarFoundry.API;
28
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
18 using IBBoard.WarFoundry.API.Exporters;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 using IBBoard.WarFoundry.API.Factories;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
20 using IBBoard.WarFoundry.API.Factories.Xml;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
21 using IBBoard.WarFoundry.API.Objects;
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
22 using WFObjects = IBBoard.WarFoundry.API.Objects;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 using IBBoard.WarFoundry.API.Commands;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 using IBBoard.WarFoundry.API.Savers;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 using IBBoard.WarFoundry.API.Requirements;
6
cfc7683e73f9 Fix breakage from r33 by completing update of move to IBBoard.WarFoundry.GTK sub-packages
IBBoard <dev@ibboard.co.uk>
parents: 5
diff changeset
26 using IBBoard.WarFoundry.GTK.Widgets;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
27 using IBBoard.WarFoundry.Plugin.Rollcall;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 using IBBoard.Xml;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 using log4net;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
31 namespace IBBoard.WarFoundry.GTK
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
32 {
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 public partial class FrmMainWindow: Gtk.Window
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 private static readonly string AppTitle = "WarFoundry";
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
36 private const int CATEGORY_BUTTON_SEPARATOR_INDEX = 6;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
37
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
38 private Preferences preferences;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
39 private ILog logger = LogManager.GetLogger(typeof(FrmMainWindow));
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
40
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 private CommandStack commandStack;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 private Dictionary<ToolButton, Category> categoryMap = new Dictionary<ToolButton, Category>();
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
43 private Dictionary<WFObjects.Unit, UnitDisplayWidget> unitToWidgetMap = new Dictionary<WFObjects.Unit,UnitDisplayWidget>();
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
44
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
45 private ObjectAddDelegate UnitAddedMethod;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
46 private ObjectRemoveDelegate UnitRemovedMethod;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
47 private DoubleValChangedDelegate PointsValueChangedMethod;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 private FailedUnitRequirementDelegate FailedUnitRequirementMethod;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 private StringValChangedDelegate UnitNameChangedMethod;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
50
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 private GameSystem system;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 private string loadedArmyPath;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
53
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 private MenuToolButton undoMenuButton, redoMenuButton;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
55
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 public static void Main (string[] args)
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
57 {
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
58 try
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 Application.Init();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 FrmMainWindow win = new FrmMainWindow(args);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 win.Show();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 Application.Run();
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
64 LogManager.GetLogger(typeof(FrmMainWindow)).Debug("Application ended");
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
65 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
66 catch(Exception ex)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
67 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
68 LogManager.GetLogger(typeof(FrmMainWindow)).Fatal("("+ex.GetType().Name+") "+ex.Message + Environment.NewLine + ex.StackTrace);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
71
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 public FrmMainWindow() : this(new string[0])
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 //Do nothing extra
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
76
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
77 public FrmMainWindow(string[] args) : base(Gtk.WindowType.Toplevel)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 logger.Info("Opening FrmMainWindow");
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
80 Build();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 //Replace the undo/redo buttons with menu versions, which Monodevelop's GUI editor doesn't currently support
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82 redoMenuButton = new MenuToolButton("gtk-redo");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 redoMenuButton.Label = "Redo";
10
c687bbe901f8 Re #37 - Resolve deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
84 redoMenuButton.TooltipText = "Redo";
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 redoMenuButton.Clicked+= redoTBButtonActivated;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 toolbar.Insert(redoMenuButton, CATEGORY_BUTTON_SEPARATOR_INDEX);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 undoMenuButton = new MenuToolButton("gtk-undo");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 undoMenuButton.Label = "Undo";
10
c687bbe901f8 Re #37 - Resolve deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
89 undoMenuButton.TooltipText = "Undo";
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 undoMenuButton.Clicked+= undoTBButtonActivated;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 toolbar.Insert(undoMenuButton, CATEGORY_BUTTON_SEPARATOR_INDEX);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX-1]);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 toolbar.Remove(toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX-2]);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 toolbar.ShowAll();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
95
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 Title = AppTitle;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 TreeViewColumn mainColumn = new TreeViewColumn ();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 mainColumn.Title = "Army Categories";
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 CellRendererText mainCell = new CellRendererText ();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 mainColumn.PackStart (mainCell, true);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 treeUnits.AppendColumn(mainColumn);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 mainColumn.SetCellDataFunc(mainCell, new TreeCellDataFunc(RenderCategoryTreeObjectName));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 treeUnits.Model = new TreeStore(typeof(WarFoundryObject));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 logger.Debug("Loading preferences");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 Preferences = new Preferences("WarFoundryGTK");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 logger.Debug("Loading translations");
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
107
8
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
108 try
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
109 {
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
110 Translation.InitialiseTranslations(Constants.ExecutablePath, Preferences["language"].ToString());
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
111 }
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
112 catch (TranslationLoadException ex)
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
113 {
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
114 logger.Error(ex);
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
115 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
116 dialog.Title = "Translation loading failed";
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
117 dialog.Run();
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
118 dialog.Destroy();
20c5fd0bb79d Fixes #5 - Stop missing translations being fatal
IBBoard <dev@ibboard.co.uk>
parents: 6
diff changeset
119 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
120
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
121 logger.Debug("Initialising");
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
122 commandStack = new CommandStack();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 commandStack.CommandStackUpdated+=new MethodInvoker(commandStack_CommandStackUpdated);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 WarFoundryCore.GameSystemChanged+= new GameSystemChangedDelegate(OnGameSystemChanged);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(OnArmyChanged);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 Destroyed+= new EventHandler(OnWindowDestroyed);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 //TODO: Translate and subscribe to other events
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
128 UnitAddedMethod = new ObjectAddDelegate(OnUnitAdded);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
129 UnitRemovedMethod = new ObjectRemoveDelegate(OnUnitRemoved);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
130 PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
133
18
c4d9b1ec75ed Re #124: Remove "factory factory"
IBBoard <dev@ibboard.co.uk>
parents: 17
diff changeset
134 //FIXME: Temporary hack to add paths and factories before we get preferences and plugins
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data"));
18
c4d9b1ec75ed Re #124: Remove "factory factory"
IBBoard <dev@ibboard.co.uk>
parents: 17
diff changeset
136 WarFoundryLoader.GetDefault().RegisterFactory(WarFoundryXmlFactory.GetFactory());
c4d9b1ec75ed Re #124: Remove "factory factory"
IBBoard <dev@ibboard.co.uk>
parents: 17
diff changeset
137 WarFoundryLoader.GetDefault().RegisterNonNativeFactory(RollcallFactory.GetFactory());
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
138 WarFoundryLoader.GetDefault().FileLoadingFinished += FileLoadingFinished;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
139 WarFoundrySaver.SetFileSaver(new WarFoundryXmlSaver());
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
140
15
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
141 logger.Debug("Initialising complete - seeing if we can load default army or system");
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
142
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 if (args.Length == 1)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 {
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
145 logger.Debug("Attempting to load from file");
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 FileInfo file = new FileInfo(args[0]);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
147
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 try
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 {
5
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
150 ICollection<IWarFoundryObject> objects = WarFoundryLoader.GetDefault().LoadFile(file);
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
151
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
152 if (objects.Count == 1)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 {
5
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
154 List<IWarFoundryObject> objectList = new List<IWarFoundryObject>();
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
155 objectList.AddRange(objects);
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
156 IWarFoundryObject loadedObject = objectList[0];
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
157
5
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
158 if (loadedObject is Army)
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
159 {
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
160 WarFoundryCore.CurrentArmy = (Army)loadedObject;
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
161 logger.InfoFormat("Loaded army from {0}", file.FullName);
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
162 }
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
163 else if (loadedObject is GameSystem)
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
164 {
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
165 WarFoundryCore.CurrentGameSystem = (GameSystem)loadedObject;
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
166 logger.InfoFormat("Loaded game system from {0}", file.FullName);
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
167 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 catch (InvalidFileException ex)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 //TODO: show error dialog
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 logger.Error(ex);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 else
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 string gameSystemID = Preferences.GetStringProperty("currSystem");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 if (gameSystemID!=null && !"".Equals(gameSystemID))
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 logger.Debug("Attempting to load current game system from properties");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 GameSystem sys = WarFoundryLoader.GetDefault().GetGameSystem(gameSystemID);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
184
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 if (sys!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 WarFoundryCore.CurrentGameSystem = sys;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 logger.InfoFormat("Loaded game system {0} from properties", gameSystemID);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
193
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
194 private void FileLoadingFinished (List<FileLoadFailure> failures)
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
195 {
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
196 foreach(FileLoadFailure failure in failures)
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
197 {
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
198 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
199 }
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
200 }
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
201
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 private void RenderCategoryTreeObjectName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 object o = model.GetValue(iter, 0);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
205
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 if (o is ArmyCategory)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 ArmyCategory c = (ArmyCategory)o;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 string name = "";
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
210
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
211 if (!Preferences.GetBooleanProperty("ShowCatPercentage"))
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 {
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
213 name = Translation.GetTranslation("categoryTreeCatName", "{0} - {1}pts", c.Name, c.Points);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215 else
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 {
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
217 name = Translation.GetTranslation("categoryTreeCatNamePercentage", "{0} - {1}pts ({2}%)", c.Name, c.Points, (c.ParentArmy.Points > 0 ? Math.Round((c.Points / c.ParentArmy.Points) * 100) : 0));
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
219
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 (cell as CellRendererText).Text = name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 }
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
222 else if (o is WFObjects.Unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
224 WFObjects.Unit u = (WFObjects.Unit)o;
32
eab45344cd56 Re #172: Add GTK# UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 30
diff changeset
225 string name = Translation.GetTranslation("unitTreeCatName", "{0} - {1}pts", u.Name, u.Points);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 (cell as CellRendererText).Text = name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
229
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230 private void OnWindowDestroyed(object source, EventArgs args)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 logger.Info("Exiting");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 Application.Quit();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
235
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 private void OnUnitNameChanged(WarFoundryObject val, string oldValue, string newValue)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
238 WFObjects.Unit unit = (WFObjects.Unit)val;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 UnitDisplayWidget widget;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 unitToWidgetMap.TryGetValue(unit, out widget);
41
a32b6bb7f1eb Fixes #129: Change notifications are slow in GTK app
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
241 logger.DebugFormat("Unit name changed for {0} - now called {1}", unit.ID, unit.Name);
a32b6bb7f1eb Fixes #129: Change notifications are slow in GTK app
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
242 treeUnits.QueueDraw();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
243
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 if (widget!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 {
26
3a396783bfed Fixes #125: Tabs lose close buttons
IBBoard <dev@ibboard.co.uk>
parents: 25
diff changeset
246 unitsNotebook.SetTabLabel(widget, NotebookUtil.CreateNotebookTabLabelWithClose(unitsNotebook, widget, newValue));
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
249
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 private void OnUnitAdded(WarFoundryObject val)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
252 WFObjects.Unit unit = (WFObjects.Unit)val;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
253 unit.NameChanged+= UnitNameChangedMethod;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
254 AddUnitToTree(unit);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
255 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
256
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
257 private void AddUnitToTree(WFObjects.Unit unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
258 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
259 TreeStore model = (TreeStore)treeUnits.Model;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
260 TreeIter iter;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
261 model.GetIterFirst(out iter);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
262
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
263 do
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
264 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
265 object obj = model.GetValue(iter, 0);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
266
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
267 if (obj is ArmyCategory)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
268 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
269 ArmyCategory cat = (ArmyCategory)obj;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
270
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
271 if (cat.Equals(unit.Category))
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
272 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
273 model.AppendValues(iter, unit);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
274 TreePath path = model.GetPath(iter);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
275 treeUnits.ExpandToPath(path);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
276 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
277 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
278 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
279 while (model.IterNext(ref iter));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
280 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
281
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
282 private void OnUnitRemoved(WarFoundryObject obj)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
283 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
284 WFObjects.Unit unit = (WFObjects.Unit)obj;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
285 unit.NameChanged-= UnitNameChangedMethod;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
286 RemoveUnitFromTree(unit);
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
287 RemoveUnitTab(unit);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
288 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
289
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
290 private void RemoveUnitFromTree(WFObjects.Unit unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
291 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
292 TreeStore model = (TreeStore)treeUnits.Model;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
293 TreeIter iter;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
294 model.GetIterFirst(out iter);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
295 bool removed = false;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
296
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
297 do
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
298 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
299 object obj = model.GetValue(iter, 0);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
300
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
301 if (obj is ArmyCategory)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
302 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
303 ArmyCategory cat = (ArmyCategory)obj;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
304
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
305 if (unit.Category == null || cat.Equals(unit.Category))
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
306 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
307 TreeIter innerIter;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
308 model.IterChildren(out innerIter, iter);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
309
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
310 do
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
311 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
312 object innerObj = model.GetValue(innerIter, 0);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
313
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
314 if (unit.Equals(innerObj))
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
315 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
316 model.Remove(ref innerIter);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
317 removed = true;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
318 break;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
319 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
320 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
321 while (model.IterNext(ref innerIter));
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
322
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
323 if (removed)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
324 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
325 break;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
326 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
327 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
328 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
329 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
330 while (model.IterNext(ref iter));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
331 }
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
332
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
333 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
334 {
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
335 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
336
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
337 if (widget != null)
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
338 {
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
339 unitsNotebook.Remove(widget);
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
340 }
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
341 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
342
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
343 private void OnPointsValueChanged(WarFoundryObject obj, double before, double after)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
344 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
345 //Set points in panel
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
346 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
347
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
348 private void OnFailedUnitRequirement(List<FailedUnitRequirement> failedRequirement)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
349 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
350 //Show error message in panel
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
351 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
352
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
353 public Preferences Preferences
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
354 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
355 get { return preferences; }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
356 set { preferences = value; }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
357 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
358
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
359 /*public AbstractNativeWarFoundryFactory Factory
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
360 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
361 get { return WarFoundryFactoryFactory.GetFactoryFactory().GetFactory(Constants.ExecutablePath, factoryType); }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
362 }*/
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
363
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
364 protected void OnDeleteEvent (object sender, DeleteEventArgs a)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
365 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
366 Application.Quit ();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
367 a.RetVal = true;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
368 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
369
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
370 protected virtual void OnExitActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
371 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
372 Application.Quit();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
373 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
374
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
375 protected virtual void OnCreateArmyActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
376 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
377 CreateNewArmy();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
378 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
379
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
380 protected virtual void OnReloadFilesActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
381 {
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
382 WarFoundryLoader.GetDefault().LoadFiles();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
383 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
384
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
385 protected virtual void OnSaveArmyAsActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
386 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
387 SaveCurrentArmyAs();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
388 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
389
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
390 protected virtual void OnCloseArmyActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
391 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
392 CloseCurrentArmy();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
393 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
394
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
395 protected virtual void OnOpenArmyActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
396 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
397 OpenArmy();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
398 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
399
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
400 protected virtual void OnSaveArmyActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
401 {
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
402 SaveCurrentArmyOrSaveAs();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
403 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
404
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
405 protected virtual void OnAddUnitActivated(object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
406 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
407 if (sender is ToolButton)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
408 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
409 Category cat = null;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
410 categoryMap.TryGetValue((ToolButton)sender, out cat);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
411
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
412 if (cat != null)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
413 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
414 logger.DebugFormat("Show FrmNewUnit for {0}", cat.Name);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
415 FrmNewUnit newUnit = new FrmNewUnit(WarFoundryCore.CurrentArmy.Race, cat, WarFoundryCore.CurrentArmy);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
416 ResponseType response = (ResponseType)newUnit.Run();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
417 newUnit.Hide();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
418
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
419 if (response == ResponseType.Ok)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
420 {
14
abbf8a3ac431 Re #90: Stop new units showing up twice
IBBoard <dev@ibboard.co.uk>
parents: 13
diff changeset
421 CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, WarFoundryCore.CurrentArmy.GetCategory(cat));
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
422 commandStack.Execute(cmd);
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
423 ShowUnitWidget(cmd.Unit);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
424 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
425
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
426 newUnit.Dispose();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
427 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
428 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
429 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
430
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
431 public CommandStack CommandStack
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
432 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
433 get { return commandStack; }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
434 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
435
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
436 private void SetAppTitle()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
437 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
438 if (WarFoundryCore.CurrentArmy!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
439 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
440 Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name + " - " + WarFoundryCore.CurrentArmy.Name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
441 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
442 else if (WarFoundryCore.CurrentGameSystem!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
443 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
444 Title = AppTitle + " - " + WarFoundryCore.CurrentGameSystem.Name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
445 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
446 else
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
447 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
448 Title = AppTitle;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
449 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
450 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
451
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
452 private void OnGameSystemChanged(GameSystem oldSys, GameSystem newSys)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
453 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
454 system = newSys;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
455 SetAppTitle();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
456 RemoveCategoryButtons();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
457
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
458 if (system!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
459 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
460 AddCategoryButtons(system.Categories);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
461 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
462 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
463
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
464 private void OnArmyChanged(Army oldArmy, Army newArmy)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
465 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
466 loadedArmyPath = null;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
467 SetAppTitle();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
468 SetArmyTree(newArmy);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
469
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
470 if (oldArmy != null)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
471 {
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
472 oldArmy.UnitAdded -= UnitAddedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
473 oldArmy.UnitRemoved -= UnitRemovedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
474 oldArmy.PointsValueChanged -= PointsValueChangedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
475 oldArmy.FailedRequirement -= FailedUnitRequirementMethod;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
476 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
477
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
478 unitToWidgetMap.Clear();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
479
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
480 while (unitsNotebook.NPages > 0)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
481 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
482 unitsNotebook.RemovePage(0);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
483 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
484
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
485 if (newArmy == null)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
486 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
487 DisableCategoryButtons();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
488 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
489 else
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
490 {
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
491 newArmy.UnitAdded += UnitAddedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
492 newArmy.UnitRemoved += UnitRemovedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
493 newArmy.PointsValueChanged += PointsValueChangedMethod;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
494 newArmy.FailedRequirement += FailedUnitRequirementMethod;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
495 //TODO: Clear all buttons
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
496 EnableCategoryButtons();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
497
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
498 if (newArmy.Race.HasCategoryOverrides())
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
499 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
500 RemoveCategoryButtons();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
501 AddCategoryButtons(newArmy.Race.Categories);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
502 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
503 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
504
43
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
505 bool nonNullNewArmy = (newArmy != null);
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
506 miCloseArmy.Sensitive = nonNullNewArmy;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
507 miSaveArmyAs.Sensitive = nonNullNewArmy;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
508 miExportArmy.Sensitive = nonNullNewArmy;
4e127ce8682f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
509 hpaned2.Visible = nonNullNewArmy;
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
510 loadedArmyPath = null;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
511 //New army has no changes, so we can't save it
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
512 miSaveArmy.Sensitive = false;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
513 saveArmyButton.Sensitive = false;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
514
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
515 CommandStack.Reset();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
516 SetPointsPanelText();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
517 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
518
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
519 private void SetArmyTree(Army army)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
520 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
521 logger.Debug("Resetting tree");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
522 TreeStore store = (TreeStore)treeUnits.Model;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
523 store.Clear();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
524 TreeIter iter;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
525
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
526 if (army!=null)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
527 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
528 logger.Debug("Loading in categories to tree");
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
529
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
530 foreach (ArmyCategory cat in army.Categories)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
531 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
532 logger.DebugFormat("Append category {0}", cat.Name);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
533 iter = store.AppendValues(cat);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
534
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
535 foreach (WFObjects.Unit unit in cat.GetUnits())
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
536 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
537 store.AppendValues(iter, unit);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
538 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
539 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
540
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
541 logger.Debug("Finished loading tree categories");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
542 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
543 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
544
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
545 private void DisableCategoryButtons()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
546 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
547 SetCategoryButtonsSensitive(false);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
548 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
549
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
550 private void EnableCategoryButtons()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
551 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
552 SetCategoryButtonsSensitive(true);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
553 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
554
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
555 private void SetCategoryButtonsSensitive(bool state)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
556 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
557 int toolbarButtonCount = toolbar.Children.Length - 1;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
558 logger.Debug("Last button index: "+toolbarButtonCount);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
559
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
560 for (int i = toolbarButtonCount; i > CATEGORY_BUTTON_SEPARATOR_INDEX; i--)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
561 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
562 logger.DebugFormat("Setting button {0} state to {1}", i, state);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
563 toolbar.Children[i].Sensitive = state;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
564 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
565 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
566
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
567 private void RemoveCategoryButtons()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
568 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
569 int toolbarButtonCount = toolbar.Children.Length - 1;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
570
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
571 for (int i = toolbarButtonCount; i > CATEGORY_BUTTON_SEPARATOR_INDEX; i--)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
572 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
573 toolbar.Remove(toolbar.Children[i]);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
574 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
575
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
576 categoryMap.Clear();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
577 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
578
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
579 private void AddCategoryButtons(Category[] cats)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
580 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
581 if (cats!=null && cats.Length > 0)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
582 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
583 logger.DebugFormat("Toolbar button count: {0}. Adding {1} categories.", toolbar.Children.Length, cats.Length);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
584
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
585 foreach (Category cat in cats)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
586 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
587 ToolButton button = new ToolButton("gtk-add");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
588 button.Label = cat.Name;
10
c687bbe901f8 Re #37 - Resolve deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
589 button.TooltipText = "Add unit from "+cat.Name;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
590 //TODO: See if we can associate data in some way, the same as we can with SWF. For now we just use the map.
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
591 categoryMap.Add(button, cat);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
592 button.Clicked+= new System.EventHandler(OnAddUnitActivated);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
593 toolbar.Insert(button, -1);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
594 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
595 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
596
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
597 toolbar.Children[CATEGORY_BUTTON_SEPARATOR_INDEX].Visible = cats!=null && cats.Length>0;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
598
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
599 toolbar.ShowAll();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
600 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
601
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
602 private void SetPointsPanelText()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
603 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
604 //TODO: Set the points value in the status bar
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
605 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
606
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
607 private void commandStack_CommandStackUpdated()
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
608 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
609 undoMenuButton.Sensitive = commandStack.CanUndo();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
610 miUndo.Sensitive = undoMenuButton.Sensitive;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
611 redoMenuButton.Sensitive = commandStack.CanRedo();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
612 miRedo.Sensitive = redoMenuButton.Sensitive;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
613 int redoLength = commandStack.RedoLength;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
614 //TODO: Build menus for undo/redo and find way of adding tooltips
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
615 /*int maxRedo = Math.Min(10, redoLength);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
616 MenuItem[] menuItems = null;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
617
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
618 if (redoLength > 0)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
619 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
620 menuItems = new MenuItem[maxRedo];
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
621 Command com;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
622 MenuItem mi;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
623
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
624 for (int i = 0; i < maxRedo; i++)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
625 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
626 com = commandStack.PeekRedoCommand(i+1);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
627
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
628 if (com == null)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
629 {
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
630 break;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
631 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
632
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
633 mi = new MenuItem(com.Description);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
634 mi.Click+=new EventHandler(redoMenu_Click);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
635 menuItems[i] = mi;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
636 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
637 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
638
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
639 redoMenu.MenuItems.Clear();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
640
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
641 if (menuItems!=null && menuItems[0]!=null)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
642 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
643 bttnRedo.ToolTipText = menuItems[0].Text;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
644 redoMenu.MenuItems.AddRange(menuItems);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
645 }*/
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
646 //TODO: Put above code back when we have a dropdown version of the redo button
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
647 if (redoLength > 0)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
648 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
649 //redoMenuButton.Tooltip = CommandStack.PeekRedoCommand().Description;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
650 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
651
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
652 int undoLength = commandStack.UndoLength;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
653 /*int maxUndo = Math.Min(10, undoLength);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
654 MenuItem[] menuItemsUndo = null;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
655
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
656 if (undoLength > 0)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
657 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
658 menuItemsUndo = new MenuItem[maxUndo];
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
659 Command com;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
660 MenuItem mi;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
661
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
662 for (int i = 0; i < maxUndo; i++)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
663 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
664 com = commandStack.PeekUndoCommand(i+1);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
665
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
666 if (com == null)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
667 {
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
668 break;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
669 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
670
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
671 mi = new MenuItem(com.UndoDescription);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
672 mi.Click+=new EventHandler(undoMenu_Click);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
673 menuItemsUndo[i] = mi;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
674 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
675 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
676
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
677 undoMenu.MenuItems.Clear();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
678
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
679 if (menuItemsUndo!=null && menuItemsUndo[0]!=null)
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
680 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
681 bttnUndo.ToolTipText = menuItemsUndo[0].Text;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
682 undoMenu.MenuItems.AddRange(menuItemsUndo);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
683 }*/
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
684 //TODO: Put above code back when we have a dropdown version of the undo button
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
685 if (undoLength > 0)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
686 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
687 //undoMenuButton.Tooltip = CommandStack.PeekUndoCommand().UndoDescription;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
688 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
689
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
690 saveArmyButton.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null;
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
691 miSaveArmy.Sensitive = commandStack.IsDirty() && WarFoundryCore.CurrentArmy!=null;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
692 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
693
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
694 private bool SaveCurrentArmyOrSaveAs()
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
695 {
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
696 if (loadedArmyPath != null)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
697 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
698 return SaveCurrentArmy();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
699 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
700 else
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
701 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
702 return SaveCurrentArmyAs();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
703 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
704 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
705
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
706 private bool OpenArmy()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
707 {
25
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
708 FileChooserDialog fileDialog = new FileChooserDialog("Open army", this, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
709 FileFilter filter = new FileFilter();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
710 filter.AddPattern("*.army");
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
711 filter.Name = "WarFoundry Army files (*.army)";
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
712 fileDialog.AddFilter(filter);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
713 int response = fileDialog.Run();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
714 string filePath = null;
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
715
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
716 if (response == (int)ResponseType.Accept)
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
717 {
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
718 filePath = fileDialog.Filename;
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
719 }
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
720
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
721 fileDialog.Hide();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
722 fileDialog.Dispose();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
723
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
724 bool success = false;
25
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
725
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
726 if (filePath != null)
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
727 {
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
728 FileInfo file = new FileInfo(filePath);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
729 Army army = WarFoundryLoader.GetDefault().LoadArmy(file);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
730
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
731 if (army != null)
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
732 {
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
733 logger.Debug("Loaded army " + army.ID);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
734 success = true;
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
735 WarFoundryCore.CurrentArmy = army;
25
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
736 loadedArmyPath = filePath;
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
737 logger.Debug("Army loading complete");
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
738 }
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
739 else
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
740 {
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
741 logger.ErrorFormat("Failed to load {0} as an army file", filePath);
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
742 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, file.Name + " could not be loaded.\n\nIf the file is an army file then please check your file loaders.");
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
743 dialog.Title = "Failed to open army";
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
744 dialog.Run();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
745 dialog.Hide();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
746 dialog.Dispose();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
747 }
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
748 }
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
749 else
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
750 {
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
751 logger.Debug("Army open requested but cancelled");
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
752 }
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
753
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
754 return success;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
755 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
756
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
757 private bool SaveCurrentArmy()
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
758 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
759 bool success = false;
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
760
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
761 if (loadedArmyPath!=null)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
762 {
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
763 success = SaveArmyToPath(WarFoundryCore.CurrentArmy, loadedArmyPath);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
764 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
765
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
766 return success;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
767 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
768
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
769 private bool SaveCurrentArmyAs()
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
770 {
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
771 FileChooserDialog fileDialog = new FileChooserDialog("Save file as", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Accept);
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
772 FileFilter filter = new FileFilter();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
773 filter.AddPattern("*.army");
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
774 filter.Name = "WarFoundry Army files (*.army)";
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
775 fileDialog.AddFilter(filter);
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
776 int response = fileDialog.Run();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
777 string filePath = null;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
778
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
779 if (response == (int)ResponseType.Accept)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
780 {
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
781 filePath = fileDialog.Filename;
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
782 }
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
783
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
784 fileDialog.Hide();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
785 fileDialog.Dispose();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
786
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
787 return SaveArmyToPath(WarFoundryCore.CurrentArmy, filePath);
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
788 }
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
789
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
790 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
791 {
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
792 bool success = false;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
793
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
794 if (filePath!=null)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
795 {
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
796 if (WarFoundrySaver.GetSaver().Save(WarFoundryCore.CurrentArmy, filePath))
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
797 {
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
798 miSaveArmy.Sensitive = false;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
799 saveArmyButton.Sensitive = false;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
800 CommandStack.setCleanMark();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
801 loadedArmyPath = filePath;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
802 success = true;
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
803 }
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
804 else
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
805 {
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
806 MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Failed to save file to "+filePath);
25
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
807 dialog.Title = "Army save failed";
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
808 dialog.Run();
01ddadfa9653 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 23
diff changeset
809 dialog.Hide();
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
810 dialog.Dispose();
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
811 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
812 }
23
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
813 //else user cancelled
d661cb257511 Re #86: Initial GTK# GUI (because of Re #53)
IBBoard <dev@ibboard.co.uk>
parents: 21
diff changeset
814
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
815 return success;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
816 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
817
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
818 private bool CloseCurrentArmy()
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
819 {
42
35ad26ac59c0 Fixes #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents: 41
diff changeset
820 if (WarFoundryCore.CurrentArmy != null)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
821 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
822 bool canClose = false;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
823
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
824 if (CommandStack.IsDirty())
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
825 {
42
35ad26ac59c0 Fixes #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents: 41
diff changeset
826 MessageDialog dia = new MessageDialog(this, DialogFlags.DestroyWithParent, MessageType.Question, ButtonsType.YesNo, "The army \"" + WarFoundryCore.CurrentArmy.Name + "\" has been modified.\r\nSave changes before closing army?");
35ad26ac59c0 Fixes #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents: 41
diff changeset
827 dia.AddButton("Cancel", ResponseType.Cancel);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
828 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
829 dia.Hide();
83c8945edac2 Re #143: GTK "Army has been modified" dialog has no buttons
IBBoard <dev@ibboard.co.uk>
parents: 26
diff changeset
830 dia.Dispose();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
831
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
832 if (dr == ResponseType.Yes)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
833 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
834 //They want to save so try to save it or prompt for save as
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
835 //If they cancel the save as then assume they don't want to close
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
836 canClose = SaveCurrentArmyOrSaveAs();
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
837 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
838 else if (dr == ResponseType.No)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
839 {
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
840 //They don't care about their changes
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
841 canClose = true;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
842 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
843 else
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
844 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
845 //Assume cancel or close with the X button
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
846 canClose = false;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
847 }
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
848 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
849 else
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
850 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
851 //Nothing has changed so we can safely close
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
852 canClose = true;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
853 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
854
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
855 if (canClose)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
856 {
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
857 //do close
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
858 WarFoundryCore.CurrentArmy = null;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
859 return true;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
860 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
861 else
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
862 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
863 return false;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
864 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
865 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
866 else
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
867 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
868 //pretend we succeeded
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
869 return true;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
870 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
871 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
872
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
873 private void CreateNewArmy()
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
874 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
875 logger.Debug("Create new army");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
876 FrmNewArmy newArmy = new FrmNewArmy(WarFoundryCore.CurrentGameSystem);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
877 ResponseType type = (ResponseType)newArmy.Run();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
878 newArmy.Hide();
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
879
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
880 if (type == ResponseType.Ok)
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
881 {
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
882 if (CloseCurrentArmy())
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
883 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
884 WarFoundryCore.CurrentArmy = new Army(newArmy.SelectedRace, newArmy.ArmyName, newArmy.ArmySize);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
885 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
886 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
887 else
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
888 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
889 logger.Debug("Create new army cancelled");
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
890 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
891
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 12
diff changeset
892 newArmy.Destroy();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
893 }
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
894
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
895 protected virtual void undoTBButtonActivated (object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
896 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
897 CommandStack.Undo();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
898 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
899
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
900 protected virtual void redoTBButtonActivated (object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
901 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
902 CommandStack.Redo();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
903 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
904
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
905 protected virtual void saveTBButtonActivated (object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
906 {
33
441cfc410987 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 32
diff changeset
907 SaveCurrentArmyOrSaveAs();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
908 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
909
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
910 protected virtual void openTBButtonActivated (object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
911 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
912 OpenArmy();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
913 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
914
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
915 protected virtual void newTBButtonActivated (object sender, System.EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
916 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
917 CreateNewArmy();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
918 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
919
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
920 protected virtual void ArmyRowActivated(object o, Gtk.RowActivatedArgs args)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
921 {
30
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
922 object obj = TreeUtils.GetItemAtPath(treeUnits, args.Path);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
923
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
924 if (obj is WFObjects.Unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
925 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
926 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
927 ShowUnitWidget(unit);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
928 }
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
929 }
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
930
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
931 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
932 {
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
933 UnitDisplayWidget widget;
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
934 unitToWidgetMap.TryGetValue(unit, out widget);
21
2cf1af4c9baf Re #53: Add XML saver
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
935
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
936 if (widget!=null)
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
937 {
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
938 logger.DebugFormat("Selecting existing page for "+unit.Name);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
939 unitsNotebook.Page = unitsNotebook.PageNum(widget);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
940 }
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
941 else
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
942 {
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
943 widget = new UnitDisplayWidget(unit, CommandStack);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
944 logger.Debug("Adding page for "+unit.Name);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
945 unitToWidgetMap[unit] = widget;
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
946 widget.Destroyed+= new EventHandler(UnitWidgetDestroyed);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
947 int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
948 logger.Debug("Page added at index "+pageNum);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
949 unitsNotebook.ShowAll();
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
950 unitsNotebook.Page = pageNum;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
951 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
952 }
15
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
953
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
954 private void UnitWidgetDestroyed(object sender, EventArgs e)
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
955 {
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
956 if (sender is UnitDisplayWidget)
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
957 {
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
958 unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit);
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
959 }
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
960 }
28
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
961
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
962 protected virtual void OnMiExportAsBasicHtmlActivated (object sender, System.EventArgs e)
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
963 {
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
964 FileChooserDialog fileDialog = new FileChooserDialog("Export army", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Export", ResponseType.Accept);
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
965 FileFilter filter = new FileFilter();
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
966 filter.AddPattern("*.html");
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
967 filter.Name = "HTML pages (*.html)";
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
968 fileDialog.AddFilter(filter);
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
969 int response = fileDialog.Run();
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
970 string filePath = null;
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
971
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
972 if (response == (int)ResponseType.Accept)
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
973 {
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
974 filePath = fileDialog.Filename;
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
975 }
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
976
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
977 fileDialog.Hide();
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
978 fileDialog.Dispose();
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
979
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
980 if (filePath != null)
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
981 {
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
982 Army army = WarFoundryCore.CurrentArmy;
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
983 logger.DebugFormat("Exporting {0} to {1} as basic HTML", army.Name, filePath);
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
984 WarFoundryHtmlExporter.GetDefault().ExportArmy(army, filePath);
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
985 }
9440eef124b0 Closes #69: Add "export" UI
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
986 }
30
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
987
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
988 protected virtual void OnTreeUnitsPopupMenu (object o, Gtk.PopupMenuArgs args)
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
989 {
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
990 object selectedItem = TreeUtils.GetSelectedItem(treeUnits);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
991
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
992 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
993 {
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
994 Menu menu = new Menu();
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
995 ImageMenuItem delete = new ImageMenuItem("Remove unit");
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
996 delete.Image = new Gtk.Image(Stock.Delete, IconSize.Menu);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
997 delete.Activated+= new EventHandler(OnUnitDelete);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
998 delete.Data["unit"] = selectedItem;
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
999 menu.Append(delete);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1000 menu.ShowAll();
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1001 menu.Popup();
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1002 }
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1003 }
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1004
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1005 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
1006 {
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1007 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
1008 commandStack.Execute(command);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1009 }
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1010
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1011 [GLib.ConnectBefore]
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1012 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
1013 {
44
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1014 TreePath path;
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1015 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
1016
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1017 if (!treeUnits.Selection.PathIsSelected(path))
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1018 {
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1019 treeUnits.Selection.SelectPath(path);
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1020 }
44e6833bb41a Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 43
diff changeset
1021
30
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1022 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
1023 {
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1024 OnTreeUnitsPopupMenu(o, null);
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1025 }
5fafbb1b4592 Re #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 29
diff changeset
1026 }
45
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1027
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1028 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
1029 {
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1030 Widget widget = args.Widget;
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1031
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1032 if (widget is UnitDisplayWidget)
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1033 {
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1034 unitToWidgetMap.Remove(((UnitDisplayWidget)widget).Unit);
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1035 }
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1036 }
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1037
5584860fb44b Fixes #145: Add UI to remove units from army
IBBoard <dev@ibboard.co.uk>
parents: 44
diff changeset
1038
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1039 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1040 }