mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-22 15:37:53 -05:00
seperate setup of mod
This commit is contained in:
parent
1de4fd93f7
commit
643abe64ab
4 changed files with 10 additions and 0 deletions
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue