Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
annotate UIControl/AbstractBaseEquipmentUIControl.cs @ 97:6d2c8ad0d8f1
Re #308: Make GTK# UI translatable
* More standardisation of widget names with WinForms
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 02 Jan 2011 15:50:29 +0000 |
parents | 4b82515586ac |
children | fac0636ae13b |
rev | line source |
---|---|
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (AbstractBaseEquipmentUIControl.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
100626381159
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. |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
4 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using IBBoard.Commands; |
100626381159
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; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 using IBBoard.Lang; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 using IBBoard.WarFoundry.API.Util; |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
11 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 namespace IBBoard.WarFoundry.GUI.GTK.UIControl |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public abstract class AbstractBaseEquipmentUIControl<UI_TYPE> where UI_TYPE : IBaseEquipmentUI |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 protected CommandStack commandStack; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 protected Unit unit; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 protected UI_TYPE ui; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 protected UnitEquipmentItem equipItem; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 protected double minPercentage, maxPercentage; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 protected int minNumber, maxNumber; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 protected bool isRatioAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 protected double equipmentAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 public AbstractBaseEquipmentUIControl(Unit unit, CommandStack commandStack) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 this.unit = unit; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 this.commandStack = commandStack; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 private void SetupUI() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 ui = CreateEquipmentUI(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 ui.SetUnitEquipmentLimitsEnabled(false); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 ui.SetOkayEnabledState(false); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 CompleteUISetup(); |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
37 ui.UnitEquipmentAmountChanged += HandleUnitEquipmentAmountChanged; |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
38 ui.UnitEquipmentAmountTypeChanged += HandleUnitEquipmentAmountChanged; |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
39 ui.ListenToWidgets(); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 /// <summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 /// Creates the UI component that will be displayed to the user and returns it |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 /// </summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 /// <returns> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 /// the UI component to display to the user |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 /// </returns> |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
48 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 protected abstract UI_TYPE CreateEquipmentUI(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 /// <summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 /// Completes any additional user interface setup. |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 /// </summary> |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
54 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 protected virtual void CompleteUISetup() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 //Do nothing |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 protected void HandleUnitEquipmentAmountChanged() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 { |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
62 SetUnitEquipmentValuesFromUI(); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
65 protected void SetUnitEquipmentLimits(UnitEquipmentItem equip) |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
66 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
67 ui.IgnoreWidgets(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
68 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
69 if (equip != null) |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
70 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
71 bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
72 maxPercentage = GetMaxPercentageLimit(equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
73 minPercentage = GetMinPercentageLimit(equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
74 maxNumber = GetMaxNumericLimit(equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
75 minNumber = GetMinNumericLimit(equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
76 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
77 ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercentage, maxPercentage, minNumber, maxNumber); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
78 ui.SetUnitEquipmentLimitsEnabled(true); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
79 ui.SetOkayEnabledState(HasNonZeroEquipmentAmount()); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
80 SetEquipmentAmountControlEnabledStates(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
81 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
82 else |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
83 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
84 maxPercentage = minPercentage = 0; |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
85 maxNumber = minNumber = 0; |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
86 ui.SetUnitEquipmentLimits(false, minPercentage, maxPercentage, minNumber, maxNumber); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
87 ui.SetUnitEquipmentLimitsEnabled(false); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
88 ui.SetOkayEnabledState(false); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
89 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
90 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
91 ui.ListenToWidgets(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
92 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
93 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
94 protected void SetUnitEquipmentValuesFromEquipment(UnitEquipmentItem equip) |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
95 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
96 isRatioAmount = UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
97 equipmentAmount = UnitEquipmentUtil.GetEquipmentAmount(unit, equip); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
98 SetUnitEquipmentValues(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
99 SetEquipmentAmountControlEnabledStates(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
100 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
101 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 /// <summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 /// Sets the unit equipment values on the UI |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 /// </summary> |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
105 |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
106 protected void SetUnitEquipmentValuesFromUI() |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
107 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
108 isRatioAmount = ui.IsRatioEquipmentAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
109 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
110 if (isRatioAmount) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
111 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
112 equipmentAmount = ui.EquipmentPercentageAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
113 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
114 else |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
115 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
116 int equipmentIntAmount = ui.EquipmentNumericAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
117 equipmentAmount = equipmentIntAmount; |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
118 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
119 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
120 SetUnitEquipmentValues(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
121 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
122 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
123 private void SetUnitEquipmentValues() |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
124 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
125 ui.IgnoreWidgets(); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
126 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
127 if (isRatioAmount) |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
128 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
129 SetEquipmentAmountsFromPercentage(equipmentAmount); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
130 } |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
131 else |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
132 { |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
133 int equipmentIntAmount = (int)equipmentAmount; |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 SetEquipmentAmountsFromNumber(equipmentIntAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 } |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
136 |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
137 ui.SetOkayEnabledState(equipmentAmount != 0); |
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
138 ui.ListenToWidgets(); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 private void SetEquipmentAmountsFromPercentage(double equipAmount) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 if (equipAmount > maxPercentage) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 string percentageTooLarge = Translation.GetTranslation("equipPercentageTooLarge", "the current percentage ({0}%) was larger than the maximum for the equipment item ({1}%) - the maximum value will be used instead", equipAmount, maxPercentage); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 string percentageTooLargeTitle = Translation.GetTranslation("equipPercentageTooLargeTitle", "equipment percentage too large"); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 // MessageBox.Show(ParentForm, percentageTooLarge, percentageTooLargeTitle); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 equipAmount = maxPercentage; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 } |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
150 else |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
151 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
152 if (equipAmount < minPercentage) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
153 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
154 string percentageTooSmall = Translation.GetTranslation("equipPercentageTooSmall", "the current percentage ({0}%) was smaller than the minimum for the equipment item ({1}%) - the minimum value will be used instead", equipAmount, minPercentage); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
155 string percentageTooSmallTitle = Translation.GetTranslation("equipPercentageTooSmallTitle", "equipment percentage too small"); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 // MessageBox.Show(ParentForm, percentageTooSmall, percentageTooSmallTitle); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
157 equipAmount = minPercentage; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
158 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
159 |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
160 } |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 ui.EquipmentNumericAmount = CalculateNumericValueFromPercentage(equipAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 ui.EquipmentPercentageAmount = equipAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 private int CalculateNumericValueFromPercentage(double percent) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 int calcedAmount = (int)CustomMath.IBBMath.Round((unit.Size * (percent / 100.0)), equipItem.RoundNumberUp); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 return Math.Min(Math.Max(calcedAmount, minNumber), maxNumber); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 private void SetEquipmentAmountsFromNumber(int equipAmount) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 if (equipAmount > maxNumber) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 string amountTooLarge = Translation.GetTranslation("equipNumberTooLarge", "the current amount ({0}) was larger than the maximum for the equipment item ({1}) - the maximum value will be used instead", equipAmount, maxNumber); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
176 string amountTooLargeTitle = Translation.GetTranslation("equipNumberTooLargeTitle", "equipment amount too large"); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 //MessageBox.Show(ParentForm, amountTooLarge, amountTooLargeTitle); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 equipAmount = maxNumber; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 } |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
180 else |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
182 if (equipAmount < minNumber) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
183 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
184 string amountTooSmall = Translation.GetTranslation("equipNumberTooSmall", "the current amount ({0}) was smaller than the minimum for the equipment item ({1}) - the minimum value will be used instead", equipAmount, minNumber); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
185 string amountTooSmallTitle = Translation.GetTranslation("equipNumberTooSmallTitle", "equipment amount too small"); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 //MessageBox.Show(ParentForm, amountTooSmall, amountTooSmallTitle); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
187 equipAmount = minNumber; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
188 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
189 |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
190 } |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 ui.EquipmentPercentageAmount = CalcualtePercentageValueFromNumber(equipAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 ui.EquipmentNumericAmount = equipAmount; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
193 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
194 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
195 private double CalcualtePercentageValueFromNumber(int number) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
196 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
197 double calcedAmount = RoundPercentage(CustomMath.IBBMath.Percentage(number, unit.Size)); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
198 return Math.Min(Math.Max(calcedAmount, minPercentage), maxPercentage); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
199 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 protected void SetEquipmentAmountControlEnabledStates() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
202 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
203 ui.SetNumericAmountEnabledState(!isRatioAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 ui.SetPercentageAmountEnabledState(true); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
205 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
207 protected double GetMaxPercentageLimit(UnitEquipmentItem equip) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
208 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 double maxPercent = RoundPercentage(UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip)); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 return Math.Max(0, maxPercent); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
211 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
212 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 protected double GetMinPercentageLimit(UnitEquipmentItem equip) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
214 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
215 double minPercent = RoundPercentage(UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip)); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 return Math.Max(0, minPercent); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
217 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
219 protected int GetMaxNumericLimit(UnitEquipmentItem equip) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
220 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 return Math.Max(0, maxNumber); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
223 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
225 protected int GetMinNumericLimit(UnitEquipmentItem equip) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
226 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 return Math.Max(0, minNumber); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
229 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
231 protected bool HasNonZeroEquipmentAmount() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
232 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
233 bool nonZero; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
235 if (isRatioAmount) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
237 nonZero = (ui.EquipmentPercentageAmount > 0); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
238 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 else |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 nonZero = (ui.EquipmentNumericAmount > 0); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
243 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
244 return nonZero; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
245 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
246 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 private double RoundPercentage(double percent) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 return Math.Round(percent, 1); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
251 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
252 public void Show() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
254 SetupUI(); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 bool okayed = ui.ShowControl(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
257 if (okayed) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
259 DoProcessing(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
260 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 ui.Dispose(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
263 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 /// <summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 /// Does the processing required for the control when the "OK" button was clicked |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 /// </summary> |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
268 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 protected abstract void DoProcessing(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
270 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
271 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 |