annotate FrmReplaceEquipment.cs @ 80:9c9af2ce8c43

Re #308: Make GTK# UI translatable * Make About box translatable (dialog title) and add translation
author IBBoard <dev@ibboard.co.uk>
date Tue, 28 Dec 2010 14:32:38 +0000
parents 7055b24cfc79
children b4416ca69153
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;
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
6 using Gtk;
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
7 using IBBoard.GtkSharp;
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
8 using IBBoard.GtkSharp.Translatable;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Objects;
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
10 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 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
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 {
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
16 public partial class FrmReplaceEquipment : TranslatableDialog, IReplaceEquipmentUI
68
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 public event SingleArgMethodInvoker<UnitEquipmentItem> UnitEquipmentItemChoiceChanged;
76
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
20 public event MethodInvoker UnitEquipmentAmountTypeChanged;
7055b24cfc79 Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents: 70
diff changeset
21 public event MethodInvoker UnitEquipmentAmountChanged;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
23 private bool isRatioLimited;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 public FrmReplaceEquipment()
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 this.Build();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 lstEquipment.Selection.Changed += OnSelectionChanged;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 TreeViewColumn equipColumn = new TreeViewColumn();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 equipColumn.Title = "Equipment";
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 CellRendererText equipCell = new CellRendererText();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 equipColumn.PackStart(equipCell, true);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 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
34 lstEquipment.AppendColumn(equipColumn);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
37 public void ListenToWidgets()
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
38 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
39 rbEquipAll.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
40 rbEquipNumeric.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
41 rbEquipPercent.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
42 numericAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
43 percentageAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
44 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
45 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
46
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
47 public void IgnoreWidgets()
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 rbEquipAll.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
50 rbEquipNumeric.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
51 rbEquipPercent.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
52 numericAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
53 percentageAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
54 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
55 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
56
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 private void OnUnitEquipmentAmountChanged()
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 if (UnitEquipmentAmountChanged != null)
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 UnitEquipmentAmountChanged();
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 private void OnUnitEquipmentAmountTypeChanged()
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 if (UnitEquipmentAmountChanged != null)
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 UnitEquipmentAmountTypeChanged();
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 }
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 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
74 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 if (UnitEquipmentItemChoiceChanged != null)
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 UnitEquipmentItemChoiceChanged(SelectedUnitEquipmentItem);
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 }
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 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
82 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 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
84
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 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
86 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 store.AppendValues(equipItem);
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 lstEquipment.Model = store;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 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
94 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 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
96 numericAmount.SetRange(minNumber, maxNumber);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 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
98 isRatioLimited = isRatioLimit;
68
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 if (isRatioLimit)
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 (minPercent == 100)
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 rbEquipAll.Active = true;
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 else
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 rbEquipPercent.Active = true;
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 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 else
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 rbEquipNumeric.Active = true;
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 }
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 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
118 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 SetNumericAmountEnabledState(isEnabled);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 SetPercentageAmountEnabledState(isEnabled);
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 public bool ShowControl()
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 int result = Run();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 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
127 this.Hide();
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 return okayClicked;
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 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
132 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 log.Debug("Cancel clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 Respond(ResponseType.Cancel);
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 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
138 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 log.Debug("Okay clicked");
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 Respond(ResponseType.Ok);
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 }
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 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
144 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 buttonOk.Sensitive = 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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 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
149 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 OnUnitEquipmentAmountChanged();
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 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
154 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 OnUnitEquipmentAmountTypeChanged();
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 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
159 {
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
160 double minPercent = GetMinPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
161 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
162 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
163 }
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 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
166 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 if (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 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
170 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
171 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
172 double maxPercentage = GetMaxPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
173 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
174 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
175 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 else
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 rbEquipPercent.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 percentageAmount.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 rbEquipAll.Sensitive = false;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 lblEquipAll.Sensitive = false;
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 }
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 private double GetMaxPercentage()
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 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188 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
189 return max;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 private double GetMinPercentage()
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 double min, max;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195 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
196 return min;
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 }
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 public UnitEquipmentItem SelectedUnitEquipmentItem
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 get
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 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
204 }
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
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
207 public bool IsRatioEquipmentAmount
68
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 get
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 return !rbEquipNumeric.Active;
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 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
215 public int EquipmentNumericAmount
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216 {
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 get
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 return (int)numericAmount.Value;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 set
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 numericAmount.Value = value;
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 }
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 68
diff changeset
228 public double EquipmentPercentageAmount
68
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 get
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 double percent;
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 if (rbEquipAll.Active)
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 percent = 100;
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 else
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 percent = percentageAmount.Value;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
243 return percent;
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
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
246 set
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 percentageAmount.Value = value;
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 }
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