annotate Widgets/UnitDisplayWidget.cs @ 65:77448375d2f9

Re #60: Add UI to add/remove/edit weapons in GTK * Add titles and make dialogs not appear on task list * Capture ratio amounts in Control object's local variable, otherwise we get 0s * Set initial values when editing equipment * Only enable the Edit button when we can edit
author IBBoard <dev@ibboard.co.uk>
date Sat, 04 Sep 2010 10:25:39 +0000
parents e3fe48c4d794
children 7028e24b67ec
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: 15
diff changeset
1 // This file (UnitDisplayWidget.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: 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.
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.Commands;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.Lang;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API;
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
10 using WFObjects = IBBoard.WarFoundry.API.Objects;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using IBBoard.WarFoundry.API.Commands;
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
12 using IBBoard.WarFoundry.GUI.GTK.UIControl;
53
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.Objects;
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
14 using IBBoard.WarFoundry.API.Util;
59
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
15 using IBBoard.GtkSharp;
60
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
16 using log4net;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
5
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
18 namespace IBBoard.WarFoundry.GTK.Widgets
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
5
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
20 [System.ComponentModel.Category("WarFoundry GTK# GUI")]
65279b85446f Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
21 [System.ComponentModel.ToolboxItem(true)]
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 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
23 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
24 private static ILog log = LogManager.GetLogger(typeof(UnitDisplayWidget));
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
25
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
26 private WFObjects.Unit unit;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 private CommandStack stack;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
29 public UnitDisplayWidget(WFObjects.Unit sourceUnit, CommandStack commandStack)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 this.Build();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 stack = commandStack;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 unit = sourceUnit;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 unitName.Text = unit.Name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 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
36 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
37 int minSize = unit.UnitType.MinSize;
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
38 unitSize.SetRange(minSize, maxSize);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
39 unitSize.Sensitive = (maxSize != minSize);
48
23238d998535 Re #86: Complete initial GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
40 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
41 unit.NameChanged += UnitNameChanged;
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
42 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
43 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
44 equipmentList.Selection.Changed += HandleEquipmentListSelectionChanged;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 SetStats();
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
46 SetWeapons();
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
47 }
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
48
60
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
49 private void HandleEquipmentListSelectionChanged (object sender, EventArgs e)
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
50 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
51 SetButtonsEnabledState();
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
52 }
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
53 private void SetButtonsEnabledState()
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
54 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
55 UnitEquipmentItem equipItem = GetSelectedEquipmentItem();
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
56 bttnReplaceEquipment.Sensitive = (equipItem != null && equipItem.HasAlternatives());
65
77448375d2f9 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
57 bttnEditEquipment.Sensitive = (UnitEquipmentUtil.CanEditEquipmentAmount(unit, equipItem));
60
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
58 bttnRemoveEquipment.Sensitive = (equipItem != null && !equipItem.IsRequired);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
59 }
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
60 private UnitEquipmentItem GetSelectedEquipmentItem()
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
61 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
62 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(equipmentList);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
63 }
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
64
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
65 private void SetStats()
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
66 {
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 CellRendererText renderer = new CellRendererText();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 unitStats.AppendColumn(Translation.GetTranslation("UnitNameColumn", "Unit Type", null), renderer, new TreeCellDataFunc(RenderUnitName));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69
11
4e5e382fbd2e Re #10 (Code readability) and Re #86 (Complete GTK# GUI):
IBBoard <dev@ibboard.co.uk>
parents: 5
diff changeset
70 TreeCellDataFunc statFunc = new TreeCellDataFunc(RenderUnitStat);
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
71 Stat[] stats = unit.UnitStatsArray;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
72
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
73 int length = stats.Length;
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
74
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
75 for (int i = 0; i < length; i++)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 {
34
a35c8be46006 Re #198: Add unit equipment slots
IBBoard <dev@ibboard.co.uk>
parents: 19
diff changeset
77 unitStats.AppendColumn(stats[i].ParentSlotName, renderer, statFunc);
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
78 }
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
80 TreeStore model = new TreeStore(typeof(WFObjects.Unit));
13
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
81 model.AppendValues(unit);
6b2c8e55564a * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 11
diff changeset
82 unitStats.Model = model;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 private void RenderUnitName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 object o = model.GetValue(iter, 0);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
89 if (o is WFObjects.Unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 {
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
91 WFObjects.Unit u = (WFObjects.Unit)o;
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 (cell as CellRendererText).Text = u.UnitType.Name;
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 private void RenderUnitStat(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
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 object o = model.GetValue(iter, 0);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
100 if (o is WFObjects.Unit)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 {
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
102 WFObjects.Unit u = (WFObjects.Unit)o;
11
4e5e382fbd2e Re #10 (Code readability) and Re #86 (Complete GTK# GUI):
IBBoard <dev@ibboard.co.uk>
parents: 5
diff changeset
103 (cell as CellRendererText).Text = u.GetStatValue(column.Title);
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 }
15
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 13
diff changeset
106
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
107 private void SetWeapons()
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
108 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
109 CellRendererText renderer = new CellRendererText();
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
110 equipmentList.AppendColumn("", renderer, new TreeCellDataFunc(RenderEquipmentLine));
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
111
59
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
112 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
113
58
7bba99c368c8 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 53
diff changeset
114 foreach (UnitEquipmentItem item in unit.GetEquipment())
7bba99c368c8 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 53
diff changeset
115 {
7bba99c368c8 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 53
diff changeset
116 model.AppendValues(item);
7bba99c368c8 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 53
diff changeset
117 }
7bba99c368c8 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 53
diff changeset
118
53
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
119 equipmentList.Model = model;
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
120 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
121
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
122 public void RenderEquipmentLine(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
123 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
124 object o = model.GetValue(iter, 0);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
125
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
126 if (o is UnitEquipmentItem)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
127 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
128 UnitEquipmentItem item = (UnitEquipmentItem)o;
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
129 (cell as CellRendererText).Text = GetUnitEquipmentText(item);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
130 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
131
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
132 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
133
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
134 private string GetUnitEquipmentText(UnitEquipmentItem item)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
135 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
136 string translation = "";
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
137
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
138 if (item.Cost == 0)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
139 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
140 translation = Translation.GetTranslation("equipmentAmountWithZeroCost", "{0} ({1} - free)", item.Name, GetAmountString(item));
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
141 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
142 else
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
143 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
144 translation = Translation.GetTranslation("equipmentAmountWithCost", "{0} ({1} at {2}pts each)", item.Name, GetAmountString(item), item.Cost);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
145 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
146
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
147 return translation;
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
148 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
149
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
150 private string GetAmountString(UnitEquipmentItem item)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
151 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
152 double amount = UnitEquipmentUtil.GetEquipmentAmount(unit, item);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
153 string amountString = "";
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
154
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
155 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, item))
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
156 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
157 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, item);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
158
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
159 if (amount == 100)
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
160 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
161 amountString = Translation.GetTranslation("equipmentChoiceAmountAll", "all ({1})", amount, number);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
162 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
163
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
164 else
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
165 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
166 amountString = Translation.GetTranslation("equipmentChoiceAmountPercentage", "{0}% ({1})", amount, number);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
167 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
168 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
169 else
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
170 {
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
171 amountString = Translation.GetTranslation("equipmentChoiceAmountNumber", "{0}", amount);
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
172 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
173
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
174 return amountString;
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
175 }
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
176
28b242612ad7 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 52
diff changeset
177 public WFObjects.Unit Unit
15
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 13
diff changeset
178 {
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 13
diff changeset
179 get { return unit; }
85db2c9a1546 Fixes #95: Can't re-open GTK# tabs
IBBoard <dev@ibboard.co.uk>
parents: 13
diff changeset
180 }
0
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 private void UnitNameChanged(WarFoundryObject obj, string oldValue, string newValue)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 unitName.Text = newValue;
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
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 private void UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 unitSize.Value = newValue;
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
59
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
192 private void HandleUnitUnitEquipmentAmountChanged(WarFoundryObject obj, double oldValue, double newValue)
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
193 {
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
194 if (oldValue == 0)
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
195 {
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
196 ((ListStore)equipmentList.Model).AppendValues(obj);
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
197 }
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
198 else if (newValue == 0)
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
199 {
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
200 TreeIter treeIter = TreeUtils.GetItemIter(equipmentList, obj);
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
201 ((ListStore)equipmentList.Model).Remove(ref treeIter);
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
202 }
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
203
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
204 equipmentList.QueueDraw();
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
205 }
c3415c6df551 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 58
diff changeset
206
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 protected virtual void OnUnitSizeFocusOut (object o, Gtk.FocusOutEventArgs args)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 SetNewUnitSize();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 [GLib.ConnectBefore ()]
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 protected virtual void OnUnitSizeKeyPress (object o, Gtk.KeyPressEventArgs args)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 {
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
215 if (args.Event.Key == Gdk.Key.Return || args.Event.Key == Gdk.Key.KP_Enter)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 SetNewUnitSize();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 private void SetNewUnitSize()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 if (unitSize.Value!=unit.Size)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 SetUnitSizeCommand cmd = new SetUnitSizeCommand(unit, (int)Math.Round(unitSize.Value));
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 stack.Execute(cmd);
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 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230 protected virtual void OnUnitNameFocusOut (object o, Gtk.FocusOutEventArgs 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 SetNewUnitName();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235 [GLib.ConnectBefore ()]
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 protected virtual void OnUnitNameKeyPress (object o, Gtk.KeyPressEventArgs args)
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237 {
49
d29ad8445461 Re #86: Complete GTK# UI
IBBoard <dev@ibboard.co.uk>
parents: 48
diff changeset
238 if (args.Event.Key == Gdk.Key.Return || args.Event.Key == Gdk.Key.KP_Enter)
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 {
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 SetNewUnitName();
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244 private void SetNewUnitName()
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 {
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
246 if (unitName.Text != unit.Name)
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 SetNameCommand cmd = new SetNameCommand(unit, unitName.Text);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249 stack.Execute(cmd);
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251 }
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
252
52
4bad8cb3f889 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 51
diff changeset
253 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
254 {
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
255 AddEquipment();
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
256 }
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
257
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
258 private void AddEquipment()
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
259 {
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
260 AddEquipmentUIControl addEquipment = new AddEquipmentUIControl(unit, stack);
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
261 addEquipment.Show();
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 49
diff changeset
262 }
60
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
263
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
264 protected virtual void HandleRemoveButtonActivated(object sender, System.EventArgs e)
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
265 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
266 UnitEquipmentItem item = GetSelectedEquipmentItem();
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
267 log.Debug("Remove "+item);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
268
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
269 if (item != null)
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
270 {
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
271 SetUnitEquipmentNumericAmountCommand cmd = new SetUnitEquipmentNumericAmountCommand(unit, item, 0);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
272 stack.Execute(cmd);
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
273 }
04c0f6a7625c Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 59
diff changeset
274 }
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
275
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
276 protected virtual void HandleEditButtonClicked(object sender, System.EventArgs e)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
277 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
278 UnitEquipmentItem item = GetSelectedEquipmentItem();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
279 log.Debug("Edit " + item);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
280
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
281 if (item != null)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
282 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
283 EditEquipmentUIControl editEquipment = new EditEquipmentUIControl(unit, item, stack);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
284 editEquipment.Show();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
285 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
286 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
287
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 60
diff changeset
288
0
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
289 }
1bb28f84d567 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
290 }