Mercurial > repos > snowblizz-super-API-ideas
annotate api/Commands/SetUnitSizeCommand.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 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (SetUnitSizeCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
15 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
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. |
82 | 4 |
5 using System; | |
0 | 6 using IBBoard.Commands; |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
7 using IBBoard.Lang; |
82 | 8 using IBBoard.WarFoundry.API.Objects; |
9 | |
10 namespace IBBoard.WarFoundry.API.Commands | |
11 { | |
12 /// <summary> | |
13 /// Summary description for SetNameCommand. | |
14 /// </summary> | |
15 public class SetUnitSizeCommand : Command | |
16 { | |
17 private Unit unit; | |
18 private int newSize, oldSize; | |
19 | |
20 public SetUnitSizeCommand(Unit toResize, int size) | |
21 { | |
22 unit = toResize; | |
23 newSize = size; | |
24 oldSize = unit.Size; | |
25 } | |
26 | |
27 public override bool CanExecute() | |
28 { | |
289
650bbe79b884
Fixes #336: Command descriptions don't refresh on language change
IBBoard <dev@ibboard.co.uk>
parents:
215
diff
changeset
|
29 return (unit != null && newSize > 0 && oldSize > 0); |
82 | 30 } |
31 | |
32 public override string Description | |
33 { | |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
34 get |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
35 { |
289
650bbe79b884
Fixes #336: Command descriptions don't refresh on language change
IBBoard <dev@ibboard.co.uk>
parents:
215
diff
changeset
|
36 return Translation.GetTranslation("setUnitSizeCommandDescription", "set size of {0} to {1}", unit.Name, newSize); |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
37 } |
82 | 38 } |
39 | |
40 public override string UndoDescription | |
41 { | |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
42 get |
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
43 { |
289
650bbe79b884
Fixes #336: Command descriptions don't refresh on language change
IBBoard <dev@ibboard.co.uk>
parents:
215
diff
changeset
|
44 return Translation.GetTranslation("setUnitSizeCommandUndoDescription", "set size of {0} to {1}", unit.Name, oldSize); |
215
391446c9b250
Re #223: Use translations within the API
IBBoard <dev@ibboard.co.uk>
parents:
104
diff
changeset
|
45 } |
82 | 46 } |
47 | |
48 public override bool Execute() | |
49 { | |
50 this.Redo(); | |
51 return true; | |
52 } | |
53 | |
54 public override void Redo() | |
55 { | |
56 unit.Size = newSize; | |
57 } | |
58 | |
59 public override void Undo() | |
60 { | |
61 unit.Size = oldSize; | |
62 } | |
63 | |
64 public override string Name | |
65 { | |
66 get { return "Change unit size"; } | |
67 } | |
68 } | |
69 } |