Skip to content

Commit 2a63596

Browse files
committed
Added ConfigManager, App::GetPreferences(), Resource::SaveNamedResource()
1 parent 5e429e8 commit 2a63596

13 files changed

Lines changed: 172 additions & 5 deletions

File tree

Spore ModAPI/SourceCode/App/App.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <Spore\App\cCreatureModeStrategy.h>
66
#include <Spore\App\cSporeApp.h>
77
#include <Spore\App\cArithmeticaResource.h>
8+
#include <Spore\App\ConfigManager.h>
89

910
namespace App
1011
{
@@ -76,5 +77,15 @@ namespace App
7677

7778
void cArithmeticaResource::func14h() {
7879
}
80+
81+
82+
//// ConfigManager ////
83+
84+
auto_STATIC_METHOD_(IConfigManager, IConfigManager*, Get);
85+
86+
PropertyList* GetPreferences()
87+
{
88+
return *(PropertyList**)GetAddress(App, sPreferencesPropList);
89+
}
7990
}
8091
#endif

Spore ModAPI/SourceCode/DLL/AddressesApp.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <Spore\App\cCellModeStrategy.h>
99
#include <Spore\App\cGameModeManager.h>
1010
#include <Spore\App\cMessageManager.h>
11+
#include <Spore\App\ConfigManager.h>
1112
#include <Spore\App\cPropManager.h>
1213
#include <Spore\App\cViewer.h>
1314
#include <Spore\App\DirectPropertyList.h>
@@ -589,14 +590,20 @@ namespace App
589590
DefineAddress(GetValue, SelectAddress(0x7F2B60, 0x7F2650));
590591
DefineAddress(SetValue, SelectAddress(0x7F2B90, 0x7F2680));
591592
}
593+
594+
namespace Addresses(IConfigManager)
595+
{
596+
DefineAddress(Get, SelectAddress(0x67DE50, 0x67DCF0));
597+
}
592598
}
593599

594-
#ifdef SDK_TO_GHIDRA
595600
namespace Addresses(App)
596601
{
602+
DefineAddress(sPreferencesPropList, SelectAddress(0x1601BA4, 0x15FD91C));
603+
#ifdef SDK_TO_GHIDRA
597604
DefineAddress(sScenarioMode, SelectAddress(0x16CBD24, 0x16C7AA4));
598605
DefineAddress(sCreatureModeStrategy, SelectAddress(0x16A2514, 0x169E294));
599-
}
600606
#endif
607+
}
601608

602609
#endif

Spore ModAPI/SourceCode/DLL/AddressesResource.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ namespace Resource
305305
namespace Addresses(Resource)
306306
{
307307
DefineAddress(ReadExtensionMappingsFromPropFile, SelectAddress(0x6B2440, 0x6B20A0));
308+
DefineAddress(SaveNamedResource, SelectAddress(0x6B4340, 0x6B3FA0));
308309
}
309310

310311
#endif

Spore ModAPI/SourceCode/IO/IODefinitions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,10 @@ namespace Resource
527527
return GetDirFromID(PathID::Debug);
528528
}
529529

530+
auto_STATIC_METHOD(Resource, bool, SaveNamedResource,
531+
Args(ResourceObject* resource, const char16_t* fileName, Database* database),
532+
Args(resource, fileName, database));
533+
530534
//////////////////////
531535

532536
EAIOZoneObject_AMBIGOUS(DatabaseDirectoryFiles);

Spore ModAPI/Spore ModAPI.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
<ClInclude Include="Spore\App\cLocaleManager.h" />
313313
<ClInclude Include="Spore\App\cMouseCamera.h" />
314314
<ClInclude Include="Spore\App\CommandLine.h" />
315+
<ClInclude Include="Spore\App\ConfigManager.h" />
315316
<ClInclude Include="Spore\App\cSporeApp.h" />
316317
<ClInclude Include="Spore\App\cStringDetokenizer.h" />
317318
<ClInclude Include="Spore\App\FileDrop.h" />

