annotate FrmEditEquipment.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
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (FrmEditEquipment.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
e3fe48c4d794 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.
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
4
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
e3fe48c4d794 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;
e3fe48c4d794 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;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using Gtk;
e3fe48c4d794 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;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using IBBoard.GtkSharp;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using log4net.Repository.Hierarchy;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 using log4net;
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
13
64
e3fe48c4d794 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
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public partial class FrmEditEquipment : Dialog, IEditEquipmentUI
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
e3fe48c4d794 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(FrmAddEquipment));
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
e3fe48c4d794 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;
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
21
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 public event MethodInvoker UnitEquipmentAmountTypeChanged;
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
23
64
e3fe48c4d794 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: 64
diff changeset
25 private bool isRatioLimited;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
26
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 public FrmEditEquipment()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 this.Build();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 TreeViewColumn equipColumn = new TreeViewColumn();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 equipColumn.Title = "Equipment";
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 CellRendererText equipCell = new CellRendererText();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 equipColumn.PackStart(equipCell, true);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 equipColumn.SetCellDataFunc(equipCell, GtkWarFoundryUtil.RenderWarFoundryObjectName);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
e3fe48c4d794 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: 64
diff changeset
37 public void ListenToWidgets()
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
38 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
39 rbEquipAll.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
40 rbEquipNumeric.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
41 rbEquipPercent.Clicked += RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
42 numericAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
43 percentageAmount.ValueChanged += SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
44 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
45
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
46 public void IgnoreWidgets()
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
47 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
48 rbEquipAll.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
49 rbEquipNumeric.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
50 rbEquipPercent.Clicked -= RadioButtonClicked;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
51 numericAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
52 percentageAmount.ValueChanged -= SpinButtonValueChanged;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
53 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
54
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 private void OnUnitEquipmentAmountChanged()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 if (UnitEquipmentAmountChanged != null)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 UnitEquipmentAmountChanged();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 private void OnUnitEquipmentAmountTypeChanged()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 if (UnitEquipmentAmountChanged != null)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 UnitEquipmentAmountTypeChanged();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 public void SetUnitEquipmentLimits(bool isRatioLimit, double minPercent, double maxPercent, int minNumber, int maxNumber)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 log.DebugFormat("IsRatio? {0}. Limits: {1}->{2}, {3}%->{4}%", isRatioLimit, minNumber, maxNumber, minPercent, maxPercent);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74 numericAmount.SetRange(minNumber, maxNumber);
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
75 percentageAmount.SetRange(minPercent, maxPercent);
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
76 SetEquipmentAmountType(isRatioLimit);
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
77 isRatioLimited = isRatioLimit;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
78 }
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
79
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
80 public void SetEquipmentAmountType(bool isRatioAmount)
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
81 {
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
82 if (isRatioAmount)
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 {
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
84 if (percentageAmount.Value == 100)
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 rbEquipAll.Active = true;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 else
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 rbEquipPercent.Active = true;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 else
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 rbEquipNumeric.Active = true;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 public void SetUnitEquipmentLimitsEnabled(bool isEnabled)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 SetNumericAmountEnabledState(isEnabled);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 SetPercentageAmountEnabledState(isEnabled);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 public bool ShowControl()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 int result = Run();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 bool okayClicked = (result == (int)ResponseType.Ok);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 this.Hide();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 return okayClicked;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 protected virtual void CancelButtonClicked(object sender, System.EventArgs e)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 log.Debug("Cancel clicked");
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116 Respond(ResponseType.Cancel);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 protected virtual void OkayButtonClicked(object sender, System.EventArgs e)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 log.Debug("Okay clicked");
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 Respond(ResponseType.Ok);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
125 public void SetOkayEnabledState(bool enabled)
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127 buttonOk.Sensitive = enabled;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
130 protected virtual void SpinButtonValueChanged(object sender, System.EventArgs e)
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 OnUnitEquipmentAmountChanged();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 protected virtual void RadioButtonClicked(object sender, System.EventArgs e)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 OnUnitEquipmentAmountTypeChanged();
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
140 public void SetNumericAmountEnabledState(bool enabled)
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 {
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
142 double minPercent = GetMinPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
143 rbEquipNumeric.Sensitive = enabled && !(isRatioLimited && minPercent == 100);
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
144 numericAmount.Sensitive = rbEquipNumeric.Sensitive;
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146
e3fe48c4d794 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)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 if (enabled)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 double minPercentage = GetMinPercentage();
70
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
152 rbEquipPercent.Sensitive = isRatioLimited && minPercentage != 100;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
153 percentageAmount.Sensitive = rbEquipPercent.Sensitive;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
154 double maxPercentage = GetMaxPercentage();
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
155 rbEquipAll.Sensitive = isRatioLimited && maxPercentage == 100;
4b82515586ac Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 64
diff changeset
156 lblEquipAll.Sensitive = rbEquipAll.Sensitive;
64
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 else
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 rbEquipPercent.Sensitive = false;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 percentageAmount.Sensitive = false;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 rbEquipAll.Sensitive = false;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 lblEquipAll.Sensitive = false;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 private double GetMaxPercentage()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 double min, max;
e3fe48c4d794 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);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 return max;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 private double GetMinPercentage()
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 double min, max;
e3fe48c4d794 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);
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 return min;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 public bool IsRatioEquipmentAmount
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
182 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
183 get
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
184 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
185 return !rbEquipNumeric.Active;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
186 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
187 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
188
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
189 public int EquipmentNumericAmount
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
190 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
191 get
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
192 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
193 return (int)numericAmount.Value;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
194 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
195
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
196 set
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
197 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
198 numericAmount.Value = value;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
199 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
200 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
201
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
202 public double EquipmentPercentageAmount
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
203 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
204 get
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
205 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
206 double percent;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
207
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
208 if (rbEquipAll.Active)
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
209 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
210 percent = 100;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
211 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
212 else
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
213 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
214 percent = percentageAmount.Value;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
215 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
216
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
217 return percent;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
218 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
219
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
220 set
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
221 {
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
222 percentageAmount.Value = value;
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
223 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
224 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
225 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
226 }
e3fe48c4d794 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
227