mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Added theme support for controlling the TextListComponent indicators.
This commit is contained in:
parent
486d3b0fcb
commit
254e271392
|
@ -571,14 +571,21 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
|
||||||
|
|
||||||
if (mTextList != nullptr) {
|
if (mTextList != nullptr) {
|
||||||
TextListComponent<FileData*>::Entry textListEntry;
|
TextListComponent<FileData*>::Entry textListEntry;
|
||||||
|
std::string indicators {mTextList->getIndicators()};
|
||||||
|
|
||||||
if (!mFirstGameEntry && (*it)->getType() == GAME)
|
if (!mFirstGameEntry && (*it)->getType() == GAME)
|
||||||
mFirstGameEntry = (*it);
|
mFirstGameEntry = (*it);
|
||||||
|
|
||||||
|
if (indicators == "none") {
|
||||||
|
name = (*it)->getName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Add a leading tick mark icon to the game name if it's part of the custom
|
// Add a leading tick mark icon to the game name if it's part of the custom
|
||||||
// collection currently being edited.
|
// collection currently being edited.
|
||||||
if (isEditing && (*it)->getType() == GAME) {
|
if (isEditing && (*it)->getType() == GAME) {
|
||||||
if (CollectionSystemsManager::getInstance()->inCustomCollection(
|
if (CollectionSystemsManager::getInstance()->inCustomCollection(
|
||||||
editingCollection, (*it))) {
|
editingCollection, (*it))) {
|
||||||
if (Settings::getInstance()->getBool("SpecialCharsASCII"))
|
if (indicators == "ascii")
|
||||||
inCollectionPrefix = "! ";
|
inCollectionPrefix = "! ";
|
||||||
else
|
else
|
||||||
inCollectionPrefix = ViewController::TICKMARK_CHAR + " ";
|
inCollectionPrefix = ViewController::TICKMARK_CHAR + " ";
|
||||||
|
@ -590,7 +597,7 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
|
||||||
|
|
||||||
if ((*it)->getFavorite() && favoriteStar &&
|
if ((*it)->getFavorite() && favoriteStar &&
|
||||||
mRoot->getSystem()->getName() != "favorites") {
|
mRoot->getSystem()->getName() != "favorites") {
|
||||||
if (Settings::getInstance()->getBool("SpecialCharsASCII"))
|
if (indicators == "ascii")
|
||||||
name = inCollectionPrefix + "* " + (*it)->getName();
|
name = inCollectionPrefix + "* " + (*it)->getName();
|
||||||
else
|
else
|
||||||
name = inCollectionPrefix + ViewController::FAVORITE_CHAR + " " +
|
name = inCollectionPrefix + ViewController::FAVORITE_CHAR + " " +
|
||||||
|
@ -598,7 +605,7 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
|
||||||
}
|
}
|
||||||
else if ((*it)->getType() == FOLDER &&
|
else if ((*it)->getType() == FOLDER &&
|
||||||
mRoot->getSystem()->getName() != "collections") {
|
mRoot->getSystem()->getName() != "collections") {
|
||||||
if (Settings::getInstance()->getBool("SpecialCharsASCII")) {
|
if (indicators == "ascii") {
|
||||||
if ((*it)->metadata.get("folderlink") != "")
|
if ((*it)->metadata.get("folderlink") != "")
|
||||||
name = "> " + (*it)->getName();
|
name = "> " + (*it)->getName();
|
||||||
else
|
else
|
||||||
|
@ -614,6 +621,7 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
|
||||||
else {
|
else {
|
||||||
name = inCollectionPrefix + (*it)->getName();
|
name = inCollectionPrefix + (*it)->getName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
color = (*it)->getType() == FOLDER;
|
color = (*it)->getType() == FOLDER;
|
||||||
textListEntry.name = name;
|
textListEntry.name = name;
|
||||||
textListEntry.object = *it;
|
textListEntry.object = *it;
|
||||||
|
|
|
@ -289,6 +289,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"letterCase", STRING},
|
{"letterCase", STRING},
|
||||||
{"forceUppercase", BOOLEAN}, // For backward compatibility with legacy themes.
|
{"forceUppercase", BOOLEAN}, // For backward compatibility with legacy themes.
|
||||||
{"lineSpacing", FLOAT},
|
{"lineSpacing", FLOAT},
|
||||||
|
{"indicators", STRING},
|
||||||
{"zIndex", FLOAT}}},
|
{"zIndex", FLOAT}}},
|
||||||
{"gameselector",
|
{"gameselector",
|
||||||
{{"selection", STRING},
|
{{"selection", STRING},
|
||||||
|
|
|
@ -118,6 +118,7 @@ public:
|
||||||
void setSelectedColor(unsigned int color) { mSelectedColor = color; }
|
void setSelectedColor(unsigned int color) { mSelectedColor = color; }
|
||||||
void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
void setColor(unsigned int id, unsigned int color) { mColors[id] = color; }
|
||||||
void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
void setLineSpacing(float lineSpacing) { mLineSpacing = lineSpacing; }
|
||||||
|
const std::string& getIndicators() const { return mIndicators; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onScroll() override
|
void onScroll() override
|
||||||
|
@ -161,6 +162,7 @@ private:
|
||||||
ImageComponent mSelectorImage;
|
ImageComponent mSelectorImage;
|
||||||
|
|
||||||
std::shared_ptr<Font> mFont;
|
std::shared_ptr<Font> mFont;
|
||||||
|
std::string mIndicators;
|
||||||
bool mUppercase;
|
bool mUppercase;
|
||||||
bool mLowercase;
|
bool mLowercase;
|
||||||
bool mCapitalize;
|
bool mCapitalize;
|
||||||
|
@ -190,6 +192,7 @@ TextListComponent<T>::TextListComponent()
|
||||||
, mAlignment {PrimaryAlignment::ALIGN_CENTER}
|
, mAlignment {PrimaryAlignment::ALIGN_CENTER}
|
||||||
, mHorizontalMargin {0.0f}
|
, mHorizontalMargin {0.0f}
|
||||||
, mFont {Font::get(FONT_SIZE_MEDIUM)}
|
, mFont {Font::get(FONT_SIZE_MEDIUM)}
|
||||||
|
, mIndicators {"symbols"}
|
||||||
, mUppercase {false}
|
, mUppercase {false}
|
||||||
, mLowercase {false}
|
, mLowercase {false}
|
||||||
, mCapitalize {false}
|
, mCapitalize {false}
|
||||||
|
@ -587,8 +590,8 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("selectorHeight"))
|
if (elem->has("selectorHeight"))
|
||||||
setSelectorHeight(elem->get<float>("selectorHeight") * Renderer::getScreenHeight());
|
setSelectorHeight(elem->get<float>("selectorHeight") * Renderer::getScreenHeight());
|
||||||
if (elem->has("selectorOffsetY")) {
|
if (elem->has("selectorOffsetY")) {
|
||||||
float scale = this->mParent ? this->mParent->getSize().y :
|
float scale {this->mParent ? this->mParent->getSize().y :
|
||||||
static_cast<float>(Renderer::getScreenHeight());
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
setSelectorOffsetY(elem->get<float>("selectorOffsetY") * scale);
|
setSelectorOffsetY(elem->get<float>("selectorOffsetY") * scale);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -596,8 +599,21 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elem->has("indicators")) {
|
||||||
|
std::string indicators {elem->get<std::string>("indicators")};
|
||||||
|
if (indicators == "symbols" || indicators == "ascii" || indicators == "none") {
|
||||||
|
mIndicators = indicators;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mIndicators = "symbols";
|
||||||
|
LOG(LogWarning) << "TextListComponent: Invalid theme configuration, property "
|
||||||
|
"<indicators> defined as \""
|
||||||
|
<< indicators << "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("selectorImagePath")) {
|
if (elem->has("selectorImagePath")) {
|
||||||
std::string path = elem->get<std::string>("selectorImagePath");
|
std::string path {elem->get<std::string>("selectorImagePath")};
|
||||||
bool tile = elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile");
|
bool tile = elem->has("selectorImageTile") && elem->get<bool>("selectorImageTile");
|
||||||
mSelectorImage.setImage(path, tile);
|
mSelectorImage.setImage(path, tile);
|
||||||
mSelectorImage.setSize(mSize.x, mSelectorHeight);
|
mSelectorImage.setSize(mSize.x, mSelectorHeight);
|
||||||
|
|
Loading…
Reference in a new issue