if (game_status != PLAYING)
{
XSync(display, FALSE);
- Delay(10);
+ if (!XPending(display)) /* delay only if no pending events */
+ Delay(10);
}
/* refresh window contents from drawing buffer, if needed */
HandleSetupInputScreen(0,0, 0,0, MB_MENU_CHOICE);
break;
+ case XK_Page_Up:
+ if (game_status == CHOOSELEVEL)
+ HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
+ break;
+
+ case XK_Page_Down:
+ if (game_status == CHOOSELEVEL)
+ HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
+ break;
+
default:
break;
}
/* level directory info */
{ TYPE_STRING, &ldi.name, "name" },
+ { TYPE_STRING, &ldi.name_short, "name_short" },
{ TYPE_STRING, &ldi.author, "author" },
{ TYPE_INTEGER, &ldi.levels, "levels" },
{ TYPE_INTEGER, &ldi.first_level, "first_level" },
static void setLevelDirInfoToDefaults(struct LevelDirInfo *ldi)
{
ldi->name = getStringCopy(ANONYMOUS_NAME);
+ ldi->name_short = NULL;
ldi->author = getStringCopy(ANONYMOUS_NAME);
ldi->levels = 0;
ldi->first_level = 0;
setSetupInfo(i, getTokenValue(setup_file_list, token_info[i].text));
leveldir[current_entry] = ldi;
+ if (leveldir[current_entry].name_short == NULL)
+ leveldir[current_entry].name_short =
+ getStringCopy(leveldir[current_entry].name);
+
leveldir[current_entry].filename = getStringCopy(dir_entry->d_name);
leveldir[current_entry].last_level =
leveldir[current_entry].first_level +
setLevelDirInfoToDefaults(&ldi);
ldi.name = getLoginName();
+ ldi.name_short = getLoginName();
ldi.author = getRealName();
ldi.levels = 100;
ldi.first_level = 1;
/* for DrawSetupScreen(), HandleSetupScreen() */
#define SETUP_SCREEN_POS_START 2
-#define SETUP_SCREEN_POS_END 16
+#define SETUP_SCREEN_POS_END (SCR_FIELDY - 1)
#define SETUP_SCREEN_POS_EMPTY1 (SETUP_SCREEN_POS_END - 2)
#define SETUP_SCREEN_POS_EMPTY2 (SETUP_SCREEN_POS_END - 2)
/* for HandleSetupInputScreen() */
#define SETUPINPUT_SCREEN_POS_START 2
-#define SETUPINPUT_SCREEN_POS_END 15
+#define SETUPINPUT_SCREEN_POS_END (SCR_FIELDY - 2)
#define SETUPINPUT_SCREEN_POS_EMPTY1 (SETUPINPUT_SCREEN_POS_START + 3)
#define SETUPINPUT_SCREEN_POS_EMPTY2 (SETUPINPUT_SCREEN_POS_END - 1)
/* for HandleChooseLevel() */
-#define MAX_LEVEL_SERIES_ON_SCREEN 15
+#define MAX_LEVEL_SERIES_ON_SCREEN (SCR_FIELDY - 2)
#ifdef MSDOS
extern unsigned char get_ascii(KeySym);
for(i=0; i<num_page_entries; i++)
{
- strncpy(buffer, leveldir[first_entry + i].name , SCR_FIELDX - 1);
+ strncpy(buffer, leveldir[first_entry + i].name_short , SCR_FIELDX - 1);
buffer[SCR_FIELDX - 1] = '\0';
DrawText(SX + 32, SY + (i + 2) * 32, buffer,
FS_BIG, leveldir[first_entry + i].color);
void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
{
static int choice = 3;
- static int first_entry = 0;
+ static int first_entry = -1;
static unsigned long choose_delay = 0;
static int redraw = TRUE;
int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
if (button == MB_MENU_INITIALIZE)
{
- redraw = TRUE;
- choice = leveldir_nr + 3 - first_entry;
-
- if (choice > num_page_entries + 2)
+ if (first_entry == -1)
{
- choice = num_page_entries + 2;
- first_entry = num_leveldirs - num_page_entries;
+ first_entry = leveldir_nr - num_page_entries + 1;
+ choice = leveldir_nr - first_entry + 3;
}
drawChooseLevelList(first_entry, num_page_entries);
drawChooseLevelInfo(leveldir_nr);
+ redraw = TRUE;
}
if (redraw)
y = choice + dy;
}
else
- x = y = 0;
+ x = y = 0; /* no action */
+
+ if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */
+ {
+ dy = SIGN(dy);
+ step = num_page_entries - 1;
+ x = 1;
+ y = (dy < 0 ? 2 : num_page_entries + 3);
+ }
}
if (x == 1 && y == 2)
if (first_entry > 0 &&
(dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
{
-#if 0
- first_entry--;
-#else
first_entry -= step;
if (first_entry < 0)
first_entry = 0;
-#endif
+
drawChooseLevelList(first_entry, num_page_entries);
drawChooseLevelInfo(first_entry);
DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);
if (first_entry + num_page_entries < num_leveldirs &&
(dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY)))
{
-#if 0
- first_entry++;
-#else
first_entry += step;
if (first_entry + num_page_entries > num_leveldirs)
first_entry = num_leveldirs - num_page_entries;
-#endif
+
drawChooseLevelList(first_entry, num_page_entries);
drawChooseLevelInfo(first_entry + num_page_entries - 1);
DrawGraphic(0, choice - 1, GFX_KUGEL_ROT);