Changeset - r26040:50e1bbc159a7
[Not reviewed]
master
0 1 0
frosch - 3 years ago 2021-10-23 13:13:39
frosch@openttd.org
Change: Suppress panning in intro game, while user is interacting with the GUI. (#9645)
1 file changed with 18 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/intro_gui.cpp
Show inline comments
 
@@ -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);
 

	
0 comments (0 inline, 0 general)