projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20001205-3-src
[rocksndiamonds.git]
/
src
/
events.c
diff --git
a/src/events.c
b/src/events.c
index a46f3548117071086e8be052b6024e40e7c0647b..1e2ca16841661450886d719a2f701e0c8eea49be 100644
(file)
--- a/
src/events.c
+++ b/
src/events.c
@@
-1,26
+1,26
@@
/***********************************************************
/***********************************************************
-*
Rocks'n'Diamonds -- McDuffin Strikes Back!
*
+*
Rocks'n'Diamonds -- McDuffin Strikes Back!
*
*----------------------------------------------------------*
*----------------------------------------------------------*
-*
(c) 1995-98 Artsoft Entertainment
*
-*
Holger Schemel
*
-*
Oststrasse 11a
*
-*
33604 Bielefeld
*
-*
phone: ++49 +521 290471
*
-*
email: aeglos@valinor.owl.de
*
+*
(c) 1995-2000 Artsoft Entertainment
*
+*
Holger Schemel
*
+*
Detmolder Strasse 189
*
+*
33604 Bielefeld
*
+*
Germany
*
+*
e-mail: info@artsoft.org
*
*----------------------------------------------------------*
*----------------------------------------------------------*
-*
events.c
*
+*
events.c
*
***********************************************************/
***********************************************************/
+#include "libgame/libgame.h"
+
#include "events.h"
#include "init.h"
#include "screens.h"
#include "tools.h"
#include "game.h"
#include "editor.h"
#include "events.h"
#include "init.h"
#include "screens.h"
#include "tools.h"
#include "game.h"
#include "editor.h"
-#include "misc.h"
#include "tape.h"
#include "joystick.h"
#include "tape.h"
#include "joystick.h"
-#include "buttons.h"
#include "network.h"
/* values for key_status */
#include "network.h"
/* values for key_status */
@@
-33,7
+33,7
@@
delay problems with lots of mouse motion events when mouse
button not pressed */
delay problems with lots of mouse motion events when mouse
button not pressed */
-int
EventFilter
(const Event *event)
+int
FilterMouseMotionEvents
(const Event *event)
{
if (event->type != EVENT_MOTIONNOTIFY)
return 1;
{
if (event->type != EVENT_MOTIONNOTIFY)
return 1;
@@
-55,7
+55,7
@@
void EventLoop(void)
NextEvent(&event);
NextEvent(&event);
- if (
EventFilter
(&event))
+ if (
FilterMouseMotionEvents
(&event))
{
switch(event.type)
{
{
switch(event.type)
{
@@
-79,13
+79,15
@@
void EventLoop(void)
}
}
}
}
}
}
-
-
HandleNoX
Event();
+ else
+
HandleNo
Event();
/* don't use all CPU time when idle; the main loop while playing
has its own synchronization and is CPU friendly, too */
/* 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 == PLAYING)
+ HandleGameActions();
+ else
{
SyncDisplay();
if (!PendingEvent()) /* delay only if no pending events */
{
SyncDisplay();
if (!PendingEvent()) /* delay only if no pending events */
@@
-121,7
+123,7
@@
void HandleOtherEvents(Event *event)
HandleClientMessageEvent((ClientMessageEvent *) event);
break;
HandleClientMessageEvent((ClientMessageEvent *) event);
break;
-#if
def USE_SDL_LIBRARY
+#if
defined(TARGET_SDL)
case SDL_JOYAXISMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_JOYAXISMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
@@
-204,7
+206,7
@@
void SleepWhileUnmapped()
void HandleExposeEvent(ExposeEvent *event)
{
void HandleExposeEvent(ExposeEvent *event)
{
-#ifndef
USE_SDL_LIBRARY
+#ifndef
TARGET_SDL
int x = event->x, y = event->y;
int width = event->width, height = event->height;
int x = event->x, y = event->y;
int width = event->width, height = event->height;
@@
-258,7
+260,7
@@
void HandleMotionEvent(MotionEvent *event)
if (!PointerInWindow(window))
return; /* window and pointer are on different screens */
if (!PointerInWindow(window))
return; /* window and pointer are on different screens */
-#if
0
+#if
1
if (button_status == MB_RELEASED && game_status != LEVELED)
return;
#endif
if (button_status == MB_RELEASED && game_status != LEVELED)
return;
#endif
@@
-324,15
+326,8
@@
void HandleFocusEvent(FocusChangeEvent *event)
void HandleClientMessageEvent(ClientMessageEvent *event)
{
void HandleClientMessageEvent(ClientMessageEvent *event)
{
-#ifdef USE_SDL_LIBRARY
- CloseAllAndExit(0); /* the only possible message here is SDL_QUIT */
-#else
-#ifndef MSDOS
- if ((event->window == window) &&
- (event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE)))
+ if (CheckCloseWindowEvent(event))
CloseAllAndExit(0);
CloseAllAndExit(0);
-#endif
-#endif
}
void HandleButton(int mx, int my, int button)
}
void HandleButton(int mx, int my, int button)
@@
-360,7
+355,7
@@
void HandleButton(int mx, int my, int button)
break;
case TYPENAME:
break;
case TYPENAME:
- HandleTypeName(0, K
EY
_Return);
+ HandleTypeName(0, K
SYM
_Return);
break;
case CHOOSELEVEL:
break;
case CHOOSELEVEL:
@@
-424,6
+419,7
@@
void HandleButton(int mx, int my, int button)
void HandleKey(Key key, int key_status)
{
int joy = 0;
void HandleKey(Key key, int key_status)
{
int joy = 0;
+ boolean anyTextGadgetActiveOrJustFinished = anyTextGadgetActive();
static struct SetupKeyboardInfo custom_key;
static struct
{
static struct SetupKeyboardInfo custom_key;
static struct
{
@@
-489,7
+485,7
@@
void HandleKey(Key key, int key_status)
if (key_status == KEY_RELEASED)
return;
if (key_status == KEY_RELEASED)
return;
- if ((key == K
EY_Return || key == KEY
_space) &&
+ if ((key == K
SYM_Return || key == KSYM
_space) &&
game_status == PLAYING && AllPlayersGone)
{
CloseDoor(DOOR_CLOSE_1);
game_status == PLAYING && AllPlayersGone)
{
CloseDoor(DOOR_CLOSE_1);
@@
-499,7
+495,7
@@
void HandleKey(Key key, int key_status)
}
/* allow quick escape to the main menu with the Escape key */
}
/* allow quick escape to the main menu with the Escape key */
- if (key == K
EY
_Escape && game_status != MAINMENU)
+ if (key == K
SYM
_Escape && game_status != MAINMENU)
{
CloseDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
game_status = MAINMENU;
{
CloseDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
game_status = MAINMENU;
@@
-532,8
+528,8
@@
void HandleKey(Key key, int key_status)
case SETUPINPUT:
switch(key)
{
case SETUPINPUT:
switch(key)
{
- case K
EY
_Return:
- case K
EY
_space:
+ case K
SYM
_Return:
+ case K
SYM
_space:
if (game_status == MAINMENU)
HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE);
else if (game_status == CHOOSELEVEL)
if (game_status == MAINMENU)
HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE);
else if (game_status == CHOOSELEVEL)
@@
-544,12
+540,12
@@
void HandleKey(Key key, int key_status)
HandleSetupInputScreen(0,0, 0,0, MB_MENU_CHOICE);
break;
HandleSetupInputScreen(0,0, 0,0, MB_MENU_CHOICE);
break;
- case K
EY
_Page_Up:
+ case K
SYM
_Page_Up:
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
- case K
EY
_Page_Down:
+ case K
SYM
_Page_Down:
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
@@
-566,18
+562,18
@@
void HandleKey(Key key, int key_status)
case HALLOFFAME:
switch(key)
{
case HALLOFFAME:
switch(key)
{
- case K
EY
_Return:
- case K
EY
_space:
+ case K
SYM
_Return:
+ case K
SYM
_space:
game_status = MAINMENU;
DrawMainMenu();
BackToFront();
break;
game_status = MAINMENU;
DrawMainMenu();
BackToFront();
break;
- case K
EY
_Page_Up:
+ case K
SYM
_Page_Up:
HandleHallOfFame(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
HandleHallOfFame(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
- case K
EY
_Page_Down:
+ case K
SYM
_Page_Down:
HandleHallOfFame(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
HandleHallOfFame(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
@@
-587,7
+583,8
@@
void HandleKey(Key key, int key_status)
break;
case LEVELED:
break;
case LEVELED:
- HandleLevelEditorKeyInput(key);
+ if (!anyTextGadgetActiveOrJustFinished)
+ HandleLevelEditorKeyInput(key);
break;
case PLAYING:
break;
case PLAYING:
@@
-596,17
+593,17
@@
void HandleKey(Key key, int key_status)
{
#ifdef DEBUG
{
#ifdef DEBUG
- case K
EY
_0:
- case K
EY
_1:
- case K
EY
_2:
- case K
EY
_3:
- case K
EY
_4:
- case K
EY
_5:
- case K
EY
_6:
- case K
EY
_7:
- case K
EY
_8:
- case K
EY
_9:
- if (key == K
EY
_0)
+ case K
SYM
_0:
+ case K
SYM
_1:
+ case K
SYM
_2:
+ case K
SYM
_3:
+ case K
SYM
_4:
+ case K
SYM
_5:
+ case K
SYM
_6:
+ case K
SYM
_7:
+ case K
SYM
_8:
+ case K
SYM
_9:
+ if (key == K
SYM
_0)
{
if (GameFrameDelay == 500)
GameFrameDelay = GAME_FRAME_DELAY;
{
if (GameFrameDelay == 500)
GameFrameDelay = GAME_FRAME_DELAY;
@@
-614,12
+611,12
@@
void HandleKey(Key key, int key_status)
GameFrameDelay = 500;
}
else
GameFrameDelay = 500;
}
else
- GameFrameDelay = (key - K
EY
_0) * 10;
+ GameFrameDelay = (key - K
SYM
_0) * 10;
printf("Game speed == %d%% (%d ms delay between two frames)\n",
GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
break;
printf("Game speed == %d%% (%d ms delay between two frames)\n",
GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
break;
- case K
EY
_d:
+ case K
SYM
_d:
if (options.debug)
{
options.debug = FALSE;
if (options.debug)
{
options.debug = FALSE;
@@
-632,7
+629,7
@@
void HandleKey(Key key, int key_status)
}
break;
}
break;
- case K
EY
_s:
+ case K
SYM
_s:
if (!global.fps_slowdown)
{
global.fps_slowdown = TRUE;
if (!global.fps_slowdown)
{
global.fps_slowdown = TRUE;
@@
-653,7
+650,7
@@
void HandleKey(Key key, int key_status)
break;
#if 0
break;
#if 0
- case K
EY
_a:
+ case K
SYM
_a:
if (ScrollStepSize == TILEX/8)
ScrollStepSize = TILEX/4;
else
if (ScrollStepSize == TILEX/8)
ScrollStepSize = TILEX/4;
else
@@
-663,7
+660,7
@@
void HandleKey(Key key, int key_status)
#endif
#if 0
#endif
#if 0
- case K
EY
_m:
+ case K
SYM
_m:
if (MoveSpeed == 8)
{
MoveSpeed = 4;
if (MoveSpeed == 8)
{
MoveSpeed = 4;
@@
-678,30
+675,28
@@
void HandleKey(Key key, int key_status)
break;
#endif
break;
#endif
- case K
EY
_f:
+ case K
SYM
_f:
ScrollStepSize = TILEX/8;
printf("ScrollStepSize == %d (1/8)\n", ScrollStepSize);
break;
ScrollStepSize = TILEX/8;
printf("ScrollStepSize == %d (1/8)\n", ScrollStepSize);
break;
- case K
EY
_g:
+ case K
SYM
_g:
ScrollStepSize = TILEX/4;
printf("ScrollStepSize == %d (1/4)\n", ScrollStepSize);
break;
ScrollStepSize = TILEX/4;
printf("ScrollStepSize == %d (1/4)\n", ScrollStepSize);
break;
- case K
EY
_h:
+ case K
SYM
_h:
ScrollStepSize = TILEX/2;
printf("ScrollStepSize == %d (1/2)\n", ScrollStepSize);
break;
ScrollStepSize = TILEX/2;
printf("ScrollStepSize == %d (1/2)\n", ScrollStepSize);
break;
- case K
EY
_l:
+ case K
SYM
_l:
ScrollStepSize = TILEX;
printf("ScrollStepSize == %d (1/1)\n", ScrollStepSize);
break;
ScrollStepSize = TILEX;
printf("ScrollStepSize == %d (1/1)\n", ScrollStepSize);
break;
-#ifndef MSDOS
- case KEY_Q:
-#endif
- case KEY_q:
+ case KSYM_Q:
+ case KSYM_q:
local_player->dynamite = 1000;
break;
local_player->dynamite = 1000;
break;
@@
-709,7
+704,7
@@
void HandleKey(Key key, int key_status)
#if 0
#if 0
- case K
EY
_z:
+ case K
SYM
_z:
{
int i;
{
int i;
@@
-738,7
+733,7
@@
void HandleKey(Key key, int key_status)
}
}
}
}
-void HandleNo
X
Event()
+void HandleNoEvent()
{
if (button_status && game_status != PLAYING)
{
{
if (button_status && game_status != PLAYING)
{
@@
-746,15
+741,12
@@
void HandleNoXEvent()
return;
}
return;
}
-#if
!defined(MSDOS) && !defined(WIN32
)
+#if
defined(PLATFORM_UNIX
)
if (options.network)
HandleNetworking();
#endif
HandleJoystick();
if (options.network)
HandleNetworking();
#endif
HandleJoystick();
-
- if (game_status == PLAYING)
- HandleGameActions();
}
static int HandleJoystickForAllPlayers()
}
static int HandleJoystickForAllPlayers()