comparison api/Commands/SetUnitSizeCommand.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 SetUnitSizeCommand : Command 15 public class SetUnitSizeCommand : Command
15 { 16 {
16 private Unit unit; 17 private Unit unit;
17 private int newSize, oldSize; 18 private int newSize, oldSize;
19 private string description;
20 private string undoDescription;
18 21
19 public SetUnitSizeCommand(Unit toResize, int size) 22 public SetUnitSizeCommand(Unit toResize, int size)
20 { 23 {
21 unit = toResize; 24 unit = toResize;
22 newSize = size; 25 newSize = size;
28 return (unit!=null && newSize >0 && oldSize > 0); 31 return (unit!=null && newSize >0 && oldSize > 0);
29 } 32 }
30 33
31 public override string Description 34 public override string Description
32 { 35 {
33 get { return "Change size of "+unit.Name; } 36 get
37 {
38 if (description == null)
39 {
40 description = Translation.GetTranslation("setUnitSizeCommandDescription", "set size of {0} to {1}", unit.Name, newSize);
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 size of "+unit.Name; } 49 get
50 {
51 if (undoDescription == null)
52 {
53 undoDescription = Translation.GetTranslation("setUnitSizeCommandUndoDescription", "set size of {0} to {1}", unit.Name, oldSize);
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();