mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
Change: Suppress panning in intro game, while user is interacting with the GUI. (#9645)
This commit is contained in:
parent
111a47af0d
commit
e8bff0ad03
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user