X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=ec0a1231b4573c329886272d7e9127e7dbc629ea;hb=c2a639c0b2c1a9a2bd14de86932a47429ae918a4;hp=0d3b008ab9f44f115c8a6bc09e9f843ad554700b;hpb=86b0ea5594dc5a9db7ac5d71fa2b7487a4fc1f9d;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 0d3b008a..ec0a1231 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 text1_width = getTextWidth(PROGRAM_TITLE_STRING, FONT_TITLE_1); - int text2_width = getTextWidth(WINDOW_SUBTITLE_STRING, FONT_TITLE_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() @@ -197,7 +217,7 @@ void DrawMainMenu() int i; UnmapAllGadgets(); - FadeSounds(); + FadeSoundsAndMusic(); KeyboardAutoRepeatOn(); ActivateJoystick(); @@ -212,6 +232,7 @@ void DrawMainMenu() { game_status = GAME_MODE_EDITOR; DrawLevelEd(); + return; } @@ -270,9 +291,9 @@ void DrawMainMenu() if (leveldir_current->readonly) { - DrawTextF(mSX + level_width + 9 * 32 - 2, + DrawTextS(mSX + level_width + 9 * 32 - 2, mSY + 3 * 32 + 1 - 7, FONT_TEXT_3, "READ"); - DrawTextF(mSX + level_width + 9 * 32 - 2, + DrawTextS(mSX + level_width + 9 * 32 - 2, mSY + 3 * 32 + 1 + 7, FONT_TEXT_3, "ONLY"); } @@ -293,6 +314,9 @@ void DrawMainMenu() LoadTape(level_nr); DrawCompleteVideoDisplay(); + PlayMenuSound(); + PlayMenuMusic(); + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); #if 0 @@ -331,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; @@ -492,6 +516,7 @@ static long helpscreen_state; static int helpscreen_step[MAX_HELPSCREEN_ELS]; static int helpscreen_frame[MAX_HELPSCREEN_ELS]; +#if 0 static int helpscreen_action[] = { IMG_PLAYER_1_MOVING_DOWN, 16, @@ -701,6 +726,8 @@ static int helpscreen_action[] = HA_END }; +#endif + static char *helpscreen_eltext[][2] = { {"THE HERO:", "(Is _this_ guy good old Rockford?)"}, @@ -768,6 +795,7 @@ static char *helpscreen_eltext[][2] = }; static int num_helpscreen_els = sizeof(helpscreen_eltext) / (2*sizeof(char *)); +#if 0 static char *helpscreen_music[][3] = { { "Alchemy", "Ian Boddy", "Drive" }, @@ -778,73 +806,113 @@ static char *helpscreen_music[][3] = { "Voyager", "The Alan Parsons Project","Pyramid" }, { "Twilight Painter", "Tangerine Dream", "Heartbreakers" } }; +#endif + static int num_helpscreen_music = 7; static int helpscreen_musicpos; -#if 0 -void OLD_DrawHelpScreenElAction(int start) +#if 1 +void DrawHelpScreenElAction(int start, boolean init) { int i = 0, j = 0; - int frame, graphic; - int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4; + int xstart = mSX + 16; + int ystart = mSY + 64 + 2 * 32; + int ystep = TILEY + 4; + int element, action, direction; + int graphic; + int delay; + int sync_frame; + + if (init) + { + SetMainBackgroundImage(IMG_BACKGROUND_INFO); + ClearWindow(); + DrawHeadline(); + + DrawTextSCentered(100, FONT_TEXT_1, "The game elements:"); + + DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4, + "Press any key or button for next page"); + } - while(helpscreen_action[j] != HA_END) + while (demo_anim_info[j].element != -999) { - if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els) + if (i >= start + MAX_HELPSCREEN_ELS || i >= num_helpscreen_els) break; - else if (i=start && helpscreen_delay[i-start]) - helpscreen_delay[i-start]--; - - while(helpscreen_action[j] != HA_NEXT) + while (demo_anim_info[j].element != -1) j++; + j++; i++; + continue; } - j += 3*helpscreen_step[i-start]; - graphic = helpscreen_action[j++]; + j += helpscreen_step[i - start]; - if (helpscreen_frame[i-start]) + element = demo_anim_info[j].element; + action = demo_anim_info[j].action; + direction = demo_anim_info[j].direction; + + if (action != -1 && direction != -1) + graphic = el_act_dir2img(element, action, direction); + else if (action != -1) + graphic = el_act2img(element, action); + else if (direction != -1) + graphic = el_act2img(element, direction); + else + graphic = el2img(element); + + delay = demo_anim_info[j++].delay; + + if (delay == -1) + delay = 1000000; + + if (helpscreen_frame[i - start] == 0) { - frame = helpscreen_action[j++] - helpscreen_frame[i-start]; - helpscreen_frame[i-start]--; + sync_frame = 0; + helpscreen_frame[i - start] = delay - 1; } else { - frame = 0; - helpscreen_frame[i-start] = helpscreen_action[j++]-1; + sync_frame = delay - helpscreen_frame[i - start]; + helpscreen_frame[i - start]--; } - helpscreen_delay[i-start] = helpscreen_action[j++] - 1; - - if (helpscreen_action[j] == HA_NEXT) + if (demo_anim_info[j].element == -1) { - if (!helpscreen_frame[i-start]) - helpscreen_step[i-start] = 0; + if (!helpscreen_frame[i - start]) + helpscreen_step[i - start] = 0; } else { - if (!helpscreen_frame[i-start]) - helpscreen_step[i-start]++; - while(helpscreen_action[j] != HA_NEXT) + if (!helpscreen_frame[i - start]) + helpscreen_step[i - start]++; + while(demo_anim_info[j].element != -1) j++; } + j++; - DrawOldGraphicExt(drawto, xstart, ystart+(i-start)*ystep, graphic+frame); + ClearRectangleOnBackground(drawto, xstart, ystart + (i - start) * ystep, + TILEX, TILEY); + DrawGraphicAnimationExt(drawto, xstart, ystart + (i - start) * ystep, + graphic, sync_frame, USE_MASKING); + + if (init) + DrawHelpScreenElText(element, action, direction, i - start); + i++; } - for(i=2;i<16;i++) - { - MarkTileDirty(0,i); - MarkTileDirty(1,i); - } + redraw_mask |= REDRAW_FIELD; + + FrameCounter++; } -#endif + +#else void DrawHelpScreenElAction(int start) { @@ -929,6 +997,64 @@ void DrawHelpScreenElAction(int start) FrameCounter++; } +#endif + +#if 1 +void DrawHelpScreenElText(int element, int action, int direction, int ypos) +{ + int xstart = mSX + 56; + int ystart = mSY + 65 + 2 * 32; + int ystep = TILEY + 4; + char *text; + + text = getHashEntry(demo_anim_text, element_info[element].token_name); + + if (text == NULL) + { + char token[MAX_LINE_LEN]; + + strcpy(token, element_info[element].token_name); + + if (action != -1) + strcat(token, element_action_info[action].suffix); + + if (direction != -1) + strcat(token, element_direction_info[MV_DIR_BIT(direction)].suffix); + + text = getHashEntry(demo_anim_text, token); + + if (text == NULL) + text = "No description available"; + } + +#if 1 + +#if 1 + + if (strlen(text) <= 34) + ystart += getFontHeight(FONT_TEXT_2) / 2; + +#if 0 + DrawTextWrapped(xstart, ystart+1 + ypos * ystep, text, FONT_LEVEL_NUMBER, + 34, 2); +#else + DrawTextWrapped(xstart, ystart+1 + ypos * ystep, text, FONT_TEXT_2, 34, 2); +#endif + +#else + DrawTextToTextArea(xstart, ystart + ypos * ystep, text, FONT_TEXT_2, 34, + 34, 2, BLIT_ON_BACKGROUND); +#endif + +#else + if (strlen(text) > 25) + text[25] = '\0'; + + DrawText(xstart, ystart + ypos * ystep + 8, text, FONT_TEXT_2); +#endif +} + +#else void DrawHelpScreenElText(int start) { @@ -940,7 +1066,7 @@ void DrawHelpScreenElText(int start) ClearWindow(); DrawHeadline(); - DrawTextFCentered(100, FONT_TEXT_1, "The game elements:"); + DrawTextSCentered(100, FONT_TEXT_1, "The game elements:"); for(i=start; i < start + MAX_HELPSCREEN_ELS && i < num_helpscreen_els; i++) { @@ -951,32 +1077,47 @@ void DrawHelpScreenElText(int start) helpscreen_eltext[i][1], FONT_TEXT_2); } - DrawTextFCentered(ybottom, FONT_TEXT_4, + DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for next page"); } +#endif void DrawHelpScreenMusicText(int num) { + struct MusicFileInfo *list = music_file_info; int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; + int i; - FadeSounds(); + for (i=0; i < num && list; i++) + list = list->next; + + FadeSoundsAndMusic(); ClearWindow(); DrawHeadline(); - DrawTextFCentered(100, FONT_TEXT_1, "The game background music loops:"); + DrawTextSCentered(100, FONT_TEXT_1, "The game background music loops:"); - DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); +#if 1 + DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); + DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", list->title); + DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); + DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", list->artist); + DrawTextSCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); + DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_3, "\"%s\"", list->album); +#else + DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "Excerpt from"); DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "\"%s\"", helpscreen_music[num][0]); - DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); + DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "by"); DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "%s", helpscreen_music[num][1]); - DrawTextFCentered(ystart + 4 * ystep, FONT_TEXT_2, "from the album"); + DrawTextSCentered(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, + DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for next page"); #if 0 @@ -989,20 +1130,20 @@ void DrawHelpScreenCreditsText() int ystart = 150, ystep = 30; int ybottom = SYSIZE - 20; - FadeSounds(); + FadeSoundsAndMusic(); ClearWindow(); DrawHeadline(); - DrawTextFCentered(100, FONT_TEXT_1, "Credits:"); - DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, "DOS port of the game:"); - DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_3, "Guido Schulz"); - DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_2, "Additional toons:"); - DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_3, "Karl Hörnell"); - DrawTextFCentered(ystart + 5 * ystep, FONT_TEXT_2, + DrawTextSCentered(100, FONT_TEXT_1, "Credits:"); + DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "DOS port of the game:"); + DrawTextSCentered(ystart + 1 * ystep, FONT_TEXT_3, "Guido Schulz"); + DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_2, "Additional toons:"); + DrawTextSCentered(ystart + 3 * ystep, FONT_TEXT_3, "Karl Hörnell"); + DrawTextSCentered(ystart + 5 * ystep, FONT_TEXT_2, "...and many thanks to all contributors"); - DrawTextFCentered(ystart + 6 * ystep, FONT_TEXT_2, "of new levels!"); + DrawTextSCentered(ystart + 6 * ystep, FONT_TEXT_2, "of new levels!"); - DrawTextFCentered(ybottom, FONT_TEXT_4, + DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for next page"); } @@ -1014,38 +1155,39 @@ void DrawHelpScreenContactText() ClearWindow(); DrawHeadline(); - DrawTextFCentered(100, FONT_TEXT_1, "Program information:"); + DrawTextSCentered(100, FONT_TEXT_1, "Program information:"); - DrawTextFCentered(ystart + 0 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 0 * ystep, FONT_TEXT_2, "This game is Freeware!"); - DrawTextFCentered(ystart + 1 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 1 * ystep, FONT_TEXT_2, "If you like it, send e-mail to:"); - DrawTextFCentered(ystart + 2 * ystep, FONT_TEXT_3, + DrawTextSCentered(ystart + 2 * ystep, FONT_TEXT_3, "info@artsoft.org"); - DrawTextFCentered(ystart + 3 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 3 * ystep, FONT_TEXT_2, "or SnailMail to:"); - DrawTextFCentered(ystart + 4 * ystep + 0, FONT_TEXT_3, + DrawTextSCentered(ystart + 4 * ystep + 0, FONT_TEXT_3, "Holger Schemel"); - DrawTextFCentered(ystart + 4 * ystep + 20, FONT_TEXT_3, + DrawTextSCentered(ystart + 4 * ystep + 20, FONT_TEXT_3, "Detmolder Strasse 189"); - DrawTextFCentered(ystart + 4 * ystep + 40, FONT_TEXT_3, + DrawTextSCentered(ystart + 4 * ystep + 40, FONT_TEXT_3, "33604 Bielefeld"); - DrawTextFCentered(ystart + 4 * ystep + 60, FONT_TEXT_3, + DrawTextSCentered(ystart + 4 * ystep + 60, FONT_TEXT_3, "Germany"); - DrawTextFCentered(ystart + 7 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 7 * ystep, FONT_TEXT_2, "If you have created new levels,"); - DrawTextFCentered(ystart + 8 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 8 * ystep, FONT_TEXT_2, "send them to me to include them!"); - DrawTextFCentered(ystart + 9 * ystep, FONT_TEXT_2, + DrawTextSCentered(ystart + 9 * ystep, FONT_TEXT_2, ":-)"); - DrawTextFCentered(ybottom, FONT_TEXT_4, + DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for main menu"); } void DrawHelpScreen() { + struct MusicFileInfo *list; int i; UnmapAllGadgets(); @@ -1056,17 +1198,29 @@ void DrawHelpScreen() helpscreen_musicpos = 0; helpscreen_state = 0; + LoadDemoAnimInfo(); + LoadDemoAnimText(); + LoadMusicInfo(); + + num_helpscreen_els = 0; + for (i=0; demo_anim_info[i].element != -999; i++) + if (demo_anim_info[i].element == -1) + num_helpscreen_els++; + + num_helpscreen_music = 0; + for (list = music_file_info; list != NULL; list = list->next) + num_helpscreen_music++; + + DrawHelpScreenElAction(0, TRUE); +#if 0 DrawHelpScreenElText(0); - DrawHelpScreenElAction(0); +#endif FadeToFront(); InitAnimation(); -#if 0 - PlaySoundLoop(SND_BACKGROUND_INFO); -#else - PlaySound_Menu_Start(SND_BACKGROUND_INFO); -#endif + PlayMenuSound(); + PlayMenuMusic(); } void HandleHelpScreen(int button) @@ -1086,8 +1240,10 @@ void HandleHelpScreen(int button) helpscreen_state++; FrameCounter = 0; + DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS, TRUE); +#if 0 DrawHelpScreenElText(helpscreen_state * MAX_HELPSCREEN_ELS); - DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS); +#endif } else if (helpscreen_state < num_helpscreen_els_pages + num_helpscreen_music - 1) @@ -1109,7 +1265,7 @@ void HandleHelpScreen(int button) } else { - FadeSounds(); + FadeSoundsAndMusic(); game_status = GAME_MODE_MAIN; DrawMainMenu(); @@ -1120,17 +1276,10 @@ void HandleHelpScreen(int button) if (DelayReached(&hs_delay, GAME_FRAME_DELAY)) { if (helpscreen_state < num_helpscreen_els_pages) - DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS); + DrawHelpScreenElAction(helpscreen_state * MAX_HELPSCREEN_ELS, FALSE); } - /* !!! 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 + PlayMenuSoundIfLoop(); } DoAnimation(); @@ -1240,12 +1389,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 */ -#if 1 - DrawBackground(mSX, mSY, SXSIZE - 32 + menu.scrollbar_xoffset, SYSIZE); -#else - DrawBackground(SX, SY, SXSIZE - 32, SYSIZE); -#endif - title_string = (ti->type == TREE_TYPE_LEVEL_DIR ? "Level Directories" : ti->type == TREE_TYPE_GRAPHICS_DIR ? "Custom Graphics" : @@ -1257,6 +1400,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 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, @@ -2192,7 +2339,7 @@ void DrawSetupScreen_Input() #if 0 DeactivateJoystickForCalibration(); - DrawTextFCentered(SYSIZE - 20, FONT_TEXT_4, + DrawTextSCentered(SYSIZE - 20, FONT_TEXT_4, "Joysticks deactivated on this screen"); #endif @@ -2766,6 +2913,9 @@ void DrawSetupScreen() DrawChooseTree(&artwork.mus_current); else DrawSetupScreen_Generic(); + + PlayMenuSound(); + PlayMenuMusic(); } void HandleSetupScreen(int mx, int my, int dx, int dy, int button)