mirror of
https://github.com/blupi-games/planetblupi
synced 2024-12-30 10:15:36 +01:00
Adapt the mouse cursor size according to the zoom
This commit is contained in:
parent
e0ace88195
commit
1b242ca3aa
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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<MouseSprites> (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);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
|
||||
void SetMouseSprite (MouseSprites sprite);
|
||||
void MouseShow (bool bShow);
|
||||
void LoadCursors ();
|
||||
void LoadCursors (Uint8 scale);
|
||||
void ChangeSprite (MouseSprites sprite);
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user