Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
annotate Widgets/UnitDisplayWidget.cs @ 143:aca4623b7bdf
Re #344: Show unit requirement failures
* Hide warning widget by default
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 19 Oct 2011 20:35:31 +0100 |
parents | fda46380dd68 |
children |
rev | line source |
---|---|
19
a191d0655f55
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
1 // This file (UnitDisplayWidget.cs) is a part of the IBBoard.WarFoundry.GTK project and is copyright 2008, 2009 IBBoard. |
0 | 2 // |
19
a191d0655f55
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
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. |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
4 |
0 | 5 using System; |
6 using Gtk; | |
7 using IBBoard.Commands; | |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
8 using IBBoard.GtkSharp; |
0 | 9 using IBBoard.Lang; |
10 using IBBoard.WarFoundry.API; | |
11 using IBBoard.WarFoundry.API.Commands; | |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
12 using IBBoard.WarFoundry.API.Objects; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
13 using IBBoard.WarFoundry.API.Util; |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
14 using IBBoard.WarFoundry.GUI.GTK.UIControl; |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
15 using log4net; |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
16 using WFObjects = IBBoard.WarFoundry.API.Objects; |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
17 using System.Collections.Generic; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
18 using IBBoard.GtkSharp.Translatable; |
0 | 19 |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
20 namespace IBBoard.WarFoundry.GUI.GTK.Widgets |
0 | 21 { |
5 | 22 [System.ComponentModel.Category("WarFoundry GTK# GUI")] |
23 [System.ComponentModel.ToolboxItem(true)] | |
0 | 24 public partial class UnitDisplayWidget : Gtk.Bin |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
25 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
26 private static ILog log = LogManager.GetLogger(typeof(UnitDisplayWidget)); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
27 private WFObjects.Unit unit; |
0 | 28 private CommandStack stack; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
29 private Dictionary<string, NodeView> statsViews = new Dictionary<string, NodeView>(); |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
30 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
31 public UnitDisplayWidget(WFObjects.Unit sourceUnit, CommandStack commandStack) |
0 | 32 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
33 this.Build(); |
0 | 34 stack = commandStack; |
35 unit = sourceUnit; | |
36 unitName.Text = unit.Name; | |
37 unitSize.Value = unit.Size; | |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
38 int maxSize = (unit.UnitType.MaxSize == WarFoundryCore.INFINITY ? int.MaxValue : unit.UnitType.MaxSize); |
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
39 int minSize = unit.UnitType.MinSize; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
40 unitSize.SetRange(minSize, maxSize); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
41 unitSize.Sensitive = (maxSize != minSize); |
48
23238d998535
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
34
diff
changeset
|
42 notesView.Buffer.Text = unit.UnitType.Notes; |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
43 unit.NameChanged += UnitNameChanged; |
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
44 unit.UnitSizeChanged += UnitSizeChanged; |
59
c3415c6df551
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
45 unit.UnitEquipmentAmountChanged += HandleUnitUnitEquipmentAmountChanged; |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
46 equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
47 SetAbilities(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
48 SetStats(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
49 SetWeapons(); |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
50 SetAddButtonEnabledState(); |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
51 ControlTranslator.TranslateWidget(this); |
13 | 52 } |
53 | |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
54 private void HandleEquipmentListSelectionChanged(object sender, EventArgs e) |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
55 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
56 SetButtonsEnabledState(); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
57 } |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
58 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
59 private void SetButtonsEnabledState() |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
60 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
61 UnitEquipmentItem equipItem = GetSelectedEquipmentItem(); |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
62 bttnReplaceWeapon.Sensitive = (equipItem != null && equipItem.HasAlternatives()); |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
63 bttnEditWeapon.Sensitive = (UnitEquipmentUtil.CanEditEquipmentAmount(unit, equipItem)); |
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
64 bttnRemoveWeapon.Sensitive = (equipItem != null && !equipItem.IsRequired); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
65 } |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
66 |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
67 private void SetAddButtonEnabledState() |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
68 { |
96
b4416ca69153
Fixes #309: Add initial preference dialog with language support
IBBoard <dev@ibboard.co.uk>
parents:
92
diff
changeset
|
69 bttnAddWeapon.Sensitive = AddEquipmentUIControl.HasEquipmentToAdd(unit); |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
70 } |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
71 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
72 private UnitEquipmentItem GetSelectedEquipmentItem() |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
73 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
74 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
75 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
76 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
77 private void SetAbilities() |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
78 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
79 CellRendererText renderer = new CellRendererText(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
80 abilitiesList.AppendColumn("", renderer, new TreeCellDataFunc(RenderAbility)); |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
81 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
82 ListStore model = new ListStore(typeof(Ability)); |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
83 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
84 foreach (Ability ability in unit.UnitType.GetRequiredAbilities()) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
85 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
86 model.AppendValues(ability); |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
87 } |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
88 |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
89 abilitiesList.Model = model; |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
90 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
91 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
92 public void RenderAbility(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
93 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
94 object o = model.GetValue(iter, 0); |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
95 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
96 if (o is Ability) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
97 { |
71
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
98 Ability ability = (Ability)o; |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
99 (cell as CellRendererText).Text = ability.Name; |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
100 } |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
101 |
91354245218a
Fixes #305: Add abilities to GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
102 } |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
103 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
104 private void SetStats() |
13 | 105 { |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
106 Stat[][] stats = unit.UnitStatsArraysWithName; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
107 string[] statsIDs = unit.UnitStatsArrayIDs; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
108 int statsCount = stats.Length; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
109 log.DebugFormat("Unit {0} has {1} stats arrays", unit.UnitType.Name, statsCount); |
13 | 110 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
111 for (int i = 0; i < statsCount; i++) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
112 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
113 NodeView statsGrid = GetStatsView(statsIDs[i]); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
114 TreeStore model = (TreeStore)statsGrid.Model; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
115 log.DebugFormat("Adding row to data table for {0}", statsIDs[i]); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
116 log.DebugFormat("TreeStore supports {0} columns", model.NColumns); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
117 model.AppendValues((object)stats[i]); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
118 } |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
119 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
120 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
121 private NodeView GetStatsView(string statsID) |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
122 { |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
123 NodeView statsView; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
124 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
125 if (statsViews.ContainsKey(statsID)) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
126 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
127 statsView = DictionaryUtils.GetValue(statsViews, statsID); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
128 } |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
129 else |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
130 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
131 statsView = CreateStatsView(statsID); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
132 statsViews[statsID] = statsView; |
13 | 133 } |
0 | 134 |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
135 return statsView; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
136 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
137 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
138 private NodeView CreateStatsView(string statsID) |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
139 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
140 log.DebugFormat("Create NodeView for stats ID {0}", statsID); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
141 SystemStats sysStats = unit.Race.GameSystem.GetSystemStatsForID(statsID); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
142 StatSlot[] sysStatSlots = sysStats.StatSlots; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
143 int statsCount = sysStatSlots.Length; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
144 NodeView statsGrid = CreateNodeView(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
145 CellRendererText renderer = new CellRendererText(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
146 statsGrid.AppendColumn(Translation.GetTranslation("UnitNameColumn", "Unit Type", null), renderer, RenderUnitStat); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
147 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
148 for (int i = 0; i < statsCount; i++) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
149 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
150 StatSlot stat = sysStatSlots[i]; |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
151 string slotName = stat.Name; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
152 statsGrid.AppendColumn(slotName, renderer, RenderUnitStat); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
153 } |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
154 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
155 statsGrid.Model = new TreeStore(typeof(Stat[])); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
156 return statsGrid; |
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
157 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
158 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
159 private NodeView CreateNodeView() |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
160 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
161 NodeView nodeView = new NodeView(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
162 statsRepeatBox.Add(nodeView); |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
163 return nodeView; |
0 | 164 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
165 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
166 private void RenderUnitStat(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) |
0 | 167 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
168 object o = model.GetValue(iter, 0); |
0 | 169 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
170 if (o is Stat[]) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
171 { |
73
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
172 Stat[] stats = (Stat[])o; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
173 (cell as CellRendererText).Text = stats[GetStatColumnIndex(column)].SlotValueString; |
0 | 174 } |
175 } | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
176 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
177 private int GetStatColumnIndex(TreeViewColumn column) |
73
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
178 { |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
179 int idx = -1; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
180 TreeViewColumn[] cols = ((TreeView)column.TreeView).Columns; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
181 int colCount = cols.Length; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
182 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
183 for (int i = 0; i < colCount; i++) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
184 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
185 if (cols[i] == column) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
186 { |
73
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
187 idx = i; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
188 break; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
189 } |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
190 } |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
191 |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
192 return idx; |
19e7123aafd5
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
72
diff
changeset
|
193 } |
15
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
194 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
195 private void SetWeapons() |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
196 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
197 CellRendererText renderer = new CellRendererText(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
198 equipmentList.AppendColumn("", renderer, new TreeCellDataFunc(RenderEquipmentLine)); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
199 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
200 ListStore model = new ListStore(typeof(UnitEquipmentItem)); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
201 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
202 foreach (UnitEquipmentItem item in unit.GetEquipment()) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
203 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
204 model.AppendValues(item); |
58
7bba99c368c8
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
53
diff
changeset
|
205 } |
7bba99c368c8
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
53
diff
changeset
|
206 |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
207 equipmentList.Model = model; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
208 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
209 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
210 public void RenderEquipmentLine(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
211 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
212 object o = model.GetValue(iter, 0); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
213 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
214 if (o is UnitEquipmentItem) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
215 { |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
216 UnitEquipmentItem item = (UnitEquipmentItem)o; |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
217 (cell as CellRendererText).Text = GetUnitEquipmentText(item); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
218 } |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
219 |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
220 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
221 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
222 private string GetUnitEquipmentText(UnitEquipmentItem item) |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
223 { |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
224 string translation = ""; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
225 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
226 if (item.Cost == 0) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
227 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
228 translation = Translation.GetTranslation("equipmentAmountWithZeroCost", "{0} ({1} - free)", item.Name, GetAmountString(item)); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
229 } |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
230 else |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
231 { |
135
fda46380dd68
Re #329: "Points" system should be used in UI
IBBoard <dev@ibboard.co.uk>
parents:
96
diff
changeset
|
232 translation = Translation.GetTranslation("equipmentAmountWithCost", "{0} ({1} at {2}{3} each)", item.Name, GetAmountString(item), item.Cost, WarFoundryCore.CurrentGameSystem.GetPointsAbbrev(item.Cost)); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
233 } |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
234 |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
235 return translation; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
236 } |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
237 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
238 private string GetAmountString(UnitEquipmentItem item) |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
239 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
240 double amount = UnitEquipmentUtil.GetEquipmentAmount(unit, item); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
241 string amountString = ""; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
242 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
243 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, item)) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
244 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
245 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, item); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
246 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
247 if (amount == 100) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
248 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
249 amountString = Translation.GetTranslation("equipmentChoiceAmountAll", "all ({1})", amount, number); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
250 } |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
251 else |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
252 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
253 amountString = Translation.GetTranslation("equipmentChoiceAmountPercentage", "{0}% ({1})", amount, number); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
254 } |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
255 } |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
256 else |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
257 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
258 amountString = Translation.GetTranslation("equipmentChoiceAmountNumber", "{0}", amount); |
53
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
259 } |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
260 |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
261 return amountString; |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
262 } |
28b242612ad7
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
52
diff
changeset
|
263 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
264 public WFObjects.Unit Unit |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
265 { |
15
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
266 get { return unit; } |
85db2c9a1546
Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents:
13
diff
changeset
|
267 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
268 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
269 private void UnitNameChanged(WarFoundryObject obj, string oldValue, string newValue) |
0 | 270 { |
271 unitName.Text = newValue; | |
272 } | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
273 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
274 private void UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue) |
0 | 275 { |
276 unitSize.Value = newValue; | |
277 } | |
278 | |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
279 private void HandleUnitUnitEquipmentAmountChanged(WarFoundryObject obj, double oldValue, double newValue) |
59
c3415c6df551
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
280 { |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
281 if (oldValue == 0) |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
282 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
283 ((ListStore)equipmentList.Model).AppendValues(obj); |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
284 } |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
285 else |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
286 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
287 if (newValue == 0) |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
288 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
289 TreeIter treeIter = TreeUtils.GetItemIter(equipmentList, obj); |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
290 ((ListStore)equipmentList.Model).Remove(ref treeIter); |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
291 } |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
292 } |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
293 |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
294 SetAddButtonEnabledState(); |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
77
diff
changeset
|
295 equipmentList.QueueDraw(); |
59
c3415c6df551
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
296 } |
c3415c6df551
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
58
diff
changeset
|
297 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
298 protected virtual void OnUnitSizeFocusOut(object o, Gtk.FocusOutEventArgs args) |
0 | 299 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
300 SetNewUnitSize(); |
0 | 301 } |
302 | |
303 [GLib.ConnectBefore ()] | |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
304 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
305 protected virtual void OnUnitSizeKeyPress(object o, Gtk.KeyPressEventArgs args) |
0 | 306 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
307 if (args.Event.Key == Gdk.Key.Return || args.Event.Key == Gdk.Key.KP_Enter) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
308 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
309 SetNewUnitSize(); |
0 | 310 } |
311 } | |
312 | |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
313 private void SetNewUnitSize() |
0 | 314 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
315 if (unitSize.Value != unit.Size) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
316 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
317 SetUnitSizeCommand cmd = new SetUnitSizeCommand(unit, (int)Math.Round(unitSize.Value)); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
318 stack.Execute(cmd); |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
319 } |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
320 } |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
321 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
322 protected virtual void OnUnitNameFocusOut(object o, Gtk.FocusOutEventArgs args) |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
323 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
324 SetNewUnitName(); |
0 | 325 } |
326 | |
327 [GLib.ConnectBefore ()] | |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
328 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
329 protected virtual void OnUnitNameKeyPress(object o, Gtk.KeyPressEventArgs args) |
0 | 330 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
331 if (args.Event.Key == Gdk.Key.Return || args.Event.Key == Gdk.Key.KP_Enter) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
332 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
333 SetNewUnitName(); |
0 | 334 } |
335 } | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
336 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
337 private void SetNewUnitName() |
0 | 338 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
339 if (unitName.Text != unit.Name) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
340 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
341 SetNameCommand cmd = new SetNameCommand(unit, unitName.Text); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
342 stack.Execute(cmd); |
0 | 343 } |
344 } | |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
345 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
346 private void OnBttnAddEquipmentClicked(object sender, System.EventArgs e) |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
49
diff
changeset
|
347 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
348 AddEquipment(); |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
49
diff
changeset
|
349 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
350 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
351 private void AddEquipment() |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
352 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
353 AddEquipmentUIControl addEquipment = new AddEquipmentUIControl(unit, stack); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
354 addEquipment.Show(); |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
355 } |
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
356 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
357 protected virtual void HandleRemoveButtonActivated(object sender, System.EventArgs e) |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
358 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
359 UnitEquipmentItem item = GetSelectedEquipmentItem(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
360 log.Debug("Remove " + item); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
361 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
362 if (item != null) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
363 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
364 SetUnitEquipmentNumericAmountCommand cmd = new SetUnitEquipmentNumericAmountCommand(unit, item, 0); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
365 stack.Execute(cmd); |
60
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
366 } |
04c0f6a7625c
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
59
diff
changeset
|
367 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
368 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
369 protected virtual void HandleEditButtonClicked(object sender, System.EventArgs e) |
64
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
370 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
371 UnitEquipmentItem item = GetSelectedEquipmentItem(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
372 log.Debug("Edit " + item); |
64
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
373 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
374 if (item != null) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
375 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
376 EditEquipmentUIControl editEquipment = new EditEquipmentUIControl(unit, item, stack); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
377 editEquipment.Show(); |
64
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
378 } |
e3fe48c4d794
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
60
diff
changeset
|
379 } |
77
68804784bf6f
Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents:
73
diff
changeset
|
380 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
381 protected virtual void HandleReplaceButtonClicked(object sender, System.EventArgs e) |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
382 { |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
383 UnitEquipmentItem item = GetSelectedEquipmentItem(); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
384 log.Debug("Replace " + item); |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
385 |
92
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
386 if (item != null) |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
387 { |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
388 ReplaceEquipmentUIControl addEquipment = new ReplaceEquipmentUIControl(unit, item, stack); |
58779fcd0166
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
91
diff
changeset
|
389 addEquipment.Show(); |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
390 } |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
391 } |
0 | 392 } |
72
f0cc295e883c
Re #307: Add support for multiple stat lines
IBBoard <dev@ibboard.co.uk>
parents:
71
diff
changeset
|
393 } |