ES-DE/es-core/src/HelpStyle.cpp

50 lines
1.4 KiB
C++
Raw Normal View History

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// 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()
{
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)
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)
{
auto elem = theme->getElement(view, "help", "helpsystem");
2020-07-13 18:58:25 +00:00
if (!elem)
return;
2014-05-29 20:41:47 +00:00
2020-07-13 18:58:25 +00:00
if (elem->has("pos"))
position =
elem->get<Vector2f>("pos") * 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"))
origin = elem->get<Vector2f>("origin");
2020-07-13 18:58:25 +00:00
if (elem->has("textColor"))
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"))
iconColor = elem->get<unsigned int>("iconColor");
2020-07-13 18:58:25 +00:00
if (elem->has("fontPath") || elem->has("fontSize"))
font = Font::getFromTheme(elem, ThemeFlags::ALL, font);
2014-05-29 20:41:47 +00:00
}