annotate Util/UnitEquipmentChoice.cs @ 193:eaa7b639d390

* Fix build issues no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 03 Apr 2011 14:50:34 +0000
parents 1ca23c47345a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
1 // This file (UnitEquipmentChoice.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
2 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
4
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
5 using System;
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
6 using IBBoard.Lang;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
8 using IBBoard.WarFoundry.API.Util;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
9 using IBBoard.WarFoundry.API;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
10
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
11 namespace IBBoard.WarFoundry.GUI.WinForms.Util
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
12 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
13 /// <summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
14 /// A helper object that holds an equipment choice for a unit.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
15 /// </summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
16
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
17 public class UnitEquipmentChoice
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
18 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
19 private Unit unit;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
20 private UnitEquipmentItem item;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
21 public GameSystem CurrentGameSystem
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
22 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
23 get { return WarFoundryCore.CurrentGameSystem; }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
24 set { WarFoundryCore.CurrentGameSystem = value; }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 101
diff changeset
25 }
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
26
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
27 public UnitEquipmentChoice(Unit unit, UnitEquipmentItem unitItem)
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
28 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
29 this.unit = unit;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
30 item = unitItem;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
31 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
32
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
33 public override string ToString()
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
34 {
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
35 String translation = "";
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
36
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
37 if (item.Cost == 0)
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
38 {
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
39 translation = Translation.GetTranslation("equipmentAmountWithZeroCost", "{0} ({1} - free)", item.Name, GetAmountString());
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
40 }
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
41 else
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
42 {
193
eaa7b639d390 * Fix build issues
IBBoard <dev@ibboard.co.uk>
parents: 190
diff changeset
43 translation = Translation.GetTranslation("equipmentAmountWithCost", "{0} ({1} at {2}pts each)", item.Name, GetAmountString(), item.Cost, CurrentGameSystem.GetPointsAbbrev(item.Cost));
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
44 }
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
45
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
46 return translation;
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
47 }
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
48
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
49 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
50 {
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
51 double amount = UnitEquipmentUtil.GetEquipmentAmount(unit, item);
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
52 string amountString = "";
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
53
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
54 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, item))
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
55 {
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
56 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, item);
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
57
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
58 if (amount == 100)
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
59 {
101
3e78af88ceb3 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 99
diff changeset
60 amountString = Translation.GetTranslation("equipmentChoiceAmountAll", "all ({1})", amount, number);
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
61 }
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
62 else
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
63 {
101
3e78af88ceb3 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 99
diff changeset
64 amountString = Translation.GetTranslation("equipmentChoiceAmountPercentage", "{0}% ({1})", amount, number);
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
65 }
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
66 }
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
67 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
68 {
101
3e78af88ceb3 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 99
diff changeset
69 amountString = Translation.GetTranslation("equipmentChoiceAmountNumber", "{0}", amount);
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
70 }
99
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
71
acaea18ac0a1 Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents: 46
diff changeset
72 return amountString;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
73 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
74
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
75 public UnitEquipmentItem Item
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
76 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
77 get { return item; }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
78 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
79 }
8
755e60be28be Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 }