Add Authors to the list of things you can search for in the Object Selection menu (#17575)

* Add Authors to Search option

Joint effort from Spacek and karst

* Update changelog.txt

* Apply code review comment

Co-authored-by: duncanspumpkin <duncans_pumpkin@hotmail.co.uk>
This commit is contained in:
AuraSpecs 2022-07-23 15:28:39 -05:00 committed by GitHub
parent 3edcc91e40
commit d82360cc16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -2,6 +2,7 @@
------------------------------------------------------------------------
- Feature: [#13634] Add ability to sell merchandise in random colours.
- Feature: [#16662] Show a warning message when g2.dat is mismatched.
- Improvement: [#17575] You can now search for Authors in Object Selection.
- Change: [#17319] Giant screenshots are now cropped to the horizontal view-clipping selection.
- Change: [#17499] Update error text when using vehicle incompatible with TD6 and add error when using incompatible track elements.
- Fix: [#7466] Coaster track not drawn at tunnel exit.

View File

@ -1319,6 +1319,19 @@ private:
return false;
}
static bool IsFilterInAuthor(const std::vector<std::string>& authors, const std::string& filterUpper)
{
for (auto& author : authors)
{
bool inAuthor = String::ToUpper(author).find(filterUpper) != std::string::npos;
if (inAuthor)
{
return true;
}
}
return false;
}
bool FilterString(const ObjectRepositoryItem* item)
{
// Nothing to search for
@ -1338,12 +1351,13 @@ private:
const auto pathUpper = String::ToUpper(item->Path);
const auto filterUpper = String::ToUpper(_filter_string);
// Check if the searched string exists in the name, ride type, or filename
// Check if the searched string exists in the name, ride type, filename, or authors field
bool inName = nameUpper.find(filterUpper) != std::string::npos;
bool inRideType = (item->Type == ObjectType::Ride) && typeUpper.find(filterUpper) != std::string::npos;
bool inPath = pathUpper.find(filterUpper) != std::string::npos;
bool inAuthor = IsFilterInAuthor(item->Authors, filterUpper);
return inName || inRideType || inPath;
return inName || inRideType || inPath || inAuthor;
}
bool SourcesMatch(ObjectSourceGame source)