Allow user to abort close, for whatever reason (helps with my next commit)

This commit is contained in:
kreatordxx 2010-01-28 04:53:56 +00:00
parent f6c32d7518
commit 5d3ea4051f
2 changed files with 25 additions and 13 deletions

View file

@ -6,6 +6,7 @@ main/playsave.c, main/playsave.h, main/object.c, main/render.c, main/hostage.c,
main/newdemo.c: Added a new code to properly re-record view/cockpit-events at beginning and end of Demo recording so views will be fine if switched before recording started; Also added lost sequence to record Rear-view reset between levels; Everything done without breaking the Demo format!
arch/sdl/window.c, main/automap.c, main/escort.c, main/game.c, main/gamecntl.c, main/kconfig.c, main/menu.c, main/net_ipx.c, main/net_udp.c, main/newmenu.c: Make response to EVENT_WINDOW_CLOSE conform to 'handling' system - returning 1 means abort closing
main/kconfig.c, main/newmenu.c: Tidy up newmenu_show/hide_cursor calls
main/newmenu.c: Allow user to abort close, for whatever reason (helps with my next commit)
20100127
--------

View file

@ -1250,9 +1250,9 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu)
break;
case EVENT_WINDOW_CLOSE:
// Don't allow cancel here - handle item selected events / key events instead
if (menu->subfunction)
(*menu->subfunction)(menu, event, menu->userdata);
if ((*menu->subfunction)(menu, event, menu->userdata))
return 1; // abort close
newmenu_hide_cursor();
game_flush_inputs();
@ -1263,7 +1263,7 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu)
if ( menu->sound_stopped )
digi_resume_digi_sounds();
// d_free(menu); // have to wait until newmenus use a separate event loop
d_free(menu);
return 0; // continue closing
break;
@ -1579,12 +1579,17 @@ int newmenu_do4( char * title, char * subtitle, int nitems, newmenu_item * item,
// All newmenus get their own event loop, for now.
while (!menu->done)
{
event_process();
if (menu->done)
{
rval = menu->citem;
if (!window_close(wind))
menu->done = 0; // user aborted close
}
}
window_close(wind);
rval = menu->citem;
d_free(menu);
return rval;
}
@ -1950,11 +1955,12 @@ int listbox_handler(window *wind, d_event *event, listbox *lb)
break;
case EVENT_WINDOW_CLOSE:
// Don't allow cancel here - handle item selected events / key events instead
if (lb->listbox_callback)
(*lb->listbox_callback)(lb, event, lb->userdata);
if ((*lb->listbox_callback)(lb, event, lb->userdata))
return 1; // abort close
newmenu_hide_cursor();
d_free(lb);
return 0; // continue closing
break;
@ -2037,12 +2043,17 @@ int newmenu_listbox1( char * title, int nitems, char * items[], int allow_abort_
lb->mouse_state = lb->omouse_state = 0; //dblclick_flag = 0;
while(!lb->done)
{
event_process();
if (lb->done)
{
rval = lb->citem;
if (!window_close(wind))
lb->done = 0; // user aborted close
}
}
window_close(wind);
rval = lb->citem;
d_free(lb);
return rval;
}