mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Added UI labels to the theme aspect ratios.
This commit is contained in:
parent
2bf5e6f3f1
commit
061974eddf
|
@ -44,20 +44,21 @@ std::vector<std::string> ThemeData::sLegacySupportedFeatures {
|
||||||
{"z-index"},
|
{"z-index"},
|
||||||
{"visible"}};
|
{"visible"}};
|
||||||
|
|
||||||
std::vector<std::string> ThemeData::sSupportedAspectRatios {
|
std::vector<std::pair<std::string, std::string>> ThemeData::sSupportedAspectRatios {
|
||||||
{"16:9"},
|
{"16:9", "16:9"},
|
||||||
{"16:9_vertical"},
|
{"16:9_vertical", "16:9 vertical"},
|
||||||
{"16:10"},
|
{"16:10", "16:10"},
|
||||||
{"16:10_vertical"},
|
{"16:10_vertical", "16:10 vertical"},
|
||||||
{"3:2"},
|
{"3:2", "3:2"},
|
||||||
{"3:2_vertical"},
|
{"3:2_vertical", "3:2 vertical"},
|
||||||
{"4:3"},
|
{"4:3", "4:3"},
|
||||||
{"4:3_vertical"},
|
{"4:3_vertical", "4:3 vertical"},
|
||||||
{"5:4"},
|
{"5:4", "5:4"},
|
||||||
{"5:4_vertical"},
|
{"5:4_vertical", "5:4 vertical"},
|
||||||
{"12:5"},
|
{"21:9", "21:9"},
|
||||||
{"43:18"},
|
{"21:9_vertical", "21:9 vertical"},
|
||||||
{"64:27"}};
|
{"32:9", "32:0"},
|
||||||
|
{"32:9_vertical", "32:9 vertical"}};
|
||||||
|
|
||||||
std::map<std::string, std::map<std::string, std::string>> ThemeData::sPropertyAttributeMap
|
std::map<std::string, std::map<std::string, std::string>> ThemeData::sPropertyAttributeMap
|
||||||
// The data type is defined by the parent property.
|
// The data type is defined by the parent property.
|
||||||
|
@ -358,20 +359,13 @@ void ThemeData::loadFile(const std::map<std::string, std::string>& sysDataMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentThemeSet->second.capabilities.aspectRatios.size() > 0) {
|
if (mCurrentThemeSet->second.capabilities.aspectRatios.size() > 0) {
|
||||||
for (auto& aspectRatio : sSupportedAspectRatios) {
|
|
||||||
if (std::find(mCurrentThemeSet->second.capabilities.aspectRatios.cbegin(),
|
if (std::find(mCurrentThemeSet->second.capabilities.aspectRatios.cbegin(),
|
||||||
mCurrentThemeSet->second.capabilities.aspectRatios.cend(),
|
mCurrentThemeSet->second.capabilities.aspectRatios.cend(),
|
||||||
aspectRatio) !=
|
|
||||||
mCurrentThemeSet->second.capabilities.aspectRatios.cend())
|
|
||||||
mAspectRatios.emplace_back(aspectRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (std::find(mAspectRatios.cbegin(), mAspectRatios.cend(),
|
|
||||||
Settings::getInstance()->getString("ThemeAspectRatio")) !=
|
Settings::getInstance()->getString("ThemeAspectRatio")) !=
|
||||||
mAspectRatios.cend())
|
mCurrentThemeSet->second.capabilities.aspectRatios.cend())
|
||||||
mSelectedAspectRatio = Settings::getInstance()->getString("ThemeAspectRatio");
|
mSelectedAspectRatio = Settings::getInstance()->getString("ThemeAspectRatio");
|
||||||
else
|
else
|
||||||
mSelectedAspectRatio = mAspectRatios.front();
|
mSelectedAspectRatio = mCurrentThemeSet->second.capabilities.aspectRatios.front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +444,7 @@ const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view,
|
||||||
return &elemIt->second;
|
return &elemIt->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, ThemeData::ThemeSet>& ThemeData::getThemeSets()
|
const std::map<std::string, ThemeData::ThemeSet>& ThemeData::getThemeSets()
|
||||||
{
|
{
|
||||||
if (!mThemeSets.empty())
|
if (!mThemeSets.empty())
|
||||||
return mThemeSets;
|
return mThemeSets;
|
||||||
|
@ -505,7 +499,7 @@ std::map<std::string, ThemeData::ThemeSet>& ThemeData::getThemeSets()
|
||||||
return mThemeSets;
|
return mThemeSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ThemeData::getThemeFromCurrentSet(const std::string& system)
|
const std::string ThemeData::getThemeFromCurrentSet(const std::string& system)
|
||||||
{
|
{
|
||||||
if (mThemeSets.empty())
|
if (mThemeSets.empty())
|
||||||
getThemeSets();
|
getThemeSets();
|
||||||
|
@ -539,6 +533,18 @@ std::string ThemeData::getThemeFromCurrentSet(const std::string& system)
|
||||||
return set->second.getThemePath(system);
|
return set->second.getThemePath(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::string ThemeData::getAspectRatioLabel(const std::string& aspectRatio)
|
||||||
|
{
|
||||||
|
auto it = std::find_if(sSupportedAspectRatios.cbegin(), sSupportedAspectRatios.cend(),
|
||||||
|
[&aspectRatio](const std::pair<std::string, std::string>& entry) {
|
||||||
|
return entry.first == aspectRatio;
|
||||||
|
});
|
||||||
|
if (it != sSupportedAspectRatios.cend())
|
||||||
|
return it->second;
|
||||||
|
else
|
||||||
|
return "invalid ratio";
|
||||||
|
}
|
||||||
|
|
||||||
const std::shared_ptr<ThemeData> ThemeData::getDefault()
|
const std::shared_ptr<ThemeData> ThemeData::getDefault()
|
||||||
{
|
{
|
||||||
static std::shared_ptr<ThemeData> theme = nullptr;
|
static std::shared_ptr<ThemeData> theme = nullptr;
|
||||||
|
@ -606,6 +612,7 @@ std::string ThemeData::resolvePlaceholders(const std::string& in)
|
||||||
ThemeData::ThemeCapability ThemeData::parseThemeCapabilities(const std::string& path)
|
ThemeData::ThemeCapability ThemeData::parseThemeCapabilities(const std::string& path)
|
||||||
{
|
{
|
||||||
ThemeCapability capabilities;
|
ThemeCapability capabilities;
|
||||||
|
std::vector<std::string> aspectRatiosTemp;
|
||||||
|
|
||||||
std::string capFile {path + "/capabilities.xml"};
|
std::string capFile {path + "/capabilities.xml"};
|
||||||
|
|
||||||
|
@ -635,23 +642,26 @@ ThemeData::ThemeCapability ThemeData::parseThemeCapabilities(const std::string&
|
||||||
for (pugi::xml_node aspectRatio = themeCapabilities.child("aspectRatio"); aspectRatio;
|
for (pugi::xml_node aspectRatio = themeCapabilities.child("aspectRatio"); aspectRatio;
|
||||||
aspectRatio = aspectRatio.next_sibling("aspectRatio")) {
|
aspectRatio = aspectRatio.next_sibling("aspectRatio")) {
|
||||||
std::string value = aspectRatio.text().get();
|
std::string value = aspectRatio.text().get();
|
||||||
if (std::find(sSupportedAspectRatios.cbegin(), sSupportedAspectRatios.cend(), value) ==
|
if (std::find_if(sSupportedAspectRatios.cbegin(), sSupportedAspectRatios.cend(),
|
||||||
sSupportedAspectRatios.cend()) {
|
[&value](const std::pair<std::string, std::string>& entry) {
|
||||||
|
return entry.first == value;
|
||||||
|
}) == sSupportedAspectRatios.cend()) {
|
||||||
LOG(LogWarning) << "Declared aspect ratio \"" << value
|
LOG(LogWarning) << "Declared aspect ratio \"" << value
|
||||||
<< "\" is not supported, ignoring entry in \"" << capFile << "\"";
|
<< "\" is not supported, ignoring entry in \"" << capFile << "\"";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (std::find(capabilities.aspectRatios.cbegin(), capabilities.aspectRatios.cend(),
|
if (std::find(aspectRatiosTemp.cbegin(), aspectRatiosTemp.cend(), value) !=
|
||||||
value) != capabilities.aspectRatios.cend()) {
|
aspectRatiosTemp.cend()) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
<< "Aspect ratio \"" << value
|
<< "Aspect ratio \"" << value
|
||||||
<< "\" is declared multiple times, ignoring entry in \"" << capFile << "\"";
|
<< "\" is declared multiple times, ignoring entry in \"" << capFile << "\"";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
capabilities.aspectRatios.emplace_back(value);
|
aspectRatiosTemp.emplace_back(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (pugi::xml_node variant = themeCapabilities.child("variant"); variant;
|
for (pugi::xml_node variant = themeCapabilities.child("variant"); variant;
|
||||||
variant = variant.next_sibling("variant")) {
|
variant = variant.next_sibling("variant")) {
|
||||||
ThemeVariant readVariant;
|
ThemeVariant readVariant;
|
||||||
|
@ -758,6 +768,17 @@ ThemeData::ThemeCapability ThemeData::parseThemeCapabilities(const std::string&
|
||||||
capabilities.legacyTheme = true;
|
capabilities.legacyTheme = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the aspect ratios in the order they are defined in sSupportedAspectRatios so they
|
||||||
|
// always show up in the same order in the UI Settings menu.
|
||||||
|
if (!aspectRatiosTemp.empty()) {
|
||||||
|
for (auto& aspectRatio : sSupportedAspectRatios) {
|
||||||
|
if (std::find(aspectRatiosTemp.cbegin(), aspectRatiosTemp.cend(), aspectRatio.first) !=
|
||||||
|
aspectRatiosTemp.cend()) {
|
||||||
|
capabilities.aspectRatios.emplace_back(aspectRatio.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -899,8 +920,9 @@ void ThemeData::parseAspectRatios(const pugi::xml_node& root)
|
||||||
prevOff = nameAttr.find_first_not_of(delim, off);
|
prevOff = nameAttr.find_first_not_of(delim, off);
|
||||||
off = nameAttr.find_first_of(delim, prevOff);
|
off = nameAttr.find_first_of(delim, prevOff);
|
||||||
|
|
||||||
if (std::find(mAspectRatios.cbegin(), mAspectRatios.cend(), viewKey) ==
|
if (std::find(mCurrentThemeSet->second.capabilities.aspectRatios.cbegin(),
|
||||||
mAspectRatios.cend()) {
|
mCurrentThemeSet->second.capabilities.aspectRatios.cend(),
|
||||||
|
viewKey) == mCurrentThemeSet->second.capabilities.aspectRatios.cend()) {
|
||||||
throw error << ": aspectRatio value \"" << viewKey
|
throw error << ": aspectRatio value \"" << viewKey
|
||||||
<< "\" is not defined in capabilities.xml";
|
<< "\" is not defined in capabilities.xml";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "utils/FileSystemUtil.h"
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "utils/MathUtil.h"
|
#include "utils/MathUtil.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <any>
|
#include <any>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -202,8 +203,9 @@ public:
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
const std::string& expectedType) const;
|
const std::string& expectedType) const;
|
||||||
|
|
||||||
static std::map<std::string, ThemeSet>& getThemeSets();
|
const static std::map<std::string, ThemeSet>& getThemeSets();
|
||||||
static std::string getThemeFromCurrentSet(const std::string& system);
|
const static std::string getThemeFromCurrentSet(const std::string& system);
|
||||||
|
const static std::string getAspectRatioLabel(const std::string& aspectRatio);
|
||||||
|
|
||||||
const bool isLegacyTheme() { return mLegacyTheme; }
|
const bool isLegacyTheme() { return mLegacyTheme; }
|
||||||
|
|
||||||
|
@ -243,7 +245,7 @@ private:
|
||||||
static std::vector<std::string> sLegacySupportedFeatures;
|
static std::vector<std::string> sLegacySupportedFeatures;
|
||||||
static std::vector<std::string> sLegacySupportedViews;
|
static std::vector<std::string> sLegacySupportedViews;
|
||||||
static std::vector<std::string> sSupportedViews;
|
static std::vector<std::string> sSupportedViews;
|
||||||
static std::vector<std::string> sSupportedAspectRatios;
|
static std::vector<std::pair<std::string, std::string>> sSupportedAspectRatios;
|
||||||
|
|
||||||
static inline std::map<std::string, ThemeSet> mThemeSets;
|
static inline std::map<std::string, ThemeSet> mThemeSets;
|
||||||
std::map<std::string, ThemeData::ThemeSet>::iterator mCurrentThemeSet;
|
std::map<std::string, ThemeData::ThemeSet>::iterator mCurrentThemeSet;
|
||||||
|
@ -251,7 +253,6 @@ private:
|
||||||
std::map<std::string, ThemeView> mViews;
|
std::map<std::string, ThemeView> mViews;
|
||||||
std::deque<std::string> mPaths;
|
std::deque<std::string> mPaths;
|
||||||
std::vector<std::string> mVariants;
|
std::vector<std::string> mVariants;
|
||||||
std::vector<std::string> mAspectRatios;
|
|
||||||
std::string mSelectedVariant;
|
std::string mSelectedVariant;
|
||||||
std::string mSelectedAspectRatio;
|
std::string mSelectedAspectRatio;
|
||||||
bool mLegacyTheme;
|
bool mLegacyTheme;
|
||||||
|
|
Loading…
Reference in a new issue