annotate Util/UnitEquipmentChoice.cs @ 34:3ceb0efd261f

Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts * Use new commands created in previous revision Re #122: Make usage of percentage or ratio common * Make sure all usage of percentages are correct Re #117: Add percentage and number boxes to equipment item dialogs * Fix some enable/disable inconsistencies for percentage amounts * Fix problems where fixed limits weren't honoured by widgets
author IBBoard <dev@ibboard.co.uk>
date Thu, 13 Aug 2009 21:16:21 +0000
parents 7c366fe55635
children 6ab7ddc038f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
1 // This file (UnitEquipmentChoice.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
2 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
4
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
5 using System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
6 using System.Collections;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
8
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
9
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
10
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
11 namespace IBBoard.WarFoundry.GUI.WinForms.Util
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
12 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
13 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
14 /// A helper object that holds an equipment choice for a unit.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
15 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
16
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
17 public class UnitEquipmentChoice
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
18 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
19 private Unit unit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
20 private UnitEquipmentItem item;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
21
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
22 private static Hashtable equipObjs = new Hashtable();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
23
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
24 public UnitEquipmentChoice(Unit unit, UnitEquipmentItem unitItem)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
25 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
26 this.unit = unit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
27 item = unitItem;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
28 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
29
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
30 public override string ToString()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
31 {
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
32 return String.Format("{0} (For {1} at {2}pts each)", item.Name, GetAmountString(), item.Cost);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
33 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
35 private string GetAmountString()
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
36 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
37 if (unit.GetEquipmentAmountIsRatio(item))
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
38 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
39 return UnitEquipmentRatioSelection.GetEquipmentAmountString(unit.GetEquipmentAmount(item));
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
40 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
41 else
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
42 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
43 return UnitEquipmentNumericSelection.GetEquipmentAmountString(unit.GetEquipmentAmount(item));
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
44 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
45 }
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
46
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
47 public UnitEquipmentItem Item
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
48 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
49 get { return item; }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
50 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 10
diff changeset
51 }
8
755e60be28be Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }