Mercurial > repos > IBBoard.WarFoundry.API
comparison api/Commands/AbstractReplaceUnitEquipmentCommand.cs @ 215:391446c9b250
Re #223: Use translations within the API
* Translate and cache undo/redo descriptions of commands
* Simplify "set equipment amount" descriptions because of ticket:224
Also:
* Line ending change on ICostedWarFoundryObject
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 22 Nov 2009 20:08:45 +0000 |
parents | 2f3cafb69799 |
children | 650bbe79b884 |
comparison
equal
deleted
inserted
replaced
214:1b718b67f7f6 | 215:391446c9b250 |
---|---|
14 /// </summary> | 14 /// </summary> |
15 public abstract class AbstractReplaceUnitEquipmentCommand : Command | 15 public abstract class AbstractReplaceUnitEquipmentCommand : Command |
16 { | 16 { |
17 private SetUnitEquipmentNumericAmountCommand removeOldCommand; | 17 private SetUnitEquipmentNumericAmountCommand removeOldCommand; |
18 private AbstractSetUnitEquipmentAmountCommand addNewCommand; | 18 private AbstractSetUnitEquipmentAmountCommand addNewCommand; |
19 private string description; | |
20 private string undoDescription; | |
19 | 21 |
20 public AbstractReplaceUnitEquipmentCommand(Unit unit, UnitEquipmentItem oldItem, AbstractSetUnitEquipmentAmountCommand addNewEquipmentCommand) | 22 public AbstractReplaceUnitEquipmentCommand(Unit unit, UnitEquipmentItem oldItem, AbstractSetUnitEquipmentAmountCommand addNewEquipmentCommand) |
21 { | 23 { |
22 //We can get away with a numeric amount here even if it is a ratio item because we're setting it to 0 | 24 //We can get away with a numeric amount here even if it is a ratio item because we're setting it to 0 |
23 removeOldCommand = new SetUnitEquipmentNumericAmountCommand(unit, oldItem, 0); | 25 removeOldCommand = new SetUnitEquipmentNumericAmountCommand(unit, oldItem, 0); |
29 return removeOldCommand.CanExecute() && addNewCommand.CanExecute(); | 31 return removeOldCommand.CanExecute() && addNewCommand.CanExecute(); |
30 } | 32 } |
31 | 33 |
32 public override string Description | 34 public override string Description |
33 { | 35 { |
34 get { return "Replace "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } | 36 get |
37 { | |
38 if (description == null) | |
39 { | |
40 description = Translation.GetTranslation("replaceUnitEquipmentCommandDescription", "replace {0} with {1} for {2}", removeOldCommand.EquipItem.Name, addNewCommand.EquipItem.Name, removeOldCommand.Unit.Name); | |
41 } | |
42 | |
43 return description; | |
44 } | |
35 } | 45 } |
36 | 46 |
37 public override string UndoDescription | 47 public override string UndoDescription |
38 { | 48 { |
39 get { return "Replace "+StringManipulation.CutToLength(addNewCommand.EquipItem.Name, 20)+" with "+StringManipulation.CutToLength(removeOldCommand.EquipItem.Name, 20)+ " for "+StringManipulation.CutToLength(removeOldCommand.Unit.Name, 20); } | 49 get |
50 { | |
51 if (undoDescription == null) | |
52 { | |
53 undoDescription = Translation.GetTranslation("replaceUnitEquipmentCommandUndoDescription", "replace {0} with {1} for {2}", addNewCommand.EquipItem.Name, removeOldCommand.EquipItem.Name, removeOldCommand.Unit.Name); | |
54 } | |
55 | |
56 return undoDescription; | |
57 } | |
40 } | 58 } |
41 | 59 |
42 public override bool Execute() | 60 public override bool Execute() |
43 { | 61 { |
44 this.Redo(); | 62 this.Redo(); |
58 } | 76 } |
59 | 77 |
60 | 78 |
61 public override string Name | 79 public override string Name |
62 { | 80 { |
63 get { return "Replace required equipment"; } | 81 get |
82 { | |
83 return "Replace required equipment"; | |
84 } | |
64 } | 85 } |
65 } | 86 } |
66 } | 87 } |