Added event_flush to take place in game_flush_inputs which will clean SDL events which may be buffered while event_process was suspended; suspend Game_Wind while loading restoring save state while playing a level to properly flush controls and reset timer; when toggeling cursor, also directly modify the mouse to wanted behaviour instead of waiting for mouse_update_cursor_and_grab
This commit is contained in:
parent
fb7551f90c
commit
c50081f72c
|
@ -4,6 +4,7 @@ D2X-Rebirth Changelog
|
||||||
--------
|
--------
|
||||||
main/game.c: Removed leftover of mouse grabbing from set_screen_mode - forgot to do this in rev1192
|
main/game.c: Removed leftover of mouse grabbing from set_screen_mode - forgot to do this in rev1192
|
||||||
SConstruct: restricted parsing of sdl-config to *NIX and Mac builds as it's static on Win32 anyways; added verbosebuild as SCons option to print out all compiler/linker messages
|
SConstruct: restricted parsing of sdl-config to *NIX and Mac builds as it's static on Win32 anyways; added verbosebuild as SCons option to print out all compiler/linker messages
|
||||||
|
main/state.c, main/game.c, arch/sdl/event.c, arch/sdl/mouse.c, arch/include/event.h: Added event_flush to take place in game_flush_inputs which will clean SDL events which may be buffered while event_process was suspended; suspend Game_Wind while loading restoring save state while playing a level to properly flush controls and reset timer; when toggeling cursor, also directly modify the mouse to wanted behaviour instead of waiting for mouse_update_cursor_and_grab
|
||||||
|
|
||||||
20100729
|
20100729
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -50,6 +50,7 @@ int event_init();
|
||||||
|
|
||||||
// Sends input events to event handlers
|
// Sends input events to event handlers
|
||||||
void event_poll();
|
void event_poll();
|
||||||
|
void event_flush();
|
||||||
|
|
||||||
// Set and call the default event handler
|
// Set and call the default event handler
|
||||||
void set_default_handler(int (*handler)(d_event *event));
|
void set_default_handler(int (*handler)(d_event *event));
|
||||||
|
|
|
@ -73,6 +73,13 @@ void event_poll()
|
||||||
mouse_update_cursor_and_grab(time);
|
mouse_update_cursor_and_grab(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void event_flush()
|
||||||
|
{
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
while (SDL_PollEvent(&event));
|
||||||
|
}
|
||||||
|
|
||||||
int event_init()
|
int event_init()
|
||||||
{
|
{
|
||||||
// We should now be active and responding to events.
|
// We should now be active and responding to events.
|
||||||
|
|
|
@ -241,13 +241,24 @@ int mouse_button_state(int button)
|
||||||
void mouse_toggle_cursor(int activate)
|
void mouse_toggle_cursor(int activate)
|
||||||
{
|
{
|
||||||
Mouse.cursor_enabled = (activate && !GameArg.CtlNoMouse);
|
Mouse.cursor_enabled = (activate && !GameArg.CtlNoMouse);
|
||||||
|
if (Mouse.cursor_enabled)
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
if (GameArg.CtlGrabMouse)
|
||||||
|
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
if (GameArg.CtlGrabMouse)
|
||||||
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we check what to do with our mouse:
|
* Here we check what to do with our mouse:
|
||||||
* If we want to display/hide cursor, do so if not already and also hide it automatically after some time.
|
* If we want to display/hide cursor, do so if not already and also hide it automatically after some time.
|
||||||
* If we want to grab/release cursor, do so if not already.
|
* If we want to grab/release cursor, do so if not already.
|
||||||
* If app looses focus, automatically show and release cursor.
|
|
||||||
*/
|
*/
|
||||||
void mouse_update_cursor_and_grab(fix time)
|
void mouse_update_cursor_and_grab(fix time)
|
||||||
{
|
{
|
||||||
|
@ -260,14 +271,14 @@ void mouse_update_cursor_and_grab(fix time)
|
||||||
else if ( (Mouse.cursor_time + (F1_0*2)) < time && show)
|
else if ( (Mouse.cursor_time + (F1_0*2)) < time && show)
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
|
||||||
if (!grab)
|
if (grab)
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (show)
|
if (show)
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
if (grab && GameArg.CtlGrabMouse)
|
if (!grab && GameArg.CtlGrabMouse)
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,6 +422,7 @@ void start_time()
|
||||||
void game_flush_inputs()
|
void game_flush_inputs()
|
||||||
{
|
{
|
||||||
int dx,dy,dz;
|
int dx,dy,dz;
|
||||||
|
event_flush();
|
||||||
key_flush();
|
key_flush();
|
||||||
joy_flush();
|
joy_flush();
|
||||||
mouse_flush();
|
mouse_flush();
|
||||||
|
@ -1173,9 +1174,8 @@ int game_handler(window *wind, d_event *event, void *data)
|
||||||
case EVENT_WINDOW_ACTIVATED:
|
case EVENT_WINDOW_ACTIVATED:
|
||||||
set_screen_mode(SCREEN_GAME);
|
set_screen_mode(SCREEN_GAME);
|
||||||
|
|
||||||
game_flush_inputs();
|
|
||||||
|
|
||||||
mouse_toggle_cursor(0);
|
mouse_toggle_cursor(0);
|
||||||
|
game_flush_inputs();
|
||||||
|
|
||||||
if (time_paused)
|
if (time_paused)
|
||||||
start_time();
|
start_time();
|
||||||
|
|
|
@ -839,6 +839,9 @@ int state_restore_all_sub(char *filename, int secret_restore)
|
||||||
init_player_stats_game(); //clear all stats
|
init_player_stats_game(); //clear all stats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Game_wind)
|
||||||
|
window_set_visible(Game_wind, 0);
|
||||||
|
|
||||||
//Read player info
|
//Read player info
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1109,8 +1112,10 @@ int state_restore_all_sub(char *filename, int secret_restore)
|
||||||
|
|
||||||
PHYSFS_close(fp);
|
PHYSFS_close(fp);
|
||||||
|
|
||||||
// Load in bitmaps, etc..
|
if (Game_wind)
|
||||||
//!! piggy_load_level_data(); //already done by StartNewLevelSub()
|
if (!window_is_visible(Game_wind))
|
||||||
|
window_set_visible(Game_wind, 1);
|
||||||
|
reset_time();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue