Move calls to ui_dialog_do_gadgets to the dialog event handler, making sure ui_event_handler gets called beforehand

This commit is contained in:
Chris Taylor 2011-10-09 20:30:31 +08:00
parent 8e0579c4a6
commit 87c8c25580
14 changed files with 20 additions and 56 deletions

View file

@ -5,6 +5,7 @@ D1X-Rebirth Changelog
main/render.c: Initialise dyn_light using memset, fixing a warning
arch/include/event.h, arch/include/window.h, arch/sdl/event.c, arch/sdl/window.c, include/ui.h, ui/dialog.c, ui/file.c, ui/keypress.c, ui/menu.c, ui/message.c, ui/popup.c: Add support for 'modeless' windows - windows that will allow events to be passed on to the underlying window. Intended for the editor
main/net_udp.c: Fix comparison is always false warning
editor/centers.c, editor/ehostage.c, editor/eswitch.c, editor/info.c, editor/med.c, editor/medrobot.c, editor/medwall.c, ui/dialog.c, ui/file.c, ui/keypress.c, ui/menu.c, ui/message.c, ui/popup.c: Move calls to ui_dialog_do_gadgets to the dialog event handler, making sure ui_event_handler gets called beforehand
20110927
--------

View file

@ -122,7 +122,6 @@ void do_centers_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MainWindow);
//------------------------------------------------------------
// If we change centers, we need to reset the ui code for all

View file

@ -401,7 +401,6 @@ void do_hostage_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MainWindow);
//------------------------------------------------------------
// If we change objects, we need to reset the ui code for all

View file

@ -388,7 +388,6 @@ void do_trigger_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MainWindow);
//------------------------------------------------------------
// If we change walls, we need to reset the ui code for all

View file

@ -317,6 +317,10 @@ int info_display_all(window *wind, d_event *event, void *userdata)
int padnum,show_all = 0;
grs_canvas *save_canvas = grd_curcanv;
// HACK: Make sure all the state-based input variables are set, until we fully migrate to event-based input
if (wind == window_get_front())
ui_event_handler(event);
switch (event->type)
{
case EVENT_WINDOW_DRAW:

View file

@ -1049,7 +1049,7 @@ void editor(void)
gamestate_restore_check();
set_default_handler(ui_event_handler);
//set_default_handler(ui_event_handler); // now we call this function first, not last, in event_process; through the dialog system
while (Function_mode == FMODE_EDITOR) {
@ -1068,7 +1068,6 @@ void editor(void)
gr_set_curfont(editor_font);
event_process();
last_keypress &= ~KEY_DEBUGGED; // mask off delete key bit which has no function in editor.
ui_dialog_do_gadgets(EditorWindow);
do_robot_window();
do_object_window();
do_wall_window();

View file

@ -564,7 +564,6 @@ void do_robot_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MainWindow);
//------------------------------------------------------------
// If we change objects, we need to reset the ui code for all
@ -795,7 +794,6 @@ void do_object_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MattWindow);
if ( QuitButton->pressed || (last_keypress==KEY_ESC)) {

View file

@ -408,7 +408,6 @@ void do_wall_window()
// Call the ui code..
//------------------------------------------------------------
ui_button_any_drawn = 0;
ui_dialog_do_gadgets(MainWindow);
//------------------------------------------------------------
// If we change walls, we need to reset the ui code for all

View file

@ -198,17 +198,7 @@ void remove_window( UI_DIALOG * dlg )
D_NEXT = D_PREV = NULL;
}
int ui_dialog_mouse(window *wind, d_event *event, UI_DIALOG *dlg)
{
return 0;
}
int ui_dialog_key(window *wind, d_event *event, UI_DIALOG *dlg)
{
return 0;
}
int ui_dialog_draw(window *wind, UI_DIALOG *dlg)
int ui_dialog_draw(UI_DIALOG *dlg)
{
return 0;
}
@ -219,6 +209,10 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
{
if (event->type == EVENT_WINDOW_CLOSED)
return 0;
// HACK: Make sure all the state-based input variables are set, until we fully migrate to event-based input
if (wind == window_get_front())
ui_event_handler(event);
if (dlg->callback)
if ((*dlg->callback)(dlg, event, dlg->userdata))
@ -234,17 +228,21 @@ int ui_dialog_handler(window *wind, d_event *event, UI_DIALOG *dlg)
case EVENT_MOUSE_BUTTON_DOWN:
case EVENT_MOUSE_BUTTON_UP:
return ui_dialog_mouse(wind, event, dlg);
/*return*/ ui_dialog_do_gadgets(dlg);
break;
case EVENT_KEY_COMMAND:
return ui_dialog_key(wind, event, dlg);
/*return*/ ui_dialog_do_gadgets(dlg);
break;
case EVENT_IDLE:
timer_delay2(50);
return ui_dialog_mouse(wind, event, dlg);
/*return*/ ui_dialog_do_gadgets(dlg);
break;
case EVENT_WINDOW_DRAW:
return ui_dialog_draw(wind, dlg);
return ui_dialog_draw(dlg);
break;
case EVENT_WINDOW_CLOSE:
//ui_close_dialog(dlg); // need to hide this function and make it not call window_close first
@ -665,13 +663,10 @@ void ui_mega_process()
}
#endif // 0
// Base level event handler
// Mainly for setting global variables for state-based event polling,
// For setting global variables for state-based event polling,
// which will eventually be replaced with direct event handling
// so we could then stick with standard_handler in inferno.c
int ui_event_handler(d_event *event)
{
timer_update();
last_keypress = 0;
switch (event->type)
@ -690,30 +685,6 @@ int ui_event_handler(d_event *event)
case EVENT_KEY_COMMAND:
last_keypress = event_key_get(event);
last_event = timer_query();
switch (last_keypress)
{
#ifdef macintosh
case KEY_COMMAND + KEY_SHIFTED + KEY_3:
#endif
case KEY_PRINT_SCREEN:
{
gr_set_current_canvas(NULL);
save_screen_shot(0);
return 1;
}
case KEY_ALTED+KEY_ENTER:
case KEY_ALTED+KEY_PADENTER:
gr_toggle_fullscreen();
return 1;
#ifndef NDEBUG
case KEY_BACKSP:
Int3();
return 1;
#endif
}
break;
case EVENT_IDLE:

View file

@ -195,7 +195,6 @@ int ui_get_filename( char * filename, char * Filespec, char * message )
while( 1 )
{
event_process();
ui_dialog_do_gadgets(dlg);
if ( Button2->pressed )
{

View file

@ -123,7 +123,6 @@ int GetKeyCode(char * text)
while(1)
{
event_process();
ui_dialog_do_gadgets(dlg);
if (last_keypress > 0)
{

View file

@ -100,7 +100,6 @@ int MenuX( int x, int y, int NumButtons, char * text[] )
while(choice==0)
{
event_process();
ui_dialog_do_gadgets(dlg);
for (i=0; i<NumButtons; i++ )
{

View file

@ -153,7 +153,6 @@ int MessageBoxN( short xc, short yc, int NumButtons, char * text, char * Button[
while(choice==0)
{
event_process();
ui_dialog_do_gadgets(dlg);
for (i=0; i<NumButtons; i++ )
{

View file

@ -122,7 +122,6 @@ int PopupMenu( int NumButtons, char * text[] )
while(choice==0)
{
event_process();
ui_dialog_do_gadgets(dlg);
for (i=0; i<NumButtons; i++ )
{