ref: cf21a2e6eaceb08275be5be29f330078c69f8684
parent: 54ea6bebeb3effbfc25b3790f4b1d8c49fa441bd
author: Iliyas Jorio <iliyas@jor.io>
date: Sun Jan 8 14:48:02 EST 2023
Prefer system mouse cursor (for beyond pillarbox)
--- a/src/level.cpp
+++ b/src/level.cpp
@@ -84,6 +84,7 @@
extern MBoolean useNewTitle;
+#if USE_CURSOR_SPRITE
static void InsertCursor( MPoint mouseHere, SDL_Surface* scratch, SDL_Surface* surface )
{
SkittlesFontPtr cursorFont = GetFont( picFont );
@@ -114,6 +115,7 @@
SDLU_BlitSurface( scratch, &cursorBackSDLRect,
surface, &cursorFrontSDLRect );
}
+#endif
static void GameStartMenuRepaint()
{
@@ -126,7 +128,9 @@
// multiple times in a row, thanks to "redo". Put initializations after redo.
SDL_Surface* gameStartSurface;
SDL_Surface* gameStartDrawSurface;
+#if USE_CURSOR_SPRITE
SDL_Surface* cursorBackSurface;
+#endif
SDL_Rect backdropSDLRect = { 0, 0, 640, 480 };
SDL_Rect cursorBackSDLRect = { 0, 0, kCursorWidth, kCursorHeight };
SDL_Rect destSDLRect;
@@ -181,8 +185,12 @@
black = SDL_MapRGB( gameStartSurface->format, 0, 0, 0 );
// make cursor backing store
+#if USE_CURSOR_SPRITE
cursorBackSurface = SDLU_InitSurface( &cursorBackSDLRect, 32 );
SDL_FillRect( cursorBackSurface, &cursorBackSDLRect, black );
+#else
+ SDL_ShowCursor( 1 );
+#endif
// make drawing surface
gameStartDrawSurface = SDLU_InitSurface( &backdropSDLRect, 32 );
@@ -279,11 +287,13 @@
SDLU_AcquireSurface( gameStartDrawSurface );
// Take the cursor out of the scene
+#if USE_CURSOR_SPRITE
RemoveCursor( mouse, cursorBackSurface, gameStartDrawSurface );
drawRect[kCursor].top = mouse.v;
drawRect[kCursor].left = mouse.h;
drawRect[kCursor].bottom = mouse.v + kCursorHeight;
drawRect[kCursor].right = mouse.h + kCursorWidth;
+#endif
// Inverted rectangles mean "nothing to do."
drawRect[kLeftSide].top = drawRect[kRightSide].top = drawRect[kGlow].top =
@@ -486,11 +496,13 @@
}
// Reinsert the cursor into the scene
+#if USE_CURSOR_SPRITE
InsertCursor( mouse, cursorBackSurface, gameStartDrawSurface );
drawRect[kCursor].top = min<short>( drawRect[kCursor].top, mouse.v );
drawRect[kCursor].left = min<short>( drawRect[kCursor].left, mouse.h );
drawRect[kCursor].bottom = max<short>( drawRect[kCursor].bottom, mouse.v + kCursorHeight );
drawRect[kCursor].right = max<short>( drawRect[kCursor].right, mouse.h + kCursorWidth );
+#endif
// Copy down everything
if( shouldFullRepaint )
@@ -534,6 +546,12 @@
{
selected = kTitleItemQuit;
}
+ else
+ {
+#if !USE_CURSOR_SPRITE
+ SDL_ShowCursor( 0 );
+#endif
+ }
switch( selected )
{
@@ -547,7 +565,9 @@
SDL_FreeSurface( gameStartSurface );
SDL_FreeSurface( gameStartDrawSurface );
+#if USE_CURSOR_SPRITE
SDL_FreeSurface( cursorBackSurface );
+#endif
QuickFadeOut( NULL );
binary files a/src/main.cpp b/src/main.cpp differ
--- a/src/pause.cpp
+++ b/src/pause.cpp
@@ -462,6 +462,7 @@
return animationStageComplete;
}
+#if USE_CURSOR_SPRITE
static void DrawDialogCursor( MRect *pauseRect, int *shade )
{
MPoint p, q;
@@ -482,6 +483,7 @@
SDLU_ReleaseSurface( drawSurface );
}
+#endif
static void DrawDialogLogo( MRect *pauseRect, int shade )
{
@@ -1051,6 +1053,10 @@
lastPauseRect.bottom = lastPauseRect.right = -9999;
SDLU_StartWatchingTyping();
+
+#if !USE_CURSOR_SPRITE
+ SDL_ShowCursor( 1 );
+#endif
DoFullRepaint = ItsTimeToRedraw;
@@ -1076,6 +1082,10 @@
if( DialogSelected[dialogType]( &dialogItem, inASCII, inSDLKey ) )
{
+#if !USE_CURSOR_SPRITE
+ SDL_ShowCursor( 0 );
+#endif
+
dialogStage = kClosing;
dialogTarget = 0;
}
@@ -1121,9 +1131,11 @@
// ... and animation is complete so add content
DialogDraw[dialogType]( &dialogItem, dialogShade );
-
+
+#if USE_CURSOR_SPRITE
// ... and cursor
DrawDialogCursor( &pauseRect, &dialogShade );
+#endif
}
SurfaceCurveEdges( drawSurface, &pauseRect );