split problems into load problems and outdated GD version

This commit is contained in:
HJfod 2024-11-10 12:55:56 +02:00
parent c9afa75367
commit 12e8bbb6a2
13 changed files with 65 additions and 25 deletions

View file

@ -91,7 +91,8 @@ namespace geode {
Mod* getLoadedMod(std::string const& id) const; Mod* getLoadedMod(std::string const& id) const;
std::vector<Mod*> getAllMods(); std::vector<Mod*> getAllMods();
std::vector<LoadProblem> getAllProblems() const; std::vector<LoadProblem> getAllProblems() const;
std::vector<LoadProblem> getProblems() const; std::vector<LoadProblem> getLoadProblems() const;
std::vector<LoadProblem> getOutdated() const;
std::vector<LoadProblem> getRecommendations() const; std::vector<LoadProblem> getRecommendations() const;
/** /**

View file

@ -446,7 +446,8 @@ namespace geode {
bool isLoggingEnabled() const; bool isLoggingEnabled() const;
void setLoggingEnabled(bool enabled); void setLoggingEnabled(bool enabled);
bool hasProblems() const; bool targetsOutdatedGDVersion() const;
bool hasLoadProblems() const;
std::vector<LoadProblem> getAllProblems() const; std::vector<LoadProblem> getAllProblems() const;
std::vector<LoadProblem> getProblems() const; std::vector<LoadProblem> getProblems() const;
std::vector<LoadProblem> getRecommendations() const; std::vector<LoadProblem> getRecommendations() const;

View file

@ -83,13 +83,12 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
} }
// show if some mods failed to load // show if some mods failed to load
if (Loader::get()->getProblems().size()) { if (Loader::get()->getLoadProblems().size()) {
static bool shownProblemPopup = false; static bool shownProblemPopup = false;
if (!shownProblemPopup) { if (!shownProblemPopup) {
shownProblemPopup = true; shownProblemPopup = true;
Notification::create("There were errors - see Geode page!", NotificationIcon::Error)->show(); Notification::create("There were errors - see Geode page!", NotificationIcon::Error)->show();
} }
if (m_fields->m_geodeButton) { if (m_fields->m_geodeButton) {
m_fields->m_exclamation = CCSprite::createWithSpriteFrameName("exMark_001.png"); m_fields->m_exclamation = CCSprite::createWithSpriteFrameName("exMark_001.png");
m_fields->m_exclamation->setPosition(m_fields->m_geodeButton->getContentSize() - ccp(10, 10)); m_fields->m_exclamation->setPosition(m_fields->m_geodeButton->getContentSize() - ccp(10, 10));

View file

@ -79,7 +79,7 @@ protected:
public: public:
void start() { void start() {
for (auto problem : Loader::get()->getProblems()) { for (auto problem : Loader::get()->getAllProblems()) {
switch (problem.type) { switch (problem.type) {
// Errors where the correct solution is to just delete the invalid .geode package // Errors where the correct solution is to just delete the invalid .geode package
case LoadProblem::Type::InvalidFile: case LoadProblem::Type::InvalidFile:

View file

@ -24,7 +24,8 @@ void crashlog::printGeodeInfo(std::stringstream& stream) {
<< "Loader Commit: " << about::getLoaderCommitHash() << "\n" << "Loader Commit: " << about::getLoaderCommitHash() << "\n"
<< "Bindings Commit: " << about::getBindingsCommitHash() << "\n" << "Bindings Commit: " << about::getBindingsCommitHash() << "\n"
<< "Installed mods: " << Loader::get()->getAllMods().size() << "\n" << "Installed mods: " << Loader::get()->getAllMods().size() << "\n"
<< "Problems: " << Loader::get()->getProblems().size() << "\n"; << "Outdated mods: " << Loader::get()->getOutdated().size() << "\n"
<< "Problems: " << Loader::get()->getLoadProblems().size() << "\n";
} }
void crashlog::printMods(std::stringstream& stream) { void crashlog::printMods(std::stringstream& stream) {
@ -44,7 +45,8 @@ void crashlog::printMods(std::stringstream& stream) {
stream << fmt::format("{} | [{}] {}\n", stream << fmt::format("{} | [{}] {}\n",
mod->isCurrentlyLoading() ? "o"sv : mod->isCurrentlyLoading() ? "o"sv :
mod->isEnabled() ? "x"sv : mod->isEnabled() ? "x"sv :
mod->hasProblems() ? "!"sv : // thank you for this bug report mod->hasLoadProblems() ? "!"sv : // thank you for this bug report
mod->targetsOutdatedGDVersion() ? "*"sv : // thank you very much for this bug report
mod->shouldLoad() ? "~"sv : mod->shouldLoad() ? "~"sv :
" "sv, " "sv,
mod->getVersion().toVString(), mod->getID() mod->getVersion().toVString(), mod->getID()

View file

@ -68,18 +68,28 @@ std::vector<Mod*> Loader::getAllMods() {
std::vector<LoadProblem> Loader::getAllProblems() const { std::vector<LoadProblem> Loader::getAllProblems() const {
return m_impl->getProblems(); return m_impl->getProblems();
} }
std::vector<LoadProblem> Loader::getProblems() const { std::vector<LoadProblem> Loader::getLoadProblems() const {
std::vector<LoadProblem> result; std::vector<LoadProblem> result;
for (auto problem : this->getAllProblems()) { for (auto problem : this->getAllProblems()) {
if ( if (
problem.type != LoadProblem::Type::Recommendation && problem.type != LoadProblem::Type::Recommendation &&
problem.type != LoadProblem::Type::Suggestion problem.type != LoadProblem::Type::Suggestion &&
problem.type != LoadProblem::Type::UnsupportedVersion
) { ) {
result.push_back(problem); result.push_back(problem);
} }
} }
return result; return result;
} }
std::vector<LoadProblem> Loader::getOutdated() const {
std::vector<LoadProblem> result;
for (auto problem : this->getAllProblems()) {
if (problem.type == LoadProblem::Type::UnsupportedVersion) {
result.push_back(problem);
}
}
return result;
}
std::vector<LoadProblem> Loader::getRecommendations() const { std::vector<LoadProblem> Loader::getRecommendations() const {
std::vector<LoadProblem> result; std::vector<LoadProblem> result;
for (auto problem : this->getAllProblems()) { for (auto problem : this->getAllProblems()) {

View file

@ -252,8 +252,16 @@ bool Mod::hasSavedValue(std::string_view const key) {
return this->getSaveContainer().contains(key); return this->getSaveContainer().contains(key);
} }
bool Mod::hasProblems() const { bool Mod::hasLoadProblems() const {
return m_impl->hasProblems(); return m_impl->hasLoadProblems();
}
bool Mod::targetsOutdatedGDVersion() const {
for (auto problem : this->getAllProblems()) {
if (problem.type == LoadProblem::Type::UnsupportedVersion) {
return true;
}
}
return false;
} }
std::vector<LoadProblem> Mod::getAllProblems() const { std::vector<LoadProblem> Mod::getAllProblems() const {
return m_impl->getProblems(); return m_impl->getProblems();
@ -263,7 +271,8 @@ std::vector<LoadProblem> Mod::getProblems() const {
for (auto problem : this->getAllProblems()) { for (auto problem : this->getAllProblems()) {
if ( if (
problem.type != LoadProblem::Type::Recommendation && problem.type != LoadProblem::Type::Recommendation &&
problem.type != LoadProblem::Type::Suggestion problem.type != LoadProblem::Type::Suggestion &&
problem.type != LoadProblem::Type::UnsupportedVersion
) { ) {
result.push_back(problem); result.push_back(problem);
} }

View file

@ -708,11 +708,15 @@ bool Mod::Impl::isCurrentlyLoading() const {
return m_isCurrentlyLoading; return m_isCurrentlyLoading;
} }
bool Mod::Impl::hasProblems() const { bool Mod::Impl::hasLoadProblems() const {
for (auto const& item : m_problems) { for (auto const& problem : m_problems) {
if (item.type <= LoadProblem::Type::Recommendation) if (
continue; problem.type != LoadProblem::Type::Recommendation &&
return true; problem.type != LoadProblem::Type::Suggestion &&
problem.type != LoadProblem::Type::UnsupportedVersion
) {
return true;
}
} }
return false; return false;
} }

View file

@ -151,7 +151,7 @@ namespace geode {
std::vector<LoadProblem> getProblems() const; std::vector<LoadProblem> getProblems() const;
bool hasProblems() const; bool hasLoadProblems() const;
bool shouldLoad() const; bool shouldLoad() const;
bool isCurrentlyLoading() const; bool isCurrentlyLoading() const;
}; };

View file

@ -185,7 +185,7 @@ bool ModItem::init(ModSource&& source) {
m_viewMenu->addChild(m_enableToggle); m_viewMenu->addChild(m_enableToggle);
m_viewMenu->updateLayout(); m_viewMenu->updateLayout();
} }
if (mod->hasProblems()) { if (mod->hasLoadProblems() || mod->targetsOutdatedGDVersion()) {
auto viewErrorSpr = createGeodeCircleButton( auto viewErrorSpr = createGeodeCircleButton(
CCSprite::createWithSpriteFrameName("exclamation.png"_spr), 1.f, CCSprite::createWithSpriteFrameName("exclamation.png"_spr), 1.f,
CircleBaseSize::Small CircleBaseSize::Small
@ -410,9 +410,14 @@ void ModItem::updateState() {
m_titleContainer->updateLayout(); m_titleContainer->updateLayout();
// If there were problems, tint the BG red // If there were problems, tint the BG red
if (m_source.asMod() && m_source.asMod()->hasProblems()) { if (m_source.asMod()) {
m_bg->setColor("mod-list-errors-found"_cc3b); if (m_source.asMod()->hasLoadProblems()) {
m_bg->setOpacity(isGeodeTheme() ? 25 : 90); m_bg->setColor("mod-list-errors-found"_cc3b);
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
}
if (m_source.asMod()->targetsOutdatedGDVersion()) {
m_bg->setOpacity(isGeodeTheme() ? 0 : 0);
}
} }
// Highlight item via BG if it wants to restart for extra UI attention // Highlight item via BG if it wants to restart for extra UI attention

View file

@ -111,7 +111,7 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
m_topContainer->addChild(m_updateAllContainer); m_topContainer->addChild(m_updateAllContainer);
if (Loader::get()->getProblems().size()) { if (Loader::get()->getLoadProblems().size()) {
m_errorsContainer = CCNode::create(); m_errorsContainer = CCNode::create();
m_errorsContainer->setID("errors-container"); m_errorsContainer->setID("errors-container");
m_errorsContainer->ignoreAnchorPointForPosition(false); m_errorsContainer->ignoreAnchorPointForPosition(false);
@ -549,7 +549,7 @@ void ModList::updateTopContainer() {
// If there are errors, show the error banner // If there are errors, show the error banner
if (m_errorsContainer) { if (m_errorsContainer) {
auto noErrors = Loader::get()->getProblems().empty(); auto noErrors = Loader::get()->getLoadProblems().empty();
m_errorsContainer->setVisible(!noErrors); m_errorsContainer->setVisible(!noErrors);
} }

View file

@ -12,8 +12,11 @@ bool InstalledModsQuery::preCheck(ModSource const& src) const {
return false; return false;
} }
// If only errors requested, only show mods with errors (duh) // If only errors requested, only show mods with errors (duh)
if (type == InstalledModListType::OnlyOutdated) {
return src.asMod()->targetsOutdatedGDVersion();
}
if (type == InstalledModListType::OnlyErrors) { if (type == InstalledModListType::OnlyErrors) {
return src.asMod()->hasProblems(); return src.asMod()->hasLoadProblems();
} }
return true; return true;
} }
@ -59,6 +62,11 @@ InstalledModListSource* InstalledModListSource::get(InstalledModListType type) {
static auto inst = new InstalledModListSource(InstalledModListType::OnlyErrors); static auto inst = new InstalledModListSource(InstalledModListType::OnlyErrors);
return inst; return inst;
} break; } break;
case InstalledModListType::OnlyOutdated: {
static auto inst = new InstalledModListSource(InstalledModListType::OnlyOutdated);
return inst;
} break;
} }
} }

View file

@ -110,6 +110,7 @@ enum class InstalledModListType {
All, All,
OnlyUpdates, OnlyUpdates,
OnlyErrors, OnlyErrors,
OnlyOutdated,
}; };
struct InstalledModsQuery final : public LocalModsQueryBase { struct InstalledModsQuery final : public LocalModsQueryBase {
InstalledModListType type = InstalledModListType::All; InstalledModListType type = InstalledModListType::All;