Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
annotate UIControl/AddEquipmentUIControl.cs @ 70:4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
* Fix widget enabling/disabling (sometimes enabling ratio input for numeric limit)
* Correct behaviour of Edit dialog (setting wrong value on edit)
* Add setting of limits based on specific equipment item to base dialog controller
* Make sure that we catch all radio button click events from Edit dialog
* Add ability to ignore and listen to widgets to make sure that changes don't cascade
TODO: See if code can be tidied up and common classes created
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 06 Nov 2010 17:03:13 +0000 |
parents | 7028e24b67ec |
children | 986fc923c0fa |
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 |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
22 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
23 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
|
24 { |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
25 return new FrmAddEquipment(); |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 } |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
66
diff
changeset
|
27 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
28 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
|
29 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
30 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
|
31 ui.SetUnitEquipmentItems(items); |
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
32 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged; |
51
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 |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 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
|
36 { |
63
c2d79b4209e3
* FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
37 equipItem = equip; |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
38 SetUnitEquipmentLimits(equip); |
62
f733073967a2
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
39 } |
f733073967a2
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
40 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
41 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
|
42 { |
63
c2d79b4209e3
* FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
43 if (isRatioAmount) |
61
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
44 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
45 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
|
46 } |
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
47 else |
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
48 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
49 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
|
50 } |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 |