X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=ec0a1231b4573c329886272d7e9127e7dbc629ea;hb=c2a639c0b2c1a9a2bd14de86932a47429ae918a4;hp=eab0b75eee96855176fe7cffc5940338c5d23c7d;hpb=e28d2724a580d0aec5521daa85e18ffaed3b86a1;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index eab0b75e..ec0a1231 100644 --- a/src/screens.c +++ b/src/screens.c @@ -71,15 +71,16 @@ static void HandleChooseTree(int, int, int, int, int, TreeInfo **); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; static int setup_mode = SETUP_MODE_MAIN; -#if 0 -static int mSX = SX; -static int mSY = SY; -#else -#define mSX (SX + (game_status == MAINMENU ? global.menu_draw_xoffset_MAIN : \ - global.menu_draw_xoffset)) -#define mSY (SY + (game_status == MAINMENU ? global.menu_draw_yoffset_MAIN : \ - global.menu_draw_yoffset)) -#endif +#define mSX (SX + (game_status >= GAME_MODE_MAIN && \ + game_status <= GAME_MODE_SETUP ? \ + menu.draw_xoffset[game_status] : menu.draw_xoffset_default)) +#define mSY (SY + (game_status >= GAME_MODE_MAIN && \ + game_status <= GAME_MODE_SETUP ? \ + menu.draw_yoffset[game_status] : menu.draw_yoffset_default)) + +#define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \ + menu.list_size[game_status] : \ + MAX_MENU_ENTRIES_ON_SCREEN) #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) #define NUM_SCROLLBAR_BITMAPS 2 @@ -106,14 +107,9 @@ static void drawCursorExt(int xpos, int ypos, int color, int graphic) ypos += MENU_SCREEN_START_YPOS; -#if 1 DrawBackground(mSX + xpos * TILEX, mSY + ypos * TILEY, TILEX, TILEY); DrawGraphicThruMaskExt(drawto, mSX + xpos * TILEX, mSY + ypos * TILEY, graphic, 0); -#else - DrawBackground(SX + xpos * 32, SY + ypos * 32, TILEX, TILEY); - DrawGraphicThruMask(xpos, ypos, graphic, 0); -#endif } static void initCursor(int ypos, int graphic) @@ -131,29 +127,61 @@ static void drawCursorXY(int xpos, int ypos, int graphic) drawCursorExt(xpos, ypos, -1, graphic); } -static void PlaySound_Menu_Start(int sound) +static void drawChooseTreeCursor(int ypos, int color) { + int last_game_status = game_status; /* save current game status */ + + /* force LEVELS draw offset on artwork setup screen */ + game_status = GAME_MODE_LEVELS; + + drawCursorExt(0, ypos, color, 0); + + 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 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() @@ -184,18 +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; -#if 0 - mSX = SX + global.menu_draw_xoffset; - mSY = SY + global.menu_draw_yoffset; -#endif - UnmapAllGadgets(); - FadeSounds(); + FadeSoundsAndMusic(); KeyboardAutoRepeatOn(); ActivateJoystick(); @@ -208,8 +230,9 @@ void DrawMainMenu() /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) { - game_status = LEVELED; + game_status = GAME_MODE_EDITOR; DrawLevelEd(); + return; } @@ -219,6 +242,13 @@ void DrawMainMenu() /* needed if last screen was the setup screen and fullscreen state changed */ ToggleFullscreenIfNeeded(); + /* leveldir_current may be invalid (level group, parent link) */ + if (!validLevelSeries(leveldir_current)) + leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); + + /* store valid level series information */ + leveldir_last_valid = leveldir_current; + /* needed if last screen (level choice) changed graphics, sounds or music */ ReloadCustomArtwork(); @@ -229,13 +259,6 @@ void DrawMainMenu() /* map gadgets for main menu screen */ MapTapeButtons(); - /* leveldir_current may be invalid (level group, parent link) */ - if (!validLevelSeries(leveldir_current)) - leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); - - /* store valid level series information */ - leveldir_last_valid = leveldir_current; - /* level_nr may have been set to value over handicap with level editor */ if (setup.handicap && level_nr > leveldir_current->handicap_level) level_nr = leveldir_current->handicap_level; @@ -252,7 +275,7 @@ void DrawMainMenu() DrawText(mSX + 32, mSY + 3*32, "Level:", FONT_MENU_1); DrawText(mSX + 32, mSY + 4*32, "Hall Of Fame", FONT_MENU_1); DrawText(mSX + 32, mSY + 5*32, "Level Creator", FONT_MENU_1); - DrawText(mSY + 32, mSY + 6*32, "Info Screen", FONT_MENU_1); + DrawText(mSX + 32, mSY + 6*32, "Info Screen", FONT_MENU_1); DrawText(mSX + 32, mSY + 7*32, "Start Game", FONT_MENU_1); DrawText(mSX + 32, mSY + 8*32, "Setup", FONT_MENU_1); DrawText(mSX + 32, mSY + 9*32, "Quit", FONT_MENU_1); @@ -266,14 +289,12 @@ void DrawMainMenu() DrawTextF(mSX + 32 + level_width - 2, mSY + 3*32 + 1, FONT_TEXT_3, "%d-%d", leveldir_current->first_level, leveldir_current->last_level); - /* if (leveldir_current->readonly) - */ { - DrawTextF(mSX + level_width + 9*32 - 2, - mSY + 3*32 + 1 - 7, FONT_TEXT_3, "READ"); - DrawTextF(mSX + level_width + 9*32 - 2, - mSY + 3*32 + 1 + 7, FONT_TEXT_3, "ONLY"); + DrawTextS(mSX + level_width + 9 * 32 - 2, + mSY + 3 * 32 + 1 - 7, FONT_TEXT_3, "READ"); + DrawTextS(mSX + level_width + 9 * 32 - 2, + mSY + 3 * 32 + 1 + 7, FONT_TEXT_3, "ONLY"); } for(i=0; i<8; i++) @@ -293,6 +314,9 @@ void DrawMainMenu() LoadTape(level_nr); DrawCompleteVideoDisplay(); + PlayMenuSound(); + PlayMenuMusic(); + OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); #if 0 @@ -313,10 +337,10 @@ static void gotoTopLevelDir() int num_page_entries; int cl_first, cl_cursor; - if (num_leveldirs <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN) num_page_entries = num_leveldirs; else - num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1; + num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; cl_first = MAX(0, leveldir_pos - num_page_entries + 1); cl_cursor = leveldir_pos - cl_first; @@ -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; @@ -343,8 +367,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (mx || my) /* mouse input */ { - x = (mx - SX) / 32; - y = (my - SY) / 32 - MENU_SCREEN_START_YPOS; + x = (mx - mSX) / 32; + y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; } else if (dx || dy) /* keyboard input */ { @@ -406,14 +430,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (y == 0) { - game_status = TYPENAME; + game_status = GAME_MODE_PSEUDO_TYPENAME; HandleTypeName(strlen(setup.player_name), 0); } else if (y == 1) { if (leveldir_first) { - game_status = CHOOSELEVEL; + game_status = GAME_MODE_LEVELS; SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); @@ -424,7 +448,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (y == 2) { - game_status = HALLOFFAME; + game_status = GAME_MODE_SCORES; DrawHallOfFame(-1); } else if (y == 3) @@ -432,12 +456,12 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (leveldir_current->readonly && strcmp(setup.player_name, "Artsoft") != 0) Request("This level is read only !", REQ_CONFIRM); - game_status = LEVELED; + game_status = GAME_MODE_EDITOR; DrawLevelEd(); } else if (y == 4) { - game_status = HELPSCREEN; + game_status = GAME_MODE_INFO; DrawHelpScreen(); } else if (y == 5) @@ -451,14 +475,14 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) else #endif { - game_status = PLAYING; + game_status = GAME_MODE_PLAYING; StopAnimation(); InitGame(); } } else if (y == 6) { - game_status = SETUP; + game_status = GAME_MODE_SETUP; setup_mode = SETUP_MODE_MAIN; DrawSetupScreen(); } @@ -467,20 +491,20 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED)) - game_status = EXITGAME; + game_status = GAME_MODE_QUIT; } } } - BackToFront(); - out: - if (game_status == MAINMENU) + if (game_status == GAME_MODE_MAIN) { DrawMicroLevel(MICROLEV_XPOS, MICROLEV_YPOS, FALSE); DoAnimation(); } + + BackToFront(); } @@ -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, @@ -526,7 +551,7 @@ static int helpscreen_action[] = IMG_INVISIBLE_WALL, -1, HA_NEXT, - IMG_WALL_CRUMBLED, -1, HA_NEXT, + IMG_WALL_SLIPPERY, -1, HA_NEXT, IMG_FONT_GAME_INFO, -1, HA_NEXT, @@ -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; - while(helpscreen_action[j] != HA_END) + if (init) { - if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els) + 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 (demo_anim_info[j].element != -999) + { + 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]; + + element = demo_anim_info[j].element; + action = demo_anim_info[j].action; + direction = demo_anim_info[j].direction; - if (helpscreen_frame[i-start]) + 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) { @@ -855,7 +923,6 @@ void DrawHelpScreenElAction(int start) int graphic; int frame_count; int sync_frame; - int frame; while (helpscreen_action[j] != HA_END) { @@ -903,22 +970,91 @@ void DrawHelpScreenElAction(int start) } j++; +#if 1 + ClearRectangleOnBackground(drawto, xstart, ystart + (i - start) * ystep, + TILEX, TILEY); + DrawGraphicAnimationExt(drawto, xstart, ystart + (i - start) * ystep, + graphic, sync_frame, USE_MASKING); +#else frame = getGraphicAnimationFrame(graphic, sync_frame); DrawGraphicExt(drawto, xstart, ystart + (i-start) * ystep, graphic, frame); +#endif i++; } +#if 1 + redraw_mask |= REDRAW_FIELD; +#else for(i=2; i<16; i++) { MarkTileDirty(0, i); MarkTileDirty(1, i); } +#endif 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) { @@ -930,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++) { @@ -941,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 @@ -979,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"); } @@ -1004,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(); @@ -1046,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) @@ -1076,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) @@ -1099,9 +1265,9 @@ void HandleHelpScreen(int button) } else { - FadeSounds(); + FadeSoundsAndMusic(); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } @@ -1110,21 +1276,13 @@ 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 - - DoAnimation(); + PlayMenuSoundIfLoop(); } + DoAnimation(); BackToFront(); } @@ -1177,7 +1335,7 @@ void HandleTypeName(int newxpos, Key key) DrawText(startx + xpos * font_width, starty, " ", FONT_INPUT_1_ACTIVE); SaveSetup(); - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; } BackToFront(); @@ -1186,6 +1344,10 @@ void HandleTypeName(int newxpos, Key key) static void DrawChooseTree(TreeInfo **ti_ptr) { UnmapAllGadgets(); + + FreeScreenGadgets(); + CreateScreenGadgets(); + CloseDoor(DOOR_CLOSE_2); ClearWindow(); @@ -1203,13 +1365,14 @@ static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti) int items_max, items_visible, item_position; items_max = numTreeInfoInGroup(ti); - items_visible = MAX_MENU_ENTRIES_ON_SCREEN - 1; + items_visible = NUM_MENU_ENTRIES_ON_SCREEN; item_position = first_entry; if (item_position > items_max - items_visible) item_position = items_max - items_visible; ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max, + GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END); } @@ -1219,23 +1382,28 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, int i; char buffer[SCR_FIELDX * 2]; int max_buffer_len = (SCR_FIELDX - 2) * 2; - int num_entries = numTreeInfoInGroup(ti); char *title_string = NULL; - int offset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : 16); + int xoffset_setup = 16; + int yoffset_setup = 16; + int xoffset = (ti->type == TREE_TYPE_LEVEL_DIR ? 0 : xoffset_setup); + 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" : ti->type == TREE_TYPE_SOUNDS_DIR ? "Custom Sounds" : ti->type == TREE_TYPE_MUSIC_DIR ? "Custom Music" : ""); - DrawText(SX + offset, SY + offset, title_string, FONT_TITLE_1); + DrawText(SX + xoffset, SY + yoffset, title_string, FONT_TITLE_1); - game_status = CHOOSELEVEL; /* force LEVELS font on artwork setup screen */ + /* 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) - { - int ypos = 1; - - DrawBackground(SX, SY + ypos * 32, TILEX, TILEY); - DrawGraphicThruMask(0, ypos, IMG_MENU_BUTTON_UP, 0); - } - - if (first_entry + num_page_entries < num_entries) - { - int ypos = MAX_MENU_ENTRIES_ON_SCREEN + 1; - - DrawBackground(SX, SY + ypos * 32, TILEX, TILEY); - DrawGraphicThruMask(0, ypos, IMG_MENU_BUTTON_DOWN, 0); - } - game_status = last_game_status; /* restore current game status */ + + redraw_mask |= REDRAW_FIELD; } static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti) @@ -1310,28 +1464,42 @@ static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti) static void HandleChooseTree(int mx, int my, int dx, int dy, int button, TreeInfo **ti_ptr) { - static unsigned long choose_delay = 0; TreeInfo *ti = *ti_ptr; int x = 0; int y = ti->cl_cursor; 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 */ + + /* force LEVELS draw offset on choose level and artwork setup screen */ + game_status = GAME_MODE_LEVELS; - if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) num_page_entries = num_entries; else - num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1; + num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; + + game_status = last_game_status; /* restore current game status */ if (button == MB_MENU_INITIALIZE) { + int num_entries = numTreeInfoInGroup(ti); int entry_pos = posTreeInfo(ti); if (ti->cl_first == -1) { + /* only on initialization */ ti->cl_first = MAX(0, entry_pos - num_page_entries + 1); - ti->cl_cursor = - entry_pos - ti->cl_first; + ti->cl_cursor = entry_pos - ti->cl_first; + } + else if (ti->cl_cursor >= num_page_entries || + (num_entries > num_page_entries && + num_entries - ti->cl_first < num_page_entries)) + { + /* only after change of list size (by custom graphic configuration) */ + ti->cl_first = MAX(0, entry_pos - num_page_entries + 1); + ti->cl_cursor = entry_pos - ti->cl_first; } if (dx == 999) /* first entry is set by scrollbar position */ @@ -1342,7 +1510,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, drawChooseTreeList(ti->cl_first, num_page_entries, ti); drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); + return; } else if (button == MB_MENU_LEAVE) @@ -1352,13 +1521,13 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, *ti_ptr = ti->node_parent; DrawChooseTree(ti_ptr); } - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) { execSetupArtwork(); } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } @@ -1367,55 +1536,66 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (mx || my) /* mouse input */ { - x = (mx - SX) / 32; - y = (my - SY) / 32 - MENU_SCREEN_START_YPOS; - } - else if (dx || dy) /* keyboard input */ - { - if (dy) - y = ti->cl_cursor + dy; + int last_game_status = game_status; /* save current game status */ - if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */ - { - dy = SIGN(dy); - step = num_page_entries - 1; - y = (dy < 0 ? -1 : num_page_entries); - } - } + /* force LEVELS draw offset on artwork setup screen */ + game_status = GAME_MODE_LEVELS; - if (x == 0 && y == -1) - { - if (ti->cl_first > 0 && - (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) - { - ti->cl_first -= step; - if (ti->cl_first < 0) - ti->cl_first = 0; + x = (mx - mSX) / 32; + y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; - drawChooseTreeList(ti->cl_first, num_page_entries, ti); - drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); - AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, - ti->cl_first, ti); - return; - } + game_status = last_game_status; /* restore current game status */ } - else if (x == 0 && y > num_page_entries - 1) + else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */ { - if (ti->cl_first + num_page_entries < num_entries && - (dy || DelayReached(&choose_delay, GADGET_FRAME_DELAY))) + /* move cursor instead of scrolling when already at start/end of list */ + if (dy == -1 * SCROLL_LINE && ti->cl_first == 0) + dy = -1; + else if (dy == +1 * SCROLL_LINE && + ti->cl_first + num_page_entries == num_entries) + dy = 1; + + /* handle scrolling screen one line or page */ + if (ti->cl_cursor + dy < 0 || + ti->cl_cursor + dy > num_page_entries - 1) { - ti->cl_first += step; - if (ti->cl_first + num_page_entries > num_entries) - ti->cl_first = MAX(0, num_entries - num_page_entries); + if (ABS(dy) == SCROLL_PAGE) + step = num_page_entries - 1; + + if (dy < 0 && ti->cl_first > 0) + { + /* scroll page/line up */ + + ti->cl_first -= step; + if (ti->cl_first < 0) + ti->cl_first = 0; + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + ti->cl_first, ti); + } + else if (dy > 0 && ti->cl_first + num_page_entries < num_entries) + { + /* scroll page/line down */ + + ti->cl_first += step; + if (ti->cl_first + num_page_entries > num_entries) + ti->cl_first = MAX(0, num_entries - num_page_entries); + + drawChooseTreeList(ti->cl_first, num_page_entries, ti); + drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); + drawChooseTreeCursor(ti->cl_cursor, FC_RED); + AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, + ti->cl_first, ti); + } - drawChooseTreeList(ti->cl_first, num_page_entries, ti); - drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti); - drawCursor(ti->cl_cursor, FC_RED); - AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, - ti->cl_first, ti); return; } + + /* handle moving cursor one line */ + y = ti->cl_cursor + dy; } if (dx == 1) @@ -1432,6 +1612,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, node_cursor->cl_cursor = ti->cl_cursor; *ti_ptr = node_cursor->node_group; DrawChooseTree(ti_ptr); + return; } } @@ -1439,6 +1620,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { *ti_ptr = ti->node_parent; DrawChooseTree(ti_ptr); + return; } @@ -1448,8 +1630,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { if (y != ti->cl_cursor) { - drawCursor(y, FC_RED); - drawCursor(ti->cl_cursor, FC_BLUE); + drawChooseTreeCursor(y, FC_RED); + drawChooseTreeCursor(ti->cl_cursor, FC_BLUE); drawChooseTreeInfo(ti->cl_first + y, ti); ti->cl_cursor = y; } @@ -1489,23 +1671,25 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, TapeErase(); } - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) { execSetupArtwork(); } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } } } - BackToFront(); - - if (game_status == CHOOSELEVEL || game_status == SETUP) +#if 0 + if (game_status == GAME_MODE_LEVELS || game_status == GAME_MODE_SETUP) DoAnimation(); + + BackToFront(); +#endif } void DrawChooseLevel() @@ -1513,17 +1697,23 @@ void DrawChooseLevel() SetMainBackgroundImage(IMG_BACKGROUND_LEVELS); DrawChooseTree(&leveldir_current); + + PlayMenuSound(); + PlayMenuMusic(); } void HandleChooseLevel(int mx, int my, int dx, int dy, int button) { HandleChooseTree(mx, my, dx, dy, button, &leveldir_current); + + DoAnimation(); + BackToFront(); } void DrawHallOfFame(int highlight_position) { UnmapAllGadgets(); - FadeSounds(); + FadeSoundsAndMusic(); CloseDoor(DOOR_CLOSE_2); if (highlight_position < 0) @@ -1534,11 +1724,8 @@ void DrawHallOfFame(int highlight_position) HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE); -#if 0 - PlaySound(SND_BACKGROUND_SCORES); -#else - PlaySound_Menu_Start(SND_BACKGROUND_SCORES); -#endif + PlayMenuSound(); + PlayMenuMusic(); } static void drawHallOfFameList(int first_entry, int highlight_position) @@ -1551,20 +1738,28 @@ static void drawHallOfFameList(int first_entry, int highlight_position) DrawText(mSX + 80, mSY + 8, "Hall Of Fame", FONT_TITLE_1); DrawTextFCentered(46, FONT_TITLE_2, "HighScores of Level %d", level_nr); - for(i=0; i 0) { - if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) + if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) { first_entry += step; - if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) - first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN); + if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) + 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 = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } - BackToFront(); + if (game_status == GAME_MODE_SCORES) + PlayMenuSoundIfLoop(); - if (game_status == HALLOFFAME) - { - DoAnimation(); -#if 1 - PlaySound_Menu_Continue(SND_BACKGROUND_SCORES); -#endif - } + DoAnimation(); + BackToFront(); } @@ -1672,13 +1861,13 @@ static void execSetupSound() static void execSetupArtwork() { - /* needed if last screen (setup choice) changed graphics, sounds or music */ - ReloadCustomArtwork(); - setup.graphics_set = artwork.gfx_current->identifier; setup.sounds_set = artwork.snd_current->identifier; setup.music_set = artwork.mus_current->identifier; + /* needed if last screen (setup choice) changed graphics, sounds or music */ + ReloadCustomArtwork(); + /* needed for displaying artwork name instead of artwork identifier */ graphics_set_name = artwork.gfx_current->name; sounds_set_name = artwork.snd_current->name; @@ -1720,7 +1909,7 @@ static void execSetupShortcut() static void execExitSetup() { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } @@ -1768,6 +1957,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 } @@ -1791,8 +1983,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:" }, @@ -1871,8 +2061,8 @@ static Key getSetupKey() } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -1886,23 +2076,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; @@ -1912,9 +2104,10 @@ 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 && - !*(boolean *)(setup_info[pos].value)) - font_nr = FONT_OPTION_OFF; + else if (type & TYPE_BOOLEAN_STYLE) + { + font_nr = (*(boolean *)value ? FONT_OPTION_ON : FONT_OPTION_OFF); + } DrawText(mSX + xpos * 32, mSY + ypos * 32, (xpos == 3 ? " " : " "), font_nr); @@ -1992,17 +2185,17 @@ static void DrawSetupScreen_Generic() DrawText(mSX + 16, mSY + 16, title_string, FONT_TITLE_1); num_setup_info = 0; - for(i=0; setup_info[i].type != 0 && i < MAX_MENU_ENTRIES_ON_SCREEN; i++) + for(i=0; setup_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { void *value_ptr = setup_info[i].value; int ypos = MENU_SCREEN_START_YPOS + i; 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) @@ -2064,8 +2257,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) if (mx || my) /* mouse input */ { - x = (mx - SX) / 32; - y = (my - SY) / 32 - MENU_SCREEN_START_YPOS; + x = (mx - mSX) / 32; + y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; } else if (dx || dy) /* keyboard input */ { @@ -2118,10 +2311,12 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void DrawSetupScreen_Input() @@ -2144,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 @@ -2275,8 +2470,8 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) if (mx || my) /* mouse input */ { - x = (mx - SX) / 32; - y = (my - SY) / 32 - MENU_SCREEN_START_YPOS; + x = (mx - mSX) / 32; + y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; } else if (dx || dy) /* keyboard input */ { @@ -2298,7 +2493,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; @@ -2362,12 +2561,14 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) } } +#if 0 BackToFront(); out: - if (game_status == SETUP) + if (game_status == GAME_MODE_SETUP) DoAnimation(); +#endif } void CustomizeKeyboard(int player_nr) @@ -2485,8 +2686,8 @@ void CustomizeKeyboard(int player_nr) } } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2648,8 +2849,8 @@ static boolean CalibrateJoystickMain(int player_nr) } - BackToFront(); DoAnimation(); + BackToFront(); /* don't eat all CPU time */ Delay(10); @@ -2712,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) @@ -2726,11 +2930,14 @@ 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() { - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; if (local_player->LevelSolved) @@ -2742,22 +2949,30 @@ void HandleGameActions() GameActions(); BackToFront(); + +#if 1 + if (tape.auto_play && !tape.playing) + AutoPlayTape(); /* continue automatically playing next tape */ +#endif } /* ---------- new screen button stuff -------------------------------------- */ /* graphic position and size values for buttons and scrollbars */ -#define SC_SCROLLBUTTON_XSIZE 32 -#define SC_SCROLLBUTTON_YSIZE 32 +#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 SC_SCROLLBUTTON_YSIZE -#define SC_SCROLL_DOWN_XPOS SC_SCROLL_UP_XPOS -#define SC_SCROLL_DOWN_YPOS (SYSIZE - SC_SCROLLBUTTON_YSIZE) +#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_VERTICAL_XSIZE SC_SCROLLBUTTON_XSIZE -#define SC_SCROLL_VERTICAL_YSIZE (SYSIZE - 3 * SC_SCROLLBUTTON_YSIZE) +#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 @@ -2803,7 +3018,7 @@ static struct #else IMG_MENU_SCROLLBAR, IMG_MENU_SCROLLBAR_ACTIVE, #endif - SX + SC_SCROLL_VERTICAL_XPOS, SY + SC_SCROLL_VERTICAL_YPOS, + SC_SCROLL_VERTICAL_XPOS, SC_SCROLL_VERTICAL_YPOS, SC_SCROLL_VERTICAL_XSIZE, SC_SCROLL_VERTICAL_YSIZE, GD_TYPE_SCROLLBAR_VERTICAL, SCREEN_CTRL_ID_SCROLL_VERTICAL, @@ -2825,16 +3040,17 @@ static void CreateScreenScrollbuttons() int gd_x1, gd_x2, gd_y1, gd_y2; int id = scrollbutton_info[i].gadget_id; - x = scrollbutton_info[i].x; - y = scrollbutton_info[i].y; - event_mask = GD_EVENT_PRESSED | GD_EVENT_REPEATED; - x += SX; - y += SY; + x = mSX + scrollbutton_info[i].x + menu.scrollbar_xoffset; + y = mSY + scrollbutton_info[i].y; width = SC_SCROLLBUTTON_XSIZE; height = SC_SCROLLBUTTON_YSIZE; + if (id == SCREEN_CTRL_ID_SCROLL_DOWN) + y = mSY + (SC_SCROLL_VERTICAL_YPOS + + (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE); + gfx_unpressed = scrollbutton_info[i].gfx_unpressed; gfx_pressed = scrollbutton_info[i].gfx_pressed; gd_bitmap_unpressed = graphic_info[gfx_unpressed].bitmap; @@ -2855,6 +3071,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); @@ -2876,19 +3093,28 @@ static void CreateScreenScrollbars() #if !defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) int gfx_unpressed, gfx_pressed; #endif + int x, y, width, height; int gd_x1, gd_x2, gd_y1, gd_y2; struct GadgetInfo *gi; int items_max, items_visible, item_position; unsigned long event_mask; - int num_page_entries = MAX_MENU_ENTRIES_ON_SCREEN - 1; + int num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; int id = scrollbar_info[i].gadget_id; + event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; + + x = mSX + scrollbar_info[i].x + menu.scrollbar_xoffset; + y = mSY + scrollbar_info[i].y; + width = scrollbar_info[i].width; + height = scrollbar_info[i].height; + + if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL) + height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE; + items_max = num_page_entries; items_visible = num_page_entries; item_position = 0; - event_mask = GD_EVENT_MOVING | GD_EVENT_OFF_BORDERS; - #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) gd_bitmap_unpressed = *scrollbar_info[i].gfx_unpressed; gd_bitmap_pressed = *scrollbar_info[i].gfx_pressed; @@ -2910,10 +3136,10 @@ static void CreateScreenScrollbars() gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_CUSTOM_TYPE_ID, i, GDI_INFO_TEXT, scrollbar_info[i].infotext, - GDI_X, scrollbar_info[i].x, - GDI_Y, scrollbar_info[i].y, - GDI_WIDTH, scrollbar_info[i].width, - GDI_HEIGHT, scrollbar_info[i].height, + GDI_X, x, + GDI_Y, y, + GDI_WIDTH, width, + GDI_HEIGHT, height, GDI_TYPE, scrollbar_info[i].type, GDI_SCROLLBAR_ITEMS_MAX, items_max, GDI_SCROLLBAR_ITEMS_VISIBLE, items_visible, @@ -2922,6 +3148,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); @@ -2935,6 +3162,8 @@ static void CreateScreenScrollbars() void CreateScreenGadgets() { + int last_game_status = game_status; /* save current game status */ + #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) int i; @@ -2956,8 +3185,13 @@ void CreateScreenGadgets() } #endif + /* force LEVELS draw offset for scrollbar / scrollbutton gadgets */ + game_status = GAME_MODE_LEVELS; + CreateScreenScrollbuttons(); CreateScreenScrollbars(); + + game_status = last_game_status; /* restore current game status */ } void FreeScreenGadgets() @@ -2984,7 +3218,7 @@ void MapChooseTreeGadgets(TreeInfo *ti) int num_entries = numTreeInfoInGroup(ti); int i; - if (num_entries <= MAX_MENU_ENTRIES_ON_SCREEN) + if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN) return; for (i=0; icustom_id; - if (game_status != CHOOSELEVEL && game_status != SETUP) + if (game_status != GAME_MODE_LEVELS && game_status != GAME_MODE_SETUP) return; switch (id) { case SCREEN_CTRL_ID_SCROLL_UP: - if (game_status == CHOOSELEVEL) - HandleChooseLevel(SX,SY + 32, 0,0, MB_MENU_MARK); - else if (game_status == SETUP) - HandleSetupScreen(SX,SY + 32, 0,0, MB_MENU_MARK); + if (game_status == GAME_MODE_LEVELS) + HandleChooseLevel(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK); + else if (game_status == GAME_MODE_SETUP) + HandleSetupScreen(0,0, 0, -1 * SCROLL_LINE, MB_MENU_MARK); break; case SCREEN_CTRL_ID_SCROLL_DOWN: - if (game_status == CHOOSELEVEL) - HandleChooseLevel(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK); - else if (game_status == SETUP) - HandleSetupScreen(SX,SY + SYSIZE - 32, 0,0, MB_MENU_MARK); + if (game_status == GAME_MODE_LEVELS) + HandleChooseLevel(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK); + else if (game_status == GAME_MODE_SETUP) + HandleSetupScreen(0,0, 0, +1 * SCROLL_LINE, MB_MENU_MARK); break; case SCREEN_CTRL_ID_SCROLL_VERTICAL: - if (game_status == CHOOSELEVEL) + if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE); - else if (game_status == SETUP) + else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 999,gi->event.item_position,MB_MENU_INITIALIZE); break;