annotate UIControl/AddEquipmentUIControl.cs @ 68:7028e24b67ec

Re #60: Add UI to add/remove/edit weapons in GTK * Add "Replace" dialog Note: Dialog null refs because of a bad assumption in the base class - base constructor calls SetupUI before Replace constructor has set all of its values
author IBBoard <dev@ibboard.co.uk>
date Wed, 03 Nov 2010 21:02:54 +0000
parents 100626381159
children 4b82515586ac
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: 63
diff changeset
1 // This file (AddEquipmentUIControl.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
4
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using IBBoard.Commands;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
6 using IBBoard.WarFoundry.API.Commands;
51
dafbd432ca23 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;
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Util;
dafbd432ca23 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.UIControl.Interfaces;
62
f733073967a2 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
10 using CustomMath = IBBoard.CustomMath;
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
11
51
dafbd432ca23 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
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
14 public class AddEquipmentUIControl : AbstractBaseEquipmentUIControl<IAddEquipmentUI>
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
15 {
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
16 public AddEquipmentUIControl(Unit unit, CommandStack commandStack) : base(unit, commandStack)
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
18 //Do nothing extra
62
f733073967a2 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
19 }
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
20
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
21 //TODO Make abstract
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
22 protected override IAddEquipmentUI CreateEquipmentUI()
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
23 {
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
24 return new FrmAddEquipment();
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 }
68
7028e24b67ec Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 66
diff changeset
26
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
27 protected override void CompleteUISetup()
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
28 {
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
29 UnitEquipmentItem[] items = Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment());
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
30 ui.SetUnitEquipmentItems(items);
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
31 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged;
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip)
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 {
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
36 equipItem = equip;
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
37
56
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
38 if (equip != null)
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
39 {
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
40 bool equipIsRatioLimit = UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip);
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
41 maxPercentage = GetMaxPercentageLimit(equip);
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
42 minPercentage = GetMinPercentageLimit(equip);
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
43 maxNumber = GetMaxNumericLimit(equip);
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
44 minNumber = GetMinNumericLimit(equip);
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
46 ui.SetUnitEquipmentLimits(equipIsRatioLimit, minPercentage, maxPercentage, minNumber, maxNumber);
56
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
47 ui.SetUnitEquipmentLimitsEnabled(true);
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
48 ui.SetOkayEnabledState(HasNonZeroEquipmentAmount());
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
49 SetEquipmentAmountControlEnabledStates();
56
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
50 }
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
51 else
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
52 {
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
53 maxPercentage = minPercentage = 0;
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
54 maxNumber = minNumber = 0;
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
55 ui.SetUnitEquipmentLimits(false, minPercentage, maxPercentage, minNumber, maxNumber);
56
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
56 ui.SetUnitEquipmentLimitsEnabled(false);
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
57 ui.SetOkayEnabledState(false);
56
0c5fbb54bfb0 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 55
diff changeset
58 }
62
f733073967a2 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
59 }
f733073967a2 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
60
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
61 protected override void DoProcessing()
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
62 {
63
c2d79b4209e3 * FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
63 if (isRatioAmount)
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
64 {
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
65 commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, equipmentAmount));
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
66 }
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
67 else
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
68 {
66
100626381159 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 65
diff changeset
69 commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int)equipmentAmount));
61
e7ad676a7344 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
70 }
51
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 }
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 }
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
dafbd432ca23 Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74