fix geode not being given top billing in mods list

This commit is contained in:
HJfod 2024-04-26 16:50:47 +03:00
parent 349af5462e
commit 00f2bf5c18
3 changed files with 12 additions and 6 deletions

View file

@ -18,9 +18,12 @@ bool InstalledModsQuery::preCheck(ModSource const& src) const {
return true;
}
bool InstalledModsQuery::queryCheck(ModSource const& src, double& weighted) const {
auto addToList = modFuzzyMatch(src.asMod()->getMetadata(), *query, weighted);
bool addToList = true;
if (query) {
addToList = modFuzzyMatch(src.asMod()->getMetadata(), *query, weighted);
}
// Loader gets boost to ensure it's normally always top of the list
if (addToList && src.asMod()->getID() == "geode.loader") {
if (addToList && src.asMod()->isInternal()) {
weighted += 5;
}
// todo: favorites

View file

@ -223,7 +223,7 @@ void filterModsWithLocalQuery(ModListSource::ProvidedMods& mods, Query const& qu
}
}
// Don't bother with unnecessary fuzzy match calculations if this mod isn't going to be added anyway
if (addToList && query.query) {
if (addToList) {
addToList = query.queryCheck(src, weighted);
}
if (addToList) {

View file

@ -5,10 +5,13 @@ bool SuggestedModsQuery::preCheck(ModSource const& src) const {
return true;
}
bool SuggestedModsQuery::queryCheck(ModSource const& src, double& weighted) const {
if (!modFuzzyMatch(src.asSuggestion()->suggestion, *query, weighted)) {
return false;
if (query) {
if (!modFuzzyMatch(src.asSuggestion()->suggestion, *query, weighted)) {
return false;
}
return modFuzzyMatch(src.asSuggestion()->forMod->getMetadata(), *query, weighted);
}
return modFuzzyMatch(src.asSuggestion()->forMod->getMetadata(), *query, weighted);
return true;
}
void SuggestedModListSource::resetQuery() {