From 2001a9f639a293013d078166457afedb846a9c83 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 15 Apr 2022 19:27:38 +0200 Subject: [PATCH] Added a collection badge to be shown when editing custom collections. Also changed the default badge lines value from 2 to 3. --- es-app/src/views/GamelistLegacy.h | 9 +- es-app/src/views/GamelistView.cpp | 9 +- es-core/src/components/BadgeComponent.cpp | 12 +- resources/graphics/badge_collection.svg | 155 ++++++++++++++++++++++ 4 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 resources/graphics/badge_collection.svg diff --git a/es-app/src/views/GamelistLegacy.h b/es-app/src/views/GamelistLegacy.h index 7b58b6c8a..edf6b2e48 100644 --- a/es-app/src/views/GamelistLegacy.h +++ b/es-app/src/views/GamelistLegacy.h @@ -522,7 +522,14 @@ void GamelistView::legacyUpdateInfoPanel(const CursorState& state) for (auto& badge : badgeComponent->getBadgeTypes()) { BadgeComponent::BadgeInfo badgeInfo; badgeInfo.badgeType = badge; - if (badge == "folder") { + if (badge == "collection" && CollectionSystemsManager::getInstance()->isEditing()) { + if (CollectionSystemsManager::getInstance()->inCustomCollection( + CollectionSystemsManager::getInstance()->getEditingCollection(), + file)) { + badgeSlots.emplace_back(badgeInfo); + } + } + else if (badge == "folder") { if (file->getType() == FOLDER) { if (file->metadata.get("folderlink") != "") badgeInfo.folderLink = true; diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 39a9c2cce..685e10817 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -578,7 +578,14 @@ void GamelistView::updateInfoPanel(const CursorState& state) for (auto& badge : badgeComponent->getBadgeTypes()) { BadgeComponent::BadgeInfo badgeInfo; badgeInfo.badgeType = badge; - if (badge == "folder") { + if (badge == "collection" && CollectionSystemsManager::getInstance()->isEditing()) { + if (CollectionSystemsManager::getInstance()->inCustomCollection( + CollectionSystemsManager::getInstance()->getEditingCollection(), + file)) { + badgeSlots.emplace_back(badgeInfo); + } + } + else if (badge == "folder") { if (file->getType() == FOLDER) { if (file->metadata.get("folderlink") != "") badgeInfo.folderLink = true; diff --git a/es-core/src/components/BadgeComponent.cpp b/es-core/src/components/BadgeComponent.cpp index b3407ab74..1f9714160 100644 --- a/es-core/src/components/BadgeComponent.cpp +++ b/es-core/src/components/BadgeComponent.cpp @@ -7,6 +7,7 @@ // Used by the gamelist views. // +#define SLOT_COLLECTION "collection" #define SLOT_FOLDER "folder" #define SLOT_FAVORITE "favorite" #define SLOT_COMPLETED "completed" @@ -67,9 +68,10 @@ namespace BadgeComponent::BadgeComponent() : mFlexboxItems {} , mFlexboxComponent {mFlexboxItems} - , mBadgeTypes {{SLOT_FOLDER, SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, - SLOT_CONTROLLER, SLOT_ALTEMULATOR}} + , mBadgeTypes {{SLOT_COLLECTION, SLOT_FOLDER, SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, + SLOT_BROKEN, SLOT_CONTROLLER, SLOT_ALTEMULATOR}} { + mBadgeIcons[SLOT_COLLECTION] = ":/graphics/badge_collection.svg"; mBadgeIcons[SLOT_FOLDER] = ":/graphics/badge_folder.svg"; mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg"; mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg"; @@ -249,6 +251,9 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, mFlexboxComponent.setLines(lines); } } + else { + mFlexboxComponent.setLines(3); + } if (elem->has("itemsPerLine")) { const unsigned int itemsPerLine {elem->get("itemsPerLine")}; @@ -261,6 +266,9 @@ void BadgeComponent::applyTheme(const std::shared_ptr& theme, mFlexboxComponent.setItemsPerLine(itemsPerLine); } } + else { + mFlexboxComponent.setItemsPerLine(4); + } if (elem->has("itemMargin")) { glm::vec2 itemMargin = elem->get("itemMargin"); diff --git a/resources/graphics/badge_collection.svg b/resources/graphics/badge_collection.svg new file mode 100644 index 000000000..1acac4219 --- /dev/null +++ b/resources/graphics/badge_collection.svg @@ -0,0 +1,155 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + +