annotate UIControl/AddEquipmentUIControl.cs @ 117:1bbea67cf13a WarFoundry_v0.1 WarFoundry_v0.1

* Update copyright date in English translation no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 30 Apr 2011 14:27:33 +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 AddEquipmentUIControl : AbstractBaseEquipmentUIControl<IAddEquipmentUI>
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 public AddEquipmentUIControl(Unit unit, CommandStack commandStack) : base(unit, commandStack)
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 //Do nothing extra
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
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 //TODO Make abstract
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 protected override IAddEquipmentUI CreateEquipmentUI()
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 return new FrmAddEquipment();
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
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 protected override void CompleteUISetup()
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 ui.SetUnitEquipmentItems(GetEquipmentItems(unit));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 public static UnitEquipmentItem[] GetEquipmentItems(Unit unit)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 return Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment());
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 public static bool HasEquipmentToAdd(Unit unit)
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 return GetEquipmentItems(unit).Length > 0;
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
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem 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 equipItem = equip;
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 SetUnitEquipmentLimits(equip);
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
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 protected override void DoProcessing()
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 if (isRatioAmount)
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 {
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, equipmentAmount));
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 else
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 commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int)equipmentAmount));
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 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 }
4a33b3012100 * Tag v0.1RC1 release
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63