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"
|
|
|
|
|
|
|
|
HelpStyle::HelpStyle()
|
|
|
|
{
|
2021-08-16 16:25:01 +00:00
|
|
|
position =
|
2021-08-17 16:41:45 +00:00
|
|
|
glm::vec2{Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f};
|
|
|
|
origin = glm::vec2{};
|
2020-06-26 15:17:35 +00:00
|
|
|
iconColor = 0x777777FF;
|
|
|
|
textColor = 0x777777FF;
|
|
|
|
|
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)
|
|
|
|
{
|
2020-06-26 15:17:35 +00:00
|
|
|
auto elem = theme->getElement(view, "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") *
|
2021-08-17 16:41:45 +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
|
|
|
|
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
|
|
|
|
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);
|
2014-05-29 20:41:47 +00:00
|
|
|
}
|