menu.list_size[game_status] : \
MAX_MENU_ENTRIES_ON_SCREEN)
+#define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \
+ NUM_MENU_ENTRIES_ON_SCREEN)
+
/* title display and control definitions */
#define MAX_NUM_TITLE_SCREENS (2 * MAX_NUM_TITLE_IMAGES + \
2 * MAX_NUM_TITLE_MESSAGES)
+#define NO_DIRECT_LEVEL_SELECT (-1)
+
+
static int num_title_screens = 0;
struct TitleControlInfo
if (pos_button != NULL) /* (x/y may be -1/-1 here) */
{
- if (pos_button->width == 0)
- pos_button->width = button_width;
- if (pos_button->height == 0)
- pos_button->height = button_height;
+ pos_button->width = button_width;
+ pos_button->height = button_height;
}
if (pos_text != NULL) /* (x/y may be -1/-1 here) */
/* calculate size for non-clickable text -- needed for text alignment */
boolean calculate_text_size = (pos_button == NULL && text != NULL);
+ if (pos_text->width == -1 || calculate_text_size)
+ pos_text->width = text_width;
+ if (pos_text->height == -1 || calculate_text_size)
+ pos_text->height = text_height;
+
if (visibleMenuPos(pos_button))
{
if (pos_text->x == -1)
pos_text->x = pos_button->x + pos_button->width;
if (pos_text->y == -1)
- pos_text->y = pos_button->y;
+ pos_text->y =
+ pos_button->y + (pos_button->height - pos_text->height) / 2;
}
-
- if (pos_text->width == -1 || calculate_text_size)
- pos_text->width = text_width;
- if (pos_text->height == -1 || calculate_text_size)
- pos_text->height = text_height;
}
if (pos_input != NULL) /* (x/y may be -1/-1 here) */
ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
if (DrawingOnBackground(dst_x, dst_y))
- {
- SetClipOrigin(bitmap, bitmap->stored_clip_gc, dst_x - src_x, dst_y - src_y);
BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
- }
else
BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y);
KeyboardAutoRepeatOn();
ActivateJoystick();
- SetDrawDeactivationMask(REDRAW_NONE);
- SetDrawBackgroundMask(REDRAW_FIELD);
-
audio.sound_deactivated = FALSE;
GetPlayerConfig();
LoadLevel(level_nr);
LoadScore(level_nr);
+ // set this after "ChangeViewportPropertiesIfNeeded()" (which may reset it)
+ SetDrawDeactivationMask(REDRAW_NONE);
+ SetDrawBackgroundMask(REDRAW_FIELD);
+
SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
if (fade_mask == REDRAW_ALL)
if (game_status == GAME_MODE_INFO)
{
+ int fade_mask = (num_title_screens == 0 ? REDRAW_FIELD : REDRAW_ALL);
+
info_mode = INFO_MODE_MAIN;
- DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
+ DrawInfoScreenExt(fade_mask, use_fading_main_menu);
}
else /* default: return to main menu */
{
}
}
-void HandleMainMenu_SelectLevel(int step, int direction)
+void HandleMainMenu_SelectLevel(int step, int direction, int selected_level_nr)
{
int old_level_nr = level_nr;
int new_level_nr;
- new_level_nr = old_level_nr + step * direction;
+ if (selected_level_nr != NO_DIRECT_LEVEL_SELECT)
+ new_level_nr = selected_level_nr;
+ else
+ new_level_nr = old_level_nr + step * direction;
+
if (new_level_nr < leveldir_current->first_level)
new_level_nr = leveldir_current->first_level;
if (new_level_nr > leveldir_current->last_level)
if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
{
/* skipping levels is only allowed when trying to skip single level */
- if (setup.skip_levels && step == 1 &&
+ if (setup.skip_levels && new_level_nr == old_level_nr + 1 &&
Request("Level still unsolved! Skip despite handicap?", REQ_ASK))
{
leveldir_current->handicap_level++;
/* needed because DrawPreviewLevelInitial() takes some time */
BackToFront();
- SyncDisplay();
+ /* SyncDisplay(); */
}
}
if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
{
- HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
+ HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT);
}
else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
{
- HandleMainMenu_SelectLevel(MAX_LEVELS, -1);
+ HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
}
else if (pos == MAIN_CONTROL_LAST_LEVEL && !button)
{
- HandleMainMenu_SelectLevel(MAX_LEVELS, +1);
+ HandleMainMenu_SelectLevel(MAX_LEVELS, +1, NO_DIRECT_LEVEL_SELECT);
}
else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
{
y += dy;
}
- if (IN_VIS_FIELD(x, y) &&
+ if (IN_VIS_MENU(x, y) &&
y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY)
{
if (button)
int ystart2 = mSY - SY + 150;
int ybottom = mSY - SY + SYSIZE - 20;
- SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO);
FadeOut(REDRAW_FIELD);
DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
"and");
DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
- "Jürgen Bonhagen");
+ "J\xfcrgen Bonhagen");
DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
"for the continuous creation");
DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
"Thanks to");
DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
- "Karl Hörnell");
+ "Karl H\xf6rnell");
DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
"for some additional toons");
}
{
struct TitleMessageInfo *tmi = &readme;
char *filename = getLevelSetInfoFilename();
+ char *title = "Level Set Information:";
+ int ystart1 = mSY - SY + 100;
+ int ybottom = mSY - SY + SYSIZE - 20;
+
+ if (filename == NULL)
+ {
+ DrawInfoScreen_NotAvailable(title, "No information for this level set.");
+
+ return;
+ }
+
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearField();
+ DrawHeadline();
+
+ DrawTextSCentered(ystart1, FONT_TEXT_1, title);
+
+ /* if x position set to "-1", automatically determine by playfield width */
+ if (tmi->x == -1)
+ tmi->x = SXSIZE / 2;
+
+ /* if y position set to "-1", use static default value */
+ if (tmi->y == -1)
+ tmi->y = 150;
+
+ /* if width set to "-1", automatically determine by playfield width */
+ if (tmi->width == -1)
+ tmi->width = SXSIZE - 2 * TILEX;
+
+ /* if height set to "-1", automatically determine by playfield height */
+ if (tmi->height == -1)
+ tmi->height = SYSIZE - 20 - tmi->y - 10;
/* if chars set to "-1", automatically determine by text and font width */
if (tmi->chars == -1)
else
tmi->height = tmi->lines * getFontHeight(tmi->font);
- SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
-
- FadeOut(REDRAW_FIELD);
-
- ClearField();
- DrawHeadline();
-
- DrawTextCentered(mSY + 100, FONT_TEXT_1, "Level Set Information:");
-
- if (filename != NULL)
- DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
- filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
- tmi->autowrap, tmi->centered, tmi->parse_comments);
- else
- DrawTextCentered(mSY + ALIGNED_TEXT_YPOS(tmi), FONT_TEXT_2,
- "No information for this level set.");
+ DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
+ filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
+ tmi->autowrap, tmi->centered, tmi->parse_comments);
- DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4,
- "Press any key or button for info menu");
+ DrawTextSCentered(ybottom, FONT_TEXT_4,
+ "Press any key or button for info menu");
FadeIn(REDRAW_FIELD);
}
strcpy(last_player_name, setup.player_name);
xpos = newxpos;
+
+#if defined(TARGET_SDL2)
+ SDL_StartTextInput();
+#endif
}
else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
{
startx = mSX + ALIGNED_TEXT_XPOS(pos);
DrawText(startx, starty, setup.player_name, font_nr);
+
+#if defined(TARGET_SDL2)
+ SDL_StopTextInput();
+#endif
}
}
static void DrawChooseTree(TreeInfo **ti_ptr)
{
+ int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
+
UnmapAllGadgets();
FreeScreenGadgets();
CloseDoor(DOOR_CLOSE_2);
- FadeOut(REDRAW_FIELD);
+ FadeOut(fade_mask);
ClearField();
HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
MapScreenTreeGadgets(*ti_ptr);
- FadeIn(REDRAW_FIELD);
+ FadeIn(fade_mask);
InitAnimation();
}
first_entry);
}
+static void clearMenuListArea()
+{
+ int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
+
+ /* correct scrollbar position if placed outside menu (playfield) area */
+ if (scrollbar_xpos > SX + SC_SCROLLBAR_XPOS)
+ scrollbar_xpos = SX + SC_SCROLLBAR_XPOS;
+
+ /* clear menu list area, but not title or scrollbar */
+ DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
+ scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32);
+}
+
static void drawChooseTreeList(int first_entry, int num_page_entries,
TreeInfo *ti)
{
DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
- /* clear tree list area, but not title or scrollbar */
- DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
- SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
- NUM_MENU_ENTRIES_ON_SCREEN * 32);
+ clearMenuListArea();
for (i = 0; i < num_page_entries; i++)
{
else
{
if (game_status == GAME_MODE_LEVELNR)
- level_nr = atoi(level_number_current->identifier);
+ {
+ int new_level_nr = atoi(level_number_current->identifier);
+
+ HandleMainMenu_SelectLevel(0, 0, new_level_nr);
+ }
game_status = GAME_MODE_MAIN;
}
if (!anyScrollbarGadgetActive() &&
- IN_VIS_FIELD(x, y) &&
+ IN_VIS_MENU(x, y) &&
mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
y >= 0 && y < num_page_entries)
{
else
{
if (game_status == GAME_MODE_LEVELNR)
- level_nr = atoi(level_number_current->identifier);
+ {
+ int new_level_nr = atoi(level_number_current->identifier);
+
+ HandleMainMenu_SelectLevel(0, 0, new_level_nr);
+ }
game_status = GAME_MODE_MAIN;
void DrawHallOfFame(int highlight_position)
{
+ int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
+
UnmapAllGadgets();
FadeSoundsAndMusic();
FadeSetEnterScreen();
- FadeOut(REDRAW_FIELD);
+ FadeOut(fade_mask);
InitAnimation();
HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE);
- FadeIn(REDRAW_FIELD);
+ FadeIn(fade_mask);
}
static void drawHallOfFameList(int first_entry, int highlight_position)
DrawSetupScreen();
}
+#if !defined(PLATFORM_ANDROID)
static void execSetupInput()
{
setup_mode = SETUP_MODE_INPUT;
DrawSetupScreen();
}
+#endif
static void execSetupShortcuts()
{
if (first_entry + num_page_entries > max_setup_info)
first_entry = 0;
- /* clear tree list area, but not title or scrollbar */
- DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32,
- SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset,
- NUM_MENU_ENTRIES_ON_SCREEN * 32);
+ clearMenuListArea();
for (i = 0; i < num_page_entries; i++)
{
static void DrawSetupScreen_Generic()
{
+ int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
boolean redraw_all = FALSE;
char *title_string = NULL;
int i;
if (redraw_mask & REDRAW_ALL)
redraw_all = TRUE;
- FadeOut(REDRAW_FIELD);
+ FadeOut(fade_mask);
ClearField();
MapScreenGadgets(max_setup_info);
if (redraw_all)
- redraw_mask = REDRAW_ALL;
+ redraw_mask = fade_mask = REDRAW_ALL;
- FadeIn(redraw_mask);
+ FadeIn(fade_mask);
InitAnimation();
}
setup_info[first_entry + y].type & TYPE_SKIP_ENTRY)
y += dy;
- if (!IN_VIS_FIELD(x, y))
+ if (!IN_VIS_MENU(x, y))
{
choice += y - y_old;
}
if (!anyScrollbarGadgetActive() &&
- IN_VIS_FIELD(x, y) &&
+ IN_VIS_MENU(x, y) &&
mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x &&
y >= 0 && y < num_page_entries)
{
{
HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1);
}
- else if (IN_VIS_FIELD(x, y) &&
+ else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet)
y >= pos_start && y <= pos_end &&
!(y >= pos_empty1 && y <= pos_empty2))
{
width = SC_SCROLLBUTTON_XSIZE;
height = SC_SCROLLBUTTON_YSIZE;
+ /* correct scrollbar position if placed outside menu (playfield) area */
+ if (x > SX + SC_SCROLL_UP_XPOS)
+ x = SX + SC_SCROLL_UP_XPOS;
+
if (id == SCREEN_CTRL_ID_SCROLL_DOWN)
y = mSY + (SC_SCROLL_VERTICAL_YPOS +
(NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE);
width = scrollbar_info[i].width;
height = scrollbar_info[i].height;
+ /* correct scrollbar position if placed outside menu (playfield) area */
+ if (x > SX + SC_SCROLL_VERTICAL_XPOS)
+ x = SX + SC_SCROLL_VERTICAL_XPOS;
+
if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL)
height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE;
switch (id)
{
case SCREEN_CTRL_ID_PREV_LEVEL:
- HandleMainMenu_SelectLevel(step, -1);
+ HandleMainMenu_SelectLevel(step, -1, NO_DIRECT_LEVEL_SELECT);
break;
case SCREEN_CTRL_ID_NEXT_LEVEL:
- HandleMainMenu_SelectLevel(step, +1);
+ HandleMainMenu_SelectLevel(step, +1, NO_DIRECT_LEVEL_SELECT);
break;
case SCREEN_CTRL_ID_PREV_PLAYER: