Mercurial > repos > IBBoard.WarFoundry.API
comparison api/Commands/SetNameCommand.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 |
---|---|
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.Commands; | 6 using IBBoard.Commands; |
7 using IBBoard.Lang; | |
7 using IBBoard.WarFoundry.API.Objects; | 8 using IBBoard.WarFoundry.API.Objects; |
8 | 9 |
9 namespace IBBoard.WarFoundry.API.Commands | 10 namespace IBBoard.WarFoundry.API.Commands |
10 { | 11 { |
11 /// <summary> | 12 /// <summary> |
13 /// </summary> | 14 /// </summary> |
14 public class SetNameCommand : Command | 15 public class SetNameCommand : Command |
15 { | 16 { |
16 private WarFoundryObject obj; | 17 private WarFoundryObject obj; |
17 private string newName, oldName; | 18 private string newName, oldName; |
19 private string description; | |
20 private string undoDescription; | |
18 | 21 |
19 public SetNameCommand(WarFoundryObject toRename, string name) | 22 public SetNameCommand(WarFoundryObject toRename, string name) |
20 { | 23 { |
21 obj = toRename; | 24 obj = toRename; |
22 newName = name; | 25 newName = name; |
28 return (obj!=null && newName!=null && newName!=""); | 31 return (obj!=null && newName!=null && newName!=""); |
29 } | 32 } |
30 | 33 |
31 public override string Description | 34 public override string Description |
32 { | 35 { |
33 get { return "Rename "+oldName; } | 36 get |
37 { | |
38 if (description == null) | |
39 { | |
40 description = Translation.GetTranslation("setUnitNameCommandDescription", "rename \"{0}\" to \"{1}\"", oldName, newName); | |
41 } | |
42 | |
43 return description; | |
44 } | |
34 } | 45 } |
35 | 46 |
36 public override string UndoDescription | 47 public override string UndoDescription |
37 { | 48 { |
38 get { return "Revert name of "+newName; } | 49 get |
50 { | |
51 if (undoDescription == null) | |
52 { | |
53 undoDescription = Translation.GetTranslation("setUnitNameCommandUndoDescription", "rename \"{0}\" to \"{1}\"", newName, oldName); | |
54 } | |
55 | |
56 return undoDescription; | |
57 } | |
39 } | 58 } |
40 | 59 |
41 public override bool Execute() | 60 public override bool Execute() |
42 { | 61 { |
43 this.Redo(); | 62 this.Redo(); |