Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
annotate Util/UnitEquipmentChoice.cs @ 163:d533f3b3ba1e
Fixes #293: Remove sorting from stats data grids
* Simple fix - set "Sort Mode" to unsortable
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 05 Jul 2010 20:08:39 +0000 |
parents | 3e78af88ceb3 |
children | 1ca23c47345a |
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; |
36 | 9 |
10 namespace IBBoard.WarFoundry.GUI.WinForms.Util | |
11 { | |
12 /// <summary> | |
13 /// A helper object that holds an equipment choice for a unit. | |
14 /// </summary> | |
15 | |
16 public class UnitEquipmentChoice | |
17 { | |
18 private Unit unit; | |
19 private UnitEquipmentItem item; | |
20 | |
21 public UnitEquipmentChoice(Unit unit, UnitEquipmentItem unitItem) | |
22 { | |
23 this.unit = unit; | |
24 item = unitItem; | |
25 } | |
26 | |
27 public override string ToString() | |
28 { | |
99
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
29 String translation = ""; |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
30 |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
31 if (item.Cost == 0) |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
32 { |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
33 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
|
34 } |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
35 else |
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 translation = Translation.GetTranslation("equipmentAmountWithCost", "{0} ({1} at {2}pts each)", item.Name, GetAmountString(), item.Cost); |
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 |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
40 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
|
41 } |
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 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
|
44 { |
99
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
45 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
|
46 string amountString = ""; |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
47 |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
48 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
|
49 { |
99
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
50 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
|
51 |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
52 if (amount == 100) |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
53 { |
101
3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
54 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
|
55 } |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
56 else |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
57 { |
101
3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
58 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
|
59 } |
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
|
60 } |
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
|
61 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
|
62 { |
101
3e78af88ceb3
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
99
diff
changeset
|
63 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
|
64 } |
99
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
65 |
acaea18ac0a1
Fixes #220: Make percentage and numeric amounts more obvious
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
66 return amountString; |
36 | 67 } |
68 | |
69 public UnitEquipmentItem Item | |
70 { | |
71 get { return item; } | |
72 } | |
73 } | |
8
755e60be28be
Re #61 - Complete structure of WarFoundry API objects
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 } |