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()
|
|
|
|
{
|
2020-06-26 15:17:35 +00:00
|
|
|
position = Vector2f(Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f);
|
|
|
|
origin = Vector2f(0.0f, 0.0f);
|
|
|
|
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"))
|
2020-06-26 15:17:35 +00:00
|
|
|
position = elem->get<Vector2f>("pos") *
|
2020-11-17 22:06:54 +00:00
|
|
|
Vector2f(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"))
|
2020-06-26 15:17:35 +00:00
|
|
|
origin = elem->get<Vector2f>("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
|
|
|
}
|