Skip to content

Commit ffd27c1

Browse files
committed
Improvements to EditorRigblock, EditorModel, cEditorResource, EditorBaseHandle, TuningSpine.
1 parent b72cf4e commit ffd27c1

File tree

12 files changed

+655
-167
lines changed

12 files changed

+655
-167
lines changed

Spore ModAPI/SourceCode/DLL/AddressesEditors.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <Spore\Editors\EditorCamera.h>
88
#include <Spore\Editors\EditorRequest.h>
99
#include <Spore\Editors\EditorUI.h>
10+
#include <Spore\Editors\TuningSpine.h>
1011
#include <Spore\Editors\PlayModeAnimations.h>
1112
#include <Spore\Editors\SpeciesManager.h>
1213
#include <Spore\Editors\CreatureWalkController.h>
@@ -20,6 +21,11 @@ namespace Editors
2021
DefineAddress(Get, SelectAddress(0x401010, 0x401010, 0x401010));
2122
}
2223

24+
namespace Addresses(cTuningSpine)
25+
{
26+
DefineAddress(Get, SelectAddress(0x401070, , 0x401070));
27+
}
28+
2329
namespace Addresses(ContentValidation) {
2430
DefineAddress(IllegalCharacters_ptr, SelectAddress(0x15DEA54, , 0x15DA7C4));
2531
DefineAddress(ValidationEditableTests_ptr, SelectAddress(0x15DEA04, , 0x15DA7D4));
@@ -41,6 +47,11 @@ namespace Editors
4147
DefineAddress(OnMouseMove, SelectAddress(0x5736C0, , 0x5737D0));
4248
DefineAddress(OnMouseWheel, SelectAddress(0x5859E0, , 0x585D10));
4349
DefineAddress(Update, SelectAddress(0x58BB20, , 0x58BE50));
50+
51+
DefineAddress(SetEditorModel, SelectAddress(0x5867D0, , 0x586B00));
52+
DefineAddress(CommitEditHistory, SelectAddress(0x5860E0, , 0x586410));
53+
DefineAddress(Undo, SelectAddress(0x58A270, , 0x58A5A0));
54+
DefineAddress(Redo, SelectAddress(0x58A620, , 0x58A950));
4455
}
4556

4657
namespace Addresses(EditorCamera)
@@ -99,8 +110,13 @@ namespace Editors
99110

100111
namespace Addresses(EditorModel)
101112
{
113+
DefineAddress(SetName, SelectAddress(0x4ADC20, , 0x4AE280));
114+
DefineAddress(SetDescription, SelectAddress(0x4ADDE0, , 0x4AE440));
102115
DefineAddress(GetCreationName, SelectAddress(0x4ADEA0, 0x4AE520, 0x4AE520));
103116
DefineAddress(SetColor, SelectAddress(0x4ADBF0, 0x4AE250, 0x4AE250));
117+
DefineAddress(Load, SelectAddress(0x4AE240, , 0x4AE8D0));
118+
DefineAddress(Save, SelectAddress(0x4AF0F0, , 0x4AF780));
119+
DefineAddress(Dispose, SelectAddress(0x4AD1F0, , 0x4AD850));
104120
}
105121

106122
namespace Addresses(CreatureWalkController)

Spore ModAPI/SourceCode/Editors/Editor.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
#ifndef MODAPI_DLL_EXPORT
22
#include <Spore\Editors\Editor.h>
33
#include <Spore\Editors\EditorModel.h>
4+
#include <Spore\Editors\TuningSpine.h>
45

