summaryrefslogtreecommitdiff
path: root/src/settings_gui.cpp
diff options
context:
space:
mode:
authorGreg Carlin <gregcarlin@users.noreply.github.com>2019-02-23 03:27:46 -0500
committerPeterN <peter@fuzzle.org>2019-02-23 08:27:46 +0000
commit00d28a500d9b2c32877871e0d2b917c8b28a82a6 (patch)
tree4833e57b77c01a0dfa327e546831319336c4cd13 /src/settings_gui.cpp
parent56a6d7aec88b170eaf0dd57e14f5fffc24d3b1af (diff)
downloadopenttd-00d28a500d9b2c32877871e0d2b917c8b28a82a6.tar.xz
Feature: Add option to adjust font size separately from GUI size. (#7003)
Adds an option in the "Game Options" next to "Interface Size" called "Font Size". Available options are normal, double, and quad.
Diffstat (limited to 'src/settings_gui.cpp')
-rw-r--r--src/settings_gui.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 2faf2b150..a15f2ff58 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -36,6 +36,7 @@
#include "textfile_gui.h"
#include "stringfilter_type.h"
#include "querystring_gui.h"
+#include "fontcache.h"
#include <vector>
@@ -64,6 +65,13 @@ static const StringID _gui_zoom_dropdown[] = {
INVALID_STRING_ID,
};
+static const StringID _font_zoom_dropdown[] = {
+ STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_NORMAL,
+ STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_2X_ZOOM,
+ STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_4X_ZOOM,
+ INVALID_STRING_ID,
+};
+
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1; ///< Number of original town names.
static StringID *_grf_names = NULL; ///< Pointer to town names defined by NewGRFs.
static int _nb_grf_names = 0; ///< Number of town names defined by NewGRFs.
@@ -302,6 +310,16 @@ struct GameOptionsWindow : Window {
break;
}
+ case WID_GO_FONT_ZOOM_DROPDOWN: {
+ list = new DropDownList();
+ *selected_index = ZOOM_LVL_OUT_4X - _font_zoom;
+ const StringID *items = _font_zoom_dropdown;
+ for (int i = 0; *items != INVALID_STRING_ID; items++, i++) {
+ *list->Append() = new DropDownListStringItem(*items, i, false);
+ }
+ break;
+ }
+
case WID_GO_BASE_GRF_DROPDOWN:
list = BuildSetDropDownList<BaseGraphics>(selected_index, (_game_mode == GM_MENU));
break;
@@ -331,6 +349,7 @@ struct GameOptionsWindow : Window {
case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break;
case WID_GO_RESOLUTION_DROPDOWN: SetDParam(0, GetCurRes() == _num_resolutions ? STR_GAME_OPTIONS_RESOLUTION_OTHER : SPECSTR_RESOLUTION_START + GetCurRes()); break;
case WID_GO_GUI_ZOOM_DROPDOWN: SetDParam(0, _gui_zoom_dropdown[ZOOM_LVL_OUT_4X - _gui_zoom]); break;
+ case WID_GO_FONT_ZOOM_DROPDOWN: SetDParam(0, _font_zoom_dropdown[ZOOM_LVL_OUT_4X - _font_zoom]); break;
case WID_GO_BASE_GRF_DROPDOWN: SetDParamStr(0, BaseGraphics::GetUsedSet()->name); break;
case WID_GO_BASE_GRF_STATUS: SetDParam(0, BaseGraphics::GetUsedSet()->GetNumInvalid()); break;
case WID_GO_BASE_SFX_DROPDOWN: SetDParamStr(0, BaseSounds::GetUsedSet()->name); break;
@@ -541,6 +560,14 @@ struct GameOptionsWindow : Window {
UpdateAllVirtCoords();
break;
+ case WID_GO_FONT_ZOOM_DROPDOWN:
+ GfxClearSpriteCache();
+ _font_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
+ ClearFontCache();
+ UpdateAllVirtCoords();
+ ReInitAllWindows();
+ break;
+
case WID_GO_BASE_GRF_DROPDOWN:
this->SetMediaSet<BaseGraphics>(index);
break;
@@ -616,6 +643,9 @@ static const NWidgetPart _nested_game_options_widgets[] = {
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(1, 0),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(0, 1),
+ NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_FONT_ZOOM, STR_NULL),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_FONT_ZOOM_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_FONT_ZOOM_DROPDOWN_TOOLTIP), SetFill(1, 0),
+ EndContainer(),
EndContainer(),
EndContainer(),