X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=5a4023ec36b3e621d0d22fa5e8dc1b3765dfc293;hb=73b48f8afe7e1e1faf0e87436d7d74b27bba5f27;hp=65b20da1cb634a22e5a6cc1e4c8ce39fdd8a1e9e;hpb=c9308ba3e7ddea2d7e44b4d98f0dfbb19e18f04f;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 65b20da1..5a4023ec 100644 --- a/src/events.c +++ b/src/events.c @@ -304,7 +304,8 @@ void HandleMouseCursor() cursor_inside_playfield && DelayReached(&special_cursor_delay, special_cursor_delay_value)) { - if (level.game_engine_type != GAME_ENGINE_TYPE_MM) + if (level.game_engine_type != GAME_ENGINE_TYPE_MM || + tile_cursor.enabled) SetMouseCursor(CURSOR_PLAYFIELD); } } @@ -400,6 +401,10 @@ void SetPlayerMouseAction(int mx, int my, int button) { int lx = getLevelFromScreenX(mx); int ly = getLevelFromScreenY(my); + int new_button = (!local_player->mouse_action.button && button); + + if (local_player->mouse_action.button_hint) + button = local_player->mouse_action.button_hint; ClearPlayerMouseAction(); @@ -412,10 +417,12 @@ void SetPlayerMouseAction(int mx, int my, int button) if (tape.recording && tape.pausing && tape.use_mouse) { - /* prevent button release or motion events from un-pausing a paused game */ - if (button && !motion_status) - TapeTogglePause(TAPE_TOGGLE_MANUAL); + /* un-pause a paused game only if mouse button was newly pressed down */ + if (new_button) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); } + + SetTileCursorXY(lx, ly); } void SleepWhileUnmapped() @@ -629,10 +636,35 @@ void HandleWindowEvent(WindowEvent *event) if (new_display_width != video.display_width || new_display_height != video.display_height) { + int nr = GRID_ACTIVE_NR(); // previous screen orientation + video.display_width = new_display_width; video.display_height = new_display_height; SDLSetScreenProperties(); + + // check if screen orientation has changed (should always be true here) + if (nr != GRID_ACTIVE_NR()) + { + int x, y; + + if (game_status == GAME_MODE_SETUP) + { + // save active virtual buttons (in case of just configuring them) + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + overlay.grid_button_all[nr][x][y] = overlay.grid_button[x][y]; + } + + nr = GRID_ACTIVE_NR(); + + overlay.grid_xsize = overlay.grid_xsize_all[nr]; + overlay.grid_ysize = overlay.grid_ysize_all[nr]; + + for (x = 0; x < MAX_GRID_XSIZE; x++) + for (y = 0; y < MAX_GRID_YSIZE; y++) + overlay.grid_button[x][y] = overlay.grid_button_all[nr][x][y]; + } } } #endif @@ -956,7 +988,16 @@ void HandleFingerEvent(FingerEvent *event) return; if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + if (strEqual(setup.touch.control_type, TOUCH_CONTROL_OFF)) + local_player->mouse_action.button_hint = + (event->type == EVENT_FINGERRELEASE ? MB_NOT_PRESSED : + event->x < 0.5 ? MB_LEFTBUTTON : + event->x > 0.5 ? MB_RIGHTBUTTON : + MB_NOT_PRESSED); + return; + } if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) HandleFingerEvent_VirtualButtons(event); @@ -1824,7 +1865,7 @@ void HandleKey(Key key, int key_status) else stored_player[pnr].action &= ~key_action; - if (tape.single_step && tape.recording && tape.pausing) + if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse) { if (key_status == KEY_PRESSED && key_action & KEY_MOTION) { @@ -2187,7 +2228,7 @@ static void HandleTileCursor(int dx, int dy, int button) (dx < 0 ? MB_LEFTBUTTON : dx > 0 ? MB_RIGHTBUTTON : MB_RELEASED)); } - else + else if (!tile_cursor.moving) { int old_xpos = tile_cursor.xpos; int old_ypos = tile_cursor.ypos; @@ -2242,6 +2283,8 @@ void HandleJoystick() static unsigned int joytest_delay = 0; static unsigned int joytest_delay_value = GADGET_FRAME_DELAY; static int joytest_last = 0; + int delay_value_first = GADGET_FRAME_DELAY_FIRST; + int delay_value = GADGET_FRAME_DELAY; int joystick = HandleJoystickForAllPlayers(); int keyboard = key_joystick_mapping; int joy = (joystick | keyboard); @@ -2254,6 +2297,7 @@ void HandleJoystick() int newbutton = (AnyJoystickButton() == JOY_BUTTON_NEW_PRESSED); int dx = (left ? -1 : right ? 1 : 0); int dy = (up ? -1 : down ? 1 : 0); + boolean use_delay_value_first = (joytest != joytest_last); if (HandleGlobalAnimClicks(-1, -1, newbutton)) { @@ -2263,10 +2307,18 @@ void HandleJoystick() if (level.game_engine_type == GAME_ENGINE_TYPE_MM) { - // when playing MM style levels, also use delay for keyboard events if (game_status == GAME_MODE_PLAYING) + { + // when playing MM style levels, also use delay for keyboard events joytest |= keyboard; + // only use first delay value for new events, but not for changed events + use_delay_value_first = (!joytest != !joytest_last); + + // only use delay after the initial keyboard event + delay_value = 0; + } + // for any joystick or keyboard event, enable playfield tile cursor if (dx || dy || button) SetTileCursorEnabled(TRUE); @@ -2281,7 +2333,7 @@ void HandleJoystick() { /* first start with longer delay, then continue with shorter delay */ joytest_delay_value = - (joytest != joytest_last ? GADGET_FRAME_DELAY_FIRST : GADGET_FRAME_DELAY); + (use_delay_value_first ? delay_value_first : delay_value); } joytest_last = joytest; @@ -2315,8 +2367,11 @@ void HandleJoystick() } case GAME_MODE_PLAYING: +#if 0 + // !!! causes immediate GameEnd() when solving MM level with keyboard !!! if (tape.playing || keyboard) newbutton = ((joy & JOY_BUTTON) != 0); +#endif if (newbutton && AllPlayersGone) { @@ -2325,7 +2380,12 @@ void HandleJoystick() return; } - if (tape.recording && tape.pausing) + if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse) + { + if (joystick & JOY_ACTION) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + } + else if (tape.recording && tape.pausing && !tape.use_mouse) { if (joystick & JOY_ACTION) TapeTogglePause(TAPE_TOGGLE_MANUAL);