X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=7c0634294d1e78ebb2ea70822f2249858f29a0f5;hb=eccf6b67a482ec5dd7040a245c189eed7f7646fe;hp=247bcffd33d5a9de7d3a2afb9fce86270feabea0;hpb=2d33cabb4017e5e4c2c4678db762b41d5ca9ea85;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 247bcffd..7c063429 100644 --- a/src/tools.c +++ b/src/tools.c @@ -3389,109 +3389,110 @@ static int RequestHandleEvents(unsigned int req_state) { Event event; - NextEvent(&event); - - switch (event.type) + while (NextValidEvent(&event)) { - case EVENT_BUTTONPRESS: - case EVENT_BUTTONRELEASE: - case EVENT_MOTIONNOTIFY: + switch (event.type) { - if (event.type == EVENT_MOTIONNOTIFY) + case EVENT_BUTTONPRESS: + case EVENT_BUTTONRELEASE: + case EVENT_MOTIONNOTIFY: { - if (!PointerInWindow(window)) - continue; /* window and pointer are on different screens */ - - if (!button_status) - continue; - - motion_status = TRUE; - mx = ((MotionEvent *) &event)->x; - my = ((MotionEvent *) &event)->y; - } - else - { - motion_status = FALSE; - mx = ((ButtonEvent *) &event)->x; - my = ((ButtonEvent *) &event)->y; - if (event.type == EVENT_BUTTONPRESS) - button_status = ((ButtonEvent *) &event)->button; + if (event.type == EVENT_MOTIONNOTIFY) + { + if (!PointerInWindow(window)) + continue; /* window and pointer on different screens */ + + if (!button_status) + continue; + + motion_status = TRUE; + mx = ((MotionEvent *) &event)->x; + my = ((MotionEvent *) &event)->y; + } else - button_status = MB_RELEASED; + { + motion_status = FALSE; + mx = ((ButtonEvent *) &event)->x; + my = ((ButtonEvent *) &event)->y; + if (event.type == EVENT_BUTTONPRESS) + button_status = ((ButtonEvent *) &event)->button; + else + button_status = MB_RELEASED; + } + + /* this sets 'request_gadget_id' */ + HandleGadgets(mx, my, button_status); + + switch (request_gadget_id) + { + case TOOL_CTRL_ID_YES: + result = TRUE; + break; + case TOOL_CTRL_ID_NO: + result = FALSE; + break; + case TOOL_CTRL_ID_CONFIRM: + result = TRUE | FALSE; + break; + + case TOOL_CTRL_ID_PLAYER_1: + result = 1; + break; + case TOOL_CTRL_ID_PLAYER_2: + result = 2; + break; + case TOOL_CTRL_ID_PLAYER_3: + result = 3; + break; + case TOOL_CTRL_ID_PLAYER_4: + result = 4; + break; + + default: + break; + } + + break; } - /* this sets 'request_gadget_id' */ - HandleGadgets(mx, my, button_status); + case EVENT_KEYPRESS: + switch (GetEventKey((KeyEvent *)&event, TRUE)) + { + case KSYM_space: + if (req_state & REQ_CONFIRM) + result = 1; + break; - switch (request_gadget_id) - { - case TOOL_CTRL_ID_YES: - result = TRUE; - break; - case TOOL_CTRL_ID_NO: - result = FALSE; - break; - case TOOL_CTRL_ID_CONFIRM: - result = TRUE | FALSE; - break; - - case TOOL_CTRL_ID_PLAYER_1: - result = 1; - break; - case TOOL_CTRL_ID_PLAYER_2: - result = 2; - break; - case TOOL_CTRL_ID_PLAYER_3: - result = 3; - break; - case TOOL_CTRL_ID_PLAYER_4: - result = 4; - break; - - default: - break; - } - - break; - } - - case EVENT_KEYPRESS: - switch (GetEventKey((KeyEvent *)&event, TRUE)) - { - case KSYM_space: - if (req_state & REQ_CONFIRM) - result = 1; - break; - - case KSYM_Return: + case KSYM_Return: #if defined(TARGET_SDL2) - case KSYM_Menu: + case KSYM_Menu: #endif - result = 1; - break; + result = 1; + break; - case KSYM_Escape: + case KSYM_Escape: #if defined(TARGET_SDL2) - case KSYM_Back: + case KSYM_Back: #endif - result = 0; - break; + result = 0; + break; - default: - break; - } + default: + break; + } - if (req_state & REQ_PLAYER) - result = 0; - break; + if (req_state & REQ_PLAYER) + result = 0; + break; - case EVENT_KEYRELEASE: - ClearPlayerAction(); - break; + case EVENT_KEYRELEASE: + ClearPlayerAction(); + break; - default: - HandleOtherEvents(&event); - break; + default: + HandleOtherEvents(&event); + break; + } } } else if (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED) @@ -7793,13 +7794,59 @@ void InitGraphicInfo_EM(void) #endif } +void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, + boolean any_player_moving, + boolean any_player_snapping, + boolean any_player_dropping) +{ + static boolean player_was_waiting = TRUE; + + if (frame == 0 && !any_player_dropping) + { + if (!player_was_waiting) + { + SaveEngineSnapshotToList(); + + player_was_waiting = TRUE; + } + } + else if (any_player_moving || any_player_snapping || any_player_dropping) + { + player_was_waiting = FALSE; + } +} + +void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, + boolean murphy_is_dropping) +{ + static boolean player_was_waiting = FALSE; + + if (murphy_is_waiting) + { + if (!player_was_waiting) + { + SaveEngineSnapshotToList(); + + player_was_waiting = TRUE; + } + } + else + { + player_was_waiting = FALSE; + } +} + void CheckSingleStepMode_EM(byte action[MAX_PLAYERS], int frame, boolean any_player_moving, - boolean player_is_dropping) + boolean any_player_snapping, + boolean any_player_dropping) { if (tape.single_step && tape.recording && !tape.pausing) - if (frame == 0 && !player_is_dropping) + if (frame == 0 && !any_player_dropping) TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + + CheckSaveEngineSnapshot_EM(action, frame, any_player_moving, + any_player_snapping, any_player_dropping); } void CheckSingleStepMode_SP(boolean murphy_is_waiting, @@ -7808,6 +7855,8 @@ void CheckSingleStepMode_SP(boolean murphy_is_waiting, if (tape.single_step && tape.recording && !tape.pausing) if (murphy_is_waiting) TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + + CheckSaveEngineSnapshot_SP(murphy_is_waiting, murphy_is_dropping); } void getGraphicSource_SP(struct GraphicInfo_SP *g_sp, @@ -8079,7 +8128,7 @@ void ChangeViewportPropertiesIfNeeded() // printf("::: new_tilesize_var != TILESIZE_VAR\n"); // changing tile size invalidates scroll values of engine snapshots - FreeEngineSnapshot(); + FreeEngineSnapshotSingle(); // changing tile size requires update of graphic mapping for EM engine init_em_graphics = TRUE;