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