annotate FrmReplaceEquipment.cs @ 68:7028e24b67ec

Re #60: Add UI to add/remove/edit weapons in GTK * Add "Replace" dialog Note: Dialog null refs because of a bad assumption in the base class - base constructor calls SetupUI before Replace constructor has set all of its values
author IBBoard <dev@ibboard.co.uk>
date Wed, 03 Nov 2010 21:02:54 +0000
parents
children 4b82515586ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (FrmAddEquipment.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
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.
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using Gtk;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.GUI.GTK.Util;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using IBBoard.GtkSharp;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using log4net.Repository.Hierarchy;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 using log4net;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 namespace IBBoard.WarFoundry.GUI.GTK
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public partial class FrmReplaceEquipment : Dialog, IReplaceEquipmentUI
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private static ILog log = LogManager.GetLogger(typeof(FrmReplaceEquipment));
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public event MethodInvoker UnitEquipmentAmountTypeChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 public event MethodInvoker UnitEquipmentAmountChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 private bool limitsEnabled = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 private bool ratioLimited = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 public FrmReplaceEquipment()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 this.Build();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 lstEquipment.Selection.Changed += OnSelectionChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 TreeViewColumn equipColumn = new TreeViewColumn();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 equipColumn.Title = "Equipment";
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 CellRendererText equipCell = new CellRendererText();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 equipColumn.PackStart(equipCell, true);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 lstEquipment.AppendColumn(equipColumn);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 private void OnUnitEquipmentAmountChanged()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 if (UnitEquipmentAmountChanged != null)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 UnitEquipmentAmountChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 private void OnUnitEquipmentAmountTypeChanged()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 if (UnitEquipmentAmountChanged != null)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 UnitEquipmentAmountTypeChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 protected void OnSelectionChanged(object o, EventArgs e)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 if (UnitEquipmentItemChoiceChanged != null)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 public void SetUnitEquipmentItems(UnitEquipmentItem[] items)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 ListStore store = new ListStore(typeof(UnitEquipmentItem));
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 foreach (UnitEquipmentItem equipItem in items)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 store.AppendValues(equipItem);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 lstEquipment.Model = store;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 ratioLimited = isRatioLimit;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 numericAmount.SetRange(minNumber, maxNumber);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 percentageAmount.SetRange(minPercent, maxPercent);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 if (isRatioLimit)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 if (minPercent == 100)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 rbEquipAll.Active = true;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 rbEquipPercent.Active = true;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 rbEquipNumeric.Active = true;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 SetNumericAmountEnabledState(isEnabled);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 SetPercentageAmountEnabledState(isEnabled);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 public bool ShowControl()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 int result = Run();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 bool okayClicked = (result == (int)ResponseType.Ok);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 this.Hide();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 return okayClicked;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 log.Debug("Cancel clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 Respond(ResponseType.Cancel);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 protected virtual void OkayButtonClicked(object sender, System.EventArgs e)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 log.Debug("Okay clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 Respond(ResponseType.Ok);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 public void SetOkayEnabledState(bool enabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 buttonOk.Sensitive = enabled;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 OnUnitEquipmentAmountChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 protected virtual void RadioButtonClicked(object sender, System.EventArgs e)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 OnUnitEquipmentAmountTypeChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 public void SetNumericAmountEnabledState(bool enabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 rbEquipNumeric.Sensitive = enabled;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144 numericAmount.Sensitive = enabled;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 public void SetPercentageAmountEnabledState(bool enabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 if (enabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 double minPercentage = GetMinPercentage();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 rbEquipPercent.Sensitive = minPercentage != 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 percentageAmount.Sensitive = minPercentage != 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 double maxPercentage = GetMaxPercentage();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 rbEquipAll.Sensitive = ratioLimited && maxPercentage == 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156 lblEquipAll.Sensitive = ratioLimited && maxPercentage == 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 rbEquipPercent.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 percentageAmount.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 rbEquipAll.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 lblEquipAll.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 private double GetMaxPercentage()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 percentageAmount.GetRange(out min, out max);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 return max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 private double GetMinPercentage()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 percentageAmount.GetRange(out min, out max);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 return min;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 public UnitEquipmentItem SelectedUnitEquipmentItem
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 return (UnitEquipmentItem)TreeUtils.GetSelectedItem(lstEquipment);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 public bool IsRatioEquipmentAmount
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 return !rbEquipNumeric.Active;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 public int EquipmentNumericAmount
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201 return (int)numericAmount.Value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 set
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 numericAmount.Value = value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 public double EquipmentPercentageAmount
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 double percent;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 if (rbEquipAll.Active)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 percent = 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 percent = percentageAmount.Value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 return percent;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
228 set
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
230 percentageAmount.Value = value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
231 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
232 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
233 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
234 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235