Mercurial > repos > snowblizz-super-API-ideas
changeset 279:51b3027a7dae
Re #295: Index out of bounds when changing unit size and clicking in equipment list
* Trigger 'fake' equipment amount changed events when the unit size changes for all ratio equipment - ratio won't have changed, but absolute number will
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 14 Jul 2010 20:01:14 +0000 |
parents | c1d55ea8a2a1 |
children | 937cb8d92aa8 |
files | api/Objects/Unit.cs |
diffstat | 1 files changed, 18 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/api/Objects/Unit.cs Wed Jul 07 19:01:13 2010 +0000 +++ b/api/Objects/Unit.cs Wed Jul 14 20:01:14 2010 +0000 @@ -33,8 +33,9 @@ public Unit(UnitType unitType, int startSize, ArmyCategory parentArmyCat) : this("", "", startSize, unitType, parentArmyCat) { - SetInitialEquipment(); - } + SetInitialEquipment(); + UnitSizeChanged += new IntValChangedDelegate(RefreshUnitEquipmentAmounts); + } public Unit(string id, string name, int startSize, UnitType unitType, ArmyCategory parentArmyCat) : base(id, name) { @@ -577,8 +578,20 @@ get { return UnitType.GetRequiredAbilities(); - } - } - + } + } + + private void RefreshUnitEquipmentAmounts(WarFoundryObject obj, int oldValue, int newValue) + { + foreach (UnitEquipmentItem item in equipment.Keys) + { + AbstractUnitEquipmentItemSelection selection = equipment[item]; + + if (selection is UnitEquipmentRatioSelection) + { + OnUnitEquipmentAmountChanged(item, selection.AmountTaken, selection.AmountTaken); + } + } + } } }