diff --git a/src/blupi.cxx b/src/blupi.cxx index 461fbd2..13cc9b4 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -877,7 +877,7 @@ DoInit (int argc, char * argv[], bool & exit) } // Load all cursors - g_pPixmap->LoadCursors (); + g_pPixmap->LoadCursors (g_windowScale); g_pPixmap->ChangeSprite (SPRITE_WAIT); // met le sablier maison // Create the sound manager. diff --git a/src/event.cxx b/src/event.cxx index 3ccc8fe..60fda46 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -1657,6 +1657,7 @@ CEvent::SetFullScreen (bool bFullScreen) SDL_SetWindowPosition ( g_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + m_pPixmap->LoadCursors (m_WindowScale); m_pPixmap->ReloadTargetTextures (); /* Force this update before otherwise the coordinates retrieved with @@ -1715,6 +1716,7 @@ CEvent::SetWindowSize (Uint8 prevScale, Uint8 newScale) SDL_SetWindowPosition ( g_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); + m_pPixmap->LoadCursors (newScale); m_pPixmap->ReloadTargetTextures (); /* Force this update before otherwise the coordinates retrieved with diff --git a/src/pixmap.cxx b/src/pixmap.cxx index 23c6c1c..627744c 100644 --- a/src/pixmap.cxx +++ b/src/pixmap.cxx @@ -770,7 +770,7 @@ CPixmap::GetCursorRect (MouseSprites sprite) } void -CPixmap::LoadCursors () +CPixmap::LoadCursors (Uint8 scale) { Uint32 rmask, gmask, bmask, amask; @@ -791,16 +791,20 @@ on the endianness (byte order) of the machine */ for (int i = SPRITE_BEGIN; i <= SPRITE_END; ++i) { MouseSprites sprite = static_cast (i); + + if (m_lpSDLCursors[sprite - 1]) + SDL_FreeCursor (m_lpSDLCursors[sprite - 1]); + SDL_Point hotspot = this->GetCursorHotSpot (sprite); SDL_Rect rect = this->GetCursorRect (sprite); - SDL_Surface * surface = - SDL_CreateRGBSurface (0, rect.w, rect.h, 32, rmask, gmask, bmask, amask); - SDL_BlitSurface (m_lpSDLBlupi, &rect, surface, nullptr); + SDL_Surface * surface = SDL_CreateRGBSurface ( + 0, rect.w * scale, rect.h * scale, 32, rmask, gmask, bmask, amask); + SDL_BlitScaled (m_lpSDLBlupi, &rect, surface, nullptr); // FIXME: change cursor first value to 0 m_lpSDLCursors[sprite - 1] = - SDL_CreateColorCursor (surface, hotspot.x, hotspot.y); + SDL_CreateColorCursor (surface, hotspot.x * scale, hotspot.y * scale); SDL_FreeSurface (surface); } } diff --git a/src/pixmap.h b/src/pixmap.h index 0777281..82d23bd 100644 --- a/src/pixmap.h +++ b/src/pixmap.h @@ -85,7 +85,7 @@ public: void SetMouseSprite (MouseSprites sprite); void MouseShow (bool bShow); - void LoadCursors (); + void LoadCursors (Uint8 scale); void ChangeSprite (MouseSprites sprite); protected: