Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
annotate UIControl/AddEquipmentUIControl.cs @ 109:4ae69806bb2d
* Remove IBBoard.INI now that we don't use Rollcall
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 01 May 2011 13:07:15 +0000 |
parents | 986fc923c0fa |
children |
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() |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
29 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
30 ui.SetUnitEquipmentItems(GetEquipmentItems(unit)); |
66
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 |
91
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
34 public static UnitEquipmentItem[] GetEquipmentItems(Unit unit) |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
35 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
36 return Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment()); |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
37 } |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
38 |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
39 public static bool HasEquipmentToAdd(Unit unit) |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
40 { |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
41 return GetEquipmentItems(unit).Length > 0; |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
42 } |
986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
IBBoard <dev@ibboard.co.uk>
parents:
70
diff
changeset
|
43 |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 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
|
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 equipItem = equip; |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
47 SetUnitEquipmentLimits(equip); |
62
f733073967a2
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
48 } |
f733073967a2
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
49 |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
50 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
|
51 { |
63
c2d79b4209e3
* FrmAddEquipment.cs: Re #60: Add UI to add/remove/edit weapons in
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
52 if (isRatioAmount) |
61
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
53 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
54 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
|
55 } |
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
56 else |
e7ad676a7344
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
57
diff
changeset
|
57 { |
66
100626381159
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
65
diff
changeset
|
58 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
|
59 } |
51
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 } |
dafbd432ca23
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 |