X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=53b8171422ab97d250b7f66508d5944fff877726;hb=4ec434ee1acb955d0e2e8c33558e5f9226904174;hp=15f7205117ff592c9fac0de054796a5f2ae2a5df;hpb=21c25c56356db2138816a0716d73934ac3893e89;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index 15f72051..53b81714 100644 --- a/src/events.c +++ b/src/events.c @@ -20,8 +20,14 @@ #include "misc.h" #include "tape.h" #include "joystick.h" +#include "buttons.h" #include "network.h" +/* values for key_status */ +#define KEY_NOT_PRESSED FALSE +#define KEY_RELEASED FALSE +#define KEY_PRESSED TRUE + void EventLoop(void) { while(1) @@ -253,9 +259,11 @@ void HandleFocusEvent(XFocusChangeEvent *event) void HandleClientMessageEvent(XClientMessageEvent *event) { +#ifndef MSDOS if ((event->window == window) && (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE))) CloseAllAndExit(0); +#endif } void HandleButton(int mx, int my, int button) @@ -272,6 +280,7 @@ void HandleButton(int mx, int my, int button) old_mx = mx; old_my = my; + HandleGadgets(mx,my, button); HandleVideoButtons(mx,my, button); HandleSoundButtons(mx,my, button); HandleGameButtons(mx,my, button); @@ -420,15 +429,33 @@ void HandleKey(KeySym key, int key_status) /* allow quick escape to the main menu with the Escape key */ if (key == XK_Escape && game_status != MAINMENU) { - CloseDoor(DOOR_CLOSE_1 | DOOR_NO_DELAY); + if (game_status == LEVELED) + { + /* draw smaller door */ + XCopyArea(display, pix[PIX_DOOR], drawto, gc, + DOOR_GFX_PAGEX7, 64, + 108, 64, + EX - 4, EY - 12); + redraw_mask |= REDRAW_ALL; + } + + CloseDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); game_status = MAINMENU; DrawMainMenu(); return; } + + +#ifndef DEBUG + if (game_status == PLAYING && (tape.playing || tape.pausing)) return; +#endif + + + switch(game_status) { case TYPENAME: @@ -496,7 +523,12 @@ void HandleKey(KeySym key, int key_status) case XK_8: case XK_9: if (key == XK_0) - GameFrameDelay = 500; + { + if (GameFrameDelay == 500) + GameFrameDelay = GAME_FRAME_DELAY; + else + GameFrameDelay = 500; + } else GameFrameDelay = (key - XK_0) * 10; printf("Game speed == %d%% (%d ms delay between two frames)\n", @@ -582,8 +614,10 @@ void HandleNoXEvent() return; } +#ifndef MSDOS if (options.network) HandleNetworking(); +#endif HandleJoystick(); @@ -600,12 +634,19 @@ static int HandleJoystickForAllPlayers() { byte joy_action = 0; + /* if (!setup.input[i].use_joystick) continue; + */ joy_action = Joystick(i); result |= joy_action; + + if (!setup.input[i].use_joystick) + continue; + + stored_player[i].action = joy_action; } @@ -633,9 +674,9 @@ void HandleJoystick() case SETUP: case SETUPINPUT: { - static long joystickmove_delay = 0; + static unsigned long joystickmove_delay = 0; - if (joystick && !button && !DelayReached(&joystickmove_delay,150)) + if (joystick && !button && !DelayReached(&joystickmove_delay, 150)) newbutton = dx = dy = 0; if (game_status==MAINMENU)