From fc16913116001a58866851920eb4d18a7be9ee5e Mon Sep 17 00:00:00 2001
From: "p.kosyh"
Date: Sun, 20 Feb 2011 15:24:41 +0000
Subject: [PATCH] SDL 1.3.0 workaround
---
src/sdl-instead/game.c | 11 +++++++++++
src/sdl-instead/graphics.c | 12 ++++++++++++
2 files changed, 23 insertions(+)
diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c
index 9458f2d..307285e 100644
--- a/src/sdl-instead/game.c
+++ b/src/sdl-instead/game.c
@@ -1149,7 +1149,18 @@ void game_menu_box_width(int show, const char *txt, int width)
menu = gfx_new(w + (b + pad)*2, h + (b + pad)*2);
gfx_img_fill(menu, 0, 0, w + (b + pad)*2, h + (b + pad)*2, game_theme.border_col);
gfx_img_fill(menu, b, b, w + pad*2, h + pad*2, game_theme.menu_bg);
+#if SDL_VERSION_ATLEAST(1,3,0)
+ do { /* hack while SDL 1.3.0 is not released */
+ img_t img2;
+ img2 = gfx_alpha_img(menu, game_theme.menu_alpha);
+ if (img2) {
+ gfx_free_image(menu);
+ menu = img2;
+ }
+ } while(0);
+#esle
gfx_set_alpha(menu, game_theme.menu_alpha);
+#endif
x = (game_theme.w - w)/2;
y = (game_theme.h - h)/2;
mx = x - b - pad;
diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c
index 4809fcf..38eda11 100644
--- a/src/sdl-instead/graphics.c
+++ b/src/sdl-instead/graphics.c
@@ -3638,9 +3638,21 @@ static void update_gfx(void *aux)
if (fade_step_nr == -1)
return;
game_cursor(CURSOR_CLEAR);
+#if SDL_VERSION_ATLEAST(1,3,0)
+ do { /* hack while SDL 1.3.0 is not released */
+ img_t img2;
+ img2 = gfx_alpha_img(img, (255 * (fade_step_nr + 1)) / ALPHA_STEPS);
+ if (img2) {
+ gfx_draw(fade_bg, 0, 0);
+ gfx_draw(img2, 0, 0);
+ gfx_free_image(img2);
+ }
+ }
+#else
gfx_set_alpha(img, (255 * (fade_step_nr + 1)) / ALPHA_STEPS);
gfx_draw(fade_bg, 0, 0);
gfx_draw(img, 0, 0);
+#endif
game_cursor(CURSOR_DRAW);
gfx_flip();
fade_step_nr ++;