Fixed a potential crash due to the filter menu entry being displayed when it shouldn't.

Also some very minor code cleanup.
This commit is contained in:
Leon Styhre 2021-04-05 14:37:33 +02:00
parent 9738957253
commit 4ca11e7062
2 changed files with 6 additions and 5 deletions

View file

@ -50,7 +50,7 @@ void GuiGamelistFilter::initializeMenu()
mMenu.addButton("BACK", "back", std::bind(&GuiGamelistFilter::applyFilters, this));
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2,
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2.0f,
Renderer::getScreenHeight() * 0.15f);
// Save the initial filter values to be able to check later if any changes were made.

View file

@ -141,8 +141,9 @@ GuiGamelistOptions::GuiGamelistOptions(
}
}
// Add the filters entry, unless this is the grouped custom collections list.
if (!mIsCustomCollectionGroup) {
// Add the filters entry, unless this is the grouped custom collections system or if there
// are no games (which should only happen for ungrouped custom collections).
if (!mIsCustomCollectionGroup && system->getRootFolder()->getChildren().size() > 0) {
if (system->getName() != "recent" && Settings::getInstance()->getBool("GamelistFilters")) {
row.elements.clear();
row.addElement(std::make_shared<TextComponent>
@ -212,8 +213,8 @@ GuiGamelistOptions::GuiGamelistOptions(
// Center the menu.
setSize(static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight()));
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, (mSize.y() -
mMenu.getSize().y()) / 2);
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2.0f, (mSize.y() -
mMenu.getSize().y()) / 2.0f);
}
GuiGamelistOptions::~GuiGamelistOptions()