X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=ffd028953a4a7073ca1729af01a631f96e42081c;hb=b645a25fff77d62a36c744fa4047a3c0e5929341;hp=2ba138ffd67661107ee06d30444a21ceb36f20b3;hpb=7a7f090296fc140cb8d51bcc02759eb0d09ed8c8;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 2ba138ff..ffd02895 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; @@ -84,7 +79,7 @@ static boolean NextValidEvent(Event *event) void EventLoop(void) { - while(1) + while (1) { if (PendingEvent()) /* got event */ { @@ -224,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 == 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); } @@ -377,7 +374,11 @@ void HandleButton(int mx, int my, int button) old_my = my; } - HandleGadgets(mx, my, button); + if (HandleGadgets(mx, my, button)) + { + /* do not handle this button event anymore */ + mx = my = -32; /* force mouse event to be outside screen tiles */ + } switch(game_status) { @@ -401,7 +402,7 @@ void HandleButton(int mx, int my, int button) break; case GAME_MODE_INFO: - HandleHelpScreen(button); + HandleInfoScreen(mx,my, 0,0, button); break; case GAME_MODE_SETUP: @@ -412,11 +413,10 @@ void HandleButton(int mx, int my, int button) #ifdef DEBUG if (button == MB_RELEASED) { - int sx = (mx - SX) / TILEX; - int sy = (my - SY) / TILEY; - - if (IN_VIS_FIELD(sx,sy)) + if (IN_GFX_SCREEN(mx, my)) { + int sx = (mx - SX) / TILEX; + int sy = (my - SY) / TILEY; int x = LEVELX(sx); int y = LEVELY(sy); @@ -425,14 +425,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"); } } @@ -471,7 +476,7 @@ void HandleKey(Key key, int key_status) 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 @@ -804,7 +802,7 @@ void HandleKey(Key key, int key_status) { int i; - for(i=0; i