#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 },
return (initial ? GAME_MODE_TITLE_INITIAL : GAME_MODE_TITLE);
}
+static int getTitleAnimMode(struct TitleControlInfo *tci)
+{
+ int base = (tci->initial ? GAME_MODE_TITLE_INITIAL_1 : GAME_MODE_TITLE_1);
+
+ return base + tci->local_nr;
+}
+
#if 0
static int getTitleScreenBackground(boolean initial)
{
static void drawChooseTreeCursor(int ypos, boolean active)
{
- int last_game_status = game_status; /* save current game status */
-
drawCursorExt(0, ypos, active, -1);
-
- SetGameStatus(last_game_status); /* restore current game status */
}
void DrawHeadline()
{
char *filename = getLevelSetTitleMessageFilename(nr, initial);
struct TitleMessageInfo *tmi = getTitleMessageInfo(nr, initial);
- int last_game_status = game_status; /* save current game status */
if (filename == NULL)
return;
/* force TITLE font on title message screen */
- SetGameStatus(getTitleMessageGameMode(initial));
+ SetFontStatus(getTitleMessageGameMode(initial));
/* if chars *and* width set to "-1", automatically determine width */
if (tmi->chars == -1 && tmi->width == -1)
filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
tmi->autowrap, tmi->centered, tmi->parse_comments);
- SetGameStatus(last_game_status); /* restore current game status */
+ ResetFontStatus();
}
void DrawTitleScreen()
KeyboardAutoRepeatOff();
HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE);
-
- StopAnimation();
}
boolean CheckTitleScreen(boolean levelset_has_changed)
UnmapAllGadgets();
FadeSoundsAndMusic();
+ ExpireSoundLoops(FALSE);
+
KeyboardAutoRepeatOn();
ActivateJoystick();
FadeOut(fade_mask);
- SetDrawtoField(DRAW_BACKBUFFER);
+ 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)
SetMouseCursor(CURSOR_DEFAULT);
- InitAnimation();
-
OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
}
title_screen_nr = 0;
tci = &title_controls[title_screen_nr];
+ SetAnimStatus(getTitleAnimMode(tci));
+
last_sound = SND_UNDEFINED;
last_music = MUS_UNDEFINED;
DrawInfoScreen_NotAvailable("Title screen information:",
"No title screen for this level set.");
-
return;
}
}
title_screen_nr++;
- tci = &title_controls[title_screen_nr];
if (title_screen_nr < num_title_screens)
{
+ tci = &title_controls[title_screen_nr];
+
+ SetAnimStatus(getTitleAnimMode(tci));
+
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 if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_LEVELNR);
{
if (leveldir_first)
{
- StopAnimation();
-
CloseDoor(DOOR_CLOSE_2);
SetGameStatus(GAME_MODE_LEVELS);
}
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);
}
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);
fade_mask = REDRAW_ALL;
UnmapAllGadgets();
+ FadeSoundsAndMusic();
FreeScreenGadgets();
CreateScreenGadgets();
DrawMaskedBorder(fade_mask);
FadeIn(fade_mask);
-
- InitAnimation();
}
static void changeSetupValue(int, int, int);
HandleInfoScreen_Elements(MB_MENU_INITIALIZE);
FadeIn(REDRAW_FIELD);
-
- InitAnimation();
}
void HandleInfoScreen_Elements(int button)
DrawMaskedBorder(fade_mask);
FadeIn(fade_mask);
-
- InitAnimation();
}
static void drawChooseTreeList(int first_entry, int num_page_entries,
int yoffset_setup = 16;
int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
- int last_game_status = game_status; /* save current game status */
title_string = ti->infotext;
initCursor(i, IMG_MENU_BUTTON);
}
- SetGameStatus(last_game_status); /* restore current game status */
-
redraw_mask |= REDRAW_FIELD;
}
int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
int num_entries = numTreeInfoInGroup(ti);
int num_page_entries;
- int last_game_status = game_status; /* save current game status */
boolean position_set_by_scrollbar = (dx == 999);
if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
else
num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
- SetGameStatus(last_game_status); /* restore current game status */
-
if (button == MB_MENU_INITIALIZE)
{
int num_entries = numTreeInfoInGroup(ti);
if (mx || my) /* mouse input */
{
- int last_game_status = game_status; /* save current game status */
-
x = (mx - mSX) / 32;
y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
-
- SetGameStatus(last_game_status); /* restore current game status */
}
else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */
{
void DrawChooseLevelSet()
{
+ FadeSoundsAndMusic();
+
SetMainBackgroundImage(IMG_BACKGROUND_LEVELS);
DrawChooseTree(&leveldir_current);
{
int i;
+ FadeSoundsAndMusic();
+
if (level_number != NULL)
{
freeTreeInfo(level_number);
FadeOut(fade_mask);
- InitAnimation();
-
PlayMenuSound();
PlayMenuMusic();
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();
}
}
- DoAnimation();
BackToFront();
-
- WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value);
}
return key;
return FONT_VALUE_1;
}
+static int getSetupValueFontNarrow(int type, int font_nr)
+{
+ return (font_nr == FONT_VALUE_1 ? FONT_VALUE_NARROW :
+ font_nr == FONT_OPTION_ON ? FONT_OPTION_ON_NARROW :
+ font_nr == FONT_OPTION_OFF ? FONT_OPTION_OFF_NARROW :
+ font_nr);
+}
+
static void drawSetupValue(int screen_pos, int setup_info_pos_raw)
{
int si_pos = (setup_info_pos_raw < 0 ? screen_pos : setup_info_pos_raw);
struct TokenInfo *si = &setup_info[si_pos];
boolean font_draw_xoffset_modified = FALSE;
+ boolean scrollbar_needed = (num_setup_info < max_setup_info);
int font_draw_xoffset_old = -1;
- int xoffset = (num_setup_info < max_setup_info ? -1 : 0);
+ int xoffset = (scrollbar_needed ? -1 : 0);
int menu_screen_value_xpos = MENU_SCREEN_VALUE_XPOS + xoffset;
int menu_screen_max_xpos = MENU_SCREEN_MAX_XPOS + xoffset;
int xpos = menu_screen_value_xpos;
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)
+ {
+ int max_menu_text_length = 26; // maximum text length for classic menu
+ int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
+ int text_startx = mSX + MENU_SCREEN_START_XPOS * 32;
+ int text_font_nr = getMenuTextFont(FONT_MENU_2);
+ int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset;
+ int text_width = max_menu_text_length * getFontWidth(text_font_nr);
+
+ if (startx + font_xoffset < text_startx + text_width + text_font_xoffset)
+ {
+ xpos += 1;
+ startx = mSX + xpos * 32;
+
+ font_nr = getSetupValueFontNarrow(type, font_nr);
+ }
+ }
/* downward compatibility correction for Juergen Bonhagen's menu settings */
if (setup_mode != SETUP_MODE_INPUT)
}
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();
+ FadeSoundsAndMusic();
FreeScreenGadgets();
CreateScreenGadgets();
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();
}
}
void CreateScreenGadgets()
{
- int last_game_status = game_status; /* save current game status */
-
CreateScreenMenubuttons();
CreateScreenScrollbuttons();
CreateScreenScrollbars();
-
- SetGameStatus(last_game_status); /* restore current game status */
}
void FreeScreenGadgets()