From 74d3e1f06348ff500cd67b87175a84835f0eadcb Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 10 Sep 2022 11:35:55 +0200 Subject: [PATCH] Modernized some code. --- es-app/src/views/GamelistLegacy.h | 43 ++++++++++++++++++------------- es-app/src/views/GamelistView.cpp | 38 +++++++++++++++------------ 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/es-app/src/views/GamelistLegacy.h b/es-app/src/views/GamelistLegacy.h index a3760c991..1aff20589 100644 --- a/es-app/src/views/GamelistLegacy.h +++ b/es-app/src/views/GamelistLegacy.h @@ -470,33 +470,41 @@ void GamelistView::legacyUpdateView(const CursorState& state) // the game counter. for (auto& gamelistInfo : mGamelistInfoComponents) { std::string gamelistInfoString; - Alignment infoAlign = gamelistInfo->getHorizontalAlignment(); + Alignment infoAlign {gamelistInfo->getHorizontalAlignment()}; if (mIsFolder && infoAlign == ALIGN_RIGHT) gamelistInfoString = ViewController::FOLDER_CHAR + " "; if (mIsFiltered) { if (mFilteredGameCountAll == mFilteredGameCount) - gamelistInfoString += ViewController::FILTER_CHAR + " " + - std::to_string(mFilteredGameCount) + " / " + - std::to_string(mGameCount); + gamelistInfoString.append(ViewController::FILTER_CHAR) + .append(" ") + .append(std::to_string(mFilteredGameCount)) + .append(" / ") + .append(std::to_string(mGameCount)); else - gamelistInfoString += - ViewController::FILTER_CHAR + " " + std::to_string(mFilteredGameCount) + - " + " + std::to_string(mFilteredGameCountAll - mFilteredGameCount) + " / " + - std::to_string(mGameCount); + gamelistInfoString.append(ViewController::FILTER_CHAR) + .append(" ") + .append(std::to_string(mFilteredGameCount)) + .append(" + ") + .append(std::to_string(mFilteredGameCountAll - mFilteredGameCount)) + .append(" / ") + .append(std::to_string(mGameCount)); } else { - gamelistInfoString += - ViewController::CONTROLLER_CHAR + " " + std::to_string(mGameCount); + gamelistInfoString.append(ViewController::CONTROLLER_CHAR) + .append(" ") + .append(std::to_string(mGameCount)); if (!(file->getSystem()->isCollection() && file->getSystem()->getFullName() == "favorites")) - gamelistInfoString += " " + ViewController::FAVORITE_CHAR + " " + - std::to_string(mFavoritesGameCount); + gamelistInfoString.append(" ") + .append(ViewController::FAVORITE_CHAR) + .append(" ") + .append(std::to_string(mFavoritesGameCount)); } if (mIsFolder && infoAlign != ALIGN_RIGHT) - gamelistInfoString += " " + ViewController::FOLDER_CHAR; + gamelistInfoString.append(" ").append(ViewController::FOLDER_CHAR); gamelistInfo->setValue(gamelistInfoString); } @@ -668,8 +676,8 @@ void GamelistView::legacyInitMDLabels() const float rowPadding {0.01f * mSize.y}; for (unsigned int i = 0; i < components.size(); ++i) { - const unsigned int row = i % rowCount; - glm::vec3 pos {}; + const unsigned int row {i % rowCount}; + glm::vec3 pos {0.0f, 0.0f, 0.0f}; if (row == 0) { pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f}; } @@ -681,7 +689,6 @@ void GamelistView::legacyInitMDLabels() components[i]->setFont(Font::get(FONT_SIZE_SMALL)); components[i]->setPosition(pos); - // components[i]->setColor(0xFFFFFFFF); components[i]->setDefaultZIndex(40.0f); } } @@ -716,12 +723,12 @@ void GamelistView::legacyInitMDValues() float bottom {0.0f}; const float colSize {(mSize.x * 0.48f) / 2.0f}; for (unsigned int i = 0; i < labels.size(); ++i) { - const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f; + const float heightDiff {(labels[i]->getSize().y - values[i]->getSize().y) / 2.0f}; values[i]->setPosition(mSize.x + glm::vec3 {labels[i]->getSize().x, heightDiff, 0.0f}); values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y); values[i]->setDefaultZIndex(40.0f); - float testBot = values[i]->getPosition().y + values[i]->getSize().y; + float testBot {values[i]->getPosition().y + values[i]->getSize().y}; if (testBot > bottom) bottom = testBot; diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 613052226..bcec46a0d 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -615,38 +615,45 @@ void GamelistView::updateView(const CursorState& state) // the game counter. for (auto& gamelistInfo : mGamelistInfoComponents) { std::string gamelistInfoString; - Alignment infoAlign = gamelistInfo->getHorizontalAlignment(); + Alignment infoAlign {gamelistInfo->getHorizontalAlignment()}; if (mIsFolder && infoAlign == ALIGN_RIGHT) gamelistInfoString = ViewController::FOLDER_CHAR + " "; if (mIsFiltered) { if (mFilteredGameCountAll == mFilteredGameCount) - gamelistInfoString += ViewController::FILTER_CHAR + " " + - std::to_string(mFilteredGameCount) + " / " + - std::to_string(mGameCount); + gamelistInfoString.append(ViewController::FILTER_CHAR) + .append(" ") + .append(std::to_string(mFilteredGameCount)) + .append(" / ") + .append(std::to_string(mGameCount)); else - gamelistInfoString += - ViewController::FILTER_CHAR + " " + std::to_string(mFilteredGameCount) + - " + " + std::to_string(mFilteredGameCountAll - mFilteredGameCount) + " / " + - std::to_string(mGameCount); + gamelistInfoString.append(ViewController::FILTER_CHAR) + .append(" ") + .append(std::to_string(mFilteredGameCount)) + .append(" + ") + .append(std::to_string(mFilteredGameCountAll - mFilteredGameCount)) + .append(" / ") + .append(std::to_string(mGameCount)); } else { - gamelistInfoString += - ViewController::CONTROLLER_CHAR + " " + std::to_string(mGameCount); + gamelistInfoString.append(ViewController::CONTROLLER_CHAR) + .append(" ") + .append(std::to_string(mGameCount)); if (!(file->getSystem()->isCollection() && file->getSystem()->getFullName() == "favorites")) - gamelistInfoString += " " + ViewController::FAVORITE_CHAR + " " + - std::to_string(mFavoritesGameCount); + gamelistInfoString.append(" ") + .append(ViewController::FAVORITE_CHAR) + .append(" ") + .append(std::to_string(mFavoritesGameCount)); } if (mIsFolder && infoAlign != ALIGN_RIGHT) - gamelistInfoString += " " + ViewController::FOLDER_CHAR; + gamelistInfoString.append(" ").append(ViewController::FOLDER_CHAR); gamelistInfo->setValue(gamelistInfoString); } - // Fade in the game image. for (auto& image : mImageComponents) { if (image->getScrollFadeIn()) { auto func = [&image](float t) { @@ -656,7 +663,6 @@ void GamelistView::updateView(const CursorState& state) } } - // Fade in the static image. for (auto& video : mVideoComponents) { if (video->getScrollFadeIn()) { auto func = [&video](float t) { @@ -807,7 +813,7 @@ void GamelistView::updateView(const CursorState& state) } for (auto& date : mDateTimeComponents) { - std::string metadata = date->getThemeMetadata(); + std::string metadata {date->getThemeMetadata()}; if (metadata == "") continue;