From 8a6652552f282af234abfb7fd844c8717e820ef5 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 16 Jan 2022 12:09:55 +0100 Subject: [PATCH] Set the clang-format option SpaceBeforeCpp11BracedList to true. --- .clang-format | 2 +- es-app/src/CollectionSystemsManager.cpp | 2 +- es-app/src/CollectionSystemsManager.h | 8 +- es-app/src/FileData.cpp | 8 +- es-app/src/MediaViewer.cpp | 6 +- es-app/src/MiximageGenerator.cpp | 16 +- es-app/src/SystemData.cpp | 4 +- es-app/src/SystemScreensaver.cpp | 10 +- es-app/src/guis/GuiAlternativeEmulators.cpp | 8 +- .../src/guis/GuiCollectionSystemsOptions.cpp | 12 +- es-app/src/guis/GuiGamelistFilter.cpp | 2 +- es-app/src/guis/GuiLaunchScreen.cpp | 42 +- es-app/src/guis/GuiMenu.cpp | 2 +- es-app/src/guis/GuiMetaDataEd.cpp | 88 ++-- es-app/src/guis/GuiOfflineGenerator.cpp | 56 +-- es-app/src/guis/GuiScraperMulti.cpp | 20 +- es-app/src/guis/GuiScraperSearch.cpp | 36 +- es-app/src/guis/GuiScraperSingle.cpp | 16 +- es-app/src/guis/GuiSettings.cpp | 2 +- es-app/src/main.cpp | 10 +- es-app/src/scrapers/GamesDBJSONScraper.cpp | 2 +- es-app/src/scrapers/Scraper.cpp | 2 +- es-app/src/scrapers/Scraper.h | 10 +- es-app/src/scrapers/ScreenScraper.cpp | 4 +- es-app/src/views/SystemView.cpp | 48 +- es-app/src/views/ViewController.cpp | 32 +- .../views/gamelist/DetailedGamelistView.cpp | 12 +- .../src/views/gamelist/GridGamelistView.cpp | 12 +- es-app/src/views/gamelist/IGamelistView.cpp | 10 +- es-app/src/views/gamelist/IGamelistView.h | 2 +- .../src/views/gamelist/VideoGamelistView.cpp | 12 +- es-core/src/GuiComponent.cpp | 38 +- es-core/src/GuiComponent.h | 4 +- es-core/src/HelpStyle.cpp | 8 +- es-core/src/Log.h | 10 +- es-core/src/Settings.cpp | 2 +- es-core/src/ThemeData.cpp | 433 +++++++++--------- es-core/src/ThemeData.h | 4 +- es-core/src/Window.cpp | 16 +- es-core/src/components/BadgeComponent.cpp | 24 +- es-core/src/components/BusyComponent.cpp | 12 +- es-core/src/components/ButtonComponent.cpp | 34 +- es-core/src/components/ComponentGrid.cpp | 38 +- es-core/src/components/ComponentGrid.h | 6 +- es-core/src/components/ComponentList.cpp | 68 +-- .../src/components/DateTimeEditComponent.cpp | 42 +- es-core/src/components/FlexboxComponent.cpp | 60 +-- es-core/src/components/FlexboxComponent.h | 4 +- es-core/src/components/GridTileComponent.cpp | 18 +- es-core/src/components/HelpComponent.cpp | 10 +- es-core/src/components/ImageComponent.cpp | 54 +-- es-core/src/components/ImageGridComponent.h | 54 +-- es-core/src/components/LottieComponent.cpp | 56 +-- es-core/src/components/MenuComponent.cpp | 18 +- es-core/src/components/NinePatchComponent.cpp | 40 +- es-core/src/components/OptionListComponent.h | 30 +- es-core/src/components/RatingComponent.cpp | 4 +- .../src/components/ScrollIndicatorComponent.h | 2 +- .../src/components/ScrollableContainer.cpp | 64 +-- es-core/src/components/SliderComponent.cpp | 26 +- es-core/src/components/SwitchComponent.cpp | 2 +- es-core/src/components/TextComponent.cpp | 64 +-- es-core/src/components/TextEditComponent.cpp | 48 +- es-core/src/components/TextListComponent.h | 36 +- es-core/src/components/VideoComponent.cpp | 8 +- .../src/components/VideoFFmpegComponent.cpp | 16 +- es-core/src/guis/GuiDetectDevice.cpp | 14 +- es-core/src/guis/GuiInfoPopup.cpp | 8 +- es-core/src/guis/GuiInputConfig.cpp | 18 +- es-core/src/guis/GuiMsgBox.cpp | 8 +- es-core/src/guis/GuiTextEditKeyboardPopup.cpp | 56 +-- es-core/src/guis/GuiTextEditKeyboardPopup.h | 10 +- es-core/src/guis/GuiTextEditPopup.cpp | 42 +- es-core/src/renderers/Renderer.cpp | 4 +- es-core/src/renderers/Renderer.h | 34 +- es-core/src/renderers/Renderer_GL21.cpp | 2 +- es-core/src/renderers/Renderer_GLES10.cpp | 10 +- es-core/src/renderers/Renderer_GLES20.cpp | 98 ++-- es-core/src/resources/Font.cpp | 44 +- es-core/src/resources/TextureData.cpp | 30 +- es-core/src/resources/TextureData.h | 2 +- es-core/src/resources/TextureResource.cpp | 20 +- es-core/src/utils/MathUtil.cpp | 66 +-- es-core/src/utils/PlatformUtil.cpp | 6 +- 84 files changed, 1161 insertions(+), 1160 deletions(-) diff --git a/.clang-format b/.clang-format index 73dfe5479..70f270fca 100644 --- a/.clang-format +++ b/.clang-format @@ -119,7 +119,7 @@ SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false +SpaceBeforeCpp11BracedList: true SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index 331d2959d..8a46ac811 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -780,7 +780,7 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s if (gameCount > 1) { std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; unsigned int target; for (unsigned int i = 0; i < 3; ++i) { diff --git a/es-app/src/CollectionSystemsManager.h b/es-app/src/CollectionSystemsManager.h index b33f83c2e..d59334145 100644 --- a/es-app/src/CollectionSystemsManager.h +++ b/es-app/src/CollectionSystemsManager.h @@ -50,10 +50,10 @@ struct CollectionSystemDecl { struct CollectionSystemData { CollectionSystemData() - : system{nullptr} - , decl{} - , isEnabled{false} - , isPopulated{false} + : system {nullptr} + , decl {} + , isEnabled {false} + , isPopulated {false} { } SystemData* system; diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index a796c5b03..e8547df66 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -1217,8 +1217,8 @@ const std::string FileData::findEmulatorPath(std::string& command) std::vector emulatorSystemPaths; std::vector emulatorStaticPaths; std::string emulatorEntry; - size_t startPos{0}; - size_t endPos{0}; + size_t startPos {0}; + size_t endPos {0}; if ((startPos = command.find("%EMULATOR_")) != std::string::npos) { endPos = command.find("%", startPos + 1); @@ -1256,7 +1256,7 @@ const std::string FileData::findEmulatorPath(std::string& command) HKEY registryKey; LSTATUS keyStatus = -1; LSTATUS pathStatus = -1; - char registryPath[1024]{}; + char registryPath[1024] {}; DWORD pathSize = 1024; // First look in HKEY_CURRENT_USER. @@ -1311,7 +1311,7 @@ const std::string FileData::findEmulatorPath(std::string& command) HKEY registryKey; LSTATUS keyStatus = -1; LSTATUS pathStatus = -1; - char path[1024]{}; + char path[1024] {}; DWORD pathSize = 1024; // First look in HKEY_CURRENT_USER. diff --git a/es-app/src/MediaViewer.cpp b/es-app/src/MediaViewer.cpp index c2000e846..ef34c026b 100644 --- a/es-app/src/MediaViewer.cpp +++ b/es-app/src/MediaViewer.cpp @@ -80,7 +80,7 @@ void MediaViewer::update(int deltaTime) void MediaViewer::render(const glm::mat4& /*parentTrans*/) { - glm::mat4 trans{Renderer::getIdentity()}; + glm::mat4 trans {Renderer::getIdentity()}; Renderer::setMatrix(trans); // Render a black background below the game media. @@ -92,7 +92,7 @@ void MediaViewer::render(const glm::mat4& /*parentTrans*/) #if defined(USE_OPENGL_21) Renderer::shaderParameters videoParameters; - unsigned int shaders{0}; + unsigned int shaders {0}; if (Settings::getInstance()->getBool("MediaViewerVideoScanlines")) shaders = Renderer::SHADER_SCANLINES; if (Settings::getInstance()->getBool("MediaViewerVideoBlur")) { @@ -118,7 +118,7 @@ void MediaViewer::render(const glm::mat4& /*parentTrans*/) Renderer::shaderPostprocessing(shaders, videoParameters); #endif } - else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2{}) { + else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2 {}) { mImage->render(trans); #if defined(USE_OPENGL_21) diff --git a/es-app/src/MiximageGenerator.cpp b/es-app/src/MiximageGenerator.cpp index cf4948257..c866838c9 100644 --- a/es-app/src/MiximageGenerator.cpp +++ b/es-app/src/MiximageGenerator.cpp @@ -17,14 +17,14 @@ #include MiximageGenerator::MiximageGenerator(FileData* game, std::string& resultMessage) - : mGame{game} - , mResultMessage{resultMessage} - , mWidth{1280} - , mHeight{960} - , mMarquee{false} - , mBox3D{false} - , mCover{false} - , mPhysicalMedia{false} + : mGame {game} + , mResultMessage {resultMessage} + , mWidth {1280} + , mHeight {960} + , mMarquee {false} + , mBox3D {false} + , mCover {false} + , mPhysicalMedia {false} { } diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index bee2823a6..54ae24aaa 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -1093,7 +1093,7 @@ SystemData* SystemData::getRandomSystem(const SystemData* currentSystem) // Get a random number in range. std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; std::uniform_int_distribution uniform_dist(0, total - 1); int target = uniform_dist(engine); @@ -1172,7 +1172,7 @@ FileData* SystemData::getRandomGame(const FileData* currentGame) // Get a random number in range. std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; std::uniform_int_distribution uniform_dist(0, total - 1); target = uniform_dist(engine); } while (currentGame && gameList.at(target) == currentGame); diff --git a/es-app/src/SystemScreensaver.cpp b/es-app/src/SystemScreensaver.cpp index 10a7ae5f7..81ed53f54 100644 --- a/es-app/src/SystemScreensaver.cpp +++ b/es-app/src/SystemScreensaver.cpp @@ -242,7 +242,7 @@ void SystemScreensaver::renderScreensaver() // Only render the video if the state requires it. if (static_cast(mState) >= STATE_FADE_IN_VIDEO) { - glm::mat4 trans{Renderer::getIdentity()}; + glm::mat4 trans {Renderer::getIdentity()}; mVideoScreensaver->render(trans); } } @@ -256,7 +256,7 @@ void SystemScreensaver::renderScreensaver() if (static_cast(mState) >= STATE_FADE_IN_VIDEO) { if (mImageScreensaver->hasImage()) { mImageScreensaver->setOpacity(255 - static_cast(mOpacity * 255)); - glm::mat4 trans{Renderer::getIdentity()}; + glm::mat4 trans {Renderer::getIdentity()}; mImageScreensaver->render(trans); } } @@ -502,7 +502,7 @@ void SystemScreensaver::pickRandomImage(std::string& path) // Get a random number in range. std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; std::uniform_int_distribution uniform_dist(0, static_cast(mImageFiles.size()) - 1); index = uniform_dist(engine); @@ -536,7 +536,7 @@ void SystemScreensaver::pickRandomVideo(std::string& path) // Get a random number in range. std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; std::uniform_int_distribution uniform_dist(0, static_cast(mVideoFiles.size()) - 1); index = uniform_dist(engine); @@ -564,7 +564,7 @@ void SystemScreensaver::pickRandomCustomImage(std::string& path) // Get a random number in range. std::random_device randDev; // Mersenne Twister pseudorandom number generator. - std::mt19937 engine{randDev()}; + std::mt19937 engine {randDev()}; std::uniform_int_distribution uniform_dist( 0, static_cast(mImageCustomFiles.size()) - 1); index = uniform_dist(engine); diff --git a/es-app/src/guis/GuiAlternativeEmulators.cpp b/es-app/src/guis/GuiAlternativeEmulators.cpp index 64ee12c78..47db99f4c 100644 --- a/es-app/src/guis/GuiAlternativeEmulators.cpp +++ b/es-app/src/guis/GuiAlternativeEmulators.cpp @@ -14,8 +14,8 @@ #include "views/ViewController.h" GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window) - : GuiComponent{window} - , mMenu{window, "ALTERNATIVE EMULATORS"} + : GuiComponent {window} + , mMenu {window, "ALTERNATIVE EMULATORS"} , mHasSystems(false) { addChild(&mMenu); @@ -216,12 +216,12 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system) else width = systemTextWidth; - s->setMenuSize(glm::vec2{width, s->getMenuSize().y}); + s->setMenuSize(glm::vec2 {width, s->getMenuSize().y}); auto menuSize = s->getMenuSize(); auto menuPos = s->getMenuPosition(); - s->setMenuPosition(glm::vec3{(s->getSize().x - menuSize.x) / 2.0f, menuPos.y, menuPos.z}); + s->setMenuPosition(glm::vec3 {(s->getSize().x - menuSize.x) / 2.0f, menuPos.y, menuPos.z}); mWindow->pushGui(s); } diff --git a/es-app/src/guis/GuiCollectionSystemsOptions.cpp b/es-app/src/guis/GuiCollectionSystemsOptions.cpp index 315a1e9d1..bfaeb9ec7 100644 --- a/es-app/src/guis/GuiCollectionSystemsOptions.cpp +++ b/es-app/src/guis/GuiCollectionSystemsOptions.cpp @@ -169,7 +169,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st auto bracketThemeCollection = std::make_shared(mWindow); bracketThemeCollection->setImage(":/graphics/arrow.svg"); bracketThemeCollection->setResize( - glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); + glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(themeCollection, true); row.addElement(bracketThemeCollection, false); row.makeAcceptInputHandler([this, unusedFolders] { @@ -203,7 +203,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st auto bracketNewCollection = std::make_shared(mWindow); bracketNewCollection->setImage(":/graphics/arrow.svg"); bracketNewCollection->setResize( - glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); + glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(newCollection, true); row.addElement(bracketNewCollection, false); auto createCollectionCall = [this](const std::string& newVal) { @@ -239,7 +239,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st auto bracketDeleteCollection = std::make_shared(mWindow); bracketDeleteCollection->setImage(":/graphics/arrow.svg"); bracketDeleteCollection->setResize( - glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); + glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); row.addElement(deleteCollection, true); row.addElement(bracketDeleteCollection, false); row.makeAcceptInputHandler([this, customSystems] { @@ -303,9 +303,9 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st ss->addRow(row); } // Make the menu slightly wider to fit the scroll indicators. - glm::vec2 menuSize{ss->getMenuSize()}; - glm::vec3 menuPos{ss->getMenuPosition()}; - ss->setMenuSize(glm::vec2{menuSize.x * 1.08f, menuSize.y}); + glm::vec2 menuSize {ss->getMenuSize()}; + glm::vec3 menuPos {ss->getMenuPosition()}; + ss->setMenuSize(glm::vec2 {menuSize.x * 1.08f, menuSize.y}); menuPos.x = static_cast((Renderer::getScreenWidth()) - ss->getMenuSize().x) / 2.0f; ss->setMenuPosition(menuPos); mWindow->pushGui(ss); diff --git a/es-app/src/guis/GuiGamelistFilter.cpp b/es-app/src/guis/GuiGamelistFilter.cpp index aca3b9617..5d8f71751 100644 --- a/es-app/src/guis/GuiGamelistFilter.cpp +++ b/es-app/src/guis/GuiGamelistFilter.cpp @@ -116,7 +116,7 @@ void GuiGamelistFilter::addFiltersToMenu() auto bracket = std::make_shared(mWindow); bracket->setImage(":/graphics/arrow.svg"); - bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); mTextFilterField->setValue(mFilterIndex->getTextFilter()); diff --git a/es-app/src/guis/GuiLaunchScreen.cpp b/es-app/src/guis/GuiLaunchScreen.cpp index 9b9acae88..f06c58b22 100644 --- a/es-app/src/guis/GuiLaunchScreen.cpp +++ b/es-app/src/guis/GuiLaunchScreen.cpp @@ -33,7 +33,7 @@ GuiLaunchScreen::~GuiLaunchScreen() void GuiLaunchScreen::displayLaunchScreen(FileData* game) { - mGrid = new ComponentGrid(mWindow, glm::ivec2{3, 8}); + mGrid = new ComponentGrid(mWindow, glm::ivec2 {3, 8}); addChild(mGrid); mImagePath = game->getMarqueePath(); @@ -50,8 +50,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) const float gameNameFontSize = 0.073f; // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{1, 0}, false, false, - glm::ivec2{1, 1}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 0}, false, false, + glm::ivec2 {1, 1}); // Title. mTitle = std::make_shared( @@ -59,19 +59,19 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) Font::get(static_cast( titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), 0x666666FF, ALIGN_CENTER); - mGrid->setEntry(mTitle, glm::ivec2{1, 1}, false, true, glm::ivec2{1, 1}); + mGrid->setEntry(mTitle, glm::ivec2 {1, 1}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{1, 2}, false, false, - glm::ivec2{1, 1}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 2}, false, false, + glm::ivec2 {1, 1}); // Row for the marquee. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{1, 3}, false, false, - glm::ivec2{1, 1}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 3}, false, false, + glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{1, 4}, false, false, - glm::ivec2{1, 1}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 4}, false, false, + glm::ivec2 {1, 1}); // Game name. mGameName = std::make_shared( @@ -79,24 +79,24 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) Font::get(static_cast( gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))), 0x444444FF, ALIGN_CENTER); - mGrid->setEntry(mGameName, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1}); + mGrid->setEntry(mGameName, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); // System name. mSystemName = std::make_shared( mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER); - mGrid->setEntry(mSystemName, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1}); + mGrid->setEntry(mSystemName, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{1, 7}, false, false, - glm::ivec2{1, 1}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {1, 7}, false, false, + glm::ivec2 {1, 1}); // Left spacer. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{0, 0}, false, false, - glm::ivec2{1, 8}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false, false, + glm::ivec2 {1, 8}); // Right spacer. - mGrid->setEntry(std::make_shared(mWindow), glm::ivec2{2, 0}, false, false, - glm::ivec2{1, 8}); + mGrid->setEntry(std::make_shared(mWindow), glm::ivec2 {2, 0}, false, false, + glm::ivec2 {1, 8}); // Adjust the width depending on the aspect ratio of the screen, to make the screen look // somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 @@ -168,7 +168,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) mGrid->getRowHeight(3)); mMarquee->setOrigin(0.5f, 0.5f); - glm::vec3 currentPos{mMarquee->getPosition()}; + glm::vec3 currentPos {mMarquee->getPosition()}; // Position the image in the middle of row four. currentPos.x = mSize.x / 2.0f; @@ -183,7 +183,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game) setPosition(static_cast(Renderer::getScreenWidth()) / 2.0f, static_cast(Renderer::getScreenHeight()) / 2.25f); - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); mBackground.setEdgeColor(0xEEEEEEFF); } @@ -225,7 +225,7 @@ void GuiLaunchScreen::render(const glm::mat4& /*parentTrans*/) // Scale up animation. setScale(mScaleUp); - glm::mat4 trans{Renderer::getIdentity() * getTransform()}; + glm::mat4 trans {Renderer::getIdentity() * getTransform()}; Renderer::setMatrix(trans); GuiComponent::renderChildren(trans); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 0c931d893..4d15701c6 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -821,7 +821,7 @@ void GuiMenu::openOtherOptions() auto bracketMediaDirectory = std::make_shared(mWindow); bracketMediaDirectory->setImage(":/graphics/arrow.svg"); bracketMediaDirectory->setResize( - glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); + glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()}); rowMediaDir.addElement(media_directory, true); rowMediaDir.addElement(bracketMediaDirectory, false); std::string titleMediaDir = "ENTER GAME MEDIA DIRECTORY"; diff --git a/es-app/src/guis/GuiMetaDataEd.cpp b/es-app/src/guis/GuiMetaDataEd.cpp index f8833d1aa..7d4a1ae6b 100644 --- a/es-app/src/guis/GuiMetaDataEd.cpp +++ b/es-app/src/guis/GuiMetaDataEd.cpp @@ -41,20 +41,20 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, std::function saveCallback, std::function clearGameFunc, std::function deleteGameFunc) - : GuiComponent{window} - , mBackground{window, ":/graphics/frame.svg"} - , mGrid{window, glm::ivec2{2, 6}} - , mScraperParams{scraperParams} - , mControllerBadges{BadgeComponent::getGameControllers()} - , mMetaDataDecl{mdd} - , mMetaData{md} - , mSavedCallback{saveCallback} - , mClearGameFunc{clearGameFunc} - , mDeleteGameFunc{deleteGameFunc} - , mIsCustomCollection{false} - , mMediaFilesUpdated{false} - , mSavedMediaAndAborted{false} - , mInvalidEmulatorEntry{false} + : GuiComponent {window} + , mBackground {window, ":/graphics/frame.svg"} + , mGrid {window, glm::ivec2 {2, 6}} + , mScraperParams {scraperParams} + , mControllerBadges {BadgeComponent::getGameControllers()} + , mMetaDataDecl {mdd} + , mMetaData {md} + , mSavedCallback {saveCallback} + , mClearGameFunc {clearGameFunc} + , mDeleteGameFunc {deleteGameFunc} + , mIsCustomCollection {false} + , mMediaFilesUpdated {false} + , mSavedMediaAndAborted {false} + , mInvalidEmulatorEntry {false} { if (ViewController::getInstance()->getState().getSystem()->isCustomCollection() || ViewController::getInstance()->getState().getSystem()->getThemeFolder() == @@ -70,7 +70,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, mTitle = std::make_shared(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); // Extract possible subfolders from the path. std::string folderPath = @@ -94,10 +94,10 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, (scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""), Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); + mGrid.setEntry(mSubtitle, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); mList = std::make_shared(mWindow); - mGrid.setEntry(mList, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1}); + mGrid.setEntry(mList, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); // Set up scroll indicators. mScrollUp = std::make_shared(mWindow); @@ -110,8 +110,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); mScrollDown->setOrigin(0.0f, 0.35f); - mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); - mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); // Populate list. for (auto it = mdd.cbegin(); it != mdd.cend(); ++it) { @@ -152,7 +152,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, case MD_BOOL: { ed = std::make_shared(window); // Make the switches slightly smaller. - glm::vec2 switchSize{ed->getSize() * 0.9f}; + glm::vec2 switchSize {ed->getSize() * 0.9f}; ed->setResize(ceilf(switchSize.x), switchSize.y); ed->setChangedColor(ICONCOLOR_USERMARKED); @@ -202,7 +202,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, auto bracket = std::make_shared(mWindow); bracket->setImage(":/graphics/arrow.svg"); - bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); const std::string title = it->displayPrompt; @@ -265,9 +265,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, float maxWidth = static_cast(Renderer::getScreenWidth()) * maxWidthModifier; - s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y}); + s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); s->setMenuPosition( - glm::vec3{(s->getSize().x - maxWidth) / 2.0f, mPosition.y, mPosition.z}); + glm::vec3 {(s->getSize().x - maxWidth) / 2.0f, mPosition.y, mPosition.z}); mWindow->pushGui(s); }); break; @@ -286,7 +286,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, auto bracket = std::make_shared(mWindow); bracket->setImage(":/graphics/arrow.svg"); - bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); const std::string title = it->displayPrompt; @@ -398,9 +398,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, float maxWidth = static_cast(Renderer::getScreenWidth()) * maxWidthModifier; - s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y}); - s->setMenuPosition(glm::vec3{(s->getSize().x - maxWidth) / 2.0f, - mPosition.y, mPosition.z}); + s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y}); + s->setMenuPosition(glm::vec3 {(s->getSize().x - maxWidth) / 2.0f, + mPosition.y, mPosition.z}); mWindow->pushGui(s); }); } @@ -424,7 +424,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, auto bracket = std::make_shared(mWindow); bracket->setImage(":/graphics/arrow.svg"); - bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); bool multiLine = it->type == MD_MULTILINE_STRING; @@ -584,7 +584,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, } mButtons = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtons, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); + mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); // Resize + center. float width = @@ -611,7 +611,7 @@ void GuiMetaDataEd::onSizeChanged() mGrid.setColWidthPerc(1, 0.055f); mGrid.setSize(mSize); - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f, (Renderer::getScreenHeight() - mSize.y) / 2.0f); @@ -629,10 +629,10 @@ void GuiMetaDataEd::save() // We need this to handle the special situation where the user sets a game to hidden while // ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist. - bool showHiddenGames{Settings::getInstance()->getBool("ShowHiddenGames")}; - bool hideGameWhileHidden{false}; - bool setGameAsCounted{false}; - int offset{0}; + bool showHiddenGames {Settings::getInstance()->getBool("ShowHiddenGames")}; + bool hideGameWhileHidden {false}; + bool setGameAsCounted {false}; + int offset {0}; for (unsigned int i = 0; i < mEditors.size(); ++i) { // The offset is needed to make the editor and metadata fields match up if we're @@ -644,7 +644,7 @@ void GuiMetaDataEd::save() if (mMetaDataDecl.at(i + offset).isStatistic) continue; - const std::string& key{mMetaDataDecl.at(i + offset).key}; + const std::string& key {mMetaDataDecl.at(i + offset).key}; if (key == "altemulator" && mInvalidEmulatorEntry == true) continue; @@ -756,10 +756,10 @@ void GuiMetaDataEd::fetch() void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result) { // Clone the mMetaData object. - MetaDataList* metadata{new MetaDataList(*mMetaData)}; + MetaDataList* metadata {new MetaDataList(*mMetaData)}; mMediaFilesUpdated = result.savedNewMedia; - int offset{0}; + int offset {0}; // Check if any values were manually changed before starting the scraping. // If so, it's these values we should compare against when scraping, not @@ -768,7 +768,7 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result) if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection) offset = 1; - const std::string& key{mMetaDataDecl.at(i + offset).key}; + const std::string& key {mMetaDataDecl.at(i + offset).key}; if (metadata->get(key) != mEditors[i]->getValue()) metadata->set(key, mEditors[i]->getValue()); @@ -783,7 +783,7 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result) if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection) offset = 1; - const std::string& key{mMetaDataDecl.at(i + offset).key}; + const std::string& key {mMetaDataDecl.at(i + offset).key}; if (key == "controller" && metadata->get(key) != "") { std::string displayName = BadgeComponent::getDisplayName(metadata->get(key)); @@ -808,20 +808,20 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result) void GuiMetaDataEd::close() { // Find out if the user made any changes. - bool metadataUpdated{false}; - int offset{0}; + bool metadataUpdated {false}; + int offset {0}; for (unsigned int i = 0; i < mEditors.size(); ++i) { if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection) offset = 1; - const std::string& key{mMetaDataDecl.at(i + offset).key}; + const std::string& key {mMetaDataDecl.at(i + offset).key}; if (key == "altemulator" && mInvalidEmulatorEntry == true) continue; - std::string mMetaDataValue{mMetaData->get(key)}; - std::string mEditorsValue{mEditors.at(i)->getValue()}; + std::string mMetaDataValue {mMetaData->get(key)}; + std::string mEditorsValue {mEditors.at(i)->getValue()}; if (key == "controller" && mEditors.at(i)->getValue() != "") { std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue()); diff --git a/es-app/src/guis/GuiOfflineGenerator.cpp b/es-app/src/guis/GuiOfflineGenerator.cpp index b46731528..40aaa4837 100644 --- a/es-app/src/guis/GuiOfflineGenerator.cpp +++ b/es-app/src/guis/GuiOfflineGenerator.cpp @@ -17,7 +17,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue(mWindow, "MIXIMAGE OFFLINE GENERATOR", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{6, 1}); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {6, 1}); mStatus = std::make_shared(mWindow, "NOT STARTED", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mStatus, glm::ivec2{0, 1}, false, true, glm::ivec2{6, 1}); + mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1}); mGameCounter = std::make_shared( mWindow, std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) + (mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); - mGrid.setEntry(mGameCounter, glm::ivec2{0, 2}, false, true, glm::ivec2{6, 1}); + mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1}); // Spacer row with top border. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 3}, false, false, - glm::ivec2{6, 1}, GridFlags::BORDER_TOP); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 3}, false, false, + glm::ivec2 {6, 1}, GridFlags::BORDER_TOP); // Left spacer. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 4}, false, false, - glm::ivec2{1, 7}); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 4}, false, false, + glm::ivec2 {1, 7}); // Generated label. mGeneratedLbl = std::make_shared( mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mGeneratedLbl, glm::ivec2{1, 4}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1}); // Generated value/counter. mGeneratedVal = std::make_shared(mWindow, std::to_string(mGamesProcessed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mGeneratedVal, glm::ivec2{2, 4}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1}); // Overwritten label. mOverwrittenLbl = std::make_shared( mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mOverwrittenLbl, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1}); // Overwritten value/counter. mOverwrittenVal = std::make_shared(mWindow, std::to_string(mImagesOverwritten), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mOverwrittenVal, glm::ivec2{2, 5}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1}); // Skipping label. mSkippedLbl = std::make_shared( mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mSkippedLbl, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1}); // Skipping value/counter. mSkippedVal = std::make_shared( mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mSkippedVal, glm::ivec2{2, 6}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mSkippedVal, glm::ivec2 {2, 6}, false, true, glm::ivec2 {1, 1}); // Failed label. mFailedLbl = std::make_shared(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mFailedLbl, glm::ivec2{1, 7}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1}); // Failed value/counter. mFailedVal = std::make_shared( mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mFailedVal, glm::ivec2{2, 7}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mFailedVal, glm::ivec2 {2, 7}, false, true, glm::ivec2 {1, 1}); // Processing label. mProcessingLbl = std::make_shared( mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mProcessingLbl, glm::ivec2{3, 4}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1}); // Processing value. mProcessingVal = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mProcessingVal, glm::ivec2{4, 4}, false, true, glm::ivec2{1, 1}); + mGrid.setEntry(mProcessingVal, glm::ivec2 {4, 4}, false, true, glm::ivec2 {1, 1}); // Spacer row. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{1, 8}, false, false, - glm::ivec2{4, 1}); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {1, 8}, false, false, + glm::ivec2 {4, 1}); // Last error message label. mLastErrorLbl = std::make_shared( mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mLastErrorLbl, glm::ivec2{1, 9}, false, true, glm::ivec2{4, 1}); + mGrid.setEntry(mLastErrorLbl, glm::ivec2 {1, 9}, false, true, glm::ivec2 {4, 1}); // Last error message value. mLastErrorVal = std::make_shared(mWindow, "", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT); - mGrid.setEntry(mLastErrorVal, glm::ivec2{1, 10}, false, true, glm::ivec2{4, 1}); + mGrid.setEntry(mLastErrorVal, glm::ivec2 {1, 10}, false, true, glm::ivec2 {4, 1}); // Right spacer. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{5, 4}, false, false, - glm::ivec2{1, 7}); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {5, 4}, false, false, + glm::ivec2 {1, 7}); // Spacer row with bottom border. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 11}, false, false, - glm::ivec2{6, 1}, GridFlags::BORDER_BOTTOM); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 11}, false, false, + glm::ivec2 {6, 1}, GridFlags::BORDER_BOTTOM); // Buttons. std::vector> buttons; @@ -177,7 +177,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queuegetFont()->getLetterHeight() * 1.9725f / mSize.y, false); diff --git a/es-app/src/guis/GuiScraperMulti.cpp b/es-app/src/guis/GuiScraperMulti.cpp index f16b84af2..5740c4df7 100644 --- a/es-app/src/guis/GuiScraperMulti.cpp +++ b/es-app/src/guis/GuiScraperMulti.cpp @@ -29,7 +29,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, bool approveResults) : GuiComponent(window) , mBackground(window, ":/graphics/frame.svg") - , mGrid(window, glm::ivec2{2, 6}) + , mGrid(window, glm::ivec2 {2, 6}) , mSearchQueue(searches) , mApproveResults(approveResults) { @@ -48,15 +48,15 @@ GuiScraperMulti::GuiScraperMulti(Window* window, // Set up grid. mTitle = std::make_shared(mWindow, "SCRAPING IN PROGRESS", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mSystem = std::make_shared(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mSystem, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); + mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); mSubtitle = std::make_shared( mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); - mGrid.setEntry(mSubtitle, glm::ivec2{0, 3}, false, true, glm::ivec2{2, 1}); + mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1}); if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic")) mSearchComp = std::make_shared( @@ -77,9 +77,9 @@ GuiScraperMulti::GuiScraperMulti(Window* window, mResultList->resetScrollIndicatorStatus(); }); - mGrid.setEntry(mSearchComp, glm::ivec2{0, 4}, + mGrid.setEntry(mSearchComp, glm::ivec2 {0, 4}, mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT, - true, glm::ivec2{2, 1}); + true, glm::ivec2 {2, 1}); mResultList = mSearchComp->getResultList(); @@ -95,8 +95,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window, mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); mScrollDown->setOrigin(0.0f, 0.35f); - mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); - mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); // Buttons. std::vector> buttons; @@ -150,7 +150,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, std::bind(&GuiScraperMulti::finish, this))); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); // Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is // the 16:9 reference. @@ -206,7 +206,7 @@ void GuiScraperMulti::onSizeChanged() mGrid.setColWidthPerc(1, 0.04f); mGrid.setSize(mSize); - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); } void GuiScraperMulti::doNextSearch() diff --git a/es-app/src/guis/GuiScraperSearch.cpp b/es-app/src/guis/GuiScraperSearch.cpp index 5f9b5d93a..02b478df6 100644 --- a/es-app/src/guis/GuiScraperSearch.cpp +++ b/es-app/src/guis/GuiScraperSearch.cpp @@ -39,7 +39,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount) : GuiComponent(window) - , mGrid(window, glm::ivec2{5, 3}) + , mGrid(window, glm::ivec2 {5, 3}) , mSearchType(type) , mScrapeCount(scrapeCount) , mRefinedSearch(false) @@ -55,8 +55,8 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int mRetryCount = 0; // Left spacer (empty component, needed for borders). - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 0}, false, false, - glm::ivec2{1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false, false, + glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); // Selected result name. mResultName = std::make_shared(mWindow, "Result name", @@ -64,7 +64,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int // Selected result thumbnail. mResultThumbnail = std::make_shared(mWindow); - mGrid.setEntry(mResultThumbnail, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mResultThumbnail, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); // Selected result description and container. mDescContainer = std::make_shared(mWindow); @@ -91,7 +91,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int mMD_Developer = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Publisher = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Genre = - std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3{}); + std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {}); mMD_Players = std::make_shared(mWindow, "", font, mdColor, ALIGN_LEFT); mMD_Filler = std::make_shared(mWindow, "", font, mdColor); @@ -121,15 +121,15 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int std::make_shared(mWindow, "", font, mdLblColor), mMD_Filler)); mMD_Grid = std::make_shared( - mWindow, glm::ivec2{2, static_cast(mMD_Pairs.size() * 2 - 1)}); + mWindow, glm::ivec2 {2, static_cast(mMD_Pairs.size() * 2 - 1)}); unsigned int i = 0; for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) { - mMD_Grid->setEntry(it->first, glm::ivec2{0, i}, false, true); - mMD_Grid->setEntry(it->second, glm::ivec2{1, i}, false, it->resize); + mMD_Grid->setEntry(it->first, glm::ivec2 {0, i}, false, true); + mMD_Grid->setEntry(it->second, glm::ivec2 {1, i}, false, it->resize); i += 2; } - mGrid.setEntry(mMD_Grid, glm::ivec2{2, 1}, false, false); + mGrid.setEntry(mMD_Grid, glm::ivec2 {2, 1}, false, false); // Result list. mResultList = std::make_shared(mWindow); @@ -288,30 +288,30 @@ void GuiScraperSearch::updateViewStyle() // Add them back depending on search type. if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) { // Show name. - mGrid.setEntry(mResultName, glm::ivec2{1, 0}, false, false, glm::ivec2{3, 1}, + mGrid.setEntry(mResultName, glm::ivec2 {1, 0}, false, false, glm::ivec2 {3, 1}, GridFlags::BORDER_TOP); // Need a border on the bottom left. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 2}, false, false, - glm::ivec2{4, 1}, GridFlags::BORDER_BOTTOM); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 2}, false, false, + glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM); // Show description on the right. - mGrid.setEntry(mDescContainer, glm::ivec2{4, 0}, false, false, glm::ivec2{1, 3}, + mGrid.setEntry(mDescContainer, glm::ivec2 {4, 0}, false, false, glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM | GridFlags::BORDER_LEFT); // Make description text wrap at edge of container. mResultDesc->setSize(mDescContainer->getSize().x, 0.0f); } else { // Fake row where name would be. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{1, 0}, false, true, - glm::ivec2{3, 1}, GridFlags::BORDER_TOP); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {1, 0}, false, true, + glm::ivec2 {3, 1}, GridFlags::BORDER_TOP); // Show result list on the right. - mGrid.setEntry(mResultList, glm::ivec2{4, 0}, true, true, glm::ivec2{1, 3}, + mGrid.setEntry(mResultList, glm::ivec2 {4, 0}, true, true, glm::ivec2 {1, 3}, GridFlags::BORDER_LEFT | GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); // Show description under image/info. - mGrid.setEntry(mDescContainer, glm::ivec2{1, 2}, false, false, glm::ivec2{3, 1}, + mGrid.setEntry(mDescContainer, glm::ivec2 {1, 2}, false, false, glm::ivec2 {3, 1}, GridFlags::BORDER_BOTTOM); // Make description text wrap at edge of container. mResultDesc->setSize(mDescContainer->getSize().x, 0); @@ -634,7 +634,7 @@ bool GuiScraperSearch::input(InputConfig* config, Input input) void GuiScraperSearch::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; renderChildren(trans); Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x00000009, 0x00000009); diff --git a/es-app/src/guis/GuiScraperSingle.cpp b/es-app/src/guis/GuiScraperSingle.cpp index c9e3ec5c7..71efbece1 100644 --- a/es-app/src/guis/GuiScraperSingle.cpp +++ b/es-app/src/guis/GuiScraperSingle.cpp @@ -24,7 +24,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window, bool& savedMediaAndAborted) : GuiComponent(window) , mClose(false) - , mGrid(window, glm::ivec2{2, 6}) + , mGrid(window, glm::ivec2 {2, 6}) , mBox(window, ":/graphics/frame.svg") , mSearchParams(params) , mSavedMediaAndAborted(savedMediaAndAborted) @@ -53,18 +53,18 @@ GuiScraperSingle::GuiScraperSingle(Window* window, ((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""), Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER); mGameName->setColor(0x555555FF); - mGrid.setEntry(mGameName, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); + mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); mSystemName = std::make_shared( mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER); - mGrid.setEntry(mSystemName, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1}); + mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1}); // Row 3 is a spacer. // GuiScraperSearch. mSearch = std::make_shared(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1); - mGrid.setEntry(mSearch, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1}); + mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1}); mResultList = mSearch->getResultList(); @@ -80,8 +80,8 @@ GuiScraperSingle::GuiScraperSingle(Window* window, mScrollDown->setResize(0.0f, mGameName->getFont()->getLetterHeight() / 2.0f); mScrollDown->setOrigin(0.0f, 0.35f); - mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); - mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); // Buttons std::vector> buttons; @@ -109,7 +109,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window, })); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1}); + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1}); mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) { doneFunc(result); @@ -156,7 +156,7 @@ void GuiScraperSingle::onSizeChanged() mGrid.setColWidthPerc(1, 0.04f); mGrid.setSize(glm::round(mSize)); - mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBox.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); // Add some extra margins to the game name. const float newSizeX = mSize.x * 0.96f; diff --git a/es-app/src/guis/GuiSettings.cpp b/es-app/src/guis/GuiSettings.cpp index 1debd3e1a..c689adb16 100644 --- a/es-app/src/guis/GuiSettings.cpp +++ b/es-app/src/guis/GuiSettings.cpp @@ -171,7 +171,7 @@ void GuiSettings::addEditableTextComponent(const std::string label, auto bracket = std::make_shared(mWindow); bracket->setImage(":/graphics/arrow.svg"); - bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()}); + bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()}); row.addElement(bracket, false); // OK callback (apply new value to ed). diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index b1cc06e7f..ed668f333 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -56,12 +56,12 @@ namespace { - SDL_Event event{}; - Window* window{nullptr}; - int lastTime{0}; + SDL_Event event {}; + Window* window {nullptr}; + int lastTime {0}; - bool forceInputConfig{false}; - bool settingsNeedSaving{false}; + bool forceInputConfig {false}; + bool settingsNeedSaving {false}; enum loadSystemsReturnCode { LOADING_OK, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0). diff --git a/es-app/src/scrapers/GamesDBJSONScraper.cpp b/es-app/src/scrapers/GamesDBJSONScraper.cpp index 6f9e87089..9dad43f0d 100644 --- a/es-app/src/scrapers/GamesDBJSONScraper.cpp +++ b/es-app/src/scrapers/GamesDBJSONScraper.cpp @@ -37,7 +37,7 @@ namespace { TheGamesDBJSONRequestResources resources; - const std::map gamesdb_new_platformid_map{ + const std::map gamesdb_new_platformid_map { {THREEDO, "25"}, {COMMODORE_AMIGA, "4911"}, {COMMODORE_AMIGA_CD32, "4947"}, diff --git a/es-app/src/scrapers/Scraper.cpp b/es-app/src/scrapers/Scraper.cpp index e2ea46a4b..6a42da6d3 100644 --- a/es-app/src/scrapers/Scraper.cpp +++ b/es-app/src/scrapers/Scraper.cpp @@ -28,7 +28,7 @@ namespace { - const std::map scraper_request_funcs{ + const std::map scraper_request_funcs { {"thegamesdb", &thegamesdb_generate_json_scraper_requests}, {"screenscraper", &screenscraper_generate_scraper_requests}}; } diff --git a/es-app/src/scrapers/Scraper.h b/es-app/src/scrapers/Scraper.h index ac669745b..7fad5b700 100644 --- a/es-app/src/scrapers/Scraper.h +++ b/es-app/src/scrapers/Scraper.h @@ -43,11 +43,11 @@ struct ScraperSearchParams { struct ScraperSearchResult { ScraperSearchResult() : mdl(GAME_METADATA) - , scraperRequestAllowance{0} - , mediaURLFetch{NOT_STARTED} - , thumbnailDownloadStatus{NOT_STARTED} - , mediaFilesDownloadStatus{NOT_STARTED} - , savedNewMedia{false} + , scraperRequestAllowance {0} + , mediaURLFetch {NOT_STARTED} + , thumbnailDownloadStatus {NOT_STARTED} + , mediaFilesDownloadStatus {NOT_STARTED} + , savedNewMedia {false} { } diff --git a/es-app/src/scrapers/ScreenScraper.cpp b/es-app/src/scrapers/ScreenScraper.cpp index aa46c1b5f..6e0b813e9 100644 --- a/es-app/src/scrapers/ScreenScraper.cpp +++ b/es-app/src/scrapers/ScreenScraper.cpp @@ -27,7 +27,7 @@ namespace { // List of systems and their IDs from: // https://www.screenscraper.fr/api/systemesListe.php?devid=xxx&devpassword=yyy&softname=zzz&output=XML - const std::map screenscraper_platformid_map{ + const std::map screenscraper_platformid_map { {THREEDO, 29}, {COMMODORE_AMIGA, 64}, {COMMODORE_AMIGA_CD32, 130}, @@ -611,7 +611,7 @@ void ScreenScraperRequest::processMedia(ScraperSearchResult& result, } else { // Region fallback: WOR(LD), US, CUS(TOM?), JP, EU. - for (auto _region : std::vector{region, "wor", "us", "cus", "jp", "eu"}) { + for (auto _region : std::vector {region, "wor", "us", "cus", "jp", "eu"}) { if (art) break; diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index a71feec3e..a39dd3a82 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -91,8 +91,8 @@ void SystemView::populate() // No logo available? Make placeholder. if (!e.data.logo) { - glm::vec2 resolution = glm::vec2{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}; + glm::vec2 resolution = glm::vec2 {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}; glm::vec3 center = {resolution.x / 2.0f, resolution.y / 2.0f, 1.0f}; // Placeholder Image. @@ -182,7 +182,7 @@ void SystemView::populate() e.data.logo->setOrigin(0.5, 0.5); } - glm::vec2 denormalized{mCarousel.logoSize * e.data.logo->getOrigin()}; + glm::vec2 denormalized {mCarousel.logoSize * e.data.logo->getOrigin()}; glm::vec3 v = {denormalized.x, denormalized.y, 0.0f}; e.data.logo->setPosition(v + offsetLogo); if (e.data.logoPlaceholderText) @@ -462,7 +462,7 @@ void SystemView::render(const glm::mat4& parentTrans) if (size() == 0) return; // Nothing to render. - glm::mat4 trans{getTransform() * parentTrans}; + glm::mat4 trans {getTransform() * parentTrans}; if (mCarousel.legacyZIndexMode) { // Render all extras. @@ -555,18 +555,18 @@ void SystemView::getViewElements(const std::shared_ptr& theme) void SystemView::renderCarousel(const glm::mat4& trans) { // Background box behind logos. - glm::mat4 carouselTrans{trans}; + glm::mat4 carouselTrans {trans}; carouselTrans = - glm::translate(carouselTrans, glm::vec3{mCarousel.pos.x, mCarousel.pos.y, 0.0f}); + glm::translate(carouselTrans, glm::vec3 {mCarousel.pos.x, mCarousel.pos.y, 0.0f}); carouselTrans = glm::translate(carouselTrans, - glm::vec3{mCarousel.origin.x * mCarousel.size.x * -1.0f, - mCarousel.origin.y * mCarousel.size.y * -1.0f, 0.0f}); + glm::vec3 {mCarousel.origin.x * mCarousel.size.x * -1.0f, + mCarousel.origin.y * mCarousel.size.y * -1.0f, 0.0f}); - glm::vec2 clipPos{carouselTrans[3].x, carouselTrans[3].y}; - Renderer::pushClipRect(glm::ivec2{static_cast(std::round(clipPos.x)), - static_cast(std::round(clipPos.y))}, - glm::ivec2{static_cast(std::round(mCarousel.size.x)), - static_cast(std::round(mCarousel.size.y))}); + glm::vec2 clipPos {carouselTrans[3].x, carouselTrans[3].y}; + Renderer::pushClipRect(glm::ivec2 {static_cast(std::round(clipPos.x)), + static_cast(std::round(clipPos.y))}, + glm::ivec2 {static_cast(std::round(mCarousel.size.x)), + static_cast(std::round(mCarousel.size.y))}); Renderer::setMatrix(carouselTrans); Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x, mCarousel.size.y, mCarousel.color, @@ -574,7 +574,7 @@ void SystemView::renderCarousel(const glm::mat4& trans) // Draw logos. // Note: logoSpacing will also include the size of the logo itself. - glm::vec2 logoSpacing{}; + glm::vec2 logoSpacing {}; float xOff = 0.0f; float yOff = 0.0f; @@ -652,9 +652,9 @@ void SystemView::renderCarousel(const glm::mat4& trans) while (index >= static_cast(mEntries.size())) index -= static_cast(mEntries.size()); - glm::mat4 logoTrans{carouselTrans}; + glm::mat4 logoTrans {carouselTrans}; logoTrans = glm::translate( - logoTrans, glm::vec3{i * logoSpacing.x + xOff, i * logoSpacing.y + yOff, 0.0f}); + logoTrans, glm::vec3 {i * logoSpacing.x + xOff, i * logoSpacing.y + yOff, 0.0f}); float distance = i - mCamOffset; @@ -703,10 +703,10 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper) int extrasCenter = static_cast(mExtrasCamOffset); // Adding texture loading buffers depending on scrolling speed and status. - int bufferIndex{getScrollingVelocity() + 1}; + int bufferIndex {getScrollingVelocity() + 1}; - Renderer::pushClipRect(glm::ivec2{}, - glm::ivec2{static_cast(mSize.x), static_cast(mSize.y)}); + Renderer::pushClipRect(glm::ivec2 {}, + glm::ivec2 {static_cast(mSize.x), static_cast(mSize.y)}); for (int i = extrasCenter + logoBuffersLeft[bufferIndex]; i <= extrasCenter + logoBuffersRight[bufferIndex]; ++i) { @@ -718,17 +718,17 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper) // Only render selected system when not showing. if (mShowing || index == mCursor) { - glm::mat4 extrasTrans{trans}; + glm::mat4 extrasTrans {trans}; if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL) extrasTrans = glm::translate( - extrasTrans, glm::vec3{(i - mExtrasCamOffset) * mSize.x, 0.0f, 0.0f}); + extrasTrans, glm::vec3 {(i - mExtrasCamOffset) * mSize.x, 0.0f, 0.0f}); else extrasTrans = glm::translate( - extrasTrans, glm::vec3{0.0f, (i - mExtrasCamOffset) * mSize.y, 0.0f}); + extrasTrans, glm::vec3 {0.0f, (i - mExtrasCamOffset) * mSize.y, 0.0f}); Renderer::pushClipRect( - glm::ivec2{static_cast(extrasTrans[3].x), static_cast(extrasTrans[3].y)}, - glm::ivec2{static_cast(mSize.x), static_cast(mSize.y)}); + glm::ivec2 {static_cast(extrasTrans[3].x), static_cast(extrasTrans[3].y)}, + glm::ivec2 {static_cast(mSize.x), static_cast(mSize.y)}); SystemViewData data = mEntries.at(index).data; for (unsigned int j = 0; j < data.backgroundExtras.size(); ++j) { GuiComponent* extra = data.backgroundExtras[j]; diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 0ce1bd95a..cf7efdb52 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -333,7 +333,7 @@ int ViewController::getSystemId(SystemData* system) void ViewController::restoreViewPosition() { if (mPreviousView) { - glm::vec3 restorePosition{mPreviousView->getPosition()}; + glm::vec3 restorePosition {mPreviousView->getPosition()}; restorePosition.x = mWrapPreviousPositionX; mPreviousView->setPosition(restorePosition); mWrapPreviousPositionX = 0; @@ -514,9 +514,9 @@ void ViewController::goToGamelist(SystemData* system) // movements will be correct. This is accomplished by simply offsetting the X position // with the position of the first or last system plus the screen width. if (wrapFirstToLast) { - glm::vec3 currentPosition{mCurrentView->getPosition()}; + glm::vec3 currentPosition {mCurrentView->getPosition()}; mWrapPreviousPositionX = currentPosition.x; - float offsetX{getGamelistView(system)->getPosition().x}; + float offsetX {getGamelistView(system)->getPosition().x}; // This is needed to move the camera in the correct direction if there are only two systems. if (SystemData::sSystemVector.size() == 2 && mNextSystem) offsetX -= Renderer::getScreenWidth(); @@ -528,9 +528,9 @@ void ViewController::goToGamelist(SystemData* system) mWrappedViews = true; } else if (wrapLastToFirst) { - glm::vec3 currentPosition{mCurrentView->getPosition()}; + glm::vec3 currentPosition {mCurrentView->getPosition()}; mWrapPreviousPositionX = currentPosition.x; - float offsetX{getGamelistView(system)->getPosition().x}; + float offsetX {getGamelistView(system)->getPosition().x}; if (SystemData::sSystemVector.size() == 2 && !mNextSystem) offsetX += Renderer::getScreenWidth(); else @@ -584,7 +584,7 @@ void ViewController::playViewTransition(bool instant) { mCancelledTransition = false; - glm::vec3 target{}; + glm::vec3 target {}; if (mCurrentView) target = mCurrentView->getPosition(); @@ -593,7 +593,7 @@ void ViewController::playViewTransition(bool instant) if (target == static_cast(-mCamera[3]) && !isAnimationPlaying(0)) return; - std::string transition_style{Settings::getInstance()->getString("TransitionStyle")}; + std::string transition_style {Settings::getInstance()->getString("TransitionStyle")}; if (instant || transition_style == "instant") { setAnimation(new LambdaAnimation( @@ -906,14 +906,14 @@ void ViewController::update(int deltaTime) void ViewController::render(const glm::mat4& parentTrans) { - glm::mat4 trans{mCamera * parentTrans}; - glm::mat4 transInverse{glm::inverse(trans)}; + glm::mat4 trans {mCamera * parentTrans}; + glm::mat4 transInverse {glm::inverse(trans)}; // Camera position, position + size. - glm::vec3 viewStart{transInverse[3]}; - glm::vec3 viewEnd{std::fabs(trans[3].x) + static_cast(Renderer::getScreenWidth()), - std::fabs(trans[3].y) + static_cast(Renderer::getScreenHeight()), - 0.0f}; + glm::vec3 viewStart {transInverse[3]}; + glm::vec3 viewEnd {std::fabs(trans[3].x) + static_cast(Renderer::getScreenWidth()), + std::fabs(trans[3].y) + static_cast(Renderer::getScreenHeight()), + 0.0f}; // Keep track of UI mode changes. UIModeController::getInstance()->monitorUIMode(); @@ -928,9 +928,9 @@ void ViewController::render(const glm::mat4& parentTrans) // Same thing as for the system view, limit the rendering only to what needs to be drawn. if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) { // Clipping. - glm::vec3 guiStart{it->second->getPosition()}; - glm::vec3 guiEnd{it->second->getPosition() + - glm::vec3{it->second->getSize().x, it->second->getSize().y, 0.0f}}; + glm::vec3 guiStart {it->second->getPosition()}; + glm::vec3 guiEnd {it->second->getPosition() + + glm::vec3 {it->second->getSize().x, it->second->getSize().y, 0.0f}}; if (guiEnd.x >= viewStart.x && guiEnd.y >= viewStart.y && guiStart.x <= viewEnd.x && guiStart.y <= viewEnd.y) diff --git a/es-app/src/views/gamelist/DetailedGamelistView.cpp b/es-app/src/views/gamelist/DetailedGamelistView.cpp index 3503fd619..88be4e63a 100644 --- a/es-app/src/views/gamelist/DetailedGamelistView.cpp +++ b/es-app/src/views/gamelist/DetailedGamelistView.cpp @@ -180,7 +180,7 @@ void DetailedGamelistView::onThemeChanged(const std::shared_ptr& them mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT); // If there is no position defined in the theme for gamelistInfo, then hide it. - if (mGamelistInfo.getPosition() == glm::vec3{}) + if (mGamelistInfo.getPosition() == glm::vec3 {}) mGamelistInfo.setVisible(false); else mGamelistInfo.setVisible(true); @@ -195,21 +195,21 @@ void DetailedGamelistView::initMDLabels() const unsigned int colCount = 2; const unsigned int rowCount = static_cast(components.size() / 2); - glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; + glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; const float colSize = (mSize.x * 0.48f) / colCount; 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{}; + glm::vec3 pos {}; if (row == 0) { - pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f}; + pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f}; } else { // Work from the last component. GuiComponent* lc = components[i - 1]; - pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f}; + pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f}; } components[i]->setFont(Font::get(FONT_SIZE_SMALL)); @@ -239,7 +239,7 @@ void DetailedGamelistView::initMDValues() for (unsigned int i = 0; i < labels.size(); ++i) { const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f; values[i]->setPosition(labels[i]->getPosition() + - glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f}); + 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); diff --git a/es-app/src/views/gamelist/GridGamelistView.cpp b/es-app/src/views/gamelist/GridGamelistView.cpp index 1f7bc9e3c..f2ee53e75 100644 --- a/es-app/src/views/gamelist/GridGamelistView.cpp +++ b/es-app/src/views/gamelist/GridGamelistView.cpp @@ -278,7 +278,7 @@ void GridGamelistView::onThemeChanged(const std::shared_ptr& theme) mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT); // If there is no position defined in the theme for gamelistInfo, then hide it. - if (mGamelistInfo.getPosition() == glm::vec3{}) + if (mGamelistInfo.getPosition() == glm::vec3 {}) mGamelistInfo.setVisible(false); else mGamelistInfo.setVisible(true); @@ -303,21 +303,21 @@ void GridGamelistView::initMDLabels() const unsigned int colCount = 2; const unsigned int rowCount = static_cast(components.size() / 2); - glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; + glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; const float colSize = (mSize.x * 0.48f) / colCount; 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{}; + glm::vec3 pos {}; if (row == 0) { - pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f}; + pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f}; } else { // Work from the last component. GuiComponent* lc = components[i - 1]; - pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f}; + pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f}; } components[i]->setFont(Font::get(FONT_SIZE_SMALL)); @@ -347,7 +347,7 @@ void GridGamelistView::initMDValues() for (unsigned int i = 0; i < labels.size(); ++i) { const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f; values[i]->setPosition(labels[i]->getPosition() + - glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f}); + 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); diff --git a/es-app/src/views/gamelist/IGamelistView.cpp b/es-app/src/views/gamelist/IGamelistView.cpp index a63489989..8f4309cd6 100644 --- a/es-app/src/views/gamelist/IGamelistView.cpp +++ b/es-app/src/views/gamelist/IGamelistView.cpp @@ -61,15 +61,15 @@ HelpStyle IGamelistView::getHelpStyle() void IGamelistView::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; float scaleX = trans[0].x; float scaleY = trans[1].y; - glm::ivec2 pos{static_cast(std::round(trans[3].x)), - static_cast(std::round(trans[3].y))}; - glm::ivec2 size{static_cast(std::round(mSize.x * scaleX)), - static_cast(std::round(mSize.y * scaleY))}; + glm::ivec2 pos {static_cast(std::round(trans[3].x)), + static_cast(std::round(trans[3].y))}; + glm::ivec2 size {static_cast(std::round(mSize.x * scaleX)), + static_cast(std::round(mSize.y * scaleY))}; Renderer::pushClipRect(pos, size); renderChildren(trans); diff --git a/es-app/src/views/gamelist/IGamelistView.h b/es-app/src/views/gamelist/IGamelistView.h index 1a1d4d396..003ef563c 100644 --- a/es-app/src/views/gamelist/IGamelistView.h +++ b/es-app/src/views/gamelist/IGamelistView.h @@ -32,7 +32,7 @@ public: void setTheme(const std::shared_ptr& theme); const std::shared_ptr getTheme() const { return mTheme; } - virtual void preloadGamelist(){}; + virtual void preloadGamelist() {}; virtual FileData* getCursor() = 0; virtual void setCursor(FileData*) = 0; diff --git a/es-app/src/views/gamelist/VideoGamelistView.cpp b/es-app/src/views/gamelist/VideoGamelistView.cpp index f6c76bc5b..fe693c2b8 100644 --- a/es-app/src/views/gamelist/VideoGamelistView.cpp +++ b/es-app/src/views/gamelist/VideoGamelistView.cpp @@ -190,7 +190,7 @@ void VideoGamelistView::onThemeChanged(const std::shared_ptr& theme) mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT); // If there is no position defined in the theme for gamelistInfo, then hide it. - if (mGamelistInfo.getPosition() == glm::vec3{}) + if (mGamelistInfo.getPosition() == glm::vec3 {}) mGamelistInfo.setVisible(false); else mGamelistInfo.setVisible(true); @@ -205,21 +205,21 @@ void VideoGamelistView::initMDLabels() const unsigned int colCount = 2; const unsigned int rowCount = static_cast(components.size() / 2); - glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; + glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f}; const float colSize = (mSize.x * 0.48f) / colCount; 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{}; + glm::vec3 pos {}; if (row == 0) { - pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f}; + pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f}; } else { // Work from the last component. GuiComponent* lc = components[i - 1]; - pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f}; + pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f}; } components[i]->setFont(Font::get(FONT_SIZE_SMALL)); @@ -249,7 +249,7 @@ void VideoGamelistView::initMDValues() for (unsigned int i = 0; i < labels.size(); ++i) { const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f; values[i]->setPosition(labels[i]->getPosition() + - glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f}); + 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); diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 7221cf4d8..b9450fac6 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -83,7 +83,7 @@ void GuiComponent::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; renderChildren(trans); } @@ -98,7 +98,7 @@ void GuiComponent::setPosition(float x, float y, float z) if (mPosition.x == x && mPosition.y == y && mPosition.z == z) return; - mPosition = glm::vec3{x, y, z}; + mPosition = glm::vec3 {x, y, z}; onPositionChanged(); } @@ -107,7 +107,7 @@ void GuiComponent::setOrigin(float x, float y) if (mOrigin.x == x && mOrigin.y == y) return; - mOrigin = glm::vec2{x, y}; + mOrigin = glm::vec2 {x, y}; onOriginChanged(); } @@ -116,14 +116,14 @@ void GuiComponent::setSize(const float w, const float h) if (mSize.x == w && mSize.y == h) return; - mSize = glm::vec2{w, h}; + mSize = glm::vec2 {w, h}; onSizeChanged(); } glm::vec2 GuiComponent::getCenter() const { - return glm::vec2{mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f, - mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 2.0f}; + return glm::vec2 {mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f, + mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 2.0f}; } void GuiComponent::addChild(GuiComponent* cmp) @@ -189,27 +189,27 @@ const glm::mat4& GuiComponent::getTransform() mTransform = glm::translate(mTransform, mPosition); if (mScale != 1.0f) - mTransform = glm::scale(mTransform, glm::vec3{mScale}); + mTransform = glm::scale(mTransform, glm::vec3 {mScale}); if (mRotation != 0.0f) { // Calculate offset as difference between origin and rotation origin. - glm::vec2 rotationSize{getRotationSize()}; - float xOff{(mOrigin.x - mRotationOrigin.x) * rotationSize.x}; - float yOff{(mOrigin.y - mRotationOrigin.y) * rotationSize.y}; + glm::vec2 rotationSize {getRotationSize()}; + float xOff {(mOrigin.x - mRotationOrigin.x) * rotationSize.x}; + float yOff {(mOrigin.y - mRotationOrigin.y) * rotationSize.y}; // Transform to offset point. if (xOff != 0.0f || yOff != 0.0f) - mTransform = glm::translate(mTransform, glm::vec3{xOff * -1.0f, yOff * -1.0f, 0.0f}); + mTransform = glm::translate(mTransform, glm::vec3 {xOff * -1.0f, yOff * -1.0f, 0.0f}); // Apply rotation transform. - mTransform = glm::rotate(mTransform, mRotation, glm::vec3{0.0f, 0.0f, 1.0f}); + mTransform = glm::rotate(mTransform, mRotation, glm::vec3 {0.0f, 0.0f, 1.0f}); // Transform back to original point. if (xOff != 0.0f || yOff != 0.0f) - mTransform = glm::translate(mTransform, glm::vec3{xOff, yOff, 0.0f}); + mTransform = glm::translate(mTransform, glm::vec3 {xOff, yOff, 0.0f}); } mTransform = glm::translate( - mTransform, glm::vec3{mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f}); + mTransform, glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f}); return mTransform; } @@ -314,9 +314,9 @@ void GuiComponent::applyTheme(const std::shared_ptr& theme, const std::string& element, unsigned int properties) { - glm::vec2 scale{getParent() ? getParent()->getSize() : - glm::vec2{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}}; + glm::vec2 scale {getParent() ? getParent()->getSize() : + glm::vec2 {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}}; const ThemeData::ThemeElement* elem = theme->getElement(view, element, ""); if (!elem) @@ -324,8 +324,8 @@ void GuiComponent::applyTheme(const std::shared_ptr& theme, using namespace ThemeFlags; if (properties & POSITION && elem->has("pos")) { - glm::vec2 denormalized{elem->get("pos") * scale}; - setPosition(glm::vec3{denormalized.x, denormalized.y, 0.0f}); + glm::vec2 denormalized {elem->get("pos") * scale}; + setPosition(glm::vec3 {denormalized.x, denormalized.y, 0.0f}); } if (properties & ThemeFlags::SIZE && elem->has("size")) diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index d135115ed..bf691c4f1 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -82,7 +82,7 @@ public: // (e.g. (0, 0) is top left, (0.5, 0.5) is the center.) void setRotationOrigin(float originX, float originY) { - mRotationOrigin = glm::vec2{originX, originY}; + mRotationOrigin = glm::vec2 {originX, originY}; } void setRotationOrigin(glm::vec2 origin) { setRotationOrigin(origin.x, origin.y); } @@ -204,7 +204,7 @@ public: virtual void onUnpauseVideo(); virtual bool isVideoPaused() { return false; } // For Lottie animations. - virtual void resetFileAnimation(){}; + virtual void resetFileAnimation() {}; virtual void onScreensaverActivate(); virtual void onScreensaverDeactivate(); diff --git a/es-core/src/HelpStyle.cpp b/es-core/src/HelpStyle.cpp index 3d979a48f..fd3815b79 100644 --- a/es-core/src/HelpStyle.cpp +++ b/es-core/src/HelpStyle.cpp @@ -14,8 +14,8 @@ HelpStyle::HelpStyle() { position = - glm::vec2{Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f}; - origin = glm::vec2{}; + glm::vec2 {Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f}; + origin = glm::vec2 {}; textColor = 0x777777FF; textColorDimmed = 0x777777FF; iconColor = 0x777777FF; @@ -38,8 +38,8 @@ void HelpStyle::applyTheme(const std::shared_ptr& theme, const std::s if (elem->has("pos")) position = elem->get("pos") * - glm::vec2{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}; + glm::vec2 {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}; if (elem->has("origin")) origin = elem->get("origin"); diff --git a/es-core/src/Log.h b/es-core/src/Log.h index b6180333a..103b799c8 100644 --- a/es-core/src/Log.h +++ b/es-core/src/Log.h @@ -52,11 +52,11 @@ protected: std::ostringstream mOutStringStream; private: - std::map mLogLevelMap{// Log level indicators. - {LogError, "Error"}, - {LogWarning, "Warn"}, - {LogInfo, "Info"}, - {LogDebug, "Debug"}}; + std::map mLogLevelMap {// Log level indicators. + {LogError, "Error"}, + {LogWarning, "Warn"}, + {LogInfo, "Info"}, + {LogDebug, "Debug"}}; inline static std::ofstream sFile; inline static LogLevel sReportingLevel = LogInfo; LogLevel mMessageLevel; diff --git a/es-core/src/Settings.cpp b/es-core/src/Settings.cpp index 115408074..e19b7a7d3 100644 --- a/es-core/src/Settings.cpp +++ b/es-core/src/Settings.cpp @@ -24,7 +24,7 @@ namespace // the in-program settings menu. Most can be set using command-line arguments, // but some are debug flags that are either hardcoded or set by internal debug // functions. - std::vector settingsSkipSaving{ + std::vector settingsSkipSaving { // clang-format off // These options can be set using command-line arguments: "WindowWidth", // Set via --resolution [width] [height] diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 888723599..3ef9fb5a4 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -21,212 +21,213 @@ #include #include -std::vector ThemeData::sSupportedViews{{"all"}, {"system"}, {"basic"}, - {"detailed"}, {"grid"}, {"video"}}; -std::vector ThemeData::sSupportedFeatures{ +std::vector ThemeData::sSupportedViews {{"all"}, {"system"}, {"basic"}, + {"detailed"}, {"grid"}, {"video"}}; +std::vector ThemeData::sSupportedFeatures { {"navigationsounds"}, {"video"}, {"carousel"}, {"z-index"}, {"visible"}}; -std::map> ThemeData::sElementMap{ - {"image", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"maxSize", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"path", PATH}, - {"default", PATH}, - {"tile", BOOLEAN}, - {"color", COLOR}, - {"colorEnd", COLOR}, - {"gradientType", STRING}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"imagegrid", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"margin", NORMALIZED_PAIR}, - {"padding", NORMALIZED_RECT}, - {"autoLayout", NORMALIZED_PAIR}, - {"autoLayoutSelectedZoom", FLOAT}, - {"gameImage", PATH}, - {"folderImage", PATH}, - {"imageSource", STRING}, - {"scrollDirection", STRING}, - {"centerSelection", BOOLEAN}, - {"scrollLoop", BOOLEAN}, - {"animate", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"gridtile", - {{"size", NORMALIZED_PAIR}, - {"padding", NORMALIZED_PAIR}, - {"imageColor", COLOR}, - {"backgroundImage", PATH}, - {"backgroundCornerSize", NORMALIZED_PAIR}, - {"backgroundColor", COLOR}, - {"backgroundCenterColor", COLOR}, - {"backgroundEdgeColor", COLOR}}}, - {"text", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"text", STRING}, - {"backgroundColor", COLOR}, - {"fontPath", PATH}, - {"fontSize", FLOAT}, - {"color", COLOR}, - {"alignment", STRING}, - {"forceUppercase", BOOLEAN}, - {"lineSpacing", FLOAT}, - {"value", STRING}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"textlist", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"selectorHeight", FLOAT}, - {"selectorOffsetY", FLOAT}, - {"selectorColor", COLOR}, - {"selectorColorEnd", COLOR}, - {"selectorGradientType", STRING}, - {"selectorImagePath", PATH}, - {"selectorImageTile", BOOLEAN}, - {"selectedColor", COLOR}, - {"primaryColor", COLOR}, - {"secondaryColor", COLOR}, - {"fontPath", PATH}, - {"fontSize", FLOAT}, - {"scrollSound", PATH}, // For backward compatibility with old themes. - {"alignment", STRING}, - {"horizontalMargin", FLOAT}, - {"forceUppercase", BOOLEAN}, - {"lineSpacing", FLOAT}, - {"zIndex", FLOAT}}}, - {"container", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"ninepatch", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"path", PATH}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"datetime", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"backgroundColor", COLOR}, - {"fontPath", PATH}, - {"fontSize", FLOAT}, - {"color", COLOR}, - {"alignment", STRING}, - {"forceUppercase", BOOLEAN}, - {"lineSpacing", FLOAT}, - {"value", STRING}, - {"format", STRING}, - {"displayRelative", BOOLEAN}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"rating", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"color", COLOR}, - {"filledPath", PATH}, - {"unfilledPath", PATH}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"animation", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"path", PATH}, - {"speed", FLOAT}, - {"direction", STRING}, - {"keepAspectRatio", BOOLEAN}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"badges", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"alignment", STRING}, - {"direction", STRING}, - {"lines", FLOAT}, - {"itemsPerLine", FLOAT}, - {"itemMargin", NORMALIZED_PAIR}, - {"slots", STRING}, - {"controllerPos", NORMALIZED_PAIR}, - {"controllerSize", FLOAT}, - {"customBadgeIcon", PATH}, - {"customControllerIcon", PATH}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}}}, - {"sound", {{"path", PATH}}}, - {"helpsystem", - {{"pos", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"textColor", COLOR}, - {"textColorDimmed", COLOR}, - {"iconColor", COLOR}, - {"iconColorDimmed", COLOR}, - {"fontPath", PATH}, - {"fontSize", FLOAT}, - {"entrySpacing", FLOAT}, - {"iconTextSpacing", FLOAT}, - {"textStyle", STRING}, - {"customButtonIcon", PATH}}}, - {"navigationsounds", - {{"systembrowseSound", PATH}, - {"quicksysselectSound", PATH}, - {"selectSound", PATH}, - {"backSound", PATH}, - {"scrollSound", PATH}, - {"favoriteSound", PATH}, - {"launchSound", PATH}}}, - {"video", - {{"pos", NORMALIZED_PAIR}, - {"size", NORMALIZED_PAIR}, - {"maxSize", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"rotation", FLOAT}, - {"rotationOrigin", NORMALIZED_PAIR}, - {"default", PATH}, - {"delay", FLOAT}, - {"visible", BOOLEAN}, - {"zIndex", FLOAT}, - {"showSnapshotNoVideo", BOOLEAN}, - {"showSnapshotDelay", BOOLEAN}}}, - {"carousel", - {{"type", STRING}, - {"size", NORMALIZED_PAIR}, - {"pos", NORMALIZED_PAIR}, - {"origin", NORMALIZED_PAIR}, - {"color", COLOR}, - {"colorEnd", COLOR}, - {"gradientType", STRING}, - {"logoScale", FLOAT}, - {"logoRotation", FLOAT}, - {"logoRotationOrigin", NORMALIZED_PAIR}, - {"logoSize", NORMALIZED_PAIR}, - {"logoAlignment", STRING}, - {"maxLogoCount", FLOAT}, - {"zIndex", FLOAT}, - {"legacyZIndexMode", STRING}}}}; +std::map> + ThemeData::sElementMap // Line break. + {{"image", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"maxSize", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"path", PATH}, + {"default", PATH}, + {"tile", BOOLEAN}, + {"color", COLOR}, + {"colorEnd", COLOR}, + {"gradientType", STRING}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"imagegrid", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"margin", NORMALIZED_PAIR}, + {"padding", NORMALIZED_RECT}, + {"autoLayout", NORMALIZED_PAIR}, + {"autoLayoutSelectedZoom", FLOAT}, + {"gameImage", PATH}, + {"folderImage", PATH}, + {"imageSource", STRING}, + {"scrollDirection", STRING}, + {"centerSelection", BOOLEAN}, + {"scrollLoop", BOOLEAN}, + {"animate", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"gridtile", + {{"size", NORMALIZED_PAIR}, + {"padding", NORMALIZED_PAIR}, + {"imageColor", COLOR}, + {"backgroundImage", PATH}, + {"backgroundCornerSize", NORMALIZED_PAIR}, + {"backgroundColor", COLOR}, + {"backgroundCenterColor", COLOR}, + {"backgroundEdgeColor", COLOR}}}, + {"text", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"text", STRING}, + {"backgroundColor", COLOR}, + {"fontPath", PATH}, + {"fontSize", FLOAT}, + {"color", COLOR}, + {"alignment", STRING}, + {"forceUppercase", BOOLEAN}, + {"lineSpacing", FLOAT}, + {"value", STRING}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"textlist", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"selectorHeight", FLOAT}, + {"selectorOffsetY", FLOAT}, + {"selectorColor", COLOR}, + {"selectorColorEnd", COLOR}, + {"selectorGradientType", STRING}, + {"selectorImagePath", PATH}, + {"selectorImageTile", BOOLEAN}, + {"selectedColor", COLOR}, + {"primaryColor", COLOR}, + {"secondaryColor", COLOR}, + {"fontPath", PATH}, + {"fontSize", FLOAT}, + {"scrollSound", PATH}, // For backward compatibility with old themes. + {"alignment", STRING}, + {"horizontalMargin", FLOAT}, + {"forceUppercase", BOOLEAN}, + {"lineSpacing", FLOAT}, + {"zIndex", FLOAT}}}, + {"container", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"ninepatch", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"path", PATH}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"datetime", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"backgroundColor", COLOR}, + {"fontPath", PATH}, + {"fontSize", FLOAT}, + {"color", COLOR}, + {"alignment", STRING}, + {"forceUppercase", BOOLEAN}, + {"lineSpacing", FLOAT}, + {"value", STRING}, + {"format", STRING}, + {"displayRelative", BOOLEAN}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"rating", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"color", COLOR}, + {"filledPath", PATH}, + {"unfilledPath", PATH}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"animation", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"path", PATH}, + {"speed", FLOAT}, + {"direction", STRING}, + {"keepAspectRatio", BOOLEAN}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"badges", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"alignment", STRING}, + {"direction", STRING}, + {"lines", FLOAT}, + {"itemsPerLine", FLOAT}, + {"itemMargin", NORMALIZED_PAIR}, + {"slots", STRING}, + {"controllerPos", NORMALIZED_PAIR}, + {"controllerSize", FLOAT}, + {"customBadgeIcon", PATH}, + {"customControllerIcon", PATH}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}}}, + {"sound", {{"path", PATH}}}, + {"helpsystem", + {{"pos", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"textColor", COLOR}, + {"textColorDimmed", COLOR}, + {"iconColor", COLOR}, + {"iconColorDimmed", COLOR}, + {"fontPath", PATH}, + {"fontSize", FLOAT}, + {"entrySpacing", FLOAT}, + {"iconTextSpacing", FLOAT}, + {"textStyle", STRING}, + {"customButtonIcon", PATH}}}, + {"navigationsounds", + {{"systembrowseSound", PATH}, + {"quicksysselectSound", PATH}, + {"selectSound", PATH}, + {"backSound", PATH}, + {"scrollSound", PATH}, + {"favoriteSound", PATH}, + {"launchSound", PATH}}}, + {"video", + {{"pos", NORMALIZED_PAIR}, + {"size", NORMALIZED_PAIR}, + {"maxSize", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"rotation", FLOAT}, + {"rotationOrigin", NORMALIZED_PAIR}, + {"default", PATH}, + {"delay", FLOAT}, + {"visible", BOOLEAN}, + {"zIndex", FLOAT}, + {"showSnapshotNoVideo", BOOLEAN}, + {"showSnapshotDelay", BOOLEAN}}}, + {"carousel", + {{"type", STRING}, + {"size", NORMALIZED_PAIR}, + {"pos", NORMALIZED_PAIR}, + {"origin", NORMALIZED_PAIR}, + {"color", COLOR}, + {"colorEnd", COLOR}, + {"gradientType", STRING}, + {"logoScale", FLOAT}, + {"logoRotation", FLOAT}, + {"logoRotationOrigin", NORMALIZED_PAIR}, + {"logoSize", NORMALIZED_PAIR}, + {"logoAlignment", STRING}, + {"maxLogoCount", FLOAT}, + {"zIndex", FLOAT}, + {"legacyZIndexMode", STRING}}}}; #define MINIMUM_THEME_FORMAT_VERSION 3 #define CURRENT_THEME_FORMAT_VERSION 7 @@ -488,16 +489,16 @@ void ThemeData::parseElement(const pugi::xml_node& root, auto splits = Utils::String::delimitedStringToVector(str, " "); if (splits.size() == 2) { - val = glm::vec4{static_cast(atof(splits.at(0).c_str())), - static_cast(atof(splits.at(1).c_str())), - static_cast(atof(splits.at(0).c_str())), - static_cast(atof(splits.at(1).c_str()))}; + val = glm::vec4 {static_cast(atof(splits.at(0).c_str())), + static_cast(atof(splits.at(1).c_str())), + static_cast(atof(splits.at(0).c_str())), + static_cast(atof(splits.at(1).c_str()))}; } else if (splits.size() == 4) { - val = glm::vec4{static_cast(atof(splits.at(0).c_str())), - static_cast(atof(splits.at(1).c_str())), - static_cast(atof(splits.at(2).c_str())), - static_cast(atof(splits.at(3).c_str()))}; + val = glm::vec4 {static_cast(atof(splits.at(0).c_str())), + static_cast(atof(splits.at(1).c_str())), + static_cast(atof(splits.at(2).c_str())), + static_cast(atof(splits.at(3).c_str()))}; } element.properties[node.name()] = val; @@ -509,11 +510,11 @@ void ThemeData::parseElement(const pugi::xml_node& root, throw error << "invalid normalized pair (property \"" << node.name() << "\", value \"" << str.c_str() << "\")"; - std::string first{str.substr(0, divider)}; - std::string second{str.substr(divider, std::string::npos)}; + std::string first {str.substr(0, divider)}; + std::string second {str.substr(divider, std::string::npos)}; - glm::vec2 val{static_cast(atof(first.c_str())), - static_cast(atof(second.c_str()))}; + glm::vec2 val {static_cast(atof(first.c_str())), + static_cast(atof(second.c_str()))}; element.properties[node.name()] = val; break; diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index 9bca793c3..971e50dd4 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -106,8 +106,8 @@ public: void operator=(const glm::vec4& value) { r = value; - const glm::vec4 initVector{value}; - v = glm::vec2{initVector.x, initVector.y}; + const glm::vec4 initVector {value}; + v = glm::vec2 {initVector.x, initVector.y}; } void operator=(const glm::vec2& value) { v = value; } void operator=(const std::string& value) { s = value; } diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index f7679096f..e49a51adf 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -45,8 +45,8 @@ Window::Window() noexcept , mAllowFileAnimation(true) , mCachedBackground(false) , mInvalidatedCachedBackground(false) - , mInitiateCacheTimer{false} - , mInvalidateCacheTimer{0} + , mInitiateCacheTimer {false} + , mInvalidateCacheTimer {0} , mVideoPlayerCount(0) , mTopScale(0.5) , mChangedThemeSet(false) @@ -253,7 +253,7 @@ void Window::input(InputConfig* config, Input input) // from the submenu. mTopScale = 1.0f; GuiComponent* menu = mGuiStack.back(); - glm::vec2 menuCenter{menu->getCenter()}; + glm::vec2 menuCenter {menu->getCenter()}; menu->setOrigin(0.5f, 0.5f); menu->setPosition(menuCenter.x, menuCenter.y, 0.0f); menu->setScale(1.0f); @@ -409,7 +409,7 @@ void Window::render() mInitiateCacheTimer = false; } - glm::mat4 trans{Renderer::getIdentity()}; + glm::mat4 trans {Renderer::getIdentity()}; mRenderedHelpPrompts = false; @@ -531,7 +531,7 @@ void Window::render() if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") { if (mTopScale < 1.0f) { mTopScale = glm::clamp(mTopScale + 0.07f, 0.0f, 1.0f); - glm::vec2 topCenter{top->getCenter()}; + glm::vec2 topCenter {top->getCenter()}; top->setOrigin(0.5f, 0.5f); top->setPosition(topCenter.x, topCenter.y, 0.0f); top->setScale(mTopScale); @@ -554,7 +554,7 @@ void Window::render() static_cast(Renderer::getScreenHeight()), 0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity); - glm::vec2 offset{mListScrollFont->sizeText(mListScrollText)}; + glm::vec2 offset {mListScrollFont->sizeText(mListScrollText)}; offset.x = (Renderer::getScreenWidth() - offset.x) * 0.5f; offset.y = (Renderer::getScreenHeight() - offset.y) * 0.5f; @@ -613,7 +613,7 @@ void Window::render() void Window::renderLoadingScreen(std::string text) { - glm::mat4 trans{Renderer::getIdentity()}; + glm::mat4 trans {Renderer::getIdentity()}; Renderer::setMatrix(trans); Renderer::drawRect(0.0f, 0.0f, static_cast(Renderer::getScreenWidth()), static_cast(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF); @@ -630,7 +630,7 @@ void Window::renderLoadingScreen(std::string text) float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x) / 2.0f); float y = std::round(Renderer::getScreenHeight() * 0.835f); - trans = glm::translate(trans, glm::vec3{x, y, 0.0f}); + trans = glm::translate(trans, glm::vec3 {x, y, 0.0f}); Renderer::setMatrix(trans); font->renderTextCache(cache); delete cache; diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index 91acf5ab0..2d0655671 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -62,11 +62,11 @@ namespace } // namespace BadgeComponent::BadgeComponent(Window* window) - : GuiComponent{window} - , mFlexboxItems{} - , mFlexboxComponent{window, mFlexboxItems} - , mBadgeTypes{{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER, - SLOT_ALTEMULATOR}} + : GuiComponent {window} + , mFlexboxItems {} + , mFlexboxComponent {window, mFlexboxItems} + , mBadgeTypes {{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER, + SLOT_ALTEMULATOR}} { mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg"; mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg"; @@ -190,12 +190,12 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, using namespace ThemeFlags; - const ThemeData::ThemeElement* elem{theme->getElement(view, element, "badges")}; + const ThemeData::ThemeElement* elem {theme->getElement(view, element, "badges")}; if (!elem) return; if (elem->has("alignment")) { - const std::string alignment{elem->get("alignment")}; + const std::string alignment {elem->get("alignment")}; if (alignment != "left" && alignment != "right") { LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" << alignment << "\""; @@ -206,7 +206,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, } if (elem->has("direction")) { - const std::string direction{elem->get("direction")}; + const std::string direction {elem->get("direction")}; if (direction != "row" && direction != "column") { LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" << direction << "\""; @@ -217,7 +217,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, } if (elem->has("lines")) { - const float lines{elem->get("lines")}; + const float lines {elem->get("lines")}; if (lines < 1.0f || lines > 10.0f) { LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" << lines << "\""; @@ -228,7 +228,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, } if (elem->has("itemsPerLine")) { - const float itemsPerLine{elem->get("itemsPerLine")}; + const float itemsPerLine {elem->get("itemsPerLine")}; if (itemsPerLine < 1.0f || itemsPerLine > 10.0f) { LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, set to \"" @@ -295,10 +295,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, FlexboxComponent::FlexboxItem item; item.label = slot; - ImageComponent badgeImage{mWindow, false, false}; + ImageComponent badgeImage {mWindow, false, false}; badgeImage.setImage(mBadgeIcons[slot]); item.baseImage = badgeImage; - item.overlayImage = ImageComponent{mWindow}; + item.overlayImage = ImageComponent {mWindow}; mFlexboxItems.emplace_back(std::move(item)); } diff --git a/es-core/src/components/BusyComponent.cpp b/es-core/src/components/BusyComponent.cpp index 4c66ac453..d6b819fc6 100644 --- a/es-core/src/components/BusyComponent.cpp +++ b/es-core/src/components/BusyComponent.cpp @@ -25,7 +25,7 @@ const AnimationDef BUSY_ANIMATION_DEF = {BUSY_ANIMATION_FRAMES, 4, true}; BusyComponent::BusyComponent(Window* window) : GuiComponent(window) , mBackground(window, ":/graphics/frame.png") - , mGrid(window, glm::ivec2{5, 3}) + , mGrid(window, glm::ivec2 {5, 3}) { mAnimation = std::make_shared(mWindow); mAnimation->load(&BUSY_ANIMATION_DEF); @@ -33,8 +33,8 @@ BusyComponent::BusyComponent(Window* window) 0x777777FF); // Col 0 = animation, col 1 = spacer, col 2 = text. - mGrid.setEntry(mAnimation, glm::ivec2{1, 1}, false, true); - mGrid.setEntry(mText, glm::ivec2{3, 1}, false, true); + mGrid.setEntry(mAnimation, glm::ivec2 {1, 1}, false, true); + mGrid.setEntry(mText, glm::ivec2 {3, 1}, false, true); addChild(&mBackground); addChild(&mGrid); @@ -60,9 +60,9 @@ void BusyComponent::onSizeChanged() mBackground.setCornerSize( {16.0f * Renderer::getScreenWidthModifier(), 16.0f * Renderer::getScreenHeightModifier()}); - mBackground.fitTo(glm::vec2{mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3), - textHeight + (2.0f * Renderer::getScreenHeightModifier())}, - mAnimation->getPosition(), glm::vec2{}); + mBackground.fitTo(glm::vec2 {mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3), + textHeight + (2.0f * Renderer::getScreenHeightModifier())}, + mAnimation->getPosition(), glm::vec2 {}); } void BusyComponent::reset() diff --git a/es-core/src/components/ButtonComponent.cpp b/es-core/src/components/ButtonComponent.cpp index 7bbad8a5a..e9858a061 100644 --- a/es-core/src/components/ButtonComponent.cpp +++ b/es-core/src/components/ButtonComponent.cpp @@ -18,17 +18,17 @@ ButtonComponent::ButtonComponent(Window* window, const std::function& func, bool upperCase, bool flatStyle) - : GuiComponent{window} - , mBox{window, ":/graphics/button.svg"} - , mFont{Font::get(FONT_SIZE_MEDIUM)} - , mPadding{{}} - , mFocused{false} - , mEnabled{true} - , mFlatStyle{flatStyle} - , mTextColorFocused{0xFFFFFFFF} - , mTextColorUnfocused{0x777777FF} - , mFlatColorFocused{0x878787FF} - , mFlatColorUnfocused{0x60606025} + : GuiComponent {window} + , mBox {window, ":/graphics/button.svg"} + , mFont {Font::get(FONT_SIZE_MEDIUM)} + , mPadding {{}} + , mFocused {false} + , mEnabled {true} + , mFlatStyle {flatStyle} + , mTextColorFocused {0xFFFFFFFF} + , mTextColorUnfocused {0x777777FF} + , mFlatColorFocused {0x878787FF} + , mFlatColorUnfocused {0x60606025} { mBox.setSharpCorners(true); @@ -46,9 +46,9 @@ void ButtonComponent::onSizeChanged() auto cornerSize = mBox.getCornerSize(); - mBox.fitTo(glm::vec2{mSize.x - mPadding.x - mPadding.z, mSize.y - mPadding.y - mPadding.w}, - glm::vec3{mPadding.x, mPadding.y, 0.0f}, - glm::vec2{-cornerSize.x * 2.0f, -cornerSize.y * 2.0f}); + mBox.fitTo(glm::vec2 {mSize.x - mPadding.x - mPadding.z, mSize.y - mPadding.y - mPadding.w}, + glm::vec3 {mPadding.x, mPadding.y, 0.0f}, + glm::vec2 {-cornerSize.x * 2.0f, -cornerSize.y * 2.0f}); } void ButtonComponent::onFocusGained() @@ -110,7 +110,7 @@ bool ButtonComponent::input(InputConfig* config, Input input) void ButtonComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; if (mFlatStyle) { if (mFocused) { @@ -131,8 +131,8 @@ void ButtonComponent::render(const glm::mat4& parentTrans) } if (mTextCache) { - glm::vec3 centerOffset{(mSize.x - mTextCache->metrics.size.x) / 2.0f, - (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f}; + glm::vec3 centerOffset {(mSize.x - mTextCache->metrics.size.x) / 2.0f, + (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f}; trans = glm::translate(trans, centerOffset); if (Settings::getInstance()->getBool("DebugText")) { diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index 61095efc0..39acfb3e6 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -136,17 +136,17 @@ bool ComponentGrid::removeEntry(const std::shared_ptr& comp) void ComponentGrid::updateCellComponent(const GridEntry& cell) { // Size. - glm::vec2 size{0.0f}; + glm::vec2 size {0.0f}; for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; ++x) size.x += getColWidth(x); for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; ++y) size.y += getRowHeight(y); - if (cell.resize && size != glm::vec2{} && cell.component->getSize() != size) + if (cell.resize && size != glm::vec2 {} && cell.component->getSize() != size) cell.component->setSize(size); // Find top left corner. - glm::vec3 pos{}; + glm::vec3 pos {}; for (int x = 0; x < cell.pos.x; ++x) pos.x += getColWidth(x); for (int y = 0; y < cell.pos.y; ++y) @@ -173,8 +173,8 @@ void ComponentGrid::updateSeparators() continue; // Find component position + size. - pos = glm::vec2{}; - size = glm::vec2{}; + pos = glm::vec2 {}; + size = glm::vec2 {}; for (int x = 0; x < it->pos.x; ++x) pos[0] += getColWidth(x); for (int y = 0; y < it->pos.y; ++y) @@ -184,7 +184,7 @@ void ComponentGrid::updateSeparators() for (int y = it->pos.y; y < it->pos.y + it->dim.y; ++y) size[1] += getRowHeight(y); - if (size == glm::vec2{}) + if (size == glm::vec2 {}) return; if (it->border & BORDER_TOP || drawAll) { @@ -259,16 +259,16 @@ bool ComponentGrid::input(InputConfig* config, Input input) bool withinBoundary = false; if (config->isMappedLike("down", input)) - withinBoundary = moveCursor(glm::ivec2{0, 1}); + withinBoundary = moveCursor(glm::ivec2 {0, 1}); if (config->isMappedLike("up", input)) - withinBoundary = moveCursor(glm::ivec2{0, -1}); + withinBoundary = moveCursor(glm::ivec2 {0, -1}); if (config->isMappedLike("left", input)) - withinBoundary = moveCursor(glm::ivec2{-1, 0}); + withinBoundary = moveCursor(glm::ivec2 {-1, 0}); if (config->isMappedLike("right", input)) - withinBoundary = moveCursor(glm::ivec2{1, 0}); + withinBoundary = moveCursor(glm::ivec2 {1, 0}); if (!withinBoundary && mPastBoundaryCallback) return mPastBoundaryCallback(config, input); @@ -295,21 +295,21 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir) { assert(dir.x || dir.y); - const glm::ivec2 origCursor{mCursor}; + const glm::ivec2 origCursor {mCursor}; const GridEntry* currentCursorEntry = getCellAt(mCursor); glm::ivec2 searchAxis(dir.x == 0, dir.y == 0); // Logic to handle entries that span several cells. if (currentCursorEntry->dim.x > 1) { if (dir.x < 0 && currentCursorEntry->pos.x == 0 && mCursor.x > currentCursorEntry->pos.x) { - onCursorMoved(mCursor, glm::ivec2{0, mCursor.y}); + onCursorMoved(mCursor, glm::ivec2 {0, mCursor.y}); mCursor.x = 0; return false; } if (dir.x > 0 && currentCursorEntry->pos.x + currentCursorEntry->dim.x == mGridSize.x && mCursor.x < currentCursorEntry->pos.x + currentCursorEntry->dim.x - 1) { - onCursorMoved(mCursor, glm::ivec2{mGridSize.x - 1, mCursor.y}); + onCursorMoved(mCursor, glm::ivec2 {mGridSize.x - 1, mCursor.y}); mCursor.x = mGridSize.x - 1; return false; } @@ -329,7 +329,7 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir) while (mCursor.x >= 0 && mCursor.y >= 0 && mCursor.x < mGridSize.x && mCursor.y < mGridSize.y) { mCursor = mCursor + dir; - glm::ivec2 curDirPos{mCursor}; + glm::ivec2 curDirPos {mCursor}; const GridEntry* cursorEntry; // Spread out on search axis+ @@ -374,7 +374,7 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir) void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell) { - const glm::ivec2 origCursor{mCursor}; + const glm::ivec2 origCursor {mCursor}; if (xPos != -1) mCursor.x = xPos; @@ -424,7 +424,7 @@ void ComponentGrid::update(int deltaTime) void ComponentGrid::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; renderChildren(trans); @@ -460,7 +460,7 @@ void ComponentGrid::setCursorTo(const std::shared_ptr& comp) { for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) { if (it->component == comp) { - glm::ivec2 oldCursor{mCursor}; + glm::ivec2 oldCursor {mCursor}; mCursor = it->pos; onCursorMoved(oldCursor, mCursor); return; @@ -484,12 +484,12 @@ std::vector ComponentGrid::getHelpPrompts() // above or below are actually focusable as otherwise they should not affect the help prompts. if (mGridSize.y > 1 && e->dim.y < mGridSize.y) { if (e->pos.y - e->dim.y >= 0) { - const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y - e->dim.y}); + const GridEntry* cell = getCellAt(glm::ivec2 {e->pos.x, e->pos.y - e->dim.y}); if (cell != nullptr && cell->canFocus) canScrollVert = true; } if (e->pos.y + e->dim.y < mGridSize.y) { - const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y + e->dim.y}); + const GridEntry* cell = getCellAt(glm::ivec2 {e->pos.x, e->pos.y + e->dim.y}); if (cell != nullptr && cell->canFocus) canScrollVert = true; } diff --git a/es-core/src/components/ComponentGrid.h b/es-core/src/components/ComponentGrid.h index fc1145108..88e0a3b36 100644 --- a/es-core/src/components/ComponentGrid.h +++ b/es-core/src/components/ComponentGrid.h @@ -42,7 +42,7 @@ public: const glm::ivec2& pos, bool canFocus, bool resize = true, - const glm::ivec2& size = glm::ivec2{1, 1}, + const glm::ivec2& size = glm::ivec2 {1, 1}, unsigned int border = GridFlags::BORDER_NONE, GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS); @@ -100,8 +100,8 @@ private: GridFlags::UpdateType updateType; unsigned int border; - GridEntry(const glm::ivec2& p = glm::ivec2{}, - const glm::ivec2& d = glm::ivec2{}, + GridEntry(const glm::ivec2& p = glm::ivec2 {}, + const glm::ivec2& d = glm::ivec2 {}, const std::shared_ptr& cmp = nullptr, bool f = false, bool r = true, diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 60989a9dc..1b269c58c 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -13,23 +13,23 @@ #define TOTAL_HORIZONTAL_PADDING_PX 20.0f ComponentList::ComponentList(Window* window) - : IList{window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP} - , mFocused{false} - , mSetupCompleted{false} - , mBottomCameraOffset{false} - , mSingleRowScroll{false} - , mSelectorBarOffset{0.0f} - , mCameraOffset{0.0f} - , mLoopRows{false} - , mLoopScroll{false} - , mLoopOffset{0} - , mLoopOffset2{0} - , mLoopTime{0} - , mScrollIndicatorStatus{SCROLL_NONE} + : IList {window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP} + , mFocused {false} + , mSetupCompleted {false} + , mBottomCameraOffset {false} + , mSingleRowScroll {false} + , mSelectorBarOffset {0.0f} + , mCameraOffset {0.0f} + , mLoopRows {false} + , mLoopScroll {false} + , mLoopOffset {0} + , mLoopOffset2 {0} + , mLoopTime {0} + , mScrollIndicatorStatus {SCROLL_NONE} { // Adjust the padding relative to the aspect ratio and screen resolution to make it look // coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. - float aspectValue{1.778f / Renderer::getScreenAspectRatio()}; + float aspectValue {1.778f / Renderer::getScreenAspectRatio()}; mHorizontalPadding = TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier(); } @@ -165,7 +165,7 @@ void ComponentList::update(int deltaTime) listUpdate(deltaTime); if (size()) { - float rowWidth{0.0f}; + float rowWidth {0.0f}; // Update our currently selected row. for (auto it = mEntries.at(mCursor).data.elements.cbegin(); @@ -176,14 +176,14 @@ void ComponentList::update(int deltaTime) if (mLoopRows && rowWidth + mHorizontalPadding / 2.0f > mSize.x) { // Loop the text. - const float speed{ + const float speed { Font::get(FONT_SIZE_MEDIUM)->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f}; - const float delay{1500.0f}; - const float scrollLength{rowWidth}; - const float returnLength{speed * 1.5f}; - const float scrollTime{(scrollLength * 1000.0f) / speed}; - const float returnTime{(returnLength * 1000.0f) / speed}; - const int maxTime{static_cast(delay + scrollTime + returnTime)}; + const float delay {1500.0f}; + const float scrollLength {rowWidth}; + const float returnLength {speed * 1.5f}; + const float scrollTime {(scrollLength * 1000.0f) / speed}; + const float returnTime {(returnLength * 1000.0f) / speed}; + const int maxTime {static_cast(delay + scrollTime + returnTime)}; mLoopTime += deltaTime; while (mLoopTime > maxTime) @@ -282,25 +282,25 @@ void ComponentList::render(const glm::mat4& parentTrans) if (!size()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; // Clip everything to be inside our bounds. - glm::vec3 dim{mSize.x, mSize.y, 0.0f}; + glm::vec3 dim {mSize.x, mSize.y, 0.0f}; dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x; dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y; - const int clipRectPosX{static_cast(std::ceil(trans[3].x))}; - const int clipRectPosY{static_cast(std::round(trans[3].y))}; - const int clipRectSizeX{static_cast(std::round(dim.x))}; - const int clipRectSizeY{static_cast(std::round(dim.y))}; + const int clipRectPosX {static_cast(std::ceil(trans[3].x))}; + const int clipRectPosY {static_cast(std::round(trans[3].y))}; + const int clipRectSizeX {static_cast(std::round(dim.x))}; + const int clipRectSizeY {static_cast(std::round(dim.y))}; - Renderer::pushClipRect(glm::ivec2{clipRectPosX, clipRectPosY}, - glm::ivec2{clipRectSizeX, clipRectSizeY}); + Renderer::pushClipRect(glm::ivec2 {clipRectPosX, clipRectPosY}, + glm::ivec2 {clipRectSizeX, clipRectSizeY}); // Scroll the camera. - trans = glm::translate(trans, glm::vec3{0.0f, -mCameraOffset, 0.0f}); + trans = glm::translate(trans, glm::vec3 {0.0f, -mCameraOffset, 0.0f}); - glm::mat4 loopTrans{trans}; + glm::mat4 loopTrans {trans}; // Draw our entries. std::vector drawAfterCursor; @@ -309,7 +309,7 @@ void ComponentList::render(const glm::mat4& parentTrans) if (mLoopRows && mFocused && mLoopOffset > 0) { loopTrans = - glm::translate(trans, glm::vec3{static_cast(-mLoopOffset), 0.0f, 0.0f}); + glm::translate(trans, glm::vec3 {static_cast(-mLoopOffset), 0.0f, 0.0f}); } auto& entry = mEntries.at(i); @@ -325,7 +325,7 @@ void ComponentList::render(const glm::mat4& parentTrans) if (mLoopOffset2 < 0 || mLoopScroll) { mLoopScroll = true; loopTrans = glm::translate( - trans, glm::vec3{static_cast(-mLoopOffset2), 0.0f, 0.0f}); + trans, glm::vec3 {static_cast(-mLoopOffset2), 0.0f, 0.0f}); it->component->render(loopTrans); } }; diff --git a/es-core/src/components/DateTimeEditComponent.cpp b/es-core/src/components/DateTimeEditComponent.cpp index 678498bfd..eb493948c 100644 --- a/es-core/src/components/DateTimeEditComponent.cpp +++ b/es-core/src/components/DateTimeEditComponent.cpp @@ -16,18 +16,18 @@ #include "utils/StringUtil.h" DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode) - : GuiComponent{window} - , mEditing{false} - , mEditIndex{0} - , mDisplayMode{dispMode} - , mKeyRepeatDir{0} - , mKeyRepeatTimer{0} - , mRelativeUpdateAccumulator{0} - , mColor{0x777777FF} - , mFont{Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)} - , mAlignRight{alignRight} - , mUppercase{false} - , mAutoSize{true} + : GuiComponent {window} + , mEditing {false} + , mEditIndex {0} + , mDisplayMode {dispMode} + , mKeyRepeatDir {0} + , mKeyRepeatTimer {0} + , mRelativeUpdateAccumulator {0} + , mColor {0x777777FF} + , mFont {Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)} + , mAlignRight {alignRight} + , mUppercase {false} + , mAutoSize {true} { updateTextCache(); } @@ -166,17 +166,17 @@ void DateTimeEditComponent::update(int deltaTime) void DateTimeEditComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; if (mTextCache) { std::shared_ptr font = getFont(); - float referenceSize{0.0f}; + float referenceSize {0.0f}; if (mAlignRight) referenceSize = std::round(mParent->getSize().x * 0.1045f); // Vertically center. - glm::vec3 off{0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f}; + glm::vec3 off {0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f}; if (mAlignRight) off.x += referenceSize - mTextCache->metrics.size.x; @@ -389,22 +389,22 @@ void DateTimeEditComponent::updateTextCache() return; // Year. - glm::vec2 start{}; - glm::vec2 end{font->sizeText(dispString.substr(0, 4))}; - glm::vec2 diff{end - start}; - mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]}); + glm::vec2 start {}; + glm::vec2 end {font->sizeText(dispString.substr(0, 4))}; + glm::vec2 diff {end - start}; + mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]}); // Month. start[0] = font->sizeText(dispString.substr(0, 5)).x; end = font->sizeText(dispString.substr(0, 7)); diff = end - start; - mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]}); + mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]}); // Day. start[0] = font->sizeText(dispString.substr(0, 8)).x; end = font->sizeText(dispString.substr(0, 10)); diff = end - start; - mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]}); + mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]}); // The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but // nobody will use it anyway so it's not worthwhile implementing. diff --git a/es-core/src/components/FlexboxComponent.cpp b/es-core/src/components/FlexboxComponent.cpp index 82779a503..679fdafc8 100644 --- a/es-core/src/components/FlexboxComponent.cpp +++ b/es-core/src/components/FlexboxComponent.cpp @@ -20,17 +20,17 @@ #include "ThemeData.h" FlexboxComponent::FlexboxComponent(Window* window, std::vector& items) - : GuiComponent{window} + : GuiComponent {window} , mItems(items) - , mDirection{DEFAULT_DIRECTION} - , mAlignment{DEFAULT_ALIGNMENT} - , mLines{DEFAULT_LINES} - , mItemsPerLine{DEFAULT_ITEMS_PER_LINE} - , mItemPlacement{DEFAULT_ITEM_PLACEMENT} - , mItemMargin{glm::vec2{DEFAULT_MARGIN_X, DEFAULT_MARGIN_Y}} - , mOverlayPosition{0.5f, 0.5f} - , mOverlaySize{0.5f} - , mLayoutValid{false} + , mDirection {DEFAULT_DIRECTION} + , mAlignment {DEFAULT_ALIGNMENT} + , mLines {DEFAULT_LINES} + , mItemsPerLine {DEFAULT_ITEMS_PER_LINE} + , mItemPlacement {DEFAULT_ITEM_PLACEMENT} + , mItemMargin {glm::vec2 {DEFAULT_MARGIN_X, DEFAULT_MARGIN_Y}} + , mOverlayPosition {0.5f, 0.5f} + , mOverlaySize {0.5f} + , mLayoutValid {false} { } @@ -42,7 +42,7 @@ void FlexboxComponent::render(const glm::mat4& parentTrans) if (!mLayoutValid) computeLayout(); - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; Renderer::setMatrix(trans); if (Settings::getInstance()->getBool("DebugImage")) @@ -105,24 +105,24 @@ void FlexboxComponent::computeLayout() mItemsPerLine = static_cast(mItems.size()); } - glm::vec2 grid{}; + glm::vec2 grid {}; if (mDirection == "row") grid = {mItemsPerLine, mLines}; else grid = {mLines, mItemsPerLine}; - glm::vec2 maxItemSize{(mSize + mItemMargin - grid * mItemMargin) / grid}; + glm::vec2 maxItemSize {(mSize + mItemMargin - grid * mItemMargin) / grid}; - float rowHeight{0.0f}; - bool firstItem{true}; + float rowHeight {0.0f}; + bool firstItem {true}; // Calculate maximum item dimensions. for (auto& item : mItems) { if (!item.visible) continue; - glm::vec2 sizeDiff{item.baseImage.getSize() / maxItemSize}; + glm::vec2 sizeDiff {item.baseImage.getSize() / maxItemSize}; // The first item dictates the maximum width for the rest. if (firstItem) { @@ -150,8 +150,8 @@ void FlexboxComponent::computeLayout() maxItemSize = glm::round(maxItemSize); - bool alignRight{mAlignment == "right"}; - float alignRightComp{0.0f}; + bool alignRight {mAlignment == "right"}; + float alignRightComp {0.0f}; // If right-aligning, move the overall container contents during grid setup. if (alignRight && mDirection == "row") @@ -165,16 +165,16 @@ void FlexboxComponent::computeLayout() for (int y = 0; y < grid.y; ++y) { for (int x = 0; x < grid.x; ++x) { itemPositions.emplace_back( - glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp), - y * (rowHeight + mItemMargin.y)}); + glm::vec2 {(x * (maxItemSize.x + mItemMargin.x) + alignRightComp), + y * (rowHeight + mItemMargin.y)}); } } } else if (mDirection == "column" && !alignRight) { for (int x = 0; x < grid.x; ++x) { for (int y = 0; y < grid.y; ++y) { - itemPositions.emplace_back(glm::vec2{(x * (maxItemSize.x + mItemMargin.x)), - y * (rowHeight + mItemMargin.y)}); + itemPositions.emplace_back(glm::vec2 {(x * (maxItemSize.x + mItemMargin.x)), + y * (rowHeight + mItemMargin.y)}); } } } @@ -182,15 +182,15 @@ void FlexboxComponent::computeLayout() for (int x = 0; x < grid.x; ++x) { for (int y = 0; y < grid.y; ++y) { itemPositions.emplace_back( - glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x), - y * (rowHeight + mItemMargin.y)}); + glm::vec2 {(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x), + y * (rowHeight + mItemMargin.y)}); } } } - int pos{0}; - float lastY{0.0f}; - float itemsOnLastRow{0}; + int pos {0}; + float lastY {0.0f}; + float itemsOnLastRow {0}; // Position items on the grid. for (auto& item : mItems) { @@ -204,7 +204,7 @@ void FlexboxComponent::computeLayout() } } - float verticalOffset{0.0f}; + float verticalOffset {0.0f}; // For any items that do not fill the maximum height, position these either on // top/start (implicit), center or bottom/end. @@ -242,9 +242,9 @@ void FlexboxComponent::computeLayout() for (auto& item : mItems) { if (!item.visible) continue; - glm::vec3 currPos{item.baseImage.getPosition()}; + glm::vec3 currPos {item.baseImage.getPosition()}; if (currPos.y == lastY) { - const float offset{(grid.x - itemsOnLastRow) * (maxItemSize.x + mItemMargin.x)}; + const float offset {(grid.x - itemsOnLastRow) * (maxItemSize.x + mItemMargin.x)}; item.baseImage.setPosition(currPos.x + offset, currPos.y, currPos.z); if (item.overlayImage.getTexture() != nullptr) { currPos = item.overlayImage.getPosition(); diff --git a/es-core/src/components/FlexboxComponent.h b/es-core/src/components/FlexboxComponent.h index 317d326e5..bd5486613 100644 --- a/es-core/src/components/FlexboxComponent.h +++ b/es-core/src/components/FlexboxComponent.h @@ -20,9 +20,9 @@ public: // Optional label, mostly a convenience for the calling class to track items. std::string label; // Main image that governs grid sizing and placement. - ImageComponent baseImage{nullptr}; + ImageComponent baseImage {nullptr}; // Optional overlay image that can be sized and positioned relative to the base image. - ImageComponent overlayImage{nullptr}; + ImageComponent overlayImage {nullptr}; bool visible = false; }; diff --git a/es-core/src/components/GridTileComponent.cpp b/es-core/src/components/GridTileComponent.cpp index 615dfd7b7..e1681a2ec 100644 --- a/es-core/src/components/GridTileComponent.cpp +++ b/es-core/src/components/GridTileComponent.cpp @@ -17,12 +17,12 @@ GridTileComponent::GridTileComponent(Window* window) , mBackground(window, ":/graphics/frame.png") { mDefaultProperties.mSize = getDefaultTileSize(); - mDefaultProperties.mPadding = glm::vec2{16.0f * Renderer::getScreenWidthModifier(), - 16.0f * Renderer::getScreenHeightModifier()}; + mDefaultProperties.mPadding = glm::vec2 {16.0f * Renderer::getScreenWidthModifier(), + 16.0f * Renderer::getScreenHeightModifier()}; mDefaultProperties.mImageColor = 0xAAAAAABB; // Attempting to use frame.svg instead causes quite severe performance problems. mDefaultProperties.mBackgroundImage = ":/graphics/frame.png"; - mDefaultProperties.mBackgroundCornerSize = glm::vec2{16.0f, 16.0f}; + mDefaultProperties.mBackgroundCornerSize = glm::vec2 {16.0f, 16.0f}; mDefaultProperties.mBackgroundCenterColor = 0xAAAAEEFF; mDefaultProperties.mBackgroundEdgeColor = 0xAAAAEEFF; @@ -52,7 +52,7 @@ GridTileComponent::GridTileComponent(Window* window) void GridTileComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{getTransform() * parentTrans}; + glm::mat4 trans {getTransform() * parentTrans}; if (mVisible) renderChildren(trans); @@ -76,8 +76,8 @@ void GridTileComponent::update(int deltaTime) void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTileProperties* properties) { - glm::vec2 screen{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}; + glm::vec2 screen {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}; if (elem->has("size")) properties->mSize = elem->get("size") * screen; @@ -132,8 +132,8 @@ void GridTileComponent::applyTheme(const std::shared_ptr& theme, glm::vec2 GridTileComponent::getDefaultTileSize() { - glm::vec2 screen{glm::vec2(static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight()))}; + glm::vec2 screen {glm::vec2(static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight()))}; return screen * 0.22f; } @@ -186,7 +186,7 @@ void GridTileComponent::setSelected(bool selected, resize(); } else { - mAnimPosition = glm::vec3{pPosition->x, pPosition->y, pPosition->z}; + mAnimPosition = glm::vec3 {pPosition->x, pPosition->y, pPosition->z}; auto func = [this](float t) { t -= 1; diff --git a/es-core/src/components/HelpComponent.cpp b/es-core/src/components/HelpComponent.cpp index 533ccad1a..d93f93c56 100644 --- a/es-core/src/components/HelpComponent.cpp +++ b/es-core/src/components/HelpComponent.cpp @@ -17,7 +17,7 @@ #include "resources/TextureResource.h" #include "utils/StringUtil.h" -static std::map sIconPathMap{}; +static std::map sIconPathMap {}; HelpComponent::HelpComponent(Window* window) : GuiComponent(window) @@ -203,7 +203,7 @@ void HelpComponent::updateGrid() std::shared_ptr& font = mStyle.font; mGrid = std::make_shared(mWindow, - glm::ivec2{static_cast(mPrompts.size()) * 4, 1}); + glm::ivec2 {static_cast(mPrompts.size()) * 4, 1}); // [icon] [spacer1] [text] [spacer2] @@ -249,8 +249,8 @@ void HelpComponent::updateGrid() col + 1, (mStyle.iconTextSpacing * Renderer::getScreenWidthModifier()) / width); mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width); - mGrid->setEntry(icons.at(i), glm::ivec2{col, 0}, false, false); - mGrid->setEntry(labels.at(i), glm::ivec2{col + 2, 0}, false, false); + mGrid->setEntry(icons.at(i), glm::ivec2 {col, 0}, false, false); + mGrid->setEntry(labels.at(i), glm::ivec2 {col + 2, 0}, false, false); } mGrid->setPosition({mStyle.position.x, mStyle.position.y, 0.0f}); @@ -291,7 +291,7 @@ void HelpComponent::setOpacity(unsigned char opacity) void HelpComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; if (mGrid) mGrid->render(trans); diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 3b2c18237..188d1b5f9 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -20,7 +20,7 @@ glm::ivec2 ImageComponent::getTextureSize() const if (mTexture) return mTexture->getSize(); else - return glm::ivec2{}; + return glm::ivec2 {}; } glm::vec2 ImageComponent::getSize() const @@ -54,8 +54,8 @@ void ImageComponent::resize() if (!mTexture) return; - const glm::vec2 textureSize{mTexture->getSourceImageSize()}; - if (textureSize == glm::vec2{}) + const glm::vec2 textureSize {mTexture->getSourceImageSize()}; + if (textureSize == glm::vec2 {}) return; if (mTexture->isTiled()) { @@ -69,7 +69,7 @@ void ImageComponent::resize() if (mTargetIsMax) { mSize = textureSize; - glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; + glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; if (resizeScale.x < resizeScale.y) { // This will be mTargetSize.x. We can't exceed it, nor be lower than it. @@ -86,7 +86,7 @@ void ImageComponent::resize() else if (mTargetIsMin) { mSize = textureSize; - glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; + glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; if (resizeScale.x > resizeScale.y) { mSize.x *= resizeScale.x; @@ -108,7 +108,7 @@ void ImageComponent::resize() else { // If both components are set, we just stretch. // If no components are set, we don't resize at all. - mSize = mTargetSize == glm::vec2{} ? textureSize : mTargetSize; + mSize = mTargetSize == glm::vec2 {} ? textureSize : mTargetSize; // If only one component is set, we resize in a way that maintains aspect ratio. if (!mTargetSize.x && mTargetSize.y) { @@ -174,7 +174,7 @@ void ImageComponent::setImage(const std::shared_ptr& texture, b void ImageComponent::setResize(float width, float height) { - mTargetSize = glm::vec2{width, height}; + mTargetSize = glm::vec2 {width, height}; mTargetIsMax = false; mTargetIsMin = false; resize(); @@ -182,7 +182,7 @@ void ImageComponent::setResize(float width, float height) void ImageComponent::setMaxSize(const float width, const float height) { - mTargetSize = glm::vec2{width, height}; + mTargetSize = glm::vec2 {width, height}; mTargetIsMax = true; mTargetIsMin = false; resize(); @@ -190,7 +190,7 @@ void ImageComponent::setMaxSize(const float width, const float height) void ImageComponent::setMinSize(const float width, const float height) { - mTargetSize = glm::vec2{width, height}; + mTargetSize = glm::vec2 {width, height}; mTargetIsMax = false; mTargetIsMin = true; resize(); @@ -236,7 +236,7 @@ void ImageComponent::uncrop() void ImageComponent::cropTransparentPadding(const float maxSizeX, const float maxSizeY) { - if (mSize == glm::vec2{}) + if (mSize == glm::vec2 {}) return; std::vector imageRGBA = mTexture.get()->getRawRGBAData(); @@ -244,10 +244,10 @@ void ImageComponent::cropTransparentPadding(const float maxSizeX, const float ma if (imageRGBA.size() == 0) return; - glm::ivec2 imageSize{mTexture.get()->getSize()}; + glm::ivec2 imageSize {mTexture.get()->getSize()}; cimg_library::CImg imageCImg(imageSize.x, imageSize.y, 1, 4, 0); - int paddingCoords[4]{}; + int paddingCoords[4] {}; // We need to convert our RGBA data to the CImg internal format as CImg does not interleave // the pixels (as in RGBARGBARGBA). @@ -256,12 +256,12 @@ void ImageComponent::cropTransparentPadding(const float maxSizeX, const float ma // This will give us the coordinates for the fully transparent areas. Utils::CImg::getTransparentPaddingCoords(imageCImg, paddingCoords); - glm::vec2 originalSize{mSize}; + glm::vec2 originalSize {mSize}; - float cropLeft{static_cast(paddingCoords[0]) / static_cast(imageSize.x)}; - float cropTop{static_cast(paddingCoords[1]) / static_cast(imageSize.y)}; - float cropRight{static_cast(paddingCoords[2]) / static_cast(imageSize.x)}; - float cropBottom{static_cast(paddingCoords[3]) / static_cast(imageSize.y)}; + float cropLeft {static_cast(paddingCoords[0]) / static_cast(imageSize.x)}; + float cropTop {static_cast(paddingCoords[1]) / static_cast(imageSize.y)}; + float cropRight {static_cast(paddingCoords[2]) / static_cast(imageSize.x)}; + float cropBottom {static_cast(paddingCoords[3]) / static_cast(imageSize.y)}; crop(cropLeft, cropTop, cropRight, cropBottom); @@ -339,10 +339,10 @@ void ImageComponent::updateVertices() // We go through this mess to make sure everything is properly rounded. // If we just round vertices at the end, edge cases occur near sizes of 0.5. - const glm::vec2 topLeft{}; - const glm::vec2 bottomRight{mSize}; - const float px{mTexture->isTiled() ? mSize.x / getTextureSize().x : 1.0f}; - const float py{mTexture->isTiled() ? mSize.y / getTextureSize().y : 1.0f}; + const glm::vec2 topLeft {}; + const glm::vec2 bottomRight {mSize}; + const float px {mTexture->isTiled() ? mSize.x / getTextureSize().x : 1.0f}; + const float py {mTexture->isTiled() ? mSize.y / getTextureSize().y : 1.0f}; // clang-format off mVertices[0] = {{topLeft.x, topLeft.y }, {mTopLeftCrop.x, py - mTopLeftCrop.y }, 0}; @@ -388,18 +388,18 @@ void ImageComponent::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; Renderer::setMatrix(trans); if (mTexture && mOpacity > 0) { if (Settings::getInstance()->getBool("DebugImage")) { - glm::vec2 targetSizePos{(mTargetSize - mSize) * mOrigin * glm::vec2{-1.0f}}; + glm::vec2 targetSizePos {(mTargetSize - mSize) * mOrigin * glm::vec2 {-1.0f}}; Renderer::drawRect(targetSizePos.x, targetSizePos.y, mTargetSize.x, mTargetSize.y, 0xFF000033, 0xFF000033); Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0xFF000033, 0xFF000033); } // An image with zero size would normally indicate a corrupt image file. - if (mTexture->getSize() != glm::ivec2{}) { + if (mTexture->getSize() != glm::ivec2 {}) { // Actually draw the image. // The bind() function returns false if the texture is not currently loaded. A blank // texture is bound in this case but we want to handle a fade so it doesn't just @@ -485,9 +485,9 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, if (!elem) return; - glm::vec2 scale{getParent() ? getParent()->getSize() : - glm::vec2(static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight()))}; + glm::vec2 scale {getParent() ? getParent()->getSize() : + glm::vec2(static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight()))}; if (properties & ThemeFlags::SIZE) { if (elem->has("size")) diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index 46e21da23..d38b475ee 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -126,13 +126,13 @@ template ImageGridComponent::ImageGridComponent(Window* window) : IList(window) { - glm::vec2 screen{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}; + glm::vec2 screen {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}; mCamera = 0.0f; mCameraDirection = 1.0f; - mAutoLayout = glm::vec2{}; + mAutoLayout = glm::vec2 {}; mAutoLayoutZoom = 1.0f; mStartPosition = 0; @@ -171,7 +171,7 @@ template bool ImageGridComponent::input(InputConfig* config, Inp if (input.value != 0) { int idx = isVertical() ? 0 : 1; - glm::ivec2 dir{}; + glm::ivec2 dir {}; if (config->isMappedLike("up", input)) dir[1 ^ idx] = -1; else if (config->isMappedLike("down", input)) @@ -181,7 +181,7 @@ template bool ImageGridComponent::input(InputConfig* config, Inp else if (config->isMappedLike("right", input)) dir[0 ^ idx] = 1; - if (dir != glm::ivec2{}) { + if (dir != glm::ivec2 {}) { if (isVertical()) listInput(dir.x + dir.y * mGridDimension.x); else @@ -210,13 +210,13 @@ template void ImageGridComponent::update(int deltaTime) template void ImageGridComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{getTransform() * parentTrans}; - glm::mat4 tileTrans{trans}; + glm::mat4 trans {getTransform() * parentTrans}; + glm::mat4 tileTrans {trans}; - float offsetX{isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x)}; - float offsetY{isVertical() ? mCamera * mCameraDirection * (mTileSize.y + mMargin.y) : 0.0f}; + float offsetX {isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x)}; + float offsetY {isVertical() ? mCamera * mCameraDirection * (mTileSize.y + mMargin.y) : 0.0f}; - tileTrans = glm::translate(tileTrans, glm::vec3{offsetX, offsetY, 0.0f}); + tileTrans = glm::translate(tileTrans, glm::vec3 {offsetX, offsetY, 0.0f}); if (mEntriesDirty) { updateTiles(); @@ -227,10 +227,10 @@ template void ImageGridComponent::render(const glm::mat4& parent float scaleX = trans[0].x; float scaleY = trans[1].y; - glm::ivec2 pos{static_cast(std::round(trans[3].x)), - static_cast(std::round(trans[3].y))}; - glm::ivec2 size{static_cast(std::round(mSize.x * scaleX)), - static_cast(std::round(mSize.y * scaleY))}; + glm::ivec2 pos {static_cast(std::round(trans[3].x)), + static_cast(std::round(trans[3].y))}; + glm::ivec2 size {static_cast(std::round(mSize.x * scaleX)), + static_cast(std::round(mSize.y * scaleY))}; Renderer::pushClipRect(pos, size); @@ -269,8 +269,8 @@ void ImageGridComponent::applyTheme(const std::shared_ptr& theme, // Keep the theme pointer to apply it on the tiles later on. mTheme = theme; - glm::vec2 screen{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}; + glm::vec2 screen {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}; const ThemeData::ThemeElement* elem = theme->getElement(view, element, "imagegrid"); if (elem) { @@ -278,8 +278,8 @@ void ImageGridComponent::applyTheme(const std::shared_ptr& theme, mMargin = elem->get("margin") * screen; if (elem->has("padding")) - mPadding = - elem->get("padding") * glm::vec4{screen.x, screen.y, screen.x, screen.y}; + mPadding = elem->get("padding") * + glm::vec4 {screen.x, screen.y, screen.x, screen.y}; if (elem->has("autoLayout")) mAutoLayout = elem->get("autoLayout"); @@ -447,7 +447,7 @@ template void ImageGridComponent::onCursorChanged(const CursorSt } } - glm::vec3 oldPos{}; + glm::vec3 oldPos {}; if (oldTile != nullptr && oldTile != newTile) { oldPos = oldTile->getBackgroundPosition(); @@ -455,7 +455,7 @@ template void ImageGridComponent::onCursorChanged(const CursorSt } if (newTile != nullptr) - newTile->setSelected(true, true, oldPos == glm::vec3{} ? nullptr : &oldPos, true); + newTile->setSelected(true, true, oldPos == glm::vec3 {} ? nullptr : &oldPos, true); } int firstVisibleCol = mStartPosition / dimOpposite; @@ -532,7 +532,7 @@ template void ImageGridComponent::buildTiles() mStartPosition -= static_cast(floorf(dimScrollable / 2.0f)); } - glm::vec2 tileDistance{mTileSize + mMargin}; + glm::vec2 tileDistance {mTileSize + mMargin}; if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f) { auto x = (mSize.x - (mMargin.x * (mAutoLayout.x - 1.0f)) - mPadding.x - mPadding.z) / @@ -540,12 +540,12 @@ template void ImageGridComponent::buildTiles() auto y = (mSize.y - (mMargin.y * (mAutoLayout.y - 1.0f)) - mPadding.y - mPadding.w) / static_cast(mAutoLayout.y); - mTileSize = glm::vec2{x, y}; + mTileSize = glm::vec2 {x, y}; tileDistance = mTileSize + mMargin; } bool vert = isVertical(); - glm::vec2 startPosition{mTileSize / 2.0f}; + glm::vec2 startPosition {mTileSize / 2.0f}; startPosition.x += mPadding.x; startPosition.y += mPadding.y; @@ -673,7 +673,7 @@ void ImageGridComponent::updateTileAtPos(int tilePos, if (idx < 0 || idx >= static_cast(mTiles.size())) idx = 0; - glm::vec3 pos{mTiles.at(idx)->getBackgroundPosition()}; + glm::vec3 pos {mTiles.at(idx)->getBackgroundPosition()}; tile->setSelected(true, allowAnimation, &pos); } else { @@ -689,7 +689,7 @@ template void ImageGridComponent::calcGridDimension() { // grid_size = columns * tile_size + (columns - 1) * margin // <=> columns = (grid_size + margin) / (tile_size + margin) - glm::vec2 gridDimension{(mSize + mMargin) / (mTileSize + mMargin)}; + glm::vec2 gridDimension {(mSize + mMargin) / (mTileSize + mMargin)}; if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f) gridDimension = mAutoLayout; @@ -697,8 +697,8 @@ template void ImageGridComponent::calcGridDimension() mLastRowPartial = floorf(gridDimension.y) != gridDimension.y; // Ceil y dim so we can display partial last row. - mGridDimension = glm::ivec2{static_cast(gridDimension.x), - static_cast(ceilf(gridDimension.y))}; + mGridDimension = glm::ivec2 {static_cast(gridDimension.x), + static_cast(ceilf(gridDimension.y))}; // Grid dimension validation. if (mGridDimension.x < 1) { diff --git a/es-core/src/components/LottieComponent.cpp b/es-core/src/components/LottieComponent.cpp index b1cb43d35..f72f3f618 100644 --- a/es-core/src/components/LottieComponent.cpp +++ b/es-core/src/components/LottieComponent.cpp @@ -19,26 +19,26 @@ #include LottieComponent::LottieComponent(Window* window) - : GuiComponent{window} - , mCacheFrames{true} - , mMaxCacheSize{0} - , mCacheSize{0} - , mFrameSize{0} - , mAnimation{nullptr} - , mSurface{nullptr} - , mStartDirection{"normal"} - , mTotalFrames{0} - , mFrameNum{0} - , mFrameRate{0.0} - , mSpeedModifier{1.0f} - , mTargetPacing{0} - , mTimeAccumulator{0} - , mLastRenderedFrame{-1} - , mSkippedFrames{0} - , mHoldFrame{false} - , mPause{false} - , mAlternate{false} - , mKeepAspectRatio{true} + : GuiComponent {window} + , mCacheFrames {true} + , mMaxCacheSize {0} + , mCacheSize {0} + , mFrameSize {0} + , mAnimation {nullptr} + , mSurface {nullptr} + , mStartDirection {"normal"} + , mTotalFrames {0} + , mFrameNum {0} + , mFrameRate {0.0} + , mSpeedModifier {1.0f} + , mTargetPacing {0} + , mTimeAccumulator {0} + , mLastRenderedFrame {-1} + , mSkippedFrames {0} + , mHoldFrame {false} + , mPause {false} + , mAlternate {false} + , mKeepAspectRatio {true} { // Get an empty texture for rendering the animation. mTexture = TextureResource::get(""); @@ -117,12 +117,12 @@ void LottieComponent::setAnimation(const std::string& path) "disabling of so ignoring this setting"; } - size_t width{0}; - size_t height{0}; + size_t width {0}; + size_t height {0}; if (mSize.x == 0.0f || mSize.y == 0.0f) { - size_t viewportWidth{0}; - size_t viewportHeight{0}; + size_t viewportWidth {0}; + size_t viewportHeight {0}; mAnimation->size(viewportWidth, viewportHeight); double sizeRatio = static_cast(viewportWidth) / static_cast(viewportHeight); @@ -216,7 +216,7 @@ void LottieComponent::applyTheme(const std::shared_ptr& theme, { using namespace ThemeFlags; - const ThemeData::ThemeElement* elem{theme->getElement(view, element, "animation")}; + const ThemeData::ThemeElement* elem {theme->getElement(view, element, "animation")}; if (elem->has("size")) { glm::vec2 size = elem->get("size"); @@ -228,7 +228,7 @@ void LottieComponent::applyTheme(const std::shared_ptr& theme, } if (elem->has("speed")) { - const float speed{elem->get("speed")}; + const float speed {elem->get("speed")}; if (speed < 0.2f || speed > 3.0f) { LOG(LogWarning) << "LottieComponent: Invalid theme configuration, set to \"" << std::fixed << std::setprecision(1) << speed << "\""; @@ -271,7 +271,7 @@ void LottieComponent::applyTheme(const std::shared_ptr& theme, GuiComponent::applyTheme(theme, view, element, properties); if (elem->has("path")) { - std::string path{elem->get("path")}; + std::string path {elem->get("path")}; if (path != "") { setAnimation(path); } @@ -338,7 +338,7 @@ void LottieComponent::render(const glm::mat4& parentTrans) if (mAnimation == nullptr) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; // This is necessary as there may otherwise be no texture to render when paused. if (mPause && mTexture->getSize().x == 0.0f) { diff --git a/es-core/src/components/MenuComponent.cpp b/es-core/src/components/MenuComponent.cpp index 8e9fa8348..c82f1e11d 100644 --- a/es-core/src/components/MenuComponent.cpp +++ b/es-core/src/components/MenuComponent.cpp @@ -22,7 +22,7 @@ MenuComponent::MenuComponent(Window* window, const std::shared_ptr& titleFont) : GuiComponent(window) , mBackground(window) - , mGrid(window, glm::ivec2{2, 4}) + , mGrid(window, glm::ivec2 {2, 4}) , mNeedsSaving(false) { addChild(&mBackground); @@ -35,11 +35,11 @@ MenuComponent::MenuComponent(Window* window, mTitle->setHorizontalAlignment(ALIGN_CENTER); mTitle->setColor(0x555555FF); setTitle(title, titleFont); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2}); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2}); // Set up list which will never change (externally, anyway). mList = std::make_shared(mWindow); - mGrid.setEntry(mList, glm::ivec2{0, 2}, true, true, glm::ivec2{2, 1}); + mGrid.setEntry(mList, glm::ivec2 {0, 2}, true, true, glm::ivec2 {2, 1}); // Set up scroll indicators. mScrollUp = std::make_shared(mWindow); @@ -52,8 +52,8 @@ MenuComponent::MenuComponent(Window* window, mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f); mScrollDown->setOrigin(0.0f, 0.35f); - mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1}); - mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1}); + mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1}); + mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1}); updateGrid(); updateSize(); @@ -120,7 +120,7 @@ void MenuComponent::updateSize() void MenuComponent::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); // Update grid row/column sizes. mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y / 2.0f); @@ -151,7 +151,7 @@ void MenuComponent::updateGrid() if (mButtons.size()) { mButtonGrid = makeButtonGrid(mWindow, mButtons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 3}, true, false, glm::ivec2{2, 1}); + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1}); } } @@ -159,13 +159,13 @@ std::shared_ptr makeButtonGrid( Window* window, const std::vector>& buttons) { std::shared_ptr buttonGrid = - std::make_shared(window, glm::ivec2{static_cast(buttons.size()), 2}); + std::make_shared(window, glm::ivec2 {static_cast(buttons.size()), 2}); // Initialize to padding. float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size(); for (int i = 0; i < static_cast(buttons.size()); ++i) { - buttonGrid->setEntry(buttons.at(i), glm::ivec2{i, 0}, true, false); + buttonGrid->setEntry(buttons.at(i), glm::ivec2 {i, 0}, true, false); buttonGridWidth += buttons.at(i)->getSize().x; } for (unsigned int i = 0; i < buttons.size(); ++i) diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index ebeeea030..691d6a559 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -17,13 +17,13 @@ NinePatchComponent::NinePatchComponent(Window* window, const std::string& path, unsigned int edgeColor, unsigned int centerColor) - : GuiComponent{window} - , mVertices{nullptr} - , mPath{path} - , mCornerSize{16.0f, 16.0f} - , mSharpCorners{false} - , mEdgeColor{edgeColor} - , mCenterColor{centerColor} + : GuiComponent {window} + , mVertices {nullptr} + , mPath {path} + , mCornerSize {16.0f, 16.0f} + , mSharpCorners {false} + , mEdgeColor {edgeColor} + , mCenterColor {centerColor} { if (!mPath.empty()) buildVertices(); @@ -55,7 +55,7 @@ void NinePatchComponent::buildVertices() if (mVertices != nullptr) delete[] mVertices; - glm::vec2 relCornerSize{}; + glm::vec2 relCornerSize {}; // Don't scale the rasterized version of the frame as it would look bad. if (mPath.substr(mPath.size() - 4, std::string::npos) == ".png") { @@ -74,7 +74,7 @@ void NinePatchComponent::buildVertices() mTexture->rasterizeAt(texSize.x, texSize.y); - if (mTexture->getSize() == glm::ivec2{}) { + if (mTexture->getSize() == glm::ivec2 {}) { mVertices = nullptr; LOG(LogWarning) << "NinePatchComponent has no texture"; return; @@ -82,10 +82,10 @@ void NinePatchComponent::buildVertices() mVertices = new Renderer::Vertex[6 * 9]; - const float imgSizeX[3]{relCornerSize.x, mSize.x - relCornerSize.x * 2.0f, relCornerSize.x}; - const float imgSizeY[3]{relCornerSize.y, mSize.y - relCornerSize.y * 2.0f, relCornerSize.y}; - const float imgPosX[3]{0, imgSizeX[0], imgSizeX[0] + imgSizeX[1]}; - const float imgPosY[3]{0, imgSizeY[0], imgSizeY[0] + imgSizeY[1]}; + const float imgSizeX[3] {relCornerSize.x, mSize.x - relCornerSize.x * 2.0f, relCornerSize.x}; + const float imgSizeY[3] {relCornerSize.y, mSize.y - relCornerSize.y * 2.0f, relCornerSize.y}; + const float imgPosX[3] {0, imgSizeX[0], imgSizeX[0] + imgSizeX[1]}; + const float imgPosY[3] {0, imgSizeY[0], imgSizeY[0] + imgSizeY[1]}; // The "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom // left corner origin vs. verticies having a top left origin. @@ -100,12 +100,12 @@ void NinePatchComponent::buildVertices() int v = 0; for (int slice = 0; slice < 9; ++slice) { - const int sliceX{slice % 3}; - const int sliceY{slice / 3}; - const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]}; - const glm::vec2 imgSize{imgSizeX[sliceX], imgSizeY[sliceY]}; - const glm::vec2 texPos{texPosX[sliceX], texPosY[sliceY]}; - const glm::vec2 texSizeSlice{texSizeX[sliceX], texSizeY[sliceY]}; + const int sliceX {slice % 3}; + const int sliceY {slice / 3}; + const glm::vec2 imgPos {imgPosX[sliceX], imgPosY[sliceY]}; + const glm::vec2 imgSize {imgSizeX[sliceX], imgSizeY[sliceY]}; + const glm::vec2 texPos {texPosX[sliceX], texPosY[sliceY]}; + const glm::vec2 texSizeSlice {texSizeX[sliceX], texSizeY[sliceY]}; // clang-format off mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0}; @@ -133,7 +133,7 @@ void NinePatchComponent::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; if (mTexture && mVertices != nullptr) { Renderer::setMatrix(trans); diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index 74b464f0c..d32a6b1e3 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -33,22 +33,22 @@ public: bool multiSelect = false, bool multiExclusiveSelect = false, bool multiShowTotal = false) - : GuiComponent{window} - , mHelpStyle{helpstyle} - , mMultiSelect{multiSelect} - , mMultiExclusiveSelect{multiExclusiveSelect} - , mMultiShowTotal{multiShowTotal} - , mKeyRepeat{false} - , mKeyRepeatDir{0} - , mKeyRepeatTimer{0} - , mKeyRepeatStartDelay{OPTIONLIST_REPEAT_START_DELAY} - , mKeyRepeatSpeed{OPTIONLIST_REPEAT_SPEED} - , mName{name} - , mText{window} - , mLeftArrow{window} - , mRightArrow{window} + : GuiComponent {window} + , mHelpStyle {helpstyle} + , mMultiSelect {multiSelect} + , mMultiExclusiveSelect {multiExclusiveSelect} + , mMultiShowTotal {multiShowTotal} + , mKeyRepeat {false} + , mKeyRepeatDir {0} + , mKeyRepeatTimer {0} + , mKeyRepeatStartDelay {OPTIONLIST_REPEAT_START_DELAY} + , mKeyRepeatSpeed {OPTIONLIST_REPEAT_SPEED} + , mName {name} + , mText {window} + , mLeftArrow {window} + , mRightArrow {window} { - auto font{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}; + auto font {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}; mText.setFont(font); mText.setColor(0x777777FF); mText.setHorizontalAlignment(ALIGN_CENTER); diff --git a/es-core/src/components/RatingComponent.cpp b/es-core/src/components/RatingComponent.cpp index 4a9867072..e05625fce 100644 --- a/es-core/src/components/RatingComponent.cpp +++ b/es-core/src/components/RatingComponent.cpp @@ -25,7 +25,7 @@ RatingComponent::RatingComponent(Window* window, bool colorizeChanges) mFilledTexture = TextureResource::get(":/graphics/star_filled.svg", true); mUnfilledTexture = TextureResource::get(":/graphics/star_unfilled.svg", true); mValue = 0.5f; - mSize = glm::vec2{64.0f * NUM_RATING_STARS, 64.0f}; + mSize = glm::vec2 {64.0f * NUM_RATING_STARS, 64.0f}; updateVertices(); updateColors(); } @@ -145,7 +145,7 @@ void RatingComponent::render(const glm::mat4& parentTrans) if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; Renderer::setMatrix(trans); diff --git a/es-core/src/components/ScrollIndicatorComponent.h b/es-core/src/components/ScrollIndicatorComponent.h index 58afa5b9b..214aa21dc 100644 --- a/es-core/src/components/ScrollIndicatorComponent.h +++ b/es-core/src/components/ScrollIndicatorComponent.h @@ -48,7 +48,7 @@ public: componentList.get()->setScrollIndicatorChangedCallback( [this, scrollUp, scrollDown](ComponentList::ScrollIndicator state, bool singleRowScroll) { - float fadeTime{FADE_IN_TIME}; + float fadeTime {FADE_IN_TIME}; bool upFadeIn = false; bool upFadeOut = false; diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index b0a67eb3d..73dcfac2d 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -15,16 +15,16 @@ #include "resources/Font.h" ScrollableContainer::ScrollableContainer(Window* window) - : GuiComponent{window} - , mScrollPos{0.0f, 0.0f} - , mScrollDir{0.0f, 0.0f} - , mClipSpacing{0.0f} - , mAutoScrollDelay{0} - , mAutoScrollSpeed{0} - , mAutoScrollAccumulator{0} - , mAutoScrollResetAccumulator{0} - , mAdjustedAutoScrollSpeed{0} - , mUpdatedSize{false} + : GuiComponent {window} + , mScrollPos {0.0f, 0.0f} + , mScrollDir {0.0f, 0.0f} + , mClipSpacing {0.0f} + , mAutoScrollDelay {0} + , mAutoScrollSpeed {0} + , mAutoScrollAccumulator {0} + , mAutoScrollResetAccumulator {0} + , mAdjustedAutoScrollSpeed {0} + , mUpdatedSize {false} { // Set the modifier to get equivalent scrolling speed regardless of screen resolution. mResolutionModifier = Renderer::getScreenHeightModifier(); @@ -37,12 +37,12 @@ ScrollableContainer::ScrollableContainer(Window* window) void ScrollableContainer::setAutoScroll(bool autoScroll) { if (autoScroll) { - mScrollDir = glm::vec2{0.0f, 1.0f}; + mScrollDir = glm::vec2 {0.0f, 1.0f}; mAutoScrollDelay = static_cast(mAutoScrollDelayConstant); reset(); } else { - mScrollDir = glm::vec2{}; + mScrollDir = glm::vec2 {}; mAutoScrollDelay = 0; mAutoScrollSpeed = 0; mAutoScrollAccumulator = 0; @@ -60,17 +60,17 @@ void ScrollableContainer::setScrollParameters(float autoScrollDelayConstant, void ScrollableContainer::reset() { - mScrollPos = glm::vec2{}; + mScrollPos = glm::vec2 {}; mAutoScrollResetAccumulator = 0; mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed; mAtEnd = false; // This is needed to resize to the font height boundary when we keep running in the background // while launching games. if (!mChildren.empty()) { - float combinedHeight{ + float combinedHeight { mChildren.front()->getFont()->getHeight(mChildren.front()->getLineSpacing())}; if (mChildren.front()->getSize().y > mSize.y) { - float numLines{mSize.y / combinedHeight}; + float numLines {mSize.y / combinedHeight}; mSize.y = floorf(numLines) * combinedHeight; } } @@ -81,16 +81,16 @@ void ScrollableContainer::update(int deltaTime) // Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled; if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() || !mWindow->getAllowTextScrolling()) { - if (mScrollPos != glm::vec2{} && !mWindow->isLaunchScreenDisplayed()) + if (mScrollPos != glm::vec2 {} && !mWindow->isLaunchScreenDisplayed()) reset(); return; } - const glm::vec2 contentSize{mChildren.front()->getSize()}; - float rowModifier{1.0f}; + const glm::vec2 contentSize {mChildren.front()->getSize()}; + float rowModifier {1.0f}; - float lineSpacing{mChildren.front()->getLineSpacing()}; - float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)}; + float lineSpacing {mChildren.front()->getLineSpacing()}; + float combinedHeight {mChildren.front()->getFont()->getHeight(lineSpacing)}; // Calculate the spacing which will be used to clip the container. if (lineSpacing > 1.2f && mClipSpacing == 0.0f) { @@ -101,23 +101,23 @@ void ScrollableContainer::update(int deltaTime) // Resize container to font height boundary to avoid rendering a fraction of the last line. if (!mUpdatedSize && contentSize.y > mSize.y) { - float numLines{mSize.y / combinedHeight}; + float numLines {mSize.y / combinedHeight}; mSize.y = floorf(numLines) * combinedHeight; mUpdatedSize = true; } else if (mUpdatedSize) { // If there are less than 8 lines of text, accelerate the scrolling further. - float lines{mSize.y / combinedHeight}; + float lines {mSize.y / combinedHeight}; if (lines < 8.0f) rowModifier = lines / 8.0f; } if (!mAdjustedAutoScrollSpeed) { - float fontSize{static_cast(mChildren.front()->getFont()->getSize())}; - float width{contentSize.x / (fontSize * 1.3f)}; + float fontSize {static_cast(mChildren.front()->getFont()->getSize())}; + float width {contentSize.x / (fontSize * 1.3f)}; // Keep speed adjustments within reason. - float speedModifier{glm::clamp(width, 10.0f, 40.0f)}; + float speedModifier {glm::clamp(width, 10.0f, 40.0f)}; speedModifier *= mAutoScrollSpeedConstant; speedModifier /= mResolutionModifier; @@ -163,7 +163,7 @@ void ScrollableContainer::update(int deltaTime) // Fade in the text as it resets to the start position. auto func = [this](float t) { this->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); - mScrollPos = glm::vec2{}; + mScrollPos = glm::vec2 {}; mAutoScrollResetAccumulator = 0; mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed; mAtEnd = false; @@ -180,16 +180,16 @@ void ScrollableContainer::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; - glm::ivec2 clipPos{static_cast(trans[3].x), static_cast(trans[3].y)}; + glm::ivec2 clipPos {static_cast(trans[3].x), static_cast(trans[3].y)}; - glm::vec3 dimScaled{}; + glm::vec3 dimScaled {}; dimScaled.x = std::fabs(trans[3].x + mSize.x); dimScaled.y = std::fabs(trans[3].y + mSize.y); - glm::ivec2 clipDim{static_cast(ceilf(dimScaled.x - trans[3].x)), - static_cast(ceilf(dimScaled.y - trans[3].y))}; + glm::ivec2 clipDim {static_cast(ceilf(dimScaled.x - trans[3].x)), + static_cast(ceilf(dimScaled.y - trans[3].y))}; // By effectively clipping the upper and lower boundaries of the container we mostly avoid // scrolling outside the vertical starting and ending positions. @@ -198,7 +198,7 @@ void ScrollableContainer::render(const glm::mat4& parentTrans) Renderer::pushClipRect(clipPos, clipDim); - trans = glm::translate(trans, -glm::vec3{mScrollPos.x, mScrollPos.y, 0.0f}); + trans = glm::translate(trans, -glm::vec3 {mScrollPos.x, mScrollPos.y, 0.0f}); Renderer::setMatrix(trans); GuiComponent::renderChildren(trans); diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index ceed09192..6ebb193cf 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -16,14 +16,14 @@ SliderComponent::SliderComponent( Window* window, float min, float max, float increment, const std::string& suffix) - : GuiComponent{window} - , mMin{min} - , mMax{max} - , mSingleIncrement{increment} - , mMoveRate{0.0f} - , mBarHeight{0.0f} - , mKnob{window} - , mSuffix{suffix} + : GuiComponent {window} + , mMin {min} + , mMax {max} + , mSingleIncrement {increment} + , mMoveRate {0.0f} + , mBarHeight {0.0f} + , mKnob {window} + , mSuffix {suffix} { assert((min - max) != 0.0f); @@ -78,7 +78,7 @@ void SliderComponent::update(int deltaTime) void SliderComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; Renderer::setMatrix(trans); if (Settings::getInstance()->getBool("DebugText")) { @@ -89,10 +89,10 @@ void SliderComponent::render(const glm::mat4& parentTrans) mSize.y, 0x00000033, 0x00000033); } - float width{mSize.x - mKnob.getSize().x - - (mTextCache ? - mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : - 0.0f)}; + float width {mSize.x - mKnob.getSize().x - + (mTextCache ? + mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) : + 0.0f)}; // Render suffix. if (mTextCache) diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index e1249009a..ac6f4f83a 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -44,7 +44,7 @@ bool SwitchComponent::input(InputConfig* config, Input input) void SwitchComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; mImage.render(trans); renderChildren(trans); } diff --git a/es-core/src/components/TextComponent.cpp b/es-core/src/components/TextComponent.cpp index 08aa17674..65e8e35e4 100644 --- a/es-core/src/components/TextComponent.cpp +++ b/es-core/src/components/TextComponent.cpp @@ -13,18 +13,18 @@ #include "utils/StringUtil.h" TextComponent::TextComponent(Window* window) - : GuiComponent{window} - , mFont{Font::get(FONT_SIZE_MEDIUM)} - , mColor{0x000000FF} - , mBgColor{0} - , mRenderBackground{false} - , mUppercase{false} - , mAutoCalcExtent{1, 1} - , mHorizontalAlignment{ALIGN_LEFT} - , mVerticalAlignment{ALIGN_CENTER} - , mLineSpacing{1.5f} - , mNoTopMargin{false} - , mSelectable{false} + : GuiComponent {window} + , mFont {Font::get(FONT_SIZE_MEDIUM)} + , mColor {0x000000FF} + , mBgColor {0} + , mRenderBackground {false} + , mUppercase {false} + , mAutoCalcExtent {1, 1} + , mHorizontalAlignment {ALIGN_LEFT} + , mVerticalAlignment {ALIGN_CENTER} + , mLineSpacing {1.5f} + , mNoTopMargin {false} + , mSelectable {false} { } @@ -36,18 +36,18 @@ TextComponent::TextComponent(Window* window, glm::vec3 pos, glm::vec2 size, unsigned int bgcolor) - : GuiComponent{window} - , mFont{nullptr} - , mColor{0x000000FF} - , mBgColor{0} - , mRenderBackground{false} - , mUppercase{false} - , mAutoCalcExtent{1, 1} - , mHorizontalAlignment{align} - , mVerticalAlignment{ALIGN_CENTER} - , mLineSpacing{1.5f} - , mNoTopMargin{false} - , mSelectable{false} + : GuiComponent {window} + , mFont {nullptr} + , mColor {0x000000FF} + , mBgColor {0} + , mRenderBackground {false} + , mUppercase {false} + , mAutoCalcExtent {1, 1} + , mHorizontalAlignment {align} + , mVerticalAlignment {ALIGN_CENTER} + , mLineSpacing {1.5f} + , mNoTopMargin {false} + , mSelectable {false} { setFont(font); setColor(color); @@ -59,7 +59,7 @@ TextComponent::TextComponent(Window* window, void TextComponent::onSizeChanged() { - mAutoCalcExtent = glm::ivec2{(getSize().x == 0), (getSize().y == 0)}; + mAutoCalcExtent = glm::ivec2 {(getSize().x == 0), (getSize().y == 0)}; onTextChanged(); } @@ -127,7 +127,7 @@ void TextComponent::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; if (mRenderBackground) { Renderer::setMatrix(trans); @@ -135,7 +135,7 @@ void TextComponent::render(const glm::mat4& parentTrans) } if (mTextCache) { - const glm::vec2& textSize{mTextCache->metrics.size}; + const glm::vec2& textSize {mTextCache->metrics.size}; float yOff = 0.0f; switch (mVerticalAlignment) { case ALIGN_TOP: { @@ -154,7 +154,7 @@ void TextComponent::render(const glm::mat4& parentTrans) break; } } - glm::vec3 off{0.0f, yOff, 0.0f}; + glm::vec3 off {0.0f, yOff, 0.0f}; if (Settings::getInstance()->getBool("DebugText")) { // Draw the "textbox" area, what we are aligned within. @@ -230,11 +230,11 @@ void TextComponent::onTextChanged() addAbbrev = newline != std::string::npos; } - glm::vec2 size{f->sizeText(text)}; + glm::vec2 size {f->sizeText(text)}; if (!isMultiline && mSize.x > 0.0f && text.size() && (size.x > mSize.x || addAbbrev)) { // Abbreviate text. const std::string abbrev = "..."; - glm::vec2 abbrevSize{f->sizeText(abbrev)}; + glm::vec2 abbrevSize {f->sizeText(abbrev)}; while (text.size() && size.x + abbrevSize.x > mSize.x) { size_t newSize = Utils::String::prevCursor(text, text.size()); @@ -247,12 +247,12 @@ void TextComponent::onTextChanged() text.append(abbrev); mTextCache = std::shared_ptr( - f->buildTextCache(text, glm::vec2{}, (mColor >> 8 << 8) | mOpacity, mSize.x, + f->buildTextCache(text, glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x, mHorizontalAlignment, mLineSpacing, mNoTopMargin)); } else { mTextCache = std::shared_ptr(f->buildTextCache( - f->wrapText(text, mSize.x), glm::vec2{}, (mColor >> 8 << 8) | mOpacity, mSize.x, + f->wrapText(text, mSize.x), glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x, mHorizontalAlignment, mLineSpacing, mNoTopMargin)); } } diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index e351a3c92..5fea9d0e9 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -19,15 +19,15 @@ #define BLINKTIME 1000 TextEditComponent::TextEditComponent(Window* window) - : GuiComponent{window} - , mFocused{false} - , mEditing{false} - , mCursor{0} - , mBlinkTime{0} - , mCursorRepeatDir{0} - , mScrollOffset{0.0f, 0.0f} - , mBox{window, ":/graphics/textinput.svg"} - , mFont{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} + : GuiComponent {window} + , mFocused {false} + , mEditing {false} + , mCursor {0} + , mBlinkTime {0} + , mCursorRepeatDir {0} + , mScrollOffset {0.0f, 0.0f} + , mBox {window, ":/graphics/textinput.svg"} + , mFont {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)} { mBox.setSharpCorners(true); addChild(&mBox); @@ -51,8 +51,8 @@ void TextEditComponent::onFocusLost() void TextEditComponent::onSizeChanged() { mBox.fitTo( - mSize, glm::vec3{}, - glm::vec2{-34.0f, -32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())}); + mSize, glm::vec3 {}, + glm::vec2 {-34.0f, -32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())}); onTextChanged(); // Wrap point probably changed. } @@ -269,7 +269,7 @@ void TextEditComponent::onTextChanged() void TextEditComponent::onCursorChanged() { if (isMultiline()) { - glm::vec2 textSize{mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor)}; + glm::vec2 textSize {mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor)}; // Need to scroll down? if (mScrollOffset.y + getTextAreaSize().y < textSize.y + mFont->getHeight()) @@ -279,7 +279,7 @@ void TextEditComponent::onCursorChanged() mScrollOffset.y = textSize.y; } else { - glm::vec2 cursorPos{mFont->sizeText(mText.substr(0, mCursor))}; + glm::vec2 cursorPos {mFont->sizeText(mText.substr(0, mCursor))}; if (mScrollOffset.x + getTextAreaSize().x < cursorPos.x) mScrollOffset.x = cursorPos.x - getTextAreaSize().x; @@ -290,24 +290,24 @@ void TextEditComponent::onCursorChanged() void TextEditComponent::render(const glm::mat4& parentTrans) { - glm::mat4 trans{getTransform() * parentTrans}; + glm::mat4 trans {getTransform() * parentTrans}; renderChildren(trans); // Text + cursor rendering. // Offset into our "text area" (padding). - trans = glm::translate(trans, glm::vec3{getTextAreaPos().x, getTextAreaPos().y, 0.0f}); + trans = glm::translate(trans, glm::vec3 {getTextAreaPos().x, getTextAreaPos().y, 0.0f}); - glm::ivec2 clipPos{static_cast(trans[3].x), static_cast(trans[3].y)}; + glm::ivec2 clipPos {static_cast(trans[3].x), static_cast(trans[3].y)}; // Use "text area" size for clipping. - glm::vec3 dimScaled{}; + glm::vec3 dimScaled {}; dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x); dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y); - glm::ivec2 clipDim{static_cast(dimScaled.x - trans[3].x), - static_cast(dimScaled.y - trans[3].y)}; + glm::ivec2 clipDim {static_cast(dimScaled.x - trans[3].x), + static_cast(dimScaled.y - trans[3].y)}; Renderer::pushClipRect(clipPos, clipDim); - trans = glm::translate(trans, glm::vec3{-mScrollOffset.x, -mScrollOffset.y, 0.0f}); + trans = glm::translate(trans, glm::vec3 {-mScrollOffset.x, -mScrollOffset.y, 0.0f}); Renderer::setMatrix(trans); if (mTextCache) @@ -343,14 +343,14 @@ void TextEditComponent::render(const glm::mat4& parentTrans) glm::vec2 TextEditComponent::getTextAreaPos() const { - return glm::vec2{(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()) / 2.0f, - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()) / 2.0f}; + return glm::vec2 {(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()) / 2.0f, + (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()) / 2.0f}; } glm::vec2 TextEditComponent::getTextAreaSize() const { - return glm::vec2{mSize.x - (TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()), - mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())}; + return glm::vec2 {mSize.x - (TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()), + mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())}; } std::vector TextEditComponent::getHelpPrompts() diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index c273164d7..c4d2cfc07 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -164,24 +164,24 @@ template void TextListComponent::render(const glm::mat4& parentT if (size() == 0) return; - glm::mat4 trans{parentTrans * getTransform()}; - std::shared_ptr& font{mFont}; + glm::mat4 trans {parentTrans * getTransform()}; + std::shared_ptr& font {mFont}; - int startEntry{0}; - float y{0.0f}; + int startEntry {0}; + float y {0.0f}; - const float entrySize{std::max(floorf(font->getHeight(1.0f)), - floorf(static_cast(font->getSize())) * mLineSpacing)}; - const float lineSpacingHeight{floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))}; + const float entrySize {std::max(floorf(font->getHeight(1.0f)), + floorf(static_cast(font->getSize())) * mLineSpacing)}; + const float lineSpacingHeight {floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))}; // This extra vertical margin is technically incorrect, but it adds a little extra leeway // to avoid removing the last row on some older theme sets. There was a sizing bug in the // RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly // too small for the last row to show up when the sizing calculation is done correctly. - const float extraMargin{(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)}; + const float extraMargin {(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)}; // Number of entries that can fit on the screen simultaneously. - int screenCount{ + int screenCount { static_cast(floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize))}; if (size() >= screenCount) { @@ -218,15 +218,15 @@ template void TextListComponent::render(const glm::mat4& parentT } // Clip to inside margins. - glm::vec3 dim{mSize.x, mSize.y, 0.0f}; + glm::vec3 dim {mSize.x, mSize.y, 0.0f}; dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x; dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y; Renderer::pushClipRect( - glm::ivec2{static_cast(std::round(trans[3].x + mHorizontalMargin)), - static_cast(std::round(trans[3].y))}, - glm::ivec2{static_cast(std::round(dim.x - mHorizontalMargin * 2.0f)), - static_cast(std::round(dim.y))}); + glm::ivec2 {static_cast(std::round(trans[3].x + mHorizontalMargin)), + static_cast(std::round(trans[3].y))}, + glm::ivec2 {static_cast(std::round(dim.x - mHorizontalMargin * 2.0f)), + static_cast(std::round(dim.y))}); for (int i = startEntry; i < listCutoff; ++i) { typename IList::Entry& entry = mEntries.at(static_cast(i)); @@ -250,7 +250,7 @@ template void TextListComponent::render(const glm::mat4& parentT else entry.data.textCache->setColor(color); - glm::vec3 offset{0.0f, y, 0.0f}; + glm::vec3 offset {0.0f, y, 0.0f}; switch (mAlignment) { case ALIGN_LEFT: @@ -271,12 +271,12 @@ template void TextListComponent::render(const glm::mat4& parentT } // Render text. - glm::mat4 drawTrans{trans}; + glm::mat4 drawTrans {trans}; // Currently selected item text might be looping. if (mCursor == i && mLoopOffset > 0) drawTrans = glm::translate( - drawTrans, offset - glm::vec3{static_cast(mLoopOffset), 0.0f, 0.0f}); + drawTrans, offset - glm::vec3 {static_cast(mLoopOffset), 0.0f, 0.0f}); else drawTrans = glm::translate(drawTrans, offset); @@ -292,7 +292,7 @@ template void TextListComponent::render(const glm::mat4& parentT mLoopScroll = true; drawTrans = trans; drawTrans = glm::translate( - drawTrans, offset - glm::vec3{static_cast(mLoopOffset2), 0.0f, 0.0f}); + drawTrans, offset - glm::vec3 {static_cast(mLoopOffset2), 0.0f, 0.0f}); Renderer::setMatrix(drawTrans); font->renderTextCache(entry.data.textCache.get()); } diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index 6a3f7977f..7ad25e459 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -178,7 +178,7 @@ void VideoComponent::render(const glm::mat4& parentTrans) if (!isVisible()) return; - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; GuiComponent::renderChildren(trans); Renderer::setMatrix(trans); @@ -225,9 +225,9 @@ void VideoComponent::applyTheme(const std::shared_ptr& theme, if (!elem) return; - glm::vec2 scale{getParent() ? getParent()->getSize() : - glm::vec2{static_cast(Renderer::getScreenWidth()), - static_cast(Renderer::getScreenHeight())}}; + glm::vec2 scale {getParent() ? getParent()->getSize() : + glm::vec2 {static_cast(Renderer::getScreenWidth()), + static_cast(Renderer::getScreenHeight())}}; if (properties & ThemeFlags::SIZE) { if (elem->has("size")) { diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 1359e9ffe..ac0c99ba9 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -60,7 +60,7 @@ VideoFFmpegComponent::~VideoFFmpegComponent() { stopVideo(); } void VideoFFmpegComponent::setResize(float width, float height) { // This resize function is used when stretching videos to full screen in the video screensaver. - mTargetSize = glm::vec2{width, height}; + mTargetSize = glm::vec2 {width, height}; mTargetIsMax = false; mStaticImage.setResize(width, height); resize(); @@ -70,7 +70,7 @@ void VideoFFmpegComponent::setMaxSize(float width, float height) { // This resize function is used in most instances, such as non-stretched video screensaver // and the gamelist videos. - mTargetSize = glm::vec2{width, height}; + mTargetSize = glm::vec2 {width, height}; mTargetIsMax = true; mStaticImage.setMaxSize(width, height); resize(); @@ -81,15 +81,15 @@ void VideoFFmpegComponent::resize() if (!mTexture) return; - const glm::vec2 textureSize{static_cast(mVideoWidth), static_cast(mVideoHeight)}; + const glm::vec2 textureSize {static_cast(mVideoWidth), static_cast(mVideoHeight)}; - if (textureSize == glm::vec2{}) + if (textureSize == glm::vec2 {}) return; if (mTargetIsMax) { mSize = textureSize; - glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; + glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)}; if (resizeScale.x < resizeScale.y) { mSize.x *= resizeScale.x; @@ -106,7 +106,7 @@ void VideoFFmpegComponent::resize() else { // If both components are set, we just stretch. // If no components are set, we don't resize at all. - mSize = mTargetSize == glm::vec2{} ? textureSize : mTargetSize; + mSize = mTargetSize == glm::vec2 {} ? textureSize : mTargetSize; // If only one component is set, we resize in a way that maintains aspect ratio. if (!mTargetSize.x && mTargetSize.y) { @@ -125,7 +125,7 @@ void VideoFFmpegComponent::resize() void VideoFFmpegComponent::render(const glm::mat4& parentTrans) { VideoComponent::render(parentTrans); - glm::mat4 trans{parentTrans * getTransform()}; + glm::mat4 trans {parentTrans * getTransform()}; GuiComponent::renderChildren(trans); if (mIsPlaying && mFormatContext) { @@ -864,7 +864,7 @@ void VideoFFmpegComponent::calculateBlackRectangle() // otherwise it will exactly match the video size. The reason to add a black rectangle // behind videos in this second instance is that the scanline rendering will make the // video partially transparent so this may avoid some unforseen issues with some themes. - if (mVideoAreaPos != glm::vec2{} && mVideoAreaSize != glm::vec2{}) { + if (mVideoAreaPos != glm::vec2 {} && mVideoAreaSize != glm::vec2 {}) { mVideoRectangleCoords.clear(); if (Settings::getInstance()->getBool("GamelistVideoPillarbox")) { diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index 8c5f91f2b..2e57e8e7b 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -25,7 +25,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, , mFirstRun(firstRun) , mForcedConfig(forcedConfig) , mBackground(window, ":/graphics/frame.svg") - , mGrid(window, glm::ivec2{1, 5}) + , mGrid(window, glm::ivec2 {1, 5}) { mHoldingConfig = nullptr; mHoldTime = 0; @@ -38,7 +38,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, mTitle = std::make_shared(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{1, 1}, + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {1, 1}, GridFlags::BORDER_BOTTOM); // Device info. @@ -55,7 +55,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, mDeviceInfo = std::make_shared( mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER); - mGrid.setEntry(mDeviceInfo, glm::ivec2{0, 1}, false, true); + mGrid.setEntry(mDeviceInfo, glm::ivec2 {0, 1}, false, true); // Message. if (numDevices > 0) { @@ -69,18 +69,18 @@ GuiDetectDevice::GuiDetectDevice(Window* window, 0x777777FF, ALIGN_CENTER); } - mGrid.setEntry(mMsg1, glm::ivec2{0, 2}, false, true); + mGrid.setEntry(mMsg1, glm::ivec2 {0, 2}, false, true); const std::string msg2str = firstRun ? "PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)" : "PRESS ESC TO CANCEL"; mMsg2 = std::make_shared(mWindow, msg2str, Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mMsg2, glm::ivec2{0, 3}, false, true); + mGrid.setEntry(mMsg2, glm::ivec2 {0, 3}, false, true); // Currently held device. mDeviceHeld = std::make_shared(mWindow, "", Font::get(FONT_SIZE_MEDIUM), 0xFFFFFFFF, ALIGN_CENTER); - mGrid.setEntry(mDeviceHeld, glm::ivec2{0, 4}, false, true); + mGrid.setEntry(mDeviceHeld, glm::ivec2 {0, 4}, false, true); // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. @@ -94,7 +94,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window, void GuiDetectDevice::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); // Grid. mGrid.setSize(mSize); diff --git a/es-core/src/guis/GuiInfoPopup.cpp b/es-core/src/guis/GuiInfoPopup.cpp index 2491c7e49..63b6809b3 100644 --- a/es-core/src/guis/GuiInfoPopup.cpp +++ b/es-core/src/guis/GuiInfoPopup.cpp @@ -54,15 +54,15 @@ GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration) setPosition(posX, posY, 0); mFrame->setImagePath(":/graphics/frame.svg"); - mFrame->fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mFrame->fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); addChild(mFrame); // We only initialize the actual time when we first start to render. mStartTime = 0; - mGrid = new ComponentGrid(window, glm::ivec2{1, 3}); + mGrid = new ComponentGrid(window, glm::ivec2 {1, 3}); mGrid->setSize(mSize); - mGrid->setEntry(s, glm::ivec2{0, 1}, false, true); + mGrid->setEntry(s, glm::ivec2 {0, 1}, false, true); addChild(mGrid); } @@ -75,7 +75,7 @@ GuiInfoPopup::~GuiInfoPopup() void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/) { // We use getIdentity() as we want to render on a specific window position, not on the view. - glm::mat4 trans{getTransform() * Renderer::getIdentity()}; + glm::mat4 trans {getTransform() * Renderer::getIdentity()}; if (mRunning && updateState()) { // If we're still supposed to be rendering it. Renderer::setMatrix(trans); diff --git a/es-core/src/guis/GuiInputConfig.cpp b/es-core/src/guis/GuiInputConfig.cpp index df0d39894..3d57f4d72 100644 --- a/es-core/src/guis/GuiInputConfig.cpp +++ b/es-core/src/guis/GuiInputConfig.cpp @@ -33,7 +33,7 @@ GuiInputConfig::GuiInputConfig(Window* window, const std::function& okCallback) : GuiComponent(window) , mBackground(window, ":/graphics/frame.svg") - , mGrid(window, glm::ivec2{1, 7}) + , mGrid(window, glm::ivec2 {1, 7}) , mTargetConfig(target) , mHoldingInput(false) { @@ -54,11 +54,11 @@ GuiInputConfig::GuiInputConfig(Window* window, addChild(&mGrid); // 0 is a spacer row. - mGrid.setEntry(std::make_shared(mWindow), glm::ivec2{0, 0}, false); + mGrid.setEntry(std::make_shared(mWindow), glm::ivec2 {0, 0}, false); mTitle = std::make_shared(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mTitle, glm::ivec2{0, 1}, false, true); + mGrid.setEntry(mTitle, glm::ivec2 {0, 1}, false, true); std::stringstream ss; if (target->getDeviceId() == DEVICE_KEYBOARD) @@ -70,7 +70,7 @@ GuiInputConfig::GuiInputConfig(Window* window, mSubtitle1 = std::make_shared(mWindow, Utils::String::toUpper(ss.str()), Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mSubtitle1, glm::ivec2{0, 2}, false, true); + mGrid.setEntry(mSubtitle1, glm::ivec2 {0, 2}, false, true); mSubtitle2 = std::make_shared(mWindow, "HOLD ANY BUTTON 1 SECOND TO SKIP", @@ -78,11 +78,11 @@ GuiInputConfig::GuiInputConfig(Window* window, // The opacity will be set to visible for any row that is skippable. mSubtitle2->setOpacity(0); - mGrid.setEntry(mSubtitle2, glm::ivec2{0, 3}, false, true); + mGrid.setEntry(mSubtitle2, glm::ivec2 {0, 3}, false, true); // 4 is a spacer row. mList = std::make_shared(mWindow); - mGrid.setEntry(mList, glm::ivec2{0, 5}, true, true); + mGrid.setEntry(mList, glm::ivec2 {0, 5}, true, true); for (int i = 0; i < inputCount; ++i) { ComponentListRow row; @@ -184,7 +184,7 @@ GuiInputConfig::GuiInputConfig(Window* window, std::make_shared(mWindow, "OK", "ok", [okFunction] { okFunction(); })); mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 6}, true, false); + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 6}, true, false); // Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent // regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. @@ -293,7 +293,7 @@ void GuiInputConfig::update(int deltaTime) void GuiInputConfig::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); // Update grid. mGrid.setSize(mSize); @@ -313,7 +313,7 @@ void GuiInputConfig::rowDone() // At bottom of list, we're done. mConfiguringAll = false; mConfiguringRow = false; - mGrid.moveCursor(glm::ivec2{0, 1}); + mGrid.moveCursor(glm::ivec2 {0, 1}); } else { // On another row. diff --git a/es-core/src/guis/GuiMsgBox.cpp b/es-core/src/guis/GuiMsgBox.cpp index 37d8bdcbc..8c405965c 100644 --- a/es-core/src/guis/GuiMsgBox.cpp +++ b/es-core/src/guis/GuiMsgBox.cpp @@ -28,7 +28,7 @@ GuiMsgBox::GuiMsgBox(Window* window, bool deleteOnButtonPress) : GuiComponent(window) , mBackground(window, ":/graphics/frame.svg") - , mGrid(window, glm::ivec2{1, 2}) + , mGrid(window, glm::ivec2 {1, 2}) , mHelpStyle(helpstyle) , mDisableBackButton(disableBackButton) , mDeleteOnButtonPress(deleteOnButtonPress) @@ -44,7 +44,7 @@ GuiMsgBox::GuiMsgBox(Window* window, mMsg = std::make_shared(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER); - mGrid.setEntry(mMsg, glm::ivec2{0, 0}, false, false); + mGrid.setEntry(mMsg, glm::ivec2 {0, 0}, false, false); // Create the buttons. mButtons.push_back(std::make_shared( @@ -72,7 +72,7 @@ GuiMsgBox::GuiMsgBox(Window* window, // Put the buttons into a ComponentGrid. mButtonGrid = makeButtonGrid(mWindow, mButtons); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, 1}, true, false, glm::ivec2{1, 1}, + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 1}, true, false, glm::ivec2 {1, 1}, GridFlags::BORDER_TOP); // Decide final width. @@ -167,7 +167,7 @@ void GuiMsgBox::onSizeChanged() mGrid.getRowHeight(0)); mGrid.onSizeChanged(); - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); } void GuiMsgBox::deleteMeAndCall(const std::function& func) diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp index 405af6ea6..a9a985870 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.cpp +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.cpp @@ -87,26 +87,26 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( const std::string& loadBtnHelpText, const std::string& clearBtnHelpText, const std::string& cancelBtnHelpText) - : GuiComponent{window} - , mBackground{window, ":/graphics/frame.svg"} - , mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 8 : 6)}} - , mHelpStyle{helpstyle} - , mInitValue{initValue} - , mAcceptBtnHelpText{acceptBtnHelpText} - , mSaveConfirmationText{saveConfirmationText} - , mLoadBtnHelpText{loadBtnHelpText} - , mClearBtnHelpText{clearBtnHelpText} - , mCancelBtnHelpText{cancelBtnHelpText} - , mOkCallback{okCallback} - , mMultiLine{multiLine} - , mComplexMode{(infoString != "" && defaultValue != "")} - , mDeleteRepeat{false} - , mShift{false} - , mAlt{false} - , mDeleteRepeatTimer{0} - , mNavigationRepeatTimer{0} - , mNavigationRepeatDirX{0} - , mNavigationRepeatDirY{0} + : GuiComponent {window} + , mBackground {window, ":/graphics/frame.svg"} + , mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}} + , mHelpStyle {helpstyle} + , mInitValue {initValue} + , mAcceptBtnHelpText {acceptBtnHelpText} + , mSaveConfirmationText {saveConfirmationText} + , mLoadBtnHelpText {loadBtnHelpText} + , mClearBtnHelpText {clearBtnHelpText} + , mCancelBtnHelpText {cancelBtnHelpText} + , mOkCallback {okCallback} + , mMultiLine {multiLine} + , mComplexMode {(infoString != "" && defaultValue != "")} + , mDeleteRepeat {false} + , mShift {false} + , mAlt {false} + , mDeleteRepeatTimer {0} + , mNavigationRepeatTimer {0} + , mNavigationRepeatDirX {0} + , mNavigationRepeatDirY {0} { addChild(&mBackground); addChild(&mGrid); @@ -134,23 +134,23 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( mText->setValue(initValue); // Header. - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true); int yPos = 1; if (mComplexMode) { mInfoString = std::make_shared( mWindow, infoString, Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mInfoString, glm::ivec2{0, yPos}, false, true); + mGrid.setEntry(mInfoString, glm::ivec2 {0, yPos}, false, true); mDefaultValue = std::make_shared( mWindow, defaultValue, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER); - mGrid.setEntry(mDefaultValue, glm::ivec2{0, yPos + 1}, false, true); + mGrid.setEntry(mDefaultValue, glm::ivec2 {0, yPos + 1}, false, true); yPos += 2; } // Text edit field. - mGrid.setEntry(mText, glm::ivec2{0, yPos}, true, false, glm::ivec2{1, 1}, + mGrid.setEntry(mText, glm::ivec2 {0, yPos}, true, false, glm::ivec2 {1, 1}, GridFlags::BORDER_TOP); std::vector>> buttonList; @@ -230,14 +230,14 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( break; } - mKeyboardGrid->setEntry(button, glm::ivec2{j, i}, true, true, - glm::ivec2{colSpan, rowSpan}); + mKeyboardGrid->setEntry(button, glm::ivec2 {j, i}, true, true, + glm::ivec2 {colSpan, rowSpan}); buttonList.push_back(buttons); } } - mGrid.setEntry(mKeyboardGrid, glm::ivec2{0, yPos + 1}, true, true, glm::ivec2{1, 4}); + mGrid.setEntry(mKeyboardGrid, glm::ivec2 {0, yPos + 1}, true, true, glm::ivec2 {1, 4}); float textHeight = mText->getFont()->getHeight(); // If the multiLine option has been set, then include three lines of text on screen. @@ -293,7 +293,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup( void GuiTextEditKeyboardPopup::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); mText->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX, mText->getSize().y); // Update grid. diff --git a/es-core/src/guis/GuiTextEditKeyboardPopup.h b/es-core/src/guis/GuiTextEditKeyboardPopup.h index b8660fdf0..dcd7c766b 100644 --- a/es-core/src/guis/GuiTextEditKeyboardPopup.h +++ b/es-core/src/guis/GuiTextEditKeyboardPopup.h @@ -53,11 +53,11 @@ private: const std::string& sk, const std::string& ak, const std::string& ask) - : button{b} - , key{k} - , shiftedKey{sk} - , altedKey{ak} - , altshiftedKey{ask} {}; + : button {b} + , key {k} + , shiftedKey {sk} + , altedKey {ak} + , altshiftedKey {ask} {}; }; void updateDeleteRepeat(int deltaTime); diff --git a/es-core/src/guis/GuiTextEditPopup.cpp b/es-core/src/guis/GuiTextEditPopup.cpp index 71d13cb5e..43d8fc765 100644 --- a/es-core/src/guis/GuiTextEditPopup.cpp +++ b/es-core/src/guis/GuiTextEditPopup.cpp @@ -28,21 +28,21 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, const std::string& loadBtnHelpText, const std::string& clearBtnHelpText, const std::string& cancelBtnHelpText) - : GuiComponent{window} - , mBackground{window, ":/graphics/frame.svg"} - , mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 5 : 3)}} - , mHelpStyle{helpstyle} - , mInitValue{initValue} - , mAcceptBtnText{acceptBtnText} - , mSaveConfirmationText{saveConfirmationText} - , mLoadBtnHelpText{loadBtnHelpText} - , mClearBtnHelpText{clearBtnHelpText} - , mCancelBtnHelpText{cancelBtnHelpText} - , mOkCallback{okCallback} - , mMultiLine{multiLine} - , mComplexMode{(infoString != "" && defaultValue != "")} - , mDeleteRepeat{false} - , mDeleteRepeatTimer{0} + : GuiComponent {window} + , mBackground {window, ":/graphics/frame.svg"} + , mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}} + , mHelpStyle {helpstyle} + , mInitValue {initValue} + , mAcceptBtnText {acceptBtnText} + , mSaveConfirmationText {saveConfirmationText} + , mLoadBtnHelpText {loadBtnHelpText} + , mClearBtnHelpText {clearBtnHelpText} + , mCancelBtnHelpText {cancelBtnHelpText} + , mOkCallback {okCallback} + , mMultiLine {multiLine} + , mComplexMode {(infoString != "" && defaultValue != "")} + , mDeleteRepeat {false} + , mDeleteRepeatTimer {0} { addChild(&mBackground); addChild(&mGrid); @@ -83,19 +83,19 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, mButtonGrid = makeButtonGrid(mWindow, buttons); - mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true); + mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true); int yPos = 1; if (mComplexMode) { - mGrid.setEntry(mInfoString, glm::ivec2{0, yPos}, false, true); - mGrid.setEntry(mDefaultValue, glm::ivec2{0, yPos + 1}, false, false); + mGrid.setEntry(mInfoString, glm::ivec2 {0, yPos}, false, true); + mGrid.setEntry(mDefaultValue, glm::ivec2 {0, yPos + 1}, false, false); yPos += 2; } - mGrid.setEntry(mText, glm::ivec2{0, yPos}, true, false, glm::ivec2{1, 1}, + mGrid.setEntry(mText, glm::ivec2 {0, yPos}, true, false, glm::ivec2 {1, 1}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM); - mGrid.setEntry(mButtonGrid, glm::ivec2{0, yPos + 1}, true, false); + mGrid.setEntry(mButtonGrid, glm::ivec2 {0, yPos + 1}, true, false); float textHeight = mText->getFont()->getHeight(); @@ -137,7 +137,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window, void GuiTextEditPopup::onSizeChanged() { - mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f}); + mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f}); mText->setSize(mSize.x - 40.0f * Renderer::getScreenHeightModifier(), mText->getSize().y); // Update grid. diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 8f6e86e8c..f2c7d0d81 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -316,8 +316,8 @@ namespace Renderer if (!createWindow()) return false; - glm::mat4 projection{getIdentity()}; - Rect viewport{0, 0, 0, 0}; + glm::mat4 projection {getIdentity()}; + Rect viewport {0, 0, 0, 0}; switch (screenRotate) { case 1: { diff --git a/es-core/src/renderers/Renderer.h b/es-core/src/renderers/Renderer.h index 132bca202..8e14bb575 100644 --- a/es-core/src/renderers/Renderer.h +++ b/es-core/src/renderers/Renderer.h @@ -20,13 +20,13 @@ struct SDL_Window; namespace Renderer { - const unsigned int SHADER_DESATURATE{1}; - const unsigned int SHADER_OPACITY{2}; - const unsigned int SHADER_DIM{4}; - const unsigned int SHADER_BLUR_HORIZONTAL{8}; - const unsigned int SHADER_BLUR_VERTICAL{16}; - const unsigned int SHADER_SCANLINES{32}; - const unsigned int SHADER_BGRA_TO_RGBA{64}; + const unsigned int SHADER_DESATURATE {1}; + const unsigned int SHADER_OPACITY {2}; + const unsigned int SHADER_DIM {4}; + const unsigned int SHADER_BLUR_HORIZONTAL {8}; + const unsigned int SHADER_BLUR_VERTICAL {16}; + const unsigned int SHADER_SCANLINES {32}; + const unsigned int SHADER_BGRA_TO_RGBA {64}; struct shaderParameters { std::array textureSize; @@ -37,12 +37,12 @@ namespace Renderer unsigned int blurPasses; shaderParameters() - : textureSize{0.0f, 0.0f} - , textureCoordinates{0.0f, 0.0f, 0.0f, 0.0f} - , fragmentSaturation{1.0f} - , fragmentDimValue{0.4f} - , fragmentOpacity{1.0f} - , blurPasses{1} + : textureSize {0.0f, 0.0f} + , textureCoordinates {0.0f, 0.0f, 0.0f, 0.0f} + , fragmentSaturation {1.0f} + , fragmentDimValue {0.4f} + , fragmentOpacity {1.0f} + , blurPasses {1} { } }; @@ -52,7 +52,7 @@ namespace Renderer // This is simply to get rid of a GCC false positive -Wunused-variable compiler warning. static GLuint shaderFBODummy = shaderFBO; - static constexpr glm::mat4 getIdentity() { return glm::mat4{1.0f}; } + static constexpr glm::mat4 getIdentity() { return glm::mat4 {1.0f}; } #if !defined(NDEBUG) #define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function)) @@ -125,9 +125,9 @@ namespace Renderer glm::vec2 pos; glm::vec2 tex; unsigned int col; - float saturation{1.0}; - float opacity{1.0}; - unsigned int shaders{0}; + float saturation {1.0}; + float opacity {1.0}; + unsigned int shaders {0}; }; bool init(); diff --git a/es-core/src/renderers/Renderer_GL21.cpp b/es-core/src/renderers/Renderer_GL21.cpp index d80797002..bd5e97d4d 100644 --- a/es-core/src/renderers/Renderer_GL21.cpp +++ b/es-core/src/renderers/Renderer_GL21.cpp @@ -379,7 +379,7 @@ namespace Renderer void setMatrix(const glm::mat4& matrix) { - glm::mat4 newMatrix{matrix}; + glm::mat4 newMatrix {matrix}; newMatrix[3] = glm::round(newMatrix[3]); GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW)); diff --git a/es-core/src/renderers/Renderer_GLES10.cpp b/es-core/src/renderers/Renderer_GLES10.cpp index 86210ee47..d966ac117 100644 --- a/es-core/src/renderers/Renderer_GLES10.cpp +++ b/es-core/src/renderers/Renderer_GLES10.cpp @@ -128,10 +128,10 @@ namespace Renderer // Not sure why the corresponding variables are missing in the OpenGL ES include files // when specifying the values manually seems to work with all graphics drivers. - int _GL_TEXTURE_SWIZZLE_R{0x8E42}; - int _GL_TEXTURE_SWIZZLE_B{0x8E44}; - int _GL_RED{0x1903}; - int _GL_BLUE{0x1905}; + int _GL_TEXTURE_SWIZZLE_R {0x8E42}; + int _GL_TEXTURE_SWIZZLE_B {0x8E44}; + int _GL_RED {0x1903}; + int _GL_BLUE {0x1905}; // Convert from BGRA to RGBA. if (format == Texture::Type::BGRA) { @@ -223,7 +223,7 @@ namespace Renderer void setMatrix(const glm::mat4& matrix) { - glm::mat4 newMatrix{matrix}; + glm::mat4 newMatrix {matrix}; newMatrix[3] = glm::round(newMatrix[3]); GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW)); diff --git a/es-core/src/renderers/Renderer_GLES20.cpp b/es-core/src/renderers/Renderer_GLES20.cpp index 62a72a024..a6e3b1042 100644 --- a/es-core/src/renderers/Renderer_GLES20.cpp +++ b/es-core/src/renderers/Renderer_GLES20.cpp @@ -18,40 +18,40 @@ namespace Renderer { - static SDL_GLContext sdlContext{nullptr}; - static glm::mat4 projectionMatrix{getIdentity()}; - glm::mat4 worldViewMatrix{getIdentity()}; - static GLuint shaderProgram{0}; - static GLint mvpUniform{0}; - static GLint texAttrib{0}; - static GLint colAttrib{0}; - static GLint posAttrib{0}; - static GLuint vertexBuffer{0}; - static GLuint whiteTexture{0}; + static SDL_GLContext sdlContext {nullptr}; + static glm::mat4 projectionMatrix {getIdentity()}; + glm::mat4 worldViewMatrix {getIdentity()}; + static GLuint shaderProgram {0}; + static GLint mvpUniform {0}; + static GLint texAttrib {0}; + static GLint colAttrib {0}; + static GLint posAttrib {0}; + static GLuint vertexBuffer {0}; + static GLuint whiteTexture {0}; static void setupShaders() { // Vertex shader. - const GLchar* vertexSource{"uniform mat4 u_mvp; \n" - "attribute vec2 a_pos; \n" - "attribute vec2 a_tex; \n" - "attribute vec4 a_col; \n" - "varying vec2 v_tex; \n" - "varying vec4 v_col; \n" - "void main(void) \n" - "{ \n" - " gl_Position = u_mvp * vec4(a_pos.xy, 0.0, 1.0); \n" - " v_tex = a_tex; \n" - " v_col = a_col; \n" - "} \n"}; + const GLchar* vertexSource {"uniform mat4 u_mvp; \n" + "attribute vec2 a_pos; \n" + "attribute vec2 a_tex; \n" + "attribute vec4 a_col; \n" + "varying vec2 v_tex; \n" + "varying vec4 v_col; \n" + "void main(void) \n" + "{ \n" + " gl_Position = u_mvp * vec4(a_pos.xy, 0.0, 1.0); \n" + " v_tex = a_tex; \n" + " v_col = a_col; \n" + "} \n"}; - const GLuint vertexShader{glCreateShader(GL_VERTEX_SHADER)}; + const GLuint vertexShader {glCreateShader(GL_VERTEX_SHADER)}; GL_CHECK_ERROR(glShaderSource(vertexShader, 1, &vertexSource, nullptr)); GL_CHECK_ERROR(glCompileShader(vertexShader)); { - GLint isCompiled{GL_FALSE}; - GLint maxLength{0}; + GLint isCompiled {GL_FALSE}; + GLint maxLength {0}; GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &isCompiled)); GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &maxLength)); @@ -76,22 +76,22 @@ namespace Renderer } // Fragment shader. - const GLchar* fragmentSource{"precision highp float; \n" - "uniform sampler2D u_tex; \n" - "varying vec2 v_tex; \n" - "varying vec4 v_col; \n" - "void main(void) \n" - "{ \n" - " gl_FragColor = texture2D(u_tex, v_tex) * v_col; \n" - "} \n"}; + const GLchar* fragmentSource {"precision highp float; \n" + "uniform sampler2D u_tex; \n" + "varying vec2 v_tex; \n" + "varying vec4 v_col; \n" + "void main(void) \n" + "{ \n" + " gl_FragColor = texture2D(u_tex, v_tex) * v_col; \n" + "} \n"}; - const GLuint fragmentShader{glCreateShader(GL_FRAGMENT_SHADER)}; + const GLuint fragmentShader {glCreateShader(GL_FRAGMENT_SHADER)}; GL_CHECK_ERROR(glShaderSource(fragmentShader, 1, &fragmentSource, nullptr)); GL_CHECK_ERROR(glCompileShader(fragmentShader)); { - GLint isCompiled{GL_FALSE}; - GLint maxLength{0}; + GLint isCompiled {GL_FALSE}; + GLint maxLength {0}; GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &isCompiled)); GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &maxLength)); @@ -123,8 +123,8 @@ namespace Renderer GL_CHECK_ERROR(glLinkProgram(shaderProgram)); { - GLint isCompiled{GL_FALSE}; - GLint maxLength{0}; + GLint isCompiled {GL_FALSE}; + GLint maxLength {0}; GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_LINK_STATUS, &isCompiled)); GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &maxLength)); @@ -270,7 +270,7 @@ namespace Renderer const unsigned int height, void* data) { - const GLenum textureType{convertTextureType(type)}; + const GLenum textureType {convertTextureType(type)}; unsigned int texture; GL_CHECK_ERROR(glGenTextures(1, &texture)); @@ -278,10 +278,10 @@ namespace Renderer // Not sure why the corresponding variables are missing in the OpenGL ES include files // when specifying the values manually seems to work with all graphics drivers. - int _GL_TEXTURE_SWIZZLE_R{0x8E42}; - int _GL_TEXTURE_SWIZZLE_B{0x8E44}; - int _GL_RED{0x1903}; - int _GL_BLUE{0x1905}; + int _GL_TEXTURE_SWIZZLE_R {0x8E42}; + int _GL_TEXTURE_SWIZZLE_B {0x8E44}; + int _GL_RED {0x1903}; + int _GL_BLUE {0x1905}; // Convert from BGRA to RGBA. if (format == Texture::Type::BGRA) { @@ -300,8 +300,8 @@ namespace Renderer // Regular GL_ALPHA textures are black + alpha when used in shaders, so create a // GL_LUMINANCE_ALPHA texture instead so it's white + alpha. if (textureType == GL_LUMINANCE_ALPHA) { - uint8_t* a_data{reinterpret_cast(data)}; - uint8_t* la_data{new uint8_t[width * height * 2]}; + uint8_t* a_data {reinterpret_cast(data)}; + uint8_t* la_data {new uint8_t[width * height * 2]}; for (uint32_t i = 0; i < (width * height); ++i) { la_data[(i * 2) + 0] = 255; la_data[(i * 2) + 1] = a_data ? a_data[i] : 255; @@ -340,8 +340,8 @@ namespace Renderer // Regular GL_ALPHA textures are black + alpha when used in shaders, so create a // GL_LUMINANCE_ALPHA texture instead so it's white + alpha. if (textureType == GL_LUMINANCE_ALPHA) { - uint8_t* a_data{reinterpret_cast(data)}; - uint8_t* la_data{new uint8_t[width * height * 2]}; + uint8_t* a_data {reinterpret_cast(data)}; + uint8_t* la_data {new uint8_t[width * height * 2]}; for (uint32_t i = 0; i < (width * height); ++i) { la_data[(i * 2) + 0] = 255; la_data[(i * 2) + 1] = a_data ? a_data[i] : 255; @@ -416,7 +416,7 @@ namespace Renderer { projectionMatrix = projection; - glm::mat4 mvpMatrix{projectionMatrix * worldViewMatrix}; + glm::mat4 mvpMatrix {projectionMatrix * worldViewMatrix}; GL_CHECK_ERROR( glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast(&mvpMatrix))); } @@ -426,7 +426,7 @@ namespace Renderer worldViewMatrix = matrix; worldViewMatrix[3] = glm::round(worldViewMatrix[3]); - glm::mat4 mvpMatrix{projectionMatrix * worldViewMatrix}; + glm::mat4 mvpMatrix {projectionMatrix * worldViewMatrix}; GL_CHECK_ERROR( glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast(&mvpMatrix))); } diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index cf06f3204..c27d8a146 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -145,7 +145,7 @@ Font::FontTexture::FontTexture(const int mSize) // This is a hack to add some extra texture size when running at very low resolutions. If not // doing this, the use of fallback fonts (such as Japanese characters) could result in the // texture not fitting the glyphs which would crash the application. - int extraTextureSize{0}; + int extraTextureSize {0}; const float screenSizeModifier = std::min(Renderer::getScreenWidthModifier(), Renderer::getScreenHeightModifier()); @@ -157,8 +157,8 @@ Font::FontTexture::FontTexture(const int mSize) // It's not entirely clear if the 18 and 6 constants are correct, but they seem to provide // a texture buffer large enough to hold the fonts (otherwise the application would crash). // This logic is obviously a hack though and needs to be properly reviewed and improved. - textureSize = glm::ivec2{mSize * (18 + extraTextureSize), mSize * (6 + extraTextureSize / 2)}; - writePos = glm::ivec2{}; + textureSize = glm::ivec2 {mSize * (18 + extraTextureSize), mSize * (6 + extraTextureSize / 2)}; + writePos = glm::ivec2 {}; rowHeight = 0; } @@ -177,7 +177,7 @@ bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out writePos.y + rowHeight + size.y + 1 < textureSize.y) { // Row full, but it should fit on the next row so move the cursor there. // Leave 1px of space between glyphs. - writePos = glm::ivec2{0, writePos.y + rowHeight + 1}; + writePos = glm::ivec2 {0, writePos.y + rowHeight + 1}; rowHeight = 0; } @@ -317,7 +317,7 @@ Font::Glyph* Font::getGlyph(unsigned int id) return nullptr; } - glm::ivec2 glyphSize{g->bitmap.width, g->bitmap.rows}; + glm::ivec2 glyphSize {g->bitmap.width, g->bitmap.rows}; FontTexture* tex = nullptr; glm::ivec2 cursor; @@ -335,15 +335,15 @@ Font::Glyph* Font::getGlyph(unsigned int id) Glyph& glyph = mGlyphMap[id]; glyph.texture = tex; - glyph.texPos = glm::vec2{cursor.x / static_cast(tex->textureSize.x), - cursor.y / static_cast(tex->textureSize.y)}; - glyph.texSize = glm::vec2{glyphSize.x / static_cast(tex->textureSize.x), - glyphSize.y / static_cast(tex->textureSize.y)}; + glyph.texPos = glm::vec2 {cursor.x / static_cast(tex->textureSize.x), + cursor.y / static_cast(tex->textureSize.y)}; + glyph.texSize = glm::vec2 {glyphSize.x / static_cast(tex->textureSize.x), + glyphSize.y / static_cast(tex->textureSize.y)}; - glyph.advance = glm::vec2{static_cast(g->metrics.horiAdvance) / 64.0f, - static_cast(g->metrics.vertAdvance) / 64.0f}; - glyph.bearing = glm::vec2{static_cast(g->metrics.horiBearingX) / 64.0f, - static_cast(g->metrics.horiBearingY) / 64.0f}; + glyph.advance = glm::vec2 {static_cast(g->metrics.horiAdvance) / 64.0f, + static_cast(g->metrics.vertAdvance) / 64.0f}; + glyph.bearing = glm::vec2 {static_cast(g->metrics.horiBearingX) / 64.0f, + static_cast(g->metrics.horiBearingY) / 64.0f}; // Upload glyph bitmap to texture. Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y, @@ -374,10 +374,10 @@ void Font::rebuildTextures() FontTexture* tex = it->second.texture; // Find the position/size. - glm::ivec2 cursor{static_cast(it->second.texPos.x * tex->textureSize.x), - static_cast(it->second.texPos.y * tex->textureSize.y)}; - glm::ivec2 glyphSize{static_cast(it->second.texSize.x * tex->textureSize.x), - static_cast(it->second.texSize.y * tex->textureSize.y)}; + glm::ivec2 cursor {static_cast(it->second.texPos.x * tex->textureSize.x), + static_cast(it->second.texPos.y * tex->textureSize.y)}; + glm::ivec2 glyphSize {static_cast(it->second.texSize.x * tex->textureSize.x), + static_cast(it->second.texSize.y * tex->textureSize.y)}; // Upload to texture. Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y, @@ -432,7 +432,7 @@ glm::vec2 Font::sizeText(std::string text, float lineSpacing) if (lineWidth > highestWidth) highestWidth = lineWidth; - return glm::vec2{highestWidth, y}; + return glm::vec2 {highestWidth, y}; } std::string Font::getTextMaxWidth(std::string text, float maxWidth) @@ -557,7 +557,7 @@ glm::vec2 Font::getWrappedTextCursorOffset(std::string text, lineWidth += glyph->advance.x; } - return glm::vec2{lineWidth, y}; + return glm::vec2 {lineWidth, y}; } // @@ -652,8 +652,8 @@ TextCache* Font::buildTextCache(const std::string& text, verts.resize(oldVertSize + 6); Renderer::Vertex* vertices = verts.data() + oldVertSize; - const float glyphStartX{x + glyph->bearing.x}; - const glm::ivec2& textureSize{glyph->texture->textureSize}; + const float glyphStartX {x + glyph->bearing.x}; + const glm::ivec2& textureSize {glyph->texture->textureSize}; const unsigned int convertedColor = Renderer::convertRGBAToABGR(color); vertices[1] = {{glyphStartX, y - glyph->bearing.y}, @@ -705,7 +705,7 @@ TextCache* Font::buildTextCache(const std::string& text, float lineSpacing, bool noTopMargin) { - return buildTextCache(text, glm::vec2{offsetX, offsetY}, color, 0.0f, ALIGN_LEFT, lineSpacing, + return buildTextCache(text, glm::vec2 {offsetX, offsetY}, color, 0.0f, ALIGN_LEFT, lineSpacing, noTopMargin); } diff --git a/es-core/src/resources/TextureData.cpp b/es-core/src/resources/TextureData.cpp index 29de4858e..5b233a9c3 100644 --- a/es-core/src/resources/TextureData.cpp +++ b/es-core/src/resources/TextureData.cpp @@ -24,19 +24,19 @@ #define DPI 96 TextureData::TextureData(bool tile) - : mTile{tile} - , mTextureID{0} + : mTile {tile} + , mTextureID {0} , mDataRGBA({}) - , mFormat{Renderer::Texture::RGBA} - , mWidth{0} - , mHeight{0} - , mSourceWidth{0.0f} - , mSourceHeight{0.0f} - , mScalable{false} - , mHasRGBAData{false} - , mPendingRasterization{false} - , mLinearMagnify{false} - , mForceRasterization{false} + , mFormat {Renderer::Texture::RGBA} + , mWidth {0} + , mHeight {0} + , mSourceWidth {0.0f} + , mSourceHeight {0.0f} + , mScalable {false} + , mHasRGBAData {false} + , mPendingRasterization {false} + , mLinearMagnify {false} + , mForceRasterization {false} { } @@ -56,20 +56,20 @@ void TextureData::initFromPath(const std::string& path) bool TextureData::initSVGFromMemory(const std::string& fileData) { - std::unique_lock lock{mMutex}; + std::unique_lock lock {mMutex}; // If already initialized then don't process it again unless it needs to be rasterized. if (!mDataRGBA.empty() && !mPendingRasterization) return true; - NSVGimage* svgImage{nsvgParse(const_cast(fileData.c_str()), "px", DPI)}; + NSVGimage* svgImage {nsvgParse(const_cast(fileData.c_str()), "px", DPI)}; if (!svgImage || svgImage->width == 0 || svgImage->height == 0) { LOG(LogError) << "Couldn't parse SVG image"; return false; } - bool rasterize{true}; + bool rasterize {true}; // If there is no image size defined yet, then don't rasterize unless mForceRasterization has // been set. diff --git a/es-core/src/resources/TextureData.h b/es-core/src/resources/TextureData.h index 5946db389..08ac57e30 100644 --- a/es-core/src/resources/TextureData.h +++ b/es-core/src/resources/TextureData.h @@ -57,7 +57,7 @@ public: float sourceWidth(); float sourceHeight(); void setSourceSize(float width, float height); - glm::vec2 getSize() { return glm::vec2{static_cast(mWidth), static_cast(mHeight)}; } + glm::vec2 getSize() { return glm::vec2 {static_cast(mWidth), static_cast(mHeight)}; } // Whether to use linear filtering when magnifying the texture. void setLinearMagnify(bool setting) { mLinearMagnify = setting; } diff --git a/es-core/src/resources/TextureResource.cpp b/es-core/src/resources/TextureResource.cpp index 8b8666415..cd2b98f76 100644 --- a/es-core/src/resources/TextureResource.cpp +++ b/es-core/src/resources/TextureResource.cpp @@ -44,15 +44,15 @@ TextureResource::TextureResource( data->load(); } - mSize = glm::ivec2{static_cast(data->width()), static_cast(data->height())}; - mSourceSize = glm::vec2{data->sourceWidth(), data->sourceHeight()}; + mSize = glm::ivec2 {static_cast(data->width()), static_cast(data->height())}; + mSourceSize = glm::vec2 {data->sourceWidth(), data->sourceHeight()}; } else { // Create a texture managed by this class because it cannot be dynamically // loaded and unloaded. This would normally be a video texture, where the player // reserves a texture to later be used for the video rendering. mTextureData = std::shared_ptr(new TextureData(tile)); - mSize = glm::ivec2{}; + mSize = glm::ivec2 {}; } sAllTextures.insert(this); } @@ -73,8 +73,8 @@ void TextureResource::initFromPixels(const unsigned char* dataRGBA, size_t width mTextureData->releaseRAM(); mTextureData->initFromRGBA(dataRGBA, width, height); // Cache the image dimensions. - mSize = glm::ivec2{static_cast(width), static_cast(height)}; - mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()}; + mSize = glm::ivec2 {static_cast(width), static_cast(height)}; + mSourceSize = glm::vec2 {mTextureData->sourceWidth(), mTextureData->sourceHeight()}; } void TextureResource::initFromMemory(const char* data, size_t length) @@ -85,9 +85,9 @@ void TextureResource::initFromMemory(const char* data, size_t length) mTextureData->releaseRAM(); mTextureData->initImageFromMemory(reinterpret_cast(data), length); // Get the size from the texture data. - mSize = glm::ivec2{static_cast(mTextureData->width()), - static_cast(mTextureData->height())}; - mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()}; + mSize = glm::ivec2 {static_cast(mTextureData->width()), + static_cast(mTextureData->height())}; + mSourceSize = glm::vec2 {mTextureData->sourceWidth(), mTextureData->sourceHeight()}; } void TextureResource::manualUnload(std::string path, bool tile) @@ -205,7 +205,7 @@ void TextureResource::rasterizeAt(float width, float height) data = mTextureData; else data = sTextureDataManager.get(this); - mSourceSize = glm::vec2{static_cast(width), static_cast(height)}; + mSourceSize = glm::vec2 {static_cast(width), static_cast(height)}; data->setSourceSize(static_cast(width), static_cast(height)); if (mForceLoad || mTextureData != nullptr) data->load(); @@ -228,7 +228,7 @@ size_t TextureResource::getTotalMemUsage() size_t TextureResource::getTotalTextureSize() { - size_t total{0}; + size_t total {0}; // Count up all textures that manage their own texture data. for (auto tex : sAllTextures) { if (tex->mTextureData != nullptr) diff --git a/es-core/src/utils/MathUtil.cpp b/es-core/src/utils/MathUtil.cpp index af64471c4..e97718d21 100644 --- a/es-core/src/utils/MathUtil.cpp +++ b/es-core/src/utils/MathUtil.cpp @@ -22,13 +22,13 @@ namespace Utils { float smoothStep(const float left, const float right, const float value) { - const float x{glm::clamp((value - left) / (right - left), 0.0f, 1.0f)}; + const float x {glm::clamp((value - left) / (right - left), 0.0f, 1.0f)}; return x * x * (3.0f - (2.0f * x)); } float smootherStep(const float left, const float right, const float value) { - const float x{glm::clamp((value - left) / (right - left), 0.0f, 1.0f)}; + const float x {glm::clamp((value - left) / (right - left), 0.0f, 1.0f)}; return x * x * x * (x * ((x * 6.0f) - 15.0f) + 10.0f); } @@ -43,7 +43,7 @@ namespace Utils } else if (currentTime < (delayTime + scrollTime)) { // Interpolate from 0 to scrollLength. - const float fraction{(currentTime - delayTime) / scrollTime}; + const float fraction {(currentTime - delayTime) / scrollTime}; return glm::mix(0.0f, scrollLength, fraction); } @@ -62,7 +62,7 @@ namespace Utils } else if (currentTime < (delayTime + scrollTime)) { // Interpolate from 0 to scrollLength. - const float fraction{(currentTime - delayTime) / scrollTime}; + const float fraction {(currentTime - delayTime) / scrollTime}; return glm::mix(0.0f, scrollLength, smootherStep(0.0f, 1.0f, fraction)); } else if (currentTime < (delayTime + scrollTime + delayTime)) { @@ -71,8 +71,8 @@ namespace Utils } else if (currentTime < (delayTime + scrollTime + delayTime + scrollTime)) { // Interpolate back from scrollLength to 0. - const float fraction{(currentTime - delayTime - scrollTime - delayTime) / - scrollTime}; + const float fraction {(currentTime - delayTime - scrollTime - delayTime) / + scrollTime}; return glm::mix(scrollLength, 0.0f, smootherStep(0.0f, 1.0f, fraction)); } // And back to waiting. @@ -82,9 +82,9 @@ namespace Utils std::string md5Hash(const std::string& data) { // Data that didn't fit in last 64 byte chunk. - unsigned char buffer[64]{}; + unsigned char buffer[64] {}; // 64 bit counter for the number of bits (low, high). - unsigned int count[2]{}; + unsigned int count[2] {}; // Digest so far. unsigned int state[4]; @@ -98,10 +98,10 @@ namespace Utils md5Update(reinterpret_cast(data.c_str()), static_cast(data.length()), state, count, buffer); - static unsigned char padding[64]{0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + static unsigned char padding[64] {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4. auto encodeFunc = [](unsigned char output[], const unsigned int input[], @@ -181,11 +181,11 @@ namespace Utils void md5Transform(const unsigned char block[64], unsigned int (&state)[4]) { - unsigned int a{state[0]}; - unsigned int b{state[1]}; - unsigned int c{state[2]}; - unsigned int d{state[3]}; - unsigned int x[16]{}; + unsigned int a {state[0]}; + unsigned int b {state[1]}; + unsigned int c {state[2]}; + unsigned int d {state[3]}; + unsigned int x[16] {}; // Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4. for (unsigned int i = 0, j = 0; j < 64; ++i, j += 4) @@ -194,22 +194,22 @@ namespace Utils ((static_cast(block[j + 2])) << 16) | ((static_cast(block[j + 3])) << 24); - const unsigned int S11{7}; - const unsigned int S12{12}; - const unsigned int S13{17}; - const unsigned int S14{22}; - const unsigned int S21{5}; - const unsigned int S22{9}; - const unsigned int S23{14}; - const unsigned int S24{20}; - const unsigned int S31{4}; - const unsigned int S32{11}; - const unsigned int S33{16}; - const unsigned int S34{23}; - const unsigned int S41{6}; - const unsigned int S42{10}; - const unsigned int S43{15}; - const unsigned int S44{21}; + const unsigned int S11 {7}; + const unsigned int S12 {12}; + const unsigned int S13 {17}; + const unsigned int S14 {22}; + const unsigned int S21 {5}; + const unsigned int S22 {9}; + const unsigned int S23 {14}; + const unsigned int S24 {20}; + const unsigned int S31 {4}; + const unsigned int S32 {11}; + const unsigned int S33 {16}; + const unsigned int S34 {23}; + const unsigned int S41 {6}; + const unsigned int S42 {10}; + const unsigned int S43 {15}; + const unsigned int S44 {21}; // fFunc, gFunc, hFunc and iFunc are basic MD5 functions. auto fFunc = [](unsigned int x, unsigned int y, unsigned int z) { diff --git a/es-core/src/utils/PlatformUtil.cpp b/es-core/src/utils/PlatformUtil.cpp index e0bb93df6..8a20e52ab 100644 --- a/es-core/src/utils/PlatformUtil.cpp +++ b/es-core/src/utils/PlatformUtil.cpp @@ -144,7 +144,7 @@ namespace Utils int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool hideWindow) { #if defined(_WIN64) - STARTUPINFOW si{}; + STARTUPINFOW si {}; PROCESS_INFORMATION pi; si.cb = sizeof(si); @@ -172,8 +172,8 @@ namespace Utils // clang-format on if (!runInBackground) { - int width{}; - int height{}; + int width {}; + int height {}; // Hack to make the emulator window render correctly when launching games while // running in full screen mode. If not done, the emulator window will simply be