comparison Util/UnitEquipmentChoice.cs @ 99:acaea18ac0a1

Fixes #220: Make percentage and numeric amounts more obvious * Differentiate between "free" and costed and build up a new string with more options * Make use of translations for all of the parts of the line Re #179: Make sure that translations are used throughout UI * Add new translations to file
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Nov 2009 16:41:28 +0000
parents 1576f669b3eb
children 3e78af88ceb3
comparison
equal deleted inserted replaced
98:c7afc7824f50 99:acaea18ac0a1
1 // This file (UnitEquipmentChoice.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard. 1 // This file (UnitEquipmentChoice.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
2 // 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. 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 4
5 using System; 5 using System;
6 using IBBoard.Lang;
6 using IBBoard.WarFoundry.API.Objects; 7 using IBBoard.WarFoundry.API.Objects;
7 8 using IBBoard.WarFoundry.API.Util;
8
9 9
10 namespace IBBoard.WarFoundry.GUI.WinForms.Util 10 namespace IBBoard.WarFoundry.GUI.WinForms.Util
11 { 11 {
12 /// <summary> 12 /// <summary>
13 /// A helper object that holds an equipment choice for a unit. 13 /// A helper object that holds an equipment choice for a unit.
24 item = unitItem; 24 item = unitItem;
25 } 25 }
26 26
27 public override string ToString() 27 public override string ToString()
28 { 28 {
29 return String.Format("{0} (For {1} at {2}pts each)", item.Name, GetAmountString(), item.Cost); 29 String translation = "";
30
31 if (item.Cost == 0)
32 {
33 translation = Translation.GetTranslation("equipmentAmountWithZeroCost", "{0} ({1} - free)", item.Name, GetAmountString());
34 }
35 else
36 {
37 translation = Translation.GetTranslation("equipmentAmountWithCost", "{0} ({1} at {2}pts each)", item.Name, GetAmountString(), item.Cost);
38 }
39
40 return translation;
30 } 41 }
31 42
32 private string GetAmountString() 43 private string GetAmountString()
33 { 44 {
34 if (unit.GetEquipmentAmountIsRatio(item)) 45 double amount = UnitEquipmentUtil.GetEquipmentAmount(unit, item);
46 string amountString = "";
47
48 if (UnitEquipmentUtil.GetEquipmentAmountIsRatio(unit, item))
35 { 49 {
36 return UnitEquipmentRatioSelection.GetEquipmentAmountString(unit.GetEquipmentAmount(item)); 50 int number = UnitEquipmentUtil.GetEquipmentAmountTaken(unit, item);
51
52 if (amount == 100)
53 {
54 amountString = Translation.GetTranslation("equipmentAmountAll", "all ({1})", amount, number);
55 }
56 else
57 {
58 amountString = Translation.GetTranslation("equipmentAmountPercentage", "{0}% ({1})", amount, number);
59 }
37 } 60 }
38 else 61 else
39 { 62 {
40 return UnitEquipmentNumericSelection.GetEquipmentAmountString(unit.GetEquipmentAmount(item)); 63 amountString = amount.ToString();
41 } 64 }
65
66 return amountString;
42 } 67 }
43 68
44 public UnitEquipmentItem Item 69 public UnitEquipmentItem Item
45 { 70 {
46 get { return item; } 71 get { return item; }