X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=7181f75029922116de9eb5cfa60d19b3f8b0404c;hb=530c3496077af2ddf295d252b4ad0c2ad15e1d21;hp=30214464c1bd46d791915af73b9c195f3fbd0481;hpb=6b748c845ff51daac061662d016447e122cf6fb3;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index 30214464..7181f750 100644 --- a/src/screens.c +++ b/src/screens.c @@ -235,6 +235,9 @@ static TreeInfo *drop_distance_current = NULL; static TreeInfo *level_number = NULL; static TreeInfo *level_number_current = NULL; +static unsigned int sync_frame_delay = 0; +static unsigned int sync_frame_delay_value = GAME_FRAME_DELAY; + static struct { int value; @@ -326,11 +329,12 @@ static struct char *text; } snapshot_modes_list[] = { - { STR_SNAPSHOT_MODE_OFF, "Off" }, - { STR_SNAPSHOT_MODE_EVERY_STEP, "Every Step" }, - { STR_SNAPSHOT_MODE_EVERY_MOVE, "Every Move" }, + { STR_SNAPSHOT_MODE_OFF, "Off" }, + { STR_SNAPSHOT_MODE_EVERY_STEP, "Every Step" }, + { STR_SNAPSHOT_MODE_EVERY_MOVE, "Every Move" }, + { STR_SNAPSHOT_MODE_EVERY_COLLECT, "Every Collect" }, - { NULL, NULL }, + { NULL, NULL }, }; static struct @@ -455,6 +459,7 @@ struct TitleControlInfo { boolean is_image; boolean initial; + boolean first; int local_nr; int sort_priority; }; @@ -803,44 +808,29 @@ static int getTitleMusic(struct TitleControlInfo *tci) static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci) { boolean is_image = tci->is_image; - int initial = tci->initial; + boolean initial = tci->initial; + boolean first = tci->first; int nr = tci->local_nr; + struct TitleMessageInfo tmi; struct TitleFadingInfo ti; - if (is_image) - { - int graphic = getTitleScreenGraphic(nr, initial); - - /* initialize fading control values to default title config settings */ - ti = (initial ? title_initial_default : title_default); - - /* override default settings with image config settings, if defined */ - if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT) - ti.fade_mode = graphic_info[graphic].fade_mode; - if (graphic_info[graphic].fade_delay > -1) - ti.fade_delay = graphic_info[graphic].fade_delay; - if (graphic_info[graphic].post_delay > -1) - ti.post_delay = graphic_info[graphic].post_delay; - if (graphic_info[graphic].auto_delay > -1) - ti.auto_delay = graphic_info[graphic].auto_delay; - } - else - { - if (initial) - { - ti.fade_mode = titlemessage_initial[nr].fade_mode; - ti.fade_delay = titlemessage_initial[nr].fade_delay; - ti.post_delay = titlemessage_initial[nr].post_delay; - ti.auto_delay = titlemessage_initial[nr].auto_delay; - } - else - { - ti.fade_mode = titlemessage[nr].fade_mode; - ti.fade_delay = titlemessage[nr].fade_delay; - ti.post_delay = titlemessage[nr].post_delay; - ti.auto_delay = titlemessage[nr].auto_delay; - } - } + tmi = (is_image ? (initial ? (first ? + titlescreen_initial_first[nr] : + titlescreen_initial[nr]) + : (first ? + titlescreen_first[nr] : + titlescreen[nr])) + : (initial ? (first ? + titlemessage_initial_first[nr] : + titlemessage_initial[nr]) + : (first ? + titlemessage_first[nr] : + titlemessage[nr]))); + + ti.fade_mode = tmi.fade_mode; + ti.fade_delay = tmi.fade_delay; + ti.post_delay = tmi.post_delay; + ti.auto_delay = tmi.auto_delay; return ti; } @@ -872,6 +862,8 @@ static void InitializeTitleControlsExt_AddTitleInfo(boolean is_image, title_controls[num_title_screens].local_nr = nr; title_controls[num_title_screens].sort_priority = sort_priority; + title_controls[num_title_screens].first = FALSE; /* will be set later */ + num_title_screens++; } @@ -914,6 +906,9 @@ static void InitializeTitleControls(boolean show_title_initial) /* sort title screens according to sort_priority and title number */ qsort(title_controls, num_title_screens, sizeof(struct TitleControlInfo), compareTitleControlInfo); + + /* mark first title screen */ + title_controls[0].first = TRUE; } static boolean visibleMenuPos(struct MenuPosInfo *pos) @@ -1242,7 +1237,7 @@ static void drawChooseTreeCursor(int ypos, boolean active) drawCursorExt(0, ypos, active, -1); - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ } void DrawHeadline() @@ -1306,7 +1301,7 @@ void DrawTitleScreenMessage(int nr, boolean initial) return; /* force TITLE font on title message screen */ - game_status = getTitleMessageGameMode(initial); + SetGameStatus(getTitleMessageGameMode(initial)); /* if chars *and* width set to "-1", automatically determine width */ if (tmi->chars == -1 && tmi->width == -1) @@ -1345,7 +1340,7 @@ void DrawTitleScreenMessage(int nr, boolean initial) filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1, tmi->autowrap, tmi->centered, tmi->parse_comments); - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ } void DrawTitleScreen() @@ -1399,7 +1394,8 @@ void DrawMainMenu() /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) { - game_status = GAME_MODE_EDITOR; + SetGameStatus(GAME_MODE_EDITOR); + DrawLevelEd(); return; @@ -1424,6 +1420,17 @@ void DrawMainMenu() /* needed if last screen (level choice) changed graphics, sounds or music */ ReloadCustomArtwork(0); + if (CheckTitleScreen(levelset_has_changed)) + { + game_status_last_screen = GAME_MODE_MAIN; + + SetGameStatus(GAME_MODE_TITLE); + + DrawTitleScreen(); + + return; + } + /* needed if different viewport properties defined for menues */ ChangeViewportPropertiesIfNeeded(); @@ -1440,16 +1447,6 @@ void DrawMainMenu() SetDrawtoField(DRAW_BACKBUFFER); - if (CheckTitleScreen(levelset_has_changed)) - { - game_status_last_screen = GAME_MODE_MAIN; - game_status = GAME_MODE_TITLE; - - DrawTitleScreen(); - - return; - } - /* 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; @@ -1552,9 +1549,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) static int last_sound = -1, last_music = -1; boolean return_to_main_menu = FALSE; struct TitleControlInfo *tci; - struct TitleFadingInfo fading_default; - struct TitleFadingInfo fading_last = fading; - struct TitleFadingInfo fading_next; int sound, music; if (button == MB_MENU_INITIALIZE) @@ -1566,10 +1560,21 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_sound = SND_UNDEFINED; last_music = MUS_UNDEFINED; + if (num_title_screens != 0) + { + FadeSetEnterScreen(); + + /* use individual title fading instead of global "enter screen" fading */ + fading = getTitleFading(tci); + } + if (game_status_last_screen == GAME_MODE_INFO) { if (num_title_screens == 0) { + /* switch game mode from title screen mode back to info screen mode */ + SetGameStatus(GAME_MODE_INFO); + DrawInfoScreen_NotAvailable("Title screen information:", "No title screen for this level set."); @@ -1579,11 +1584,12 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeSoundsAndMusic(); FadeOut(REDRAW_ALL); - - /* only required to update logic for redrawing global border */ - ClearField(); } + /* only required to update logic for redrawing global border */ + ClearField(); + + /* title screens may have different window size */ ChangeViewportPropertiesIfNeeded(); if (tci->is_image) @@ -1591,17 +1597,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); - fading_default = (tci->initial ? title_initial_default : title_default); - - fading = fading_next = getTitleFading(tci); - - if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) && - fading_next.fade_mode & FADE_TYPE_TRANSFORM) - { - fading.fade_mode = FADE_MODE_FADE; - fading.fade_delay = fading_default.fade_delay; - } - sound = getTitleSound(tci); music = getTitleMusic(tci); @@ -1617,8 +1612,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeIn(REDRAW_ALL); - fading = fading_next; - DelayReached(&title_delay, 0); /* reset delay counter */ return; @@ -1635,9 +1628,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0) { - FadeSetEnterScreen(); + SetGameStatus(GAME_MODE_INFO); - game_status = GAME_MODE_INFO; info_mode = INFO_MODE_MAIN; DrawInfoScreen(); @@ -1658,6 +1650,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (music == MUS_UNDEFINED || music != last_music) FadeMusic(); + fading = getTitleFading(tci); + FadeOut(REDRAW_ALL); if (tci->is_image) @@ -1665,8 +1659,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); - fading_next = getTitleFading(tci); - sound = getTitleSound(tci); music = getTitleMusic(tci); @@ -1678,15 +1670,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_sound = sound; last_music = music; - /* last screen already faded out, next screen has no animation */ - if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) && - fading_next.fade_mode == FADE_MODE_NONE) - fading = fading_next; - FadeIn(REDRAW_ALL); - fading = fading_next; - DelayReached(&title_delay, 0); /* reset delay counter */ } else @@ -1706,14 +1691,15 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (game_status_last_screen == GAME_MODE_INFO) { - game_status = GAME_MODE_INFO; + SetGameStatus(GAME_MODE_INFO); + info_mode = INFO_MODE_MAIN; DrawInfoScreen(); } else /* default: return to main menu */ { - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -1848,7 +1834,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_LEVELNR; + SetGameStatus(GAME_MODE_LEVELNR); ChangeViewportPropertiesIfNeeded(); @@ -1874,7 +1860,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (pos == MAIN_CONTROL_NAME) { - game_status = GAME_MODE_PSEUDO_TYPENAME; + SetGameStatus(GAME_MODE_PSEUDO_TYPENAME); HandleTypeName(strlen(setup.player_name), 0); } @@ -1886,7 +1872,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_LEVELS; + SetGameStatus(GAME_MODE_LEVELS); SaveLevelSetup_LastSeries(); SaveLevelSetup_SeriesInfo(); @@ -1905,7 +1891,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_SCORES; + SetGameStatus(GAME_MODE_SCORES); DrawHallOfFame(-1); } @@ -1919,7 +1905,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_EDITOR; + SetGameStatus(GAME_MODE_EDITOR); FadeSetEnterScreen(); @@ -1931,7 +1917,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_INFO; + SetGameStatus(GAME_MODE_INFO); + info_mode = INFO_MODE_MAIN; ChangeViewportPropertiesIfNeeded(); @@ -1950,7 +1937,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) CloseDoor(DOOR_CLOSE_2); - game_status = GAME_MODE_SETUP; + SetGameStatus(GAME_MODE_SETUP); + setup_mode = SETUP_MODE_MAIN; ChangeViewportPropertiesIfNeeded(); @@ -1963,7 +1951,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SaveLevelSetup_SeriesInfo(); if (Request("Do you really want to quit?", REQ_ASK | REQ_STAY_CLOSED)) - game_status = GAME_MODE_QUIT; + SetGameStatus(GAME_MODE_QUIT); } } } @@ -2031,7 +2019,7 @@ static void execInfoLevelSet() static void execExitInfo() { - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -2203,6 +2191,11 @@ static void DrawInfoScreen_Main() PlayMenuSound(); PlayMenuMusic(); +#if 1 + // needed after returning from title screens with different window size + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); +#endif + DrawMaskedBorder(fade_mask); FadeIn(fade_mask); @@ -2682,7 +2675,8 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos) void DrawInfoScreen_TitleScreen() { game_status_last_screen = GAME_MODE_INFO; - game_status = GAME_MODE_TITLE; + + SetGameStatus(GAME_MODE_TITLE); DrawTitleScreen(); } @@ -3615,7 +3609,7 @@ void HandleTypeName(int newxpos, Key key) is_active = FALSE; - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); } else if (key == KSYM_Escape) { @@ -3623,7 +3617,7 @@ void HandleTypeName(int newxpos, Key key) is_active = FALSE; - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); } if (is_active) @@ -3661,7 +3655,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr) if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY)) { - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); @@ -3740,7 +3734,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, initCursor(i, IMG_MENU_BUTTON); } - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ redraw_mask |= REDRAW_FIELD; } @@ -3797,7 +3791,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, else num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN; - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ if (button == MB_MENU_INITIALIZE) { @@ -3872,7 +3866,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, HandleMainMenu_SelectLevel(0, 0, new_level_nr); } - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -3887,7 +3881,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, x = (mx - mSX) / 32; y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS; - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ } else if (dx || dy) /* keyboard or scrollbar/scrollbutton input */ { @@ -4070,7 +4064,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, HandleMainMenu_SelectLevel(0, 0, new_level_nr); } - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -4286,7 +4280,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) FadeSound(SND_BACKGROUND_SCORES); - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -4296,7 +4290,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) FadeSound(SND_BACKGROUND_SCORES); - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -5286,7 +5280,7 @@ static void execSetupShortcuts5() static void execExitSetup() { - game_status = GAME_MODE_MAIN; + SetGameStatus(GAME_MODE_MAIN); DrawMainMenu(); } @@ -5396,7 +5390,7 @@ static struct TokenInfo setup_info_graphics[] = { TYPE_SWITCH, &setup.quick_switch, "Quick Player Focus Switch:" }, { TYPE_SWITCH, &setup.quick_doors, "Quick Menu Doors:" }, { TYPE_SWITCH, &setup.show_titlescreen,"Show Title Screens:" }, - { TYPE_SWITCH, &setup.toons, "Show Toons:" }, + { TYPE_SWITCH, &setup.toons, "Show Menu Animations:" }, { TYPE_ECS_AGA, &setup.prefer_aga_graphics,"EMC graphics preference:" }, { TYPE_SWITCH, &setup.sp_show_border_elements,"Supaplex Border Elements:" }, { TYPE_SWITCH, &setup.small_game_graphics, "Small Game Graphics:" }, @@ -5615,8 +5609,7 @@ static Key getSetupKey() DoAnimation(); BackToFront(); - /* don't eat all CPU time */ - Delay(10); + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); } return key; @@ -6303,8 +6296,7 @@ void CustomizeKeyboard(int player_nr) DoAnimation(); BackToFront(); - /* don't eat all CPU time */ - Delay(10); + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); } /* write new key bindings back to player setup */ @@ -6459,8 +6451,7 @@ static boolean CalibrateJoystickMain(int player_nr) DoAnimation(); BackToFront(); - /* don't eat all CPU time */ - Delay(10); + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); } /* calibrated center position (joystick should now be centered) */ @@ -6482,7 +6473,7 @@ static boolean CalibrateJoystickMain(int player_nr) NextEvent(&event); HandleOtherEvents(&event); - Delay(10); + WaitUntilDelayReached(&sync_frame_delay, sync_frame_delay_value); } } @@ -6940,7 +6931,7 @@ void CreateScreenGadgets() CreateScreenScrollbuttons(); CreateScreenScrollbars(); - game_status = last_game_status; /* restore current game status */ + SetGameStatus(last_game_status); /* restore current game status */ } void FreeScreenGadgets()