annotate UIControl/ReplaceEquipmentUIControl.cs @ 115:5e8de1507cfb WarFoundry_v0.1

* Remove dependency on Rollcall plugin * Update to VS2008 project * Make sure SharpZipLib is included no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 30 Apr 2011 14:08:45 +0000
parents 4a33b3012100
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
4a33b3012100 * Tag v0.1RC1 release
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
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
4a33b3012100 * Tag v0.1RC1 release
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.
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using IBBoard.Commands;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Commands;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Util;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.GUI.GTK.UIControl.Interfaces;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using CustomMath = IBBoard.CustomMath;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 namespace IBBoard.WarFoundry.GUI.GTK.UIControl
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class ReplaceEquipmentUIControl : AbstractBaseEquipmentUIControl<IReplaceEquipmentUI>
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private UnitEquipmentItem origItem;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public ReplaceEquipmentUIControl(Unit unit, UnitEquipmentItem equipmentItem, CommandStack commandStack) : base(unit, commandStack)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 origItem = equipmentItem;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 //TODO Make abstract
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 protected override IReplaceEquipmentUI CreateEquipmentUI()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 return new FrmReplaceEquipment();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 protected override void CompleteUISetup()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 UnitType unitType = unit.UnitType;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 string[] mutexGroups = origItem.MutexGroups;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 UnitEquipmentItem[] mutexItems = unitType.GetEquipmentItemsByExclusionGroups(mutexGroups);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 UnitEquipmentItem[] currentEquipment = unit.GetEquipment();
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 UnitEquipmentItem[] allowedItems = Arrays.Subtract(mutexItems, currentEquipment);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 ui.SetUnitEquipmentItems(allowedItems);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 equipItem = equip;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 SetUnitEquipmentLimits(equip);
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 protected override void DoProcessing()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 if (isRatioAmount)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 commandStack.Execute(new ReplaceUnitEquipmentWithRatioAmountItemCommand(unit, origItem, equipItem, equipmentAmount));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 else
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 commandStack.Execute(new ReplaceUnitEquipmentWithRatioAmountItemCommand(unit, origItem, equipItem, (int)equipmentAmount));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60