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
|
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
|
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
|
20100201
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -27,6 +27,7 @@ typedef enum event_type
|
||||||
EVENT_WINDOW_DEACTIVATED,
|
EVENT_WINDOW_DEACTIVATED,
|
||||||
EVENT_WINDOW_DRAW,
|
EVENT_WINDOW_DRAW,
|
||||||
EVENT_WINDOW_CLOSE,
|
EVENT_WINDOW_CLOSE,
|
||||||
|
EVENT_WINDOW_CLOSED,
|
||||||
EVENT_USER // spare for use by modules that use windows (e.g. newmenu)
|
EVENT_USER // spare for use by modules that use windows (e.g. newmenu)
|
||||||
} event_type;
|
} event_type;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ int window_close(window *wind)
|
||||||
{
|
{
|
||||||
window *prev;
|
window *prev;
|
||||||
d_event event;
|
d_event event;
|
||||||
|
int (*w_callback)(window *wind, d_event *event, void *data) = wind->w_callback;
|
||||||
|
|
||||||
event.type = EVENT_WINDOW_DEACTIVATED; // Deactivate first
|
event.type = EVENT_WINDOW_DEACTIVATED; // Deactivate first
|
||||||
window_send_event(wind, &event);
|
window_send_event(wind, &event);
|
||||||
|
@ -92,6 +93,10 @@ int window_close(window *wind)
|
||||||
}
|
}
|
||||||
|
|
||||||
d_free(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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
main/game.c
13
main/game.c
|
@ -22,6 +22,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#ifdef OGL
|
#ifdef OGL
|
||||||
#include "ogl_init.h"
|
#include "ogl_init.h"
|
||||||
|
@ -1161,6 +1162,7 @@ window *game_setup(void)
|
||||||
void game_render_frame();
|
void game_render_frame();
|
||||||
|
|
||||||
window *Game_wind = NULL;
|
window *Game_wind = NULL;
|
||||||
|
jmp_buf LeaveGame;
|
||||||
|
|
||||||
// Event handler for the game
|
// Event handler for the game
|
||||||
int game_handler(window *wind, d_event *event, void *data)
|
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
|
return 0; // continue closing
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVENT_WINDOW_CLOSED:
|
||||||
|
longjmp(LeaveGame, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1284,8 +1290,11 @@ void game()
|
||||||
{
|
{
|
||||||
Game_wind = game_setup();
|
Game_wind = game_setup();
|
||||||
|
|
||||||
while (Game_wind)
|
if (setjmp(LeaveGame) == 0)
|
||||||
event_process();
|
{
|
||||||
|
while (Game_wind)
|
||||||
|
event_process();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//called at the end of the program
|
//called at the end of the program
|
||||||
|
|
|
@ -214,7 +214,7 @@ void error_messagebox(char *s)
|
||||||
|
|
||||||
// Hide all windows so they don't interfere
|
// Hide all windows so they don't interfere
|
||||||
// Don't care about unfreed pointers on exit; trying to close the windows may cause problems
|
// 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);
|
window_set_visible(wind, 0);
|
||||||
|
|
||||||
nm_messagebox( TXT_SORRY, 1, TXT_OK, s );
|
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)
|
int newmenu_handler(window *wind, d_event *event, newmenu *menu)
|
||||||
{
|
{
|
||||||
|
if (event->type == EVENT_WINDOW_CLOSED)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (menu->subfunction)
|
if (menu->subfunction)
|
||||||
{
|
{
|
||||||
int rval = (*menu->subfunction)(menu, event, menu->userdata);
|
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)
|
int listbox_handler(window *wind, d_event *event, listbox *lb)
|
||||||
{
|
{
|
||||||
|
if (event->type == EVENT_WINDOW_CLOSED)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (lb->listbox_callback)
|
if (lb->listbox_callback)
|
||||||
{
|
{
|
||||||
int rval = (*lb->listbox_callback)(lb, event, lb->userdata);
|
int rval = (*lb->listbox_callback)(lb, event, lb->userdata);
|
||||||
|
|
Loading…
Reference in a new issue