Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
annotate UIControl/ReplaceEquipmentUIControl.cs @ 167:9808adf2d566 default tip
Re #419: Remove assumptions of a file-based install
* Update GTK# GUI to use Streams version of XSLT export
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 28 Nov 2012 20:25:53 +0000 |
parents | 4b82515586ac |
children |
rev | line source |
---|---|
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (AddEquipmentUIControl.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2010 IBBoard |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
7028e24b67ec
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. |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using IBBoard.Commands; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using IBBoard.WarFoundry.API.Commands; |
7028e24b67ec
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; |
7028e24b67ec
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; |
7028e24b67ec
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; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 using CustomMath = IBBoard.CustomMath; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 |
7028e24b67ec
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 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 public class ReplaceEquipmentUIControl : AbstractBaseEquipmentUIControl<IReplaceEquipmentUI> |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 private UnitEquipmentItem origItem; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 public ReplaceEquipmentUIControl(Unit unit, UnitEquipmentItem equipmentItem, CommandStack commandStack) : base(unit, commandStack) |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 origItem = equipmentItem; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 //TODO Make abstract |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 protected override IReplaceEquipmentUI CreateEquipmentUI() |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 return new FrmReplaceEquipment(); |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 protected override void CompleteUISetup() |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 UnitType unitType = unit.UnitType; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 string[] mutexGroups = origItem.MutexGroups; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 UnitEquipmentItem[] mutexItems = unitType.GetEquipmentItemsByExclusionGroups(mutexGroups); |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 UnitEquipmentItem[] currentEquipment = unit.GetEquipment(); |
69
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
36 UnitEquipmentItem[] allowedItems = Arrays.Subtract(mutexItems, currentEquipment); |
3b4a646b4054
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
68
diff
changeset
|
37 ui.SetUnitEquipmentItems(allowedItems); |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged; |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip) |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 equipItem = equip; |
70
4b82515586ac
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
69
diff
changeset
|
44 SetUnitEquipmentLimits(equip); |
68
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 protected override void DoProcessing() |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 if (isRatioAmount) |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 commandStack.Execute(new ReplaceUnitEquipmentWithRatioAmountItemCommand(unit, origItem, equipItem, equipmentAmount)); |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 else |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 { |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 commandStack.Execute(new ReplaceUnitEquipmentWithRatioAmountItemCommand(unit, origItem, equipItem, (int)equipmentAmount)); |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 } |
7028e24b67ec
Re #60: Add UI to add/remove/edit weapons in GTK
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 |