From e8bff0ad03550a65f3575375ffec22d9a4426afb Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 23 Oct 2021 15:13:39 +0200 Subject: Change: Suppress panning in intro game, while user is interacting with the GUI. (#9645) --- src/intro_gui.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 8d11a2bb3..fe19ec063 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -102,6 +102,8 @@ struct SelectGameWindow : public Window { size_t cur_viewport_command_index; /** Time spent (milliseconds) on current viewport command. */ uint cur_viewport_command_time; + uint mouse_idle_time; + Point mouse_idle_pos; /** * Find and parse all viewport command signs. @@ -181,6 +183,8 @@ struct SelectGameWindow : public Window { this->cur_viewport_command_index = (size_t)-1; this->cur_viewport_command_time = 0; + this->mouse_idle_time = 0; + this->mouse_idle_pos = _cursor.pos; } void OnRealtimeTick(uint delta_ms) override @@ -189,6 +193,17 @@ struct SelectGameWindow : public Window { if (intro_viewport_commands.empty()) return; + bool suppress_panning = true; + if (this->mouse_idle_pos.x != _cursor.pos.x || this->mouse_idle_pos.y != _cursor.pos.y) { + this->mouse_idle_pos = _cursor.pos; + this->mouse_idle_time = 2000; + } else if (this->mouse_idle_time > delta_ms) { + this->mouse_idle_time -= delta_ms; + } else { + this->mouse_idle_time = 0; + suppress_panning = false; + } + /* Determine whether to move to the next command or stay at current. */ bool changed_command = false; if (this->cur_viewport_command_index >= intro_viewport_commands.size()) { @@ -212,6 +227,9 @@ struct SelectGameWindow : public Window { /* Early exit if the current command hasn't elapsed and isn't animated. */ if (!changed_command && !vc.pan_to_next && vc.vehicle == INVALID_VEHICLE) return; + /* Suppress panning commands, while user interacts with GUIs. */ + if (!changed_command && suppress_panning) return; + /* Reset the zoom level. */ if (changed_command) FixTitleGameZoom(vc.zoom_adjust); -- cgit v1.2.3-54-g00ecf