Changeset - r27486:1f3330e09b1a
[Not reviewed]
master
0 1 0
Patric Stout - 15 months ago 2023-06-03 21:09:41
truebrain@openttd.org
Codechange: simplify UpdateCursorPositionRelative

The function is only called with fix_at=true, so don't support
the other cases.
1 file changed with 5 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1880,27 +1880,17 @@ void SetAnimatedMouseCursor(const AnimCu
 
}
 

	
 
/**
 
 * Update cursor position on mouse movement for relative modes.
 
 * Update cursor position based on a relative change.
 
 *
 
 * @param delta_x How much change in the X position.
 
 * @param delta_y How much change in the Y position.
 
 */
 
void CursorVars::UpdateCursorPositionRelative(int delta_x, int delta_y)
 
{
 
	if (this->fix_at) {
 
		this->delta.x = delta_x;
 
		this->delta.y = delta_y;
 
	} else {
 
		int last_position_x = this->pos.x;
 
		int last_position_y = this->pos.y;
 
	assert(this->fix_at);
 

	
 
		this->pos.x = Clamp(this->pos.x + delta_x, 0, _cur_resolution.width - 1);
 
		this->pos.y = Clamp(this->pos.y + delta_y, 0, _cur_resolution.height - 1);
 

	
 
		this->delta.x = last_position_x - this->pos.x;
 
		this->delta.y = last_position_y - this->pos.y;
 

	
 
		this->dirty = true;
 
	}
 
	this->delta.x = delta_x;
 
	this->delta.y = delta_y;
 
}
 

	
 
/**
0 comments (0 inline, 0 general)