Add setting to increase size of main toolbar
This commit is contained in:
@@ -2117,3 +2117,6 @@ STR_ERROR_CAN_T_SELL_25_SHARE_IN :{WHITE}Can't se
|
||||
STR_ERROR_PROTECTED :{WHITE}This company is not old enough to trade shares yet...
|
||||
|
||||
STR_TOWN_DIRECTORY_INFO :{BLACK}{STRING1}, Towns: {COMMA}
|
||||
|
||||
STR_GAME_OPTIONS_GUI_SCALE_MAIN_TOOLBAR :{BLACK}Bigger main toolbar
|
||||
STR_GAME_OPTIONS_GUI_SCALE_MAIN_TOOLBAR_TOOLTIP :{BLACK}Check this box to increase the scale of the main toolbar
|
||||
|
@@ -561,6 +561,16 @@ struct GameOptionsWindow : Window {
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_GUI_SCALE_MAIN_TOOLBAR: {
|
||||
_settings_client.gui.bigger_main_toolbar = !_settings_client.gui.bigger_main_toolbar;
|
||||
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_MAIN_TOOLBAR, _settings_client.gui.bigger_main_toolbar);
|
||||
this->SetDirty();
|
||||
|
||||
ReInitAllWindows(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_GO_GUI_SCALE:
|
||||
if (ClickSliderWidget(this->GetWidget<NWidgetBase>(widget)->GetCurrentRect(), pt, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE, this->gui_scale)) {
|
||||
if (!_ctrl_pressed) this->gui_scale = ((this->gui_scale + 12) / 25) * 25;
|
||||
@@ -766,6 +776,7 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_AUTO, _gui_scale_cfg == -1);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_BEVEL_BUTTON, _settings_client.gui.scale_bevels);
|
||||
this->SetWidgetLoweredState(WID_GO_GUI_SCALE_MAIN_TOOLBAR, _settings_client.gui.bigger_main_toolbar);
|
||||
|
||||
bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
|
||||
this->GetWidget<NWidgetCore>(WID_GO_BASE_GRF_STATUS)->SetDataTip(missing_files ? STR_EMPTY : STR_GAME_OPTIONS_BASE_GRF_STATUS, STR_NULL);
|
||||
@@ -825,6 +836,11 @@ 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_BEVEL_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_BEVELS_TOOLTIP),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_GAME_OPTIONS_GUI_SCALE_MAIN_TOOLBAR, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_GUI_SCALE_MAIN_TOOLBAR), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_GUI_SCALE_MAIN_TOOLBAR_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
|
@@ -281,6 +281,7 @@ struct GUISettings : public TimeSettings {
|
||||
bool newgrf_disable_big_gui; ///< whether to disable "big GUI" NewGRFs
|
||||
|
||||
bool scale_bevels; ///< bevels are scaled with GUI scale.
|
||||
bool bigger_main_toolbar; ///< bigger main toolbar.
|
||||
|
||||
/**
|
||||
* Returns true when the user has sufficient privileges to edit newgrfs on a running game
|
||||
|
@@ -5663,6 +5663,14 @@ post_cb = [](auto) { SetupWidgetDimensions(); ReInitAllWindows(true); }
|
||||
cat = SC_BASIC
|
||||
startup = true
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.bigger_main_toolbar
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
post_cb = [](auto) { ReInitAllWindows(true); }
|
||||
cat = SC_BASIC
|
||||
startup = true
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.show_wagon_intro_year
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
|
@@ -59,6 +59,7 @@
|
||||
#include "newgrf_object.h"
|
||||
#include "newgrf_roadstop.h"
|
||||
#include "newgrf_station.h"
|
||||
#include "zoom_func.h"
|
||||
|
||||
#include "widgets/toolbar_widget.h"
|
||||
|
||||
@@ -2145,6 +2146,8 @@ struct MainToolbarWindow : Window {
|
||||
|
||||
MainToolbarWindow(WindowDesc *desc) : Window(desc)
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
this->InitNested(0);
|
||||
|
||||
_last_started_action = CBF_NONE;
|
||||
@@ -2158,11 +2161,15 @@ struct MainToolbarWindow : Window {
|
||||
|
||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
||||
}
|
||||
|
||||
void OnPaint() override
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
/* If spectator, disable all construction buttons
|
||||
* ie : Build road, rail, ships, airports and landscaping
|
||||
* Since enabled state is the default, just disable when needed */
|
||||
@@ -2532,6 +2539,8 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
|
||||
ScenarioEditorToolbarWindow(WindowDesc *desc) : Window(desc)
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
this->InitNested(0);
|
||||
|
||||
_last_started_action = CBF_NONE;
|
||||
@@ -2544,11 +2553,15 @@ struct ScenarioEditorToolbarWindow : Window {
|
||||
|
||||
void FindWindowPlacementAndResize(int def_width, int def_height) override
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
||||
}
|
||||
|
||||
void OnPaint() override
|
||||
{
|
||||
MainToolbarScaleAdjuster scale_adjust;
|
||||
|
||||
this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= MIN_YEAR);
|
||||
this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= MAX_YEAR);
|
||||
this->SetWidgetDisabledState(WID_TE_ROADS, (GetRoadTypes(true) & ~_roadtypes_type) == ROADTYPES_NONE);
|
||||
@@ -2811,3 +2824,30 @@ void AllocateToolbar()
|
||||
new MainToolbarWindow(&_toolb_normal_desc);
|
||||
}
|
||||
}
|
||||
|
||||
static uint _toolbar_scale_adjuster_depth = 0;
|
||||
MainToolbarScaleAdjuster::MainToolbarScaleAdjuster()
|
||||
{
|
||||
_toolbar_scale_adjuster_depth++;
|
||||
if (_settings_client.gui.bigger_main_toolbar && _toolbar_scale_adjuster_depth == 1) {
|
||||
this->old_gui_zoom = _gui_zoom;
|
||||
this->old_gui_scale = _gui_scale;
|
||||
|
||||
/* Bump scale to next integer multiple */
|
||||
_gui_scale = Clamp(100 * ((_gui_scale / 100) + 1), MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE);
|
||||
|
||||
int8 new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X;
|
||||
_gui_zoom = static_cast<ZoomLevel>(Clamp(new_zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max));
|
||||
SetupWidgetDimensions();
|
||||
}
|
||||
}
|
||||
|
||||
MainToolbarScaleAdjuster::~MainToolbarScaleAdjuster()
|
||||
{
|
||||
_toolbar_scale_adjuster_depth--;
|
||||
if (_settings_client.gui.bigger_main_toolbar && _toolbar_scale_adjuster_depth == 0) {
|
||||
_gui_zoom = this->old_gui_zoom;
|
||||
_gui_scale = this->old_gui_scale;
|
||||
SetupWidgetDimensions();
|
||||
}
|
||||
}
|
||||
|
@@ -72,4 +72,12 @@ DropDownListItem *MakeCompanyDropDownListItem(CompanyID cid);
|
||||
|
||||
extern uint _toolbar_width;
|
||||
|
||||
struct MainToolbarScaleAdjuster {
|
||||
ZoomLevel old_gui_zoom;
|
||||
int old_gui_scale;
|
||||
|
||||
MainToolbarScaleAdjuster();
|
||||
~MainToolbarScaleAdjuster();
|
||||
};
|
||||
|
||||
#endif /* TOOLBAR_GUI_H */
|
||||
|
@@ -25,6 +25,7 @@ enum GameOptionsWidgets {
|
||||
WID_GO_GUI_SCALE, ///< GUI Scale slider.
|
||||
WID_GO_GUI_SCALE_AUTO, ///< Autodetect GUI scale button.
|
||||
WID_GO_GUI_SCALE_BEVEL_BUTTON, ///< Toggle for chunky bevels.
|
||||
WID_GO_GUI_SCALE_MAIN_TOOLBAR, ///< Toggle for bigger main toolbar.
|
||||
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
|
||||
WID_GO_BASE_GRF_STATUS, ///< Info about missing files etc.
|
||||
WID_GO_BASE_GRF_TEXTFILE, ///< Open base GRF readme, changelog (+1) or license (+2).
|
||||
|
@@ -3618,7 +3618,10 @@ void ReInitAllWindows(bool zoom_changed)
|
||||
|
||||
/* When _gui_zoom has changed, we need to resize toolbar and statusbar first,
|
||||
* so EnsureVisibleCaption uses the updated size information. */
|
||||
{
|
||||
MainToolbarScaleAdjuster toolbar_scale_adjuster;
|
||||
ReInitWindow(FindWindowById(WC_MAIN_TOOLBAR, 0), zoom_changed);
|
||||
}
|
||||
ReInitWindow(FindWindowById(WC_STATUS_BAR, 0), zoom_changed);
|
||||
for (Window *w : Window::IterateFromBack()) {
|
||||
if (w->window_class == WC_MAIN_TOOLBAR || w->window_class == WC_STATUS_BAR) continue;
|
||||
|
Reference in New Issue
Block a user