Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
comparison UI/EquipmentAmountControl.cs @ 83:6d5cb8c7b6ed
Fixes #204: Use new limits in WinForms UI
* Set initial amounts correctly
* Disable percentage option when all that can be done is "equip all"
* Remove unused references to "INFINITY"
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 30 Oct 2009 21:00:04 +0000 |
parents | 9dc22147c2db |
children | 0bb9f40d44eb |
comparison
equal
deleted
inserted
replaced
82:9dc22147c2db | 83:6d5cb8c7b6ed |
---|---|
53 double minPercent = UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip); | 53 double minPercent = UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip); |
54 int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip); | 54 int maxNumber = UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip); |
55 int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); | 55 int minNumber = UnitEquipmentUtil.GetMinEquipmentCount(unit, equip); |
56 | 56 |
57 SetUpDownControlMinMaxes(minPercent, maxPercent, minNumber, maxNumber); | 57 SetUpDownControlMinMaxes(minPercent, maxPercent, minNumber, maxNumber); |
58 SetEquipmentAmountsFromPercentage(equipIsRatioLimit ? minPercent : minNumber); | 58 |
59 if (equipIsRatioLimit) | |
60 { | |
61 SetEquipmentAmountsFromPercentage(minPercent); | |
62 } | |
63 else | |
64 { | |
65 SetEquipmentAmountsFromNumber(minNumber); | |
66 } | |
59 | 67 |
60 rbEquipAll.Enabled = equipIsRatioLimit && maxPercent == 100; | 68 rbEquipAll.Enabled = equipIsRatioLimit && maxPercent == 100; |
61 rbEquipAll.Checked = equipIsRatioLimit && minPercent == 100; | 69 rbEquipAll.Checked = equipIsRatioLimit && minPercent == 100; |
62 percentage.Enabled = equipIsRatioLimit; | 70 percentage.Enabled = equipIsRatioLimit && minPercent != 100; |
63 rbPercentage.Enabled = percentage.Enabled; | 71 rbPercentage.Enabled = percentage.Enabled; |
64 rbPercentage.Checked = equipIsRatioLimit && !rbEquipAll.Checked; | 72 rbPercentage.Checked = equipIsRatioLimit && !rbEquipAll.Checked; |
65 numeric.Enabled = !equipIsRatioLimit || minPercent != 100; | 73 numeric.Enabled = !equipIsRatioLimit || minPercent != 100; |
66 rbNumeric.Enabled = numeric.Enabled; | 74 rbNumeric.Enabled = numeric.Enabled; |
67 rbNumeric.Checked = !equipIsRatioLimit; | 75 rbNumeric.Checked = !equipIsRatioLimit; |
188 | 196 |
189 if (isRatio) | 197 if (isRatio) |
190 { | 198 { |
191 SetEquipmentAmountsFromPercentage(equipAmountNum); | 199 SetEquipmentAmountsFromPercentage(equipAmountNum); |
192 } | 200 } |
193 else if (equipAmountNum == WarFoundryCore.INFINITY) | |
194 { | |
195 rbEquipAll.Checked = true; | |
196 } | |
197 else | 201 else |
198 { | 202 { |
199 int equipAmount = (int) equipAmountNum; | 203 int equipAmount = (int) equipAmountNum; |
200 SetEquipmentAmountsFromNumber(equipAmount); | 204 SetEquipmentAmountsFromNumber(equipAmount); |
201 } | 205 } |
208 percentage.Value = (decimal) equipAmountNum; | 212 percentage.Value = (decimal) equipAmountNum; |
209 } | 213 } |
210 | 214 |
211 private void SetEquipmentAmountsFromNumber(int equipAmount) | 215 private void SetEquipmentAmountsFromNumber(int equipAmount) |
212 { | 216 { |
213 rbEquipAll.Checked = (equipAmount == WarFoundryCore.INFINITY); | |
214 equipAmount = (equipAmount == WarFoundryCore.INFINITY ? unit.Size : equipAmount); | |
215 percentage.Value = CalcualtePercentageValueFromNumber(equipAmount); | 217 percentage.Value = CalcualtePercentageValueFromNumber(equipAmount); |
216 numeric.Value = equipAmount; | 218 numeric.Value = equipAmount; |
217 } | 219 } |
218 | 220 |
219 private void radioCheckedChanged(object sender, EventArgs e) | 221 private void radioCheckedChanged(object sender, EventArgs e) |