mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Implement theme customizable button icons.
This commit is contained in:
parent
32520a1c3a
commit
5851ab054f
|
@ -67,4 +67,72 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
|
|||
|
||||
if (elem->has("textStyle"))
|
||||
textStyle = elem->get<std::string>("textStyle");
|
||||
|
||||
// Load custom button icons.
|
||||
|
||||
// General.
|
||||
if (elem->has("dpad_updown"))
|
||||
mCustomButtons.dpad_updown = elem->get<std::string>("dpad_updown");
|
||||
if (elem->has("dpad_leftright"))
|
||||
mCustomButtons.dpad_leftright = elem->get<std::string>("dpad_leftright");
|
||||
if (elem->has("dpad_all"))
|
||||
mCustomButtons.dpad_all = elem->get<std::string>("dpad_all");
|
||||
if (elem->has("thumbstick_click"))
|
||||
mCustomButtons.thumbstick_click = elem->get<std::string>("thumbstick_click");
|
||||
if (elem->has("button_l"))
|
||||
mCustomButtons.button_l = elem->get<std::string>("button_l");
|
||||
if (elem->has("button_r"))
|
||||
mCustomButtons.button_r = elem->get<std::string>("button_r");
|
||||
if (elem->has("button_lr"))
|
||||
mCustomButtons.button_lr = elem->get<std::string>("button_lr");
|
||||
|
||||
// SNES.
|
||||
if (elem->has("button_a_SNES"))
|
||||
mCustomButtons.button_a_SNES = elem->get<std::string>("button_a_SNES");
|
||||
if (elem->has("button_b_SNES"))
|
||||
mCustomButtons.button_b_SNES = elem->get<std::string>("button_b_SNES");
|
||||
if (elem->has("button_x_SNES"))
|
||||
mCustomButtons.button_x_SNES = elem->get<std::string>("button_x_SNES");
|
||||
if (elem->has("button_y_SNES"))
|
||||
mCustomButtons.button_y_SNES = elem->get<std::string>("button_y_SNES");
|
||||
if (elem->has("button_start_SNES"))
|
||||
mCustomButtons.button_start_SNES = elem->get<std::string>("button_start_SNES");
|
||||
if (elem->has("button_back_SNES"))
|
||||
mCustomButtons.button_back_SNES = elem->get<std::string>("button_back_SNES");
|
||||
|
||||
// PS.
|
||||
if (elem->has("button_a_PS"))
|
||||
mCustomButtons.button_a_PS = elem->get<std::string>("button_a_PS");
|
||||
if (elem->has("button_b_PS"))
|
||||
mCustomButtons.button_b_PS = elem->get<std::string>("button_b_PS");
|
||||
if (elem->has("button_x_PS"))
|
||||
mCustomButtons.button_x_PS = elem->get<std::string>("button_x_PS");
|
||||
if (elem->has("button_y_PS"))
|
||||
mCustomButtons.button_y_PS = elem->get<std::string>("button_y_PS");
|
||||
if (elem->has("button_start_PS4"))
|
||||
mCustomButtons.button_start_PS4 = elem->get<std::string>("button_start_PS4");
|
||||
if (elem->has("button_back_PS4"))
|
||||
mCustomButtons.button_back_PS4 = elem->get<std::string>("button_back_PS4");
|
||||
if (elem->has("button_start_PS5"))
|
||||
mCustomButtons.button_start_PS5 = elem->get<std::string>("button_start_PS5");
|
||||
if (elem->has("button_back_PS5"))
|
||||
mCustomButtons.button_back_PS5 = elem->get<std::string>("button_back_PS5");
|
||||
|
||||
// XBOX.
|
||||
if (elem->has("button_a_XBOX"))
|
||||
mCustomButtons.button_a_XBOX = elem->get<std::string>("button_a_XBOX");
|
||||
if (elem->has("button_b_XBOX"))
|
||||
mCustomButtons.button_b_XBOX = elem->get<std::string>("button_b_XBOX");
|
||||
if (elem->has("button_x_XBOX"))
|
||||
mCustomButtons.button_x_XBOX = elem->get<std::string>("button_x_XBOX");
|
||||
if (elem->has("button_y_XBOX"))
|
||||
mCustomButtons.button_y_XBOX = elem->get<std::string>("button_y_XBOX");
|
||||
if (elem->has("button_start_XBOX"))
|
||||
mCustomButtons.button_start_XBOX = elem->get<std::string>("button_start_XBOX");
|
||||
if (elem->has("button_back_XBOX"))
|
||||
mCustomButtons.button_back_XBOX = elem->get<std::string>("button_back_XBOX");
|
||||
if (elem->has("button_start_XBOX360"))
|
||||
mCustomButtons.button_start_XBOX360 = elem->get<std::string>("button_start_XBOX360");
|
||||
if (elem->has("button_back_XBOX360"))
|
||||
mCustomButtons.button_back_XBOX360 = elem->get<std::string>("button_back_XBOX360");
|
||||
}
|
||||
|
|
|
@ -30,6 +30,48 @@ struct HelpStyle {
|
|||
float iconTextSpacing;
|
||||
std::string textStyle;
|
||||
|
||||
struct CustomButtonIcons {
|
||||
|
||||
// General.
|
||||
std::string dpad_updown;
|
||||
std::string dpad_leftright;
|
||||
std::string dpad_all;
|
||||
std::string thumbstick_click;
|
||||
std::string button_l;
|
||||
std::string button_r;
|
||||
std::string button_lr;
|
||||
|
||||
// SNES.
|
||||
std::string button_a_SNES;
|
||||
std::string button_b_SNES;
|
||||
std::string button_x_SNES;
|
||||
std::string button_y_SNES;
|
||||
std::string button_start_SNES;
|
||||
std::string button_back_SNES;
|
||||
|
||||
// PS.
|
||||
std::string button_a_PS;
|
||||
std::string button_b_PS;
|
||||
std::string button_x_PS;
|
||||
std::string button_y_PS;
|
||||
std::string button_start_PS4;
|
||||
std::string button_back_PS4;
|
||||
std::string button_start_PS5;
|
||||
std::string button_back_PS5;
|
||||
|
||||
// XBOX.
|
||||
std::string button_a_XBOX;
|
||||
std::string button_b_XBOX;
|
||||
std::string button_x_XBOX;
|
||||
std::string button_y_XBOX;
|
||||
std::string button_start_XBOX;
|
||||
std::string button_back_XBOX;
|
||||
std::string button_start_XBOX360;
|
||||
std::string button_back_XBOX360;
|
||||
};
|
||||
|
||||
CustomButtonIcons mCustomButtons;
|
||||
|
||||
HelpStyle(); // Default values.
|
||||
void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view);
|
||||
};
|
||||
|
|
|
@ -158,7 +158,36 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
|
|||
{"fontSize", FLOAT},
|
||||
{"entrySpacing", FLOAT},
|
||||
{"iconTextSpacing", FLOAT},
|
||||
{"textStyle", STRING}}},
|
||||
{"textStyle", STRING},
|
||||
{"dpad_updown", PATH},
|
||||
{"dpad_leftright", PATH},
|
||||
{"dpad_all", PATH},
|
||||
{"thumbstick_click", PATH},
|
||||
{"button_l", PATH},
|
||||
{"button_r", PATH},
|
||||
{"button_lr", PATH},
|
||||
{"button_a_SNES", PATH},
|
||||
{"button_b_SNES", PATH},
|
||||
{"button_x_SNEs", PATH},
|
||||
{"button_y_SNES", PATH},
|
||||
{"button_back_SNES", PATH},
|
||||
{"button_start_SNES", PATH},
|
||||
{"button_a_PS", PATH},
|
||||
{"button_b_PS", PATH},
|
||||
{"button_x_PS", PATH},
|
||||
{"button_y_PS", PATH},
|
||||
{"button_back_PS4", PATH},
|
||||
{"button_start_PS4", PATH},
|
||||
{"button_back_PS5", PATH},
|
||||
{"button_start_PS5", PATH},
|
||||
{"button_a_XBOX", PATH},
|
||||
{"button_b_XBOX", PATH},
|
||||
{"button_x_XBOX", PATH},
|
||||
{"button_y_XBOX", PATH},
|
||||
{"button_back_XBOX", PATH},
|
||||
{"button_start_XBOX", PATH},
|
||||
{"button_back_XBOX360", PATH},
|
||||
{"button_start_XBOX360", PATH}}},
|
||||
{"navigationsounds",
|
||||
{{"systembrowseSound", PATH},
|
||||
{"quicksysselectSound", PATH},
|
||||
|
|
|
@ -32,55 +32,126 @@ void HelpComponent::assignIcons()
|
|||
sIconPathMap.clear();
|
||||
|
||||
// These graphics files are common between all controller types.
|
||||
sIconPathMap["up/down"] = ":/help/dpad_updown.svg";
|
||||
sIconPathMap["left/right"] = ":/help/dpad_leftright.svg";
|
||||
sIconPathMap["up/down/left/right"] = ":/help/dpad_all.svg";
|
||||
sIconPathMap["thumbstickclick"] = ":/help/thumbstick_click.svg";
|
||||
sIconPathMap["l"] = ":/help/button_l.svg";
|
||||
sIconPathMap["r"] = ":/help/button_r.svg";
|
||||
sIconPathMap["lr"] = ":/help/button_lr.svg";
|
||||
sIconPathMap["up/down"] = mStyle.mCustomButtons.dpad_updown.empty() ?
|
||||
":/help/dpad_updown.svg" :
|
||||
mStyle.mCustomButtons.dpad_updown;
|
||||
sIconPathMap["left/right"] = mStyle.mCustomButtons.dpad_leftright.empty() ?
|
||||
":/help/dpad_leftright.svg" :
|
||||
mStyle.mCustomButtons.dpad_leftright;
|
||||
sIconPathMap["up/down/left/right"] = mStyle.mCustomButtons.dpad_all.empty() ?
|
||||
":/help/dpad_all.svg" :
|
||||
mStyle.mCustomButtons.dpad_all;
|
||||
sIconPathMap["thumbstickclick"] = mStyle.mCustomButtons.thumbstick_click.empty() ?
|
||||
":/help/thumbstick_click.svg" :
|
||||
mStyle.mCustomButtons.thumbstick_click;
|
||||
sIconPathMap["l"] = mStyle.mCustomButtons.button_l.empty() ? ":/help/button_l.svg" :
|
||||
mStyle.mCustomButtons.button_l;
|
||||
sIconPathMap["r"] = mStyle.mCustomButtons.button_r.empty() ? ":/help/button_r.svg" :
|
||||
mStyle.mCustomButtons.button_r;
|
||||
sIconPathMap["lr"] = mStyle.mCustomButtons.button_lr.empty() ? ":/help/button_lr.svg" :
|
||||
mStyle.mCustomButtons.button_lr;
|
||||
|
||||
// These graphics files are custom per controller type.
|
||||
if (controllerType == "snes") {
|
||||
sIconPathMap["a"] = ":/help/button_a_SNES.svg";
|
||||
sIconPathMap["b"] = ":/help/button_b_SNES.svg";
|
||||
sIconPathMap["x"] = ":/help/button_x_SNES.svg";
|
||||
sIconPathMap["y"] = ":/help/button_y_SNES.svg";
|
||||
sIconPathMap["start"] = ":/help/button_start_SNES.svg";
|
||||
sIconPathMap["back"] = ":/help/button_back_SNES.svg";
|
||||
sIconPathMap["a"] = mStyle.mCustomButtons.button_a_SNES.empty() ?
|
||||
":/help/button_a_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_a_SNES;
|
||||
sIconPathMap["b"] = mStyle.mCustomButtons.button_b_SNES.empty() ?
|
||||
":/help/button_b_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_b_SNES;
|
||||
sIconPathMap["x"] = mStyle.mCustomButtons.button_x_SNES.empty() ?
|
||||
":/help/button_x_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_x_SNES;
|
||||
sIconPathMap["y"] = mStyle.mCustomButtons.button_y_SNES.empty() ?
|
||||
":/help/button_y_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_y_SNES;
|
||||
sIconPathMap["start"] = mStyle.mCustomButtons.button_start_SNES.empty() ?
|
||||
":/help/button_start_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_start_SNES;
|
||||
sIconPathMap["back"] = mStyle.mCustomButtons.button_back_SNES.empty() ?
|
||||
":/help/button_back_SNES.svg" :
|
||||
mStyle.mCustomButtons.button_back_SNES;
|
||||
}
|
||||
else if (controllerType == "ps4") {
|
||||
sIconPathMap["a"] = ":/help/button_a_PS.svg";
|
||||
sIconPathMap["b"] = ":/help/button_b_PS.svg";
|
||||
sIconPathMap["x"] = ":/help/button_x_PS.svg";
|
||||
sIconPathMap["y"] = ":/help/button_y_PS.svg";
|
||||
sIconPathMap["start"] = ":/help/button_start_PS4.svg";
|
||||
sIconPathMap["back"] = ":/help/button_back_PS4.svg";
|
||||
sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ?
|
||||
":/help/button_a_PS.svg" :
|
||||
mStyle.mCustomButtons.button_a_PS;
|
||||
sIconPathMap["b"] = mStyle.mCustomButtons.button_b_PS.empty() ?
|
||||
":/help/button_b_PS.svg" :
|
||||
mStyle.mCustomButtons.button_b_PS;
|
||||
sIconPathMap["x"] = mStyle.mCustomButtons.button_x_PS.empty() ?
|
||||
":/help/button_x_PS.svg" :
|
||||
mStyle.mCustomButtons.button_x_PS;
|
||||
sIconPathMap["y"] = mStyle.mCustomButtons.button_y_PS.empty() ?
|
||||
":/help/button_y_PS.svg" :
|
||||
mStyle.mCustomButtons.button_y_PS;
|
||||
sIconPathMap["start"] = mStyle.mCustomButtons.button_start_PS4.empty() ?
|
||||
":/help/button_start_PS4.svg" :
|
||||
mStyle.mCustomButtons.button_start_PS4;
|
||||
sIconPathMap["back"] = mStyle.mCustomButtons.button_back_PS4.empty() ?
|
||||
":/help/button_back_PS4.svg" :
|
||||
mStyle.mCustomButtons.button_back_PS4;
|
||||
}
|
||||
else if (controllerType == "ps5") {
|
||||
sIconPathMap["a"] = ":/help/button_a_PS.svg";
|
||||
sIconPathMap["b"] = ":/help/button_b_PS.svg";
|
||||
sIconPathMap["x"] = ":/help/button_x_PS.svg";
|
||||
sIconPathMap["y"] = ":/help/button_y_PS.svg";
|
||||
sIconPathMap["start"] = ":/help/button_start_PS5.svg";
|
||||
sIconPathMap["back"] = ":/help/button_back_PS5.svg";
|
||||
sIconPathMap["a"] = mStyle.mCustomButtons.button_a_PS.empty() ?
|
||||
":/help/button_a_PS.svg" :
|
||||
mStyle.mCustomButtons.button_a_PS;
|
||||
sIconPathMap["b"] = mStyle.mCustomButtons.button_b_PS.empty() ?
|
||||
":/help/button_b_PS.svg" :
|
||||
mStyle.mCustomButtons.button_b_PS;
|
||||
sIconPathMap["x"] = mStyle.mCustomButtons.button_x_PS.empty() ?
|
||||
":/help/button_x_PS.svg" :
|
||||
mStyle.mCustomButtons.button_x_PS;
|
||||
sIconPathMap["y"] = mStyle.mCustomButtons.button_y_PS.empty() ?
|
||||
":/help/button_y_PS.svg" :
|
||||
mStyle.mCustomButtons.button_y_PS;
|
||||
sIconPathMap["start"] = mStyle.mCustomButtons.button_start_PS5.empty() ?
|
||||
":/help/button_start_PS5.svg" :
|
||||
mStyle.mCustomButtons.button_start_PS5;
|
||||
sIconPathMap["back"] = mStyle.mCustomButtons.button_back_PS5.empty() ?
|
||||
":/help/button_back_PS5.svg" :
|
||||
mStyle.mCustomButtons.button_back_PS5;
|
||||
}
|
||||
else if (controllerType == "xbox360") {
|
||||
sIconPathMap["a"] = ":/help/button_a_XBOX.svg";
|
||||
sIconPathMap["b"] = ":/help/button_b_XBOX.svg";
|
||||
sIconPathMap["x"] = ":/help/button_x_XBOX.svg";
|
||||
sIconPathMap["y"] = ":/help/button_y_XBOX.svg";
|
||||
sIconPathMap["start"] = ":/help/button_start_XBOX360.svg";
|
||||
sIconPathMap["back"] = ":/help/button_back_XBOX360.svg";
|
||||
sIconPathMap["a"] = mStyle.mCustomButtons.button_a_XBOX.empty() ?
|
||||
":/help/button_a_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_a_XBOX;
|
||||
sIconPathMap["b"] = mStyle.mCustomButtons.button_b_XBOX.empty() ?
|
||||
":/help/button_b_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_b_XBOX;
|
||||
sIconPathMap["x"] = mStyle.mCustomButtons.button_x_XBOX.empty() ?
|
||||
":/help/button_x_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_x_XBOX;
|
||||
sIconPathMap["y"] = mStyle.mCustomButtons.button_y_XBOX.empty() ?
|
||||
":/help/button_y_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_y_XBOX;
|
||||
sIconPathMap["start"] = mStyle.mCustomButtons.button_start_XBOX360.empty() ?
|
||||
":/help/button_start_XBOX360.svg" :
|
||||
mStyle.mCustomButtons.button_start_XBOX360;
|
||||
sIconPathMap["back"] = mStyle.mCustomButtons.button_back_XBOX360.empty() ?
|
||||
":/help/button_back_XBOX360.svg" :
|
||||
mStyle.mCustomButtons.button_back_XBOX360;
|
||||
}
|
||||
else {
|
||||
// Xbox One and later.
|
||||
sIconPathMap["a"] = ":/help/button_a_XBOX.svg";
|
||||
sIconPathMap["b"] = ":/help/button_b_XBOX.svg";
|
||||
sIconPathMap["x"] = ":/help/button_x_XBOX.svg";
|
||||
sIconPathMap["y"] = ":/help/button_y_XBOX.svg";
|
||||
sIconPathMap["start"] = ":/help/button_start_XBOX.svg";
|
||||
sIconPathMap["back"] = ":/help/button_back_XBOX.svg";
|
||||
sIconPathMap["a"] = mStyle.mCustomButtons.button_a_XBOX.empty() ?
|
||||
":/help/button_a_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_a_XBOX;
|
||||
sIconPathMap["b"] = mStyle.mCustomButtons.button_b_XBOX.empty() ?
|
||||
":/help/button_b_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_b_XBOX;
|
||||
sIconPathMap["x"] = mStyle.mCustomButtons.button_x_XBOX.empty() ?
|
||||
":/help/button_x_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_x_XBOX;
|
||||
sIconPathMap["y"] = mStyle.mCustomButtons.button_y_XBOX.empty() ?
|
||||
":/help/button_y_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_y_XBOX;
|
||||
sIconPathMap["start"] = mStyle.mCustomButtons.button_start_XBOX.empty() ?
|
||||
":/help/button_start_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_start_XBOX;
|
||||
sIconPathMap["back"] = mStyle.mCustomButtons.button_back_XBOX.empty() ?
|
||||
":/help/button_back_XBOX.svg" :
|
||||
mStyle.mCustomButtons.button_back_XBOX;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +171,7 @@ void HelpComponent::setStyle(const HelpStyle& style)
|
|||
{
|
||||
mStyle = style;
|
||||
updateGrid();
|
||||
assignIcons();
|
||||
}
|
||||
|
||||
void HelpComponent::updateGrid()
|
||||
|
|
Loading…
Reference in a new issue