Put LeaveGame longjmp back, but in response to new EVENT_WINDOW_CLOSED, fixing demo issues; fix compiler error in last commit
This commit is contained in:
parent
0f6def2613
commit
98d5b76928
|
@ -4,6 +4,7 @@ D2X-Rebirth Changelog
|
|||
--------
|
||||
arch/include/event.h, arch/sdl/window.c, main/automap.c, main/dumpmine.c, main/editor/med.c, main/escort.c, main/game.c, main/gamecntl.c, main/gamesave.c, main/gameseq.c, main/kconfig.c, main/net_ipx.c, main/net_udp.c, main/newmenu.c: Add EVENT_WINDOW_DEACTIVATED; move many game_flush_inputs, start_time and stop_time calls to game_handler as well as digi_pause_digi_sounds and digi_resume_digi_sounds
|
||||
main/inferno.c: Hide all other windows before showing error dialog, hopefully so errors don't happen while the error dialog is there
|
||||
arch/include/event.h, arch/sdl/window.c, main/game.c, main/inferno.c, main/newmenu.c: Put LeaveGame longjmp back, but in response to new EVENT_WINDOW_CLOSED, fixing demo issues; fix compiler error in last commit
|
||||
|
||||
20100201
|
||||
--------
|
||||
|
|
|
@ -27,6 +27,7 @@ typedef enum event_type
|
|||
EVENT_WINDOW_DEACTIVATED,
|
||||
EVENT_WINDOW_DRAW,
|
||||
EVENT_WINDOW_CLOSE,
|
||||
EVENT_WINDOW_CLOSED,
|
||||
EVENT_USER // spare for use by modules that use windows (e.g. newmenu)
|
||||
} event_type;
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ int window_close(window *wind)
|
|||
{
|
||||
window *prev;
|
||||
d_event event;
|
||||
int (*w_callback)(window *wind, d_event *event, void *data) = wind->w_callback;
|
||||
|
||||
event.type = EVENT_WINDOW_DEACTIVATED; // Deactivate first
|
||||
window_send_event(wind, &event);
|
||||
|
@ -92,6 +93,10 @@ int window_close(window *wind)
|
|||
}
|
||||
|
||||
d_free(wind);
|
||||
|
||||
event.type = EVENT_WINDOW_CLOSED;
|
||||
w_callback(wind, &event, NULL); // callback needs to recognise this is a NULL pointer!
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#ifdef OGL
|
||||
#include "ogl_init.h"
|
||||
|
@ -1161,6 +1162,7 @@ window *game_setup(void)
|
|||
void game_render_frame();
|
||||
|
||||
window *Game_wind = NULL;
|
||||
jmp_buf LeaveGame;
|
||||
|
||||
// Event handler for the game
|
||||
int game_handler(window *wind, d_event *event, void *data)
|
||||
|
@ -1269,6 +1271,10 @@ int game_handler(window *wind, d_event *event, void *data)
|
|||
return 0; // continue closing
|
||||
break;
|
||||
|
||||
case EVENT_WINDOW_CLOSED:
|
||||
longjmp(LeaveGame, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
|
@ -1284,8 +1290,11 @@ void game()
|
|||
{
|
||||
Game_wind = game_setup();
|
||||
|
||||
if (setjmp(LeaveGame) == 0)
|
||||
{
|
||||
while (Game_wind)
|
||||
event_process();
|
||||
}
|
||||
}
|
||||
|
||||
//called at the end of the program
|
||||
|
|
|
@ -214,7 +214,7 @@ void error_messagebox(char *s)
|
|||
|
||||
// Hide all windows so they don't interfere
|
||||
// Don't care about unfreed pointers on exit; trying to close the windows may cause problems
|
||||
for (wind = window_get_front(), wind != NULL; wind = window_get_front())
|
||||
for (wind = window_get_front(); wind != NULL; wind = window_get_front())
|
||||
window_set_visible(wind, 0);
|
||||
|
||||
nm_messagebox( TXT_SORRY, 1, TXT_OK, s );
|
||||
|
|
|
@ -1248,6 +1248,9 @@ int newmenu_draw(window *wind, newmenu *menu)
|
|||
|
||||
int newmenu_handler(window *wind, d_event *event, newmenu *menu)
|
||||
{
|
||||
if (event->type == EVENT_WINDOW_CLOSED)
|
||||
return 0;
|
||||
|
||||
if (menu->subfunction)
|
||||
{
|
||||
int rval = (*menu->subfunction)(menu, event, menu->userdata);
|
||||
|
@ -1928,6 +1931,9 @@ int listbox_draw(window *wind, listbox *lb)
|
|||
|
||||
int listbox_handler(window *wind, d_event *event, listbox *lb)
|
||||
{
|
||||
if (event->type == EVENT_WINDOW_CLOSED)
|
||||
return 0;
|
||||
|
||||
if (lb->listbox_callback)
|
||||
{
|
||||
int rval = (*lb->listbox_callback)(lb, event, lb->userdata);
|
||||
|
|
Loading…
Reference in a new issue