Skip to content

Commit

Permalink
make all mods including disables ones be unzipped
Browse files Browse the repository at this point in the history
this makes it so disabled mods' resources are loaded
  • Loading branch information
HJfod committed Aug 2, 2023
1 parent e68d5f4 commit 0a6d31e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions loader/src/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int geodeEntry(void* platformData) {
if (!internalSetupRes) {
LoaderImpl::get()->platformMessageBox(
"Unable to Load Geode!",
"There was an unknown fatal error setting up "
"the internal mod and Geode can not be loaded." + internalSetupRes.unwrapErr()
"There was a fatal error setting up "
"the internal mod and Geode can not be loaded: " + internalSetupRes.unwrapErr()
);
LoaderImpl::get()->reset();
return 1;
Expand Down
17 changes: 12 additions & 5 deletions loader/src/loader/ModImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ Result<> Mod::Impl::setup() {
m_saveDirPath = dirs::getModsSaveDir() / m_info.id();
ghc::filesystem::create_directories(m_saveDirPath);

// always create temp dir for all mods, even if disabled, so resources can be loaded
GEODE_UNWRAP(this->createTempDir().expect("Unable to create temp dir: {error}"));

this->setupSettings();
auto loadRes = this->loadData();
if (!loadRes) {
log::warn("Unable to load data for \"{}\": {}", m_info.id(), loadRes.unwrapErr());
}
if (LoaderImpl::get()->m_isSetup) {
Loader::get()->updateResources(false);
}

return Ok();
}

Expand Down Expand Up @@ -299,8 +306,6 @@ Result<> Mod::Impl::loadBinary() {
return Ok();
}

GEODE_UNWRAP(this->createTempDir());

if (this->hasUnresolvedDependencies()) {
return Err("Mod has unresolved dependencies");
}
Expand All @@ -323,9 +328,6 @@ Result<> Mod::Impl::loadBinary() {
});

Loader::get()->updateAllDependencies();
if (LoaderImpl::get()->m_isSetup) {
Loader::get()->updateResources(false);
}

log::debug("Enabling mod {}", m_info.id());
GEODE_UNWRAP(this->enable());
Expand Down Expand Up @@ -605,6 +607,11 @@ Result<> Mod::Impl::createTempDir() {
return Ok();
}

// If the info doesn't specify a path, don't do anything
if (m_info.path().string().empty()) {
return Ok();
}

// Create geode/temp
auto tempDir = dirs::getModRuntimeDir();
if (!file::createDirectoryAll(tempDir)) {
Expand Down

0 comments on commit 0a6d31e

Please sign in to comment.