Changed to scaling the menu title per language instead of the overall menu

This commit is contained in:
Leon Styhre 2024-07-04 19:33:07 +02:00
parent 6b541ad501
commit 1df2641e0c
5 changed files with 12 additions and 12 deletions

View file

@ -10,7 +10,6 @@
#include "Settings.h"
#include "components/ButtonComponent.h"
#include "utils/LocalizationUtil.h"
#define BUTTON_GRID_VERT_PADDING Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.915f
#define BUTTON_GRID_HORIZ_PADDING Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.283f
@ -114,11 +113,9 @@ void MenuComponent::updateSize()
}
}
float width {std::min(
mRenderer->getScreenHeight() * 1.05f * Utils::Localization::sMenuScaleFactor,
mRenderer->getScreenWidth() * (mRenderer->getIsVerticalOrientation() ?
0.94f * Utils::Localization::sMenuScaleFactor :
0.90f * Utils::Localization::sMenuScaleFactor))};
float width {std::min(mRenderer->getScreenHeight() * 1.05f,
mRenderer->getScreenWidth() *
(mRenderer->getIsVerticalOrientation() ? 0.94f : 0.90f))};
setSize(width, height);
}

View file

@ -16,6 +16,7 @@
#include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h"
#include "components/TextComponent.h"
#include "utils/LocalizationUtil.h"
#include "utils/StringUtil.h"
#include <cmath>
@ -24,7 +25,8 @@ class MenuComponent : public GuiComponent
{
public:
MenuComponent(std::string title,
const std::shared_ptr<Font>& titleFont = Font::get(FONT_SIZE_LARGE));
const std::shared_ptr<Font>& titleFont =
Font::get(FONT_SIZE_LARGE * Utils::Localization::sMenuTitleScaleFactor));
virtual ~MenuComponent();
void save();

View file

@ -29,7 +29,7 @@ namespace Utils
{
const std::vector<std::pair<std::string, std::string>> sSupportedLocales {{{"en"}, {"US"}},
{{"sv"}, {"SE"}}};
float sMenuScaleFactor {1.0f};
float sMenuTitleScaleFactor {1.0f};
std::pair<std::string, std::string> getLocale()
{
@ -90,7 +90,7 @@ namespace Utils
}
}
sMenuScaleFactor = 1.0f;
sMenuTitleScaleFactor = 1.0f;
std::string languageSetting {Settings::getInstance()->getString("ApplicationLanguage")};
std::vector<std::string> localeVector;
std::pair<std::string, std::string> localePair;
@ -138,9 +138,9 @@ namespace Utils
locale = "en_US";
}
// Language-specific menu scale factor.
// Language-specific menu title scale factor.
if (localePair.first == "sv")
sMenuScaleFactor = 1.02f;
sMenuTitleScaleFactor = 0.86f;
std::string localePath;
localePath.append("/")

View file

@ -21,7 +21,7 @@ namespace Utils
namespace Localization
{
extern const std::vector<std::pair<std::string, std::string>> sSupportedLocales;
extern float sMenuScaleFactor;
extern float sMenuTitleScaleFactor;
std::pair<std::string, std::string> getLocale();
void setLocale();

View file

@ -1 +1,2 @@
en_US
sv_SE