comparison api/Commands/RemoveUnitCommand.cs @ 289:650bbe79b884 WarFoundry_v0.1

Fixes #336: Command descriptions don't refresh on language change * Remove cached string values and just return the text each time
author IBBoard <dev@ibboard.co.uk>
date Sun, 02 Jan 2011 21:01:20 +0000
parents 391446c9b250
children
comparison
equal deleted inserted replaced
288:5c4b3d91795f 289:650bbe79b884
14 /// </summary> 14 /// </summary>
15 public class RemoveUnitCommand : Command 15 public class RemoveUnitCommand : Command
16 { 16 {
17 private Unit unit; 17 private Unit unit;
18 private ArmyCategory cat; 18 private ArmyCategory cat;
19 private string description;
20 private string undoDescription;
21 19
22 public RemoveUnitCommand(Unit toRemove) 20 public RemoveUnitCommand(Unit toRemove)
23 { 21 {
24 unit = toRemove; 22 unit = toRemove;
25 cat = unit.Category; 23 cat = unit.Category;
26 } 24 }
27 25
28 public override bool CanExecute() 26 public override bool CanExecute()
29 { 27 {
30 return (unit!=null); 28 return (unit != null);
31 } 29 }
32 30
33 public override string Description 31 public override string Description
34 { 32 {
35 get 33 get
36 { 34 {
37 if (description == null) 35 return Translation.GetTranslation("removeUnitCommandDescription", "remove {0} from the army", unit.Name);
38 {
39 description = Translation.GetTranslation("removeUnitCommandDescription", "remove {0} from the army", unit.Name);
40 }
41
42 return description;
43 } 36 }
44 } 37 }
45 38
46 public override string UndoDescription 39 public override string UndoDescription
47 { 40 {
48 get 41 get
49 { 42 {
50 if (undoDescription == null) 43 return Translation.GetTranslation("removeUnitCommandUndoDescription", "re-add {0} to the army", unit.Name);
51 {
52 undoDescription = Translation.GetTranslation("removeUnitCommandUndoDescription", "re-add {0} to the army", unit.Name);
53 }
54
55 return undoDescription;
56 } 44 }
57 } 45 }
58 46
59 public override bool Execute() 47 public override bool Execute()
60 { 48 {