X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=b85a8075114bd732ba0fac936786fa8b10f8d153;hb=f7704e2d22e9499efe6380e0c916c2bd4918e4be;hp=e478e8aaddb27df22630345f5385705f00492bdd;hpb=22f539028eb272b70d339e1f37552a2a89f37dd6;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index e478e8aa..b85a8075 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -15,6 +15,7 @@ #include "sound.h" #include "joystick.h" #include "misc.h" +#include "setup.h" #if defined(TARGET_SDL) @@ -60,6 +61,32 @@ static void setFullscreenParameters() } } +static void SDLSetWindowIcon(char *basename) +{ + char *filename = getCustomImageFilename(basename); + SDL_Surface *surface; + + if (filename == NULL) + { + Error(ERR_WARN, "SDLSetWindowIcon(): cannot find file '%s'", basename); + + return; + } + + if ((surface = IMG_Load(filename)) == NULL) + { + Error(ERR_WARN, "IMG_Load() failed: %s", SDL_GetError()); + + return; + } + + /* set transparent color */ + SDL_SetColorKey(surface, SDL_SRCCOLORKEY, + SDL_MapRGB(surface->format, 0x00, 0x00, 0x00)); + + SDL_WM_SetIcon(surface, NULL); +} + void SDLInitVideoDisplay(void) { putenv("SDL_VIDEO_CENTERED=1"); @@ -169,6 +196,9 @@ void SDLInitVideoBuffer(DrawBuffer **backbuffer, DrawWindow **window, } } + /* set window icon */ + SDLSetWindowIcon(program.sdl_icon_filename); + /* open SDL video output device (window or fullscreen mode) */ if (!SDLSetVideoMode(backbuffer, fullscreen)) Error(ERR_EXIT, "setting video mode failed"); @@ -324,8 +354,8 @@ void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap, SDL_UpdateRect(backbuffer->surface, dst_x, dst_y, width, height); } -void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, - int width, int height, Uint32 color) +void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, int width, int height, + Uint32 color) { Bitmap *real_dst_bitmap = (dst_bitmap == window ? backbuffer : dst_bitmap); SDL_Rect rect; @@ -347,8 +377,8 @@ void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, SDL_UpdateRect(backbuffer->surface, x, y, width, height); } -void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, - int post_delay) +void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height, + int fade_mode, int fade_delay, int post_delay) { static boolean initialization_needed = TRUE; static SDL_Surface *surface_screen_copy = NULL; @@ -356,8 +386,8 @@ void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, SDL_Surface *surface_screen = backbuffer->surface; SDL_Surface *surface_cross; /* initialized later */ SDL_Rect src_rect, dst_rect; - int src_x = 0, src_y = 0; - int dst_x = 0, dst_y = 0; + int src_x = x, src_y = y; + int dst_x = x, dst_y = y; boolean fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE); unsigned int time_last, time_current; float alpha; @@ -365,16 +395,16 @@ void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, src_rect.x = src_x; src_rect.y = src_y; - src_rect.w = video.width; - src_rect.h = video.height; + src_rect.w = width; + src_rect.h = height; dst_x += video_xoffset; dst_y += video_yoffset; dst_rect.x = dst_x; dst_rect.y = dst_y; - dst_rect.w = video.width; - dst_rect.h = video.height; + dst_rect.w = width; + dst_rect.h = height; #if 0 if (!initialization_needed) @@ -466,7 +496,11 @@ void SDLFadeScreen(Bitmap *bitmap_cross, int fade_mode, int fade_delay, SDL_BlitSurface(surface_cross, &src_rect, surface_screen, &dst_rect); /* draw screen buffer to visible display */ +#if 1 + SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height); +#else SDL_Flip(surface_screen); +#endif } Delay(post_delay); @@ -1465,6 +1499,7 @@ Bitmap *SDLLoadImage(char *filename) if ((sdl_image_tmp = IMG_Load(filename)) == NULL) { SetError("IMG_Load(): %s", SDL_GetError()); + return NULL; } @@ -1472,6 +1507,7 @@ Bitmap *SDLLoadImage(char *filename) if ((new_bitmap->surface = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + return NULL; } @@ -1481,6 +1517,7 @@ Bitmap *SDLLoadImage(char *filename) if ((new_bitmap->surface_masked = SDL_DisplayFormat(sdl_image_tmp)) == NULL) { SetError("SDL_DisplayFormat(): %s", SDL_GetError()); + return NULL; }