mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added theme support for controlling the TextListComponent indicators.
This commit is contained in:
parent
486d3b0fcb
commit
254e271392
|
@ -571,48 +571,56 @@ 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);
|
||||||
// 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 (Settings::getInstance()->getBool("SpecialCharsASCII"))
|
|
||||||
inCollectionPrefix = "! ";
|
|
||||||
else
|
|
||||||
inCollectionPrefix = ViewController::TICKMARK_CHAR + " ";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inCollectionPrefix = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((*it)->getFavorite() && favoriteStar &&
|
if (indicators == "none") {
|
||||||
mRoot->getSystem()->getName() != "favorites") {
|
name = (*it)->getName();
|
||||||
if (Settings::getInstance()->getBool("SpecialCharsASCII"))
|
|
||||||
name = inCollectionPrefix + "* " + (*it)->getName();
|
|
||||||
else
|
|
||||||
name = inCollectionPrefix + ViewController::FAVORITE_CHAR + " " +
|
|
||||||
(*it)->getName();
|
|
||||||
}
|
|
||||||
else if ((*it)->getType() == FOLDER &&
|
|
||||||
mRoot->getSystem()->getName() != "collections") {
|
|
||||||
if (Settings::getInstance()->getBool("SpecialCharsASCII")) {
|
|
||||||
if ((*it)->metadata.get("folderlink") != "")
|
|
||||||
name = "> " + (*it)->getName();
|
|
||||||
else
|
|
||||||
name = "# " + (*it)->getName();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((*it)->metadata.get("folderlink") != "")
|
|
||||||
name = ViewController::FOLDERLINK_CHAR + " " + (*it)->getName();
|
|
||||||
else
|
|
||||||
name = ViewController::FOLDER_CHAR + " " + (*it)->getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
name = inCollectionPrefix + (*it)->getName();
|
// 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")
|
||||||
|
name = inCollectionPrefix + "* " + (*it)->getName();
|
||||||
|
else
|
||||||
|
name = inCollectionPrefix + ViewController::FAVORITE_CHAR + " " +
|
||||||
|
(*it)->getName();
|
||||||
|
}
|
||||||
|
else if ((*it)->getType() == FOLDER &&
|
||||||
|
mRoot->getSystem()->getName() != "collections") {
|
||||||
|
if (indicators == "ascii") {
|
||||||
|
if ((*it)->metadata.get("folderlink") != "")
|
||||||
|
name = "> " + (*it)->getName();
|
||||||
|
else
|
||||||
|
name = "# " + (*it)->getName();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((*it)->metadata.get("folderlink") != "")
|
||||||
|
name = ViewController::FOLDERLINK_CHAR + " " + (*it)->getName();
|
||||||
|
else
|
||||||
|
name = ViewController::FOLDER_CHAR + " " + (*it)->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
name = inCollectionPrefix + (*it)->getName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
color = (*it)->getType() == FOLDER;
|
color = (*it)->getType() == FOLDER;
|
||||||
textListEntry.name = name;
|
textListEntry.name = name;
|
||||||
|
|
|
@ -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