mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Simplified a number of HelpComponent function and variable names
This commit is contained in:
parent
26472bccbc
commit
bdcdbeca86
|
@ -71,9 +71,9 @@ bool MediaViewer::startMediaViewer(FileData* game)
|
||||||
Window::getInstance()->stopInfoPopup();
|
Window::getInstance()->stopInfoPopup();
|
||||||
|
|
||||||
mHelp = std::make_unique<HelpComponent>(Font::get(FONT_SIZE_MINI));
|
mHelp = std::make_unique<HelpComponent>(Font::get(FONT_SIZE_MINI));
|
||||||
mHelp->setStyleOrigin(glm::vec2 {0.5, 0.5f});
|
mHelp->setHelpOrigin(glm::vec2 {0.5, 0.5f});
|
||||||
mHelp->setStyleTextColor(0xAAAAAAFF);
|
mHelp->setHelpTextColor(0xAAAAAAFF);
|
||||||
mHelp->setStyleIconColor(0xAAAAAAFF);
|
mHelp->setHelpIconColor(0xAAAAAAFF);
|
||||||
|
|
||||||
mEntryCount = std::to_string(mImages.size() + (mVideo == nullptr ? 0 : 1));
|
mEntryCount = std::to_string(mImages.size() + (mVideo == nullptr ? 0 : 1));
|
||||||
|
|
||||||
|
@ -84,14 +84,13 @@ bool MediaViewer::startMediaViewer(FileData* game)
|
||||||
|
|
||||||
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
||||||
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
||||||
mHelp->setStylePosition(
|
mHelp->setHelpPosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f});
|
||||||
glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f});
|
|
||||||
}
|
}
|
||||||
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
||||||
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
mMediaType->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
||||||
mHelp->setStylePosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
mHelp->setHelpPosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)});
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)});
|
||||||
}
|
}
|
||||||
|
|
||||||
mHelp->setPrompts(getHelpPrompts());
|
mHelp->setPrompts(getHelpPrompts());
|
||||||
|
|
|
@ -177,9 +177,9 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
||||||
mFrameHeight = Font::get(FONT_SIZE_MINI)->getLetterHeight() * 1.9f;
|
mFrameHeight = Font::get(FONT_SIZE_MINI)->getLetterHeight() * 1.9f;
|
||||||
|
|
||||||
mHelp = std::make_unique<HelpComponent>(Font::get(FONT_SIZE_MINI));
|
mHelp = std::make_unique<HelpComponent>(Font::get(FONT_SIZE_MINI));
|
||||||
mHelp->setStyleOrigin(glm::vec2 {0.5, 0.5f});
|
mHelp->setHelpOrigin(glm::vec2 {0.5, 0.5f});
|
||||||
mHelp->setStyleTextColor(0xAAAAAAFF);
|
mHelp->setHelpTextColor(0xAAAAAAFF);
|
||||||
mHelp->setStyleIconColor(0xAAAAAAFF);
|
mHelp->setHelpIconColor(0xAAAAAAFF);
|
||||||
|
|
||||||
mEntryCount = std::to_string(mPages.size());
|
mEntryCount = std::to_string(mPages.size());
|
||||||
|
|
||||||
|
@ -190,14 +190,13 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
||||||
|
|
||||||
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
if (mHelpInfoPosition == HelpInfoPosition::TOP) {
|
||||||
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f, mFrameHeight / 2.0f);
|
||||||
mHelp->setStylePosition(
|
mHelp->setHelpPosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f});
|
||||||
glm::vec2 {mRenderer->getScreenWidth() / 2.0f, mFrameHeight / 2.0f});
|
|
||||||
}
|
}
|
||||||
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
else if (mHelpInfoPosition == HelpInfoPosition::BOTTOM) {
|
||||||
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
mEntryNumText->setPosition(mRenderer->getScreenWidth() * 0.01f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f));
|
||||||
mHelp->setStylePosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
mHelp->setHelpPosition(glm::vec2 {mRenderer->getScreenWidth() / 2.0f,
|
||||||
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)});
|
mRenderer->getScreenHeight() - (mFrameHeight / 2.0f)});
|
||||||
}
|
}
|
||||||
|
|
||||||
mHelp->setPrompts(getHelpPrompts());
|
mHelp->setPrompts(getHelpPrompts());
|
||||||
|
|
|
@ -18,37 +18,37 @@
|
||||||
|
|
||||||
HelpComponent::HelpComponent(std::shared_ptr<Font> font)
|
HelpComponent::HelpComponent(std::shared_ptr<Font> font)
|
||||||
: mRenderer {Renderer::getInstance()}
|
: mRenderer {Renderer::getInstance()}
|
||||||
, mStyleFont {font}
|
, mFont {font}
|
||||||
, mStyleFontDimmed {font}
|
, mFontDimmed {font}
|
||||||
, mStylePosition {glm::vec2 {Renderer::getScreenWidth() * 0.012f,
|
, mHelpPosition {glm::vec2 {Renderer::getScreenWidth() * 0.012f,
|
||||||
Renderer::getScreenHeight() *
|
Renderer::getScreenHeight() *
|
||||||
(Renderer::getIsVerticalOrientation() ? 0.975f : 0.9515f)}}
|
(Renderer::getIsVerticalOrientation() ? 0.975f : 0.9515f)}}
|
||||||
, mStylePositionDimmed {mStylePosition}
|
, mHelpPositionDimmed {mHelpPosition}
|
||||||
, mStyleOrigin {glm::vec2 {0.0f, 0.0f}}
|
, mHelpOrigin {glm::vec2 {0.0f, 0.0f}}
|
||||||
, mStyleOriginDimmed {mStyleOrigin}
|
, mHelpOriginDimmed {mHelpOrigin}
|
||||||
, mStyleRotationOrigin {0.5f, 0.5f}
|
, mHelpRotationOrigin {0.5f, 0.5f}
|
||||||
, mStyleTextColor {0x777777FF}
|
, mTextColor {0x777777FF}
|
||||||
, mStyleTextColorDimmed {0x777777FF}
|
, mTextColorDimmed {0x777777FF}
|
||||||
, mStyleIconColor {0x777777FF}
|
, mIconColor {0x777777FF}
|
||||||
, mStyleIconColorDimmed {0x777777FF}
|
, mIconColorDimmed {0x777777FF}
|
||||||
, mStyleBackgroundColor {0x00000000}
|
, mBackgroundColor {0x00000000}
|
||||||
, mStyleBackgroundColorEnd {0x00000000}
|
, mBackgroundColorEnd {0x00000000}
|
||||||
, mStyleBackgroundHorizontalPadding {0.0f, 0.0f}
|
, mBackgroundHorizontalPadding {0.0f, 0.0f}
|
||||||
, mStyleBackgroundVerticalPadding {0.0f, 0.0f}
|
, mBackgroundVerticalPadding {0.0f, 0.0f}
|
||||||
, mStyleBackgroundCornerRadius {0.0f}
|
, mBackgroundCornerRadius {0.0f}
|
||||||
, mStyleColorGradientHorizontal {true}
|
, mColorGradientHorizontal {true}
|
||||||
, mStyleEntryLayout {EntryLayout::ICON_FIRST}
|
, mEntryLayout {EntryLayout::ICON_FIRST}
|
||||||
, mEntryRelativeScale {1.0f}
|
, mEntryRelativeScale {1.0f}
|
||||||
, mLetterHeight {mStyleFont->getLetterHeight() * 1.25f}
|
, mLetterHeight {mFont->getLetterHeight() * 1.25f}
|
||||||
, mLetterHeightDimmed {mLetterHeight}
|
, mLetterHeightDimmed {mLetterHeight}
|
||||||
, mStyleRotation {0.0f}
|
, mHelpRotation {0.0f}
|
||||||
, mStyleEntrySpacing {0.00833f}
|
, mEntrySpacing {0.00833f}
|
||||||
, mStyleEntrySpacingDimmed {mStyleEntrySpacing}
|
, mEntrySpacingDimmed {mEntrySpacing}
|
||||||
, mStyleIconTextSpacing {0.00416f}
|
, mIconTextSpacing {0.00416f}
|
||||||
, mStyleIconTextSpacingDimmed {mStyleIconTextSpacing}
|
, mIconTextSpacingDimmed {mIconTextSpacing}
|
||||||
, mStyleOpacity {1.0f}
|
, mHelpOpacity {1.0f}
|
||||||
, mStyleOpacityDimmed {mStyleOpacity}
|
, mHelpOpacityDimmed {mHelpOpacity}
|
||||||
, mStyleLetterCase {"uppercase"}
|
, mLetterCase {"uppercase"}
|
||||||
{
|
{
|
||||||
assignIcons();
|
assignIcons();
|
||||||
updateGrid();
|
updateGrid();
|
||||||
|
@ -73,11 +73,11 @@ void HelpComponent::setOpacity(float opacity)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GuiComponent::setOpacity(opacity *
|
GuiComponent::setOpacity(opacity *
|
||||||
(mWindow->isBackgroundDimmed() ? mStyleOpacityDimmed : mStyleOpacity));
|
(mWindow->isBackgroundDimmed() ? mHelpOpacityDimmed : mHelpOpacity));
|
||||||
|
|
||||||
for (unsigned int i {0}; i < mGrid->getChildCount(); ++i)
|
for (unsigned int i {0}; i < mGrid->getChildCount(); ++i)
|
||||||
mGrid->getChild(i)->setOpacity(
|
mGrid->getChild(i)->setOpacity(
|
||||||
opacity * (mWindow->isBackgroundDimmed() ? mStyleOpacityDimmed : mStyleOpacity));
|
opacity * (mWindow->isBackgroundDimmed() ? mHelpOpacityDimmed : mHelpOpacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
@ -91,64 +91,64 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (elem->has("pos"))
|
if (elem->has("pos"))
|
||||||
mStylePosition = elem->get<glm::vec2>("pos") *
|
mHelpPosition = elem->get<glm::vec2>("pos") *
|
||||||
glm::vec2 {Renderer::getScreenWidth(), Renderer::getScreenHeight()};
|
glm::vec2 {Renderer::getScreenWidth(), Renderer::getScreenHeight()};
|
||||||
|
|
||||||
if (elem->has("posDimmed"))
|
if (elem->has("posDimmed"))
|
||||||
mStylePositionDimmed = elem->get<glm::vec2>("posDimmed") *
|
mHelpPositionDimmed = elem->get<glm::vec2>("posDimmed") *
|
||||||
glm::vec2 {Renderer::getScreenWidth(), Renderer::getScreenHeight()};
|
glm::vec2 {Renderer::getScreenWidth(), Renderer::getScreenHeight()};
|
||||||
else
|
else
|
||||||
mStylePositionDimmed = mStylePosition;
|
mHelpPositionDimmed = mHelpPosition;
|
||||||
|
|
||||||
if (elem->has("origin"))
|
if (elem->has("origin"))
|
||||||
mStyleOrigin = elem->get<glm::vec2>("origin");
|
mHelpOrigin = elem->get<glm::vec2>("origin");
|
||||||
|
|
||||||
if (elem->has("originDimmed"))
|
if (elem->has("originDimmed"))
|
||||||
mStyleOriginDimmed = elem->get<glm::vec2>("originDimmed");
|
mHelpOriginDimmed = elem->get<glm::vec2>("originDimmed");
|
||||||
else
|
else
|
||||||
mStyleOriginDimmed = mStyleOrigin;
|
mHelpOriginDimmed = mHelpOrigin;
|
||||||
|
|
||||||
if (elem->has("rotation"))
|
if (elem->has("rotation"))
|
||||||
mStyleRotation = static_cast<float>(glm::radians(elem->get<float>("rotation")));
|
mHelpRotation = static_cast<float>(glm::radians(elem->get<float>("rotation")));
|
||||||
|
|
||||||
if (elem->has("rotationOrigin"))
|
if (elem->has("rotationOrigin"))
|
||||||
mStyleRotationOrigin = glm::clamp(elem->get<glm::vec2>("rotationOrigin"), 0.0f, 1.0f);
|
mHelpRotationOrigin = glm::clamp(elem->get<glm::vec2>("rotationOrigin"), 0.0f, 1.0f);
|
||||||
|
|
||||||
if (elem->has("textColor"))
|
if (elem->has("textColor"))
|
||||||
mStyleTextColor = elem->get<unsigned int>("textColor");
|
mTextColor = elem->get<unsigned int>("textColor");
|
||||||
|
|
||||||
if (elem->has("textColorDimmed"))
|
if (elem->has("textColorDimmed"))
|
||||||
mStyleTextColorDimmed = elem->get<unsigned int>("textColorDimmed");
|
mTextColorDimmed = elem->get<unsigned int>("textColorDimmed");
|
||||||
else
|
else
|
||||||
mStyleTextColorDimmed = mStyleTextColor;
|
mTextColorDimmed = mTextColor;
|
||||||
|
|
||||||
if (elem->has("iconColor"))
|
if (elem->has("iconColor"))
|
||||||
mStyleIconColor = elem->get<unsigned int>("iconColor");
|
mIconColor = elem->get<unsigned int>("iconColor");
|
||||||
|
|
||||||
if (elem->has("iconColorDimmed"))
|
if (elem->has("iconColorDimmed"))
|
||||||
mStyleIconColorDimmed = elem->get<unsigned int>("iconColorDimmed");
|
mIconColorDimmed = elem->get<unsigned int>("iconColorDimmed");
|
||||||
else
|
else
|
||||||
mStyleIconColorDimmed = mStyleIconColor;
|
mIconColorDimmed = mIconColor;
|
||||||
|
|
||||||
if (elem->has("backgroundColor")) {
|
if (elem->has("backgroundColor")) {
|
||||||
mStyleBackgroundColor = elem->get<unsigned int>("backgroundColor");
|
mBackgroundColor = elem->get<unsigned int>("backgroundColor");
|
||||||
|
|
||||||
if (elem->has("backgroundColorEnd"))
|
if (elem->has("backgroundColorEnd"))
|
||||||
mStyleBackgroundColorEnd = elem->get<unsigned int>("backgroundColorEnd");
|
mBackgroundColorEnd = elem->get<unsigned int>("backgroundColorEnd");
|
||||||
else
|
else
|
||||||
mStyleBackgroundColorEnd = mStyleBackgroundColor;
|
mBackgroundColorEnd = mBackgroundColor;
|
||||||
|
|
||||||
if (elem->has("backgroundGradientType")) {
|
if (elem->has("backgroundGradientType")) {
|
||||||
const std::string& backgroundGradientType {
|
const std::string& backgroundGradientType {
|
||||||
elem->get<std::string>("backgroundGradientType")};
|
elem->get<std::string>("backgroundGradientType")};
|
||||||
if (backgroundGradientType == "horizontal") {
|
if (backgroundGradientType == "horizontal") {
|
||||||
mStyleColorGradientHorizontal = true;
|
mColorGradientHorizontal = true;
|
||||||
}
|
}
|
||||||
else if (backgroundGradientType == "vertical") {
|
else if (backgroundGradientType == "vertical") {
|
||||||
mStyleColorGradientHorizontal = false;
|
mColorGradientHorizontal = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mStyleColorGradientHorizontal = true;
|
mColorGradientHorizontal = true;
|
||||||
LOG(LogWarning) << "HelpComponent: Invalid theme configuration, property "
|
LOG(LogWarning) << "HelpComponent: Invalid theme configuration, property "
|
||||||
"\"backgroundGradientType\" for element \""
|
"\"backgroundGradientType\" for element \""
|
||||||
<< element.substr(11) << "\" defined as \""
|
<< element.substr(11) << "\" defined as \""
|
||||||
|
@ -160,23 +160,21 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("backgroundHorizontalPadding")) {
|
if (elem->has("backgroundHorizontalPadding")) {
|
||||||
const glm::vec2 backgroundHorizontalPadding {
|
const glm::vec2 backgroundHorizontalPadding {
|
||||||
glm::clamp(elem->get<glm::vec2>("backgroundHorizontalPadding"), 0.0f, 0.2f)};
|
glm::clamp(elem->get<glm::vec2>("backgroundHorizontalPadding"), 0.0f, 0.2f)};
|
||||||
mStyleBackgroundHorizontalPadding.x =
|
mBackgroundHorizontalPadding.x =
|
||||||
backgroundHorizontalPadding.x * mRenderer->getScreenWidth();
|
backgroundHorizontalPadding.x * mRenderer->getScreenWidth();
|
||||||
mStyleBackgroundHorizontalPadding.y =
|
mBackgroundHorizontalPadding.y =
|
||||||
backgroundHorizontalPadding.y * mRenderer->getScreenWidth();
|
backgroundHorizontalPadding.y * mRenderer->getScreenWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("backgroundVerticalPadding")) {
|
if (elem->has("backgroundVerticalPadding")) {
|
||||||
const glm::vec2 backgroundVerticalPadding {
|
const glm::vec2 backgroundVerticalPadding {
|
||||||
glm::clamp(elem->get<glm::vec2>("backgroundVerticalPadding"), 0.0f, 0.2f)};
|
glm::clamp(elem->get<glm::vec2>("backgroundVerticalPadding"), 0.0f, 0.2f)};
|
||||||
mStyleBackgroundVerticalPadding.x =
|
mBackgroundVerticalPadding.x = backgroundVerticalPadding.x * mRenderer->getScreenHeight();
|
||||||
backgroundVerticalPadding.x * mRenderer->getScreenHeight();
|
mBackgroundVerticalPadding.y = backgroundVerticalPadding.y * mRenderer->getScreenHeight();
|
||||||
mStyleBackgroundVerticalPadding.y =
|
|
||||||
backgroundVerticalPadding.y * mRenderer->getScreenHeight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("backgroundCornerRadius")) {
|
if (elem->has("backgroundCornerRadius")) {
|
||||||
mStyleBackgroundCornerRadius =
|
mBackgroundCornerRadius =
|
||||||
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
glm::clamp(elem->get<float>("backgroundCornerRadius"), 0.0f, 0.5f) *
|
||||||
mRenderer->getScreenWidth();
|
mRenderer->getScreenWidth();
|
||||||
}
|
}
|
||||||
|
@ -185,33 +183,32 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
mEntryRelativeScale = glm::clamp(elem->get<float>("entryRelativeScale"), 0.2f, 3.0f);
|
mEntryRelativeScale = glm::clamp(elem->get<float>("entryRelativeScale"), 0.2f, 3.0f);
|
||||||
|
|
||||||
if (elem->has("fontPath") || elem->has("fontSize")) {
|
if (elem->has("fontPath") || elem->has("fontSize")) {
|
||||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f, 1.0f, false, true);
|
mFont = Font::getFromTheme(elem, ThemeFlags::ALL, mFont, 0.0f, 1.0f, false, true);
|
||||||
mLetterHeight = mStyleFont->getLetterHeight() * 1.25f;
|
mLetterHeight = mFont->getLetterHeight() * 1.25f;
|
||||||
if (!elem->has("fontSizeDimmed")) {
|
if (!elem->has("fontSizeDimmed")) {
|
||||||
mStyleFontDimmed = Font::getFromTheme(
|
mFontDimmed = Font::getFromTheme(
|
||||||
elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
elem, ThemeFlags::ALL, mFont, 0.0f,
|
||||||
(mEntryRelativeScale < 1.0f ? mEntryRelativeScale : 1.0f), true, true);
|
(mEntryRelativeScale < 1.0f ? mEntryRelativeScale : 1.0f), true, true);
|
||||||
mLetterHeightDimmed = mLetterHeight;
|
mLetterHeightDimmed = mLetterHeight;
|
||||||
}
|
}
|
||||||
if (mEntryRelativeScale < 1.0f)
|
if (mEntryRelativeScale < 1.0f)
|
||||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
mFont = Font::getFromTheme(elem, ThemeFlags::ALL, mFont, 0.0f, mEntryRelativeScale,
|
||||||
mEntryRelativeScale, false, true);
|
false, true);
|
||||||
}
|
}
|
||||||
else if (mEntryRelativeScale < 1.0f) {
|
else if (mEntryRelativeScale < 1.0f) {
|
||||||
mStyleFont = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
mFont = Font::getFromTheme(elem, ThemeFlags::ALL, mFont, 0.0f, mEntryRelativeScale, false,
|
||||||
mEntryRelativeScale, false, true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("fontSizeDimmed")) {
|
if (elem->has("fontSizeDimmed")) {
|
||||||
mStyleFontDimmed =
|
mFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mFont, 0.0f, 1.0f, true, true);
|
||||||
Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f, 1.0f, true, true);
|
mLetterHeightDimmed = mFontDimmed->getLetterHeight() * 1.25f;
|
||||||
mLetterHeightDimmed = mStyleFontDimmed->getLetterHeight() * 1.25f;
|
|
||||||
if (mEntryRelativeScale < 1.0f)
|
if (mEntryRelativeScale < 1.0f)
|
||||||
mStyleFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mStyleFont, 0.0f,
|
mFontDimmed = Font::getFromTheme(elem, ThemeFlags::ALL, mFont, 0.0f,
|
||||||
mEntryRelativeScale, true, true);
|
mEntryRelativeScale, true, true);
|
||||||
}
|
}
|
||||||
else if (mEntryRelativeScale < 1.0f && !elem->has("fontPath") && !elem->has("fontSize")) {
|
else if (mEntryRelativeScale < 1.0f && !elem->has("fontPath") && !elem->has("fontSize")) {
|
||||||
mStyleFontDimmed = mStyleFont;
|
mFontDimmed = mFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("scope")) {
|
if (elem->has("scope")) {
|
||||||
|
@ -257,10 +254,10 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("entryLayout")) {
|
if (elem->has("entryLayout")) {
|
||||||
const std::string& entryLayout {elem->get<std::string>("entryLayout")};
|
const std::string& entryLayout {elem->get<std::string>("entryLayout")};
|
||||||
if (entryLayout == "iconFirst") {
|
if (entryLayout == "iconFirst") {
|
||||||
mStyleEntryLayout = EntryLayout::ICON_FIRST;
|
mEntryLayout = EntryLayout::ICON_FIRST;
|
||||||
}
|
}
|
||||||
else if (entryLayout == "textFirst") {
|
else if (entryLayout == "textFirst") {
|
||||||
mStyleEntryLayout = EntryLayout::TEXT_FIRST;
|
mEntryLayout = EntryLayout::TEXT_FIRST;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogWarning) << "HelpComponent: Invalid theme configuration, property "
|
LOG(LogWarning) << "HelpComponent: Invalid theme configuration, property "
|
||||||
|
@ -270,32 +267,31 @@ void HelpComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("entrySpacing"))
|
if (elem->has("entrySpacing"))
|
||||||
mStyleEntrySpacing = glm::clamp(elem->get<float>("entrySpacing"), 0.0f, 0.04f);
|
mEntrySpacing = glm::clamp(elem->get<float>("entrySpacing"), 0.0f, 0.04f);
|
||||||
|
|
||||||
if (elem->has("entrySpacingDimmed"))
|
if (elem->has("entrySpacingDimmed"))
|
||||||
mStyleEntrySpacingDimmed = glm::clamp(elem->get<float>("entrySpacingDimmed"), 0.0f, 0.04f);
|
mEntrySpacingDimmed = glm::clamp(elem->get<float>("entrySpacingDimmed"), 0.0f, 0.04f);
|
||||||
else
|
else
|
||||||
mStyleEntrySpacingDimmed = mStyleEntrySpacing;
|
mEntrySpacingDimmed = mEntrySpacing;
|
||||||
|
|
||||||
if (elem->has("iconTextSpacing"))
|
if (elem->has("iconTextSpacing"))
|
||||||
mStyleIconTextSpacing = glm::clamp(elem->get<float>("iconTextSpacing"), 0.0f, 0.04f);
|
mIconTextSpacing = glm::clamp(elem->get<float>("iconTextSpacing"), 0.0f, 0.04f);
|
||||||
|
|
||||||
if (elem->has("iconTextSpacingDimmed"))
|
if (elem->has("iconTextSpacingDimmed"))
|
||||||
mStyleIconTextSpacingDimmed =
|
mIconTextSpacingDimmed = glm::clamp(elem->get<float>("iconTextSpacingDimmed"), 0.0f, 0.04f);
|
||||||
glm::clamp(elem->get<float>("iconTextSpacingDimmed"), 0.0f, 0.04f);
|
|
||||||
else
|
else
|
||||||
mStyleIconTextSpacingDimmed = mStyleIconTextSpacing;
|
mIconTextSpacingDimmed = mIconTextSpacing;
|
||||||
|
|
||||||
if (elem->has("letterCase"))
|
if (elem->has("letterCase"))
|
||||||
mStyleLetterCase = elem->get<std::string>("letterCase");
|
mLetterCase = elem->get<std::string>("letterCase");
|
||||||
|
|
||||||
if (elem->has("opacity"))
|
if (elem->has("opacity"))
|
||||||
mStyleOpacity = glm::clamp(elem->get<float>("opacity"), 0.2f, 1.0f);
|
mHelpOpacity = glm::clamp(elem->get<float>("opacity"), 0.2f, 1.0f);
|
||||||
|
|
||||||
if (elem->has("opacityDimmed"))
|
if (elem->has("opacityDimmed"))
|
||||||
mStyleOpacityDimmed = glm::clamp(elem->get<float>("opacityDimmed"), 0.2f, 1.0f);
|
mHelpOpacityDimmed = glm::clamp(elem->get<float>("opacityDimmed"), 0.2f, 1.0f);
|
||||||
else
|
else
|
||||||
mStyleOpacityDimmed = mStyleOpacity;
|
mHelpOpacityDimmed = mHelpOpacity;
|
||||||
|
|
||||||
// Load custom button icons.
|
// Load custom button icons.
|
||||||
// The names may look a bit strange when combined with the PREFIX string "button_" but it's
|
// The names may look a bit strange when combined with the PREFIX string "button_" but it's
|
||||||
|
@ -399,26 +395,26 @@ void HelpComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!mVisible)
|
if (!mVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mStyleBackgroundColor != 0x00000000) {
|
if (mBackgroundColor != 0x00000000) {
|
||||||
mPosition = mGrid->getPosition();
|
mPosition = mGrid->getPosition();
|
||||||
mSize = mGrid->getSize();
|
mSize = mGrid->getSize();
|
||||||
mOrigin = mGrid->getOrigin();
|
mOrigin = mGrid->getOrigin();
|
||||||
mRotation = mStyleRotation;
|
mRotation = mHelpRotation;
|
||||||
mRotationOrigin = mStyleRotationOrigin;
|
mRotationOrigin = mHelpRotationOrigin;
|
||||||
|
|
||||||
glm::mat4 trans {parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
trans = glm::translate(trans, glm::vec3 {-mStyleBackgroundHorizontalPadding.x,
|
trans = glm::translate(trans, glm::vec3 {-mBackgroundHorizontalPadding.x,
|
||||||
-mStyleBackgroundVerticalPadding.x, 0.0f});
|
-mBackgroundVerticalPadding.x, 0.0f});
|
||||||
mRenderer->setMatrix(trans);
|
mRenderer->setMatrix(trans);
|
||||||
|
|
||||||
mRenderer->drawRect(
|
mRenderer->drawRect(0.0f, 0.0f,
|
||||||
0.0f, 0.0f,
|
mSize.x + mBackgroundHorizontalPadding.x +
|
||||||
mSize.x + mStyleBackgroundHorizontalPadding.x + mStyleBackgroundHorizontalPadding.y -
|
mBackgroundHorizontalPadding.y -
|
||||||
(mStyleEntrySpacing * mRenderer->getScreenWidth()),
|
(mEntrySpacing * mRenderer->getScreenWidth()),
|
||||||
mSize.y + mStyleBackgroundVerticalPadding.x + mStyleBackgroundVerticalPadding.y,
|
mSize.y + mBackgroundVerticalPadding.x + mBackgroundVerticalPadding.y,
|
||||||
mStyleBackgroundColor, mStyleBackgroundColorEnd, mStyleColorGradientHorizontal,
|
mBackgroundColor, mBackgroundColorEnd, mColorGradientHorizontal,
|
||||||
mThemeOpacity, 1.0f, Renderer::BlendFactor::SRC_ALPHA,
|
mThemeOpacity, 1.0f, Renderer::BlendFactor::SRC_ALPHA,
|
||||||
Renderer::BlendFactor::ONE_MINUS_SRC_ALPHA, mStyleBackgroundCornerRadius);
|
Renderer::BlendFactor::ONE_MINUS_SRC_ALPHA, mBackgroundCornerRadius);
|
||||||
|
|
||||||
mPosition = {0.0f, 0.0f, 0.0f};
|
mPosition = {0.0f, 0.0f, 0.0f};
|
||||||
mSize = {0.0f, 0.0f};
|
mSize = {0.0f, 0.0f};
|
||||||
|
@ -430,8 +426,8 @@ void HelpComponent::render(const glm::mat4& parentTrans)
|
||||||
const glm::mat4 trans {parentTrans * getTransform()};
|
const glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mGrid) {
|
if (mGrid) {
|
||||||
mGrid->setRotationOrigin(mStyleRotationOrigin);
|
mGrid->setRotationOrigin(mHelpRotationOrigin);
|
||||||
mGrid->setRotation(mStyleRotation);
|
mGrid->setRotation(mHelpRotation);
|
||||||
mGrid->render(trans);
|
mGrid->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -637,7 +633,7 @@ void HelpComponent::updateGrid()
|
||||||
|
|
||||||
const bool isDimmed {mWindow->isBackgroundDimmed()};
|
const bool isDimmed {mWindow->isBackgroundDimmed()};
|
||||||
|
|
||||||
std::shared_ptr<Font>& font {isDimmed ? mStyleFontDimmed : mStyleFont};
|
std::shared_ptr<Font>& font {isDimmed ? mFontDimmed : mFont};
|
||||||
mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {static_cast<int>(mPrompts.size()) * 5, 1});
|
mGrid = std::make_shared<ComponentGrid>(glm::ivec2 {static_cast<int>(mPrompts.size()) * 5, 1});
|
||||||
|
|
||||||
std::vector<std::shared_ptr<ImageComponent>> icons;
|
std::vector<std::shared_ptr<ImageComponent>> icons;
|
||||||
|
@ -663,51 +659,49 @@ void HelpComponent::updateGrid()
|
||||||
imageCache[mIconPathMap[it->first]] = icon;
|
imageCache[mIconPathMap[it->first]] = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
icon->setColorShift(isDimmed ? mStyleIconColorDimmed : mStyleIconColor);
|
icon->setColorShift(isDimmed ? mIconColorDimmed : mIconColor);
|
||||||
|
|
||||||
if (mEntryRelativeScale < 1.0f)
|
if (mEntryRelativeScale < 1.0f)
|
||||||
icon->setResize(0, height);
|
icon->setResize(0, height);
|
||||||
else
|
else
|
||||||
icon->setResize(0, height / mEntryRelativeScale);
|
icon->setResize(0, height / mEntryRelativeScale);
|
||||||
|
|
||||||
icon->setOpacity(isDimmed ? mStyleOpacityDimmed : mStyleOpacity);
|
icon->setOpacity(isDimmed ? mHelpOpacityDimmed : mHelpOpacity);
|
||||||
icons.push_back(icon);
|
icons.push_back(icon);
|
||||||
|
|
||||||
// Apply text style and color from the theme to the label and add it to the label list.
|
// Apply text style and color from the theme to the label and add it to the label list.
|
||||||
std::string lblInput {it->second};
|
std::string lblInput {it->second};
|
||||||
if (mStyleLetterCase == "lowercase")
|
if (mLetterCase == "lowercase")
|
||||||
lblInput = Utils::String::toLower(lblInput);
|
lblInput = Utils::String::toLower(lblInput);
|
||||||
else if (mStyleLetterCase == "capitalize")
|
else if (mLetterCase == "capitalize")
|
||||||
lblInput = Utils::String::toCapitalized(lblInput);
|
lblInput = Utils::String::toCapitalized(lblInput);
|
||||||
else
|
else
|
||||||
lblInput = Utils::String::toUpper(lblInput);
|
lblInput = Utils::String::toUpper(lblInput);
|
||||||
auto lbl = std::make_shared<TextComponent>(
|
auto lbl = std::make_shared<TextComponent>(lblInput, font,
|
||||||
lblInput, font, isDimmed ? mStyleTextColorDimmed : mStyleTextColor);
|
isDimmed ? mTextColorDimmed : mTextColor);
|
||||||
lbl->setOpacity(isDimmed ? mStyleOpacityDimmed : mStyleOpacity);
|
lbl->setOpacity(isDimmed ? mHelpOpacityDimmed : mHelpOpacity);
|
||||||
labels.push_back(lbl);
|
labels.push_back(lbl);
|
||||||
|
|
||||||
width += icon->getSize().x + lbl->getSize().x +
|
width +=
|
||||||
(((isDimmed ? mStyleIconTextSpacingDimmed : mStyleIconTextSpacing) *
|
icon->getSize().x + lbl->getSize().x +
|
||||||
mRenderer->getScreenWidth() +
|
(((isDimmed ? mIconTextSpacingDimmed : mIconTextSpacing) * mRenderer->getScreenWidth() +
|
||||||
(isDimmed ? mStyleEntrySpacingDimmed : mStyleEntrySpacing) *
|
(isDimmed ? mEntrySpacingDimmed : mEntrySpacing) * mRenderer->getScreenWidth()));
|
||||||
mRenderer->getScreenWidth()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid->setSize(width, height);
|
mGrid->setSize(width, height);
|
||||||
|
|
||||||
if (mStyleEntryLayout == EntryLayout::ICON_FIRST) {
|
if (mEntryLayout == EntryLayout::ICON_FIRST) {
|
||||||
for (int i {0}; i < static_cast<int>(icons.size()); ++i) {
|
for (int i {0}; i < static_cast<int>(icons.size()); ++i) {
|
||||||
const int col {i * 5};
|
const int col {i * 5};
|
||||||
mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width);
|
mGrid->setColWidthPerc(col, icons.at(i)->getSize().x / width);
|
||||||
mGrid->setColWidthPerc(
|
mGrid->setColWidthPerc(col + 1,
|
||||||
col + 1, ((isDimmed ? mStyleIconTextSpacingDimmed : mStyleIconTextSpacing) *
|
((isDimmed ? mIconTextSpacingDimmed : mIconTextSpacing) *
|
||||||
mRenderer->getScreenWidth()) /
|
|
||||||
width);
|
|
||||||
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
|
||||||
mGrid->setColWidthPerc(col + 3,
|
|
||||||
((isDimmed ? mStyleEntrySpacingDimmed : mStyleEntrySpacing) *
|
|
||||||
mRenderer->getScreenWidth()) /
|
mRenderer->getScreenWidth()) /
|
||||||
width);
|
width);
|
||||||
|
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
||||||
|
mGrid->setColWidthPerc(col + 3, ((isDimmed ? mEntrySpacingDimmed : mEntrySpacing) *
|
||||||
|
mRenderer->getScreenWidth()) /
|
||||||
|
width);
|
||||||
|
|
||||||
mGrid->setEntry(icons.at(i), glm::ivec2 {col, 0}, false, false);
|
mGrid->setEntry(icons.at(i), glm::ivec2 {col, 0}, false, false);
|
||||||
mGrid->setEntry(labels.at(i), glm::ivec2 {col + 2, 0}, false, false);
|
mGrid->setEntry(labels.at(i), glm::ivec2 {col + 2, 0}, false, false);
|
||||||
|
@ -717,15 +711,14 @@ void HelpComponent::updateGrid()
|
||||||
for (int i {0}; i < static_cast<int>(icons.size()); ++i) {
|
for (int i {0}; i < static_cast<int>(icons.size()); ++i) {
|
||||||
const int col {i * 5};
|
const int col {i * 5};
|
||||||
mGrid->setColWidthPerc(col, labels.at(i)->getSize().x / width);
|
mGrid->setColWidthPerc(col, labels.at(i)->getSize().x / width);
|
||||||
mGrid->setColWidthPerc(
|
mGrid->setColWidthPerc(col + 1,
|
||||||
col + 1, ((isDimmed ? mStyleIconTextSpacingDimmed : mStyleIconTextSpacing) *
|
((isDimmed ? mIconTextSpacingDimmed : mIconTextSpacing) *
|
||||||
mRenderer->getScreenWidth()) /
|
|
||||||
width);
|
|
||||||
mGrid->setColWidthPerc(col + 2, icons.at(i)->getSize().x / width);
|
|
||||||
mGrid->setColWidthPerc(col + 3,
|
|
||||||
((isDimmed ? mStyleEntrySpacingDimmed : mStyleEntrySpacing) *
|
|
||||||
mRenderer->getScreenWidth()) /
|
mRenderer->getScreenWidth()) /
|
||||||
width);
|
width);
|
||||||
|
mGrid->setColWidthPerc(col + 2, icons.at(i)->getSize().x / width);
|
||||||
|
mGrid->setColWidthPerc(col + 3, ((isDimmed ? mEntrySpacingDimmed : mEntrySpacing) *
|
||||||
|
mRenderer->getScreenWidth()) /
|
||||||
|
width);
|
||||||
|
|
||||||
mGrid->setEntry(labels.at(i), glm::ivec2 {col, 0}, false, false);
|
mGrid->setEntry(labels.at(i), glm::ivec2 {col, 0}, false, false);
|
||||||
mGrid->setEntry(icons.at(i), glm::ivec2 {col + 2, 0}, false, false);
|
mGrid->setEntry(icons.at(i), glm::ivec2 {col + 2, 0}, false, false);
|
||||||
|
@ -734,15 +727,15 @@ void HelpComponent::updateGrid()
|
||||||
|
|
||||||
if (isDimmed) {
|
if (isDimmed) {
|
||||||
mGrid->setPosition(
|
mGrid->setPosition(
|
||||||
{mStylePositionDimmed.x +
|
{mHelpPositionDimmed.x +
|
||||||
((mStyleEntrySpacingDimmed * mRenderer->getScreenWidth()) * mStyleOriginDimmed.x),
|
((mEntrySpacingDimmed * mRenderer->getScreenWidth()) * mHelpOriginDimmed.x),
|
||||||
mStylePositionDimmed.y, 0.0f});
|
mHelpPositionDimmed.y, 0.0f});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mGrid->setPosition({mStylePosition.x + ((mStyleEntrySpacing * mRenderer->getScreenWidth()) *
|
mGrid->setPosition(
|
||||||
mStyleOrigin.x),
|
{mHelpPosition.x + ((mEntrySpacing * mRenderer->getScreenWidth()) * mHelpOrigin.x),
|
||||||
mStylePosition.y, 0.0f});
|
mHelpPosition.y, 0.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid->setOrigin(isDimmed ? mStyleOriginDimmed : mStyleOrigin);
|
mGrid->setOrigin(isDimmed ? mHelpOriginDimmed : mHelpOrigin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,10 @@ public:
|
||||||
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
||||||
|
|
||||||
void setOpacity(float opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
void setStylePosition(const glm::vec2 position) { mStylePosition = position; }
|
void setHelpPosition(const glm::vec2 position) { mHelpPosition = position; }
|
||||||
void setStyleOrigin(const glm::vec2 origin) { mStyleOrigin = origin; }
|
void setHelpOrigin(const glm::vec2 origin) { mHelpOrigin = origin; }
|
||||||
void setStyleTextColor(const unsigned int textColor) { mStyleTextColor = textColor; }
|
void setHelpTextColor(const unsigned int textColor) { mTextColor = textColor; }
|
||||||
void setStyleIconColor(const unsigned int iconColor) { mStyleIconColor = iconColor; }
|
void setHelpIconColor(const unsigned int iconColor) { mIconColor = iconColor; }
|
||||||
|
|
||||||
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view,
|
const std::string& view,
|
||||||
|
@ -48,8 +48,8 @@ private:
|
||||||
std::vector<HelpPrompt> mPrompts;
|
std::vector<HelpPrompt> mPrompts;
|
||||||
std::map<std::string, std::string> mIconPathMap;
|
std::map<std::string, std::string> mIconPathMap;
|
||||||
|
|
||||||
std::shared_ptr<Font> mStyleFont;
|
std::shared_ptr<Font> mFont;
|
||||||
std::shared_ptr<Font> mStyleFontDimmed;
|
std::shared_ptr<Font> mFontDimmed;
|
||||||
|
|
||||||
std::vector<std::string> mEntries;
|
std::vector<std::string> mEntries;
|
||||||
static inline std::vector<std::string> sAllowedEntries {"thumbstickclick",
|
static inline std::vector<std::string> sAllowedEntries {"thumbstickclick",
|
||||||
|
@ -76,33 +76,33 @@ private:
|
||||||
TEXT_FIRST
|
TEXT_FIRST
|
||||||
};
|
};
|
||||||
|
|
||||||
glm::vec2 mStylePosition;
|
glm::vec2 mHelpPosition;
|
||||||
glm::vec2 mStylePositionDimmed;
|
glm::vec2 mHelpPositionDimmed;
|
||||||
glm::vec2 mStyleOrigin;
|
glm::vec2 mHelpOrigin;
|
||||||
glm::vec2 mStyleOriginDimmed;
|
glm::vec2 mHelpOriginDimmed;
|
||||||
glm::vec2 mStyleRotationOrigin;
|
glm::vec2 mHelpRotationOrigin;
|
||||||
unsigned int mStyleTextColor;
|
unsigned int mTextColor;
|
||||||
unsigned int mStyleTextColorDimmed;
|
unsigned int mTextColorDimmed;
|
||||||
unsigned int mStyleIconColor;
|
unsigned int mIconColor;
|
||||||
unsigned int mStyleIconColorDimmed;
|
unsigned int mIconColorDimmed;
|
||||||
unsigned int mStyleBackgroundColor;
|
unsigned int mBackgroundColor;
|
||||||
unsigned int mStyleBackgroundColorEnd;
|
unsigned int mBackgroundColorEnd;
|
||||||
glm::vec2 mStyleBackgroundHorizontalPadding;
|
glm::vec2 mBackgroundHorizontalPadding;
|
||||||
glm::vec2 mStyleBackgroundVerticalPadding;
|
glm::vec2 mBackgroundVerticalPadding;
|
||||||
float mStyleBackgroundCornerRadius;
|
float mBackgroundCornerRadius;
|
||||||
bool mStyleColorGradientHorizontal;
|
bool mColorGradientHorizontal;
|
||||||
EntryLayout mStyleEntryLayout;
|
EntryLayout mEntryLayout;
|
||||||
float mEntryRelativeScale;
|
float mEntryRelativeScale;
|
||||||
float mLetterHeight;
|
float mLetterHeight;
|
||||||
float mLetterHeightDimmed;
|
float mLetterHeightDimmed;
|
||||||
float mStyleRotation;
|
float mHelpRotation;
|
||||||
float mStyleEntrySpacing;
|
float mEntrySpacing;
|
||||||
float mStyleEntrySpacingDimmed;
|
float mEntrySpacingDimmed;
|
||||||
float mStyleIconTextSpacing;
|
float mIconTextSpacing;
|
||||||
float mStyleIconTextSpacingDimmed;
|
float mIconTextSpacingDimmed;
|
||||||
float mStyleOpacity;
|
float mHelpOpacity;
|
||||||
float mStyleOpacityDimmed;
|
float mHelpOpacityDimmed;
|
||||||
std::string mStyleLetterCase;
|
std::string mLetterCase;
|
||||||
|
|
||||||
struct CustomButtonIcons {
|
struct CustomButtonIcons {
|
||||||
// Generic
|
// Generic
|
||||||
|
|
Loading…
Reference in a new issue