seperate setup of mod

This commit is contained in:
altalk23 2022-12-14 09:47:09 +03:00
parent 1de4fd93f7
commit 643abe64ab
4 changed files with 10 additions and 0 deletions

View file

@ -129,6 +129,9 @@ namespace geode {
friend void GEODE_CALL ::geode_implicit_load(Mod*); friend void GEODE_CALL ::geode_implicit_load(Mod*);
public: public:
// TODO: impl pimpl
Result<> setup();
std::string getID() const; std::string getID() const;
std::string getName() const; std::string getName() const;
std::string getDeveloper() const; std::string getDeveloper() const;

View file

@ -54,5 +54,6 @@ InternalMod::~InternalMod() {}
InternalMod* InternalMod::get() { InternalMod* InternalMod::get() {
static auto g_mod = new InternalMod; static auto g_mod = new InternalMod;
g_mod->setup();
return g_mod; return g_mod;
} }

View file

@ -190,6 +190,8 @@ Result<Mod*> Loader::Impl::loadModFromInfo(ModInfo const& info) {
// create Mod instance // create Mod instance
auto mod = new Mod(info); auto mod = new Mod(info);
mod->setup();
m_mods.insert({ info.id, mod }); m_mods.insert({ info.id, mod });
mod->m_enabled = InternalMod::get()->getSavedValue<bool>( mod->m_enabled = InternalMod::get()->getSavedValue<bool>(
"should-load-" + info.id, true "should-load-" + info.id, true

View file

@ -17,6 +17,9 @@ Mod::Mod(ModInfo const& info) {
m_info = info; m_info = info;
m_saveDirPath = dirs::getModsSaveDir() / info.id; m_saveDirPath = dirs::getModsSaveDir() / info.id;
ghc::filesystem::create_directories(m_saveDirPath); ghc::filesystem::create_directories(m_saveDirPath);
}
Result<> Mod::setup() {
this->setupSettings(); this->setupSettings();
auto loadRes = this->loadData(); auto loadRes = this->loadData();
if (!loadRes) { if (!loadRes) {
@ -25,6 +28,7 @@ Mod::Mod(ModInfo const& info) {
info.id, loadRes.unwrapErr() info.id, loadRes.unwrapErr()
); );
} }
return Ok();
} }
Mod::~Mod() { Mod::~Mod() {