Spore ModAPI/Spore ModAPI.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,9 @@
21062106
<ClInclude Include="Spore\Pollinator\cSPAchievementSerializer.h">
21072107
<Filter>Header Files</Filter>
21082108
</ClInclude>
2109+
<ClInclude Include="Spore\App\ConfigManager.h">
2110+
<Filter>Header Files</Filter>
2111+
</ClInclude>
21092112
</ItemGroup>
21102113
<ItemGroup>
21112114
<ClCompile Include="SourceCode\Allocator.cpp">
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#pragma once
2+
3+
#include <Spore\App\CommandLine.h>
4+
#include <Spore\App\PropertyList.h>
5+
#include <EASTL\fixed_vector.h>
6+
#include <EASTL\string.h>
7+
#include <EASTL\vector.h>
8+
#include <EASTL\vector_map.h>
9+
10+
#define IConfigManagerPtr eastl::intrusive_ptr<App::IConfigManager>
11+
#define ConfigManager (*App::IConfigManager::Get())
12+
13+
namespace App
14+
{
15+
class IConfigManager
16+
{
17+
public:
18+
enum Messages
19+
{
20+
kMsgOptionApplied = 0xF62ADE
21+
};
22+
23+
static IConfigManager* Get();
24+
25+
/* 00h */ virtual int AddRef() = 0;
26+
/* 04h */ virtual int Release() = 0;
27+
/* 08h */ virtual ~IConfigManager() = 0;
28+
/* 0Ch */ virtual bool Init(CommandLine* commandLine, bool) = 0;
29+
/* 10h */ virtual bool Shutdown() = 0;
30+
/* 14h */ virtual void Update() = 0;
31+
/* 18h */ virtual void SetScriptPath(const char* path) = 0;
32+
/* 1Ch */ virtual void SetScriptKey(uint32_t instanceID, uint32_t groupID) = 0;
33+
/* 20h */ virtual void SetInfoAlerts(bool) = 0;
34+
/* 24h */ virtual void SetErrorAlerts(bool) = 0;
35+
/* 28h */ virtual bool Configure() = 0;
36+
/* 2Ch */ virtual void SetOption(uint32_t optionID, int value) = 0;
37+
/* 30h */ virtual int GetOption(uint32_t optionID) = 0;
38+
/* 34h */ virtual int GetOptionDefault(uint32_t optionID) = 0;
39+
/* 38h */ virtual void GetOptionIDs(eastl::vector<uint32_t>& dst) = 0;
40+
/* 3Ch */ virtual bool SavePreferences() = 0;
41+
/* 40h */ virtual void ResetToDefaults() = 0;
42+
/* 44h */ virtual int GetNumScreenResolutions() = 0;
43+
/* 48h */ virtual bool GetScreenResolutionInfo(int optionIndex, int& dstScreenWidth, int& dstScreenHeight, int& dstRefreshRate) = 0;
44+
/* 4Ch */ virtual bool GetConfigString(int index, eastl::string& dst) = 0;
45+
/* 50h */ virtual void SaveOptionSetup(const char* path) = 0;
46+
};
47+
48+
namespace Addresses(IConfigManager)
49+
{
50+
DeclareAddress(Get); // 0x67DE50 0x67DCF0
51+
}
52+
53+
class cConfigScriptState
54+
{
55+
public:
56+
struct cOption
57+
{
58+
/* 00h */ uint32_t mID;
59+
/* 04h */ int mDefaultValue;
60+
/* 08h */ int mValue;
61+
/* 0Ch */ eastl::fixed_vector<PropertyListPtr, 4> mPossibleValues;
62+
/* 34h */ eastl::fixed_vector<eastl::vector_map<uint32_t, PropertyListPtr>, 4> field_34;
63+
};
64+
ASSERT_SIZE(cOption, 0xAC);
65+
66+
/* 00h */ uint32_t field_0; // 0x21566AA
67+
/* 04h */ int field_4;
68+
/* 08h */ int field_8;
69+
/* 0Ch */ bool field_C;
70+
/* 0Dh */ bool field_D;
71+
/* 10h */ eastl::string field_10;
72+
/* 20h */ eastl::string field_20;
73+
/* 30h */ eastl::string field_30;
74+
/* 40h */ bool field_40;
75+
/* 41h */ bool field_41;
76+
/* 42h */ bool mInfoAlerts;
77+
/* 43h */ bool field_43; // true
78+
/* 44h */ eastl::vector<cOption> mOptions;
79+
/* 58h */ int field_58;
80+
/* 5Ch */ int field_5C;
81+
/* 60h */ eastl::vector<eastl::string> mConfigStrings;
82+
/* 74h */ eastl::vector<int> field_74;
83+
};
84+
ASSERT_SIZE(cConfigScriptState, 0x88);
85+
86+
class cConfigManager
87+
: public IConfigManager
88+
, public RefCountTemplate
89+
{
90+
public:
91+
/* 0Ch */ ObjectPtr mpFileParser;
92+
/* 10h */ ObjectPtr mpScriptParser;
93+
/* 14h */ ResourceKey mScriptKey;
94+
/* 20h */ cConfigScriptState mConfigScriptState;
95+
/* A8h */ int field_A8; // -1
96+
/* ACh */ bool mIsSafeMode;
97+
/* ADh */ bool mShowConfigAlerts;
98+
/* B0h */ PropertyListPtr mpAppPropList;
99+
};
100+
ASSERT_SIZE(cConfigManager, 0xB4);
101+
102+
/// Returns the preferences property list, which is stored in `AppData/Spore/Preferences/Preferences.prop`
103+
/// @returns
104+
PropertyList* GetPreferences();
105+
106+
#ifdef SDK_TO_GHIDRA
107+
PropertyList* sPreferencesPropList;
108+
#endif
109+
}
110+
111+
namespace Addresses(App)
112+
{
113+
DeclareAddress(sPreferencesPropList); // 0x1601BA4 0x15FD91C
114+
}

