Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
annotate UIControl/AbstractBaseEquipmentUIControl.cs @ 129:ac4231d6c3f0
* Add extra icon sizes for scaling
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 01 Oct 2011 20:30:45 +0100 |
parents | fac0636ae13b |
children |
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; |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
24 |
66
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 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
59 |
66
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 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
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 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
93 |
70
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 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
122 |
70
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"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
147 ShowMessage(percentageTooLarge, percentageTooLargeTitle); |
66
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"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
156 ShowMessage(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 |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
171 private void ShowMessage(string message, string title) |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
172 { |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
173 Gtk.MessageDialog dialog = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal, Gtk.MessageType.Warning, Gtk.ButtonsType.Ok, false, message); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
174 dialog.Title = title; |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
175 dialog.Run(); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
176 dialog.Hide(); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
177 dialog.Dispose(); |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
178 } |
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
179 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 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
|
181 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 if (equipAmount > maxNumber) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 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
|
185 string amountTooLargeTitle = Translation.GetTranslation("equipNumberTooLargeTitle", "equipment amount too large"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
186 ShowMessage(amountTooLarge, amountTooLargeTitle); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 equipAmount = maxNumber; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 } |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
189 else |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
191 if (equipAmount < minNumber) |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
192 { |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
193 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
|
194 string amountTooSmallTitle = Translation.GetTranslation("equipNumberTooSmallTitle", "equipment amount too small"); |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
195 ShowMessage(amountTooSmall, amountTooSmallTitle); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
196 equipAmount = minNumber; |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
197 } |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
198 |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
199 } |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
200 ui.EquipmentPercentageAmount = CalcualtePercentageValueFromNumber(equipAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
201 ui.EquipmentNumericAmount = equipAmount; |
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 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
204 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
|
205 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
206 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
|
207 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
|
208 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
209 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
210 protected void SetEquipmentAmountControlEnabledStates() |
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 ui.SetNumericAmountEnabledState(!isRatioAmount); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
213 ui.SetPercentageAmountEnabledState(true); |
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 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
216 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
|
217 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
218 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
|
219 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
|
220 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
221 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
222 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
|
223 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
224 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
|
225 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
|
226 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
227 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
228 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
|
229 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
230 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
|
231 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
|
232 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
233 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
234 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
|
235 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
236 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
|
237 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
|
238 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
239 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
240 protected bool HasNonZeroEquipmentAmount() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
241 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
242 bool nonZero; |
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 if (isRatioAmount) |
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 nonZero = (ui.EquipmentPercentageAmount > 0); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
247 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
248 else |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
249 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
250 nonZero = (ui.EquipmentNumericAmount > 0); |
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 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
253 return nonZero; |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
254 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
255 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
256 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
|
257 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
258 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
|
259 } |
98
fac0636ae13b
Re #308: Make GTK# UI translatable
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
260 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
261 public void Show() |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
262 { |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
263 SetupUI(); |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
264 bool okayed = ui.ShowControl(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
265 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
266 if (okayed) |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
267 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
268 DoProcessing(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
269 } |
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 ui.Dispose(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
272 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
273 |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
274 /// <summary> |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
275 /// 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
|
276 /// </summary> |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
277 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
278 protected abstract void DoProcessing(); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
279 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
280 } |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
281 |