mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-18 09:10:17 -05:00
deprecate Mod::isLoaded
This commit is contained in:
parent
5b7d3183bb
commit
ae048e48a9
11 changed files with 26 additions and 54 deletions
|
@ -85,14 +85,14 @@ namespace geode {
|
||||||
ghc::filesystem::path getPackagePath() const;
|
ghc::filesystem::path getPackagePath() const;
|
||||||
VersionInfo getVersion() const;
|
VersionInfo getVersion() const;
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
bool isLoaded() const;
|
[[deprecated("use isEnabled instead")]] bool isLoaded() const;
|
||||||
bool supportsDisabling() const;
|
bool supportsDisabling() const;
|
||||||
bool canDisable() const;
|
[[deprecated("always true")]] bool canDisable() const;
|
||||||
bool canEnable() const;
|
[[deprecated("always true")]] bool canEnable() const;
|
||||||
bool needsEarlyLoad() const;
|
bool needsEarlyLoad() const;
|
||||||
[[deprecated]] bool supportsUnloading() const;
|
[[deprecated("always false")]] bool supportsUnloading() const;
|
||||||
[[deprecated("use wasSuccessfullyLoaded instead")]] bool wasSuccesfullyLoaded() const;
|
[[deprecated("use isEnabled instead")]] bool wasSuccesfullyLoaded() const;
|
||||||
bool wasSuccessfullyLoaded() const;
|
[[deprecated("use isEnabled instead")]] bool wasSuccessfullyLoaded() const;
|
||||||
[[deprecated("use getMetadata instead")]] ModInfo getModInfo() const;
|
[[deprecated("use getMetadata instead")]] ModInfo getModInfo() const;
|
||||||
ModMetadata getMetadata() const;
|
ModMetadata getMetadata() const;
|
||||||
ghc::filesystem::path getTempDir() const;
|
ghc::filesystem::path getTempDir() const;
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct CustomLoadingLayer : Modify<CustomLoadingLayer, LoadingLayer> {
|
||||||
void updateLoadedModsLabel() {
|
void updateLoadedModsLabel() {
|
||||||
auto allMods = Loader::get()->getAllMods();
|
auto allMods = Loader::get()->getAllMods();
|
||||||
auto count = std::count_if(allMods.begin(), allMods.end(), [&](auto& item) {
|
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());
|
auto str = fmt::format("Geode: Loaded {}/{} mods", count, allMods.size());
|
||||||
m_fields->m_loadedModsLabel->setCString(str.c_str());
|
m_fields->m_loadedModsLabel->setCString(str.c_str());
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void printMods(std::stringstream& stream) {
|
||||||
using namespace std::string_view_literals;
|
using namespace std::string_view_literals;
|
||||||
for (auto& mod : mods) {
|
for (auto& mod : mods) {
|
||||||
stream << fmt::format("{} | [{}] {}\n",
|
stream << fmt::format("{} | [{}] {}\n",
|
||||||
mod->isLoaded() ? "x"sv : " "sv,
|
mod->isEnabled() ? "x"sv : " "sv,
|
||||||
mod->getVersion().toString(), mod->getID()
|
mod->getVersion().toString(), mod->getID()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,13 +201,13 @@ Mod* Loader::Impl::getInstalledMod(std::string const& id) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Loader::Impl::isModLoaded(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 {
|
Mod* Loader::Impl::getLoadedMod(std::string const& id) const {
|
||||||
if (m_mods.count(id)) {
|
if (m_mods.count(id)) {
|
||||||
auto mod = m_mods.at(id);
|
auto mod = m_mods.at(id);
|
||||||
if (mod->isLoaded()) {
|
if (mod->isEnabled()) {
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
|
||||||
log::debug("{} {}", node->getID(), node->getVersion());
|
log::debug("{} {}", node->getID(), node->getVersion());
|
||||||
log::pushNest();
|
log::pushNest();
|
||||||
|
|
||||||
if (node->isLoaded()) {
|
if (node->isEnabled()) {
|
||||||
for (auto const& dep : node->m_impl->m_dependants) {
|
for (auto const& dep : node->m_impl->m_dependants) {
|
||||||
this->loadModGraph(dep, early);
|
this->loadModGraph(dep, early);
|
||||||
}
|
}
|
||||||
|
@ -436,7 +436,7 @@ void Loader::Impl::findProblems() {
|
||||||
log::pushNest();
|
log::pushNest();
|
||||||
|
|
||||||
for (auto const& dep : mod->getMetadata().getDependencies()) {
|
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;
|
continue;
|
||||||
switch(dep.importance) {
|
switch(dep.importance) {
|
||||||
case ModMetadata::Dependency::Importance::Suggested:
|
case ModMetadata::Dependency::Importance::Suggested:
|
||||||
|
@ -491,7 +491,7 @@ void Loader::Impl::findProblems() {
|
||||||
|
|
||||||
Mod* myEpicMod = mod; // clang fix
|
Mod* myEpicMod = mod; // clang fix
|
||||||
// if the mod is not loaded but there are no problems related to it
|
// if the mod is not loaded but there are no problems related to it
|
||||||
if (!mod->isLoaded() &&
|
if (!mod->isEnabled() &&
|
||||||
Mod::get()->getSavedValue<bool>("should-load-" + mod->getID(), true) &&
|
Mod::get()->getSavedValue<bool>("should-load-" + mod->getID(), true) &&
|
||||||
!std::any_of(m_problems.begin(), m_problems.end(), [myEpicMod](auto& item) {
|
!std::any_of(m_problems.begin(), m_problems.end(), [myEpicMod](auto& item) {
|
||||||
return std::holds_alternative<ModMetadata>(item.cause) &&
|
return std::holds_alternative<ModMetadata>(item.cause) &&
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool Mod::isEnabled() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::isLoaded() const {
|
bool Mod::isLoaded() const {
|
||||||
return m_impl->isLoaded();
|
return this->isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::supportsDisabling() const {
|
bool Mod::supportsDisabling() const {
|
||||||
|
@ -55,11 +55,11 @@ bool Mod::supportsDisabling() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::canDisable() const {
|
bool Mod::canDisable() const {
|
||||||
return m_impl->canDisable();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::canEnable() const {
|
bool Mod::canEnable() const {
|
||||||
return m_impl->canEnable();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::needsEarlyLoad() const {
|
bool Mod::needsEarlyLoad() const {
|
||||||
|
@ -71,10 +71,10 @@ bool Mod::supportsUnloading() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::wasSuccesfullyLoaded() const {
|
bool Mod::wasSuccesfullyLoaded() const {
|
||||||
return this->wasSuccessfullyLoaded();
|
return this->isEnabled();
|
||||||
}
|
}
|
||||||
bool Mod::wasSuccessfullyLoaded() const {
|
bool Mod::wasSuccessfullyLoaded() const {
|
||||||
return m_impl->wasSuccessfullyLoaded();
|
return this->isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
ModInfo Mod::getModInfo() const {
|
ModInfo Mod::getModInfo() const {
|
||||||
|
|
|
@ -113,22 +113,10 @@ bool Mod::Impl::isEnabled() const {
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::Impl::isLoaded() const {
|
|
||||||
return m_binaryLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Mod::Impl::supportsDisabling() const {
|
bool Mod::Impl::supportsDisabling() const {
|
||||||
return m_metadata.getID() != "geode.loader";
|
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 {
|
bool Mod::Impl::needsEarlyLoad() const {
|
||||||
auto deps = m_dependants;
|
auto deps = m_dependants;
|
||||||
return getMetadata().needsEarlyLoad() ||
|
return getMetadata().needsEarlyLoad() ||
|
||||||
|
@ -137,10 +125,6 @@ bool Mod::Impl::needsEarlyLoad() const {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Mod::Impl::wasSuccessfullyLoaded() const {
|
|
||||||
return !this->isEnabled() || this->isLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Hook*> Mod::Impl::getHooks() const {
|
std::vector<Hook*> Mod::Impl::getHooks() const {
|
||||||
return m_hooks;
|
return m_hooks;
|
||||||
}
|
}
|
||||||
|
@ -322,7 +306,7 @@ bool Mod::Impl::hasSetting(std::string const& key) const {
|
||||||
|
|
||||||
Result<> Mod::Impl::loadBinary() {
|
Result<> Mod::Impl::loadBinary() {
|
||||||
log::debug("Loading binary for mod {}", m_metadata.getID());
|
log::debug("Loading binary for mod {}", m_metadata.getID());
|
||||||
if (m_binaryLoaded)
|
if (m_enabled)
|
||||||
return Ok();
|
return Ok();
|
||||||
|
|
||||||
LoaderImpl::get()->provideNextMod(m_self);
|
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());
|
log::error("Failed to load binary for mod {}: {}", m_metadata.getID(), res.unwrapErr());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
m_binaryLoaded = true;
|
|
||||||
|
|
||||||
LoaderImpl::get()->releaseNextMod();
|
LoaderImpl::get()->releaseNextMod();
|
||||||
|
|
||||||
|
@ -613,8 +596,9 @@ ModJson Mod::Impl::getRuntimeInfo() const {
|
||||||
for (auto patch : m_patches) {
|
for (auto patch : m_patches) {
|
||||||
obj["patches"].as_array().push_back(ModJson(patch->getRuntimeInfo()));
|
obj["patches"].as_array().push_back(ModJson(patch->getRuntimeInfo()));
|
||||||
}
|
}
|
||||||
|
// TODO: so which one is it
|
||||||
// obj["enabled"] = m_enabled;
|
// obj["enabled"] = m_enabled;
|
||||||
obj["loaded"] = m_binaryLoaded;
|
obj["loaded"] = m_enabled;
|
||||||
obj["temp-dir"] = this->getTempDir();
|
obj["temp-dir"] = this->getTempDir();
|
||||||
obj["save-dir"] = this->getSaveDir();
|
obj["save-dir"] = this->getSaveDir();
|
||||||
obj["config-dir"] = this->getConfigDir(false);
|
obj["config-dir"] = this->getConfigDir(false);
|
||||||
|
@ -653,7 +637,6 @@ Mod* Loader::Impl::createInternalMod() {
|
||||||
else {
|
else {
|
||||||
mod = new Mod(infoRes.unwrap());
|
mod = new Mod(infoRes.unwrap());
|
||||||
}
|
}
|
||||||
mod->m_impl->m_binaryLoaded = true;
|
|
||||||
mod->m_impl->m_enabled = true;
|
mod->m_impl->m_enabled = true;
|
||||||
m_mods.insert({ mod->getID(), mod });
|
m_mods.insert({ mod->getID(), mod });
|
||||||
return mod;
|
return mod;
|
||||||
|
|
|
@ -26,10 +26,6 @@ namespace geode {
|
||||||
* Whether the mod is enabled or not
|
* Whether the mod is enabled or not
|
||||||
*/
|
*/
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
/**
|
|
||||||
* Whether the mod binary is loaded or not
|
|
||||||
*/
|
|
||||||
bool m_binaryLoaded = false;
|
|
||||||
/**
|
/**
|
||||||
* Mod temp directory name
|
* Mod temp directory name
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +58,6 @@ namespace geode {
|
||||||
*/
|
*/
|
||||||
bool m_resourcesLoaded = false;
|
bool m_resourcesLoaded = false;
|
||||||
|
|
||||||
|
|
||||||
ModRequestedAction m_requestedAction = ModRequestedAction::None;
|
ModRequestedAction m_requestedAction = ModRequestedAction::None;
|
||||||
|
|
||||||
Impl(Mod* self, ModMetadata const& metadata);
|
Impl(Mod* self, ModMetadata const& metadata);
|
||||||
|
@ -84,12 +79,8 @@ namespace geode {
|
||||||
ghc::filesystem::path getPackagePath() const;
|
ghc::filesystem::path getPackagePath() const;
|
||||||
VersionInfo getVersion() const;
|
VersionInfo getVersion() const;
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
bool isLoaded() const;
|
|
||||||
bool supportsDisabling() const;
|
bool supportsDisabling() const;
|
||||||
bool canDisable() const;
|
|
||||||
bool canEnable() const;
|
|
||||||
bool needsEarlyLoad() const;
|
bool needsEarlyLoad() const;
|
||||||
bool wasSuccessfullyLoaded() const;
|
|
||||||
ModMetadata getMetadata() const;
|
ModMetadata getMetadata() const;
|
||||||
ghc::filesystem::path getTempDir() const;
|
ghc::filesystem::path getTempDir() const;
|
||||||
ghc::filesystem::path getBinaryPath() const;
|
ghc::filesystem::path getBinaryPath() const;
|
||||||
|
|
|
@ -15,7 +15,7 @@ ModInfo::Impl& ModInfoImpl::getImpl(ModInfo& info) {
|
||||||
|
|
||||||
bool Dependency::isResolved() const {
|
bool Dependency::isResolved() const {
|
||||||
return !this->required ||
|
return !this->required ||
|
||||||
(this->mod && this->mod->isLoaded() && this->mod->isEnabled() &&
|
(this->mod && this->mod->isEnabled() &&
|
||||||
this->version.compare(this->mod->getVersion()));
|
this->version.compare(this->mod->getVersion()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ ModMetadata::Impl& ModMetadataImpl::getImpl(ModMetadata& info) {
|
||||||
|
|
||||||
bool ModMetadata::Dependency::isResolved() const {
|
bool ModMetadata::Dependency::isResolved() const {
|
||||||
return this->importance != Importance::Required ||
|
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 {
|
bool ModMetadata::Incompatibility::isResolved() const {
|
||||||
|
|
|
@ -151,7 +151,7 @@ static Mod* modFromAddress(void const* addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& mod : Loader::get()->getAllMods()) {
|
for (auto& mod : Loader::get()->getAllMods()) {
|
||||||
if (!mod->isLoaded() || !ghc::filesystem::exists(mod->getBinaryPath())) {
|
if (!mod->isEnabled() || !ghc::filesystem::exists(mod->getBinaryPath())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ghc::filesystem::equivalent(imagePath, mod->getBinaryPath())) {
|
if (ghc::filesystem::equivalent(imagePath, mod->getBinaryPath())) {
|
||||||
|
|
|
@ -291,7 +291,7 @@ bool ModCell::init(
|
||||||
auto viewBtn = CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ModCell::onInfo));
|
auto viewBtn = CCMenuItemSpriteExtra::create(viewSpr, this, menu_selector(ModCell::onInfo));
|
||||||
m_menu->addChild(viewBtn);
|
m_menu->addChild(viewBtn);
|
||||||
|
|
||||||
if (m_mod->wasSuccessfullyLoaded()) {
|
if (m_mod->isEnabled()) {
|
||||||
auto latestIndexItem = Index::get()->getMajorItem(
|
auto latestIndexItem = Index::get()->getMajorItem(
|
||||||
mod->getMetadata().getID()
|
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 =
|
m_enableToggle =
|
||||||
CCMenuItemToggler::createWithStandardSprites(this, menu_selector(ModCell::onEnable), .7f);
|
CCMenuItemToggler::createWithStandardSprites(this, menu_selector(ModCell::onEnable), .7f);
|
||||||
m_enableToggle->setPosition(-45.f, 0.f);
|
m_enableToggle->setPosition(-45.f, 0.f);
|
||||||
|
@ -322,8 +322,6 @@ bool ModCell::init(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
auto exMark = CCSprite::createWithSpriteFrameName("exMark_001.png");
|
auto exMark = CCSprite::createWithSpriteFrameName("exMark_001.png");
|
||||||
exMark->setScale(.5f);
|
exMark->setScale(.5f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue