Fix mouse positioning when UI is scaled #83634
Open
+57
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Fix mouse positioning when UI is scaled"
Purpose of change
Fixes #80724
Also fixes a similar problem where the mouse view is showing details for the wrong tile when the UI is scaled.
Describe the solution
When the UI is scaled, both
input_context::get_coordinates_text()and the override ofinput_context::get_coordinates()in sdltiles.cpp ends up working with a mix of physical and logical coordinates and dimensions. The fix is to normalise everything to logical values before performing calculations.The logic gets a little more complicated because terrain and overmap are already in logical sizes and don't need the adjustment.
Describe alternatives you've considered
None, although I did wonder why
input_context::get_coordinates()is overridden in sdltiles.cpp andinput_context::get_coordinates_text()uses#if !defined( TILES )..#elseTesting
Loaded and game with 2x scaling and:
Repeated the same with no scaling to verify it's not broken by the fix.
Additional context
none