fix AppDelegate on Windows + reworked the Mod enable/disable system +

save loader settings + L + ratio
This commit is contained in:
HJfod 2022-02-11 15:29:28 +02:00
parent 5ccf83ed5f
commit 9fc589121f
5 changed files with 31 additions and 11 deletions

View file

@ -79,7 +79,7 @@ public:
RT_ADD(
virtual void applicationWillBecomeActive() {}
virtual void applicationWillResignActive() {}
virtual void trySaveGame() {}
virtual void trySaveGame() = 0;
virtual void gameDidSave() {}
)

View file

@ -30,10 +30,18 @@ namespace geode {
class GEODE_DLL Loader {
protected:
struct LoaderSettings {
struct ModSettings {
bool m_enabled = true;
};
std::unordered_map<std::string, ModSettings> m_mods;
};
std::unordered_map<std::string, Mod*> m_mods;
std::vector<LogMessage*> m_logs;
std::vector<std::string> m_modDirectories;
LogStream* m_logStream;
LoaderSettings m_loadedSettings;
bool m_isSetup = false;
static bool s_unloading;
@ -88,6 +96,11 @@ namespace geode {
Loader();
virtual ~Loader();
Result<> saveSettings();
Result<> loadSettings();
bool shouldLoadMod(std::string const& id) const;
/**
* Get the shared Loader instance
* @returns Shared loader instance

View file

@ -209,6 +209,14 @@ namespace geode {
* Pointer to the Mod's unload function
*/
geode_unload m_unloadFunc = nullptr;
/**
* Pointer to the Mod's enable function
*/
geode_enable m_enableFunc = nullptr;
/**
* Pointer to the Mod's enable function
*/
geode_disable m_disableFunc = nullptr;
/**
* Path to the mod's build directory
*/
@ -386,16 +394,14 @@ namespace geode {
Result<> unload();
/**
* Enable & load this mod
* Enable this mod
* @returns Successful result on success,
* errorful result with info on error
*/
Result<> enable();
/**
* Disable & unload this mod
* @warning May crash if the mod doesn't
* properly handle unloading!
* Disable this mod if it supports doing so
* @returns Successful result on success,
* errorful result with info on error
*/

View file

@ -141,4 +141,6 @@ namespace geode {
*/
typedef bool(GEODE_CALL* geode_load)(Mod*);
typedef void(GEODE_CALL* geode_unload)();
typedef bool(GEODE_CALL* geode_enable)();
typedef bool(GEODE_CALL* geode_disable)();
}

View file

@ -100,13 +100,12 @@ class AnimatedSpriteDelegate {}
class AppDelegate : cocos2d::CCApplication {
void bgScale() = mac 0x3aaab0, win 0x0, ios 0x0;
virtual bool applicationDidFinishLaunching() = mac 0x3aa900, win 0x0, ios 0x0;
virtual void applicationDidEnterBackground() = mac 0x3aabe0, win 0x0, ios 0x0;
virtual void applicationWillEnterForeground() = mac 0x3aac80, win 0x0, ios 0x0;
virtual void applicationWillBecomeActive() = mac 0x3aab30, win 0x0, ios 0x0;
virtual void applicationWillResignActive() = mac 0x3aab50, win 0x0, ios 0x0;
virtual bool applicationDidFinishLaunching() = mac 0x3aa900, win 0x3cbb0, ios 0x0;
virtual void applicationDidEnterBackground() = mac 0x3aabe0, win 0x3cf40, ios 0x0;
virtual void applicationWillEnterForeground() = mac 0x3aac80, win 0x3d130, ios 0x0;
virtual void applicationWillBecomeActive() = mac 0x3aab30, win 0x3ce90, ios 0x0;
virtual void applicationWillResignActive() = mac 0x3aab50, win 0x3d3e0, ios 0x0;
virtual void trySaveGame() = mac 0x3aaf10, win 0x3d5e0, ios 0x1a28f0;
void trySaveGame_() = mac 0x3aaf10, win 0x3d5e0, ios 0x1a28f0;
virtual void willSwitchToScene(cocos2d::CCScene*) = mac 0x3aaf40, win 0x0, ios 0x0;
static AppDelegate* get() = mac 0x3aab10, win 0x0, ios 0x0;