5555#include < EASTL\string.h>
5656#include < EASTL\vector.h>
5757
58- // / Access the active editor object.
58+ // / Access the active editor object; check Editors::cEditor
5959#define Editor (*Editors::GetEditor ())
6060
6161#define cEditorPtr intrusive_ptr<Editors::cEditor>
@@ -96,6 +96,26 @@ namespace Editors
9696 kComplexityFlagBakedBlock = 0x4 ,
9797 };
9898
99+ // / Structure that records the state of the editor (current mode, budget, etc) for undo/redo history
100+ class EditorStateEditHistory
101+ : public DefaultRefCounted
102+ {
103+ public:
104+ /* 08h */ int mBudget ;
105+ /* 0Ch */ Mode mMode ;
106+ /* 10h */ int field_10;
107+ /* 14h */ bool field_14;
108+ /* 15h */ bool field_15;
109+ /* 18h */ int field_18;
110+ /* 1Ch */ int field_1C;
111+ /* 20h */ int field_20;
112+ /* 24h */ int field_24;
113+ /* 28h */ int field_28;
114+ };
115+ ASSERT_SIZE (EditorStateEditHistory, 0x2C );
116+
117+ // / Main class for editors. A single instance of this class exists during the whole game, and is used for all
118+ // / editors (except the Adventure editor, that one uses App::cScenarioMode); you can access it with the Editor macro.
99119 class cEditor
100120 : public App::IGameMode
101121 , public Graphics::IRenderable
@@ -110,17 +130,44 @@ namespace Editors
110130 // PLACEHOLDER virtual method 54h -> reads temporary database
111131 // PLACEHOLDER virtual method 58h -> wrties temporary database
112132
113- virtual ~cEditor ();
133+ // / Changes the current editor model, updating the creation with the parts and paints of the new editor model.
134+ // / @param pEditorModel
135+ void SetEditorModel (EditorModel* pEditorModel);
136+
137+ // / Get current editor model, which is the creation with the parts and paints.
138+ // / @returns
139+ inline EditorModel* GetEditorModel () const ;
140+
141+ // / Adds an edit history (undo/redo) entry based on the current model of the editor.
142+ // / @param arg1
143+ // / @param pStateHistory
144+ void CommitEditHistory (bool arg1, EditorStateEditHistory* pStateHistory = nullptr );
145+
146+ void Undo (bool , bool );
147+ void Redo ();
114148
115- // /
116149 // / Returns true if the editor is currently in the given mode.
117150 // / @param mode Either build, paint or play mode.
151+ // / @returns
118152 bool IsMode (Mode mode) const ;
119153
120- // /
121154 // / Returns true if the editor is currently active.
155+ // / @returns
122156 bool IsActive () const ;
123157
158+ EditorCamera* GetCamera ();
159+
160+ // _ZN6Editor9ScalePartEP14EditorRigblockii
161+ // Editor::ScalePart(EditorRigblock *, int, int)
162+
163+
164+ bool sub_581F70 (EditorRigblock* part, void * activeHandle, int value);
165+
166+ // loc_573BB1 -> set part is hovered?
167+
168+
169+ void RemovePart (EditorRigblock* part); // PLACEHOLDER
170+
124171 public:
125172
126173 int vftable_1C;
@@ -164,7 +211,7 @@ namespace Editors
164211 /* 88h */ IModelWorldPtr field_88;
165212 // / The model world that contains the background model.
166213 /* 8Ch */ IModelWorldPtr mpBackgroundModelWorld;
167- /* 90h */ int field_90;
214+ /* 90h */ int field_90; // related with havok world?
168215 /* 94h */ IEffectWorldPtr mpEffectWorld;
169216
170217 // use appropiate container!
@@ -188,14 +235,15 @@ namespace Editors
188235 /* C8h */ int field_C8; // not initialized
189236
190237 // also valid for spines
191- /* CCh */ intrusive_ptr<EditorRigblock> mpActivePart;
192- /* D0h */ intrusive_ptr<EditorRigblock> mpMovingPart; // the part that is being moved, only when mouse is being clicked
193- /* D4h */ intrusive_ptr<EditorRigblock> mpSelectedPart; // also valid for spines
238+ // / Rigblock that is being hovered, and where actions like mouse wheel scaling will be applied
239+ /* CCh */ EditorRigblockPtr mpActivePart;
240+ /* D0h */ EditorRigblockPtr mpMovingPart; // the part that is being moved, only when mouse is being clicked
241+ /* D4h */ EditorRigblockPtr mpSelectedPart; // also valid for spines
194242
195- /* D8h */ int field_D8;
196- /* DCh */ int field_DC;
243+ /* D8h */ DefaultRefCountedPtr field_D8;
244+ /* DCh */ DefaultRefCountedPtr field_DC;
197245 /* E0h */ bool field_E0;
198- /* E4h */ UnkClass4 * mpActiveHandle; // morph handles
246+ /* E4h */ EditorBaseHandle * mpActiveHandle; // morph handles
199247 // / Is the mouse over the skin of the creature?
200248 /* E8h */ bool mbMouseIsInSkin;
201249 /* E9h */ bool field_E9;
@@ -212,7 +260,7 @@ namespace Editors
212260 /* 142h */ bool field_142;
213261 /* 143h */ bool field_143; // not initialized
214262 /* 144h */ bool field_144; // true
215- /* 148h */ int field_148;
263+ /* 148h */ ObjectPtr field_148;
216264 /* 14Ch */ int field_14C; // vertebra? only present in creature-like editor
217265 /* 150h */ intrusive_ptr<Object> field_150; // something related with painting? uses sub_4C3E70 to return something that parts also use
218266 /* 154h */ int field_154;
@@ -224,9 +272,9 @@ namespace Editors
224272
225273 /* 158h */ int field_158;
226274 /* 15Ch */ int field_15C;
227- /* 160h */ vector<int > field_160 ;
228- /* 174h */ vector<int > field_174 ;
229- /* 188h */ int field_188 ;
275+ /* 160h */ vector<intrusive_ptr<EditorStateEditHistory>> mStateEditHistory ;
276+ /* 174h */ vector<cEditorResourcePtr> mEditHistory ;
277+ /* 188h */ int mEditHistoryIndex ;
230278 // / The ID of the .prop configuration file of the current editor.
231279 /* 18Ch */ uint32_t mEditorName ; // 0x465C50BA
232280 /* 190h */ bool mbTransitionHideUI; // true
@@ -240,7 +288,7 @@ namespace Editors
240288 /* 1ACh */ int field_1AC;
241289 // / Maps a creation format extension to its default editor. For example, 'crt' is mapped to 'CreatureEditorExtraLarge'.
242290 /* 1B0h */ map<uint32_t , uint32_t > mDefaultEditors ;
243- /* 1CCh */ intrusive_ptr<EditorRequest> mEditorRequest ; // in 35h there is bool editorAllowNameEdit;
291+ /* 1CCh */ EditorRequestPtr mEditorRequest ; // in 35h there is bool editorAllowNameEdit;
244292 /* 1D0h */ ResourceKey mParentAssetKey ;
245293 /* 1DCh */ string16 field_1DC;
246294 /* 1ECh */ int field_1EC;
@@ -375,7 +423,7 @@ namespace Editors
375423 /* 364h */ int field_364;
376424 /* 368h */ int field_368;
377425 /* 36Ch */ vector<int > field_36C;
378- /* 380h */ int field_380;
426+ /* 380h */ DefaultRefCountedPtr field_380;
379427 /* 384h */ bool field_384;
380428 /* 385h */ bool field_385;
381429 /* 388h */ int field_388; // not initialized
@@ -388,17 +436,13 @@ namespace Editors
388436 /* 398h */ bool field_398; // true
389437 /* 399h */ bool field_399; // true
390438 /* 39Ah */ bool field_39A; // true
391- /* 39Ch */ int field_39C;
392- /* 3A0h */ int field_3A0;
393- /* 3A4h */ int field_3A4;
394- /* 3A8h */ int field_3A8; // not initialized
395- /* 3ACh */ int field_3AC; // not initialized
396- /* 3B0h */ int field_3B0; // not initialized
439+ /* 39Ch */ vector<int > field_39C;
440+ /* 3B0h */ float field_3B0; // not initialized
397441 /* 3B4h */ int field_3B4; // not initialized
398- /* 3B8h */ intrusive_ptr<Palettes::PaletteMain> mpPartsPalette;
399- /* 3BCh */ intrusive_ptr<Palettes::PaletteUI> mpPartsPaletteUI;
400- /* 3C0h */ intrusive_ptr<Palettes::PaletteMain> mpPaintPalette;
401- /* 3C4h */ intrusive_ptr<Palettes::PaletteUI> mpPaintPaletteUI;
442+ /* 3B8h */ PaletteMainPtr mpPartsPalette;
443+ /* 3BCh */ PaletteUIPtr mpPartsPaletteUI;
444+ /* 3C0h */ PaletteMainPtr mpPaintPalette;
445+ /* 3C4h */ PaletteUIPtr mpPaintPaletteUI;
402446 /* 3C8h */ bool field_3C8;
403447 /* 3C9h */ bool field_3C9; // true
404448
@@ -515,19 +559,6 @@ namespace Editors
515559 /* 5F4h */ int field_5F4;
516560 /* 5F8h */ int field_5F8;
517561 /* 5FCh */ int field_5FC; // not initialized
518-
519- EditorCamera* GetCamera ();
520-
521- // _ZN6Editor9ScalePartEP14EditorRigblockii
522- // Editor::ScalePart(EditorRigblock *, int, int)
523-
524-
525- bool sub_581F70 (EditorRigblock* part, void * activeHandle, int value);
526-
527- // loc_573BB1 -> set part is hovered?
528-
529-
530- void RemovePart (EditorRigblock* part); // PLACEHOLDER
531562 };
532563
533564 static_assert (sizeof (cEditor) == 0x600 , " sizeof(cEditor) must be 0x600!" );
@@ -547,6 +578,11 @@ namespace Editors
547578 DeclareAddress (OnMouseMove);
548579 DeclareAddress (OnMouseWheel);
549580 DeclareAddress (Update);
581+
582+ DeclareAddress (SetEditorModel); // 0x5867D0, 0x586B00
583+ DeclareAddress (CommitEditHistory); // 0x5860E0, 0x586410
584+ DeclareAddress (Undo); // 0x58A270, 0x58A5A0
585+ DeclareAddress (Redo); // 0x58A620, 0x58A950
550586 }
551587
552588 // / Returns the Editor instance (there can only be one at a time).
@@ -557,16 +593,7 @@ namespace Editors
557593
558594 inline EditorCamera* cEditor::GetCamera ()
559595 {
560- App::ICamera* pCamera = this ->mpGameModeMgr ->GetCameraManager ()->GetActiveCamera ();
561-
562- if (pCamera != nullptr )
563- {
564- return (EditorCamera*) pCamera->Cast (EditorCamera::TYPE);
565- }
566- else
567- {
568- return nullptr ;
569- }
596+ return object_cast<EditorCamera>(mpGameModeMgr->GetCameraManager ()->GetActiveCamera ());
570597 }
571598
572599 inline bool cEditor::IsMode (Mode mode) const {
@@ -576,4 +603,9 @@ namespace Editors
576603 inline bool cEditor::IsActive () const {
577604 return mIsActive ;
578605 }
606+
607+ inline EditorModel* cEditor::GetEditorModel () const
608+ {
609+ return mpEditorModel;
610+ }
579611}
0 commit comments