diff --git a/es-app/src/CollectionSystemsManager.cpp b/es-app/src/CollectionSystemsManager.cpp index d6a7f90ec..388ee5c1d 100644 --- a/es-app/src/CollectionSystemsManager.cpp +++ b/es-app/src/CollectionSystemsManager.cpp @@ -516,7 +516,8 @@ void CollectionSystemsManager::deleteCollectionFiles(FileData* file) } } -bool CollectionSystemsManager::isThemeGenericCollectionCompatible(bool genericCustomCollections) +const bool CollectionSystemsManager::isThemeGenericCollectionCompatible( + bool genericCustomCollections) { std::vector cfgSys = getCollectionThemeFolders(genericCustomCollections); for (auto sysIt = cfgSys.cbegin(); sysIt != cfgSys.cend(); sysIt++) { @@ -526,8 +527,8 @@ bool CollectionSystemsManager::isThemeGenericCollectionCompatible(bool genericCu return true; } -bool CollectionSystemsManager::isThemeCustomCollectionCompatible( - std::vector stringVector) +const bool CollectionSystemsManager::isThemeCustomCollectionCompatible( + const std::vector& stringVector) { if (isThemeGenericCollectionCompatible(true)) return true; @@ -548,7 +549,8 @@ bool CollectionSystemsManager::isThemeCustomCollectionCompatible( return true; } -std::string CollectionSystemsManager::getValidNewCollectionName(std::string inName, int index) +std::string CollectionSystemsManager::getValidNewCollectionName(const std::string& inName, + int index) { std::string name = inName; @@ -602,7 +604,7 @@ std::string CollectionSystemsManager::getValidNewCollectionName(std::string inNa return name; } -void CollectionSystemsManager::setEditMode(std::string collectionName, bool showPopup) +void CollectionSystemsManager::setEditMode(const std::string& collectionName, bool showPopup) { if (mCustomCollectionSystemsData.find(collectionName) == mCustomCollectionSystemsData.cend()) { LOG(LogError) << "Tried to edit a non-existing collection: " << collectionName; @@ -645,8 +647,8 @@ void CollectionSystemsManager::exitEditMode(bool showPopup) mEditingCollectionSystemData->system->onMetaDataSavePoint(); } -bool CollectionSystemsManager::inCustomCollection(const std::string& collectionName, - FileData* gameFile) +const bool CollectionSystemsManager::inCustomCollection(const std::string& collectionName, + FileData* gameFile) { auto collectionEntry = mCustomCollectionSystemsData.find(collectionName); @@ -658,7 +660,7 @@ bool CollectionSystemsManager::inCustomCollection(const std::string& collectionN return false; } -bool CollectionSystemsManager::toggleGameInCollection(FileData* file) +const bool CollectionSystemsManager::toggleGameInCollection(FileData* file) { if (file->getType() == GAME) { bool adding = true; @@ -903,7 +905,7 @@ std::vector CollectionSystemsManager::getUnusedSystemsFromTheme() return themeSys; } -SystemData* CollectionSystemsManager::addNewCustomCollection(std::string name) +SystemData* CollectionSystemsManager::addNewCustomCollection(const std::string& name) { CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName]; decl.themeFolder = name; @@ -913,7 +915,7 @@ SystemData* CollectionSystemsManager::addNewCustomCollection(std::string name) return createNewCollectionEntry(name, decl, true, true); } -void CollectionSystemsManager::deleteCustomCollection(std::string collectionName) +void CollectionSystemsManager::deleteCustomCollection(const std::string& collectionName) { auto collectionEntry = mCustomCollectionSystemsData.find(collectionName); @@ -1090,7 +1092,7 @@ SystemData* CollectionSystemsManager::getAllGamesCollection() return allSysData->system; } -SystemData* CollectionSystemsManager::createNewCollectionEntry(std::string name, +SystemData* CollectionSystemsManager::createNewCollectionEntry(const std::string& name, CollectionSystemDecl sysDecl, bool index, bool custom) @@ -1456,13 +1458,13 @@ void CollectionSystemsManager::trimCollectionCount(FileData* rootFolder, int lim } } -bool CollectionSystemsManager::themeFolderExists(std::string folder) +const bool CollectionSystemsManager::themeFolderExists(const std::string& folder) { std::vector themeSys = getSystemsFromTheme(); return std::find(themeSys.cbegin(), themeSys.cend(), folder) != themeSys.cend(); } -bool CollectionSystemsManager::includeFileInAutoCollections(FileData* file) +const bool CollectionSystemsManager::includeFileInAutoCollections(FileData* file) { // We exclude non-game files from collections (i.e. "kodi", entries from non-game systems). // If/when there are more in the future, maybe this can be a more complex method, with a @@ -1470,7 +1472,8 @@ bool CollectionSystemsManager::includeFileInAutoCollections(FileData* file) return file->getName() != "kodi" && file->getSystem()->isGameSystem(); } -std::string CollectionSystemsManager::getCustomCollectionConfigPath(std::string collectionName) +std::string CollectionSystemsManager::getCustomCollectionConfigPath( + const std::string& collectionName) { return getCollectionsFolder() + "/custom-" + collectionName + ".cfg"; } diff --git a/es-app/src/CollectionSystemsManager.h b/es-app/src/CollectionSystemsManager.h index ff31f88d7..176f19831 100644 --- a/es-app/src/CollectionSystemsManager.h +++ b/es-app/src/CollectionSystemsManager.h @@ -90,15 +90,15 @@ public: void deleteCollectionFiles(FileData* file); // Return whether the current theme is compatible with Automatic or Custom Collections. - bool isThemeGenericCollectionCompatible(bool genericCustomCollections); - bool isThemeCustomCollectionCompatible(std::vector stringVector); - std::string getValidNewCollectionName(std::string name, int index = 0); + const bool isThemeGenericCollectionCompatible(bool genericCustomCollections); + const bool isThemeCustomCollectionCompatible(const std::vector& stringVector); + std::string getValidNewCollectionName(const std::string& name, int index = 0); - void setEditMode(std::string collectionName, bool showPopup = true); + void setEditMode(const std::string& collectionName, bool showPopup = true); void exitEditMode(bool showPopup = true); - bool inCustomCollection(const std::string& collectionName, FileData* gameFile); + const bool inCustomCollection(const std::string& collectionName, FileData* gameFile); // Add or remove a game from a specific collection. - bool toggleGameInCollection(FileData* file); + const bool toggleGameInCollection(FileData* file); SystemData* getSystemToView(SystemData* sys); // Used to generate a description of the collection (all other metadata fields are hidden). @@ -106,8 +106,8 @@ public: // Return the unused folders from current theme path. std::vector getUnusedSystemsFromTheme(); - SystemData* addNewCustomCollection(std::string name); - void deleteCustomCollection(std::string collectionName); + SystemData* addNewCustomCollection(const std::string& name); + void deleteCustomCollection(const std::string& collectionName); // Reactivate a game in all custom collections where it has an entry in the configuration file. void reactivateCustomCollectionEntry(FileData* game); @@ -115,17 +115,19 @@ public: // Repopulate the collection, which is basically a forced update of its complete content. void repopulateCollection(SystemData* sysData); - std::map getAutoCollectionSystems() + const std::map& // Line break. + getAutoCollectionSystems() const { return mAutoCollectionSystemsData; } - std::map getCustomCollectionSystems() + const std::map& + getCustomCollectionSystems() { return mCustomCollectionSystemsData; } - SystemData* getCustomCollectionsBundle() { return mCustomCollectionsBundle; } - bool isEditing() { return mIsEditingCustom; } - std::string getEditingCollection() { return mEditingCollection; } + SystemData* getCustomCollectionsBundle() const { return mCustomCollectionsBundle; } + const bool isEditing() const { return mIsEditingCustom; } + const std::string& getEditingCollection() const { return mEditingCollection; } private: static CollectionSystemsManager* sInstance; @@ -146,7 +148,7 @@ private: void initCustomCollectionSystems(); SystemData* getAllGamesCollection(); // Create a new empty collection system based on the name and declaration. - SystemData* createNewCollectionEntry(std::string name, + SystemData* createNewCollectionEntry(const std::string& name, CollectionSystemDecl sysDecl, bool index = true, bool custom = false); @@ -172,10 +174,10 @@ private: std::vector getUserCollectionThemeFolders(); void trimCollectionCount(FileData* rootFolder, int limit); // Return whether a specific folder exists in the theme. - bool themeFolderExists(std::string folder); - bool includeFileInAutoCollections(FileData* file); + const bool themeFolderExists(const std::string& folder); + const bool includeFileInAutoCollections(FileData* file); - std::string getCustomCollectionConfigPath(std::string collectionName); + std::string getCustomCollectionConfigPath(const std::string& collectionName); std::string getCollectionsFolder(); }; diff --git a/es-app/src/FileData.cpp b/es-app/src/FileData.cpp index 8174cdde2..150dcd111 100644 --- a/es-app/src/FileData.cpp +++ b/es-app/src/FileData.cpp @@ -142,7 +142,7 @@ const std::vector FileData::getChildrenRecursive() const std::vector childrenRecursive; for (auto it = mChildrenByFilename.cbegin(); it != mChildrenByFilename.cend(); it++) { - childrenRecursive.push_back((*it).second); + childrenRecursive.emplace_back((*it).second); // Recurse through any subdirectories. if ((*it).second->getType() == FOLDER) { std::vector childrenSubdirectory = (*it).second->getChildrenRecursive(); @@ -208,7 +208,7 @@ const std::string FileData::getMediaDirectory() return mediaDirPath; } -const std::string FileData::getMediafilePath(std::string subdirectory) const +const std::string FileData::getMediafilePath(const std::string& subdirectory) const { const std::vector extList = {".png", ".jpg"}; std::string subFolders; @@ -336,7 +336,7 @@ const std::vector& FileData::getChildrenListToDisplay() mFilteredChildren.clear(); for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { if (idx->showFile((*it))) { - mFilteredChildren.push_back(*it); + mFilteredChildren.emplace_back(*it); } } return mFilteredChildren; @@ -357,9 +357,9 @@ std::vector FileData::getFilesRecursive(unsigned int typeMask, if ((*it)->getType() & typeMask) { if (!displayedOnly || !idx->isFiltered() || idx->showFile(*it)) { if (countAllGames) - out.push_back(*it); + out.emplace_back(*it); else if ((*it)->getCountAsGame()) - out.push_back(*it); + out.emplace_back(*it); } } if ((*it)->getChildren().size() > 0) { @@ -370,7 +370,7 @@ std::vector FileData::getFilesRecursive(unsigned int typeMask, else { for (auto it2 = subChildren.cbegin(); it2 != subChildren.cend(); it2++) { if ((*it2)->getCountAsGame()) - out.push_back(*it2); + out.emplace_back(*it2); } } } @@ -388,11 +388,11 @@ std::vector FileData::getScrapeFilesRecursive(bool includeFolders, for (auto it = mChildren.cbegin(); it != mChildren.cend(); it++) { if (includeFolders && (*it)->getType() == FOLDER) { if (!(respectExclusions && (*it)->getExcludeFromScraper())) - out.push_back(*it); + out.emplace_back(*it); } else if ((*it)->getType() == GAME) { if (!(respectExclusions && (*it)->getExcludeFromScraper())) - out.push_back(*it); + out.emplace_back(*it); } // If the flag has been passed to exclude directories recursively, then skip the entire @@ -410,9 +410,7 @@ std::vector FileData::getScrapeFilesRecursive(bool includeFolders, return out; } -std::string FileData::getKey() { return getFileName(); } - -const bool FileData::isArcadeAsset() +const bool FileData::isArcadeAsset() const { const std::string stem = Utils::FileSystem::getStem(mPath); return ((mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || @@ -420,7 +418,7 @@ const bool FileData::isArcadeAsset() (MameNames::getInstance()->isBios(stem) || MameNames::getInstance()->isDevice(stem))); } -const bool FileData::isArcadeGame() +const bool FileData::isArcadeGame() const { const std::string stem = Utils::FileSystem::getStem(mPath); return ((mSystem && (mSystem->hasPlatformId(PlatformIds::ARCADE) || @@ -428,8 +426,6 @@ const bool FileData::isArcadeGame() (!MameNames::getInstance()->isBios(stem) && !MameNames::getInstance()->isDevice(stem))); } -FileData* FileData::getSourceFileData() { return this; } - void FileData::addChild(FileData* file) { assert(mType == FOLDER); @@ -438,7 +434,7 @@ void FileData::addChild(FileData* file) const std::string key = file->getKey(); if (mChildrenByFilename.find(key) == mChildrenByFilename.cend()) { mChildrenByFilename[key] = file; - mChildren.push_back(file); + mChildren.emplace_back(file); file->mParent = this; } } @@ -511,10 +507,10 @@ void FileData::sort(ComparisonFunction& comparator, if (foldersOnTop) { for (unsigned int i = 0; i < mChildren.size(); i++) { if (mChildren[i]->getType() == FOLDER) { - mChildrenFolders.push_back(mChildren[i]); + mChildrenFolders.emplace_back(mChildren[i]); } else { - mChildrenOthers.push_back(mChildren[i]); + mChildrenOthers.emplace_back(mChildren[i]); mOnlyFolders = false; } } @@ -628,15 +624,15 @@ void FileData::sortFavoritesOnTop(ComparisonFunction& comparator, if (foldersOnTop && mChildren[i]->getType() == FOLDER) { if (!mChildren[i]->getFavorite()) - mChildrenFolders.push_back(mChildren[i]); + mChildrenFolders.emplace_back(mChildren[i]); else - mChildrenFavoritesFolders.push_back(mChildren[i]); + mChildrenFavoritesFolders.emplace_back(mChildren[i]); } else if (mChildren[i]->getFavorite()) { - mChildrenFavorites.push_back(mChildren[i]); + mChildrenFavorites.emplace_back(mChildren[i]); } else { - mChildrenOthers.push_back(mChildren[i]); + mChildrenOthers.emplace_back(mChildren[i]); } if (mChildren[i]->getType() != FOLDER) @@ -751,7 +747,7 @@ void FileData::countGames(std::pair& gameCount) mGameCount = gameCount; } -FileData::SortType FileData::getSortTypeFromString(std::string desc) +const FileData::SortType& FileData::getSortTypeFromString(const std::string& desc) const { std::vector SortTypes = FileSorts::SortTypes; @@ -1149,7 +1145,7 @@ void FileData::launchGame(Window* window) gameToUpdate->mSystem->onMetaDataSavePoint(); } -std::string FileData::findEmulatorPath(std::string& command) +const std::string FileData::findEmulatorPath(std::string& command) { // Extract the emulator executable from the launch command string. There are two ways // that the emulator can be defined in es_systems.xml, either using the find rules in diff --git a/es-app/src/FileData.h b/es-app/src/FileData.h index 2411a4dd6..1133a067a 100644 --- a/es-app/src/FileData.h +++ b/es-app/src/FileData.h @@ -43,7 +43,7 @@ public: const bool getKidgame(); const bool getHidden(); const bool getCountAsGame(); - const std::pair getGameCount() { return mGameCount; } + const std::pair& getGameCount() const { return mGameCount; } const bool getExcludeFromScraper(); const std::vector getChildrenRecursive() const; FileType getType() const { return mType; } @@ -56,11 +56,11 @@ public: const std::vector& getChildren() const { return mChildren; } SystemData* getSystem() const { return mSystem; } SystemEnvironmentData* getSystemEnvData() const { return mEnvData; } - const bool getOnlyFoldersFlag() { return mOnlyFolders; } - const bool getHasFoldersFlag() { return mHasFolders; } + const bool getOnlyFoldersFlag() const { return mOnlyFolders; } + const bool getHasFoldersFlag() const { return mHasFolders; } static const std::string getROMDirectory(); static const std::string getMediaDirectory(); - const std::string getMediafilePath(std::string subdirectory) const; + const std::string getMediafilePath(const std::string& subdirectory) const; const std::string getImagePath() const; const std::string get3DBoxPath() const; const std::string getBackCoverPath() const; @@ -73,7 +73,7 @@ public: const std::string getThumbnailPath() const; const std::string getVideoPath() const; - bool getDeletionFlag() { return mDeletionFlag; } + const bool getDeletionFlag() const { return mDeletionFlag; } void setDeletionFlag(bool setting) { mDeletionFlag = setting; } const std::vector& getChildrenListToDisplay(); @@ -87,17 +87,17 @@ public: void addChild(FileData* file); // Error if mType != FOLDER void removeChild(FileData* file); // Error if mType != FOLDER - bool isPlaceHolder() { return mType == PLACEHOLDER; } + const bool isPlaceHolder() const { return mType == PLACEHOLDER; } virtual void refreshMetadata() { return; } - virtual std::string getKey(); - const bool isArcadeAsset(); - const bool isArcadeGame(); - std::string getFullPath() { return getPath(); } + virtual std::string getKey() { return getFileName(); } + const bool isArcadeAsset() const; + const bool isArcadeGame() const; + const std::string& getFullPath() const { return getPath(); } std::string getFileName() { return Utils::FileSystem::getFileName(getPath()); } - virtual FileData* getSourceFileData(); - std::string getSystemName() const { return mSystemName; } + virtual FileData* getSourceFileData() { return this; } + const std::string& getSystemName() const { return mSystemName; } // Returns our best guess at the "real" name for this file. std::string getDisplayName() const; @@ -106,7 +106,7 @@ public: std::string getCleanName() const; void launchGame(Window* window); - std::string findEmulatorPath(std::string& command); + const std::string findEmulatorPath(std::string& command); typedef bool ComparisonFunction(const FileData* a, const FileData* b); struct SortType { @@ -128,8 +128,8 @@ public: void countGames(std::pair& gameCount); void setSortTypeString(std::string typestring) { mSortTypeString = typestring; } - std::string getSortTypeString() { return mSortTypeString; } - FileData::SortType getSortTypeFromString(std::string desc); + const std::string& getSortTypeString() const { return mSortTypeString; } + const FileData::SortType& getSortTypeFromString(const std::string& desc) const; protected: FileData* mSourceFileData; diff --git a/es-app/src/MetaData.cpp b/es-app/src/MetaData.cpp index ed52670fd..688a759b3 100644 --- a/es-app/src/MetaData.cpp +++ b/es-app/src/MetaData.cpp @@ -14,61 +14,64 @@ #include -// clang-format off -// The statistic entries must be placed at the bottom or otherwise there will be problems with -// saving the values in GuiMetaDataEd. -MetaDataDecl gameDecls[] = { -// key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd, shouldScrape -{"name", MD_STRING, "", false, "name", "enter name", true}, -{"sortname", MD_STRING, "", false, "sortname", "enter sortname", false}, -{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, -{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, -{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, -{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, -{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, -{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, -{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, -{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, -{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, -{"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on", false}, -{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, -{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, -{"nogamecount", MD_BOOL, "false", false, "exclude from game counter", "enter don't count as game off/on", false}, -{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, -{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, -{"playcount", MD_INT, "0", false, "times played", "enter number of times played", false}, -{"controller", MD_CONTROLLER, "", false, "controller", "select controller", true}, -{"altemulator", MD_ALT_EMULATOR, "", false, "alternative emulator", "select alternative emulator", false}, -{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} -}; +namespace +{ + // clang-format off + // The statistic entries must be placed at the bottom or otherwise there will be problems with + // saving the values in GuiMetaDataEd. + MetaDataDecl gameDecls[] = { + // key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd, shouldScrape + {"name", MD_STRING, "", false, "name", "enter name", true}, + {"sortname", MD_STRING, "", false, "sortname", "enter sortname", false}, + {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, + {"rating", MD_RATING, "0", false, "rating", "enter rating", true}, + {"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, + {"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, + {"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, + {"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, + {"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, + {"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, + {"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, + {"kidgame", MD_BOOL, "false", false, "kidgame", "enter kidgame off/on", false}, + {"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, + {"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, + {"nogamecount", MD_BOOL, "false", false, "exclude from game counter", "enter don't count as game off/on", false}, + {"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, + {"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, + {"playcount", MD_INT, "0", false, "times played", "enter number of times played", false}, + {"controller", MD_CONTROLLER, "", false, "controller", "select controller", true}, + {"altemulator", MD_ALT_EMULATOR, "", false, "alternative emulator", "select alternative emulator", false}, + {"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} + }; -MetaDataDecl folderDecls[] = { -{"name", MD_STRING, "", false, "name", "enter name", true}, -{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, -{"rating", MD_RATING, "0", false, "rating", "enter rating", true}, -{"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, -{"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, -{"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, -{"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, -{"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, -{"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, -{"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, -{"kidgame", MD_BOOL, "false", false, "kidgame (only affects badges)", "enter kidgame off/on", false}, -{"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, -{"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, -{"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, -{"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, -{"controller", MD_CONTROLLER, "", false, "controller", "select controller", true}, -{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} -}; -// clang-format on + MetaDataDecl folderDecls[] = { + {"name", MD_STRING, "", false, "name", "enter name", true}, + {"desc", MD_MULTILINE_STRING, "", false, "description", "enter description", true}, + {"rating", MD_RATING, "0", false, "rating", "enter rating", true}, + {"releasedate", MD_DATE, "19700101T010000", false, "release date", "enter release date", true}, + {"developer", MD_STRING, "unknown", false, "developer", "enter developer", true}, + {"publisher", MD_STRING, "unknown", false, "publisher", "enter publisher", true}, + {"genre", MD_STRING, "unknown", false, "genre", "enter genre", true}, + {"players", MD_STRING, "unknown", false, "players", "enter number of players", true}, + {"favorite", MD_BOOL, "false", false, "favorite", "enter favorite off/on", false}, + {"completed", MD_BOOL, "false", false, "completed", "enter completed off/on", false}, + {"kidgame", MD_BOOL, "false", false, "kidgame (only affects badges)", "enter kidgame off/on", false}, + {"hidden", MD_BOOL, "false", false, "hidden", "enter hidden off/on", false}, + {"broken", MD_BOOL, "false", false, "broken/not working", "enter broken off/on", false}, + {"nomultiscrape", MD_BOOL, "false", false, "exclude from multi-scraper", "enter no multi-scrape off/on", false}, + {"hidemetadata", MD_BOOL, "false", false, "hide metadata fields", "enter hide metadata off/on", false}, + {"controller", MD_CONTROLLER, "", false, "controller", "select controller", true}, + {"lastplayed", MD_TIME, "0", true, "last played", "enter last played date", false} + }; + // clang-format on -const std::vector gameMDD(gameDecls, - gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0])); + const std::vector gameMDD(gameDecls, + gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0])); -const std::vector folderMDD(folderDecls, - folderDecls + - sizeof(folderDecls) / sizeof(folderDecls[0])); + const std::vector folderMDD(folderDecls, + folderDecls + + sizeof(folderDecls) / sizeof(folderDecls[0])); +} // namespace const std::vector& getMDDByType(MetaDataListType type) { diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 1ca0cae81..25c8580af 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -973,7 +973,7 @@ bool SystemData::createSystemDirectories() return false; } -bool SystemData::isVisible() +const bool SystemData::isVisible() const { // This function doesn't make much sense at the moment; if a system does not have any // games available, it will not be processed during startup and will as such not exist. diff --git a/es-app/src/SystemData.h b/es-app/src/SystemData.h index a89eb4586..312cee3a8 100644 --- a/es-app/src/SystemData.h +++ b/es-app/src/SystemData.h @@ -96,10 +96,10 @@ public: std::string getThemePath() const; std::pair getDisplayedGameCount() const; - bool getScrapeFlag() { return mScrapeFlag; } + const bool getScrapeFlag() const { return mScrapeFlag; } void setScrapeFlag(bool scrapeflag) { mScrapeFlag = scrapeflag; } - std::string getAlternativeEmulator() { return mAlternativeEmulator; } + const std::string& getAlternativeEmulator() const { return mAlternativeEmulator; } void setAlternativeEmulator(const std::string& command) { mAlternativeEmulator = command; } std::string getLaunchCommandFromLabel(const std::string& label); @@ -122,16 +122,16 @@ public: { return std::find(sSystemVector.crbegin(), sSystemVector.crend(), this); } - bool isCollection() { return mIsCollectionSystem; } - bool isCustomCollection() { return mIsCustomCollectionSystem; } - bool isGroupedCustomCollection() { return mIsGroupedCustomCollectionSystem; } + const bool isCollection() const { return mIsCollectionSystem; } + const bool isCustomCollection() const { return mIsCustomCollectionSystem; } + const bool isGroupedCustomCollection() const { return mIsGroupedCustomCollectionSystem; } void setIsGroupedCustomCollection(bool isGroupedCustom) { mIsGroupedCustomCollectionSystem = isGroupedCustom; }; - bool isGameSystem() { return mIsGameSystem; } + const bool isGameSystem() const { return mIsGameSystem; } - bool isVisible(); + const bool isVisible() const; static SystemData* getSystemByName(const std::string& systemName); SystemData* getNext() const; diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index d4d605ec9..401fff11c 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -111,7 +111,7 @@ void GuiComponent::setOrigin(float x, float y) onOriginChanged(); } -void GuiComponent::setSize(float w, float h) +void GuiComponent::setSize(const float w, const float h) { if (mSize.x == w && mSize.y == h) return; diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 17ce415b2..5e23475be 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -88,7 +88,7 @@ public: virtual glm::vec2 getSize() const { return mSize; } void setSize(const glm::vec2& size) { setSize(size.x, size.y); } - void setSize(float w, float h); + void setSize(const float w, const float h); virtual void setResize(float width, float height) {} virtual void onSizeChanged() {} diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index b7309c9d3..82045ce8b 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -22,45 +22,46 @@ std::vector BadgeComponent::sGameControllers; -// clang-format off - -// The "unknown" controller entry has to be placed last. -GameControllers sControllerDefinitions [] = { - // shortName displayName fileName - {"gamepad_generic", "Gamepad (Generic)", ":/graphics/controllers/gamepad_generic.svg"}, - {"gamepad_nintendo_nes", "Gamepad (Nintendo NES)", ":/graphics/controllers/gamepad_nintendo_nes.svg"}, - {"gamepad_nintendo_snes", "Gamepad (Nintendo SNES)", ":/graphics/controllers/gamepad_nintendo_snes.svg"}, - {"gamepad_nintendo_64", "Gamepad (Nintendo 64)", ":/graphics/controllers/gamepad_nintendo_64.svg"}, - {"gamepad_playstation", "Gamepad (PlayStation)", ":/graphics/controllers/gamepad_playstation.svg"}, - {"gamepad_sega_md_3_buttons", "Gamepad (Sega Mega Drive/Genesis 3 Buttons)", ":/graphics/controllers/gamepad_sega_md_3_buttons.svg"}, - {"gamepad_sega_md_6_buttons", "Gamepad (Sega Mega Drive/Genesis 6 Buttons)", ":/graphics/controllers/gamepad_sega_md_6_buttons.svg"}, - {"gamepad_xbox", "Gamepad (Xbox)", ":/graphics/controllers/gamepad_xbox.svg"}, - {"joystick_generic", "Joystick (Generic)", ":/graphics/controllers/joystick_generic.svg"}, - {"joystick_arcade_no_buttons", "Joystick (Arcade No Buttons)", ":/graphics/controllers/joystick_arcade_no_buttons.svg"}, - {"joystick_arcade_1_button", "Joystick (Arcade 1 Button)", ":/graphics/controllers/joystick_arcade_1_button.svg"}, - {"joystick_arcade_2_buttons", "Joystick (Arcade 2 Buttons)", ":/graphics/controllers/joystick_arcade_2_buttons.svg"}, - {"joystick_arcade_3_buttons", "Joystick (Arcade 3 Buttons)", ":/graphics/controllers/joystick_arcade_3_buttons.svg"}, - {"joystick_arcade_4_buttons", "Joystick (Arcade 4 Buttons)", ":/graphics/controllers/joystick_arcade_4_buttons.svg"}, - {"joystick_arcade_5_buttons", "Joystick (Arcade 5 Buttons)", ":/graphics/controllers/joystick_arcade_5_buttons.svg"}, - {"joystick_arcade_6_buttons", "Joystick (Arcade 6 Buttons)", ":/graphics/controllers/joystick_arcade_6_buttons.svg"}, - {"keyboard_generic", "Keyboard (Generic)", ":/graphics/controllers/keyboard_generic.svg"}, - {"keyboard_and_mouse_generic", "Keyboard and Mouse (Generic)", ":/graphics/controllers/keyboard_and_mouse_generic.svg"}, - {"mouse_generic", "Mouse (Generic)", ":/graphics/controllers/mouse_generic.svg"}, - {"mouse_amiga", "Mouse (Amiga)", ":/graphics/controllers/mouse_amiga.svg"}, - {"lightgun_generic", "Lightgun (Generic)", ":/graphics/controllers/lightgun_generic.svg"}, - {"lightgun_nintendo", "Lightgun (Nintendo)", ":/graphics/controllers/lightgun_nintendo.svg"}, - {"steering_wheel_generic", "Steering Wheel (Generic)", ":/graphics/controllers/steering_wheel_generic.svg"}, - {"flight_stick_generic", "Flight Stick (Generic)", ":/graphics/controllers/flight_stick_generic.svg"}, - {"spinner_generic", "Spinner (Generic)", ":/graphics/controllers/spinner_generic.svg"}, - {"trackball_generic", "Trackball (Generic)", ":/graphics/controllers/trackball_generic.svg"}, - {"wii_remote_nintendo", "Wii Remote (Nintendo)", ":/graphics/controllers/wii_remote_nintendo.svg"}, - {"wii_remote_and_nunchuk_nintendo", "Wii Remote and Nunchuk (Nintendo)", ":/graphics/controllers/wii_remote_and_nunchuk_nintendo.svg"}, - {"joycon_left_or_right_nintendo", "Joy-Con Left or Right (Nintendo)", ":/graphics/controllers/joycon_left_or_right_nintendo.svg"}, - {"joycon_pair_nintendo", "Joy-Con Pair (Nintendo)", ":/graphics/controllers/joycon_pair_nintendo.svg"}, - {"unknown", "Unknown Controller", ":/graphics/controllers/unknown.svg"} -}; - -// clang-format on +namespace +{ + // clang-format off + // The "unknown" controller entry has to be placed last. + GameControllers sControllerDefinitions [] = { + // shortName displayName fileName + {"gamepad_generic", "Gamepad (Generic)", ":/graphics/controllers/gamepad_generic.svg"}, + {"gamepad_nintendo_nes", "Gamepad (Nintendo NES)", ":/graphics/controllers/gamepad_nintendo_nes.svg"}, + {"gamepad_nintendo_snes", "Gamepad (Nintendo SNES)", ":/graphics/controllers/gamepad_nintendo_snes.svg"}, + {"gamepad_nintendo_64", "Gamepad (Nintendo 64)", ":/graphics/controllers/gamepad_nintendo_64.svg"}, + {"gamepad_playstation", "Gamepad (PlayStation)", ":/graphics/controllers/gamepad_playstation.svg"}, + {"gamepad_sega_md_3_buttons", "Gamepad (Sega Mega Drive/Genesis 3 Buttons)", ":/graphics/controllers/gamepad_sega_md_3_buttons.svg"}, + {"gamepad_sega_md_6_buttons", "Gamepad (Sega Mega Drive/Genesis 6 Buttons)", ":/graphics/controllers/gamepad_sega_md_6_buttons.svg"}, + {"gamepad_xbox", "Gamepad (Xbox)", ":/graphics/controllers/gamepad_xbox.svg"}, + {"joystick_generic", "Joystick (Generic)", ":/graphics/controllers/joystick_generic.svg"}, + {"joystick_arcade_no_buttons", "Joystick (Arcade No Buttons)", ":/graphics/controllers/joystick_arcade_no_buttons.svg"}, + {"joystick_arcade_1_button", "Joystick (Arcade 1 Button)", ":/graphics/controllers/joystick_arcade_1_button.svg"}, + {"joystick_arcade_2_buttons", "Joystick (Arcade 2 Buttons)", ":/graphics/controllers/joystick_arcade_2_buttons.svg"}, + {"joystick_arcade_3_buttons", "Joystick (Arcade 3 Buttons)", ":/graphics/controllers/joystick_arcade_3_buttons.svg"}, + {"joystick_arcade_4_buttons", "Joystick (Arcade 4 Buttons)", ":/graphics/controllers/joystick_arcade_4_buttons.svg"}, + {"joystick_arcade_5_buttons", "Joystick (Arcade 5 Buttons)", ":/graphics/controllers/joystick_arcade_5_buttons.svg"}, + {"joystick_arcade_6_buttons", "Joystick (Arcade 6 Buttons)", ":/graphics/controllers/joystick_arcade_6_buttons.svg"}, + {"keyboard_generic", "Keyboard (Generic)", ":/graphics/controllers/keyboard_generic.svg"}, + {"keyboard_and_mouse_generic", "Keyboard and Mouse (Generic)", ":/graphics/controllers/keyboard_and_mouse_generic.svg"}, + {"mouse_generic", "Mouse (Generic)", ":/graphics/controllers/mouse_generic.svg"}, + {"mouse_amiga", "Mouse (Amiga)", ":/graphics/controllers/mouse_amiga.svg"}, + {"lightgun_generic", "Lightgun (Generic)", ":/graphics/controllers/lightgun_generic.svg"}, + {"lightgun_nintendo", "Lightgun (Nintendo)", ":/graphics/controllers/lightgun_nintendo.svg"}, + {"steering_wheel_generic", "Steering Wheel (Generic)", ":/graphics/controllers/steering_wheel_generic.svg"}, + {"flight_stick_generic", "Flight Stick (Generic)", ":/graphics/controllers/flight_stick_generic.svg"}, + {"spinner_generic", "Spinner (Generic)", ":/graphics/controllers/spinner_generic.svg"}, + {"trackball_generic", "Trackball (Generic)", ":/graphics/controllers/trackball_generic.svg"}, + {"wii_remote_nintendo", "Wii Remote (Nintendo)", ":/graphics/controllers/wii_remote_nintendo.svg"}, + {"wii_remote_and_nunchuk_nintendo", "Wii Remote and Nunchuk (Nintendo)", ":/graphics/controllers/wii_remote_and_nunchuk_nintendo.svg"}, + {"joycon_left_or_right_nintendo", "Joy-Con Left or Right (Nintendo)", ":/graphics/controllers/joycon_left_or_right_nintendo.svg"}, + {"joycon_pair_nintendo", "Joy-Con Pair (Nintendo)", ":/graphics/controllers/joycon_pair_nintendo.svg"}, + {"unknown", "Unknown Controller", ":/graphics/controllers/unknown.svg"} + }; + // clang-format on +} // namespace BadgeComponent::BadgeComponent(Window* window) : GuiComponent{window} @@ -81,7 +82,7 @@ void BadgeComponent::populateGameControllers() { sGameControllers.clear(); for (auto controller : sControllerDefinitions) - sGameControllers.push_back(controller); + sGameControllers.emplace_back(controller); } void BadgeComponent::setBadges(const std::vector& badges) @@ -289,7 +290,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, item.baseImage = badgeImage; item.overlayImage = ImageComponent{mWindow}; - mFlexboxItems.push_back(item); + mFlexboxItems.emplace_back(std::move(item)); } else { LOG(LogError) << "Invalid badge slot \"" << slot << "\" defined"; diff --git a/es-core/src/components/BadgeComponent.h b/es-core/src/components/BadgeComponent.h index 2f998b9da..a1d37ba6b 100644 --- a/es-core/src/components/BadgeComponent.h +++ b/es-core/src/components/BadgeComponent.h @@ -30,7 +30,7 @@ public: }; static void populateGameControllers(); - std::vector getBadgeTypes() { return mBadgeTypes; } + const std::vector& getBadgeTypes() const { return mBadgeTypes; } void setBadges(const std::vector& badges); static const std::vector& getGameControllers() { diff --git a/es-core/src/components/FlexboxComponent.cpp b/es-core/src/components/FlexboxComponent.cpp index 3b9fe9a0d..1680ce528 100644 --- a/es-core/src/components/FlexboxComponent.cpp +++ b/es-core/src/components/FlexboxComponent.cpp @@ -164,7 +164,7 @@ void FlexboxComponent::computeLayout() if (mDirection == "row") { for (int y = 0; y < grid.y; y++) { for (int x = 0; x < grid.x; x++) { - itemPositions.push_back( + itemPositions.emplace_back( glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp), y * (rowHeight + mItemMargin.y)}); } @@ -173,15 +173,15 @@ void FlexboxComponent::computeLayout() else if (mDirection == "column" && !alignRight) { for (int x = 0; x < grid.x; x++) { for (int y = 0; y < grid.y; y++) { - itemPositions.push_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)}); } } } else { // Right-aligned. for (int x = 0; x < grid.x; x++) { for (int y = 0; y < grid.y; y++) { - itemPositions.push_back( + itemPositions.emplace_back( glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x), y * (rowHeight + mItemMargin.y)}); } diff --git a/es-core/src/components/FlexboxComponent.h b/es-core/src/components/FlexboxComponent.h index ce5a6c60f..317d326e5 100644 --- a/es-core/src/components/FlexboxComponent.h +++ b/es-core/src/components/FlexboxComponent.h @@ -29,14 +29,14 @@ public: FlexboxComponent(Window* window, std::vector& items); // Getters/setters for the layout. - std::string getDirection() const { return mDirection; } + const std::string& getDirection() const { return mDirection; } void setDirection(const std::string& direction) { assert(direction == "row" || direction == "column"); mDirection = direction; } - std::string getAlignment() const { return mAlignment; } + const std::string& getAlignment() const { return mAlignment; } void setAlignment(const std::string& value) { assert(value == "left" || value == "right"); @@ -58,7 +58,7 @@ public: mLayoutValid = false; } - std::string getItemPlacement() const { return mItemPlacement; } + const std::string& getItemPlacement() const { return mItemPlacement; } void setItemPlacement(const std::string& value) { assert(value == "start" || value == "center" || value == "end" || value == "stretch"); @@ -66,10 +66,10 @@ public: mLayoutValid = false; } - glm::vec2 getItemMargin() const { return mItemMargin; } + const glm::vec2& getItemMargin() const { return mItemMargin; } void setItemMargin(glm::vec2 value); - glm::vec2 getOverlayPosition() const { return mOverlayPosition; } + const glm::vec2& getOverlayPosition() const { return mOverlayPosition; } void setOverlayPosition(glm::vec2 position) { mOverlayPosition = position; } float getOverlaySize() const { return mOverlaySize; } diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index 92aa7c7d7..3c027d28f 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -132,7 +132,7 @@ void ImageComponent::resize() onSizeChanged(); } -void ImageComponent::setImage(std::string path, bool tile, bool linearMagnify) +void ImageComponent::setImage(const std::string& path, bool tile, bool linearMagnify) { // Always load bundled graphic resources statically, unless mForceLoad has been set. // This eliminates annoying texture pop-in problems that would otherwise occur. @@ -179,7 +179,7 @@ void ImageComponent::setResize(float width, float height) resize(); } -void ImageComponent::setMaxSize(float width, float height) +void ImageComponent::setMaxSize(const float width, const float height) { mTargetSize = glm::vec2{width, height}; mTargetIsMax = true; @@ -187,7 +187,7 @@ void ImageComponent::setMaxSize(float width, float height) resize(); } -void ImageComponent::setMinSize(float width, float height) +void ImageComponent::setMinSize(const float width, const float height) { mTargetSize = glm::vec2{width, height}; mTargetIsMax = false; @@ -195,31 +195,31 @@ void ImageComponent::setMinSize(float width, float height) resize(); } -void ImageComponent::cropLeft(float percent) +void ImageComponent::cropLeft(const float percent) { assert(percent >= 0.0f && percent <= 1.0f); mTopLeftCrop.x = percent; } -void ImageComponent::cropTop(float percent) +void ImageComponent::cropTop(const float percent) { assert(percent >= 0.0f && percent <= 1.0f); mTopLeftCrop.y = percent; } -void ImageComponent::cropRight(float percent) +void ImageComponent::cropRight(const float percent) { assert(percent >= 0.0f && percent <= 1.0f); mBottomRightCrop.x = 1.0f - percent; } -void ImageComponent::cropBot(float percent) +void ImageComponent::cropBot(const float percent) { assert(percent >= 0.0f && percent <= 1.0f); mBottomRightCrop.y = 1.0f - percent; } -void ImageComponent::crop(float left, float top, float right, float bot) +void ImageComponent::crop(const float left, const float top, const float right, const float bot) { cropLeft(left); cropTop(top); @@ -233,7 +233,7 @@ void ImageComponent::uncrop() crop(0.0f, 0.0f, 0.0f, 0.0f); } -void ImageComponent::cropTransparentPadding(float maxSizeX, float maxSizeY) +void ImageComponent::cropTransparentPadding(const float maxSizeX, const float maxSizeY) { if (mSize == glm::vec2{}) return; diff --git a/es-core/src/components/ImageComponent.h b/es-core/src/components/ImageComponent.h index e91955204..89b98dc77 100644 --- a/es-core/src/components/ImageComponent.h +++ b/es-core/src/components/ImageComponent.h @@ -20,11 +20,11 @@ public: ImageComponent(Window* window, bool forceLoad = false, bool dynamic = true); virtual ~ImageComponent() {} - void setDefaultImage(std::string path) { mDefaultPath = path; } + void setDefaultImage(const std::string& path) { mDefaultPath = path; } // Loads the image at the given filepath. Will tile if tile is true (retrieves texture // as tiling, creates vertices accordingly). - void setImage(std::string path, bool tile = false, bool linearMagnify = false); + void setImage(const std::string& path, bool tile = false, bool linearMagnify = false); // Loads an image from memory. void setImage(const char* data, size_t length, bool tile = false); // Use an already existing texture. @@ -37,32 +37,32 @@ public: // zero, don't do any resizing. // Can be set before or after an image is loaded. // setMaxSize() and setResize() are mutually exclusive. - void setResize(float width, float height) override; + void setResize(const float width, const float height) override; void setResize(const glm::vec2& size) { setResize(size.x, size.y); } // Resize the image to be as large as possible but fit within a box of this size. // Can be set before or after an image is loaded. // Never breaks the aspect ratio. setMaxSize() and setResize() are mutually exclusive. - void setMaxSize(float width, float height); + void setMaxSize(const float width, const float height); void setMaxSize(const glm::vec2& size) { setMaxSize(size.x, size.y); } - void setMinSize(float width, float height); + void setMinSize(const float width, const float height); void setMinSize(const glm::vec2& size) { setMinSize(size.x, size.y); } glm::vec2 getRotationSize() const override { return mRotateByTargetSize ? mTargetSize : mSize; } // Applied AFTER image positioning and sizing. // cropTop(0.2) will crop 20% of the top of the image. - void cropLeft(float percent); - void cropTop(float percent); - void cropRight(float percent); - void cropBot(float percent); - void crop(float left, float top, float right, float bot); + void cropLeft(const float percent); + void cropTop(const float percent); + void cropRight(const float percent); + void cropBot(const float percent); + void crop(const float left, const float top, const float right, const float bot); void uncrop(); // This crops any entirely transparent areas around the actual image. // The arguments restrict how much the end result is allowed to be scaled. - void cropTransparentPadding(float maxSizeX, float maxSizeY); + void cropTransparentPadding(const float maxSizeX, const float maxSizeY); // Multiply all pixels in the image by this color when rendering. void setColorShift(unsigned int color) override; diff --git a/es-core/src/components/VideoFFmpegComponent.cpp b/es-core/src/components/VideoFFmpegComponent.cpp index 5cb0ca94f..d59d5bf74 100644 --- a/es-core/src/components/VideoFFmpegComponent.cpp +++ b/es-core/src/components/VideoFFmpegComponent.cpp @@ -695,7 +695,7 @@ void VideoFFmpegComponent::getProcessedFrames() currFrame.frameRGBA.begin(), std::make_move_iterator(&mVideoFrameResampled->data[0][0]), std::make_move_iterator(&mVideoFrameResampled->data[0][bufferSize])); - mVideoFrameQueue.push(std::move(currFrame)); + mVideoFrameQueue.emplace(std::move(currFrame)); av_frame_unref(mVideoFrameResampled); } @@ -723,7 +723,7 @@ void VideoFFmpegComponent::getProcessedFrames() &mAudioFrameResampled->data[0][0], &mAudioFrameResampled->data[0][bufferSize]); - mAudioFrameQueue.push(std::move(currFrame)); + mAudioFrameQueue.emplace(std::move(currFrame)); av_frame_unref(mAudioFrameResampled); } } @@ -883,18 +883,19 @@ void VideoFFmpegComponent::calculateBlackRectangle() rectHeight = mSize.y; } // Populate the rectangle coordinates to be used in render(). - mVideoRectangleCoords.push_back(std::round(mVideoAreaPos.x - rectWidth * mOrigin.x)); - mVideoRectangleCoords.push_back(std::round(mVideoAreaPos.y - rectHeight * mOrigin.y)); - mVideoRectangleCoords.push_back(std::round(rectWidth)); - mVideoRectangleCoords.push_back(std::round(rectHeight)); + mVideoRectangleCoords.emplace_back(std::round(mVideoAreaPos.x - rectWidth * mOrigin.x)); + mVideoRectangleCoords.emplace_back( + std::round(mVideoAreaPos.y - rectHeight * mOrigin.y)); + mVideoRectangleCoords.emplace_back(std::round(rectWidth)); + mVideoRectangleCoords.emplace_back(std::round(rectHeight)); } // If the option to display pillarboxes is disabled, then make the rectangle equivalent // to the size of the video. else { - mVideoRectangleCoords.push_back(std::round(mPosition.x - mSize.x * mOrigin.x)); - mVideoRectangleCoords.push_back(std::round(mPosition.y - mSize.y * mOrigin.y)); - mVideoRectangleCoords.push_back(std::round(mSize.x)); - mVideoRectangleCoords.push_back(std::round(mSize.y)); + mVideoRectangleCoords.emplace_back(std::round(mPosition.x - mSize.x * mOrigin.x)); + mVideoRectangleCoords.emplace_back(std::round(mPosition.y - mSize.y * mOrigin.y)); + mVideoRectangleCoords.emplace_back(std::round(mSize.x)); + mVideoRectangleCoords.emplace_back(std::round(mSize.y)); } } } diff --git a/es-core/src/renderers/Renderer.cpp b/es-core/src/renderers/Renderer.cpp index 1af81433c..9ad22fc14 100644 --- a/es-core/src/renderers/Renderer.cpp +++ b/es-core/src/renderers/Renderer.cpp @@ -505,7 +505,7 @@ namespace Renderer drawTriangleStrips(vertices, 4, trans, srcBlendFactor, dstBlendFactor); } - unsigned int convertRGBAToABGR(const unsigned int _color) + const unsigned int convertRGBAToABGR(const unsigned int _color) { unsigned char red = ((_color & 0xff000000) >> 24) & 255; unsigned char green = ((_color & 0x00ff0000) >> 16) & 255; @@ -515,7 +515,7 @@ namespace Renderer return alpha << 24 | blue << 16 | green << 8 | red; } - unsigned int convertABGRToRGBA(const unsigned int _color) + const unsigned int convertABGRToRGBA(const unsigned int _color) { unsigned char alpha = ((_color & 0xff000000) >> 24) & 255; unsigned char blue = ((_color & 0x00ff0000) >> 16) & 255; @@ -542,17 +542,17 @@ namespace Renderer return nullptr; } - const glm::mat4 getProjectionMatrix() { return mProjectionMatrix; } + const glm::mat4& getProjectionMatrix() { return mProjectionMatrix; } SDL_Window* getSDLWindow() { return sdlWindow; } - int getWindowWidth() { return windowWidth; } - int getWindowHeight() { return windowHeight; } - int getScreenWidth() { return screenWidth; } - int getScreenHeight() { return screenHeight; } - int getScreenOffsetX() { return screenOffsetX; } - int getScreenOffsetY() { return screenOffsetY; } - int getScreenRotate() { return screenRotate; } - float getScreenWidthModifier() { return screenWidthModifier; } - float getScreenHeightModifier() { return screenHeightModifier; } - float getScreenAspectRatio() { return screenAspectRatio; } + const int getWindowWidth() { return windowWidth; } + const int getWindowHeight() { return windowHeight; } + const int getScreenWidth() { return screenWidth; } + const int getScreenHeight() { return screenHeight; } + const int getScreenOffsetX() { return screenOffsetX; } + const int getScreenOffsetY() { return screenOffsetY; } + const int getScreenRotate() { return screenRotate; } + const float getScreenWidthModifier() { return screenWidthModifier; } + const float getScreenHeightModifier() { return screenHeightModifier; } + const float getScreenAspectRatio() { return screenAspectRatio; } } // namespace Renderer diff --git a/es-core/src/renderers/Renderer.h b/es-core/src/renderers/Renderer.h index eeea8da30..a932449ed 100644 --- a/es-core/src/renderers/Renderer.h +++ b/es-core/src/renderers/Renderer.h @@ -144,23 +144,23 @@ namespace Renderer const Blend::Factor srcBlendFactor = Blend::SRC_ALPHA, const Blend::Factor dstBlendFactor = Blend::ONE_MINUS_SRC_ALPHA); SDL_Window* getSDLWindow(); - int getWindowWidth(); - int getWindowHeight(); - int getScreenWidth(); - int getScreenHeight(); - int getScreenOffsetX(); - int getScreenOffsetY(); - int getScreenRotate(); - float getScreenWidthModifier(); - float getScreenHeightModifier(); - float getScreenAspectRatio(); + const int getWindowWidth(); + const int getWindowHeight(); + const int getScreenWidth(); + const int getScreenHeight(); + const int getScreenOffsetX(); + const int getScreenOffsetY(); + const int getScreenRotate(); + const float getScreenWidthModifier(); + const float getScreenHeightModifier(); + const float getScreenAspectRatio(); - unsigned int convertRGBAToABGR(unsigned int color); - unsigned int convertABGRToRGBA(unsigned int color); + const unsigned int convertRGBAToABGR(const unsigned int color); + const unsigned int convertABGRToRGBA(const unsigned int color); Shader* getShaderProgram(unsigned int shaderID); - const glm::mat4 getProjectionMatrix(); - void shaderPostprocessing(unsigned int shaders, + const glm::mat4& getProjectionMatrix(); + void shaderPostprocessing(const unsigned int shaders, const Renderer::shaderParameters& parameters = shaderParameters(), unsigned char* textureRGBA = nullptr); @@ -180,7 +180,7 @@ namespace Renderer void updateTexture(const unsigned int texture, const Texture::Type type, const unsigned int x, - const unsigned y, + const unsigned int y, const unsigned int width, const unsigned int height, void* data); diff --git a/es-core/src/renderers/Renderer_GL21.cpp b/es-core/src/renderers/Renderer_GL21.cpp index a4c9ec5c5..c476be97d 100644 --- a/es-core/src/renderers/Renderer_GL21.cpp +++ b/es-core/src/renderers/Renderer_GL21.cpp @@ -17,7 +17,7 @@ namespace Renderer static SDL_GLContext sdlContext = nullptr; static GLuint whiteTexture = 0; - static GLenum convertBlendFactor(const Blend::Factor _blendFactor) + inline GLenum convertBlendFactor(const Blend::Factor _blendFactor) { // clang-format off switch (_blendFactor) { @@ -36,7 +36,7 @@ namespace Renderer // clang-format on } - static GLenum convertTextureType(const Texture::Type _type) + inline GLenum convertTextureType(const Texture::Type _type) { // clang-format off switch (_type) { @@ -203,7 +203,7 @@ namespace Renderer void updateTexture(const unsigned int texture, const Texture::Type type, const unsigned int x, - const unsigned y, + const unsigned int y, const unsigned int width, const unsigned int height, void* data) @@ -246,8 +246,8 @@ namespace Renderer const Blend::Factor dstBlendFactor, const shaderParameters& parameters) { - float width = vertices[3].pos[0]; - float height = vertices[3].pos[1]; + const float width = vertices[3].pos[0]; + const float height = vertices[3].pos[1]; GL_CHECK_ERROR(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), &vertices[0].pos)); GL_CHECK_ERROR(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &vertices[0].tex)); diff --git a/es-core/src/renderers/Renderer_GLES10.cpp b/es-core/src/renderers/Renderer_GLES10.cpp index 2d16db771..21cd8cfd1 100644 --- a/es-core/src/renderers/Renderer_GLES10.cpp +++ b/es-core/src/renderers/Renderer_GLES10.cpp @@ -20,7 +20,7 @@ namespace Renderer static SDL_GLContext sdlContext = nullptr; static GLuint whiteTexture = 0; - static GLenum convertBlendFactor(const Blend::Factor _blendFactor) + inline GLenum convertBlendFactor(const Blend::Factor _blendFactor) { // clang-format off switch (_blendFactor) { @@ -39,7 +39,7 @@ namespace Renderer // clang-format on } - static GLenum convertTextureType(const Texture::Type _type) + inline GLenum convertTextureType(const Texture::Type _type) { // clang-format off switch (_type) { @@ -148,7 +148,7 @@ namespace Renderer void updateTexture(const unsigned int texture, const Texture::Type type, const unsigned int x, - const unsigned y, + const unsigned int y, const unsigned int width, const unsigned int height, void* data)