X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=031d7f6e09b658997fe99e4cbf076f84f222d564;hb=d965f76d694c19c4188ac3429cfa049200abdf54;hp=76e2444709815029e88dd31fcad6bbe6d4510ca1;hpb=5c717898f717007b885f86e0d02f10d2a0306237;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 76e24447..031d7f6e 100644 --- a/src/screens.c +++ b/src/screens.c @@ -48,22 +48,27 @@ /* screens on the info screen */ #define INFO_MODE_MAIN 0 -#define INFO_MODE_ELEMENTS 1 -#define INFO_MODE_MUSIC 2 -#define INFO_MODE_CREDITS 3 -#define INFO_MODE_PROGRAM 4 -#define INFO_MODE_LEVELSET 5 +#define INFO_MODE_TITLESCREEN 1 +#define INFO_MODE_ELEMENTS 2 +#define INFO_MODE_MUSIC 3 +#define INFO_MODE_CREDITS 4 +#define INFO_MODE_PROGRAM 5 +#define INFO_MODE_LEVELSET 6 -#define MAX_INFO_MODES 6 +#define MAX_INFO_MODES 7 /* for various menu stuff */ -#define MAX_INFO_ELEMENTS_ON_SCREEN 10 -#define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - 2) +#define MENU_SCREEN_START_XPOS 1 #define MENU_SCREEN_START_YPOS 2 #define MENU_SCREEN_VALUE_XPOS 14 #define MENU_SCREEN_MAX_XPOS (SCR_FIELDX - 1) #define MENU_TITLE1_YPOS 8 #define MENU_TITLE2_YPOS 46 +#define MAX_INFO_ELEMENTS_ON_SCREEN 10 +#define MAX_MENU_ENTRIES_ON_SCREEN (SCR_FIELDY - MENU_SCREEN_START_YPOS) +#define MAX_MENU_TEXT_LENGTH_BIG (MENU_SCREEN_VALUE_XPOS - \ + MENU_SCREEN_START_XPOS) +#define MAX_MENU_TEXT_LENGTH_MEDIUM (MAX_MENU_TEXT_LENGTH_BIG * 2) /* buttons and scrollbars identifiers */ #define SCREEN_CTRL_ID_SCROLL_UP 0 @@ -74,6 +79,30 @@ #define NUM_SCREEN_SCROLLBARS 1 #define NUM_SCREEN_GADGETS 3 +/* graphic position and size values for buttons and scrollbars */ +#define SC_SCROLLBUTTON_XSIZE TILEX +#define SC_SCROLLBUTTON_YSIZE TILEY + +#define SC_SCROLLBAR_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE) + +#define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE +#define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \ + SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_UP_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_VERTICAL_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \ + SC_SCROLLBUTTON_YSIZE) + +#define SC_SCROLL_DOWN_XPOS SC_SCROLLBAR_XPOS +#define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \ + SC_SCROLL_VERTICAL_YSIZE) + +#define SC_BORDER_SIZE 14 + + /* forward declarations of internal functions */ static void HandleScreenGadgets(struct GadgetInfo *); static void HandleSetupScreen_Generic(int, int, int, int, int); @@ -87,9 +116,11 @@ static void DrawChooseLevel(void); static void DrawInfoScreen(void); static void DrawSetupScreen(void); +static void DrawInfoScreenExt(int); static void DrawInfoScreen_HelpAnim(int, int, boolean); static void DrawInfoScreen_HelpText(int, int, int, int); static void HandleInfoScreen_Main(int, int, int, int, int); +static void HandleInfoScreen_TitleScreen(int); static void HandleInfoScreen_Elements(int); static void HandleInfoScreen_Music(int); static void HandleInfoScreen_Credits(int); @@ -136,6 +167,8 @@ static void drawCursorExt(int xpos, int ypos, int color, int g) g == IMG_MENU_BUTTON_RIGHT ? IMG_MENU_BUTTON_RIGHT_ACTIVE : g == IMG_MENU_BUTTON_LEAVE_MENU ? IMG_MENU_BUTTON_LEAVE_MENU_ACTIVE : g == IMG_MENU_BUTTON_ENTER_MENU ? IMG_MENU_BUTTON_ENTER_MENU_ACTIVE : + g == IMG_MENU_BUTTON_LAST_LEVEL ? IMG_MENU_BUTTON_LAST_LEVEL_ACTIVE : + g == IMG_MENU_BUTTON_NEXT_LEVEL ? IMG_MENU_BUTTON_NEXT_LEVEL_ACTIVE : IMG_MENU_BUTTON_ACTIVE); ypos += MENU_SCREEN_START_YPOS; @@ -171,40 +204,6 @@ static void drawChooseTreeCursor(int ypos, int color) game_status = last_game_status; /* restore current game status */ } -static void PlayMenuSound() -{ - int sound = menu.sound[game_status]; - - if (sound == SND_UNDEFINED) - return; - - if (sound_info[sound].loop) - PlaySoundLoop(sound); - else - PlaySound(sound); -} - -static void PlayMenuSoundIfLoop() -{ - int sound = menu.sound[game_status]; - - if (sound == SND_UNDEFINED) - return; - - if (sound_info[sound].loop) - PlaySoundLoop(sound); -} - -static void PlayMenuMusic() -{ - int music = menu.music[game_status]; - - if (music == MUS_UNDEFINED) - return; - - PlayMusic(music); -} - void DrawHeadline() { DrawTextSCentered(MENU_TITLE1_YPOS, FONT_TITLE_1, PROGRAM_TITLE_STRING); @@ -235,9 +234,83 @@ static void ToggleFullscreenIfNeeded() } } -void DrawMainMenu() +static int getLastLevelButtonPos() +{ + return 10; +} + +static int getCurrentLevelTextPos() +{ + return (getLastLevelButtonPos() + 1); +} + +static int getNextLevelButtonPos() +{ + return getLastLevelButtonPos() + 3 + 1; +} + +static int getLevelRangeTextPos() +{ + return getNextLevelButtonPos() + 1; +} + +void DrawTitleScreenImage(int nr) +{ + int graphic = IMG_TITLESCREEN_1 + nr; + Bitmap *bitmap = graphic_info[graphic].bitmap; + int width = graphic_info[graphic].src_image_width; + int height = graphic_info[graphic].src_image_height; + int src_x = 0, src_y = 0; + int dst_x, dst_y; + + if (bitmap == NULL) + return; + + if (width > WIN_XSIZE) + { + /* image width too large for window => center image horizontally */ + src_x = (width - WIN_XSIZE) / 2; + width = WIN_XSIZE; + } + + if (height > WIN_YSIZE) + { + /* image height too large for window => center image vertically */ + src_y = (height - WIN_YSIZE) / 2; + height = WIN_YSIZE; + } + + dst_x = (WIN_XSIZE - width) / 2; + dst_y = (WIN_YSIZE - height) / 2; + + ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); + + if (DrawingOnBackground(dst_x, dst_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); + + redraw_mask = REDRAW_ALL; +} + +void DrawTitleScreen() +{ + KeyboardAutoRepeatOff(); + + SetMainBackgroundImage(IMG_BACKGROUND_TITLE); + + PlayMenuSound(); + PlayMenuMusic(); + + HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE); + + StopAnimation(); +} + +static void DrawMainMenuExt(int fade_delay) { static LevelDirTree *leveldir_last_valid = NULL; + boolean levelset_has_changed = FALSE; char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:"); #if 1 char *level_text = "Levelset"; @@ -258,6 +331,10 @@ void DrawMainMenu() audio.sound_deactivated = FALSE; +#if 1 + GetPlayerConfig(); +#endif + /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) { @@ -277,6 +354,9 @@ void DrawMainMenu() if (!validLevelSeries(leveldir_current)) leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); + if (leveldir_current != leveldir_last_valid) + levelset_has_changed = TRUE; + /* store valid level series information */ leveldir_last_valid = leveldir_current; @@ -287,6 +367,16 @@ void DrawMainMenu() SetDrawtoField(DRAW_BACKBUFFER); #endif + if (setup.show_titlescreen && + levelset_has_changed && + graphic_info[IMG_TITLESCREEN_1].bitmap != NULL) + { + game_status = GAME_MODE_TITLE; + DrawTitleScreen(); + + return; + } + #if 0 /* map gadgets for main menu screen */ MapTapeButtons(); @@ -296,7 +386,9 @@ void DrawMainMenu() if (setup.handicap && level_nr > leveldir_current->handicap_level) level_nr = leveldir_current->handicap_level; +#if 0 GetPlayerConfig(); +#endif LoadLevel(level_nr); SetMainBackgroundImage(IMG_BACKGROUND_MAIN); @@ -315,20 +407,30 @@ void DrawMainMenu() /* calculated after (possible) reload of custom artwork */ name_width = getTextWidth(name_text, FONT_MENU_1); +#if 1 + level_width = 9 * 32; +#else #if 1 level_width = 9 * getFontWidth(FONT_MENU_1); #else level_width = getTextWidth(level_text, FONT_MENU_1); +#endif #endif DrawText(mSX + 32 + name_width, mSY + 2 * 32, setup.player_name, FONT_INPUT_1); + +#if 1 + DrawText(mSX + getCurrentLevelTextPos() * 32, mSY + 3 * 32, + int2str(level_nr, 3), FONT_VALUE_1); +#else #if 1 DrawText(mSX + level_width + 2 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1); #else DrawText(mSX + level_width + 5 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1); +#endif #endif DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE); @@ -338,12 +440,17 @@ void DrawMainMenu() #if 1 { int text_height = getFontHeight(FONT_TEXT_3); +#if 1 + int xpos = getLevelRangeTextPos() * 32; +#else + int xpos = level_width + 6 * 32; +#endif int ypos2 = -SY + 3 * 32 + 16; int ypos1 = ypos2 - text_height; - DrawTextF(mSX + level_width + 6 * 32, mSY + ypos1, FONT_TEXT_3, + DrawTextF(mSX + xpos, mSY + ypos1, FONT_TEXT_3, "%03d", leveldir_current->first_level); - DrawTextF(mSX + level_width + 6 * 32, mSY + ypos2, FONT_TEXT_3, + DrawTextF(mSX + xpos, mSY + ypos2, FONT_TEXT_3, "%03d", leveldir_current->last_level); } #else @@ -370,18 +477,27 @@ void DrawMainMenu() initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU : IMG_MENU_BUTTON)); +#if 1 + drawCursorXY(getLastLevelButtonPos(), 1, IMG_MENU_BUTTON_LAST_LEVEL); + drawCursorXY(getNextLevelButtonPos(), 1, IMG_MENU_BUTTON_NEXT_LEVEL); +#else #if 1 drawCursorXY(level_width / 32 + 1, 1, IMG_MENU_BUTTON_LEFT); drawCursorXY(level_width / 32 + 5, 1, IMG_MENU_BUTTON_RIGHT); #else drawCursorXY(level_width / 32 + 4, 1, IMG_MENU_BUTTON_LEFT); drawCursorXY(level_width / 32 + 8, 1, IMG_MENU_BUTTON_RIGHT); +#endif #endif DrawTextSCentered(326, FONT_TITLE_2, "A Game by Artsoft Entertainment"); +#if 0 FadeToFront(); +#endif +#if 0 InitAnimation(); +#endif HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE); @@ -393,12 +509,46 @@ void DrawMainMenu() PlayMenuSound(); PlayMenuMusic(); +#if 0 +#if 1 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#else + if (fade_delay > 0) + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + else + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#endif +#endif + +#if 0 + InitAnimation(); +#endif #if 1 /* map gadgets for main menu screen */ MapTapeButtons(); #endif + +#if 1 +#if 1 + FadeIn(fade_delay); +#else + BackToFront(); +#endif +#endif + +#if 1 + InitAnimation(); +#endif + +#if 1 + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); +#endif +} + +void DrawMainMenu() +{ + DrawMainMenuExt(0); } #if 0 @@ -432,6 +582,94 @@ static void gotoTopLevelDir() } #endif +void HandleTitleScreen(int mx, int my, int dx, int dy, int button) +{ + static int title_nr = 0; + boolean return_to_main_menu = FALSE; + boolean use_fading_main_menu = TRUE; + boolean use_cross_fading = TRUE; + int fade_delay = 500; + int post_delay = fade_delay / 2; + + if (button == MB_MENU_INITIALIZE) + { + title_nr = 0; + + if (game_status == GAME_MODE_INFO) + { + FadeSoundsAndMusic(); + + FadeOut(fade_delay, post_delay); + } + + DrawTitleScreenImage(title_nr); + + FadeIn(fade_delay); + + return; + } + else if (button == MB_MENU_LEAVE) + { + return_to_main_menu = TRUE; + use_fading_main_menu = FALSE; + } + else if (button == MB_MENU_CHOICE) + { + title_nr++; + + if (!use_cross_fading) + FadeOut(fade_delay, post_delay); + + if (title_nr < MAX_NUM_TITLE_SCREENS && + graphic_info[IMG_TITLESCREEN_1 + title_nr].bitmap != NULL) + { + Bitmap *drawto_last = drawto; + + if (use_cross_fading) + drawto = bitmap_db_title; + + DrawTitleScreenImage(title_nr); + + drawto = drawto_last; + + if (use_cross_fading) + FadeCross(fade_delay); + else + FadeIn(fade_delay); + } + else + { + FadeSoundsAndMusic(); + + FadeOut(fade_delay, post_delay); + + return_to_main_menu = TRUE; + } + } + + if (return_to_main_menu) + { + int menu_fade_delay = (use_fading_main_menu ? fade_delay : 0); + + RedrawBackground(); + + if (game_status == GAME_MODE_INFO) + { + OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + + info_mode = INFO_MODE_MAIN; + DrawInfoScreenExt(menu_fade_delay); + } + else /* default: return to main menu */ + { + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + + game_status = GAME_MODE_MAIN; + DrawMainMenuExt(menu_fade_delay); + } + } +} + void HandleMainMenu(int mx, int my, int dx, int dy, int button) { static unsigned long level_delay = 0; @@ -552,7 +790,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) else if (y == 3) { if (leveldir_current->readonly && - strcmp(setup.player_name, "Artsoft") != 0) + !strEqual(setup.player_name, "Artsoft")) Request("This level is read only !", REQ_CONFIRM); game_status = GAME_MODE_EDITOR; DrawLevelEd(); @@ -600,6 +838,12 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) static struct TokenInfo *info_info; static int num_info_info; +static void execInfoTitleScreen() +{ + info_mode = INFO_MODE_TITLESCREEN; + DrawInfoScreen(); +} + static void execInfoElements() { info_mode = INFO_MODE_ELEMENTS; @@ -638,6 +882,7 @@ static void execExitInfo() static struct TokenInfo info_info_main[] = { + { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" }, { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" }, { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" }, { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" }, @@ -649,7 +894,7 @@ static struct TokenInfo info_info_main[] = { 0, NULL, NULL } }; -static void DrawInfoScreen_Main() +static void DrawInfoScreen_Main(int fade_delay) { int i; @@ -669,10 +914,11 @@ static void DrawInfoScreen_Main() for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; int font_nr = FONT_MENU_1; - DrawText(mSX + 32, mSY + ypos * 32, info_info[i].text, font_nr); + DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr); if (info_info[i].type & TYPE_ENTER_MENU) initCursor(i, IMG_MENU_BUTTON_ENTER_MENU); @@ -684,6 +930,18 @@ static void DrawInfoScreen_Main() num_info_info++; } +#if 1 + + HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE); + + PlayMenuSound(); + PlayMenuMusic(); + + FadeIn(fade_delay); + InitAnimation(); + +#else + FadeToFront(); InitAnimation(); @@ -691,6 +949,7 @@ static void DrawInfoScreen_Main() PlayMenuMusic(); HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE); +#endif } void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) @@ -936,6 +1195,16 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) max_chars_per_line, max_lines_per_text); } +void DrawInfoScreen_TitleScreen() +{ + DrawTitleScreen(); +} + +void HandleInfoScreen_TitleScreen(int button) +{ + HandleTitleScreen(0, 0, 0, 0, button); +} + void DrawInfoScreen_Elements() { SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS); @@ -1098,17 +1367,17 @@ void HandleInfoScreen_Music(int button) DrawTextSCentered(100, FONT_TEXT_1, "The Game Background Music:"); } - if (strcmp(list->title, UNKNOWN_NAME) != 0) + if (!strEqual(list->title, UNKNOWN_NAME)) { - if (strcmp(list->title_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->title_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->title_header); DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->title); } - if (strcmp(list->artist, UNKNOWN_NAME) != 0) + if (!strEqual(list->artist, UNKNOWN_NAME)) { - if (strcmp(list->artist_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->artist_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->artist_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "by"); @@ -1116,9 +1385,9 @@ void HandleInfoScreen_Music(int button) DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "%s", list->artist); } - if (strcmp(list->album, UNKNOWN_NAME) != 0) + if (!strEqual(list->album, UNKNOWN_NAME)) { - if (strcmp(list->album_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->album_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->album_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the album"); @@ -1126,9 +1395,9 @@ void HandleInfoScreen_Music(int button) DrawTextFCentered(ystart + y++ * dy, FONT_TEXT_3, "\"%s\"", list->album); } - if (strcmp(list->year, UNKNOWN_NAME) != 0) + if (!strEqual(list->year, UNKNOWN_NAME)) { - if (strcmp(list->year_header, UNKNOWN_NAME) != 0) + if (!strEqual(list->year_header, UNKNOWN_NAME)) DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, list->year_header); else DrawTextSCentered(ystart + y++ * dy, FONT_TEXT_2, "from the year"); @@ -1317,11 +1586,13 @@ void HandleInfoScreen_LevelSet(int button) } } -void DrawInfoScreen() +static void DrawInfoScreenExt(int fade_delay) { SetMainBackgroundImage(IMG_BACKGROUND_INFO); - if (info_mode == INFO_MODE_ELEMENTS) + if (info_mode == INFO_MODE_TITLESCREEN) + DrawInfoScreen_TitleScreen(); + else if (info_mode == INFO_MODE_ELEMENTS) DrawInfoScreen_Elements(); else if (info_mode == INFO_MODE_MUSIC) DrawInfoScreen_Music(); @@ -1332,7 +1603,7 @@ void DrawInfoScreen() else if (info_mode == INFO_MODE_LEVELSET) DrawInfoScreen_LevelSet(); else - DrawInfoScreen_Main(); + DrawInfoScreen_Main(fade_delay); if (info_mode != INFO_MODE_MUSIC) { @@ -1341,9 +1612,16 @@ void DrawInfoScreen() } } +void DrawInfoScreen() +{ + DrawInfoScreenExt(0); +} + void HandleInfoScreen(int mx, int my, int dx, int dy, int button) { - if (info_mode == INFO_MODE_ELEMENTS) + if (info_mode == INFO_MODE_TITLESCREEN) + HandleInfoScreen_TitleScreen(button); + else if (info_mode == INFO_MODE_ELEMENTS) HandleInfoScreen_Elements(button); else if (info_mode == INFO_MODE_MUSIC) HandleInfoScreen_Music(button); @@ -1461,8 +1739,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, TreeInfo *ti) { int i; - char buffer[SCR_FIELDX * 2]; - int max_buffer_len = (SCR_FIELDX - 2) * 2; char *title_string = NULL; #if 0 int xoffset_sets = 16; @@ -1502,14 +1778,24 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, /* clear tree list area, but not title or scrollbar */ DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SXSIZE - 32 + menu.scrollbar_xoffset, + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, MAX_MENU_ENTRIES_ON_SCREEN * 32); for (i = 0; i < num_page_entries; i++) { TreeInfo *node, *node_first; int entry_pos = first_entry + i; + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; + int startx = mSX + xpos * 32; + int starty = mSY + ypos * 32; + int font_nr = FONT_TEXT_1; + int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int startx_text = startx + font_xoffset; + int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset; + int text_size = startx_scrollbar - startx_text; + int max_buffer_len = text_size / getFontWidth(font_nr); + char buffer[max_buffer_len + 1]; node_first = getTreeInfoFirstGroupEntry(ti); node = getTreeInfoFromPos(node_first, entry_pos); @@ -1517,7 +1803,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, strncpy(buffer, node->name, max_buffer_len); buffer[max_buffer_len] = '\0'; - DrawText(mSX + 32, mSY + ypos * 32, buffer, FONT_TEXT_1 + node->color); + DrawText(startx, starty, buffer, font_nr + node->color); if (node->parent_link) initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU); @@ -1862,8 +2148,10 @@ static void drawHallOfFameList(int first_entry, int highlight_position) DrawText(mSX, sy, int2str(entry + 1, 3), font_nr1); DrawText(mSX + dx1, sy, ".", font_nr1); DrawText(mSX + dx2, sy, ".........................", font_nr3); - if (strcmp(highscore[entry].Name, EMPTY_PLAYER_NAME) != 0) + + if (!strEqual(highscore[entry].Name, EMPTY_PLAYER_NAME)) DrawText(mSX + dx2, sy, highscore[entry].Name, font_nr2); + DrawText(mSX + dx3, sy, int2str(highscore[entry].Score, 5), font_nr4); } @@ -2052,6 +2340,7 @@ static struct TokenInfo setup_info_main[] = static struct TokenInfo setup_info_game[] = { { TYPE_SWITCH, &setup.team_mode, "Team-Mode (Multi-Player):" }, + { TYPE_YES_NO, &setup.input_on_focus, "Only Move Focussed Player:" }, { TYPE_SWITCH, &setup.handicap, "Handicap:" }, { TYPE_SWITCH, &setup.skip_levels, "Skip Unsolved Levels:" }, { TYPE_SWITCH, &setup.time_limit, "Time Limit:" }, @@ -2064,6 +2353,7 @@ static struct TokenInfo setup_info_game[] = static struct TokenInfo setup_info_editor[] = { +#if 0 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" }, { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" }, { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" }, @@ -2072,12 +2362,15 @@ static struct TokenInfo setup_info_editor[] = { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" }, { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" }, { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" }, +#endif { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" }, { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" }, { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" }, { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" }, { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" }, { TYPE_EMPTY, NULL, "" }, + { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" }, + { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, { 0, NULL, NULL } @@ -2087,14 +2380,16 @@ static struct TokenInfo setup_info_graphics[] = { { TYPE_SWITCH, &setup.fullscreen, "Fullscreen Mode:" }, { TYPE_SWITCH, &setup.scroll_delay, "Delayed Scrolling:" }, - { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" }, #if 0 + { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scrolling:" }, { TYPE_SWITCH, &setup.double_buffering,"Double-Buffering:" }, { TYPE_SWITCH, &setup.fading, "Fading:" }, #endif { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" }, { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" }, - { TYPE_SWITCH, &setup.toons, "Toons:" }, + { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" }, + { TYPE_SWITCH, &setup.toons, "Show Toons:" }, + { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -2219,11 +2514,41 @@ static Key getSetupKey() return key; } +static int getSetupTextFont(int type) +{ + if (type & (TYPE_SWITCH | + TYPE_YES_NO | + TYPE_STRING | + TYPE_ECS_AGA | + TYPE_KEYTEXT)) + return FONT_MENU_2; + else + return FONT_MENU_1; +} + +static int getSetupValueFont(int type, void *value) +{ + if (type & TYPE_KEY) + return (type & TYPE_QUERY ? FONT_INPUT_1_ACTIVE : FONT_VALUE_1); + else if (type & TYPE_STRING) + return FONT_VALUE_2; + else if (type & TYPE_ECS_AGA) + return FONT_VALUE_1; + else if (type & TYPE_BOOLEAN_STYLE) + return (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); + else + return FONT_VALUE_1; +} + static void drawSetupValue(int pos) { + boolean font_draw_xoffset_modified = FALSE; + int font_draw_xoffset_old = -1; int xpos = MENU_SCREEN_VALUE_XPOS; int ypos = MENU_SCREEN_START_YPOS + pos; - int font_nr = FONT_VALUE_1; + int startx = mSX + xpos * 32; + int starty = mSY + ypos * 32; + int font_nr, font_width; int type = setup_info[pos].type; void *value = setup_info[pos].value; char *value_string = getSetupValue(type, value); @@ -2235,7 +2560,7 @@ static void drawSetupValue(int pos) if (type & TYPE_KEY) { #if 1 - xpos = 1; + xpos = MENU_SCREEN_START_XPOS; #else xpos = 3; #endif @@ -2243,33 +2568,99 @@ static void drawSetupValue(int pos) if (type & TYPE_QUERY) { value_string = ""; +#if 0 font_nr = FONT_INPUT_1_ACTIVE; +#endif } } else if (type & TYPE_STRING) { int max_value_len = (SCR_FIELDX - 2) * 2; - xpos = 1; + xpos = MENU_SCREEN_START_XPOS; +#if 0 font_nr = FONT_VALUE_2; +#endif if (strlen(value_string) > max_value_len) value_string[max_value_len] = '\0'; } + else if (type & TYPE_ECS_AGA) + { +#if 0 + font_nr = FONT_VALUE_1; +#endif + } else if (type & TYPE_BOOLEAN_STYLE) { +#if 0 font_nr = (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); +#endif + } + + startx = mSX + xpos * 32; + starty = mSY + ypos * 32; + font_nr = getSetupValueFont(type, value); + font_width = getFontWidth(font_nr); + + /* downward compatibility correction for Juergen Bonhagen's menu settings */ + if (setup_mode != SETUP_MODE_INPUT) + { + int check_font_nr = FONT_OPTION_ON; /* known font that needs correction */ + int font1_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset; + int font2_xoffset = getFontBitmapInfo(check_font_nr)->draw_xoffset; + int text_startx = mSX + MENU_SCREEN_START_XPOS * 32; + int text_font_nr = getSetupTextFont(FONT_MENU_2); + int text_font_xoffset = getFontBitmapInfo(text_font_nr)->draw_xoffset; + int text_width = MAX_MENU_TEXT_LENGTH_MEDIUM * getFontWidth(text_font_nr); + boolean correct_font_draw_xoffset = FALSE; + + if (xpos == MENU_SCREEN_START_XPOS && + startx + font1_xoffset < text_startx + text_font_xoffset) + correct_font_draw_xoffset = TRUE; + + if (xpos == MENU_SCREEN_VALUE_XPOS && + startx + font2_xoffset < text_startx + text_width + text_font_xoffset) + correct_font_draw_xoffset = TRUE; + +#if 0 + printf("::: %d + %d < %d + %d + %d\n", + startx, font_xoffset, text_startx, text_width, text_font_xoffset); + printf("::: => need correction == %d\n", correct_font_draw_xoffset); +#endif + + /* check if setup value would overlap with setup text when printed */ + /* (this can happen for extreme/wrong values for font draw offset) */ + if (correct_font_draw_xoffset) + { + font_draw_xoffset_old = getFontBitmapInfo(font_nr)->draw_xoffset; + font_draw_xoffset_modified = TRUE; + + if (type & TYPE_KEY) + getFontBitmapInfo(font_nr)->draw_xoffset += 2 * getFontWidth(font_nr); + else if (!(type & TYPE_STRING)) + getFontBitmapInfo(font_nr)->draw_xoffset = text_font_xoffset + 20 - + MAX_MENU_TEXT_LENGTH_MEDIUM * (16 - getFontWidth(text_font_nr)); + } } +#if 1 + for (i = 0; i <= MENU_SCREEN_MAX_XPOS - xpos; i++) + DrawText(startx + i * font_width, starty, " ", font_nr); +#else #if 1 for (i = xpos; i <= MENU_SCREEN_MAX_XPOS; i++) - DrawText(mSX + i * 32, mSY + ypos * 32, " ", font_nr); + DrawText(mSX + i * 32, starty, " ", font_nr); #else - DrawText(mSX + xpos * 32, mSY + ypos * 32, + DrawText(startx, starty, (xpos == 3 ? " " : " "), font_nr); #endif +#endif + + DrawText(startx, starty, value_string, font_nr); - DrawText(mSX + xpos * 32, mSY + ypos * 32, value_string, font_nr); + if (font_draw_xoffset_modified) + getFontBitmapInfo(font_nr)->draw_xoffset = font_draw_xoffset_old; } static void changeSetupValue(int pos) @@ -2355,8 +2746,13 @@ static void DrawSetupScreen_Generic() for (i = 0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { void *value_ptr = setup_info[i].value; + int xpos = MENU_SCREEN_START_XPOS; int ypos = MENU_SCREEN_START_YPOS + i; +#if 1 + int font_nr; +#else int font_nr = FONT_MENU_1; +#endif /* set some entries to "unchangeable" according to other variables */ if ((value_ptr == &setup.sound_simple && !audio.sound_available) || @@ -2365,18 +2761,23 @@ static void DrawSetupScreen_Generic() (value_ptr == &setup.fullscreen && !video.fullscreen_available)) setup_info[i].type |= TYPE_GHOSTED; +#if 1 + font_nr = getSetupTextFont(setup_info[i].type); +#else #if 1 if (setup_info[i].type & (TYPE_SWITCH | TYPE_YES_NO | TYPE_STRING | + TYPE_ECS_AGA | TYPE_KEYTEXT)) font_nr = FONT_MENU_2; #else if (setup_info[i].type & TYPE_STRING) font_nr = FONT_MENU_2; +#endif #endif - DrawText(mSX + 32, mSY + ypos * 32, setup_info[i].text, font_nr); + DrawText(mSX + xpos * 32, mSY + ypos * 32, setup_info[i].text, font_nr); if (setup_info[i].type & TYPE_ENTER_MENU) initCursor(i, IMG_MENU_BUTTON_ENTER_MENU); @@ -3131,245 +3532,15 @@ void HandleGameActions() if (game_status != GAME_MODE_PLAYING) return; - /* !!! FIX THIS (START) !!! */ - if (level.game_engine_type == GAME_ENGINE_TYPE_EM) - { - byte *recorded_player_action; - byte summarized_player_action = 0; - byte tape_action[MAX_PLAYERS]; - int i; - -#if 1 - if (level.native_em_level->lev->home == 0) /* all players at home */ - { - local_player->LevelSolved = TRUE; - AllPlayersGone = TRUE; - - level.native_em_level->lev->home = -1; - } - - if (local_player->LevelSolved) - GameWon(); - - if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) - TapeStop(); - - if (game_status != GAME_MODE_PLAYING) - return; -#else - if (level.native_em_level->lev->home == 0) /* all players at home */ - { - if (local_player->LevelSolved) - GameWon(); - - if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) - TapeStop(); - - if (game_status != GAME_MODE_PLAYING) - return; - } -#endif - - if (level.native_em_level->ply[0]->alive == 0 && - level.native_em_level->ply[1]->alive == 0 && - level.native_em_level->ply[2]->alive == 0 && - level.native_em_level->ply[3]->alive == 0) /* all dead */ - AllPlayersGone = TRUE; - - if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) - TapeStop(); - - /* --- game actions --- */ - - if (tape.pausing) - { - /* don't use 100% CPU while in pause mode -- this should better be solved - like in the R'n'D game engine! */ - - Delay(10); - - return; - } - - recorded_player_action = (tape.playing ? TapePlayAction() : NULL); - -#if 1 - /* !!! CHECK THIS (tape.pausing is always FALSE here!) !!! */ - if (recorded_player_action == NULL && tape.pausing) - return; -#endif - - for (i = 0; i < MAX_PLAYERS; i++) - { - summarized_player_action |= stored_player[i].action; - - if (!network_playing) - stored_player[i].effective_action = stored_player[i].action; - } - - if (!options.network && !setup.team_mode) - local_player->effective_action = summarized_player_action; - - if (recorded_player_action != NULL) - for (i = 0; i < MAX_PLAYERS; i++) - stored_player[i].effective_action = recorded_player_action[i]; - - for (i = 0; i < MAX_PLAYERS; i++) - { - tape_action[i] = stored_player[i].effective_action; - - /* !!! (this does not happen in the EM engine) !!! */ - if (tape.recording && tape_action[i] && !tape.player_participates[i]) - tape.player_participates[i] = TRUE; /* player just appeared from CE */ - } - - /* only save actions from input devices, but not programmed actions */ - if (tape.recording) - TapeRecordAction(tape_action); - -#if 1 - { - byte effective_action[MAX_PLAYERS]; - - for (i = 0; i < MAX_PLAYERS; i++) - effective_action[i] = stored_player[i].effective_action; - - -#if 0 - printf("::: %s: ", - tape.playing ? "PLAYING" : - tape.recording ? "RECORDING" : - "STOPPED"); - - for (i = 1; i < MAX_PLAYERS; i++) - if ((recorded_player_action && recorded_player_action[i] != 0) || - tape_action[i] != 0 || - effective_action[i] != 0) - printf("::: -----------------> WARNING!\n"); - - printf("::: %08d: %08x [%08x] [%08x]\n", - FrameCounter, - (recorded_player_action ? recorded_player_action[0] : -1), - tape_action[0], - effective_action[0]); -#endif - - - GameActions_EM(effective_action); - } -#else - GameActions_EM(local_player->effective_action); -#endif - - if (TimeFrames >= FRAMES_PER_SECOND) - { - TimeFrames = 0; - TapeTime++; - - if (!level.use_step_counter) - { - TimePlayed++; - - if (TimeLeft > 0) - { - TimeLeft--; - - if (TimeLeft <= 10 && setup.time_limit) - PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE); - - DrawGameValue_Time(TimeLeft); - - if (!TimeLeft && setup.time_limit) - level.native_em_level->lev->killed_out_of_time = TRUE; - } - else if (level.time == 0 && level.native_em_level->lev->home > 0) - DrawGameValue_Time(TimePlayed); - - level.native_em_level->lev->time = - (level.time == 0 ? TimePlayed : TimeLeft); - } + GameActions(); /* main game loop */ - if (tape.recording || tape.playing) - DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime); - } - - FrameCounter++; - TimeFrames++; - - BackToFront(); - } - else - { - if (game.restart_level) - StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE); - - if (local_player->LevelSolved) - GameWon(); - - if (AllPlayersGone && !TAPE_IS_STOPPED(tape)) - TapeStop(); - - GameActions(); - BackToFront(); - - if (tape.auto_play && !tape.playing) - AutoPlayTape(); /* continue automatically playing next tape */ - } + if (tape.auto_play && !tape.playing) + AutoPlayTape(); /* continue automatically playing next tape */ } -void StartGameActions(boolean init_network_game, boolean record_tape, - long random_seed) -{ -#if 1 - unsigned long new_random_seed = InitRND(random_seed); - - if (record_tape) - TapeStartRecording(new_random_seed); -#else - if (record_tape) - TapeStartRecording(random_seed); -#endif - -#if defined(NETWORK_AVALIABLE) - if (init_network_game) - { - SendToServer_StartPlaying(); - - return; - } -#endif - - StopAnimation(); - - game_status = GAME_MODE_PLAYING; - -#if 0 - InitRND(random_seed); -#endif - - InitGame(); -} /* ---------- new screen button stuff -------------------------------------- */ -/* graphic position and size values for buttons and scrollbars */ -#define SC_SCROLLBUTTON_XSIZE TILEX -#define SC_SCROLLBUTTON_YSIZE TILEY - -#define SC_SCROLL_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE -#define SC_SCROLL_VERTICAL_YSIZE ((MAX_MENU_ENTRIES_ON_SCREEN - 2) * \ - SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_UP_XPOS (SXSIZE - SC_SCROLLBUTTON_XSIZE) -#define SC_SCROLL_UP_YPOS (2 * SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_VERTICAL_XPOS SC_SCROLL_UP_XPOS -#define SC_SCROLL_VERTICAL_YPOS (SC_SCROLL_UP_YPOS + \ - SC_SCROLLBUTTON_YSIZE) -#define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS -#define SC_SCROLL_DOWN_YPOS (SC_SCROLL_VERTICAL_YPOS + \ - SC_SCROLL_VERTICAL_YSIZE) - -#define SC_BORDER_SIZE 14 - static struct { int gfx_unpressed, gfx_pressed;