} volumes_list[] =
{
{ 0, "0 %" },
+ { 1, "1 %" },
+ { 2, "2 %" },
+ { 5, "5 %" },
{ 10, "10 %" },
{ 20, "20 %" },
{ 30, "30 %" },
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) */
}
}
+static void DrawPressedGraphicThruMask(int dst_x, int dst_y,
+ int graphic, boolean pressed)
+{
+ struct GraphicInfo *g = &graphic_info[graphic];
+ Bitmap *src_bitmap;
+ int src_x, src_y;
+ int xoffset = (pressed ? g->pressed_xoffset : 0);
+ int yoffset = (pressed ? g->pressed_yoffset : 0);
+
+ getFixedGraphicSource(graphic, 0, &src_bitmap, &src_x, &src_y);
+
+ BlitBitmapMasked(src_bitmap, drawto, src_x + xoffset, src_y + yoffset,
+ g->width, g->height, dst_x, dst_y);
+}
+
static void DrawCursorAndText_Main_Ext(int nr, boolean active_text,
- boolean active_input)
+ boolean active_input,
+ boolean pressed_button)
{
int i;
int y = mSY + pos->y;
DrawBackgroundForGraphic(x, y, pos->width, pos->height, button_graphic);
- DrawFixedGraphicThruMaskExt(drawto, x, y, button_graphic, 0);
+ DrawPressedGraphicThruMask(x, y, button_graphic, pressed_button);
}
if (visibleTextPos(pos_text) && text != NULL)
}
}
-static void DrawCursorAndText_Main(int nr, boolean active_text)
+static void DrawCursorAndText_Main(int nr, boolean active_text,
+ boolean pressed_button)
{
- DrawCursorAndText_Main_Ext(nr, active_text, FALSE);
+ DrawCursorAndText_Main_Ext(nr, active_text, FALSE, pressed_button);
}
#if 0
-static void DrawCursorAndText_Main_Input(int nr, boolean active_text)
+static void DrawCursorAndText_Main_Input(int nr, boolean active_text,
+ boolean pressed_button)
{
- DrawCursorAndText_Main_Ext(nr, active_text, TRUE);
+ DrawCursorAndText_Main_Ext(nr, active_text, TRUE, pressed_button);
}
#endif
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)
- RedrawBackground();
+ RedrawGlobalBorder();
ClearField();
InitializeMainControls();
- DrawCursorAndText_Main(-1, FALSE);
+ DrawCursorAndText_Main(-1, FALSE, FALSE);
DrawPreviewLevelInitial();
HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
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(int mx, int my, int dx, int dy, int button)
{
static int choice = MAIN_CONTROL_GAME;
+ static boolean button_pressed_last = FALSE;
+ boolean button_pressed = FALSE;
int pos = choice;
int i;
if (button == MB_MENU_INITIALIZE)
{
- DrawCursorAndText_Main(choice, TRUE);
+ DrawCursorAndText_Main(choice, TRUE, FALSE);
return;
}
break;
}
}
+
+ // handle pressed/unpressed state for active/inactive menu buttons
+ // (if pos != -1, "i" contains index position corresponding to "pos")
+ if (button &&
+ pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT &&
+ insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY))
+ button_pressed = TRUE;
+
+ if (button_pressed != button_pressed_last)
+ DrawCursorAndText_Main(choice, TRUE, button_pressed);
}
else if (dx || dy) /* keyboard input */
{
{
PlaySound(SND_MENU_ITEM_ACTIVATING);
- DrawCursorAndText_Main(choice, FALSE);
- DrawCursorAndText_Main(pos, TRUE);
+ DrawCursorAndText_Main(choice, FALSE, FALSE);
+ DrawCursorAndText_Main(pos, TRUE, button_pressed);
choice = pos;
}
}
}
}
+
+ button_pressed_last = button_pressed;
}
if (fade_mask == REDRAW_ALL)
{
- RedrawBackground();
+ RedrawGlobalBorder();
OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
}
int ystart2 = mSY - SY + 150;
int ybottom = mSY - SY + SYSIZE - 20;
- SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO);
FadeOut(REDRAW_FIELD);
{
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);
}
static void DrawChooseTree(TreeInfo **ti_ptr)
{
+ int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
+
+ if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
+ {
+ game_status = GAME_MODE_MAIN;
+
+ DrawMainMenuExt(REDRAW_FIELD, FALSE);
+
+ return;
+ }
+
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();
}
int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
/* correct scrollbar position if placed outside menu (playfield) area */
- if (scrollbar_xpos > SC_SCROLLBAR_XPOS)
- scrollbar_xpos = SC_SCROLLBAR_XPOS;
+ 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,
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)
{
if (volumes_simple == NULL)
{
+ boolean current_volume_simple_found = FALSE;
int i;
for (i = 0; volumes_list[i].value != -1; i++)
setString(&ti->infotext, "Sound Volume");
pushTreeInfo(&volumes_simple, ti);
+
+ if (value == setup.volume_simple)
+ current_volume_simple_found = TRUE;
+ }
+
+ if (!current_volume_simple_found)
+ {
+ // add entry for non-preset volume value
+
+ TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+ char identifier[32], name[32];
+ int value = setup.volume_simple;
+
+ ti->node_top = &volumes_simple;
+ ti->sort_priority = value;
+
+ sprintf(identifier, "%d", value);
+ sprintf(name, "%d %% (Current)", value);
+
+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext, "Sound Volume");
+
+ pushTreeInfo(&volumes_simple, ti);
}
/* sort volume values to start with lowest volume value */
if (volumes_loops == NULL)
{
+ boolean current_volume_loops_found = FALSE;
int i;
for (i = 0; volumes_list[i].value != -1; i++)
setString(&ti->infotext, "Loops Volume");
pushTreeInfo(&volumes_loops, ti);
+
+ if (value == setup.volume_loops)
+ current_volume_loops_found = TRUE;
+ }
+
+ if (!current_volume_loops_found)
+ {
+ // add entry for non-preset volume value
+
+ TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+ char identifier[32], name[32];
+ int value = setup.volume_loops;
+
+ ti->node_top = &volumes_loops;
+ ti->sort_priority = value;
+
+ sprintf(identifier, "%d", value);
+ sprintf(name, "%d %% (Current)", value);
+
+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext, "Loops Volume");
+
+ pushTreeInfo(&volumes_loops, ti);
}
/* sort volume values to start with lowest volume value */
if (volumes_music == NULL)
{
+ boolean current_volume_music_found = FALSE;
int i;
for (i = 0; volumes_list[i].value != -1; i++)
setString(&ti->infotext, "Music Volume");
pushTreeInfo(&volumes_music, ti);
+
+ if (value == setup.volume_music)
+ current_volume_music_found = TRUE;
+ }
+
+ if (!current_volume_music_found)
+ {
+ // add entry for non-preset volume value
+
+ TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_UNDEFINED);
+ char identifier[32], name[32];
+ int value = setup.volume_music;
+
+ ti->node_top = &volumes_music;
+ ti->sort_priority = value;
+
+ sprintf(identifier, "%d", value);
+ sprintf(name, "%d %% (Current)", value);
+
+ setString(&ti->identifier, identifier);
+ setString(&ti->name, name);
+ setString(&ti->name_sorting, name);
+ setString(&ti->infotext, "Music Volume");
+
+ pushTreeInfo(&volumes_music, ti);
}
/* sort volume values to start with lowest volume value */
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();
}
height = SC_SCROLLBUTTON_YSIZE;
/* correct scrollbar position if placed outside menu (playfield) area */
- if (x > SC_SCROLL_UP_XPOS)
- x = SC_SCROLL_UP_XPOS;
+ 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 +
height = scrollbar_info[i].height;
/* correct scrollbar position if placed outside menu (playfield) area */
- if (x > SC_SCROLL_VERTICAL_XPOS)
- x = SC_SCROLL_VERTICAL_XPOS;
+ 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;