#include "editor.h"
#include "files.h"
#include "tape.h"
-#include "cartoons.h"
+#include "anim.h"
#include "network.h"
#include "init.h"
#include "config.h"
static TreeInfo *level_number = NULL;
static TreeInfo *level_number_current = NULL;
-static unsigned int sync_frame_delay = 0;
-static unsigned int sync_frame_delay_value = GAME_FRAME_DELAY;
-
static struct
{
int value;
{
{ STR_SPECIAL_RENDERING_OFF, "Off (May show artifacts, fast)" },
{ STR_SPECIAL_RENDERING_BITMAP, "Bitmap/Texture mode (slower)" },
+#if DEBUG
+ // this mode may work under certain conditions, but does not work on Windows
{ STR_SPECIAL_RENDERING_TARGET, "Target Texture mode (slower)" },
+#endif
{ STR_SPECIAL_RENDERING_DOUBLE, "Double Texture mode (slower)" },
{ NULL, NULL },
{
{ TOUCH_CONTROL_VIRTUAL_BUTTONS, "Virtual Buttons" },
{ TOUCH_CONTROL_WIPE_GESTURES, "Wipe Gestures" },
+ { TOUCH_CONTROL_FOLLOW_FINGER, "Follow Finger" },
{ NULL, NULL },
};
y >= rect_y && y < rect_y + rect->height);
}
+static boolean insidePreviewRect(struct PreviewInfo *preview, int x, int y)
+{
+ int rect_width = preview->xsize * preview->tile_size;
+ int rect_height = preview->ysize * preview->tile_size;
+ int rect_x = ALIGNED_XPOS(preview->x, rect_width, preview->align);
+ int rect_y = ALIGNED_YPOS(preview->y, rect_height, preview->valign);
+
+ return (x >= rect_x && x < rect_x + rect_width &&
+ y >= rect_y && y < rect_y + rect_height);
+}
+
static void AdjustScrollbar(int id, int items_max, int items_visible,
int item_position)
{
KeyboardAutoRepeatOff();
HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
-
- StopAnimation();
}
boolean CheckTitleScreen(boolean levelset_has_changed)
/* do not fade out here -- function may continue and fade on editor screen */
UnmapAllGadgets();
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
ExpireSoundLoops(FALSE);
if (CheckTitleScreen(levelset_has_changed))
{
- game_status_last_screen = GAME_MODE_MAIN;
-
SetGameStatus(GAME_MODE_TITLE);
DrawTitleScreen();
return;
}
- /* needed if different viewport properties defined for menues */
- ChangeViewportPropertiesIfNeeded();
-
if (redraw_mask & REDRAW_ALL)
fade_mask = REDRAW_ALL;
FadeOut(fade_mask);
- SetDrawtoField(DRAW_BACKBUFFER);
+ /* needed if different viewport properties defined for menues */
+ ChangeViewportPropertiesIfNeeded();
+
+ SetDrawtoField(DRAW_TO_BACKBUFFER);
/* level_nr may have been set to value over handicap with level editor */
if (setup.handicap && level_nr > leveldir_current->handicap_level)
LoadTape(level_nr);
DrawCompleteVideoDisplay();
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
/* create gadgets for main menu screen */
FreeScreenGadgets();
SetMouseCursor(CURSOR_DEFAULT);
- InitAnimation();
-
OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
}
/* switch game mode from title screen mode back to info screen mode */
SetGameStatus(GAME_MODE_INFO);
+ /* store that last screen was info screen, not main menu screen */
+ game_status_last_screen = GAME_MODE_INFO;
+
DrawInfoScreen_NotAvailable("Title screen information:",
"No title screen for this level set.");
return;
}
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
}
FadeOut(REDRAW_ALL);
- /* only required to update logic for redrawing global border */
- ClearField();
-
/* title screens may have different window size */
ChangeViewportPropertiesIfNeeded();
+ /* only required to update logic for redrawing global border */
+ ClearField();
+
if (tci->is_image)
DrawTitleScreenImage(tci->local_nr, tci->initial);
else
sound = getTitleSound(tci);
music = getTitleMusic(tci);
- if (sound == SND_UNDEFINED || sound != last_sound)
- FadeSounds();
- if (music == MUS_UNDEFINED || music != last_music)
+ if (last_sound != SND_UNDEFINED && sound != last_sound)
+ FadeSound(last_sound);
+ if (last_music != MUS_UNDEFINED && music != last_music)
FadeMusic();
fading = getTitleFading(tci);
}
else
{
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
return_to_main_menu = TRUE;
}
}
}
+ /* check if level preview was clicked */
+ if (insidePreviewRect(&preview, mx - SX, my - SY))
+ pos = MAIN_CONTROL_GAME;
+
// handle pressed/unpressed state for active/inactive menu buttons
// (if pos != -1, "i" contains index position corresponding to "pos")
if (button &&
pos = choice + dy;
}
- if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
- {
- HandleMainMenu_SelectLevel(1, (dx < 0 ? -1 : +1), NO_DIRECT_LEVEL_SELECT);
- }
- else if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
+ if (pos == MAIN_CONTROL_FIRST_LEVEL && !button)
{
HandleMainMenu_SelectLevel(MAX_LEVELS, -1, NO_DIRECT_LEVEL_SELECT);
}
}
else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_LEVELNR);
- ChangeViewportPropertiesIfNeeded();
-
DrawChooseLevelNr();
}
else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
choice = pos;
}
+ else if (dx != 0)
+ {
+ if (choice != MAIN_CONTROL_INFO &&
+ choice != MAIN_CONTROL_SETUP)
+ HandleMainMenu_SelectLevel(1, dx, NO_DIRECT_LEVEL_SELECT);
+ }
}
else
{
{
if (leveldir_first)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_LEVELS);
if (setup.internal.choose_from_top_leveldir)
gotoTopLevelDir();
- ChangeViewportPropertiesIfNeeded();
-
DrawChooseLevelSet();
}
}
else if (pos == MAIN_CONTROL_SCORES)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_SCORES);
!strEqual(setup.player_name, "Artsoft"))
Request("This level is read only!", REQ_CONFIRM);
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_EDITOR);
}
else if (pos == MAIN_CONTROL_INFO)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_INFO);
info_mode = INFO_MODE_MAIN;
- ChangeViewportPropertiesIfNeeded();
-
DrawInfoScreen();
}
else if (pos == MAIN_CONTROL_GAME)
{
- StopAnimation();
-
StartGameActions(options.network, setup.autorecord, level.random_seed);
}
else if (pos == MAIN_CONTROL_SETUP)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_SETUP);
setup_mode = SETUP_MODE_MAIN;
- ChangeViewportPropertiesIfNeeded();
-
DrawSetupScreen();
}
else if (pos == MAIN_CONTROL_QUIT)
fade_mask = REDRAW_ALL;
UnmapAllGadgets();
+ FadeMenuSoundsAndMusic();
FreeScreenGadgets();
CreateScreenGadgets();
FadeOut(fade_mask);
+ /* needed if different viewport properties defined for info screen */
ChangeViewportPropertiesIfNeeded();
+ SetMainBackgroundImage(IMG_BACKGROUND_INFO);
+
ClearField();
OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
MapScreenGadgets(max_info_info);
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
DrawMaskedBorder(fade_mask);
FadeIn(fade_mask);
-
- InitAnimation();
}
static void changeSetupValue(int, int, int);
choice = choice_store[mode] = first_entry + y;
}
+ else if (dx < 0)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ for (i = 0; menu_info[i].type != 0; i++)
+ {
+ if (menu_info[i].type & TYPE_LEAVE_MENU)
+ {
+ void (*menu_callback_function)(void) = menu_info[i].value;
+
+ FadeSetLeaveMenu();
+
+ menu_callback_function();
+
+ /* absolutely needed because function changes 'menu_info'! */
+ break;
+ }
+ }
+
+ return;
+ }
}
else if (!(menu_info[first_entry + y].type & TYPE_GHOSTED))
{
void DrawInfoScreen_TitleScreen()
{
- game_status_last_screen = GAME_MODE_INFO;
-
SetGameStatus(GAME_MODE_TITLE);
DrawTitleScreen();
HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
FadeIn(REDRAW_FIELD);
-
- InitAnimation();
}
void HandleInfoScreen_Elements(int button)
if (page >= num_pages)
{
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
if (list == NULL)
{
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
ClearField();
DrawHeadline();
{
PlaySound(SND_MENU_ITEM_SELECTING);
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
if (list == NULL)
{
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
return;
}
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
if (list != music_file_info)
FadeSetNextScreen();
{
SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
FadeOut(REDRAW_FIELD);
if (screen_nr >= num_screens)
{
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
{
PlaySound(SND_MENU_ITEM_SELECTING);
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
ystart2 += ystep;
- DrawTextF(xstart1, ystart2, font_header, "Compile time");
- DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
+ DrawTextF(xstart1, ystart2, font_header, "Source date");
+ DrawTextF(xstart2, ystart2, font_text, getSourceDateString());
ystart2 += 3 * ystep;
DrawTextF(xstart1, ystart2, font_header, "Library");
{
PlaySound(SND_MENU_ITEM_SELECTING);
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
{
PlaySound(SND_MENU_ITEM_SELECTING);
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
info_mode = INFO_MODE_MAIN;
DrawInfoScreen();
static void DrawInfoScreen()
{
- SetMainBackgroundImage(IMG_BACKGROUND_INFO);
-
if (info_mode == INFO_MODE_TITLE)
DrawInfoScreen_TitleScreen();
else if (info_mode == INFO_MODE_ELEMENTS)
if (info_mode != INFO_MODE_MAIN &&
info_mode != INFO_MODE_TITLE &&
info_mode != INFO_MODE_MUSIC)
- {
- PlayMenuSound();
- PlayMenuMusic();
- }
+ PlayMenuSoundsAndMusic();
}
void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
xpos = newxpos;
-#if defined(TARGET_SDL2)
- SDL_StartTextInput();
-#endif
+ StartTextInput(startx, starty, pos->width, pos->height);
}
else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
{
DrawText(startx, starty, setup.player_name, font_nr);
-#if defined(TARGET_SDL2)
- SDL_StopTextInput();
-#endif
+ StopTextInput();
}
}
FadeOut(fade_mask);
+ /* needed if different viewport properties defined for choosing level (set) */
+ ChangeViewportPropertiesIfNeeded();
+
+ if (game_status == GAME_MODE_LEVELNR)
+ SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
+ else if (game_status == GAME_MODE_LEVELS)
+ SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
+
ClearField();
OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
DrawMaskedBorder(fade_mask);
FadeIn(fade_mask);
-
- InitAnimation();
}
static void drawChooseTreeList(int first_entry, int num_page_entries,
ti->cl_cursor = y;
}
+ else if (dx < 0)
+ {
+ if (game_status == GAME_MODE_SETUP)
+ {
+ if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED ||
+ setup_mode == SETUP_MODE_CHOOSE_SCROLL_DELAY ||
+ setup_mode == SETUP_MODE_CHOOSE_SNAPSHOT_MODE)
+ execSetupGame();
+ else if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE ||
+ setup_mode == SETUP_MODE_CHOOSE_SCALING_TYPE ||
+ setup_mode == SETUP_MODE_CHOOSE_RENDERING)
+ execSetupGraphics();
+ else if (setup_mode == SETUP_MODE_CHOOSE_VOLUME_SIMPLE ||
+ setup_mode == SETUP_MODE_CHOOSE_VOLUME_LOOPS ||
+ setup_mode == SETUP_MODE_CHOOSE_VOLUME_MUSIC)
+ execSetupSound();
+ else if (setup_mode == SETUP_MODE_CHOOSE_TOUCH_CONTROL ||
+ setup_mode == SETUP_MODE_CHOOSE_MOVE_DISTANCE ||
+ setup_mode == SETUP_MODE_CHOOSE_DROP_DISTANCE)
+ execSetupTouch();
+ else
+ execSetupArtwork();
+ }
+ }
}
else
{
void DrawChooseLevelSet()
{
- SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
+ FadeMenuSoundsAndMusic();
DrawChooseTree(&leveldir_current);
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
}
void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
{
int i;
+ FadeMenuSoundsAndMusic();
+
if (level_number != NULL)
{
freeTreeInfo(level_number);
ti->node_top = &level_number;
ti->sort_priority = 10000 + value;
- ti->color = (level.no_valid_file ? FC_BLUE :
+ ti->color = (level.no_level_file ? FC_BLUE :
LevelStats_getSolved(i) ? FC_GREEN :
LevelStats_getPlayed(i) ? FC_YELLOW : FC_RED);
sprintf(identifier, "%d", value);
sprintf(name, "%03d: %s", value,
- (level.no_valid_file ? "(no file)" : level.name));
+ (level.no_level_file ? "(no file)" : level.name));
setString(&ti->identifier, identifier);
setString(&ti->name, name);
if (level_number_current == NULL)
level_number_current = level_number;
- SetMainBackgroundImage(IMG_BACKGROUND_LEVELNR);
-
DrawChooseTree(&level_number_current);
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
}
void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
{
int fade_mask = REDRAW_FIELD;
- /* needed if different viewport properties defined for scores */
- ChangeViewportPropertiesIfNeeded();
-
if (CheckIfGlobalBorderHasChanged())
fade_mask = REDRAW_ALL;
UnmapAllGadgets();
- FadeSoundsAndMusic();
+ FadeMenuSoundsAndMusic();
/* (this is needed when called from GameEnd() after winning a game) */
KeyboardAutoRepeatOn();
FadeOut(fade_mask);
- InitAnimation();
+ /* needed if different viewport properties defined for scores */
+ ChangeViewportPropertiesIfNeeded();
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2);
int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3);
int font_nr4 = (active ? FONT_TEXT_4_ACTIVE : FONT_TEXT_4);
+ int dxoff = getFontDrawOffsetX(font_nr1);
int dx1 = 3 * getFontWidth(font_nr1);
int dx2 = dx1 + getFontWidth(font_nr1);
- int dx3 = SXSIZE - 2 * (mSX - SX) - 5 * getFontWidth(font_nr4);
+ int dx3 = SXSIZE - 2 * (mSX - SX + dxoff) - 5 * getFontWidth(font_nr4);
int num_dots = (dx3 - dx2) / getFontWidth(font_nr3);
int sy = mSY + 64 + i * 32;
static void execSetupGraphics()
{
+ // update "setup.window_scaling_percent" from list selection
+ // (in this case, window scaling was changed on setup screen)
if (setup_mode == SETUP_MODE_CHOOSE_WINDOW_SIZE)
- {
- // update "setup.window_scaling_percent" from list selection
execSetupGraphics_setWindowSizes(FALSE);
- }
- else
- {
- // update list selection from "setup.window_scaling_percent"
- execSetupGraphics_setWindowSizes(TRUE);
- }
+
+ // update list selection from "setup.window_scaling_percent"
+ // (window scaling may have changed by resizing the window)
+ execSetupGraphics_setWindowSizes(TRUE);
execSetupGraphics_setScalingTypes();
execSetupGraphics_setRenderingModes();
};
static struct TokenInfo setup_info_touch[] =
+{
+ { TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
+ { TYPE_STRING, &touch_controls_text, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Back" },
+
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_touch_wipe_gestures[] =
{
{ TYPE_ENTER_LIST, execSetupChooseTouchControls, "Touch Control Type:" },
{ TYPE_STRING, &touch_controls_text, "" },
}
}
- DoAnimation();
BackToFront();
-
- WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
}
return key;
int ypos = MENU_SCREEN_START_YPOS + screen_pos;
int startx = mSX + xpos * 32;
int starty = mSY + ypos * 32;
- int font_nr, font_width;
+ int font_nr, font_nr_default, font_width_default;
int type = si->type;
void *value = si->value;
char *value_string = getSetupValue(type, value);
startx = mSX + xpos * 32;
starty = mSY + ypos * 32;
- font_nr = getSetupValueFont(type, value);
- font_width = getFontWidth(font_nr);
+ font_nr_default = getSetupValueFont(type, value);
+ font_width_default = getFontWidth(font_nr_default);
+
+ font_nr = font_nr_default;
// special check if right-side setup values moved left due to scrollbar
if (scrollbar_needed && xpos > MENU_SCREEN_START_XPOS)
startx = mSX + xpos * 32;
font_nr = getSetupValueFontNarrow(type, font_nr);
- font_width = getFontWidth(font_nr);
}
}
}
for (i = 0; i <= menu_screen_max_xpos - xpos; i++)
- DrawText(startx + i * font_width, starty, " ", font_nr);
+ DrawText(startx + i * font_width_default, starty, " ", font_nr_default);
DrawText(startx, starty, value_string, font_nr);
fade_mask = REDRAW_ALL;
UnmapAllGadgets();
+ FadeMenuSoundsAndMusic();
FreeScreenGadgets();
CreateScreenGadgets();
FadeOut(fade_mask);
+ /* needed if different viewport properties defined for setup screen */
+ ChangeViewportPropertiesIfNeeded();
+
+ SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
+
ClearField();
OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
{
setup_info = setup_info_touch;
title_string = "Setup Touch Ctrls";
+
+ if (strEqual(setup.touch.control_type, TOUCH_CONTROL_WIPE_GESTURES))
+ setup_info = setup_info_touch_wipe_gestures;
}
else if (setup_mode == SETUP_MODE_SHORTCUTS)
{
DrawMaskedBorder(fade_mask);
FadeIn(fade_mask);
-
- InitAnimation();
}
void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button)
HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE);
FadeIn(REDRAW_FIELD);
-
- InitAnimation();
}
static void setJoystickDeviceToNr(char *device_name, int device_nr)
FadeIn(REDRAW_FIELD);
- InitAnimation();
-
while (!finished)
{
if (PendingEvent()) /* got event */
}
}
- DoAnimation();
BackToFront();
-
- WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
}
/* write new key bindings back to player setup */
setup.input[player_nr].key = custom_key;
- StopAnimation();
DrawSetupScreen_Input();
}
FadeIn(REDRAW_FIELD);
while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */
- InitAnimation();
while (result < 0)
{
}
}
- DoAnimation();
BackToFront();
-
- WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
}
/* calibrated center position (joystick should now be centered) */
new_joystick_xmiddle = joy_x;
new_joystick_ymiddle = joy_y;
- StopAnimation();
-
/* wait until the last pressed button was released */
while (Joystick(player_nr) & JOY_BUTTON)
{
NextEvent(&event);
HandleOtherEvents(&event);
- WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
+ BackToFront();
}
}
{
DeactivateJoystick();
- SetMainBackgroundImage(IMG_BACKGROUND_SETUP);
-
if (setup_mode == SETUP_MODE_INPUT)
DrawSetupScreen_Input();
else if (setup_mode == SETUP_MODE_CHOOSE_GAME_SPEED)
else
DrawSetupScreen_Generic();
- PlayMenuSound();
- PlayMenuMusic();
+ PlayMenuSoundsAndMusic();
}
void RedrawSetupScreenAfterFullscreenToggle()