Miscellaneous code cleanup.

This commit is contained in:
Leon Styhre 2021-09-19 19:46:59 +02:00
parent fc78f8ee18
commit fad326c3bd
8 changed files with 30 additions and 29 deletions

View file

@ -674,7 +674,6 @@ bool CollectionSystemsManager::toggleGameInCollection(FileData* file)
rootFolder->getChildrenByFilename(); rootFolder->getChildrenByFilename();
bool found = children.find(key) != children.cend(); bool found = children.find(key) != children.cend();
FileFilterIndex* fileIndex = sysData->getIndex(); FileFilterIndex* fileIndex = sysData->getIndex();
std::string name = sysData->getName();
SystemData* systemViewToUpdate = getSystemToView(sysData); SystemData* systemViewToUpdate = getSystemToView(sysData);

View file

@ -346,9 +346,9 @@ std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask,
out.insert(out.cend(), subChildren.cbegin(), subChildren.cend()); out.insert(out.cend(), subChildren.cbegin(), subChildren.cend());
} }
else { else {
for (auto it = subChildren.cbegin(); it != subChildren.cend(); it++) { for (auto it2 = subChildren.cbegin(); it2 != subChildren.cend(); it2++) {
if ((*it)->getCountAsGame()) if ((*it2)->getCountAsGame())
out.push_back(*it); out.push_back(*it2);
} }
} }
} }

View file

@ -392,19 +392,20 @@ bool SystemData::loadConfig()
bool onlyProcessCustomFile = false; bool onlyProcessCustomFile = false;
for (auto path : configPaths) { for (auto configPath : configPaths) {
// If the loadExclusive tag is present in the custom es_systems.xml file, then skip // If the loadExclusive tag is present in the custom es_systems.xml file, then skip
// processing of the bundled configuration file. // processing of the bundled configuration file.
if (onlyProcessCustomFile) if (onlyProcessCustomFile)
break; break;
LOG(LogInfo) << "Parsing systems configuration file \"" << path << "\"..."; LOG(LogInfo) << "Parsing systems configuration file \"" << configPath << "\"...";
pugi::xml_document doc; pugi::xml_document doc;
#if defined(_WIN64) #if defined(_WIN64)
pugi::xml_parse_result res = doc.load_file(Utils::String::stringToWideString(path).c_str()); pugi::xml_parse_result res =
doc.load_file(Utils::String::stringToWideString(configPath).c_str());
#else #else
pugi::xml_parse_result res = doc.load_file(path.c_str()); pugi::xml_parse_result res = doc.load_file(configPath.c_str());
#endif #endif
if (!res) { if (!res) {
@ -414,7 +415,7 @@ bool SystemData::loadConfig()
pugi::xml_node loadExclusive = doc.child("loadExclusive"); pugi::xml_node loadExclusive = doc.child("loadExclusive");
if (loadExclusive) { if (loadExclusive) {
if (path == configPaths.front() && configPaths.size() > 1) { if (configPath == configPaths.front() && configPaths.size() > 1) {
LOG(LogInfo) << "Only loading custom file as the <loadExclusive> tag is present"; LOG(LogInfo) << "Only loading custom file as the <loadExclusive> tag is present";
onlyProcessCustomFile = true; onlyProcessCustomFile = true;
} }
@ -1234,21 +1235,21 @@ void SystemData::onMetaDataSavePoint()
writeMetaData(); writeMetaData();
} }
void SystemData::setupSystemSortType(FileData* mRootFolder) void SystemData::setupSystemSortType(FileData* rootFolder)
{ {
// If DefaultSortOrder is set to something, check that it is actually a valid value. // If DefaultSortOrder is set to something, check that it is actually a valid value.
if (Settings::getInstance()->getString("DefaultSortOrder") != "") { if (Settings::getInstance()->getString("DefaultSortOrder") != "") {
for (unsigned int i = 0; i < FileSorts::SortTypes.size(); i++) { for (unsigned int i = 0; i < FileSorts::SortTypes.size(); i++) {
if (FileSorts::SortTypes.at(i).description == if (FileSorts::SortTypes.at(i).description ==
Settings::getInstance()->getString("DefaultSortOrder")) { Settings::getInstance()->getString("DefaultSortOrder")) {
mRootFolder->setSortTypeString( rootFolder->setSortTypeString(
Settings::getInstance()->getString("DefaultSortOrder")); Settings::getInstance()->getString("DefaultSortOrder"));
break; break;
} }
} }
} }
// If no valid sort type was defined in the configuration file, set to default sorting. // If no valid sort type was defined in the configuration file, set to default sorting.
if (mRootFolder->getSortTypeString() == "") if (rootFolder->getSortTypeString() == "")
mRootFolder->setSortTypeString( rootFolder->setSortTypeString(
Settings::getInstance()->getDefaultString("DefaultSortOrder")); Settings::getInstance()->getDefaultString("DefaultSortOrder"));
} }

View file

@ -146,7 +146,7 @@ public:
void onMetaDataSavePoint(); void onMetaDataSavePoint();
void writeMetaData(); void writeMetaData();
void setupSystemSortType(FileData* mRootFolder); void setupSystemSortType(FileData* rootFolder);
private: private:
std::string mName; std::string mName;

View file

@ -440,10 +440,10 @@ void SystemScreensaver::generateImageList()
continue; continue;
std::vector<FileData*> allFiles = (*it)->getRootFolder()->getFilesRecursive(GAME, true); std::vector<FileData*> allFiles = (*it)->getRootFolder()->getFilesRecursive(GAME, true);
for (auto it = allFiles.begin(); it != allFiles.end(); it++) { for (auto it2 = allFiles.begin(); it2 != allFiles.end(); it2++) {
std::string imagePath = (*it)->getImagePath(); std::string imagePath = (*it2)->getImagePath();
if (imagePath != "") if (imagePath != "")
mImageFiles.push_back((*it)); mImageFiles.push_back((*it2));
} }
} }
} }
@ -457,10 +457,10 @@ void SystemScreensaver::generateVideoList()
continue; continue;
std::vector<FileData*> allFiles = (*it)->getRootFolder()->getFilesRecursive(GAME, true); std::vector<FileData*> allFiles = (*it)->getRootFolder()->getFilesRecursive(GAME, true);
for (auto it = allFiles.begin(); it != allFiles.end(); it++) { for (auto it2 = allFiles.begin(); it2 != allFiles.end(); it2++) {
std::string videoPath = (*it)->getVideoPath(); std::string videoPath = (*it2)->getVideoPath();
if (videoPath != "") if (videoPath != "")
mVideoFiles.push_back((*it)); mVideoFiles.push_back((*it2));
} }
} }
} }

