mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Added support for specifying a theme name in the capabilities.xml file.
This commit is contained in:
parent
0b7e9dc7c9
commit
623540dd35
|
@ -106,16 +106,32 @@ void GuiMenu::openUIOptions()
|
|||
auto themeSet =
|
||||
std::make_shared<OptionListComponent<std::string>>(getHelpStyle(), "THEME SET", false);
|
||||
|
||||
// Theme selection.
|
||||
// Theme set.
|
||||
if (!themeSets.empty()) {
|
||||
selectedSet = themeSets.find(Settings::getInstance()->getString("ThemeSet"));
|
||||
if (selectedSet == themeSets.cend())
|
||||
selectedSet = themeSets.cbegin();
|
||||
|
||||
for (auto it = themeSets.cbegin(); it != themeSets.cend(); ++it) {
|
||||
std::vector<std::pair<std::string, std::pair<std::string, ThemeData::ThemeSet>>>
|
||||
themeSetsSorted;
|
||||
std::string sortName;
|
||||
for (auto& theme : themeSets) {
|
||||
if (theme.second.capabilities.themeName != "")
|
||||
sortName = theme.second.capabilities.themeName;
|
||||
else
|
||||
sortName = theme.first;
|
||||
themeSetsSorted.emplace_back(std::make_pair(Utils::String::toUpper(sortName),
|
||||
std::make_pair(theme.first, theme.second)));
|
||||
}
|
||||
std::sort(themeSetsSorted.begin(), themeSetsSorted.end(),
|
||||
[](const auto& a, const auto& b) { return a.first < b.first; });
|
||||
for (auto it = themeSetsSorted.cbegin(); it != themeSetsSorted.cend(); ++it) {
|
||||
// If required, abbreviate the theme set name so it doesn't overlap the setting name.
|
||||
const float maxNameLength = mSize.x * 0.62f;
|
||||
themeSet->add(it->first, it->first, it == selectedSet, maxNameLength);
|
||||
const float maxNameLength {mSize.x * 0.62f};
|
||||
std::string themeName {(*it).first};
|
||||
if ((*it).second.second.capabilities.legacyTheme)
|
||||
themeName.append(" [LEGACY]");
|
||||
themeSet->add(themeName, it->second.first, (*it).second.first == selectedSet->first,
|
||||
maxNameLength);
|
||||
}
|
||||
s->addWithLabel("THEME SET", themeSet);
|
||||
s->addSaveFunc([this, themeSet, s] {
|
||||
|
|
|
@ -751,7 +751,7 @@ void ThemeData::populateThemeSets()
|
|||
Utils::FileSystem::getHomePath() + "/.emulationstation/themes"
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < pathCount; ++i) {
|
||||
for (size_t i {0}; i < pathCount; ++i) {
|
||||
if (!Utils::FileSystem::isDirectory(paths[i]))
|
||||
continue;
|
||||
|
||||
|
@ -768,12 +768,20 @@ void ThemeData::populateThemeSets()
|
|||
#endif
|
||||
ThemeCapability capabilities {parseThemeCapabilities(*it)};
|
||||
|
||||
std::string themeName;
|
||||
if (capabilities.themeName != "") {
|
||||
themeName.append(" (theme name \"")
|
||||
.append(capabilities.themeName)
|
||||
.append("\")");
|
||||
}
|
||||
|
||||
#if defined(_WIN64)
|
||||
LOG(LogInfo) << "Added" << (capabilities.legacyTheme ? " legacy" : "")
|
||||
<< " theme set \"" << Utils::String::replace(*it, "/", "\\") << "\"";
|
||||
<< " theme set \"" << Utils::String::replace(*it, "/", "\\") << "\""
|
||||
<< themeName;
|
||||
#else
|
||||
LOG(LogInfo) << "Added" << (capabilities.legacyTheme ? " legacy" : "")
|
||||
<< " theme set \"" << *it << "\"";
|
||||
<< " theme set \"" << *it << "\"" << themeName;
|
||||
#endif
|
||||
if (!capabilities.legacyTheme) {
|
||||
int aspectRatios {0};
|
||||
|
@ -1026,6 +1034,10 @@ ThemeData::ThemeCapability ThemeData::parseThemeCapabilities(const std::string&
|
|||
return capabilities;
|
||||
}
|
||||
|
||||
const pugi::xml_node& themeName {themeCapabilities.child("themeName")};
|
||||
if (themeName != nullptr)
|
||||
capabilities.themeName = themeName.text().get();
|
||||
|
||||
for (pugi::xml_node aspectRatio {themeCapabilities.child("aspectRatio")}; aspectRatio;
|
||||
aspectRatio = aspectRatio.next_sibling("aspectRatio")) {
|
||||
const std::string& value {aspectRatio.text().get()};
|
||||
|
|
|
@ -212,6 +212,7 @@ public:
|
|||
};
|
||||
|
||||
struct ThemeCapability {
|
||||
std::string themeName;
|
||||
std::vector<ThemeVariant> variants;
|
||||
std::vector<ThemeColorScheme> colorSchemes;
|
||||
std::vector<std::string> aspectRatios;
|
||||
|
|
|
@ -302,7 +302,7 @@ private:
|
|||
};
|
||||
|
||||
HelpStyle mHelpStyle;
|
||||
std::function<void(const std::string&)> mSelectedChangedCallback;
|
||||
std::function<void(const T& object)> mSelectedChangedCallback;
|
||||
|
||||
void open()
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ private:
|
|||
mParent->onSizeChanged();
|
||||
|
||||
if (mSelectedChangedCallback)
|
||||
mSelectedChangedCallback(it->name);
|
||||
mSelectedChangedCallback(it->object);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue