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*);
public:
// TODO: impl pimpl
Result<> setup();
std::string getID() const;
std::string getName() const;
std::string getDeveloper() const;

View file

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

View file

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

View file

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