View file

@ -147,9 +147,6 @@ void GuiGamelistFilter::addFiltersToMenu()
std::string menuLabel = (*it).menuLabel; // Text to show in menu. std::string menuLabel = (*it).menuLabel; // Text to show in menu.
std::shared_ptr<OptionListComponent<std::string>> optionList; std::shared_ptr<OptionListComponent<std::string>> optionList;
// Add filters (with first one selected).
ComponentListRow row;
// Add genres. // Add genres.
optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(), optionList = std::make_shared<OptionListComponent<std::string>>(mWindow, getHelpStyle(),
menuLabel, true); menuLabel, true);

View file

@ -95,13 +95,13 @@ void NinePatchComponent::buildVertices()
const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]}; const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]};
const glm::vec2 imgSize{imgSizeX[sliceX], imgSizeY[sliceY]}; const glm::vec2 imgSize{imgSizeX[sliceX], imgSizeY[sliceY]};
const glm::vec2 texPos{texPosX[sliceX], texPosY[sliceY]}; const glm::vec2 texPos{texPosX[sliceX], texPosY[sliceY]};
const glm::vec2 texSize{texSizeX[sliceX], texSizeY[sliceY]}; const glm::vec2 texSizeSlice{texSizeX[sliceX], texSizeY[sliceY]};
// clang-format off // clang-format off
mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0}; mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0};
mVertices[v + 2] = {{imgPos.x , imgPos.y + imgSize.y}, {texPos.x, texPos.y + texSize.y}, 0}; mVertices[v + 2] = {{imgPos.x , imgPos.y + imgSize.y}, {texPos.x, texPos.y + texSizeSlice.y}, 0};
mVertices[v + 3] = {{imgPos.x + imgSize.x, imgPos.y }, {texPos.x + texSize.x, texPos.y }, 0}; mVertices[v + 3] = {{imgPos.x + imgSize.x, imgPos.y }, {texPos.x + texSizeSlice.x, texPos.y }, 0};
mVertices[v + 4] = {{imgPos.x + imgSize.x, imgPos.y + imgSize.y}, {texPos.x + texSize.x, texPos.y + texSize.y}, 0}; mVertices[v + 4] = {{imgPos.x + imgSize.x, imgPos.y + imgSize.y}, {texPos.x + texSizeSlice.x, texPos.y + texSizeSlice.y}, 0};
// clang-format on // clang-format on
// Round vertices. // Round vertices.

View file

@ -62,7 +62,11 @@ public:
ALIGN_RIGHT ALIGN_RIGHT
}; };
void setAlignment(Alignment align) { mAlignment = align; } void setAlignment(Alignment align)
{
// Set alignment.
mAlignment = align;
}
void setCursorChangedCallback(const std::function<void(CursorState state)>& func) void setCursorChangedCallback(const std::function<void(CursorState state)>& func)
{ {