Add font size to options

This commit is contained in:
Deve 2019-05-16 22:16:36 +02:00
parent 86a0d06f99
commit ec485bae4c
5 changed files with 32 additions and 4 deletions

View File

@ -51,6 +51,16 @@
<spacer width="5" height="2%"/> <spacer width="5" height="2%"/>
<div layout="horizontal-row" width="100%" height="fit">
<label proportion="1" I18N="In the ui settings" text="Font size" align="center"/>
<spacer width="2%" height="20"/>
<div layout="horizontal-row" proportion="5" height="100%">
<gauge id="font_size" min_value="1" max_value="5" width="60%"/>
</div>
</div>
<spacer width="5" height="2%"/>
<div layout="horizontal-row" width="100%" height="fit"> <div layout="horizontal-row" width="100%" height="fit">
<checkbox id="showfps"/> <checkbox id="showfps"/>
<spacer width="1%" height="100%" /> <spacer width="1%" height="100%" />

View File

@ -644,7 +644,7 @@ namespace UserConfigParams
&m_video_group, "Generate mipmap for textures using " &m_video_group, "Generate mipmap for textures using "
"high quality method with SSE")); "high quality method with SSE"));
PARAM_PREFIX FloatUserConfigParam m_fonts_size PARAM_PREFIX FloatUserConfigParam m_fonts_size
PARAM_DEFAULT( FloatUserConfigParam(2, "fonts_size", PARAM_DEFAULT( FloatUserConfigParam(3, "fonts_size",
&m_video_group,"The size of fonts. 0 is the smallest and 6 is the biggest") ); &m_video_group,"The size of fonts. 0 is the smallest and 6 is the biggest") );
// ---- Recording // ---- Recording

View File

@ -52,14 +52,17 @@ void override_default_params()
case ACONFIGURATION_SCREENSIZE_NORMAL: case ACONFIGURATION_SCREENSIZE_NORMAL:
UserConfigParams::m_multitouch_scale = 1.3f; UserConfigParams::m_multitouch_scale = 1.3f;
UserConfigParams::m_multitouch_sensitivity_x = 0.1f; UserConfigParams::m_multitouch_sensitivity_x = 0.1f;
UserConfigParams::m_fonts_size = 5.0f;
break; break;
case ACONFIGURATION_SCREENSIZE_LARGE: case ACONFIGURATION_SCREENSIZE_LARGE:
UserConfigParams::m_multitouch_scale = 1.2f; UserConfigParams::m_multitouch_scale = 1.2f;
UserConfigParams::m_multitouch_sensitivity_x = 0.15f; UserConfigParams::m_multitouch_sensitivity_x = 0.15f;
UserConfigParams::m_fonts_size = 5.0f;
break; break;
case ACONFIGURATION_SCREENSIZE_XLARGE: case ACONFIGURATION_SCREENSIZE_XLARGE:
UserConfigParams::m_multitouch_scale = 1.1f; UserConfigParams::m_multitouch_scale = 1.1f;
UserConfigParams::m_multitouch_sensitivity_x = 0.2f; UserConfigParams::m_multitouch_sensitivity_x = 0.2f;
UserConfigParams::m_fonts_size = 4.0f;
break; break;
default: default:
break; break;
@ -68,9 +71,6 @@ void override_default_params()
// Enable screen keyboard // Enable screen keyboard
UserConfigParams::m_screen_keyboard = 1; UserConfigParams::m_screen_keyboard = 1;
// Set bigger fonts and buttons
UserConfigParams::m_fonts_size = 4.5f;
// It shouldn't matter, but STK is always run in fullscreen on android // It shouldn't matter, but STK is always run in fullscreen on android
UserConfigParams::m_fullscreen = true; UserConfigParams::m_fullscreen = true;

View File

@ -160,6 +160,12 @@ void OptionsScreenUI::init()
UserConfigParams::m_minimap_display = 1; UserConfigParams::m_minimap_display = 1;
} }
minimap_options->setValue(UserConfigParams::m_minimap_display); minimap_options->setValue(UserConfigParams::m_minimap_display);
GUIEngine::SpinnerWidget* font_size = getWidget<GUIEngine::SpinnerWidget>("font_size");
assert( font_size != NULL );
font_size->setValue((int)roundf(UserConfigParams::m_fonts_size));
m_prev_font_size = UserConfigParams::m_fonts_size;
// ---- video modes // ---- video modes
CheckBoxWidget* splitscreen_method = getWidget<CheckBoxWidget>("split_screen_horizontally"); CheckBoxWidget* splitscreen_method = getWidget<CheckBoxWidget>("split_screen_horizontally");
@ -248,6 +254,12 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
assert( minimap_options != NULL ); assert( minimap_options != NULL );
UserConfigParams::m_minimap_display = minimap_options->getValue(); UserConfigParams::m_minimap_display = minimap_options->getValue();
} }
else if (name == "font_size")
{
GUIEngine::SpinnerWidget* font_size = getWidget<GUIEngine::SpinnerWidget>("font_size");
assert( font_size != NULL );
UserConfigParams::m_fonts_size = font_size->getValue();
}
else if (name == "split_screen_horizontally") else if (name == "split_screen_horizontally")
{ {
CheckBoxWidget* split_screen_horizontally = getWidget<CheckBoxWidget>("split_screen_horizontally"); CheckBoxWidget* split_screen_horizontally = getWidget<CheckBoxWidget>("split_screen_horizontally");
@ -268,6 +280,11 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
void OptionsScreenUI::tearDown() void OptionsScreenUI::tearDown()
{ {
if (m_prev_font_size != UserConfigParams::m_fonts_size)
{
irr_driver->sameRestart();
}
Screen::tearDown(); Screen::tearDown();
// save changes when leaving screen // save changes when leaving screen
user_config->saveConfig(); user_config->saveConfig();

View File

@ -35,6 +35,7 @@ class OptionsScreenUI : public GUIEngine::Screen, public GUIEngine::ScreenSingle
{ {
OptionsScreenUI(); OptionsScreenUI();
bool m_inited; bool m_inited;
float m_prev_font_size;
std::vector<std::string> m_skins; std::vector<std::string> m_skins;