X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=b30159555f124225f1526a46778befe0bf8c6a47;hb=7e68d10c8f4c814e532cc30f6fc721c269a99cb6;hp=2998066b98230577aae3198ddbc0b861877646bc;hpb=c7bda2237780e82311e5ede18042f3619b257f8a;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 2998066b..b3015955 100644 --- a/src/events.c +++ b/src/events.c @@ -128,7 +128,7 @@ static boolean SkipPressedMouseMotionEvent(const Event *event) return FALSE; } -static boolean WaitEventFiltered(Event *event) +static boolean WaitValidEvent(Event *event) { WaitEvent(event); @@ -152,7 +152,7 @@ static boolean WaitEventFiltered(Event *event) boolean NextValidEvent(Event *event) { while (PendingEvent()) - if (WaitEventFiltered(event)) + if (WaitValidEvent(event)) return TRUE; return FALSE; @@ -298,7 +298,8 @@ void HandleMouseCursor() cursor_inside_playfield && DelayReached(&special_cursor_delay, special_cursor_delay_value)) { - SetMouseCursor(CURSOR_PLAYFIELD); + if (level.game_engine_type != GAME_ENGINE_TYPE_MM) + SetMouseCursor(CURSOR_PLAYFIELD); } } else if (gfx.cursor_mode != CURSOR_DEFAULT) @@ -369,6 +370,13 @@ void ClearEventQueue() } } +void ClearPlayerMouseAction() +{ + local_player->mouse_action.lx = 0; + local_player->mouse_action.ly = 0; + local_player->mouse_action.button = 0; +} + void ClearPlayerAction() { int i; @@ -379,6 +387,22 @@ void ClearPlayerAction() stored_player[i].action = 0; ClearJoystickState(); + ClearPlayerMouseAction(); +} + +void SetPlayerMouseAction(int mx, int my, int button) +{ + int lx = getLevelFromScreenX(mx); + int ly = getLevelFromScreenY(my); + + ClearPlayerMouseAction(); + + if (!IN_GFX_FIELD_PLAY(mx, my) || !IN_LEV_FIELD(lx, ly)) + return; + + local_player->mouse_action.lx = lx; + local_player->mouse_action.ly = ly; + local_player->mouse_action.button = button; } void SleepWhileUnmapped() @@ -391,7 +415,7 @@ void SleepWhileUnmapped() { Event event; - if (!WaitEventFiltered(&event)) + if (!WaitValidEvent(&event)) continue; switch (event.type) @@ -1323,14 +1347,16 @@ void HandleButton(int mx, int my, int button, int button_nr) HandleSetupScreen(mx, my, 0, 0, button); break; -#if defined(TARGET_SDL2) case GAME_MODE_PLAYING: + SetPlayerMouseAction(mx, my, button); + +#if defined(TARGET_SDL2) HandleFollowFinger(mx, my, button); #endif #ifdef DEBUG - if (button == MB_PRESSED && !motion_status && IN_GFX_FIELD_PLAY(mx, my) && - GetKeyModState() & KMOD_Control) + if (button == MB_PRESSED && !motion_status && !button_hold && + IN_GFX_FIELD_PLAY(mx, my) && GetKeyModState() & KMOD_Control) DumpTileFromScreen(mx, my); #endif @@ -1892,7 +1918,9 @@ void HandleKey(Key key, int key_status) void HandleNoEvent() { // if (button_status && game_status != GAME_MODE_PLAYING) - if (button_status && (game_status != GAME_MODE_PLAYING || tape.pausing)) + if (button_status && (game_status != GAME_MODE_PLAYING || + tape.pausing || + level.game_engine_type == GAME_ENGINE_TYPE_MM)) { HandleButton(0, 0, button_status, -button_status); }