aboutsummaryrefslogtreecommitdiff
path: root/nestedvm.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2017-10-28 08:55:33 +0100
committerSimon Tatham <anakin@pobox.com>2017-10-28 09:04:39 +0100
commit6da8dc91a2c1ecd5cc7e02bc63d1404bf80382f9 (patch)
tree3742708560769f84fb53aa6677166ec9a3807c44 /nestedvm.c
parentefcc00ffefa34b2c4048e560099814c19a064ba5 (diff)
downloadpuzzles-6da8dc91a2c1ecd5cc7e02bc63d1404bf80382f9.zip
puzzles-6da8dc91a2c1ecd5cc7e02bc63d1404bf80382f9.tar.gz
puzzles-6da8dc91a2c1ecd5cc7e02bc63d1404bf80382f9.tar.bz2
puzzles-6da8dc91a2c1ecd5cc7e02bc63d1404bf80382f9.tar.xz
Map: stop storing pixel coordinates in game_ui.
The fields (ui->dragx,ui->dragy) stored the pixel coordinates of the visible cursor (if any), no matter whether that cursor was being displayed in response to a mouse dragging action or arrow-key activity. But this meant that resizing the window while the keyboard cursor was visible would cause the cursor to be drawn in totally the wrong place in the newly resized window: you get a new drawstate with a fresh blitter (so at least no part of the old-size window is accidentally 'restored' on to the new-size one), but the ui fields saying where _next_ to draw the cursor would still have bogus values left over from the previous window size. To fix this, I've arranged that we simply don't use ui->dragx and ui->dragy any more in keyboard cursor mode: instead, we leave it to game_redraw to spot that the keyboard cursor is visible and compute its pixel coordinates for display. A knock-on effect is that when we need to know which region is under the cursor during interpret_move, we can't use the previous strategy of just calling region_from_coords(ui->dragx, ui->dragy) regardless of which kind of cursor is active. So I've split that function up into an inner section taking a tile and a displacement from the tile's centre and an outer part which derives those from real pixel coordinates in the case where the cursor is originating from a mouse drag; then there's a new alternative outer part which derives the same (tile, displacement) pair purely from the game_ui keyboard cursor data without having to explicitly translate into pixels and back in the middle. Probably a less fragile strategy anyway.
Diffstat (limited to 'nestedvm.c')
0 files changed, 0 insertions, 0 deletions