void EventLoop(void)
{
- while(1)
+ while (1)
{
if (PendingEvent()) /* got event */
{
/* simulate key release events for still pressed keys */
key_joystick_mapping = 0;
- for (i=0; i<MAX_PLAYERS; i++)
+ for (i = 0; i < MAX_PLAYERS; i++)
stored_player[i].action = 0;
}
KeyboardAutoRepeatOn();
- while(window_unmapped)
+ while (window_unmapped)
{
Event event;
old_my = my;
}
- HandleGadgets(mx, my, button);
+ if (HandleGadgets(mx, my, button))
+ {
+ /* do not handle this button event anymore */
+ mx = my = 0;
+ }
switch(game_status)
{
break;
case GAME_MODE_INFO:
- HandleHelpScreen(button);
+ HandleInfoScreen(mx,my, 0,0, button);
break;
case GAME_MODE_SETUP:
#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);
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(" 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");
}
}
static boolean bomb_placed[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE };
int pnr;
- for (pnr=0; pnr<MAX_PLAYERS; pnr++)
+ for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
{
int i;
byte key_action = 0;
custom_key = setup.input[pnr].key;
- for (i=0; i<6; i++)
+ for (i = 0; i < 6; i++)
if (key == *key_info[i].key_custom)
key_action |= key_info[i].action;
{
int i;
- for (i=0; i<6; i++)
+ for (i = 0; i < 6; i++)
if (key == key_info[i].key_default)
joy |= key_info[i].action;
}
return;
}
- /* allow quick escape to the main menu with the Escape key */
- if (key == KSYM_Escape &&
- game_status != GAME_MODE_MAIN &&
- game_status != GAME_MODE_PLAYING &&
- game_status != GAME_MODE_EDITOR &&
- game_status != GAME_MODE_LEVELS &&
- game_status != GAME_MODE_SETUP)
- {
- game_status = GAME_MODE_MAIN;
- DrawMainMenu();
- return;
- }
-
/* special key shortcuts */
if (game_status == GAME_MODE_MAIN || game_status == GAME_MODE_PLAYING)
{
TapeTogglePause(TAPE_TOGGLE_MANUAL);
}
-#if 0
-#ifndef DEBUG
-
- if (game_status == GAME_MODE_PLAYING && (tape.playing || tape.pausing))
- return;
-
-#endif
-#endif
-
-
- HandleGadgetsKeyInput(key);
+ if (HandleGadgetsKeyInput(key))
+ {
+ if (key != KSYM_Escape) /* always allow ESC key to be handled */
+ key = KSYM_UNDEFINED;
+ }
switch(game_status)
{
case GAME_MODE_MAIN:
case GAME_MODE_LEVELS:
case GAME_MODE_SETUP:
+ case GAME_MODE_INFO:
switch(key)
{
case KSYM_Return:
HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE);
else if (game_status == GAME_MODE_SETUP)
HandleSetupScreen(0,0, 0,0, MB_MENU_CHOICE);
+ else if (game_status == GAME_MODE_INFO)
+ HandleInfoScreen(0,0, 0,0, MB_MENU_CHOICE);
break;
case KSYM_Escape:
HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE);
else if (game_status == GAME_MODE_SETUP)
HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE);
+ else if (game_status == GAME_MODE_INFO)
+ HandleInfoScreen(0,0, 0,0, MB_MENU_LEAVE);
break;
case KSYM_Page_Up:
HandleChooseLevel(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
else if (game_status == GAME_MODE_SETUP)
HandleSetupScreen(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
+ else if (game_status == GAME_MODE_INFO)
+ HandleInfoScreen(0,0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK);
break;
case KSYM_Page_Down:
HandleChooseLevel(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
else if (game_status == GAME_MODE_SETUP)
HandleSetupScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
+ else if (game_status == GAME_MODE_INFO)
+ HandleInfoScreen(0,0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK);
break;
#ifdef DEBUG
}
break;
- case GAME_MODE_INFO:
- HandleHelpScreen(MB_RELEASED);
- break;
-
case GAME_MODE_SCORES:
switch(key)
{
case KSYM_Return:
+ case KSYM_Escape:
game_status = GAME_MODE_MAIN;
DrawMainMenu();
- BackToFront();
break;
case KSYM_Page_Up:
{
int i;
- for (i=0; i < MAX_INVENTORY_SIZE; 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;
{
int i;
- for(i=0; i<MAX_PLAYERS; i++)
+ for (i = 0; i < MAX_PLAYERS; i++)
{
printf("Player %d:\n", i);
printf(" jx == %d, jy == %d\n",
break;
}
default:
- break;
+ if (key == KSYM_Escape)
+ {
+ game_status = GAME_MODE_MAIN;
+ DrawMainMenu();
+
+ return;
+ }
}
}
int i;
int result = 0;
- for (i=0; i<MAX_PLAYERS; i++)
+ for (i = 0; i < MAX_PLAYERS; i++)
{
byte joy_action = 0;
case GAME_MODE_MAIN:
case GAME_MODE_LEVELS:
case GAME_MODE_SETUP:
+ case GAME_MODE_INFO:
{
static unsigned long joystickmove_delay = 0;
HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
else if (game_status == GAME_MODE_SETUP)
HandleSetupScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
+ else if (game_status == GAME_MODE_INFO)
+ HandleInfoScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK);
break;
}
HandleHallOfFame(0,0, dx,dy, !newbutton);
break;
- case GAME_MODE_INFO:
- HandleHelpScreen(!newbutton);
- break;
-
case GAME_MODE_EDITOR:
HandleLevelEditorIdle();
break;