X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fevents.c;h=952f8995f602cdec1a475dd9c4fd76211138d907;hp=b2bf0979495a2b8e139f49bd043c5cfef18641e3;hb=0229cbe9c9f7d6969ac5ca96eb6b525a9fe3ccf4;hpb=db8186256826b3a86f03fc482a240523d3f3f65b diff --git a/src/events.c b/src/events.c index b2bf0979..952f8995 100644 --- a/src/events.c +++ b/src/events.c @@ -19,6 +19,7 @@ #include "editor.h" #include "files.h" #include "tape.h" +#include "cartoons.h" #include "network.h" @@ -66,7 +67,7 @@ static int FilterEventsExt(const Event *event) /* do no reset mouse cursor before all pending events have been processed */ if (gfx.cursor_mode == cursor_mode_last && - ((effectiveGameStatus() == GAME_MODE_TITLE && + ((game_status == GAME_MODE_TITLE && gfx.cursor_mode == CURSOR_NONE) || (game_status == GAME_MODE_PLAYING && gfx.cursor_mode == CURSOR_PLAYFIELD))) @@ -108,9 +109,8 @@ boolean SkipPressedMouseMotionEvent(const Event *event) if (event->type != EVENT_MOTIONNOTIFY) return FALSE; - /* only skip motion events with pressed button outside level editor */ - if (button_status == MB_RELEASED || - game_status == GAME_MODE_EDITOR || game_status == GAME_MODE_PLAYING) + /* only skip motion events with pressed button outside the game */ + if (button_status == MB_RELEASED || game_status == GAME_MODE_PLAYING) return FALSE; if (PendingEvent()) @@ -154,6 +154,9 @@ boolean NextValidEvent(Event *event) void EventLoop(void) { + static unsigned int sync_frame_delay = 0; + unsigned int sync_frame_delay_value = GAME_FRAME_DELAY; + while (1) { if (PendingEvent()) /* got event */ @@ -209,7 +212,7 @@ void EventLoop(void) } else { - if (effectiveGameStatus() == GAME_MODE_TITLE) + if (game_status == GAME_MODE_TITLE) { /* when showing title screens, hide mouse pointer (if not moved) */ @@ -219,7 +222,8 @@ void EventLoop(void) SetMouseCursor(CURSOR_NONE); } } - else if (game_status == GAME_MODE_PLAYING && !tape.pausing) + else if (game_status == GAME_MODE_PLAYING && (!tape.pausing || + tape.single_step)) { /* when playing, display a special mouse pointer inside the playfield */ @@ -246,18 +250,14 @@ void EventLoop(void) has its own synchronization and is CPU friendly, too */ if (game_status == GAME_MODE_PLAYING) - { HandleGameActions(); - } - else - { - if (!PendingEvent()) /* delay only if no pending events */ - Delay(10); - } /* refresh window contents from drawing buffer, if needed */ BackToFront(); + if (game_status != GAME_MODE_PLAYING) + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); + if (game_status == GAME_MODE_QUIT) return; } @@ -408,9 +408,6 @@ void HandleButtonEvent(ButtonEvent *event) void HandleMotionEvent(MotionEvent *event) { - if (!PointerInWindow(window)) - return; /* window and pointer are on different screens */ - if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR) return; @@ -933,12 +930,14 @@ void HandleWindowManagerEvent(Event *event) void HandleButton(int mx, int my, int button, int button_nr) { static int old_mx = 0, old_my = 0; + boolean button_hold = FALSE; if (button < 0) { mx = old_mx; my = old_my; button = -button; + button_hold = TRUE; } else { @@ -947,6 +946,7 @@ void HandleButton(int mx, int my, int button, int button_nr) } #if defined(PLATFORM_ANDROID) + // !!! for now, do not handle gadgets when playing -- maybe fix this !!! if (game_status != GAME_MODE_PLAYING && HandleGadgets(mx, my, button)) { @@ -961,6 +961,9 @@ void HandleButton(int mx, int my, int button, int button_nr) } #endif + if (button_hold && game_status == GAME_MODE_PLAYING && tape.pausing) + return; + /* do not use scroll wheel button events for anything other than gadgets */ if (IS_WHEEL_BUTTON(button_nr)) return; @@ -1549,28 +1552,6 @@ void HandleKey(Key key, int key_status) } break; -#if 0 - case KSYM_s: - if (!global.fps_slowdown) - { - global.fps_slowdown = TRUE; - global.fps_slowdown_factor = 2; - printf("fps slowdown enabled -- display only every 2nd frame\n"); - } - else if (global.fps_slowdown_factor == 2) - { - global.fps_slowdown_factor = 4; - printf("fps slowdown enabled -- display only every 4th frame\n"); - } - else - { - global.fps_slowdown = FALSE; - global.fps_slowdown_factor = 1; - printf("fps slowdown disabled\n"); - } - break; -#endif - case KSYM_v: printf("::: currently using game engine version %d\n", game.engine_version); @@ -1596,7 +1577,8 @@ 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) + if (button_status && (game_status != GAME_MODE_PLAYING || tape.pausing)) { HandleButton(0, 0, -button_status, button_status); }