This commit is contained in:
p.kosyh 2010-01-21 13:30:10 +00:00
parent cbb9d292b8
commit aa8e6016d9
3 changed files with 13 additions and 10 deletions

View file

@ -1515,7 +1515,7 @@ static struct el *old_el = NULL;
int game_paused(void) int game_paused(void)
{ {
return menu_shown || use_xref || old_xref; return menu_shown || use_xref || old_xref || (fade_step_nr != -1);
} }
void menu_update(struct el *elem) void menu_update(struct el *elem)

View file

@ -2698,28 +2698,28 @@ void gfx_warp_cursor(int x, int y)
SDL_WarpMouse(x, y); SDL_WarpMouse(x, y);
} }
#define ALPHA_STEPS 5 #define ALPHA_STEPS 5
volatile int step_nr = -1; int fade_step_nr = -1;
static void update_gfx(void *aux) static void update_gfx(void *aux)
{ {
img_t img = (img_t) aux; img_t img = (img_t) aux;
if (step_nr == -1) if (fade_step_nr == -1)
return; return;
game_cursor(CURSOR_CLEAR); game_cursor(CURSOR_CLEAR);
gfx_set_alpha(img, (255 * (step_nr + 1)) / ALPHA_STEPS); gfx_set_alpha(img, (255 * (fade_step_nr + 1)) / ALPHA_STEPS);
gfx_draw(img, 0, 0); gfx_draw(img, 0, 0);
game_cursor(CURSOR_DRAW); game_cursor(CURSOR_DRAW);
gfx_flip(); gfx_flip();
step_nr ++; fade_step_nr ++;
if (step_nr == ALPHA_STEPS) { if (fade_step_nr == ALPHA_STEPS) {
step_nr = -1; fade_step_nr = -1;
} }
} }
static Uint32 update(Uint32 interval, void *aux) static Uint32 update(Uint32 interval, void *aux)
{ {
push_user_event(update_gfx, aux); push_user_event(update_gfx, aux);
return interval; return interval;
} }
extern void nsleep(int delay); extern void nsleep(int delay);
@ -2729,9 +2729,9 @@ void gfx_change_screen(img_t src)
struct inp_event ev; struct inp_event ev;
memset(&ev, 0, sizeof(ev)); memset(&ev, 0, sizeof(ev));
SDL_TimerID han; SDL_TimerID han;
step_nr = 0; fade_step_nr = 0;
han = SDL_AddTimer(60, update, src); han = SDL_AddTimer(60, update, src);
while (input(&ev, 1) >=0 && step_nr != -1) /* just wait for change */ while (input(&ev, 1) >=0 && fade_step_nr != -1) /* just wait for change */
game_cursor(CURSOR_ON); game_cursor(CURSOR_ON);
SDL_RemoveTimer(han); SDL_RemoveTimer(han);
} }

View file

@ -11,6 +11,9 @@ typedef struct {
int g; int g;
int b; int b;
} color_t; } color_t;
extern int fade_step_nr;
#define ALIGN_LEFT 1 #define ALIGN_LEFT 1
#define ALIGN_RIGHT 2 #define ALIGN_RIGHT 2
#define ALIGN_CENTER 4 #define ALIGN_CENTER 4