New approach to handle a bunch of closing windows - removed window_do_close() again, reworked game_leave_menus by checking window_get_front() and closing this window until it's Game_wind, while event_process checking if window still exists after drawing and if not, take next window from previous which should be updated by then
This commit is contained in:
parent
1f5fde02c7
commit
097dd32c5a
|
@ -1,5 +1,9 @@
|
||||||
D2X-Rebirth Changelog
|
D2X-Rebirth Changelog
|
||||||
|
|
||||||
|
20110212
|
||||||
|
--------
|
||||||
|
arch/inlcude/window.h, arch/sdl/event.c, arch/sdl/window.c, main/game.c: New approach to handle a bunch of closing windows - removed window_do_close() again, reworked game_leave_menus by checking window_get_front() and closing this window until it's Game_wind, while event_process checking if window still exists after drawing and if not, take next window from previous which should be updated by then
|
||||||
|
|
||||||
20110211
|
20110211
|
||||||
--------
|
--------
|
||||||
main/gamecntl.c, main/kconfig.c, main/newmenu.c: Controls.select_weapon_count needs to be incremented differently to get non-0 when we want to select the laser type weapon; Readded jumping from first to last item in newmenu and vice versa
|
main/gamecntl.c, main/kconfig.c, main/newmenu.c: Controls.select_weapon_count needs to be incremented differently to get non-0 when we want to select the laser type weapon; Readded jumping from first to last item in newmenu and vice versa
|
||||||
|
|
|
@ -19,7 +19,6 @@ typedef struct window window;
|
||||||
|
|
||||||
extern 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);
|
extern 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);
|
||||||
extern int window_close(window *wind);
|
extern int window_close(window *wind);
|
||||||
extern int window_do_close(window *wind);
|
|
||||||
extern int window_exists(window *wind);
|
extern int window_exists(window *wind);
|
||||||
extern window *window_get_front(void);
|
extern window *window_get_front(void);
|
||||||
extern window *window_get_first(void);
|
extern window *window_get_first(void);
|
||||||
|
|
|
@ -152,19 +152,19 @@ void event_process(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.type = EVENT_WINDOW_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))
|
wind = window_get_first();
|
||||||
|
while (wind != NULL)
|
||||||
|
{
|
||||||
|
window *prev = window_get_prev(wind);
|
||||||
if (window_is_visible(wind))
|
if (window_is_visible(wind))
|
||||||
window_send_event(wind, &event);
|
window_send_event(wind, &event);
|
||||||
|
if (!window_exists(wind))
|
||||||
|
wind = window_get_next(prev); // the current window seemed to be closed. so take the next one from the previous which should be able to point to the one after the currently closed
|
||||||
|
else
|
||||||
|
wind = window_get_next(wind);
|
||||||
|
}
|
||||||
|
|
||||||
gr_flip();
|
gr_flip();
|
||||||
|
|
||||||
wind = window_get_first();
|
|
||||||
while (wind != NULL) // go through all windows and actually close them if they want to
|
|
||||||
{
|
|
||||||
window *next_wind = window_get_next(wind);
|
|
||||||
window_do_close(wind);
|
|
||||||
wind = next_wind;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void event_toggle_focus(int activate_focus)
|
void event_toggle_focus(int activate_focus)
|
||||||
|
|
|
@ -18,7 +18,6 @@ struct window
|
||||||
grs_canvas w_canv; // the window's canvas to draw to
|
grs_canvas w_canv; // the window's canvas to draw to
|
||||||
int (*w_callback)(window *wind, d_event *event, void *data); // the event handler
|
int (*w_callback)(window *wind, d_event *event, void *data); // the event handler
|
||||||
int w_visible; // whether it's visible
|
int w_visible; // whether it's visible
|
||||||
ubyte w_closing_state;
|
|
||||||
void *data; // whatever the user wants (eg menu data for 'newmenu' menus)
|
void *data; // whatever the user wants (eg menu data for 'newmenu' menus)
|
||||||
struct window *prev; // the previous window in the doubly linked list
|
struct window *prev; // the previous window in the doubly linked list
|
||||||
struct window *next; // the next window in the doubly linked list
|
struct window *next; // the next window in the doubly linked list
|
||||||
|
@ -42,7 +41,6 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c
|
||||||
gr_init_sub_canvas(&wind->w_canv, src, x, y, w, h);
|
gr_init_sub_canvas(&wind->w_canv, src, x, y, w, h);
|
||||||
wind->w_callback = event_callback;
|
wind->w_callback = event_callback;
|
||||||
wind->w_visible = 1; // default to visible
|
wind->w_visible = 1; // default to visible
|
||||||
wind->w_closing_state = 0;
|
|
||||||
wind->data = data;
|
wind->data = data;
|
||||||
|
|
||||||
if (FirstWindow == NULL)
|
if (FirstWindow == NULL)
|
||||||
|
@ -61,20 +59,11 @@ window *window_create(grs_canvas *src, int x, int y, int w, int h, int (*event_c
|
||||||
}
|
}
|
||||||
|
|
||||||
int window_close(window *wind)
|
int window_close(window *wind)
|
||||||
{
|
|
||||||
wind->w_closing_state = 1; // mark this window to close
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int window_do_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;
|
int (*w_callback)(window *wind, d_event *event, void *data) = wind->w_callback;
|
||||||
|
|
||||||
if (!wind->w_closing_state)
|
|
||||||
return 0;
|
|
||||||
if (wind == window_get_front())
|
if (wind == window_get_front())
|
||||||
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED); // Deactivate first
|
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_DEACTIVATED); // Deactivate first
|
||||||
|
|
||||||
|
@ -87,7 +76,6 @@ int window_do_close(window *wind)
|
||||||
if (wind == window_get_front())
|
if (wind == window_get_front())
|
||||||
{
|
{
|
||||||
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
|
WINDOW_SEND_EVENT(wind, EVENT_WINDOW_ACTIVATED);
|
||||||
wind->w_closing_state = 0;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1343,13 +1343,11 @@ void flicker_lights();
|
||||||
|
|
||||||
void game_leave_menus(void)
|
void game_leave_menus(void)
|
||||||
{
|
{
|
||||||
window *wind;
|
|
||||||
|
|
||||||
if (!Game_wind)
|
if (!Game_wind)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (wind = window_get_next(Game_wind); wind != NULL; wind = window_get_next(wind))
|
while (window_get_front() != Game_wind) // go through all windows and actually close them if they want to
|
||||||
window_close(wind);
|
window_close(window_get_front());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameProcessFrame(void)
|
void GameProcessFrame(void)
|
||||||
|
|
|
@ -394,7 +394,6 @@ int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy)
|
||||||
if (must_have)
|
if (must_have)
|
||||||
con_printf(CON_URGENT, "Can't open movie <%s>: %s\n", filename, PHYSFS_getLastError());
|
con_printf(CON_URGENT, "Can't open movie <%s>: %s\n", filename, PHYSFS_getLastError());
|
||||||
window_close(wind);
|
window_close(wind);
|
||||||
window_do_close(wind);
|
|
||||||
if (reshow)
|
if (reshow)
|
||||||
show_menus();
|
show_menus();
|
||||||
d_free(m);
|
d_free(m);
|
||||||
|
@ -419,7 +418,6 @@ int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy)
|
||||||
Int3();
|
Int3();
|
||||||
SDL_FreeRW(filehndl);
|
SDL_FreeRW(filehndl);
|
||||||
window_close(wind);
|
window_close(wind);
|
||||||
window_do_close(wind);
|
|
||||||
if (reshow)
|
if (reshow)
|
||||||
show_menus();
|
show_menus();
|
||||||
d_free(m);
|
d_free(m);
|
||||||
|
|
Loading…
Reference in a new issue