add more user friendly dependency messages

This commit is contained in:
Cvolton 2024-02-15 20:19:24 +01:00
parent 264f773e80
commit f1ddc568e0
No known key found for this signature in database
3 changed files with 60 additions and 11 deletions

View file

@ -38,6 +38,9 @@ namespace geode {
UnzipFailed,
UnsupportedVersion,
UnsupportedGeodeVersion,
NeedsNewerGeodeVersion,
DisabledDependency,
OutdatedDependency,
};
Type type;
std::variant<ghc::filesystem::path, ModMetadata, Mod*> cause;

View file

@ -443,7 +443,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
node,
res.unwrapErr()
});
log::error("Unsupported game version: {}", res.unwrapErr());
log::error("Geometry Dash version {} is required to run this mod", res.unwrapErr());
m_refreshingModCount -= 1;
log::popNest();
return;
@ -451,10 +451,10 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
if (!this->isModVersionSupported(node->getMetadata().getGeodeVersion())) {
this->addProblem({
LoadProblem::Type::UnsupportedGeodeVersion,
node->getMetadata().getGeodeVersion() > this->getVersion() ? LoadProblem::Type::NeedsNewerGeodeVersion : LoadProblem::Type::UnsupportedGeodeVersion,
node,
fmt::format(
"Geode version {} is not supported (current: {})",
"Geode version {}\nis required to run this mod\n(installed: {})",
node->getMetadata().getGeodeVersion().toString(),
this->getVersion().toString()
)
@ -539,13 +539,46 @@ void Loader::Impl::findProblems() {
log::warn("{} recommends {} {}", id, dep.id, dep.version);
break;
case ModMetadata::Dependency::Importance::Required:
if(m_mods.find(dep.id) == m_mods.end()) {
this->addProblem({
LoadProblem::Type::MissingDependency,
mod,
fmt::format("{} {}", dep.id, dep.version.toString())
fmt::format("{}", dep.id)
});
log::error("{} requires {} {}", id, dep.id, dep.version);
break;
} else {
auto installedDependency = m_mods.at(dep.id);
if(!installedDependency->isEnabled()) {
this->addProblem({
LoadProblem::Type::DisabledDependency,
mod,
fmt::format("{}", dep.id)
});
log::error("{} requires {} {}", id, dep.id, dep.version);
break;
} else if(!dep.version.compare(installedDependency->getVersion())) {
// TODO: this also fires on major version mismatch
this->addProblem({
LoadProblem::Type::OutdatedDependency,
mod,
fmt::format("{}", dep.id)
});
log::error("{} requires {} {}", id, dep.id, dep.version);
break;
} else {
// this should never happen i think?
// (major mismatch should eventually fall through here though once that's fixed)
this->addProblem({
LoadProblem::Type::MissingDependency,
mod,
fmt::format("{}", dep.id)
});
log::error("{} requires {} {}", id, dep.id, dep.version);
break;
}
}
}
}

View file

@ -84,7 +84,15 @@ bool ProblemsListCell::init(LoadProblem problem, ProblemsListPopup* list, CCSize
break;
case LoadProblem::Type::MissingDependency:
icon = "info-alert.png"_spr;
message = fmt::format("{} depends on {}", cause, problem.message);
message = fmt::format("Install {} to use {}", problem.message, cause);
break;
case LoadProblem::Type::DisabledDependency:
icon = "info-alert.png"_spr;
message = fmt::format("Enable {} to use {}", problem.message, cause);
break;
case LoadProblem::Type::OutdatedDependency:
icon = "info-alert.png"_spr;
message = fmt::format("Update {} to use {}", problem.message, cause);
break;
case LoadProblem::Type::PresentIncompatibility:
icon = "info-alert.png"_spr;
@ -105,6 +113,11 @@ bool ProblemsListCell::init(LoadProblem problem, ProblemsListPopup* list, CCSize
message = fmt::format("{} is incompatible with this version of Geode", cause);
m_longMessage = problem.message;
break;
case LoadProblem::Type::NeedsNewerGeodeVersion:
icon = "info-alert.png"_spr;
message = fmt::format("Update Geode to use {}", cause);
m_longMessage = problem.message;
break;
}
m_problem = std::move(problem);