mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-16 00:24:53 -04:00
fix mouse controls in textscreen windows (#966)
SDL_RenderSetLogicalSize() automatically centers it
This commit is contained in:
parent
798ba2b507
commit
28a88c41dc
@ -378,19 +378,15 @@ void TXT_UpdateScreen(void)
|
|||||||
void TXT_GetMousePosition(int *x, int *y)
|
void TXT_GetMousePosition(int *x, int *y)
|
||||||
{
|
{
|
||||||
int window_w, window_h;
|
int window_w, window_h;
|
||||||
int origin_x, origin_y;
|
|
||||||
|
|
||||||
SDL_GetMouseState(x, y);
|
SDL_GetMouseState(x, y);
|
||||||
|
|
||||||
// Translate mouse position from 'pixel' position into character position.
|
// Translate mouse position from 'pixel' position into character position.
|
||||||
// We are working here in screen coordinates and not pixels, since this is
|
// We are working here in screen coordinates and not pixels, since this is
|
||||||
// what SDL_GetWindowSize() returns; we must calculate and subtract the
|
// what SDL_GetWindowSize() returns.
|
||||||
// origin position since we center the image within the window.
|
|
||||||
SDL_GetWindowSize(TXT_SDLWindow, &window_w, &window_h);
|
SDL_GetWindowSize(TXT_SDLWindow, &window_w, &window_h);
|
||||||
origin_x = (window_w - screen_image_w) / 2;
|
*x = ((*x) * TXT_SCREEN_W) / window_w;
|
||||||
origin_y = (window_h - screen_image_h) / 2;
|
*y = ((*y) * TXT_SCREEN_H) / window_h;
|
||||||
*x = ((*x - origin_x) * TXT_SCREEN_W) / screen_image_w;
|
|
||||||
*y = ((*y - origin_y) * TXT_SCREEN_H) / screen_image_h;
|
|
||||||
|
|
||||||
if (*x < 0)
|
if (*x < 0)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user