Spore ModAPI/Spore/App/PropertyList.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <Spore\App\Property.h>
2323
#include <Spore\IO\IStream.h>
2424
#include <Spore\Resource\ResourceObject.h>
25+
#include <Spore\Resource\Database.h>
2526
#include <EASTL\vector_map.h>
2627
#include <EASTL\vector.h>
2728

@@ -170,6 +171,13 @@ namespace App
170171
///
171172
void SetParent(PropertyList* pParent);
172173

174+
/// Adds the given property list to the IPropManager, and saves its contents into the given database.
175+
/// The current resource key of the propList will be used as its file name.
176+
/// @param propList The property list to save
177+
/// @param database The destination database
178+
/// @param async If true, schedule to save it asynchronously and return immediately
179+
static void SaveToDatabase(PropertyList* propList, Resource::Database* database, bool async);
180+
173181
protected:
174182
typedef eastl::vector_map<uint32_t, Property> PropertyMap;
175183
/* 18h */ PropertyMap mProperties;
@@ -196,5 +204,7 @@ namespace App
196204
DeclareAddress(Clear);
197205

198206
DeclareAddress(SetParent);
207+
208+
DeclareAddress(SaveToDatabase); // 0x6B2080 TODO
199209
}
200210
}

Spore ModAPI/Spore/App/cAppSystem.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <Spore\App\IMessageListener.h>
44
#include <Spore\App\CommandLine.h>
55
#include <Spore\App\Canvas.h>
6+
#include <Spore\App\PropertyList.h>
67
#include <Spore\Object.h>
78
#include <EASTL\string.h>
89

@@ -67,7 +68,7 @@ namespace App
6768
{
6869
public:
6970
/* 10h */ Canvas* mpCanvas;
70-
// 1Ch is cResourceManager, 24h is cLocaleManager, 28h is cResourceKeyGenerator, 40h is cJobManager
71+
// 1Ch is cResourceManager, 24h is cLocaleManager, 28h is cResourceKeyGenerator, 3Ch is IConfigManager, 40h is cJobManager, CCh is PropertyListPtr mpPreferencesPropList
7172
/* 14h */ char padding_14[0x124];
7273
/* 138h */ eastl::string16 mMySporeCreationsFolderName;
7374
/* 148h */ eastl::string16 mAppDataSporeFolderName;

Spore ModAPI/Spore/Audio/AudioSystem.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ namespace Audio
2525
{
2626
typedef int AudioTrack;
2727

28+
enum AudioProperties
29+
{
30+
kAudioVolume = 0x25DF0108
31+
};
32+
2833
class AudioSystem
2934
{
3035
//PLACEHODER we might need to complete this

0 commit comments

Comments
 (0)