X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=968084f48474583c99d069c728b5425b27dac550;hb=1e56877fb87c1004b98e6c5fbb1132da2178b46e;hp=f2f645933e6be727a2e8bb39a4637fffe4740e59;hpb=02a095de0eb40735cb15b3f043c1639dbd883ce1;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index f2f64593..968084f4 100644 --- a/src/events.c +++ b/src/events.c @@ -38,6 +38,7 @@ static boolean cursor_inside_playfield = FALSE; static int cursor_mode_last = CURSOR_DEFAULT; static unsigned int special_cursor_delay = 0; static unsigned int special_cursor_delay_value = 1000; +static boolean special_cursor_enabled = FALSE; static boolean stop_processing_events = FALSE; @@ -48,6 +49,11 @@ static void HandleNoEvent(void); static void HandleEventActions(void); +void SetPlayfieldMouseCursorEnabled(boolean enabled) +{ + special_cursor_enabled = enabled; +} + // event filter to set mouse x/y position (for pointer class global animations) // (this is especially required to ensure smooth global animation mouse pointer // movement when the screen is updated without handling events; this can happen @@ -108,7 +114,7 @@ static int FilterEvents(const Event *event) { SetMouseCursor(CURSOR_DEFAULT); - DelayReached(&special_cursor_delay, 0); + ResetDelayCounter(&special_cursor_delay); cursor_mode_last = CURSOR_DEFAULT; } @@ -214,6 +220,8 @@ static void HandleEvents(void) while (NextValidEvent(&event)) { + int game_status_last = game_status; + switch (event.type) { case EVENT_BUTTONPRESS: @@ -264,6 +272,10 @@ static void HandleEvents(void) break; } + // always handle events within delay period if game status has changed + if (game_status != game_status_last) + ResetDelayCounter(&event_frame_delay); + // do not handle events for longer than standard frame delay period if (DelayReached(&event_frame_delay, event_frame_delay_value)) break; @@ -330,15 +342,14 @@ static void HandleMouseCursor(void) // display normal pointer if mouse pressed if (button_status != MB_RELEASED) - DelayReached(&special_cursor_delay, 0); + ResetDelayCounter(&special_cursor_delay); if (gfx.cursor_mode != CURSOR_PLAYFIELD && cursor_inside_playfield && + special_cursor_enabled && DelayReached(&special_cursor_delay, special_cursor_delay_value)) { - if (level.game_engine_type != GAME_ENGINE_TYPE_MM || - tile_cursor.enabled) - SetMouseCursor(CURSOR_PLAYFIELD); + SetMouseCursor(CURSOR_PLAYFIELD); } } else if (gfx.cursor_mode != CURSOR_DEFAULT) @@ -518,6 +529,10 @@ void HandleButtonEvent(ButtonEvent *event) // for any mouse button event, disable playfield tile cursor SetTileCursorEnabled(FALSE); + // for any mouse button event, disable playfield mouse cursor + if (cursor_inside_playfield) + SetPlayfieldMouseCursorEnabled(FALSE); + #if defined(HAS_SCREEN_KEYBOARD) if (video.shifted_up) event->y += video.shifted_up_pos; @@ -1470,7 +1485,7 @@ void HandleKeyEvent(KeyEvent *event) if (key_status == KEY_PRESSED) SetOverlayEnabled(!GetOverlayEnabled()); } - else + else if (!textinput_status) { // for any other "real" key event, disable virtual buttons SetOverlayEnabled(FALSE); @@ -1749,9 +1764,14 @@ void HandleButton(int mx, int my, int button, int button_nr) break; case GAME_MODE_PSEUDO_TYPENAME: + case GAME_MODE_PSEUDO_TYPENAMES: HandleTypeName(KSYM_Return); break; + case GAME_MODE_NAMES: + HandleChoosePlayerName(mx, my, 0, 0, button); + break; + case GAME_MODE_LEVELS: HandleChooseLevelSet(mx, my, 0, 0, button); break; @@ -2080,6 +2100,8 @@ void HandleKey(Key key, int key_status) { key_action |= key_info[i].action | JOY_BUTTON_SNAP; key_snap_action |= key_info[i].action; + + tape.property_bits |= TAPE_PROPERTY_TAS_KEYS; } } } @@ -2143,6 +2165,10 @@ void HandleKey(Key key, int key_status) // for MM style levels, handle in-game keyboard input in HandleJoystick() if (level.game_engine_type == GAME_ENGINE_TYPE_MM) joy |= key_action; + + // for any keyboard event, enable playfield mouse cursor + if (key_action && key_status == KEY_PRESSED) + SetPlayfieldMouseCursorEnabled(TRUE); } } else @@ -2258,6 +2284,10 @@ void HandleKey(Key key, int key_status) TapeQuickSave(); else if (key == setup.shortcut.load_game) TapeQuickLoad(); + else if (key == setup.shortcut.restart_game) + TapeRestartGame(); + else if (key == setup.shortcut.pause_before_end) + TapeReplayAndPauseBeforeEnd(); else if (key == setup.shortcut.toggle_pause) TapeTogglePause(TAPE_TOGGLE_MANUAL | TAPE_TOGGLE_PLAY_PAUSE); @@ -2297,11 +2327,13 @@ void HandleKey(Key key, int key_status) switch (game_status) { case GAME_MODE_PSEUDO_TYPENAME: + case GAME_MODE_PSEUDO_TYPENAMES: HandleTypeName(key); break; case GAME_MODE_TITLE: case GAME_MODE_MAIN: + case GAME_MODE_NAMES: case GAME_MODE_LEVELS: case GAME_MODE_LEVELNR: case GAME_MODE_SETUP: @@ -2319,6 +2351,8 @@ void HandleKey(Key key, int key_status) HandleTitleScreen(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0, 0, 0, 0, MB_MENU_CHOICE); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_LEVELNR) @@ -2337,6 +2371,8 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_TITLE) HandleTitleScreen(0, 0, 0, 0, MB_MENU_LEAVE); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_LEVELNR) @@ -2350,7 +2386,9 @@ void HandleKey(Key key, int key_status) break; case KSYM_Page_Up: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); @@ -2363,7 +2401,9 @@ void HandleKey(Key key, int key_status) break; case KSYM_Page_Down: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR) HandleChooseLevelNr(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); @@ -2390,7 +2430,7 @@ void HandleKey(Key key, int key_status) switch (key) { case KSYM_Escape: - RequestQuitGame(setup.ask_on_escape); + RequestQuitGame(TRUE); break; default: @@ -2547,6 +2587,7 @@ void HandleJoystick(void) } if (newbutton && (game_status == GAME_MODE_PSEUDO_TYPENAME || + game_status == GAME_MODE_PSEUDO_TYPENAMES || anyTextGadgetActive())) { // leave name input in main menu or text input gadget @@ -2575,6 +2616,10 @@ void HandleJoystick(void) SetTileCursorEnabled(TRUE); } + // for any joystick event, enable playfield mouse cursor + if (dx || dy || button) + SetPlayfieldMouseCursorEnabled(TRUE); + if (joytest && !button && !DelayReached(&joytest_delay, joytest_delay_value)) { // delay joystick/keyboard actions if axes/keys continually pressed @@ -2593,6 +2638,7 @@ void HandleJoystick(void) { case GAME_MODE_TITLE: case GAME_MODE_MAIN: + case GAME_MODE_NAMES: case GAME_MODE_LEVELS: case GAME_MODE_LEVELNR: case GAME_MODE_SETUP: @@ -2606,6 +2652,8 @@ void HandleJoystick(void) HandleTitleScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + else if (game_status == GAME_MODE_NAMES) + HandleChoosePlayerName(0,0,dx,dy,newbutton?MB_MENU_CHOICE:MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevelSet(0,0,dx,dy,newbutton?MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELNR)