Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
comparison UIControl/AddEquipmentUIControl.cs @ 91:986fc923c0fa
Fixes #331: Equipment buttons should be disabled when options aren't available
* Edit was already handled via UnitEquipmentUtil call
* Added enabling/disabling for Add via extracted methods on AddEquipmentUIControl
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 31 Dec 2010 11:36:06 +0000 |
parents | 4b82515586ac |
children |
comparison
equal
deleted
inserted
replaced
90:a754a2d1881c | 91:986fc923c0fa |
---|---|
24 { | 24 { |
25 return new FrmAddEquipment(); | 25 return new FrmAddEquipment(); |
26 } | 26 } |
27 | 27 |
28 protected override void CompleteUISetup() | 28 protected override void CompleteUISetup() |
29 { | 29 { |
30 UnitEquipmentItem[] items = Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment()); | 30 ui.SetUnitEquipmentItems(GetEquipmentItems(unit)); |
31 ui.SetUnitEquipmentItems(items); | |
32 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged; | 31 ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged; |
32 } | |
33 | |
34 public static UnitEquipmentItem[] GetEquipmentItems(Unit unit) | |
35 { | |
36 return Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment()); | |
37 } | |
38 | |
39 public static bool HasEquipmentToAdd(Unit unit) | |
40 { | |
41 return GetEquipmentItems(unit).Length > 0; | |
33 } | 42 } |
34 | 43 |
35 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip) | 44 private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip) |
36 { | 45 { |
37 equipItem = equip; | 46 equipItem = equip; |