mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Changed the theme property forceUppercase to the more versatile letterCase property.
This commit is contained in:
parent
6db671de3d
commit
09bc9770f2
|
@ -1066,10 +1066,15 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
|||
|
||||
std::string nodeName = node.name();
|
||||
|
||||
if (!mLegacyTheme && element.type == "video") {
|
||||
if (nodeName == "showSnapshotNoVideo" || nodeName == "showSnapshotDelay")
|
||||
if (!mLegacyTheme) {
|
||||
if (nodeName == "showSnapshotNoVideo" || nodeName == "showSnapshotDelay") {
|
||||
throw error << ": Legacy <" << nodeName
|
||||
<< "> property found for non-legacy theme set";
|
||||
}
|
||||
else if (nodeName == "forceUppercase") {
|
||||
throw error << ": Legacy <" << nodeName
|
||||
<< "> property found for non-legacy theme set";
|
||||
}
|
||||
}
|
||||
|
||||
// If an attribute exists, then replace nodeName with its name.
|
||||
|
|
|
@ -50,12 +50,13 @@ namespace ThemeFlags
|
|||
ALIGNMENT = 0x00000080,
|
||||
TEXT = 0x00000100,
|
||||
METADATA = 0x00000200,
|
||||
FORCE_UPPERCASE = 0x00000400,
|
||||
LINE_SPACING = 0x00000800,
|
||||
DELAY = 0x00001000,
|
||||
Z_INDEX = 0x00002000,
|
||||
ROTATION = 0x00004000,
|
||||
VISIBLE = 0x00008000,
|
||||
LETTER_CASE = 0x00000400,
|
||||
FORCE_UPPERCASE = 0x00000800, // For backward compatibility with legacy themes.
|
||||
LINE_SPACING = 0x00001000,
|
||||
DELAY = 0x00002000,
|
||||
Z_INDEX = 0x00004000,
|
||||
ROTATION = 0x00008000,
|
||||
VISIBLE = 0x00010000,
|
||||
ALL = 0xFFFFFFFF
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -94,8 +94,8 @@ void CarouselComponent::addEntry(const std::shared_ptr<ThemeData>& theme,
|
|||
if (legacyMode) {
|
||||
text->applyTheme(theme, "system", "text_logoText",
|
||||
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
|
||||
ThemeFlags::FORCE_UPPERCASE | ThemeFlags::LINE_SPACING |
|
||||
ThemeFlags::TEXT);
|
||||
ThemeFlags::LETTER_CASE | ThemeFlags::FORCE_UPPERCASE |
|
||||
ThemeFlags::LINE_SPACING | ThemeFlags::TEXT);
|
||||
}
|
||||
if (!legacyMode) {
|
||||
text->setLineSpacing(mLineSpacing);
|
||||
|
@ -401,14 +401,24 @@ void CarouselComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
letterCase = elem->get<std::string>("letterCase");
|
||||
|
||||
if (elem->has("text")) {
|
||||
if (letterCase == "uppercase")
|
||||
if (letterCase == "uppercase") {
|
||||
mText = Utils::String::toUpper(elem->get<std::string>("text"));
|
||||
else if (letterCase == "lowercase")
|
||||
}
|
||||
else if (letterCase == "lowercase") {
|
||||
mText = Utils::String::toLower(elem->get<std::string>("text"));
|
||||
else if (letterCase == "capitalize")
|
||||
}
|
||||
else if (letterCase == "capitalize") {
|
||||
mText = Utils::String::toCapitalized(elem->get<std::string>("text"));
|
||||
else
|
||||
}
|
||||
else if (letterCase == "none") {
|
||||
mText = elem->get<std::string>("text");
|
||||
}
|
||||
else {
|
||||
LOG(LogWarning)
|
||||
<< "CarouselComponent: Invalid theme configuration, property <letterCase> set to \""
|
||||
<< letterCase << "\"";
|
||||
mText = elem->get<std::string>("text");
|
||||
}
|
||||
}
|
||||
|
||||
GuiComponent::applyTheme(theme, view, element, ALL);
|
||||
|
|
|
@ -147,6 +147,25 @@ void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (properties & METADATA && elem->has("metadata"))
|
||||
setMetadataField(elem->get<std::string>("metadata"));
|
||||
|
||||
if (properties & LETTER_CASE && elem->has("letterCase")) {
|
||||
std::string letterCase {elem->get<std::string>("letterCase")};
|
||||
if (letterCase == "uppercase") {
|
||||
setUppercase(true);
|
||||
}
|
||||
else if (letterCase == "lowercase") {
|
||||
setLowercase(true);
|
||||
}
|
||||
else if (letterCase == "capitalize") {
|
||||
setCapitalize(true);
|
||||
}
|
||||
else if (letterCase != "none") {
|
||||
LOG(LogWarning)
|
||||
<< "DateTimeComponent: Invalid theme configuration, property <letterCase> set to \""
|
||||
<< letterCase << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy themes only.
|
||||
if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
||||
setUppercase(elem->get<bool>("forceUppercase"));
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ TextComponent::TextComponent()
|
|||
, mRenderBackground {false}
|
||||
, mUppercase {false}
|
||||
, mLowercase {false}
|
||||
, mCapitalized {false}
|
||||
, mCapitalize {false}
|
||||
, mAutoCalcExtent {1, 1}
|
||||
, mHorizontalAlignment {ALIGN_LEFT}
|
||||
, mVerticalAlignment {ALIGN_CENTER}
|
||||
|
@ -46,7 +46,7 @@ TextComponent::TextComponent(const std::string& text,
|
|||
, mRenderBackground {false}
|
||||
, mUppercase {false}
|
||||
, mLowercase {false}
|
||||
, mCapitalized {false}
|
||||
, mCapitalize {false}
|
||||
, mAutoCalcExtent {1, 1}
|
||||
, mHorizontalAlignment {align}
|
||||
, mVerticalAlignment {ALIGN_CENTER}
|
||||
|
@ -126,7 +126,7 @@ void TextComponent::setUppercase(bool uppercase)
|
|||
mUppercase = uppercase;
|
||||
if (uppercase) {
|
||||
mLowercase = false;
|
||||
mCapitalized = false;
|
||||
mCapitalize = false;
|
||||
}
|
||||
onTextChanged();
|
||||
}
|
||||
|
@ -136,15 +136,15 @@ void TextComponent::setLowercase(bool lowercase)
|
|||
mLowercase = lowercase;
|
||||
if (lowercase) {
|
||||
mUppercase = false;
|
||||
mCapitalized = false;
|
||||
mCapitalize = false;
|
||||
}
|
||||
onTextChanged();
|
||||
}
|
||||
|
||||
void TextComponent::setCapitalized(bool capitalized)
|
||||
void TextComponent::setCapitalize(bool capitalize)
|
||||
{
|
||||
mCapitalized = capitalized;
|
||||
if (capitalized) {
|
||||
mCapitalize = capitalize;
|
||||
if (capitalize) {
|
||||
mUppercase = false;
|
||||
mLowercase = false;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void TextComponent::calculateExtent()
|
|||
mSize = mFont->sizeText(Utils::String::toUpper(mText), mLineSpacing);
|
||||
else if (mLowercase)
|
||||
mSize = mFont->sizeText(Utils::String::toLower(mText), mLineSpacing);
|
||||
else if (mCapitalized)
|
||||
else if (mCapitalize)
|
||||
mSize = mFont->sizeText(Utils::String::toCapitalized(mText), mLineSpacing);
|
||||
else
|
||||
mSize = mFont->sizeText(mText, mLineSpacing); // Original case.
|
||||
|
@ -247,7 +247,7 @@ void TextComponent::calculateExtent()
|
|||
mFont->sizeWrappedText(Utils::String::toLower(mText), getSize().x, mLineSpacing)
|
||||
.y;
|
||||
}
|
||||
else if (mCapitalized) {
|
||||
else if (mCapitalize) {
|
||||
mSize.y = mFont
|
||||
->sizeWrappedText(Utils::String::toCapitalized(mText), getSize().x,
|
||||
mLineSpacing)
|
||||
|
@ -275,7 +275,7 @@ void TextComponent::onTextChanged()
|
|||
text = Utils::String::toUpper(mText);
|
||||
else if (mLowercase)
|
||||
text = Utils::String::toLower(mText);
|
||||
else if (mCapitalized)
|
||||
else if (mCapitalize)
|
||||
text = Utils::String::toCapitalized(mText);
|
||||
else
|
||||
text = mText; // Original case.
|
||||
|
@ -397,6 +397,25 @@ void TextComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (properties & METADATA && elem->has("metadata"))
|
||||
setMetadataField(elem->get<std::string>("metadata"));
|
||||
|
||||
if (properties & LETTER_CASE && elem->has("letterCase")) {
|
||||
std::string letterCase {elem->get<std::string>("letterCase")};
|
||||
if (letterCase == "uppercase") {
|
||||
setUppercase(true);
|
||||
}
|
||||
else if (letterCase == "lowercase") {
|
||||
setLowercase(true);
|
||||
}
|
||||
else if (letterCase == "capitalize") {
|
||||
setCapitalize(true);
|
||||
}
|
||||
else if (letterCase != "none") {
|
||||
LOG(LogWarning)
|
||||
<< "TextComponent: Invalid theme configuration, property <letterCase> set to \""
|
||||
<< letterCase << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy themes only.
|
||||
if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
||||
setUppercase(elem->get<bool>("forceUppercase"));
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void setFont(const std::shared_ptr<Font>& font);
|
||||
void setUppercase(bool uppercase);
|
||||
void setLowercase(bool lowercase);
|
||||
void setCapitalized(bool capitalize);
|
||||
void setCapitalize(bool capitalize);
|
||||
void onSizeChanged() override;
|
||||
void setText(const std::string& text, bool update = true);
|
||||
void setHiddenText(const std::string& text) { mHiddenText = text; }
|
||||
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
bool mUppercase;
|
||||
bool mLowercase;
|
||||
bool mCapitalized;
|
||||
bool mCapitalize;
|
||||
glm::ivec2 mAutoCalcExtent;
|
||||
std::shared_ptr<TextCache> mTextCache;
|
||||
Alignment mHorizontalAlignment;
|
||||
|
|
|
@ -78,6 +78,38 @@ public:
|
|||
void setUppercase(bool uppercase)
|
||||
{
|
||||
mUppercase = uppercase;
|
||||
|
||||
if (uppercase) {
|
||||
mLowercase = false;
|
||||
mCapitalize = false;
|
||||
}
|
||||
|
||||
for (auto it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||
it->data.textCache.reset();
|
||||
}
|
||||
|
||||
void setLowercase(bool lowercase)
|
||||
{
|
||||
mLowercase = lowercase;
|
||||
|
||||
if (lowercase) {
|
||||
mUppercase = false;
|
||||
mCapitalize = false;
|
||||
}
|
||||
|
||||
for (auto it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||
it->data.textCache.reset();
|
||||
}
|
||||
|
||||
void setCapitalize(bool capitalize)
|
||||
{
|
||||
mCapitalize = capitalize;
|
||||
|
||||
if (capitalize) {
|
||||
mUppercase = false;
|
||||
mLowercase = false;
|
||||
}
|
||||
|
||||
for (auto it = mEntries.begin(); it != mEntries.end(); ++it)
|
||||
it->data.textCache.reset();
|
||||
}
|
||||
|
@ -115,6 +147,8 @@ private:
|
|||
|
||||
std::shared_ptr<Font> mFont;
|
||||
bool mUppercase;
|
||||
bool mLowercase;
|
||||
bool mCapitalize;
|
||||
float mLineSpacing;
|
||||
float mSelectorHeight;
|
||||
float mSelectorOffsetY;
|
||||
|
@ -140,6 +174,8 @@ template <typename T> TextListComponent<T>::TextListComponent()
|
|||
|
||||
mFont = Font::get(FONT_SIZE_MEDIUM);
|
||||
mUppercase = false;
|
||||
mLowercase = false;
|
||||
mCapitalize = false;
|
||||
mLineSpacing = 1.5f;
|
||||
mSelectorHeight = mFont->getSize() * 1.5f;
|
||||
mSelectorOffsetY = 0;
|
||||
|
@ -229,9 +265,20 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
else
|
||||
color = mColors[entry.data.colorId];
|
||||
|
||||
if (!entry.data.textCache)
|
||||
entry.data.textCache = std::unique_ptr<TextCache>(font->buildTextCache(
|
||||
mUppercase ? Utils::String::toUpper(entry.name) : entry.name, 0, 0, 0x000000FF));
|
||||
if (!entry.data.textCache) {
|
||||
if (mUppercase)
|
||||
entry.data.textCache = std::unique_ptr<TextCache>(
|
||||
font->buildTextCache(Utils::String::toUpper(entry.name), 0, 0, 0x000000FF));
|
||||
else if (mLowercase)
|
||||
entry.data.textCache = std::unique_ptr<TextCache>(
|
||||
font->buildTextCache(Utils::String::toLower(entry.name), 0, 0, 0x000000FF));
|
||||
else if (mCapitalize)
|
||||
entry.data.textCache = std::unique_ptr<TextCache>(font->buildTextCache(
|
||||
Utils::String::toCapitalized(entry.name), 0, 0, 0x000000FF));
|
||||
else
|
||||
entry.data.textCache =
|
||||
std::unique_ptr<TextCache>(font->buildTextCache(entry.name, 0, 0, 0x000000FF));
|
||||
}
|
||||
|
||||
// If a game is marked as hidden, lower the text opacity a lot.
|
||||
// If a game is marked to not be counted, lower the opacity a moderate amount.
|
||||
|
@ -462,6 +509,25 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
}
|
||||
}
|
||||
|
||||
if (properties & LETTER_CASE && elem->has("letterCase")) {
|
||||
std::string letterCase {elem->get<std::string>("letterCase")};
|
||||
if (letterCase == "uppercase") {
|
||||
setUppercase(true);
|
||||
}
|
||||
else if (letterCase == "lowercase") {
|
||||
setLowercase(true);
|
||||
}
|
||||
else if (letterCase == "capitalize") {
|
||||
setCapitalize(true);
|
||||
}
|
||||
else if (letterCase != "none") {
|
||||
LOG(LogWarning)
|
||||
<< "TextListComponent: Invalid theme configuration, property <letterCase> set to \""
|
||||
<< letterCase << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy themes only.
|
||||
if (properties & FORCE_UPPERCASE && elem->has("forceUppercase"))
|
||||
setUppercase(elem->get<bool>("forceUppercase"));
|
||||
|
||||
|
|
Loading…
Reference in a new issue