2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-26 15:17:35 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-26 15:17:35 +00:00
|
|
|
// HelpStyle.cpp
|
|
|
|
//
|
|
|
|
// Style (default colors, position and origin) for the help system.
|
|
|
|
// Also theme handling.
|
|
|
|
//
|
|
|
|
|
2014-05-29 20:41:47 +00:00
|
|
|
#include "HelpStyle.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2014-05-29 20:41:47 +00:00
|
|
|
#include "resources/Font.h"
|
|
|
|
|
2022-01-29 17:41:22 +00:00
|
|
|
#define PREFIX "button_"
|
|
|
|
|
2014-05-29 20:41:47 +00:00
|
|
|
HelpStyle::HelpStyle()
|
|
|
|
{
|
2021-08-16 16:25:01 +00:00
|
|
|
position =
|
2022-01-16 11:09:55 +00:00
|
|
|
glm::vec2 {Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f};
|
|
|
|
origin = glm::vec2 {};
|
2020-06-26 15:17:35 +00:00
|
|
|
textColor = 0x777777FF;
|
2021-08-22 14:43:15 +00:00
|
|
|
textColorDimmed = 0x777777FF;
|
|
|
|
iconColor = 0x777777FF;
|
|
|
|
iconColorDimmed = 0x777777FF;
|
2021-08-20 15:20:05 +00:00
|
|
|
entrySpacing = 16.0f;
|
|
|
|
iconTextSpacing = 8.0f;
|
2022-02-09 19:44:22 +00:00
|
|
|
letterCase = "uppercase";
|
2020-06-26 15:17:35 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (FONT_SIZE_SMALL != 0)
|
2020-06-26 15:17:35 +00:00
|
|
|
font = Font::get(FONT_SIZE_SMALL);
|
|
|
|
else
|
|
|
|
font = nullptr;
|
2014-05-29 20:41:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view)
|
|
|
|
{
|
2022-01-29 17:41:22 +00:00
|
|
|
auto elem = theme->getElement(view, "helpsystem_help", "helpsystem");
|
2020-07-13 18:58:25 +00:00
|
|
|
if (!elem)
|
2020-06-26 15:17:35 +00:00
|
|
|
return;
|
2014-05-29 20:41:47 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (elem->has("pos"))
|
2021-08-16 16:25:01 +00:00
|
|
|
position = elem->get<glm::vec2>("pos") *
|
2022-01-16 11:09:55 +00:00
|
|
|
glm::vec2 {static_cast<float>(Renderer::getScreenWidth()),
|
|
|
|
static_cast<float>(Renderer::getScreenHeight())};
|
2014-05-29 20:41:47 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (elem->has("origin"))
|
2021-08-16 16:25:01 +00:00
|
|
|
origin = elem->get<glm::vec2>("origin");
|
2018-04-15 18:41:25 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (elem->has("textColor"))
|
2020-06-26 15:17:35 +00:00
|
|
|
textColor = elem->get<unsigned int>("textColor");
|
2014-05-29 20:41:47 +00:00
|
|
|
|
2021-08-22 14:43:15 +00:00
|
|
|
if (elem->has("textColorDimmed"))
|
|
|
|
textColorDimmed = elem->get<unsigned int>("textColorDimmed");
|
2021-09-04 19:47:42 +00:00
|
|
|
else
|
|
|
|
textColorDimmed = textColor;
|
2021-08-22 14:43:15 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (elem->has("iconColor"))
|
2020-06-26 15:17:35 +00:00
|
|
|
iconColor = elem->get<unsigned int>("iconColor");
|
2014-05-29 21:27:18 +00:00
|
|
|
|
2021-08-22 14:43:15 +00:00
|
|
|
if (elem->has("iconColorDimmed"))
|
|
|
|
iconColorDimmed = elem->get<unsigned int>("iconColorDimmed");
|
2021-09-04 19:47:42 +00:00
|
|
|
else
|
|
|
|
iconColorDimmed = iconColor;
|
2021-08-22 14:43:15 +00:00
|
|
|
|
2020-07-13 18:58:25 +00:00
|
|
|
if (elem->has("fontPath") || elem->has("fontSize"))
|
2020-06-26 15:17:35 +00:00
|
|
|
font = Font::getFromTheme(elem, ThemeFlags::ALL, font);
|
2021-08-20 15:20:05 +00:00
|
|
|
|
|
|
|
if (elem->has("entrySpacing"))
|
|
|
|
entrySpacing = elem->get<float>("entrySpacing");
|
|
|
|
|
|
|
|
if (elem->has("iconTextSpacing"))
|
|
|
|
iconTextSpacing = elem->get<float>("iconTextSpacing");
|
2021-08-20 15:51:36 +00:00
|
|
|
|
2022-02-09 19:44:22 +00:00
|
|
|
if (elem->has("letterCase"))
|
|
|
|
letterCase = elem->get<std::string>("letterCase");
|
2021-08-22 15:51:19 +00:00
|
|
|
|
|
|
|
// Load custom button icons.
|
2022-01-29 17:41:22 +00:00
|
|
|
// The names may look a bit strange when combined with the PREFIX string "button_" but it's
|
|
|
|
// because ThemeData adds this prefix to avoid name collisions when using XML attributes.
|
2021-08-22 15:51:19 +00:00
|
|
|
|
|
|
|
// General.
|
2022-01-29 17:41:22 +00:00
|
|
|
if (elem->has(PREFIX "dpad_updown"))
|
|
|
|
mCustomButtons.dpad_updown = elem->get<std::string>(PREFIX "dpad_updown");
|
|
|
|
if (elem->has(PREFIX "dpad_leftright"))
|
|
|
|
mCustomButtons.dpad_leftright = elem->get<std::string>(PREFIX "dpad_leftright");
|
|
|
|
if (elem->has(PREFIX "dpad_all"))
|
|
|
|
mCustomButtons.dpad_all = elem->get<std::string>(PREFIX "dpad_all");
|
|
|
|
if (elem->has(PREFIX "thumbstick_click"))
|
|
|
|
mCustomButtons.thumbstick_click = elem->get<std::string>(PREFIX "thumbstick_click");
|
|
|
|
if (elem->has(PREFIX "button_l"))
|
|
|
|
mCustomButtons.button_l = elem->get<std::string>(PREFIX "button_l");
|
|
|
|
if (elem->has(PREFIX "button_r"))
|
|
|
|
mCustomButtons.button_r = elem->get<std::string>(PREFIX "button_r");
|
|
|
|
if (elem->has(PREFIX "button_lr"))
|
|
|
|
mCustomButtons.button_lr = elem->get<std::string>(PREFIX "button_lr");
|
|
|
|
if (elem->has(PREFIX "button_lt"))
|
|
|
|
mCustomButtons.button_lt = elem->get<std::string>(PREFIX "button_lt");
|
|
|
|
if (elem->has(PREFIX "button_rt"))
|
|
|
|
mCustomButtons.button_rt = elem->get<std::string>(PREFIX "button_rt");
|
2021-08-22 15:51:19 +00:00
|
|
|
|
|
|
|
// SNES.
|
2022-01-29 17:41:22 +00:00
|
|
|
if (elem->has(PREFIX "button_a_SNES"))
|
|
|
|
mCustomButtons.button_a_SNES = elem->get<std::string>(PREFIX "button_a_SNES");
|
|
|
|
if (elem->has(PREFIX "button_b_SNES"))
|
|
|
|
mCustomButtons.button_b_SNES = elem->get<std::string>(PREFIX "button_b_SNES");
|
|
|
|
if (elem->has(PREFIX "button_x_SNES"))
|
|
|
|
mCustomButtons.button_x_SNES = elem->get<std::string>(PREFIX "button_x_SNES");
|
|
|
|
if (elem->has(PREFIX "button_y_SNES"))
|
|
|
|
mCustomButtons.button_y_SNES = elem->get<std::string>(PREFIX "button_y_SNES");
|
|
|
|
if (elem->has(PREFIX "button_start_SNES"))
|
|
|
|
mCustomButtons.button_start_SNES = elem->get<std::string>(PREFIX "button_start_SNES");
|
|
|
|
if (elem->has(PREFIX "button_back_SNES"))
|
|
|
|
mCustomButtons.button_back_SNES = elem->get<std::string>(PREFIX "button_back_SNES");
|
|
|
|
|
|
|
|
// PlayStation.
|
|
|
|
if (elem->has(PREFIX "button_a_PS"))
|
|
|
|
mCustomButtons.button_a_PS = elem->get<std::string>(PREFIX "button_a_PS");
|
|
|
|
if (elem->has(PREFIX "button_b_PS"))
|
|
|
|
mCustomButtons.button_b_PS = elem->get<std::string>(PREFIX "button_b_PS");
|
|
|
|
if (elem->has(PREFIX "button_x_PS"))
|
|
|
|
mCustomButtons.button_x_PS = elem->get<std::string>(PREFIX "button_x_PS");
|
|
|
|
if (elem->has(PREFIX "button_y_PS"))
|
|
|
|
mCustomButtons.button_y_PS = elem->get<std::string>(PREFIX "button_y_PS");
|
|
|
|
if (elem->has(PREFIX "button_start_PS4"))
|
|
|
|
mCustomButtons.button_start_PS4 = elem->get<std::string>(PREFIX "button_start_PS4");
|
|
|
|
if (elem->has(PREFIX "button_back_PS4"))
|
|
|
|
mCustomButtons.button_back_PS4 = elem->get<std::string>(PREFIX "button_back_PS4");
|
|
|
|
if (elem->has(PREFIX "button_start_PS5"))
|
|
|
|
mCustomButtons.button_start_PS5 = elem->get<std::string>(PREFIX "button_start_PS5");
|
|
|
|
if (elem->has(PREFIX "button_back_PS5"))
|
|
|
|
mCustomButtons.button_back_PS5 = elem->get<std::string>(PREFIX "button_back_PS5");
|
2021-08-22 15:51:19 +00:00
|
|
|
|
|
|
|
// XBOX.
|
2022-01-29 17:41:22 +00:00
|
|
|
if (elem->has(PREFIX "button_a_XBOX"))
|
|
|
|
mCustomButtons.button_a_XBOX = elem->get<std::string>(PREFIX "button_a_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_b_XBOX"))
|
|
|
|
mCustomButtons.button_b_XBOX = elem->get<std::string>(PREFIX "button_b_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_x_XBOX"))
|
|
|
|
mCustomButtons.button_x_XBOX = elem->get<std::string>(PREFIX "button_x_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_y_XBOX"))
|
|
|
|
mCustomButtons.button_y_XBOX = elem->get<std::string>(PREFIX "button_y_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_start_XBOX"))
|
|
|
|
mCustomButtons.button_start_XBOX = elem->get<std::string>(PREFIX "button_start_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_back_XBOX"))
|
|
|
|
mCustomButtons.button_back_XBOX = elem->get<std::string>(PREFIX "button_back_XBOX");
|
|
|
|
if (elem->has(PREFIX "button_start_XBOX360"))
|
|
|
|
mCustomButtons.button_start_XBOX360 = elem->get<std::string>(PREFIX "button_start_XBOX360");
|
|
|
|
if (elem->has(PREFIX "button_back_XBOX360"))
|
|
|
|
mCustomButtons.button_back_XBOX360 = elem->get<std::string>(PREFIX "button_back_XBOX360");
|
2014-05-29 20:41:47 +00:00
|
|
|
}
|