-
Notifications
You must be signed in to change notification settings - Fork 4
/
undoframework.h
182 lines (159 loc) · 4.87 KB
/
undoframework.h
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#ifndef UNDOFRAMEWORK_H
#define UNDOFRAMEWORK_H
#include <QUndoCommand>
#include "itemfile.h"
#include "resourcehandler.h"
class SpriteModel;
class QSpinBox;
class ItemEditor;
enum ItemAction {
ITEM_ACTION_NONE,
ITEM_ACTION_INSERT_NEW,
ITEM_ACTION_INSERT,
ITEM_ACTION_MOVE_NEW,
ITEM_ACTION_MOVE,
ITEM_ACTION_PASTE_NEW,
ITEM_ACTION_PASTE,
ITEM_ACTION_IMPORT_NEW,
ITEM_ACTION_IMPORT,
ITEM_ACTION_REPLACE
};
class CommandSetItemAppearance : public QUndoCommand
{
public:
CommandSetItemAppearance( ItemEditor *itemEditor, ItemData *itemData, QUndoCommand *parent = NULL );
~CommandSetItemAppearance( void ) {};
virtual void undo( void );
virtual void redo( void );
private:
ItemEditor *m_itemEditor;
ItemData *m_itemData;
quint8 m_oldWidth, m_oldHeight, m_oldCropsize, m_oldLayers, m_oldXDiv, m_oldYDiv, m_oldZDiv, m_oldAnimations;
quint8 m_newWidth, m_newHeight, m_newCropsize, m_newLayers, m_newXDiv, m_newYDiv, m_newZDiv, m_newAnimations;
};
class CommandSetItemProperties : public QUndoCommand
{
public:
CommandSetItemProperties( ItemEditor *itemEditor, ItemData *itemData, PropertyList properties, QUndoCommand *parent = NULL );
~CommandSetItemProperties( void ) {};
virtual void undo( void );
virtual void redo( void );
private:
ItemEditor *m_itemEditor;
ItemData *m_itemData;
PropertyList m_oldProperties;
PropertyList m_properties;
};
class CommandImportSprites : public QUndoCommand
{
public:
CommandImportSprites( quint8 resourceType, quint32 indexStart, ResourceList& resources, QUndoCommand *parent = NULL );
~CommandImportSprites( void );
virtual void undo( void );
virtual void redo( void );
private:
quint8 m_resourceType;
quint32 m_indexStart;
ResourceList m_resources;
bool m_resourceOwner;
};
class CommandSwapSprite : public QUndoCommand
{
public:
CommandSwapSprite( qint32 fromIndex, qint32 toIndex, SharedResource& fromResource, SharedResource& toResource, QUndoCommand *parent = NULL );
~CommandSwapSprite( void );
virtual void undo( void );
virtual void redo( void );
private:
qint32 m_fromIndex;
qint32 m_toIndex;
SharedResource m_fromResource;
SharedResource m_toResource;
};
class CommandCutItems : public QUndoCommand
{
public:
CommandCutItems( ItemFile *_itemFile, const ItemList& _items, QUndoCommand *parent = NULL );
~CommandCutItems( void );
virtual void undo( void );
virtual void redo( void );
private:
ItemFile *m_itemFile;
ItemList m_items;
QList<QPair<qint32, TibiaItem *> > m_cutItems;
quint8 m_parent;
bool m_itemsOwner;
};
class CommandChangeItem : public QUndoCommand
{
public:
CommandChangeItem( ItemFile *_itemFile, TibiaItem *_item, PropertyList _properties, QUndoCommand *parent = NULL );
~CommandChangeItem( void ) {};
virtual void undo( void );
virtual void redo( void );
private:
ItemFile *m_itemFile;
TibiaItem *m_item;
PropertyList m_beforeProperties;
PropertyList m_afterProperties;
};
class CommandRemoveItems : public QUndoCommand
{
public:
CommandRemoveItems( ItemFile *_itemFile, const ItemList& _items, QUndoCommand *parent = NULL );
virtual void undo( void ) {
QUndoCommand::undo();
};
virtual void redo( void ) {
QUndoCommand::redo();
};
};
class CommandRemoveItem : public QUndoCommand
{
public:
CommandRemoveItem( ItemFile *itemFile, TibiaItem *item, QUndoCommand *parent = NULL );
~CommandRemoveItem( void );
virtual void undo( void );
virtual void redo( void );
private:
ItemFile *m_itemFile;
TibiaItem *m_item;
qint32 m_index;
quint8 m_parent;
bool m_itemOwner;
};
class CommandRelocateItems : public QUndoCommand
{
public:
CommandRelocateItems( ItemFile *itemFile, const ItemList& items, TibiaItem *toItem, ItemAction action, quint8 toParent = ITEM_PARENT_INTERNAL, qint32 toIndex = -1, QUndoCommand *parent = NULL );
virtual void undo( void ) {
QUndoCommand::undo();
};
virtual void redo( void ) {
QUndoCommand::redo();
};
};
class CommandRelocateItem : public QUndoCommand
{
public:
CommandRelocateItem( ItemFile *itemFile, TibiaItem *fromItem, TibiaItem *toItem, ItemAction action, quint8 toParent = ITEM_PARENT_INTERNAL, qint32 toIndex = -1, QUndoCommand *parent = NULL );
~CommandRelocateItem( void );
virtual void undo( void );
virtual void redo( void );
private:
ItemFile *m_itemFile;
TibiaItem *m_fromItem;
TibiaItem *m_toItem;
qint32 m_fromIndex;
qint32 m_toIndex;
quint8 m_toParent;
quint8 m_fromParent;
ItemAction m_action;
bool m_toItemOwner;
bool m_fromItemOwner;
};
inline bool isItemContainer( quint8 parent )
{
return ( parent == ITEM_PARENT_ITEMS || parent == ITEM_PARENT_OUTFITS || parent == ITEM_PARENT_EFFECTS || parent == ITEM_PARENT_PROJECTILES );
};
#endif // UNDOFRAMEWORK_H