Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
changeset 81:e749b748e7ea
Re #198: Add slots with counts to units
* Update EquipmentAmountControl to resolve errors
Also:
* Use lower-case slot name for StatColumnStyle check for "Name"
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 26 Oct 2009 20:56:09 +0000 |
parents | c243b043aa62 |
children | 9dc22147c2db |
files | UI/EquipmentAmountControl.cs UI/StatColumnStyle.cs |
diffstat | 2 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/UI/EquipmentAmountControl.cs Wed Oct 21 20:11:18 2009 +0000 +++ b/UI/EquipmentAmountControl.cs Mon Oct 26 20:56:09 2009 +0000 @@ -6,6 +6,7 @@ using System.Text; using System.Windows.Forms; using IBBoard.CustomMath; +using IBBoard.Limits; using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Objects; @@ -47,10 +48,12 @@ { if (equip != null) { - if (equip.IsRatioLimit) + AbstractLimit limit = unit.UnitType.GetEquipmentSlotLimit(equip.SlotName); + + if (equip.IsRatioLimit && limit is IPercentageLimit) { - double minPercent = equip.MinPercentage; - double maxPercent = equip.MaxPercentage; + double minPercent = ((IPercentageLimit)equip.MinLimit).Percentage; + double maxPercent = ((IPercentageLimit)equip.MaxLimit).Percentage; int minNumber = (int) CalculateNumericValueFromPercentage(minPercent); int maxNumber = (int) CalculateNumericValueFromPercentage(maxPercent); @@ -77,8 +80,8 @@ } else { - int minNumber = equip.MinNumber; - int maxNumber = equip.MaxNumber; + int minNumber = equip.MinLimit.GetLimit(unit.Size); + int maxNumber = GetMaxNumber(limit); double minPercent = (double) CalcualtePercentageValueFromNumber(minNumber); double maxPercent = (double) CalcualtePercentageValueFromNumber(maxNumber); @@ -108,6 +111,19 @@ } } + private int GetMaxNumber(AbstractLimit limit) + { + int maxNumber = equip.MaxLimit.GetLimit(unit.Size); + + if (!(limit is UnlimitedLimit)) + { + int slotMax = limit.GetLimit(unit.Size) - unit.GetEquipmentAmountInSlot(equip.SlotName); + maxNumber = Math.Min(slotMax, maxNumber); + } + + return maxNumber; + } + private void SetUpDownControlMinMaxes(double minPercent, double maxPercent, int minNumber, int maxNumber) { percentage.ValueChanged -= percentage_ValueChanged;
--- a/UI/StatColumnStyle.cs Wed Oct 21 20:11:18 2009 +0000 +++ b/UI/StatColumnStyle.cs Mon Oct 26 20:56:09 2009 +0000 @@ -22,7 +22,7 @@ { Stat stat = (Stat) obj; StringFormat stringFormat = new StringFormat(); - stringFormat.Alignment = (stat.ParentSlotName == "Name" ? StringAlignment.Near : StringAlignment.Center); + stringFormat.Alignment = (stat.ParentSlotName == "name" ? StringAlignment.Near : StringAlignment.Center);//TODO: make "name" a constrant g.DrawString(stat.SlotValueString, GetFont(), foreBrush, rect, stringFormat); } else