Added theme support for controlling the TextListComponent collection indicators.

This commit is contained in:
Leon Styhre 2022-04-15 21:20:43 +02:00
parent 03e457516a
commit 7daf69092f
3 changed files with 34 additions and 16 deletions

View file

@ -572,29 +572,30 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
if (mTextList != nullptr) {
TextListComponent<FileData*>::Entry textListEntry;
std::string indicators {mTextList->getIndicators()};
std::string collectionIndicators {mTextList->getCollectionIndicators()};
if (!mFirstGameEntry && (*it)->getType() == GAME)
mFirstGameEntry = (*it);
// Add a leading tick mark icon to the game name if it's part of the custom
// collection currently being edited.
if (isEditing && (*it)->getType() == GAME) {
if (CollectionSystemsManager::getInstance()->inCustomCollection(
editingCollection, (*it))) {
if (collectionIndicators == "ascii")
inCollectionPrefix = "! ";
else
inCollectionPrefix = ViewController::TICKMARK_CHAR + " ";
}
else {
inCollectionPrefix = "";
}
}
if (indicators == "none") {
name = (*it)->getName();
name = inCollectionPrefix + (*it)->getName();
}
else {
// Add a leading tick mark icon to the game name if it's part of the custom
// collection currently being edited.
if (isEditing && (*it)->getType() == GAME) {
if (CollectionSystemsManager::getInstance()->inCustomCollection(
editingCollection, (*it))) {
if (indicators == "ascii")
inCollectionPrefix = "! ";
else
inCollectionPrefix = ViewController::TICKMARK_CHAR + " ";
}
else {
inCollectionPrefix = "";
}
}
if ((*it)->getFavorite() && favoriteStar &&
mRoot->getSystem()->getName() != "favorites") {
if (indicators == "ascii")

View file

@ -290,6 +290,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
{"forceUppercase", BOOLEAN}, // For backward compatibility with legacy themes.
{"lineSpacing", FLOAT},
{"indicators", STRING},
{"collectionIndicators", STRING},
{"zIndex", FLOAT}}},
{"gameselector",
{{"selection", STRING},

View file

@ -119,6 +119,7 @@ public:
void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
const std::string& getIndicators() const { return mIndicators; }
const std::string& getCollectionIndicators() const { return mCollectionIndicators; }
protected:
void onScroll() override
@ -163,6 +164,7 @@ private:
std::shared_ptr<Font> mFont;
std::string mIndicators;
std::string mCollectionIndicators;
bool mUppercase;
bool mLowercase;
bool mCapitalize;
@ -193,6 +195,7 @@ TextListComponent<T>::TextListComponent()
, mHorizontalMargin {0.0f}
, mFont {Font::get(FONT_SIZE_MEDIUM)}
, mIndicators {"symbols"}
, mCollectionIndicators {"symbols"}
, mUppercase {false}
, mLowercase {false}
, mCapitalize {false}
@ -612,6 +615,19 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
}
}
if (elem->has("collectionIndicators")) {
std::string collectionIndicators {elem->get<std::string>("collectionIndicators")};
if (collectionIndicators == "symbols" || collectionIndicators == "ascii") {
mCollectionIndicators = collectionIndicators;
}
else {
mCollectionIndicators = "symbols";
LOG(LogWarning) << "TextListComponent: Invalid theme configuration, property "
"<collectionIndicators> defined as \""
<< collectionIndicators << "\"";
}
}
if (elem->has("selectorImagePath")) {
std::string path {elem->get<std::string>("selectorImagePath")};
bool tile = elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile");