mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-28 18:35:43 -05:00
split problems into load problems and outdated GD version
This commit is contained in:
parent
c9afa75367
commit
12e8bbb6a2
13 changed files with 65 additions and 25 deletions
|
@ -91,7 +91,8 @@ namespace geode {
|
|||
Mod* getLoadedMod(std::string const& id) const;
|
||||
std::vector<Mod*> getAllMods();
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -446,7 +446,8 @@ namespace geode {
|
|||
bool isLoggingEnabled() const;
|
||||
void setLoggingEnabled(bool enabled);
|
||||
|
||||
bool hasProblems() const;
|
||||
bool targetsOutdatedGDVersion() const;
|
||||
bool hasLoadProblems() const;
|
||||
std::vector<LoadProblem> getAllProblems() const;
|
||||
std::vector<LoadProblem> getProblems() const;
|
||||
std::vector<LoadProblem> getRecommendations() const;
|
||||
|
|
|
@ -83,13 +83,12 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
|
|||
}
|
||||
|
||||
// show if some mods failed to load
|
||||
if (Loader::get()->getProblems().size()) {
|
||||
if (Loader::get()->getLoadProblems().size()) {
|
||||
static bool shownProblemPopup = false;
|
||||
if (!shownProblemPopup) {
|
||||
shownProblemPopup = true;
|
||||
Notification::create("There were errors - see Geode page!", NotificationIcon::Error)->show();
|
||||
}
|
||||
|
||||
if (m_fields->m_geodeButton) {
|
||||
m_fields->m_exclamation = CCSprite::createWithSpriteFrameName("exMark_001.png");
|
||||
m_fields->m_exclamation->setPosition(m_fields->m_geodeButton->getContentSize() - ccp(10, 10));
|
||||
|
|
|
@ -79,7 +79,7 @@ protected:
|
|||
|
||||
public:
|
||||
void start() {
|
||||
for (auto problem : Loader::get()->getProblems()) {
|
||||
for (auto problem : Loader::get()->getAllProblems()) {
|
||||
switch (problem.type) {
|
||||
// Errors where the correct solution is to just delete the invalid .geode package
|
||||
case LoadProblem::Type::InvalidFile:
|
||||
|
|
|
@ -24,7 +24,8 @@ void crashlog::printGeodeInfo(std::stringstream& stream) {
|
|||
<< "Loader Commit: " << about::getLoaderCommitHash() << "\n"
|
||||
<< "Bindings Commit: " << about::getBindingsCommitHash() << "\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) {
|
||||
|
@ -44,7 +45,8 @@ void crashlog::printMods(std::stringstream& stream) {
|
|||
stream << fmt::format("{} | [{}] {}\n",
|
||||
mod->isCurrentlyLoading() ? "o"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 :
|
||||
" "sv,
|
||||
mod->getVersion().toVString(), mod->getID()
|
||||
|
|
|
@ -68,18 +68,28 @@ std::vector<Mod*> Loader::getAllMods() {
|
|||
std::vector<LoadProblem> Loader::getAllProblems() const {
|
||||
return m_impl->getProblems();
|
||||
}
|
||||
std::vector<LoadProblem> Loader::getProblems() const {
|
||||
std::vector<LoadProblem> Loader::getLoadProblems() const {
|
||||
std::vector<LoadProblem> result;
|
||||
for (auto problem : this->getAllProblems()) {
|
||||
if (
|
||||
problem.type != LoadProblem::Type::Recommendation &&
|
||||
problem.type != LoadProblem::Type::Suggestion
|
||||
problem.type != LoadProblem::Type::Suggestion &&
|
||||
problem.type != LoadProblem::Type::UnsupportedVersion
|
||||
) {
|
||||
result.push_back(problem);
|
||||
}
|
||||
}
|
||||
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> result;
|
||||
for (auto problem : this->getAllProblems()) {
|
||||
|
|
|
@ -252,8 +252,16 @@ bool Mod::hasSavedValue(std::string_view const key) {
|
|||
return this->getSaveContainer().contains(key);
|
||||
}
|
||||
|
||||
bool Mod::hasProblems() const {
|
||||
return m_impl->hasProblems();
|
||||
bool Mod::hasLoadProblems() const {
|
||||
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 {
|
||||
return m_impl->getProblems();
|
||||
|
@ -263,7 +271,8 @@ std::vector<LoadProblem> Mod::getProblems() const {
|
|||
for (auto problem : this->getAllProblems()) {
|
||||
if (
|
||||
problem.type != LoadProblem::Type::Recommendation &&
|
||||
problem.type != LoadProblem::Type::Suggestion
|
||||
problem.type != LoadProblem::Type::Suggestion &&
|
||||
problem.type != LoadProblem::Type::UnsupportedVersion
|
||||
) {
|
||||
result.push_back(problem);
|
||||
}
|
||||
|
|
|
@ -708,11 +708,15 @@ bool Mod::Impl::isCurrentlyLoading() const {
|
|||
return m_isCurrentlyLoading;
|
||||
}
|
||||
|
||||
bool Mod::Impl::hasProblems() const {
|
||||
for (auto const& item : m_problems) {
|
||||
if (item.type <= LoadProblem::Type::Recommendation)
|
||||
continue;
|
||||
return true;
|
||||
bool Mod::Impl::hasLoadProblems() const {
|
||||
for (auto const& problem : m_problems) {
|
||||
if (
|
||||
problem.type != LoadProblem::Type::Recommendation &&
|
||||
problem.type != LoadProblem::Type::Suggestion &&
|
||||
problem.type != LoadProblem::Type::UnsupportedVersion
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace geode {
|
|||
|
||||
std::vector<LoadProblem> getProblems() const;
|
||||
|
||||
bool hasProblems() const;
|
||||
bool hasLoadProblems() const;
|
||||
bool shouldLoad() const;
|
||||
bool isCurrentlyLoading() const;
|
||||
};
|
||||
|
|
|
@ -185,7 +185,7 @@ bool ModItem::init(ModSource&& source) {
|
|||
m_viewMenu->addChild(m_enableToggle);
|
||||
m_viewMenu->updateLayout();
|
||||
}
|
||||
if (mod->hasProblems()) {
|
||||
if (mod->hasLoadProblems() || mod->targetsOutdatedGDVersion()) {
|
||||
auto viewErrorSpr = createGeodeCircleButton(
|
||||
CCSprite::createWithSpriteFrameName("exclamation.png"_spr), 1.f,
|
||||
CircleBaseSize::Small
|
||||
|
@ -410,9 +410,14 @@ void ModItem::updateState() {
|
|||
m_titleContainer->updateLayout();
|
||||
|
||||
// If there were problems, tint the BG red
|
||||
if (m_source.asMod() && m_source.asMod()->hasProblems()) {
|
||||
m_bg->setColor("mod-list-errors-found"_cc3b);
|
||||
m_bg->setOpacity(isGeodeTheme() ? 25 : 90);
|
||||
if (m_source.asMod()) {
|
||||
if (m_source.asMod()->hasLoadProblems()) {
|
||||
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
|
||||
|
|
|
@ -111,7 +111,7 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
|
|||
|
||||
m_topContainer->addChild(m_updateAllContainer);
|
||||
|
||||
if (Loader::get()->getProblems().size()) {
|
||||
if (Loader::get()->getLoadProblems().size()) {
|
||||
m_errorsContainer = CCNode::create();
|
||||
m_errorsContainer->setID("errors-container");
|
||||
m_errorsContainer->ignoreAnchorPointForPosition(false);
|
||||
|
@ -549,7 +549,7 @@ void ModList::updateTopContainer() {
|
|||
|
||||
// If there are errors, show the error banner
|
||||
if (m_errorsContainer) {
|
||||
auto noErrors = Loader::get()->getProblems().empty();
|
||||
auto noErrors = Loader::get()->getLoadProblems().empty();
|
||||
m_errorsContainer->setVisible(!noErrors);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,11 @@ bool InstalledModsQuery::preCheck(ModSource const& src) const {
|
|||
return false;
|
||||
}
|
||||
// If only errors requested, only show mods with errors (duh)
|
||||
if (type == InstalledModListType::OnlyOutdated) {
|
||||
return src.asMod()->targetsOutdatedGDVersion();
|
||||
}
|
||||
if (type == InstalledModListType::OnlyErrors) {
|
||||
return src.asMod()->hasProblems();
|
||||
return src.asMod()->hasLoadProblems();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -59,6 +62,11 @@ InstalledModListSource* InstalledModListSource::get(InstalledModListType type) {
|
|||
static auto inst = new InstalledModListSource(InstalledModListType::OnlyErrors);
|
||||
return inst;
|
||||
} break;
|
||||
|
||||
case InstalledModListType::OnlyOutdated: {
|
||||
static auto inst = new InstalledModListSource(InstalledModListType::OnlyOutdated);
|
||||
return inst;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ enum class InstalledModListType {
|
|||
All,
|
||||
OnlyUpdates,
|
||||
OnlyErrors,
|
||||
OnlyOutdated,
|
||||
};
|
||||
struct InstalledModsQuery final : public LocalModsQueryBase {
|
||||
InstalledModListType type = InstalledModListType::All;
|
||||
|
|
Loading…
Reference in a new issue