Add EVENT_WINDOW_ACTIVATED, change EVENT_DRAW to EVENT_WINDOW_DRAW and EVENT_CLOSE to EVENT_WINDOW_CLOSE

This commit is contained in:
kreatordxx 2010-01-20 05:10:32 +00:00
parent fe6d09750e
commit 88d1b32914
13 changed files with 47 additions and 22 deletions

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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();

View file

@ -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();

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -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;