From 829db8e4f942068d283c42c40aee01c425094890 Mon Sep 17 00:00:00 2001 From: RoqueDeicide Date: Sat, 24 Jun 2023 21:00:21 +0400 Subject: [PATCH] Feature: A setting to bring back old tile tooltip behavior. If enabled, the setting allows tooltips for tiles, such as industries, to show instantly, when otherwise they would require a right-click. --- src/lang/extra/english.txt | 3 +++ src/main_gui.cpp | 3 ++- src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings/settings.ini | 7 +++++++ src/viewport_gui.cpp | 2 +- 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 12b956dbc8..ade7daad46 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -2121,3 +2121,6 @@ STR_TOWN_DIRECTORY_INFO :{BLACK}{STRING1 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 + +STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP :Show tooltips for tiles without a right-click: {STRING2} +STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP_HELPTEXT :Allow tooltips for tiles, such as industries, to show without the need for a right-click, if latter is set to be necessary for all tooltips. diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 373d1a7f96..74c3f6675e 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -528,7 +528,8 @@ struct MainWindow : Window virtual void OnMouseOver(Point pt, int widget) override { - if (pt.x != -1 && _game_mode != GM_MENU && (_settings_client.gui.hover_delay_ms == 0 ? _right_button_down : _mouse_hovering)) { + if (pt.x != -1 && _game_mode != GM_MENU && + (_settings_client.gui.hover_delay_ms == 0 && (_right_button_down || _settings_client.gui.instant_tile_tooltip) || _mouse_hovering)) { /* Show tooltip with last month production or town name */ const Point p = GetTileBelowCursor(); const TileIndex tile = TileVirtXY(p.x, p.y); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4190b563fe..cd0ec409d6 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1924,6 +1924,7 @@ static SettingsContainer &GetSettingsTree() { general->Add(new SettingEntry("gui.osk_activation")); general->Add(new SettingEntry("gui.hover_delay_ms")); + general->Add(new SettingEntry("gui.instant_tile_tooltip")); general->Add(new SettingEntry("gui.errmsg_duration")); general->Add(new SettingEntry("gui.window_snap_radius")); general->Add(new SettingEntry("gui.window_soft_limit")); diff --git a/src/settings_type.h b/src/settings_type.h index 40bac7f2e2..3cf3bd98ce 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -132,6 +132,7 @@ struct GUISettings : public TimeSettings { uint8 auto_scrolling; ///< scroll when moving mouse to the edge (see #ViewportAutoscrolling) byte errmsg_duration; ///< duration of error message uint16 hover_delay_ms; ///< time required to activate a hover event, in milliseconds + bool instant_tile_tooltip; ///< don't require a right click to activate a hover event to show a tooltip for an in-game tile (e.g. industry). bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap uint8 scroll_mode; ///< viewport scroll mode diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index cf8250ceb6..74865f0f86 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -4544,6 +4544,13 @@ str = STR_CONFIG_SETTING_HOVER_DELAY strhelp = STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT strval = STR_CONFIG_SETTING_HOVER_DELAY_VALUE +[SDTC_BOOL] +var = gui.instant_tile_tooltip +flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC +def = true +str = STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP +strhelp = STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP_HELPTEXT + [SDTC_OMANY] var = gui.osk_activation type = SLE_UINT8 diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 80bdddc7e7..0d93705d02 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -158,7 +158,7 @@ public: virtual void OnMouseOver(Point pt, int widget) override { - if (pt.x != -1 && (_settings_client.gui.hover_delay_ms == 0 ? _right_button_down : _mouse_hovering)) { + if (pt.x != -1 && (_settings_client.gui.hover_delay_ms == 0 && (_right_button_down || _settings_client.gui.instant_tile_tooltip) || _mouse_hovering)) { /* Show tooltip with last month production or town name */ const Point p = GetTileBelowCursor(); const TileIndex tile = TileVirtXY(p.x, p.y);