add separate message for outdated incompat

This commit is contained in:
Cvolton 2024-02-15 21:34:20 +01:00
parent f1ddc568e0
commit 98d572c0e5
No known key found for this signature in database
4 changed files with 33 additions and 17 deletions

View file

@ -41,6 +41,7 @@ namespace geode {
NeedsNewerGeodeVersion, NeedsNewerGeodeVersion,
DisabledDependency, DisabledDependency,
OutdatedDependency, OutdatedDependency,
OutdatedIncompatibility,
}; };
Type type; Type type;
std::variant<ghc::filesystem::path, ModMetadata, Mod*> cause; std::variant<ghc::filesystem::path, ModMetadata, Mod*> cause;

View file

@ -16,6 +16,14 @@ namespace geode {
Any Any
}; };
enum class VersionCompareResult {
TooOld,
Match,
TooNew,
MajorMismatch,
GenericMismatch
};
/** /**
* A version label, like v1.0.0-alpha or v2.3.4-prerelease. Limited to these * A version label, like v1.0.0-alpha or v2.3.4-prerelease. Limited to these
* options; arbitary identifiers are not supported. Additional numbering * options; arbitary identifiers are not supported. Additional numbering
@ -198,30 +206,35 @@ namespace geode {
static Result<ComparableVersionInfo> parse(std::string const& string); static Result<ComparableVersionInfo> parse(std::string const& string);
constexpr bool compare(VersionInfo const& version) const { constexpr bool compare(VersionInfo const& version) const {
return compareWithReason(version) == VersionCompareResult::Match;
}
constexpr VersionCompareResult compareWithReason(VersionInfo const& version) const {
if (m_compare == VersionCompare::Any) { if (m_compare == VersionCompare::Any) {
return true; return VersionCompareResult::Match;
} }
// opposing major versions never match // opposing major versions never match
if (m_version.getMajor() != version.getMajor()) { if (m_version.getMajor() != version.getMajor()) {
return false; return VersionCompareResult::MajorMismatch;
} }
// the comparison works invertedly as a version like "v1.2.0" // the comparison works invertedly as a version like "v1.2.0"
// should return true for "<=v1.3.0" // should return true for "<=v1.3.0"
switch (m_compare) { switch (m_compare) {
case VersionCompare::LessEq: case VersionCompare::LessEq:
return version <= m_version; return version <= m_version ? VersionCompareResult::Match : VersionCompareResult::TooNew;
case VersionCompare::MoreEq: case VersionCompare::MoreEq:
return version >= m_version; return version >= m_version ? VersionCompareResult::Match : VersionCompareResult::TooOld;
case VersionCompare::Less: case VersionCompare::Less:
return version < m_version; return version < m_version ? VersionCompareResult::Match : VersionCompareResult::TooNew;
case VersionCompare::More: case VersionCompare::More:
return version > m_version; return version > m_version ? VersionCompareResult::Match : VersionCompareResult::TooOld;
case VersionCompare::Exact: case VersionCompare::Exact:
return version == m_version; return version == m_version ? VersionCompareResult::Match :
(version > m_version) ? VersionCompareResult::TooOld : VersionCompareResult::TooNew;
default: default:
return false; return VersionCompareResult::GenericMismatch;
} }
} }

View file

@ -558,8 +558,7 @@ void Loader::Impl::findProblems() {
}); });
log::error("{} requires {} {}", id, dep.id, dep.version); log::error("{} requires {} {}", id, dep.id, dep.version);
break; break;
} else if(!dep.version.compare(installedDependency->getVersion())) { } else if(dep.version.compareWithReason(installedDependency->getVersion()) == VersionCompareResult::TooOld) {
// TODO: this also fires on major version mismatch
this->addProblem({ this->addProblem({
LoadProblem::Type::OutdatedDependency, LoadProblem::Type::OutdatedDependency,
mod, mod,
@ -568,12 +567,11 @@ void Loader::Impl::findProblems() {
log::error("{} requires {} {}", id, dep.id, dep.version); log::error("{} requires {} {}", id, dep.id, dep.version);
break; break;
} else { } else {
// this should never happen i think? // fires on major mismatch or too new version of dependency
// (major mismatch should eventually fall through here though once that's fixed)
this->addProblem({ this->addProblem({
LoadProblem::Type::MissingDependency, LoadProblem::Type::MissingDependency,
mod, mod,
fmt::format("{}", dep.id) fmt::format("{} {}", dep.id, dep.version)
}); });
log::error("{} requires {} {}", id, dep.id, dep.version); log::error("{} requires {} {}", id, dep.id, dep.version);
break; break;
@ -597,9 +595,9 @@ void Loader::Impl::findProblems() {
case ModMetadata::Incompatibility::Importance::Breaking: { case ModMetadata::Incompatibility::Importance::Breaking: {
this->addProblem({ this->addProblem({
LoadProblem::Type::PresentIncompatibility, dep.version.toString()[0] == '<' ? LoadProblem::Type::OutdatedIncompatibility : LoadProblem::Type::PresentIncompatibility,
mod, mod,
fmt::format("{} {}", dep.id, dep.version.toString()) fmt::format("{}", dep.id)
}); });
log::error("{} breaks {} {}", id, dep.id, dep.version); log::error("{} breaks {} {}", id, dep.id, dep.version);
} break; } break;
@ -608,7 +606,7 @@ void Loader::Impl::findProblems() {
this->addProblem({ this->addProblem({
LoadProblem::Type::PresentIncompatibility, LoadProblem::Type::PresentIncompatibility,
mod, mod,
fmt::format("{} {}", dep.id, dep.version.toString()) fmt::format("{}", dep.id)
}); });
log::error("{} supersedes {} {}", id, dep.id, dep.version); log::error("{} supersedes {} {}", id, dep.id, dep.version);
} break; } break;

View file

@ -96,7 +96,11 @@ bool ProblemsListCell::init(LoadProblem problem, ProblemsListPopup* list, CCSize
break; break;
case LoadProblem::Type::PresentIncompatibility: case LoadProblem::Type::PresentIncompatibility:
icon = "info-alert.png"_spr; icon = "info-alert.png"_spr;
message = fmt::format("{} is incompatible with {}", cause, problem.message); message = fmt::format("Uninstall {} to use {}", problem.message, cause);
break;
case LoadProblem::Type::OutdatedIncompatibility:
icon = "info-alert.png"_spr;
message = fmt::format("Update {} to use {}", problem.message, cause);
break; break;
case LoadProblem::Type::UnzipFailed: case LoadProblem::Type::UnzipFailed:
icon = "info-alert.png"_spr; icon = "info-alert.png"_spr;