Option to disable mouse cursor for touchscreen devices

This commit is contained in:
Sergii Pylypenko
2021-05-11 01:05:10 +03:00
parent 8cccaceda8
commit 4d369cbeb2
6 changed files with 34 additions and 3 deletions

View File

@@ -1399,7 +1399,7 @@ void ScreenSizeChanged()
void UndrawMouseCursor()
{
/* Don't undraw mouse cursor if it is handled by the video driver. */
if (VideoDriver::GetInstance()->UseSystemCursor()) return;
if (VideoDriver::GetInstance()->UseSystemCursor() || !_settings_client.gui.draw_mouse_cursor) return;
/* Don't undraw the mouse cursor if the screen is not ready */
if (_screen.dst_ptr == nullptr) return;
@@ -1415,7 +1415,7 @@ void UndrawMouseCursor()
void DrawMouseCursor()
{
/* Don't draw mouse cursor if it is handled by the video driver. */
if (VideoDriver::GetInstance()->UseSystemCursor()) return;
if (VideoDriver::GetInstance()->UseSystemCursor() || !_settings_client.gui.draw_mouse_cursor) return;
/* Don't draw the mouse cursor if the screen is not ready */
if (_screen.dst_ptr == nullptr) return;

View File

@@ -1279,6 +1279,8 @@ STR_CONFIG_SETTING_VIDEO_16BPP :{BLACK}16 bit
STR_CONFIG_SETTING_VIDEO_16BPP_HELPTEXT :{BLACK}Set video color depth to 16 bits per pixel, this requires restart, this video mode does not support water animation
STR_CONFIG_SETTING_VIDEO_24BPP :{BLACK}24 bit
STR_CONFIG_SETTING_VIDEO_24BPP_HELPTEXT :{BLACK}Set video color depth to 24 bits per pixel, this video mode supports water animation
STR_CONFIG_SETTING_MOUSE_CURSOR :{BLACK}Mouse cursor
STR_CONFIG_SETTING_MOUSE_CURSOR_HELPTEXT :{BLACK}Show mouse cursor
STR_CONFIG_SETTING_SHOWFINANCES :Show finances window at the end of the year: {STRING2}
STR_CONFIG_SETTING_SHOWFINANCES_HELPTEXT :If enabled, the finances window pops up at the end of each year to allow easy inspection of the financial status of the company
STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT :New orders are 'non-stop' by default: {STRING2}

View File

@@ -521,6 +521,15 @@ struct GameOptionsWindow : Window {
#endif
break;
case WID_GO_MOUSE_CURSOR:
if (_settings_client.gui.draw_mouse_cursor) {
UndrawMouseCursor();
}
_settings_client.gui.draw_mouse_cursor = !_settings_client.gui.draw_mouse_cursor;
this->SetWidgetLoweredState(WID_GO_MOUSE_CURSOR, _settings_client.gui.draw_mouse_cursor);
this->SetDirty();
break;
case WID_GO_VIDEO_ACCEL_BUTTON:
_video_hw_accel = !_video_hw_accel;
ShowErrorMessage(STR_GAME_OPTIONS_VIDEO_ACCELERATION_RESTART, INVALID_STRING_ID, WL_INFO);
@@ -696,6 +705,7 @@ struct GameOptionsWindow : Window {
this->SetWidgetLoweredState(WID_GO_8BPP_BUTTON, _ini_blitter == "8bpp-optimized");
this->SetWidgetLoweredState(WID_GO_16BPP_BUTTON, _ini_blitter == "16bpp-simple");
this->SetWidgetLoweredState(WID_GO_32BPP_BUTTON, _ini_blitter == "32bpp-anim" || _ini_blitter == "");
this->SetWidgetLoweredState(WID_GO_MOUSE_CURSOR, _settings_client.gui.draw_mouse_cursor);
#if 0
#ifndef __APPLE__
@@ -734,7 +744,9 @@ static const NWidgetPart _nested_game_options_widgets[] = {
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_CONFIG_SETTING_WINDOWS_TITLEBARS, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_WINDOWS_TITLEBARS), SetMinimalSize(21, 9), SetDataTip(STR_CONFIG_SETTING_WINDOWS_TITLEBARS, STR_CONFIG_SETTING_WINDOWS_TITLEBARS_HELPTEXT), SetFill(1, 0),
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_CONFIG_SETTING_WINDOWS_TITLEBARS, STR_NULL),
NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_WINDOWS_TITLEBARS), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_CONFIG_SETTING_WINDOWS_TITLEBARS_HELPTEXT),
EndContainer(),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
@@ -749,6 +761,13 @@ static const NWidgetPart _nested_game_options_widgets[] = {
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_32BPP_BUTTON), SetMinimalSize(9, 9), SetDataTip(STR_CONFIG_SETTING_VIDEO_24BPP, STR_CONFIG_SETTING_VIDEO_24BPP_HELPTEXT),
EndContainer(),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_CONFIG_SETTING_MOUSE_CURSOR, STR_NULL),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXT, COLOUR_GREY), SetMinimalSize(0, 12), SetDataTip(STR_CONFIG_SETTING_MOUSE_CURSOR, STR_NULL),
NWidget(NWID_SPACER), SetMinimalSize(1, 0), SetFill(1, 0),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_GO_MOUSE_CURSOR), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_CONFIG_SETTING_MOUSE_CURSOR_HELPTEXT),
EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),

View File

@@ -98,6 +98,7 @@ struct GUISettings {
bool compact_vertical_toolbar; ///< compact mode for vertical toolbars, with more sub-menus
bool build_confirmation; ///< show confirmation dialog when building roads and stations
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

View File

@@ -2748,6 +2748,14 @@ str = STR_CONFIG_SETTING_WINDOWS_TITLEBARS
strhelp = STR_CONFIG_SETTING_WINDOWS_TITLEBARS_HELPTEXT
cat = SC_BASIC
[SDTC_BOOL]
var = gui.draw_mouse_cursor
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = true
str = STR_CONFIG_SETTING_MOUSE_CURSOR
strhelp = STR_CONFIG_SETTING_MOUSE_CURSOR_HELPTEXT
cat = SC_BASIC
[SDTC_BOOL]
var = gui.windows_decorations
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC

View File

@@ -27,6 +27,7 @@ enum GameOptionsWidgets {
WID_GO_VERTICAL_TOOLBAR, ///< Enable vertical toolbar.
WID_GO_BUILD_CONFIRMATION, ///< Enable build confirmation dialog.
WID_GO_WINDOWS_TITLEBARS, ///< Titlebars for all windows.
WID_GO_MOUSE_CURSOR, ///< Show mouse cursor.
WID_GO_GUI_ZOOM_DROPDOWN, ///< Dropdown for the GUI zoom level.
WID_GO_BASE_GRF_DROPDOWN, ///< Use to select a base GRF.
WID_GO_BASE_GRF_STATUS, ///< Info about missing files etc.