56
namespace Editors
67
{
78
auto_METHOD(cEditor, bool, sub_581F70, Args(EditorRigblock* part, void* activeHandle, int value), Args(part, activeHandle, value));
89

10+
auto_METHOD_VOID(cEditor, SetEditorModel, Args(EditorModel* pEditorModel), Args(pEditorModel));
11+
auto_METHOD_VOID(cEditor, CommitEditHistory, Args(bool p, EditorStateEditHistory* pStateHistory), Args(p, pStateHistory));
12+
auto_METHOD_VOID(cEditor, Undo, Args(bool a, bool b), Args(a, b));
13+
auto_METHOD_VOID_(cEditor, Redo);
14+
15+
auto_METHOD_VOID_(EditorModel, Dispose);
916
auto_METHOD_const_(EditorModel, string16&, GetCreationName);
1017
auto_METHOD_VOID(EditorModel, SetColor, Args(int index, struct ColorRGB color), Args(index, color));
18+
auto_METHOD_VOID(EditorModel, Load, Args(cEditorResource* pResource), Args(pResource));
19+
auto_METHOD_VOID(EditorModel, Save, Args(cEditorResource* pResource), Args(pResource));
20+
21+
auto_STATIC_METHOD_(cTuningSpine, cTuningSpine*, Get);
1122

1223

1324
int IEditorLimits::AddRef() {
@@ -24,5 +35,64 @@ namespace Editors
2435
return mnRefCount;
2536
}
2637

38+
39+
auto_METHOD_VIRTUAL_VOID(EditorModel, INameableEntity, SetName, Args(const char16_t* pString), Args(pString));
40+
auto_METHOD_VIRTUAL_VOID(EditorModel, INameableEntity, SetDescription, Args(const char16_t* pString), Args(pString));
41+
42+
const char16_t* EditorModel::GetName() {
43+
return mName.c_str();
44+
}
45+
46+
const char16_t* EditorModel::GetDescription() {
47+
return mDescription.c_str();
48+
}
49+
50+
void EditorModel::SetTags(const char16_t* pString) {}
51+
const char16_t* EditorModel::GetTags() { return nullptr; }
52+
53+
EditorModel::EditorModel()
54+
: mnRefCount(0)
55+
, mKey()
56+
, mParts()
57+
, field_2C()
58+
, field_30()
59+
, field_34()
60+
, field_38()
61+
, field_3C()
62+
, field_40(-2.0f)
63+
, field_44(2.0f)
64+
, field_48()
65+
, field_4C()
66+
, field_4D()
67+
, field_4E(true)
68+
, field_4F()
69+
, field_50()
70+
, field_51()
71+
, mTranslationOptions()
72+
, mModelType()
73+
, mName()
74+
, mDescription()
75+
, mAcceptedName()
76+
, mSkinEffectIDs()
77+
, mSkinEffectSeeds{1234, 1234, 1234}
78+
, mColors {ColorRGB(1.0f, 1.0f, 1.0f), ColorRGB(1.0f, 1.0f, 1.0f), ColorRGB(1.0f, 1.0f, 1.0f)}
79+
, field_C8()
80+
{
81+
}
82+
83+
EditorModel::~EditorModel()
84+
{
85+
Dispose();
86+
87+
// field_30 is a pointer, but I don't know what kind so we manually Release it
88+
if (field_30 != 0) {
89+
int* pointer = (int*)field_30;
90+
pointer[1]--;
91+
if (pointer[1] == 0) {
92+
pointer[1] = 1;
93+
delete ((IVirtual*)pointer);
94+
}
95+
}
96+
}
2797
}
2898
#endif

Spore ModAPI/Spore ModAPI.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
<ClInclude Include="ModAPI\Detouring.h" />
319319
<ClInclude Include="Spore\Creations.h" />
320320
<ClInclude Include="Spore\Editors\CreatureWalkController.h" />
321+
<ClInclude Include="Spore\Editors\EditorBaseHandle.h" />
321322
<ClInclude Include="Spore\Editors\EditorLimits.h" />
322323
<ClInclude Include="Spore\Editors\INameableEntity.h" />
323324
<ClInclude Include="Spore\Editors\PlayModeActor.h" />

Spore ModAPI/Spore ModAPI.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,9 @@
18631863
<ClInclude Include="Spore\Simulator\cScenarioSimulator.h">
18641864
<Filter>Header Files</Filter>
18651865
</ClInclude>
1866+
<ClInclude Include="Spore\Editors\EditorBaseHandle.h">
1867+
<Filter>Header Files</Filter>
1868+
</ClInclude>
18661869
</ItemGroup>
18671870
<ItemGroup>
18681871
<ClCompile Include="SourceCode\Allocator.cpp">

Spore ModAPI/Spore/Editors/Editor.h

Lines changed: 82 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
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

Comments
 (0)