projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added pushed objects going into acid (with compile time option)
[rocksndiamonds.git]
/
src
/
libgame
/
sdl.c
diff --git
a/src/libgame/sdl.c
b/src/libgame/sdl.c
index fca1e8b9f3e357c06f8ac4818344ed4f30efbaf0..04cfc0e739fbafa9ca8df4b92d94609e601ec28c 100644
(file)
--- a/
src/libgame/sdl.c
+++ b/
src/libgame/sdl.c
@@
-14,6
+14,7
@@
#include "joystick.h"
#include "misc.h"
#include "setup.h"
#include "joystick.h"
#include "misc.h"
#include "setup.h"
+#include "gadgets.h"
#define ENABLE_UNUSED_CODE 0 // currently unused functions
#define ENABLE_UNUSED_CODE 0 // currently unused functions
@@
-39,6
+40,7
@@
void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
#if defined(USE_TOUCH_INPUT_OVERLAY)
// functions to draw overlay graphics for touch device input
static void DrawTouchInputOverlay(void);
#if defined(USE_TOUCH_INPUT_OVERLAY)
// functions to draw overlay graphics for touch device input
static void DrawTouchInputOverlay(void);
+static void DrawTouchGadgetsOverlay(void);
#endif
void SDLLimitScreenUpdates(boolean enable)
#endif
void SDLLimitScreenUpdates(boolean enable)
@@
-212,18
+214,25
@@
static void UpdateScreenExt(SDL_Rect *rect, boolean with_frame_delay)
#if defined(USE_TOUCH_INPUT_OVERLAY)
// draw overlay graphics for touch device input, if needed
DrawTouchInputOverlay();
#if defined(USE_TOUCH_INPUT_OVERLAY)
// draw overlay graphics for touch device input, if needed
DrawTouchInputOverlay();
+
+ // draw overlay gadgets for touch device input, if needed
+ DrawTouchGadgetsOverlay();
#endif
// global synchronization point of the game to align video frame delay
if (with_frame_delay)
WaitUntilDelayReached(&video.frame_delay, video.frame_delay_value);
#endif
// global synchronization point of the game to align video frame delay
if (with_frame_delay)
WaitUntilDelayReached(&video.frame_delay, video.frame_delay_value);
+ video.frame_counter++;
+
// show render target buffer on screen
SDL_RenderPresent(sdl_renderer);
}
static void UpdateScreen_WithFrameDelay(SDL_Rect *rect)
{
// show render target buffer on screen
SDL_RenderPresent(sdl_renderer);
}
static void UpdateScreen_WithFrameDelay(SDL_Rect *rect)
{
+ PumpEvents(); // execute event filter actions while waiting
+
UpdateScreenExt(rect, TRUE);
}
UpdateScreenExt(rect, TRUE);
}
@@
-264,7
+273,7
@@
static void SDLSetWindowIcon(char *basename)
if ((surface = IMG_Load(filename)) == NULL)
{
if ((surface = IMG_Load(filename)) == NULL)
{
- Error(ERR_WARN, "IMG_Load(
) failed: %s"
, SDL_GetError());
+ Error(ERR_WARN, "IMG_Load(
'%s') failed: %s", basename
, SDL_GetError());
return;
}
return;
}
@@
-344,6
+353,11
@@
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
if (new_surface == NULL)
Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
if (new_surface == NULL)
Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
+ // workaround for a bug in SDL 2.0.12 (which does not convert the color key)
+ if (SDLHasColorKey(surface) && !SDLHasColorKey(new_surface))
+ SDL_SetColorKey(new_surface, SET_TRANSPARENT_PIXEL,
+ SDLGetColorKey(surface));
+
return new_surface;
}
return new_surface;
}
@@
-2230,7
+2244,8
@@
Bitmap *SDLLoadImage(char *filename)
// load image to temporary surface
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
// load image to temporary surface
if ((sdl_image_tmp = IMG_Load(filename)) == NULL)
- Error(ERR_EXIT, "IMG_Load() failed: %s", SDL_GetError());
+ Error(ERR_EXIT, "IMG_Load('%s') failed: %s", getBaseNamePtr(filename),
+ SDL_GetError());
print_timestamp_time("IMG_Load");
print_timestamp_time("IMG_Load");
@@
-2514,7
+2529,7
@@
static void setJoystickButton(int nr, int button_id_raw, int button_state)
void HandleJoystickEvent(Event *event)
{
void HandleJoystickEvent(Event *event)
{
- switch(event->type)
+ switch
(event->type)
{
case SDL_CONTROLLERDEVICEADDED:
#if DEBUG_JOYSTICKS
{
case SDL_CONTROLLERDEVICEADDED:
#if DEBUG_JOYSTICKS
@@
-2825,7
+2840,10
@@
static void DrawTouchInputOverlay_ShowGridButtons(int alpha)
continue;
if (grid_button == overlay.grid_button_highlight)
continue;
if (grid_button == overlay.grid_button_highlight)
- alpha_draw = alpha_highlight;
+ {
+ draw_outlined = FALSE;
+ alpha_draw = MIN((float)alpha_highlight * 1.5, SDL_ALPHA_OPAQUE);
+ }
if (draw_pressed && overlay.grid_button_action & grid_button_action)
{
if (draw_pressed && overlay.grid_button_action & grid_button_action)
{
@@
-2941,4
+2959,9
@@
static void DrawTouchInputOverlay(void)
DrawTouchInputOverlay_ShowGridButtons(alpha);
}
DrawTouchInputOverlay_ShowGridButtons(alpha);
}
+
+static void DrawTouchGadgetsOverlay(void)
+{
+ DrawGadgets_OverlayTouchButtons();
+}
#endif
#endif