X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fevents.c;h=e46b177553430e80ffb8fdac0ad6f0246d65921c;hb=5ed4de42ced8e7dce5b786ba3d5fd1a6f6a7d7f6;hp=ed76f9a655beac4341b36a1cb80bb4cfda26b5fb;hpb=f9a30d8f0565691424cc9fd2643a50a176dae903;p=rocksndiamonds.git diff --git a/src/events.c b/src/events.c index ed76f9a6..e46b1775 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,42 +259,47 @@ 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) { static int old_mx = 0, old_my = 0; - if (mx<0 || my<0) + if (button < 0) { mx = old_mx; my = old_my; + button = -button; } else { old_mx = mx; old_my = my; - HandleVideoButtons(mx,my,button); - HandleSoundButtons(mx,my,button); - HandleGameButtons(mx,my,button); + HandleVideoButtons(mx,my, button); + HandleSoundButtons(mx,my, button); + HandleGameButtons(mx,my, button); } + HandleGadgets(mx, my, button); + switch(game_status) { case MAINMENU: - HandleMainMenu(mx,my,0,0,button); + HandleMainMenu(mx,my, 0,0, button); break; case TYPENAME: - HandleTypeName(0,XK_Return); + HandleTypeName(0, XK_Return); break; case CHOOSELEVEL: - HandleChooseLevel(mx,my,0,0,button); + HandleChooseLevel(mx,my, 0,0, button); break; case HALLOFFAME: @@ -296,7 +307,7 @@ void HandleButton(int mx, int my, int button) break; case LEVELED: - LevelEd(mx,my,button); + LevelEd(mx,my, button); break; case HELPSCREEN: @@ -304,11 +315,11 @@ void HandleButton(int mx, int my, int button) break; case SETUP: - HandleSetupScreen(mx,my,0,0,button); + HandleSetupScreen(mx,my, 0,0, button); break; case SETUPINPUT: - HandleSetupInputScreen(mx,my,0,0,button); + HandleSetupInputScreen(mx,my, 0,0, button); break; case PLAYING: @@ -420,15 +431,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 +525,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", @@ -545,80 +579,6 @@ void HandleKey(KeySym key, int key_status) #if 0 - case XK_x: - - { - int i,j,k, num_steps = 8, step_size = TILEX / num_steps; - static long scroll_delay=0; - long scroll_delay_value = 4*4 / num_steps; - - printf("Scroll test\n"); - - for(i=0;i<3;i++) - { - for(j=0;j