Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
diff FrmEditUnitEquipment.cs @ 8:755e60be28be
Re #61 - Complete structure of WarFoundry API objects
* Update to using UnitEquipmentItem where properties have moved from EquipmentItem
* Add UnitEquipmentChoice as replacement for UnitEquipmentItemObj
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 05 Apr 2009 13:50:41 +0000 |
parents | 8935971e307c |
children | 19bdbb80999c |
line wrap: on
line diff
--- a/FrmEditUnitEquipment.cs Sat Mar 07 21:08:31 2009 +0000 +++ b/FrmEditUnitEquipment.cs Sun Apr 05 13:50:41 2009 +0000 @@ -21,8 +21,7 @@ { private Unit unit; private UnitEquipmentItem equipItem; - private EquipmentItem equip; - private float equipAmount; + private double equipAmount; private CommandStack commandStack; private System.Windows.Forms.NumericUpDown numEquipAmount; @@ -41,15 +40,14 @@ commandStack = stack; this.unit = unit; this.equipItem = equipItem; - equip = equipItem.EquipmentItem; InitializeComponent(); - this.Text = equip.Name + " for " + unit.Name; - equipAmount = unit.GetEquipmentAmount(equip.ID); + this.Text = equipItem.Name + " for " + unit.Name; + equipAmount = unit.GetEquipmentAmount(equipItem); - if (equip.IsRatioLimit) + if (equipItem.IsRatioLimit) { - numEquipAmount.Minimum = (decimal)Math.Round(equip.MinNumber * 100, 2); - numEquipAmount.Maximum = (decimal)Math.Round(equip.MaxNumber * 100, 2); + numEquipAmount.Minimum = (decimal)Math.Round(equipItem.MinNumber * 100.0, 2); + numEquipAmount.Maximum = (decimal)Math.Round(equipItem.MaxNumber * 100.0, 2); numEquipAmount.Value = (decimal)Math.Round(equipAmount * 100, 2); cbEquipAll.Enabled = false; lblPercent.Visible = true; @@ -57,12 +55,12 @@ } else { - numEquipAmount.Minimum = (decimal)(equip.MinNumber != -1 ? equip.MinNumber : unit.Size); - numEquipAmount.Maximum = (decimal)(equip.MaxNumber != -1 ? equip.MaxNumber : unit.Size); + numEquipAmount.Minimum = (decimal)(equipItem.MinNumber != -1 ? equipItem.MinNumber : unit.Size); + numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != -1 ? equipItem.MaxNumber : unit.Size); numEquipAmount.Value = (decimal)(equipAmount == -1 ? unit.Size : equipAmount); cbEquipAll.Checked = (equipAmount == -1); - cbEquipAll.Enabled = (equip.MaxNumber == -1 && equip.MinNumber != -1); - numEquipAmount.Enabled = !cbEquipAll.Checked && equip.MinNumber != -1; + cbEquipAll.Enabled = (equipItem.MaxNumber == -1 && equipItem.MinNumber != -1); + numEquipAmount.Enabled = !cbEquipAll.Checked && equipItem.MinNumber != -1; numEquipAmount.Width = 144; } @@ -189,8 +187,8 @@ } private bool setValue() - { - if ((!numEquipAmount.Enabled || numEquipAmount.Value == 0) && !cbEquipAll.Checked && unit.GetEquipmentAmount(equip.ID) != 0) + { + if ((!numEquipAmount.Enabled || numEquipAmount.Value == 0) && !cbEquipAll.Checked && unit.GetEquipmentAmount(equipItem) != 0) { if (equipItem.IsRequired) { @@ -212,18 +210,18 @@ { if (equipAmount!=-1) { - commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, -1)); + commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, -1)); } } else if (numEquipAmount.Value != (decimal)equipAmount) { - if (equip.IsRatioLimit) + if (equipItem.IsRatioLimit) { - commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, (float)((double)numEquipAmount.Value / 100.0))); + commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, ((double)numEquipAmount.Value / 100.0))); } else { - commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equip, (float)numEquipAmount.Value)); + commandStack.Execute(new SetUnitEquipmentAmountCommand(unit, equipItem, (double)numEquipAmount.Value)); } } @@ -237,7 +235,7 @@ private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e) { - numEquipAmount.Enabled = !cbEquipAll.Checked && equip.MinNumber != -1; + numEquipAmount.Enabled = !cbEquipAll.Checked && equipItem.MinNumber != -1; setOkayButton(); }