summaryrefslogtreecommitdiff
path: root/src/intro_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2021-10-23 15:13:39 +0200
committerGitHub <noreply@github.com>2021-10-23 15:13:39 +0200
commite8bff0ad03550a65f3575375ffec22d9a4426afb (patch)
tree8e9ce1238b6977fae4c8f1d92ba370a137c43d33 /src/intro_gui.cpp
parent111a47af0d0bb37b421eb8a77f1f8e69d38bbe3c (diff)
downloadopenttd-e8bff0ad03550a65f3575375ffec22d9a4426afb.tar.xz
Change: Suppress panning in intro game, while user is interacting with the GUI. (#9645)
Diffstat (limited to 'src/intro_gui.cpp')
-rw-r--r--src/intro_gui.cpp18
1 files changed, 18 insertions, 0 deletions
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);