15
|
1 // This file (SetUnitSizeCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
|
|
2 //
|
82
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
|
|
4
|
|
5 using System;
|
0
|
6 using IBBoard.Commands;
|
82
|
7 using IBBoard.WarFoundry.API.Objects;
|
|
8
|
|
9 namespace IBBoard.WarFoundry.API.Commands
|
|
10 {
|
|
11 /// <summary>
|
|
12 /// Summary description for SetNameCommand.
|
|
13 /// </summary>
|
|
14 public class SetUnitSizeCommand : Command
|
|
15 {
|
|
16 private Unit unit;
|
|
17 private int newSize, oldSize;
|
|
18
|
|
19 public SetUnitSizeCommand(Unit toResize, int size)
|
|
20 {
|
|
21 unit = toResize;
|
|
22 newSize = size;
|
|
23 oldSize = unit.Size;
|
|
24 }
|
|
25
|
|
26 public override bool CanExecute()
|
|
27 {
|
|
28 return (unit!=null && newSize >0 && oldSize > 0);
|
|
29 }
|
|
30
|
|
31 public override string Description
|
|
32 {
|
|
33 get { return "Change size of "+unit.Name; }
|
|
34 }
|
|
35
|
|
36 public override string UndoDescription
|
|
37 {
|
|
38 get { return "Revert size of "+unit.Name; }
|
|
39 }
|
|
40
|
|
41 public override bool Execute()
|
|
42 {
|
|
43 this.Redo();
|
|
44 return true;
|
|
45 }
|
|
46
|
|
47 public override void Redo()
|
|
48 {
|
|
49 unit.Size = newSize;
|
|
50 }
|
|
51
|
|
52 public override void Undo()
|
|
53 {
|
|
54 unit.Size = oldSize;
|
|
55 }
|
|
56
|
|
57 public override string Name
|
|
58 {
|
|
59 get { return "Change unit size"; }
|
|
60 }
|
|
61 }
|
|
62 }
|