X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=a6b259d9eb7a065b4a04917fdaaef5143a98d09c;hb=983c38dbae8637ef26d8be356e04c9b64bf9fc1f;hp=d0b5313d735b27fcf89b67157aa58f3c38974e1f;hpb=c2e3fd53db25f745d11fbe9b19bef78b3a3461a7;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index d0b5313d..a6b259d9 100644 --- a/src/screens.c +++ b/src/screens.c @@ -139,29 +139,49 @@ static void drawChooseTreeCursor(int ypos, int color) game_status = last_game_status; /* restore current game status */ } -static void PlaySound_Menu_Start(int sound) +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 PlaySound_Menu_Continue(int 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() { - int font1_width = getFontWidth(FONT_TITLE_1); - int font2_width = getFontWidth(FONT_TITLE_2); - int x1 = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * font1_width) / 2; - int x2 = SX + (SXSIZE - strlen(WINDOW_SUBTITLE_STRING) * font2_width) / 2; + int text1_width = getTextWidth(PROGRAM_TITLE_STRING, FONT_TITLE_1); + int text2_width = getTextWidth(PROGRAM_COPYRIGHT_STRING, FONT_TITLE_2); + int x1 = SX + (SXSIZE - text1_width) / 2; + int x2 = SX + (SXSIZE - text2_width) / 2; - DrawText(x1, SY + 8, PROGRAM_TITLE_STRING, FONT_TITLE_1); - DrawText(x2, SY + 46, WINDOW_SUBTITLE_STRING, FONT_TITLE_2); + DrawText(x1, SY + 8, PROGRAM_TITLE_STRING, FONT_TITLE_1); + DrawText(x2, SY + 46, PROGRAM_COPYRIGHT_STRING, FONT_TITLE_2); } static void ToggleFullscreenIfNeeded() @@ -192,13 +212,12 @@ void DrawMainMenu() { static LevelDirTree *leveldir_last_valid = NULL; char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:"); - int font_width = getFontWidth(FONT_MENU_1); - int name_width = font_width * strlen("Name:"); - int level_width = font_width * strlen("Level:"); + int name_width = getTextWidth("Name:", FONT_MENU_1); + int level_width = getTextWidth("Level:", FONT_MENU_1); int i; UnmapAllGadgets(); - FadeSounds(); + FadeSoundsAndMusic(); KeyboardAutoRepeatOn(); ActivateJoystick(); @@ -213,6 +232,7 @@ void DrawMainMenu() { game_status = GAME_MODE_EDITOR; DrawLevelEd(); + return; } @@ -294,6 +314,9 @@ void DrawMainMenu() LoadTape(level_nr); DrawCompleteVideoDisplay(); + PlayMenuSound(); + PlayMenuMusic(); + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); #if 0 @@ -332,7 +355,7 @@ static void gotoTopLevelDir() void HandleMainMenu(int mx, int my, int dx, int dy, int button) { - static int choice = 0; + static int choice = 5; int x = 0; int y = choice; @@ -473,8 +496,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } } - BackToFront(); - out: if (game_status == GAME_MODE_MAIN) @@ -482,6 +503,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); } + + BackToFront(); } @@ -958,15 +981,28 @@ void DrawHelpScreenElText(int start) void DrawHelpScreenMusicText(int num) { + struct MusicFileInfo *list = music_file_info; int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; + int i; + + for (i=0; i < num && list; i++) + list = list->next; - FadeSounds(); + FadeSoundsAndMusic(); ClearWindow(); DrawHeadline(); DrawTextFCentered(100, FONT_TEXT_1, "The game background music loops:"); +#if 1 + DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); + DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title); + DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); + DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", list->artist); + DrawTextFCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); + DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", list->album); +#else DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", helpscreen_music[num][0]); @@ -976,6 +1012,7 @@ void DrawHelpScreenMusicText(int num) DrawTextFCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", helpscreen_music[num][2]); +#endif DrawTextFCentered(ybottom, FONT_TEXT_4, "Press any key or button for next page"); @@ -990,7 +1027,7 @@ void DrawHelpScreenCreditsText() int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; - FadeSounds(); + FadeSoundsAndMusic(); ClearWindow(); DrawHeadline(); @@ -1047,6 +1084,7 @@ void DrawHelpScreenContactText() void DrawHelpScreen() { + struct MusicFileInfo *list; int i; UnmapAllGadgets(); @@ -1057,17 +1095,20 @@ void DrawHelpScreen() helpscreen_musicpos = 0; helpscreen_state = 0; + LoadMusicInfo(); + + num_helpscreen_music = 0; + for (list = music_file_info; list != NULL; list = list->next) + num_helpscreen_music++; + DrawHelpScreenElText(0); DrawHelpScreenElAction(0); FadeToFront(); InitAnimation(); -#if 0 - PlaySoundLoop(SND_BACKGROUND_INFO); -#else - PlaySound_Menu_Start(SND_BACKGROUND_INFO); -#endif + PlayMenuSound(); + PlayMenuMusic(); } void HandleHelpScreen(int button) @@ -1110,7 +1151,7 @@ void HandleHelpScreen(int button) } else { - FadeSounds(); + FadeSoundsAndMusic(); game_status = GAME_MODE_MAIN; DrawMainMenu(); @@ -1124,18 +1165,10 @@ void HandleHelpScreen(int button) DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS); } - /* !!! workaround for playing "music" that is really a sound loop (and - must therefore periodically be reactivated with the current sound - engine !!! */ -#if 0 - PlaySoundLoop(SND_BACKGROUND_INFO); -#else - PlaySound_Menu_Continue(SND_BACKGROUND_INFO); -#endif - - DoAnimation(); + PlayMenuSoundIfLoop(); } + DoAnimation(); BackToFront(); } @@ -1242,9 +1275,6 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : yoffset_setup); int last_game_status = game_status; /* save current game status */ - DrawBackground(SX, SY, SXSIZE - 32, SYSIZE); - redraw_mask |= REDRAW_FIELD; - title_string = (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" : ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" : @@ -1256,6 +1286,11 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, /* force LEVELS font on artwork setup screen */ game_status = GAME_MODE_LEVELS; + /* clear tree list area, but not title or scrollbar */ + DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, + SXSIZE - 32 + menu.scrollbar_xoffset, + MAX_MENU_ENTRIES_ON_SCREEN * 32); + for(i=0; i 0) @@ -1645,27 +1687,20 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); drawHallOfFameList(first_entry, highlight_position); - - return; } } - - if (button_released) + else if (button_released) { FadeSound(SND_BACKGROUND_SCORES); game_status = GAME_MODE_MAIN; DrawMainMenu(); } - BackToFront(); - if (game_status == GAME_MODE_SCORES) - { - DoAnimation(); -#if 1 - PlaySound_Menu_Continue(SND_BACKGROUND_SCORES); -#endif - } + PlayMenuSoundIfLoop(); + + DoAnimation(); + BackToFront(); } @@ -1808,6 +1843,9 @@ static struct TokenInfo setup_info_editor[] = { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX Boulderd.:" }, { TYPE_SWITCH, &setup.editor.el_chars, "Characters:" }, { TYPE_SWITCH, &setup.editor.el_custom, "Custom:" }, + { TYPE_SWITCH, &setup.editor.el_custom_more, "More Custom:" }, + { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" }, + { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, { 0, NULL, NULL } @@ -1831,8 +1869,6 @@ static struct TokenInfo setup_info_graphics[] = static struct TokenInfo setup_info_sound[] = { - { TYPE_SWITCH, &setup.sound, "Sound:", }, - { TYPE_EMPTY, NULL, "" }, { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" }, { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" }, { TYPE_SWITCH, &setup.sound_music, "Game Music:" }, @@ -1911,8 +1947,8 @@ static Key getSetupKey() } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -1926,23 +1962,25 @@ static void drawSetupValue(int pos) int xpos = MENU_SCREEN_VALUE_XPOS; int ypos = MENU_SCREEN_START_YPOS + pos; int font_nr = FONT_VALUE_1; - char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED, - setup_info[pos].value); + int type = setup_info[pos].type; + void *value = setup_info[pos].value; + char *value_string = (!(type & TYPE_GHOSTED) ? getSetupValue(type, value) : + "n/a"); if (value_string == NULL) return; - if (setup_info[pos].type & TYPE_KEY) + if (type & TYPE_KEY) { xpos = 3; - if (setup_info[pos].type & TYPE_QUERY) + if (type & TYPE_QUERY) { value_string = ""; font_nr = FONT_INPUT_1_ACTIVE; } } - else if (setup_info[pos].type & TYPE_STRING) + else if (type & TYPE_STRING) { int max_value_len = (SCR_FIELDX - 2) * 2; @@ -1952,10 +1990,9 @@ static void drawSetupValue(int pos) if (strlen(value_string) > max_value_len) value_string[max_value_len] = '\0'; } - else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE) + else if (type & TYPE_BOOLEAN_STYLE) { - font_nr = (*(boolean *)(setup_info[pos].value) ? FONT_OPTION_ON : - FONT_OPTION_OFF); + font_nr = (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); } DrawText(mSX + xpos * 32, mSY + ypos * 32, @@ -2041,10 +2078,10 @@ static void DrawSetupScreen_Generic() int font_nr = FONT_MENU_1; /* set some entries to "unchangeable" according to other variables */ - if ((value_ptr == &setup.sound && !audio.sound_available) || - (value_ptr == &setup.sound_loops && !audio.loops_available) || - (value_ptr == &setup.sound_music && !audio.music_available) || - (value_ptr == &setup.fullscreen && !video.fullscreen_available)) + if ((value_ptr == &setup.sound_simple && !audio.sound_available) || + (value_ptr == &setup.sound_loops && !audio.loops_available) || + (value_ptr == &setup.sound_music && !audio.music_available) || + (value_ptr == &setup.fullscreen && !video.fullscreen_available)) setup_info[i].type |= TYPE_GHOSTED; if (setup_info[i].type & TYPE_STRING) @@ -2160,10 +2197,12 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void DrawSetupScreen_Input() @@ -2340,7 +2379,11 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) static unsigned long delay = 0; if (!DelayReached(&delay, GADGET_FRAME_DELAY)) +#if 1 + return; +#else goto out; +#endif player_nr = (player_nr + (x == 10 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS; @@ -2404,12 +2447,14 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); out: if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void CustomizeKeyboard(int player_nr) @@ -2527,8 +2572,8 @@ void CustomizeKeyboard(int player_nr) } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2690,8 +2735,8 @@ static boolean CalibrateJoystickMain(int player_nr) } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2754,6 +2799,9 @@ void DrawSetupScreen() DrawChooseTree(&artwork.mus_current); else DrawSetupScreen_Generic(); + + PlayMenuSound(); + PlayMenuMusic(); } void HandleSetupScreen(int mx, int my, int dx, int dy, int button) @@ -2768,6 +2816,9 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &artwork.mus_current); else HandleSetupScreen_Generic(mx, my, dx, dy, button); + + DoAnimation(); + BackToFront(); } void HandleGameActions() @@ -2906,6 +2957,7 @@ static void CreateScreenScrollbuttons() GDI_STATE, GD_BUTTON_UNPRESSED, GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2, + GDI_DIRECT_DRAW, FALSE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END); @@ -2982,6 +3034,7 @@ static void CreateScreenScrollbars() GDI_DESIGN_UNPRESSED, gd_bitmap_unpressed, gd_x1, gd_y1, GDI_DESIGN_PRESSED, gd_bitmap_pressed, gd_x2, gd_y2, GDI_BORDER_SIZE, SC_BORDER_SIZE, SC_BORDER_SIZE, + GDI_DIRECT_DRAW, FALSE, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END);