settings saving

This commit is contained in:
HJfod 2022-02-05 18:59:59 +02:00
parent 02af57248e
commit 35fd598d23
5 changed files with 42 additions and 11 deletions

View file

@ -162,7 +162,7 @@ namespace geode {
* Get a list of all loaded mods
* @returns List of all loaded mods
*/
std::vector<Mod*> getLoadedMods() const;
std::vector<Mod*> getLoadedMods(bool resolved = false) const;
/**
* Get the count of loaded mods
* @returns Tuple where the first element is the count of

View file

@ -139,6 +139,10 @@ namespace geode {
* Settings
*/
std::unordered_map<std::string, Setting*> m_settings;
/**
* Whether the mod can be disabled or not
*/
bool m_supportsDisabling = true;
};
/**
@ -178,10 +182,6 @@ namespace geode {
* Whether the mod is loadable or not
*/
bool m_resolved = false;
/**
* Whether the mod can be disabled or not
*/
bool m_supportsDisabling = true;
/**
* Mod temp directory name
*/
@ -189,7 +189,7 @@ namespace geode {
/**
* Mod save directory name
*/
ghc::filesystem::path m_saveDirName;
ghc::filesystem::path m_saveDirPath;
/**
* Pointers to mods that depend on
* this Mod. Makes it possible to
@ -401,6 +401,9 @@ namespace geode {
*/
Result<> disable();
Result<> saveData();
Result<> loadData();
/**
* Get the value of a setting
* @param key The setting's key

View file

@ -53,8 +53,8 @@ namespace geode {
std::string getKey() const { return m_key; }
virtual void save(nlohmann::json& json) const;
virtual void load(nlohmann::json const& json);
virtual Result<> save(nlohmann::json& json) const = 0;
virtual Result<> load(nlohmann::json const& json) = 0;
static Result<Setting*> parseFromJSON(nlohmann::json const& json);
@ -142,6 +142,9 @@ namespace geode {
protected:
friend class GeodeSetting<BoolSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Bool; }
};
@ -149,6 +152,9 @@ namespace geode {
class IntSetting : public SingleSetting<int, IntSetting>, public INumericSetting<int, IntSetting, false, true, true> {
protected:
friend class GeodeSetting<IntSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Int; }
@ -158,6 +164,9 @@ namespace geode {
protected:
friend class GeodeSetting<FloatSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Float; }
};
@ -168,6 +177,9 @@ namespace geode {
friend class GeodeSetting<StringSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
static bool replaceWithBuiltInFilter(std::string& filter);
inline virtual SettingType getType() override { return SettingType::String; }
@ -179,6 +191,9 @@ namespace geode {
friend class GeodeSetting<ColorSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Color; }
};
@ -189,6 +204,9 @@ namespace geode {
friend class GeodeSetting<ColorAlphaSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::ColorAlpha; }
};
@ -197,6 +215,9 @@ namespace geode {
protected:
friend class GeodeSetting<PathSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Path; }
};
@ -205,11 +226,18 @@ namespace geode {
protected:
friend class GeodeSetting<StringSelectSetting>;
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::StringSelect; }
};
class CustomSettingPlaceHolder : public Setting {
protected:
Result<> save(nlohmann::json& json) const override;
Result<> load(nlohmann::json const& json) override;
public:
inline virtual SettingType getType() override { return SettingType::Custom; }
};

View file

@ -20,10 +20,10 @@ function(create_geode_file proname)
else()
if (GEODE_AUTO_INSTALL_IN_API)
set(INSTALL_FLAGS --install --api)
message(STATUS "Installing in geode/api after build")
message(STATUS "Installing ${proname} in geode/api after build")
else()
set(INSTALL_FLAGS --install)
message(STATUS "Installing in geode/mods after build")
message(STATUS "Installing ${proname} in geode/mods after build")
endif()
endif()
add_custom_command(

View file

@ -105,7 +105,7 @@ class AppDelegate : cocos2d::CCApplication {
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 void trySaveGame() = mac 0x3aaf10, win 0x0, ios 0x0;
virtual void trySaveGame() = mac 0x3aaf10, win 0x3d5e0, ios 0x0;
virtual void willSwitchToScene(cocos2d::CCScene*) = mac 0x3aaf40, win 0x0, ios 0x0;
static AppDelegate* get() = mac 0x3aab10, win 0x0, ios 0x0;