forked from AerysBat/XNALara
-
Notifications
You must be signed in to change notification settings - Fork 2
/
UndoHistoryState.cs
116 lines (93 loc) · 3.76 KB
/
UndoHistoryState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
namespace XNALara
{
public abstract class UndoHistoryState
{
public abstract void Apply(ControlGUI gui);
public abstract bool DetermineSignificance(UndoHistoryState prevState);
}
public class UndoHistoryStateSelectItem : UndoHistoryState
{
private Item selectedItem;
public UndoHistoryStateSelectItem(Item selectedItem) {
this.selectedItem = selectedItem;
}
public override void Apply(ControlGUI gui) {
gui.HandleItemSelectedIn3D(selectedItem);
}
public override bool DetermineSignificance(UndoHistoryState prevState) {
if (prevState is UndoHistoryStateSelectItem) {
UndoHistoryStateSelectItem prevStateCast = (UndoHistoryStateSelectItem)prevState;
return selectedItem != prevStateCast.selectedItem;
}
return true;
}
public override string ToString() {
return string.Format("SelectItem {0}", selectedItem.Type);
}
}
public class UndoHistoryStateSelectBone : UndoHistoryState
{
private Armature.Bone selectedBone;
public UndoHistoryStateSelectBone(Armature.Bone selectedBone) {
this.selectedBone = selectedBone;
}
public override void Apply(ControlGUI gui) {
gui.HandleBoneSelectedIn3D(selectedBone);
}
public override bool DetermineSignificance(UndoHistoryState prevState) {
if (prevState is UndoHistoryStateSelectBone) {
UndoHistoryStateSelectBone prevStateCast = (UndoHistoryStateSelectBone)prevState;
return selectedBone != prevStateCast.selectedBone;
}
return true;
}
public override string ToString() {
return string.Format("SelectBone {0}", selectedBone.name);
}
}
public class UndoHistoryStateBoneTransform : UndoHistoryState
{
private Armature.Bone bone;
private ControlGUI.BoneTransform transform;
public UndoHistoryStateBoneTransform(Armature.Bone bone, ControlGUI.BoneTransform transform) {
this.bone = bone;
this.transform = transform.Clone();
}
public override void Apply(ControlGUI gui) {
gui.HandleBoneRotationXChanged(bone, transform.rotX);
gui.HandleBoneRotationYChanged(bone, transform.rotY);
gui.HandleBoneRotationZChanged(bone, transform.rotZ);
gui.HandleBoneTranslationXChanged(bone, transform.moveX);
gui.HandleBoneTranslationYChanged(bone, transform.moveY);
gui.HandleBoneTranslationZChanged(bone, transform.moveZ);
}
public override bool DetermineSignificance(UndoHistoryState prevState) {
if (prevState is UndoHistoryStateBoneTransform) {
UndoHistoryStateBoneTransform prevStateCast = (UndoHistoryStateBoneTransform)prevState;
if (bone == prevStateCast.bone) {
return false;
}
}
return true;
}
public override string ToString() {
return string.Format("BoneTransform ({0} {1} {2}) ({3} {4} {5})",
transform.rotX, transform.rotY, transform.rotZ,
transform.moveX, transform.moveY, transform.moveZ);
}
}
public class UndoHistoryStateInterrupt : UndoHistoryState
{
public override void Apply(ControlGUI gui) {
}
public override bool DetermineSignificance(UndoHistoryState prevState) {
if (prevState is UndoHistoryStateInterrupt) {
return false;
}
return true;
}
public override string ToString() {
return string.Format("[Interrupt]");
}
}
}