Add "origin" theming element for help prompt

This commit is contained in:
Koerty 2018-04-15 20:41:25 +02:00
parent b622a4272e
commit 1b4a545c90
5 changed files with 9 additions and 0 deletions

View file

@ -729,6 +729,8 @@ EmulationStation borrows the concept of "nine patches" from Android (or "9-Slice
#### helpsystem #### helpsystem
* `pos` - type: NORMALIZED_PAIR. Default is "0.012 0.9515" * `pos` - type: NORMALIZED_PAIR. Default is "0.012 0.9515"
* `origin` - type: NORMALIZED_PAIR.
- Where on the component `pos` refers to. For example, an origin of `0.5 0.5` and a `pos` of `0.5 0.5` would place the component exactly in the middle of the screen.
* `textColor` - type: COLOR. Default is 777777FF. * `textColor` - type: COLOR. Default is 777777FF.
* `iconColor` - type: COLOR. Default is 777777FF. * `iconColor` - type: COLOR. Default is 777777FF.
* `fontPath` - type: PATH. * `fontPath` - type: PATH.

View file

@ -6,6 +6,7 @@
HelpStyle::HelpStyle() HelpStyle::HelpStyle()
{ {
position = Vector2f(Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f); position = Vector2f(Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f);
origin = Vector2f(0.0f, 0.0f);
iconColor = 0x777777FF; iconColor = 0x777777FF;
textColor = 0x777777FF; textColor = 0x777777FF;
@ -24,6 +25,9 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
if(elem->has("pos")) if(elem->has("pos"))
position = elem->get<Vector2f>("pos") * Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); position = elem->get<Vector2f>("pos") * Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
if(elem->has("origin"))
origin = elem->get<Vector2f>("origin");
if(elem->has("textColor")) if(elem->has("textColor"))
textColor = elem->get<unsigned int>("textColor"); textColor = elem->get<unsigned int>("textColor");

View file

@ -12,6 +12,7 @@ class ThemeData;
struct HelpStyle struct HelpStyle
{ {
Vector2f position; Vector2f position;
Vector2f origin;
unsigned int iconColor; unsigned int iconColor;
unsigned int textColor; unsigned int textColor;
std::shared_ptr<Font> font; std::shared_ptr<Font> font;

View file

@ -104,6 +104,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "path", PATH } } }, { "path", PATH } } },
{ "helpsystem", { { "helpsystem", {
{ "pos", NORMALIZED_PAIR }, { "pos", NORMALIZED_PAIR },
{ "origin", NORMALIZED_PAIR },
{ "textColor", COLOR }, { "textColor", COLOR },
{ "iconColor", COLOR }, { "iconColor", COLOR },
{ "fontPath", PATH }, { "fontPath", PATH },

View file

@ -97,6 +97,7 @@ void HelpComponent::updateGrid()
mGrid->setPosition(Vector3f(mStyle.position.x(), mStyle.position.y(), 0.0f)); mGrid->setPosition(Vector3f(mStyle.position.x(), mStyle.position.y(), 0.0f));
//mGrid->setPosition(OFFSET_X, Renderer::getScreenHeight() - mGrid->getSize().y() - OFFSET_Y); //mGrid->setPosition(OFFSET_X, Renderer::getScreenHeight() - mGrid->getSize().y() - OFFSET_Y);
mGrid->setOrigin(mStyle.origin);
} }
std::shared_ptr<TextureResource> HelpComponent::getIconTexture(const char* name) std::shared_ptr<TextureResource> HelpComponent::getIconTexture(const char* name)