diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5c2244395..4de06674f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,9 @@ D1X-Rebirth Changelog +20100120 +-------- +arch/include/event.h, arch/sdl/event.c, arch/sdl/window.c, main/automap.c, main/game.c, main/gamecntl.c, main/kconfig.c, main/menu.c, main/net_ipx.c, main/net_udp.c, main/newmenu.c, main/state.c: Add EVENT_WINDOW_ACTIVATED, change EVENT_DRAW to EVENT_WINDOW_DRAW and EVENT_CLOSE to EVENT_WINDOW_CLOSE + 20100119 -------- main/net_ipx.c, main/net_udp.c: Make net_ipx_show_game_rules and net_udp_show_game_rules into windows diff --git a/arch/include/event.h b/arch/include/event.h index e3be95c88..bdad6f9c4 100644 --- a/arch/include/event.h +++ b/arch/include/event.h @@ -7,8 +7,9 @@ typedef enum event_type { EVENT_IDLE = 0, EVENT_KEY_COMMAND, - EVENT_DRAW, - EVENT_CLOSE, + EVENT_WINDOW_ACTIVATED, + EVENT_WINDOW_DRAW, + EVENT_WINDOW_CLOSE, EVENT_USER // spare for use by modules that use windows (e.g. newmenu) } event_type; diff --git a/arch/sdl/event.c b/arch/sdl/event.c index b3609a563..b1d13243a 100644 --- a/arch/sdl/event.c +++ b/arch/sdl/event.c @@ -88,7 +88,7 @@ void event_process(void) window_send_event(wind, &event); - event.type = EVENT_DRAW; // then draw all visible windows + event.type = EVENT_WINDOW_DRAW; // then draw all visible windows for (wind = window_get_first(); wind != NULL; wind = window_get_next(wind)) if (window_is_visible(wind)) window_send_event(wind, &event); diff --git a/arch/sdl/window.c b/arch/sdl/window.c index de7940b8f..5f76aa0ec 100644 --- a/arch/sdl/window.c +++ b/arch/sdl/window.c @@ -29,6 +29,7 @@ static window *FirstWindow = NULL; window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_callback)(window *wind, d_event *event, void *data), void *data) { window *wind; + d_event event = { EVENT_WINDOW_ACTIVATED }; wind = d_malloc(sizeof(window)); if (wind == NULL) @@ -48,6 +49,7 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c FrontWindow->next = wind; wind->next = NULL; FrontWindow = wind; + window_send_event(wind, &event); return wind; } @@ -56,13 +58,22 @@ int window_close(window *wind) { d_event event; - event.type = EVENT_CLOSE; + event.type = EVENT_WINDOW_CLOSE; if (!window_send_event(wind, &event)) return 0; // user cancelled close (e.g. clicked 'No' to abort box) if (wind == FrontWindow) + { FrontWindow = wind->prev; + if (window_is_visible(wind)) + { + window *w2; + event.type = EVENT_WINDOW_ACTIVATED; + if ((w2 = window_get_front())) + window_send_event(w2, &event); + } + } if (wind == FirstWindow) FirstWindow = wind->next; if (wind->next) @@ -97,6 +108,8 @@ window *window_get_next(window *wind) // Make wind the front window void window_select(window *wind) { + d_event event = { EVENT_WINDOW_ACTIVATED }; + Assert (wind != NULL); if (wind == FrontWindow) @@ -111,11 +124,18 @@ void window_select(window *wind) wind->prev = FrontWindow; wind->next = NULL; FrontWindow = wind; + + if (window_is_visible(wind)) + window_send_event(wind, &event); } void window_set_visible(window *wind, int visible) { + d_event event = { EVENT_WINDOW_ACTIVATED }; + wind->w_visible = visible; + if (visible && (wind == FrontWindow)) + window_send_event(wind, &event); } int window_is_visible(window *wind) diff --git a/main/automap.c b/main/automap.c index ad64ac713..e1978a81b 100644 --- a/main/automap.c +++ b/main/automap.c @@ -356,12 +356,12 @@ int automap_handler(window *wind, d_event *event, automap *am) vms_matrix tempm; int c; - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { draw_automap(am); return 1; } - else if (event->type == EVENT_CLOSE) + else if (event->type == EVENT_WINDOW_CLOSE) { #ifdef OGL gr_free_bitmap_data(&am->automap_background); diff --git a/main/game.c b/main/game.c index 865a9e274..285a32ee7 100644 --- a/main/game.c +++ b/main/game.c @@ -995,7 +995,7 @@ int game_handler(window *wind, d_event *event, void *data) { data = data; - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { if (force_cockpit_redraw) { //screen need redrawing? init_cockpit(); @@ -1005,7 +1005,7 @@ int game_handler(window *wind, d_event *event, void *data) return 1; } - else if (event->type == EVENT_CLOSE) + else if (event->type == EVENT_WINDOW_CLOSE) // Will have abort dialog here... return 1; diff --git a/main/gamecntl.c b/main/gamecntl.c index 86b88c983..9d6336859 100644 --- a/main/gamecntl.c +++ b/main/gamecntl.c @@ -228,12 +228,12 @@ int pause_handler(window *wind, d_event *event, char *msg) { int key; - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { show_boxed_message(msg, 1); return 1; } - else if (event->type == EVENT_CLOSE) + else if (event->type == EVENT_WINDOW_CLOSE) { game_flush_inputs(); reset_cockpit(); diff --git a/main/kconfig.c b/main/kconfig.c index 7400d7cc3..a3a29827d 100644 --- a/main/kconfig.c +++ b/main/kconfig.c @@ -650,12 +650,12 @@ int kconfig_handler(window *wind, d_event *event, kc_menu *menu) int mx, my, mz, x1, x2, y1, y2; #endif - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { kconfig_sub_draw_table(menu); return 1; } - else if (event->type == EVENT_CLOSE) + else if (event->type == EVENT_WINDOW_CLOSE) { game_flush_inputs(); newmenu_hide_cursor(); diff --git a/main/menu.c b/main/menu.c index 15b9df4a2..d7bf5705b 100644 --- a/main/menu.c +++ b/main/menu.c @@ -694,7 +694,7 @@ int options_menuset(newmenu *menu, d_event *event, void *userdata) } break; // stay in menu until escape - case EVENT_CLOSE: + case EVENT_WINDOW_CLOSE: write_player_file(); break; diff --git a/main/net_ipx.c b/main/net_ipx.c index 21308c3ca..f6b816e06 100644 --- a/main/net_ipx.c +++ b/main/net_ipx.c @@ -3962,7 +3962,7 @@ static int show_game_rules_handler(window *wind, d_event *event, netgame_info *n return 0; break; - case EVENT_DRAW: + case EVENT_WINDOW_DRAW: gr_set_current_canvas(NULL); #ifdef OGL nm_draw_background1(NULL); @@ -4018,7 +4018,7 @@ static int show_game_rules_handler(window *wind, d_event *event, netgame_info *n gr_set_current_canvas(NULL); break; - case EVENT_CLOSE: + case EVENT_WINDOW_CLOSE: game_flush_inputs(); break; diff --git a/main/net_udp.c b/main/net_udp.c index f7562880d..d1ee2a504 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -4260,7 +4260,7 @@ static int show_game_rules_handler(window *wind, d_event *event, netgame_info *n return 0; break; - case EVENT_DRAW: + case EVENT_WINDOW_DRAW: gr_set_current_canvas(NULL); #ifdef OGL nm_draw_background1(NULL); @@ -4316,7 +4316,7 @@ static int show_game_rules_handler(window *wind, d_event *event, netgame_info *n gr_set_current_canvas(NULL); break; - case EVENT_CLOSE: + case EVENT_WINDOW_CLOSE: game_flush_inputs(); break; diff --git a/main/newmenu.c b/main/newmenu.c index 2b58912cc..be89065de 100644 --- a/main/newmenu.c +++ b/main/newmenu.c @@ -560,7 +560,7 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu) #endif int rval = 0; - if (event->type == EVENT_CLOSE) + if (event->type == EVENT_WINDOW_CLOSE) { // Don't allow cancel here - handle item selected events / key events instead if (menu->subfunction) @@ -580,7 +580,7 @@ int newmenu_handler(window *wind, d_event *event, newmenu *menu) return 1; // always close } - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { int ty; @@ -1688,7 +1688,7 @@ int listbox_handler(window *wind, d_event *event, listbox *lb) #endif int rval = 0; - if (event->type == EVENT_CLOSE) + if (event->type == EVENT_WINDOW_CLOSE) { // Don't allow cancel here - handle item selected events / key events instead if (lb->listbox_callback) @@ -1698,7 +1698,7 @@ int listbox_handler(window *wind, d_event *event, listbox *lb) return 1; // always close } - if (event->type == EVENT_DRAW) + if (event->type == EVENT_WINDOW_DRAW) { #ifdef OGL nm_draw_background1(NULL); diff --git a/main/state.c b/main/state.c index 35a6b7380..36557b4c9 100644 --- a/main/state.c +++ b/main/state.c @@ -107,7 +107,7 @@ int state_callback(newmenu *menu, d_event *event, grs_bitmap *sc_bmp[]) newmenu_item *items = newmenu_get_items(menu); int citem = newmenu_get_citem(menu); - if ( (citem > 0) && (event->type == EVENT_DRAW) ) + if ( (citem > 0) && (event->type == EVENT_WINDOW_DRAW) ) { if ( sc_bmp[citem-1] ) { grs_canvas *save_canv = grd_curcanv;