Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison API/Commands/SetUnitSizeCommand.cs @ 337:3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 03 Apr 2011 18:50:32 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
336:3631c1493c7f | 337:3c4a6403a88c |
---|---|
1 // This file (SetUnitSizeCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. | |
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. | |
4 | |
5 using System; | |
6 using IBBoard.Commands; | |
7 using IBBoard.Lang; | |
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 { | |
29 return (unit != null && newSize > 0 && oldSize > 0); | |
30 } | |
31 | |
32 public override string Description | |
33 { | |
34 get | |
35 { | |
36 return Translation.GetTranslation("setUnitSizeCommandDescription", "set size of {0} to {1}", unit.Name, newSize); | |
37 } | |
38 } | |
39 | |
40 public override string UndoDescription | |
41 { | |
42 get | |
43 { | |
44 return Translation.GetTranslation("setUnitSizeCommandUndoDescription", "set size of {0} to {1}", unit.Name, oldSize); | |
45 } | |
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 } |