diff --git a/loader/include/Geode/loader/Mod.hpp b/loader/include/Geode/loader/Mod.hpp index 27f8eb44..bdc57981 100644 --- a/loader/include/Geode/loader/Mod.hpp +++ b/loader/include/Geode/loader/Mod.hpp @@ -85,14 +85,14 @@ namespace geode { ghc::filesystem::path getPackagePath() const; VersionInfo getVersion() const; bool isEnabled() const; - bool isLoaded() const; + [[deprecated("use isEnabled instead")]] bool isLoaded() const; bool supportsDisabling() const; - bool canDisable() const; - bool canEnable() const; + [[deprecated("always true")]] bool canDisable() const; + [[deprecated("always true")]] bool canEnable() const; bool needsEarlyLoad() const; - [[deprecated]] bool supportsUnloading() const; - [[deprecated("use wasSuccessfullyLoaded instead")]] bool wasSuccesfullyLoaded() const; - bool wasSuccessfullyLoaded() const; + [[deprecated("always false")]] bool supportsUnloading() const; + [[deprecated("use isEnabled instead")]] bool wasSuccesfullyLoaded() const; + [[deprecated("use isEnabled instead")]] bool wasSuccessfullyLoaded() const; [[deprecated("use getMetadata instead")]] ModInfo getModInfo() const; ModMetadata getMetadata() const; ghc::filesystem::path getTempDir() const; diff --git a/loader/src/hooks/LoadingLayer.cpp b/loader/src/hooks/LoadingLayer.cpp index 9307998c..b3a24bd0 100644 --- a/loader/src/hooks/LoadingLayer.cpp +++ b/loader/src/hooks/LoadingLayer.cpp @@ -16,7 +16,7 @@ struct CustomLoadingLayer : Modify { void updateLoadedModsLabel() { auto allMods = Loader::get()->getAllMods(); auto count = std::count_if(allMods.begin(), allMods.end(), [&](auto& item) { - return item->isLoaded(); + return item->isEnabled(); }); auto str = fmt::format("Geode: Loaded {}/{} mods", count, allMods.size()); m_fields->m_loadedModsLabel->setCString(str.c_str()); diff --git a/loader/src/internal/crashlog.cpp b/loader/src/internal/crashlog.cpp index ec1cc514..7f698616 100644 --- a/loader/src/internal/crashlog.cpp +++ b/loader/src/internal/crashlog.cpp @@ -30,7 +30,7 @@ static void printMods(std::stringstream& stream) { using namespace std::string_view_literals; for (auto& mod : mods) { stream << fmt::format("{} | [{}] {}\n", - mod->isLoaded() ? "x"sv : " "sv, + mod->isEnabled() ? "x"sv : " "sv, mod->getVersion().toString(), mod->getID() ); } diff --git a/loader/src/loader/LoaderImpl.cpp b/loader/src/loader/LoaderImpl.cpp index a02a5b03..197676f5 100644 --- a/loader/src/loader/LoaderImpl.cpp +++ b/loader/src/loader/LoaderImpl.cpp @@ -201,13 +201,13 @@ Mod* Loader::Impl::getInstalledMod(std::string const& id) const { } bool Loader::Impl::isModLoaded(std::string const& id) const { - return m_mods.count(id) && m_mods.at(id)->isLoaded(); + return m_mods.count(id) && m_mods.at(id)->isEnabled(); } Mod* Loader::Impl::getLoadedMod(std::string const& id) const { if (m_mods.count(id)) { auto mod = m_mods.at(id); - if (mod->isLoaded()) { + if (mod->isEnabled()) { return mod; } } @@ -400,7 +400,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) { log::debug("{} {}", node->getID(), node->getVersion()); log::pushNest(); - if (node->isLoaded()) { + if (node->isEnabled()) { for (auto const& dep : node->m_impl->m_dependants) { this->loadModGraph(dep, early); } @@ -436,7 +436,7 @@ void Loader::Impl::findProblems() { log::pushNest(); for (auto const& dep : mod->getMetadata().getDependencies()) { - if (dep.mod && dep.mod->isLoaded() && dep.version.compare(dep.mod->getVersion())) + if (dep.mod && dep.mod->isEnabled() && dep.version.compare(dep.mod->getVersion())) continue; switch(dep.importance) { case ModMetadata::Dependency::Importance::Suggested: @@ -491,7 +491,7 @@ void Loader::Impl::findProblems() { Mod* myEpicMod = mod; // clang fix // if the mod is not loaded but there are no problems related to it - if (!mod->isLoaded() && + if (!mod->isEnabled() && Mod::get()->getSavedValue("should-load-" + mod->getID(), true) && !std::any_of(m_problems.begin(), m_problems.end(), [myEpicMod](auto& item) { return std::holds_alternative(item.cause) && diff --git a/loader/src/loader/Mod.cpp b/loader/src/loader/Mod.cpp index 392d91c4..9eead765 100644 --- a/loader/src/loader/Mod.cpp +++ b/loader/src/loader/Mod.cpp @@ -47,7 +47,7 @@ bool Mod::isEnabled() const { } bool Mod::isLoaded() const { - return m_impl->isLoaded(); + return this->isEnabled(); } bool Mod::supportsDisabling() const { @@ -55,11 +55,11 @@ bool Mod::supportsDisabling() const { } bool Mod::canDisable() const { - return m_impl->canDisable(); + return true; } bool Mod::canEnable() const { - return m_impl->canEnable(); + return true; } bool Mod::needsEarlyLoad() const { @@ -71,10 +71,10 @@ bool Mod::supportsUnloading() const { } bool Mod::wasSuccesfullyLoaded() const { - return this->wasSuccessfullyLoaded(); + return this->isEnabled(); } bool Mod::wasSuccessfullyLoaded() const { - return m_impl->wasSuccessfullyLoaded(); + return this->isEnabled(); } ModInfo Mod::getModInfo() const { diff --git a/loader/src/loader/ModImpl.cpp b/loader/src/loader/ModImpl.cpp index e25d4c37..dcb8e662 100644 --- a/loader/src/loader/ModImpl.cpp +++ b/loader/src/loader/ModImpl.cpp @@ -113,22 +113,10 @@ bool Mod::Impl::isEnabled() const { return m_enabled; } -bool Mod::Impl::isLoaded() const { - return m_binaryLoaded; -} - bool Mod::Impl::supportsDisabling() const { return m_metadata.getID() != "geode.loader"; } -bool Mod::Impl::canDisable() const { - return true; -} - -bool Mod::Impl::canEnable() const { - return true; -} - bool Mod::Impl::needsEarlyLoad() const { auto deps = m_dependants; return getMetadata().needsEarlyLoad() || @@ -137,10 +125,6 @@ bool Mod::Impl::needsEarlyLoad() const { }); } -bool Mod::Impl::wasSuccessfullyLoaded() const { - return !this->isEnabled() || this->isLoaded(); -} - std::vector Mod::Impl::getHooks() const { return m_hooks; } @@ -322,7 +306,7 @@ bool Mod::Impl::hasSetting(std::string const& key) const { Result<> Mod::Impl::loadBinary() { log::debug("Loading binary for mod {}", m_metadata.getID()); - if (m_binaryLoaded) + if (m_enabled) return Ok(); LoaderImpl::get()->provideNextMod(m_self); @@ -334,7 +318,6 @@ Result<> Mod::Impl::loadBinary() { log::error("Failed to load binary for mod {}: {}", m_metadata.getID(), res.unwrapErr()); return res; } - m_binaryLoaded = true; LoaderImpl::get()->releaseNextMod(); @@ -613,8 +596,9 @@ ModJson Mod::Impl::getRuntimeInfo() const { for (auto patch : m_patches) { obj["patches"].as_array().push_back(ModJson(patch->getRuntimeInfo())); } + // TODO: so which one is it // obj["enabled"] = m_enabled; - obj["loaded"] = m_binaryLoaded; + obj["loaded"] = m_enabled; obj["temp-dir"] = this->getTempDir(); obj["save-dir"] = this->getSaveDir(); obj["config-dir"] = this->getConfigDir(false); @@ -653,7 +637,6 @@ Mod* Loader::Impl::createInternalMod() { else { mod = new Mod(infoRes.unwrap()); } - mod->m_impl->m_binaryLoaded = true; mod->m_impl->m_enabled = true; m_mods.insert({ mod->getID(), mod }); return mod; diff --git a/loader/src/loader/ModImpl.hpp b/loader/src/loader/ModImpl.hpp index 9048036d..7e983d09 100644 --- a/loader/src/loader/ModImpl.hpp +++ b/loader/src/loader/ModImpl.hpp @@ -26,10 +26,6 @@ namespace geode { * Whether the mod is enabled or not */ bool m_enabled = false; - /** - * Whether the mod binary is loaded or not - */ - bool m_binaryLoaded = false; /** * Mod temp directory name */ @@ -62,7 +58,6 @@ namespace geode { */ bool m_resourcesLoaded = false; - ModRequestedAction m_requestedAction = ModRequestedAction::None; Impl(Mod* self, ModMetadata const& metadata); @@ -84,12 +79,8 @@ namespace geode { ghc::filesystem::path getPackagePath() const; VersionInfo getVersion() const; bool isEnabled() const; - bool isLoaded() const; bool supportsDisabling() const; - bool canDisable() const; - bool canEnable() const; bool needsEarlyLoad() const; - bool wasSuccessfullyLoaded() const; ModMetadata getMetadata() const; ghc::filesystem::path getTempDir() const; ghc::filesystem::path getBinaryPath() const; diff --git a/loader/src/loader/ModInfoImpl.cpp b/loader/src/loader/ModInfoImpl.cpp index c482b7b6..f10f6f8c 100644 --- a/loader/src/loader/ModInfoImpl.cpp +++ b/loader/src/loader/ModInfoImpl.cpp @@ -15,7 +15,7 @@ ModInfo::Impl& ModInfoImpl::getImpl(ModInfo& info) { bool Dependency::isResolved() const { return !this->required || - (this->mod && this->mod->isLoaded() && this->mod->isEnabled() && + (this->mod && this->mod->isEnabled() && this->version.compare(this->mod->getVersion())); } diff --git a/loader/src/loader/ModMetadataImpl.cpp b/loader/src/loader/ModMetadataImpl.cpp index 884ace85..0265f8af 100644 --- a/loader/src/loader/ModMetadataImpl.cpp +++ b/loader/src/loader/ModMetadataImpl.cpp @@ -18,7 +18,7 @@ ModMetadata::Impl& ModMetadataImpl::getImpl(ModMetadata& info) { bool ModMetadata::Dependency::isResolved() const { return this->importance != Importance::Required || - this->mod && this->mod->isLoaded() && this->version.compare(this->mod->getVersion()); + this->mod && this->mod->isEnabled() && this->version.compare(this->mod->getVersion()); } bool ModMetadata::Incompatibility::isResolved() const { diff --git a/loader/src/platform/mac/crashlog.mm b/loader/src/platform/mac/crashlog.mm index 1c7704f8..7a104e86 100644 --- a/loader/src/platform/mac/crashlog.mm +++ b/loader/src/platform/mac/crashlog.mm @@ -151,7 +151,7 @@ static Mod* modFromAddress(void const* addr) { } for (auto& mod : Loader::get()->getAllMods()) { - if (!mod->isLoaded() || !ghc::filesystem::exists(mod->getBinaryPath())) { + if (!mod->isEnabled() || !ghc::filesystem::exists(mod->getBinaryPath())) { continue; } if (ghc::filesystem::equivalent(imagePath, mod->getBinaryPath())) { diff --git a/loader/src/ui/internal/list/ModListCell.cpp b/loader/src/ui/internal/list/ModListCell.cpp index 3c9c199d..bb855607 100644 --- a/loader/src/ui/internal/list/ModListCell.cpp +++ b/loader/src/ui/internal/list/ModListCell.cpp @@ -291,7 +291,7 @@ bool ModCell::init( auto viewBtn = CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ModCell::onInfo)); m_menu->addChild(viewBtn); - if (m_mod->wasSuccessfullyLoaded()) { + if (m_mod->isEnabled()) { auto latestIndexItem = Index::get()->getMajorItem( mod->getMetadata().getID() ); @@ -314,7 +314,7 @@ bool ModCell::init( } } - if (m_mod->wasSuccessfullyLoaded() && m_mod->getMetadata().getID() != "geode.loader") { + if (m_mod->getMetadata().getID() != "geode.loader") { m_enableToggle = CCMenuItemToggler::createWithStandardSprites(this, menu_selector(ModCell::onEnable), .7f); m_enableToggle->setPosition(-45.f, 0.f); @@ -322,8 +322,6 @@ bool ModCell::init( } } - - auto exMark = CCSprite::createWithSpriteFrameName("exMark_001.png"); exMark->setScale(.5f);