diff 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
line wrap: on
line diff
--- a/UIControl/AddEquipmentUIControl.cs	Fri Dec 31 10:54:42 2010 +0000
+++ b/UIControl/AddEquipmentUIControl.cs	Fri Dec 31 11:36:06 2010 +0000
@@ -26,12 +26,21 @@
 		}
 
 		protected override void CompleteUISetup()
-		{			
-			UnitEquipmentItem[] items = Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment());
-			ui.SetUnitEquipmentItems(items);
+		{
+			ui.SetUnitEquipmentItems(GetEquipmentItems(unit));
 			ui.UnitEquipmentItemChoiceChanged += HandleUiUnitEquipmentItemChoiceChanged;
 		}
 
+		public static UnitEquipmentItem[] GetEquipmentItems(Unit unit)
+		{
+			return Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment());
+		}
+
+		public static bool HasEquipmentToAdd(Unit unit)
+		{
+			return GetEquipmentItems(unit).Length > 0;
+		}
+
 		private void HandleUiUnitEquipmentItemChoiceChanged(UnitEquipmentItem equip)
 		{
 			equipItem = equip;