annotate FrmNewArmy.cs @ 149:45c2485f37c0

* Initialise variable - xbuild is more picky than MonoDevelop
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Nov 2011 14:22:46 +0000
parents d4b726cec12c
children
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: 5
diff changeset
1 // This file (FrmNewArmy.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: 5
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 Gtk;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.Lang;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Objects;
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
10 using IBBoard.GtkSharp;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using log4net;
52
4bad8cb3f889 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
12 using IBBoard.WarFoundry.GUI.GTK.Util;
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 75
diff changeset
13 using IBBoard.GtkSharp.Translatable;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
15 namespace IBBoard.WarFoundry.GUI.GTK
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 {
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 75
diff changeset
17 public partial class FrmNewArmy : TranslatableDialog, ITranslatable
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 private ILog logger = LogManager.GetLogger(typeof(FrmNewArmy));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 private Race race;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 private string armyName;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 private int pointsValue;
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
23 private bool isDefaultArmyName = true;
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
24
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public FrmNewArmy(GameSystem gameSystem)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 this.Build();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
29 GameSystem[] gameSystems = WarFoundryLoader.GetDefault().GetGameSystems();
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
30 ComboBoxUtils.FillCombo(systemCombo, gameSystems, delegate(GameSystem sys){return sys.Name;});
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
31
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
32 lstRaces.Selection.Changed += new EventHandler(OnSelectionChanged);
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
33
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
34 TreeViewColumn raceColumn = new TreeViewColumn();
84
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
35 raceColumn.Title = Translation.GetTranslation("frmNewArmyRaceColumn", "race");
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
36 CellRendererText raceCell = new CellRendererText();
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
37 raceColumn.PackStart(raceCell, true);
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
38 lstRaces.AppendColumn(raceColumn);
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
39 raceColumn.SetCellDataFunc(raceCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
40
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
41 if (gameSystem != null)
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
42 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
43 ComboBoxUtils.SelectItem(systemCombo, gameSystem);
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
44 }
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
45 else if (gameSystems.Length == 1)
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
46 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
47 ComboBoxUtils.SelectIndex(systemCombo, 0);
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
48 }
96
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
49
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
50 Translation.TranslationChanged += Retranslate;
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
51 Translate();
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
52 }
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
53
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
54 private void Retranslate()
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
55 {
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
56 Translate();
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
57 }
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
58
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
59 public override void Dispose()
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
60 {
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
61 Translation.TranslationChanged -= Retranslate;
b4416ca69153 Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents: 86
diff changeset
62 base.Dispose();
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
63 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
64
85
bfb29a60b802 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 84
diff changeset
65 protected override void Translate()
bfb29a60b802 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 84
diff changeset
66 {
bfb29a60b802 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 84
diff changeset
67 base.Translate();
86
9515b57ba752 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
68 ControlTranslator.TranslateButtons(bttnCreate, bttnCancel);
85
bfb29a60b802 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 84
diff changeset
69 }
bfb29a60b802 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 84
diff changeset
70
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 protected virtual void OnSelectionChanged(object o, EventArgs e)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 {
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
73 logger.Debug("Race selection changed");
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
74 SetArmyName();
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
75 SetOkayButtonState();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
77
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
78 private void SetOkayButtonState()
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 {
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
80 bttnCreate.Sensitive = (lstRaces.Selection.CountSelectedRows() == 1 && txtArmyName.Text != "" && sbPointsValue.Value > 0);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
83 protected virtual void OnCreateClicked(object sender, System.EventArgs e)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 {
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
85 race = GetSelectedRace();
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
86 armyName = txtArmyName.Text;
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
87 pointsValue = (int)sbPointsValue.Value;
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
88 Respond(ResponseType.Ok);
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
89 }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
90
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
91 private Race GetSelectedRace()
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
92 {
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 TreeModel model;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 TreeIter iter;
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
95 lstRaces.Selection.GetSelected(out model, out iter);
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
96 return (Race)model.GetValue(iter, 0);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
99 protected virtual void OnCancelClicked(object sender, System.EventArgs e)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 Respond(ResponseType.Cancel);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
104 protected virtual void OnTextChanged(object sender, System.EventArgs e)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 {
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
106 SetOkayButtonState();
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
107 isDefaultArmyName = false;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
110 protected virtual void OnSpinChangeValue(object o, Gtk.ChangeValueArgs args)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 {
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
112 SetArmyName();
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
113 SetOkayButtonState();
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
116 protected virtual void OnSpinValueChanged(object sender, System.EventArgs e)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 {
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
118 SetArmyName();
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
119 SetOkayButtonState();
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
120 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
121
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
122 protected virtual void OnSystemComboChanged(object sender, System.EventArgs e)
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
123 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
124 GameSystem system = ComboBoxUtils.GetSelectedItem<GameSystem>(systemCombo);
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
125 SetRaces(system);
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
126 sbPointsValue.Value = system.SystemArmyDefaultSize;
84
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
127 ListStore model = (ListStore)lstRaces.Model;
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
128
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
129 if (model.IterNChildren() == 1)
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
130 {
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
131 TreeIter iter;
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
132 model.GetIterFirst(out iter);
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
133 lstRaces.Selection.SelectIter(iter);
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
134 SetArmyName();
84
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
135 }
9db2112b31d7 Fixes #333: GTK interface doesn't auto-select race if only one exists
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
136
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
137 logger.Debug("System selection changed: " + (system == null ? "null" : system.Name));
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
138 SetOkayButtonState();
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
139 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
140
36
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
141 private void SetRaces(GameSystem system)
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
142 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
143 ListStore store = new ListStore(typeof(Race));
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
144
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
145 if (system != null)
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
146 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
147 foreach (Race race in WarFoundryLoader.GetDefault().GetRaces(system))
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
148 {
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
149 store.AppendValues(race);
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
150 }
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
151 }
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
152
d68992a831df Fixes #182: Make GTK# more like WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
153 lstRaces.Model = store;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
155
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
156 private void SetArmyName()
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
157 {
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
158 if (isDefaultArmyName || txtArmyName.Text == "")
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
159 {
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
160 if (lstRaces.Selection.CountSelectedRows() == 1)
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
161 {
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
162 GameSystem currSystem = SelectedGameSystem;
139
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
163 int points = (int)sbPointsValue.Value;
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 134
diff changeset
164 txtArmyName.Text = Army.GenerateDefaultName(GetSelectedRace(), points, currSystem.GetPointsAbbrev(points));
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
165 }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
166 else {
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
167 txtArmyName.Text = "";
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
168 }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
169
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
170 isDefaultArmyName = true;
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
171 }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
172 }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
173
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 public Race SelectedRace
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 get { return race; }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
178
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 public string ArmyName
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 get { return armyName; }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 }
77
68804784bf6f Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
183
75
2ceae5d685d8 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
184 public int ArmySize
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 get { return pointsValue; }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 }
134
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
188
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
189 private GameSystem SelectedGameSystem
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
190 {
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
191 get { return ComboBoxUtils.GetSelectedItem<GameSystem>(systemCombo); }
7e77e79e5fdd Fixes #325: Use default army size when creating armies
IBBoard <dev@ibboard.co.uk>
parents: 133
diff changeset
192 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 }