diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index ade7daad46..9957b38c1e 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -2122,5 +2122,5 @@ 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. +STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP :Show viewport tooltips for tiles without a right-click: {STRING2} +STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP_HELPTEXT :Show viewport tooltips for tile types such as industries without requiring a right-click, when the show tooltips setting is set to right-click. diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 74c3f6675e..9f355ee6e7 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -528,8 +528,7 @@ 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 || _settings_client.gui.instant_tile_tooltip) || _mouse_hovering)) { + if (pt.x != -1 && _game_mode != GM_MENU && IsViewportMouseHoverActive()) { /* 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 cd0ec409d6..42b0d26533 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1924,7 +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 ConditionallyHiddenSettingEntry("gui.instant_tile_tooltip", []() -> bool { return _settings_client.gui.hover_delay_ms != 0; })); 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/table/settings/settings.ini b/src/table/settings/settings.ini index 74865f0f86..44dccfe518 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -4543,11 +4543,12 @@ interval = 50 str = STR_CONFIG_SETTING_HOVER_DELAY strhelp = STR_CONFIG_SETTING_HOVER_DELAY_HELPTEXT strval = STR_CONFIG_SETTING_HOVER_DELAY_VALUE +post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); } [SDTC_BOOL] var = gui.instant_tile_tooltip flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC -def = true +def = false str = STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP strhelp = STR_CONFIG_SETTING_INSTANT_TILE_TOOLTIP_HELPTEXT diff --git a/src/viewport.cpp b/src/viewport.cpp index 8e35d546c4..ddd5312d04 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -6703,3 +6703,14 @@ int GetSlopeTreeBrightnessAdjust(Slope slope) return 0; } } + +bool IsViewportMouseHoverActive() +{ + if (_settings_client.gui.hover_delay_ms == 0) { + /* right click mode */ + return _right_button_down || _settings_client.gui.instant_tile_tooltip; + } else { + /* normal mode */ + return _mouse_hovering; + } +} diff --git a/src/viewport_func.h b/src/viewport_func.h index 82d6c59ad2..598eedf39b 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -170,4 +170,6 @@ void MarkBridgeDirty(TileIndex tile, ViewportMarkDirtyFlags flags = VMDF_NONE); void MarkBridgeOrTunnelDirty(TileIndex tile, ViewportMarkDirtyFlags flags = VMDF_NONE); void MarkBridgeOrTunnelDirtyOnReservationChange(TileIndex tile, ViewportMarkDirtyFlags flags = VMDF_NONE); +bool IsViewportMouseHoverActive(); + #endif /* VIEWPORT_FUNC_H */ diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 0d93705d02..feb961069d 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 || _settings_client.gui.instant_tile_tooltip) || _mouse_hovering)) { + if (pt.x != -1 && IsViewportMouseHoverActive()) { /* Show tooltip with last month production or town name */ const Point p = GetTileBelowCursor(); const TileIndex tile = TileVirtXY(p.x, p.y);