X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=92cda6925740c592f8715e214c23593500fe4e69;hb=74c0f7de91268e40d15948f473eac51a9760b9c0;hp=ffe1d4f0b09b306762c9560bab9a8ccf66a264c7;hpb=e57078603232563176d90bb543ce2bc3a15b889e;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index ffe1d4f0..92cda692 100644 --- a/src/events.c +++ b/src/events.c @@ -23,11 +23,6 @@ #include "tape.h" #include "network.h" -/* values for key_status */ -#define KEY_NOT_PRESSED FALSE -#define KEY_RELEASED FALSE -#define KEY_PRESSED TRUE - static boolean cursor_inside_playfield = FALSE; static boolean playfield_cursor_set = FALSE; @@ -50,7 +45,7 @@ int FilterMouseMotionEvents(const Event *event) cursor_inside_playfield = (motion->x >= SX && motion->x < SX + SXSIZE && motion->y >= SY && motion->y < SY + SYSIZE); - if (game_status == PLAYING && playfield_cursor_set) + if (game_status == GAME_MODE_PLAYING && playfield_cursor_set) { SetMouseCursor(CURSOR_DEFAULT); playfield_cursor_set = FALSE; @@ -58,7 +53,8 @@ int FilterMouseMotionEvents(const Event *event) } /* skip mouse motion events without pressed button outside level editor */ - if (button_status == MB_RELEASED && game_status != LEVELED) + if (button_status == MB_RELEASED && game_status != GAME_MODE_EDITOR && + game_status != GAME_MODE_PLAYING) return 0; else return 1; @@ -83,7 +79,7 @@ static boolean NextValidEvent(Event *event) void EventLoop(void) { - while(1) + while (1) { if (PendingEvent()) /* got event */ { @@ -116,7 +112,7 @@ void EventLoop(void) else { /* when playing, display a special mouse pointer inside the playfield */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { if (!playfield_cursor_set && cursor_inside_playfield && DelayReached(&playfield_cursor_delay, 1000)) @@ -137,7 +133,7 @@ void EventLoop(void) /* don't use all CPU time when idle; the main loop while playing has its own synchronization and is CPU friendly, too */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) HandleGameActions(); else { @@ -149,7 +145,7 @@ void EventLoop(void) /* refresh window contents from drawing buffer, if needed */ BackToFront(); - if (game_status == EXITGAME) + if (game_status == GAME_MODE_QUIT) return; } } @@ -223,7 +219,7 @@ void ClearPlayerAction() /* simulate key release events for still pressed keys */ key_joystick_mapping = 0; - for (i=0; itype==EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED); - boolean with_modifiers = (game_status == PLAYING ? FALSE : TRUE); + boolean with_modifiers = (game_status == GAME_MODE_PLAYING ? FALSE : TRUE); Key key = GetEventKey(event, with_modifiers); + Key keymod = (with_modifiers ? GetEventKey(event, FALSE) : key); + HandleKeyModState(keymod, key_status); HandleKey(key, key_status); } @@ -339,15 +337,15 @@ void HandleFocusEvent(FocusChangeEvent *event) because unfortunately this is a global setting and not (which would be far better) set for each X11 window individually. The effect would be keyboard auto repeat while playing the game - (game_status == PLAYING), which is not desired. + (game_status == GAME_MODE_PLAYING), which is not desired. To avoid this special case, we just wait 1/10 second before processing the 'FocusIn' event. */ - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { Delay(100); - KeyboardAutoRepeatOff(); + KeyboardAutoRepeatOffUnlessAutoplay(); } if (old_joystick_status != -1) joystick.status = old_joystick_status; @@ -380,34 +378,34 @@ void HandleButton(int mx, int my, int button) switch(game_status) { - case MAINMENU: + case GAME_MODE_MAIN: HandleMainMenu(mx,my, 0,0, button); break; - case TYPENAME: + case GAME_MODE_PSEUDO_TYPENAME: HandleTypeName(0, KSYM_Return); break; - case CHOOSELEVEL: + case GAME_MODE_LEVELS: HandleChooseLevel(mx,my, 0,0, button); break; - case HALLOFFAME: + case GAME_MODE_SCORES: HandleHallOfFame(0,0, 0,0, button); break; - case LEVELED: + case GAME_MODE_EDITOR: break; - case HELPSCREEN: - HandleHelpScreen(button); + case GAME_MODE_INFO: + HandleInfoScreen(button); break; - case SETUP: + case GAME_MODE_SETUP: HandleSetupScreen(mx,my, 0,0, button); break; - case PLAYING: + case GAME_MODE_PLAYING: #ifdef DEBUG if (button == MB_RELEASED) { @@ -424,13 +422,19 @@ void HandleButton(int mx, int my, int button) if (!IN_LEV_FIELD(x, y)) break; - printf(" Feld[%d][%d] == %d\n", x,y, Feld[x][y]); + printf(" Feld[%d][%d] == %d ('%s')\n", x,y, Feld[x][y], + element_info[Feld[x][y]].token_name); + printf(" Back[%d][%d] == %d\n", x,y, Back[x][y]); printf(" Store[%d][%d] == %d\n", x,y, Store[x][y]); printf(" Store2[%d][%d] == %d\n", x,y, Store2[x][y]); printf(" StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]); printf(" MovPos[%d][%d] == %d\n", x,y, MovPos[x][y]); printf(" MovDir[%d][%d] == %d\n", x,y, MovDir[x][y]); printf(" MovDelay[%d][%d] == %d\n", x,y, MovDelay[x][y]); + printf(" ChangeDelay[%d][%d] == %d\n", x,y, ChangeDelay[x][y]); + printf(" GfxElement[%d][%d] == %d\n", x,y, GfxElement[x][y]); + printf(" GfxAction[%d][%d] == %d\n", x,y, GfxAction[x][y]); + printf(" GfxFrame[%d][%d] == %d\n", x,y, GfxFrame[x][y]); printf("\n"); } } @@ -462,14 +466,14 @@ void HandleKey(Key key, int key_status) { &custom_key.bomb, DEFAULT_KEY_BOMB, JOY_BUTTON_2 } }; - if (game_status == PLAYING) + if (game_status == GAME_MODE_PLAYING) { /* only needed for single-step tape recording mode */ static boolean clear_button_2[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; static boolean bomb_placed[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; int pnr; - for (pnr=0; pnrdynamite = 1000; - break; + { + int i; + for (i = 0; i < MAX_INVENTORY_SIZE; i++) + if (local_player->inventory_size < MAX_INVENTORY_SIZE) + local_player->inventory_element[local_player->inventory_size++] = + EL_DYNAMITE; + } + + break; #if 0 @@ -802,7 +813,7 @@ void HandleKey(Key key, int key_status) { int i; - for(i=0; i