Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
annotate Util/UnitEquipmentChoice.cs @ 253:7243e6646926 default tip
Re #427: Resizable equipment dialog
* Make equipment dialog resizable
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 27 Apr 2013 16:10:08 +0100 |
parents | eaa7b639d390 |
children |
rev | line source |
---|---|
36 | 1 // This file (UnitEquipmentChoice.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. |
2 // | |
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. | |
4 | |
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 | 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 | 9 using IBBoard.WarFoundry.API; |
36 | 10 |
11 namespace IBBoard.WarFoundry.GUI.WinForms.Util | |
12 { | |
13 /// <summary> | |
14 /// A helper object that holds an equipment choice for a unit. | |
15 /// </summary> | |
16 | |
17 public class UnitEquipmentChoice | |
18 { | |
19 private Unit unit; | |
20 private UnitEquipmentItem item; | |
190 | 21 public GameSystem CurrentGameSystem |
22 { | |
23 get { return WarFoundryCore.CurrentGameSystem; } | |
24 set { WarFoundryCore.CurrentGameSystem = value; } | |
25 } | |
36 | 26 |
27 public UnitEquipmentChoice(Unit unit, UnitEquipmentItem unitItem) | |
28 { | |
29 this.unit = unit; | |
30 item = unitItem; | |
31 } | |
32 | |
33 public override string ToString() | |
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 | 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 | 73 } |
74 | |
75 public UnitEquipmentItem Item | |
76 { | |
77 get { return item; } | |
78 } | |
79 } | |
8
755e60be28be
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 } |