annotate FrmReplaceEquipment.cs @ 75:2ceae5d685d8

Re #86: Complete initial GTK# UI * Fix default game system selecting
author IBBoard <dev@ibboard.co.uk>
date Tue, 23 Nov 2010 20:17:18 +0000
parents 4b82515586ac
children 7055b24cfc79
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;
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
25 private bool isRatioLimited;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 public FrmReplaceEquipment()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 this.Build();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 lstEquipment.Selection.Changed += OnSelectionChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 TreeViewColumn equipColumn = new TreeViewColumn();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 equipColumn.Title = "Equipment";
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 CellRendererText equipCell = new CellRendererText();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 equipColumn.PackStart(equipCell, true);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 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
36 lstEquipment.AppendColumn(equipColumn);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
39 public void ListenToWidgets()
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
40 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
41 rbEquipAll.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
42 rbEquipNumeric.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
43 rbEquipPercent.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
44 numericAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
45 percentageAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
46 lstEquipment.Selection.Changed += OnSelectionChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
47 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
48
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
49 public void IgnoreWidgets()
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
50 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
51 rbEquipAll.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
52 rbEquipNumeric.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
53 rbEquipPercent.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
54 numericAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
55 percentageAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
56 lstEquipment.Selection.Changed -= OnSelectionChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
57 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
58
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 private void OnUnitEquipmentAmountChanged()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 if (UnitEquipmentAmountChanged != null)
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 UnitEquipmentAmountChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 }
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 private void OnUnitEquipmentAmountTypeChanged()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 if (UnitEquipmentAmountChanged != null)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 UnitEquipmentAmountTypeChanged();
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 }
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 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
76 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 if (UnitEquipmentItemChoiceChanged != null)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 }
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 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
84 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 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
86
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 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
88 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 store.AppendValues(equipItem);
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 lstEquipment.Model = store;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 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
96 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 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
98 numericAmount.SetRange(minNumber, maxNumber);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 percentageAmount.SetRange(minPercent, maxPercent);
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
100 isRatioLimited = isRatioLimit;
68
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 if (isRatioLimit)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 if (minPercent == 100)
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 rbEquipAll.Active = true;
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 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 rbEquipPercent.Active = true;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 }
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 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 rbEquipNumeric.Active = true;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 }
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 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
120 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 SetNumericAmountEnabledState(isEnabled);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 SetPercentageAmountEnabledState(isEnabled);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 }
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 public bool ShowControl()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 int result = Run();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 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
129 this.Hide();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 return okayClicked;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 }
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 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
134 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 log.Debug("Cancel clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 Respond(ResponseType.Cancel);
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 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
140 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 log.Debug("Okay clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 Respond(ResponseType.Ok);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 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
146 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 buttonOk.Sensitive = 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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 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
151 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 OnUnitEquipmentAmountChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 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
156 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 OnUnitEquipmentAmountTypeChanged();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 }
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 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
161 {
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
162 double minPercent = GetMinPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
163 rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100);
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
164 numericAmount.Sensitive = rbEquipNumeric.Sensitive;
68
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 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
168 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 if (enabled)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 double minPercentage = GetMinPercentage();
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
172 rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
173 percentageAmount.Sensitive = rbEquipPercent.Sensitive;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
174 double maxPercentage = GetMaxPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
175 rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
176 lblEquipAll.Sensitive = rbEquipAll.Sensitive;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 else
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 rbEquipPercent.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 percentageAmount.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 rbEquipAll.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 lblEquipAll.Sensitive = false;
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 }
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 private double GetMaxPercentage()
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 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 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
191 return max;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 private double GetMinPercentage()
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 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 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
198 return min;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 }
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 public UnitEquipmentItem SelectedUnitEquipmentItem
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 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 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
206 }
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
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
209 public bool IsRatioEquipmentAmount
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 return !rbEquipNumeric.Active;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 }
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
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
217 public int EquipmentNumericAmount
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219 get
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 return (int)numericAmount.Value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 }
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 set
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 numericAmount.Value = value;
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 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
229
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
230 public double EquipmentPercentageAmount
68
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 get
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 double percent;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
235
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
236 if (rbEquipAll.Active)
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
237 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
238 percent = 100;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
239 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
240 else
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
241 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
242 percent = percentageAmount.Value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
244
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
245 return percent;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
247
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
248 set
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
249 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
250 percentageAmount.Value = value;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
251 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
252 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
253 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
254 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
255