From e2f2a4dfa314c5ade20fc21617f4586fd1143324 Mon Sep 17 00:00:00 2001 From: Miguel Horta Date: Wed, 23 Aug 2023 23:31:24 +0100 Subject: [PATCH] change: Remove min_button setting --- src/gfx_func.h | 10 ---------- src/settings_gui.cpp | 25 ------------------------- src/settings_type.h | 1 - src/table/settings/misc_settings.ini | 9 --------- src/widget.cpp | 10 +++++----- src/window.cpp | 2 +- 6 files changed, 6 insertions(+), 51 deletions(-) diff --git a/src/gfx_func.h b/src/gfx_func.h index c4a5da5aba..e34d05eeab 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -229,16 +229,6 @@ static inline int Center(int top, int height, uint size = FONT_HEIGHT_NORMAL) return top + (height - size) / 2; } -/** - * Returns fint/button size, rescaled to current screen resolution from the base Android resolution, which is 854x480 - * @param value The value to rescale - * @return Rescaled value, using lesser of the curret screen coordinates - */ -static inline int RescaleFrom854x480(int value) -{ - return std::min(value * _cur_resolution.width / 854, value * _cur_resolution.height / 480); -} - extern DrawPixelInfo *_cur_dpi; /** diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 7037d755bd..d9de67865c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -53,8 +53,6 @@ #include #endif -enum { MIN_BUTTON_SIZE = 10, MAX_BUTTON_SIZE = 100 }; - static const StringID _autosave_dropdown[] = { STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH, @@ -278,16 +276,6 @@ struct GameOptionsWindow : Window { } break; - case WID_GO_BUTTON_SIZE_DROPDOWN: // Dropdowns for size of all GUI elements and fonts - list = DropDownList(); - *selected_index = _settings_client.gui.min_button; - for (uint i = MIN_BUTTON_SIZE; i <= MAX_BUTTON_SIZE; i++) { - DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false); - item->SetParam(0, i); - list.emplace_back(item); - } - break; - case WID_GO_BASE_GRF_DROPDOWN: list = BuildSetDropDownList(selected_index, (_game_mode == GM_MENU)); break; @@ -310,7 +298,6 @@ struct GameOptionsWindow : Window { case WID_GO_CURRENCY_DROPDOWN: SetDParam(0, _currency_specs[this->opt->locale.currency].name); break; case WID_GO_AUTOSAVE_DROPDOWN: SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]); break; case WID_GO_LANG_DROPDOWN: SetDParamStr(0, _current_language->own_name); break; - case WID_GO_BUTTON_SIZE_DROPDOWN: SetDParam(0, _settings_client.gui.min_button); 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; @@ -466,13 +453,6 @@ struct GameOptionsWindow : Window { this->SetWidgetLoweredState(WID_GO_WINDOWS_TITLEBARS, _settings_client.gui.windows_titlebars); this->SetDirty(); - if (_settings_client.gui.min_button == 48 && _settings_client.gui.windows_titlebars) { - _settings_client.gui.min_button = 40; - } - if (_settings_client.gui.min_button == 40 && !_settings_client.gui.windows_titlebars) { - _settings_client.gui.min_button = 48; - } - ReInitAllWindows(false); break; @@ -642,10 +622,6 @@ struct GameOptionsWindow : Window { } break; - case WID_GO_BUTTON_SIZE_DROPDOWN: // Setup screenshot format dropdown - _settings_client.gui.min_button = index; - break; - case WID_GO_REFRESH_RATE_DROPDOWN: { _settings_client.gui.refresh_rate = *std::next(_refresh_rates.begin(), index); if (_settings_client.gui.refresh_rate > 60) { @@ -732,7 +708,6 @@ static const NWidgetPart _nested_game_options_widgets[] = { NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_AUTO), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_AUTO_TOOLTIP), EndContainer(), - NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_BUTTON_SIZE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_JUST_INT, STR_CONFIG_SETTING_BUTTON_SIZE_TOOLTIP), SetFill(1, 0), NWidget(NWID_HORIZONTAL), NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_BEVELS, STR_NULL), NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0), diff --git a/src/settings_type.h b/src/settings_type.h index 15bfc50a60..064efd3b6d 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -115,7 +115,6 @@ struct GUISettings { bool windows_titlebars; ///< show or hide titlebars for all windows to increase scrren space bool draw_mouse_cursor; ///< draw mouse cursor, touchscreen does not generally need a mouse cursor, but mouse cursor shows currently selected build tool bool windows_decorations; ///< draw ornament on all window edges - uint min_button; ///< min size of most button widgets bool show_finances; ///< show finances at end of year bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames bool new_nonstop; ///< ttdpatch compatible nonstop handling diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index cb2ff1ea07..d95513e138 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -265,15 +265,6 @@ name = ""mono_aa"" var = _fcsettings.mono.aa def = true -[SDTG_VAR] -name = ""min_button_size"" -type = SLE_UINT -var = _settings_client.gui.min_button -def = 48 -min = 0 -max = 100 -cat = SC_EXPERT - [SDTG_VAR] name = ""sprite_cache_size_px"" type = SLE_UINT diff --git a/src/widget.cpp b/src/widget.cpp index 3e960d2ded..ae7840572f 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -27,6 +27,8 @@ #include "safeguards.h" +extern int _gui_scale; + /** Distances used in drawing widgets. */ enum WidgetDrawDistances { /* WWT_IMGBTN(_2) */ @@ -1152,14 +1154,13 @@ void NWidgetResizeBase::SetMinimalSizeForSizingType() min_size = 0; break; case NWST_BUTTON: - min_size = _settings_client.gui.min_button; + min_size = GetMinButtonSize(); break; case NWST_VIEWPORT: - min_size = 3 * _settings_client.gui.min_button; + min_size = (5 * _gui_scale) / 2; break; default: NOT_REACHED(); } - min_size = RescaleFrom854x480(min_size); this->min_x = std::max(this->min_x, min_size); this->min_y = std::max(this->min_y, min_size); @@ -3693,8 +3694,7 @@ NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int wid */ uint GetMinButtonSize(uint min_1) { - uint min_sizing = _settings_client.gui.min_button; - min_sizing = RescaleFrom854x480(min_sizing); + uint min_sizing = _gui_scale / 4; return std::max(min_sizing, min_1); } diff --git a/src/window.cpp b/src/window.cpp index 8152cc88b8..7d7763a5e1 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2959,7 +2959,7 @@ static void HandleAutoscroll() int x = _cursor.pos.x; int y = _cursor.pos.y; - int border = RescaleFrom854x480(_settings_client.gui.min_button); + int border = GetMinButtonSize(); Window *w = FindWindowFromPt(x, y); if (w == nullptr || w->flags & WF_DISABLE_VP_SCROLL) return; if (_settings_client.gui.auto_scrolling != VA_EVERY_VIEWPORT && w->window_class != WC_MAIN_WINDOW) return;