X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fscreens.c;h=e68ec1a8d37efb07cee16488cc4a1c64f5a1a93f;hp=6ee974e01917746dfe3407a7e7e9d49ae11ea5d4;hb=7ecbe0a730dc19d8a46ffe6bbcb052f20d0c4152;hpb=7144673ff1fabd59d009c1c2a9aa8950942c86b7 diff --git a/src/screens.c b/src/screens.c index 6ee974e0..e68ec1a8 100644 --- a/src/screens.c +++ b/src/screens.c @@ -174,10 +174,8 @@ static void HandleChooseTree(int, int, int, int, int, TreeInfo **); static void DrawChooseLevelSet(void); static void DrawChooseLevelNr(void); static void DrawInfoScreen(void); -static void DrawAndFadeInInfoScreen(int); static void DrawSetupScreen(void); -static void DrawInfoScreenExt(int, int); static void DrawInfoScreen_NotAvailable(char *, char *); static void DrawInfoScreen_HelpAnim(int, int, boolean); static void DrawInfoScreen_HelpText(int, int, int, int); @@ -1254,14 +1252,6 @@ void DrawHeadline() setup.internal.program_copyright); } -int effectiveGameStatus() -{ - if (game_status == GAME_MODE_INFO && info_mode == INFO_MODE_TITLE) - return GAME_MODE_TITLE; - - return game_status; -} - void DrawTitleScreenImage(int nr, boolean initial) { int graphic = getTitleScreenGraphic(nr, initial); @@ -1368,10 +1358,11 @@ boolean CheckTitleScreen(boolean levelset_has_changed) return (show_titlescreen && num_title_screens > 0); } -void DrawMainMenuExt(int fade_mask, boolean do_fading) +void DrawMainMenu() { static LevelDirTree *leveldir_last_valid = NULL; boolean levelset_has_changed = FALSE; + int fade_mask = REDRAW_FIELD; LimitScreenUpdates(FALSE); @@ -1417,13 +1408,16 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) /* needed if last screen (level choice) changed graphics, sounds or music */ ReloadCustomArtwork(0); + /* needed if different viewport properties defined for menues */ + ChangeViewportPropertiesIfNeeded(); + if (redraw_mask & REDRAW_ALL) fade_mask = REDRAW_ALL; - FadeOut(fade_mask); + if (CheckIfGlobalBorderHasChanged()) + fade_mask = REDRAW_ALL; - /* needed if different viewport properties defined for menues */ - ChangeViewportPropertiesIfNeeded(); + FadeOut(fade_mask); /* needed if last screen was the editor screen */ UndrawSpecialEditorDoor(); @@ -1432,6 +1426,7 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) if (CheckTitleScreen(levelset_has_changed)) { + game_status_last_screen = GAME_MODE_MAIN; game_status = GAME_MODE_TITLE; DrawTitleScreen(); @@ -1452,8 +1447,10 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) SetMainBackgroundImage(IMG_BACKGROUND_MAIN); +#if 0 if (fade_mask == REDRAW_ALL) RedrawGlobalBorder(); +#endif ClearField(); @@ -1481,11 +1478,12 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) MapScreenMenuGadgets(SCREEN_MASK_MAIN); /* copy actual game door content to door double buffer for OpenDoor() */ + BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0); BlitBitmap(drawto, bitmap_db_door_2, VX, VY, VXSIZE, VYSIZE, 0, 0); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - DrawMaskedBorder(REDRAW_ALL); + DrawMaskedBorder(fade_mask); FadeIn(fade_mask); FadeSetEnterMenu(); @@ -1501,16 +1499,6 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2); } -void DrawAndFadeInMainMenu(int fade_mask) -{ - DrawMainMenuExt(fade_mask, TRUE); -} - -void DrawMainMenu() -{ - DrawMainMenuExt(REDRAW_ALL, FALSE); -} - static void gotoTopLevelDir() { /* move upwards until inside (but not above) top level directory */ @@ -1547,7 +1535,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) static int title_screen_nr = 0; static int last_sound = -1, last_music = -1; boolean return_to_main_menu = FALSE; - boolean use_fading_main_menu = TRUE; struct TitleControlInfo *tci; struct TitleFadingInfo fading_default; struct TitleFadingInfo fading_last = fading; @@ -1563,7 +1550,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_sound = SND_UNDEFINED; last_music = MUS_UNDEFINED; - if (game_status == GAME_MODE_INFO) + if (game_status_last_screen == GAME_MODE_INFO) { if (num_title_screens == 0) { @@ -1576,8 +1563,13 @@ 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(); } + ChangeViewportPropertiesIfNeeded(); + if (tci->is_image) DrawTitleScreenImage(tci->local_nr, tci->initial); else @@ -1622,16 +1614,17 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (button == MB_MENU_LEAVE) { return_to_main_menu = TRUE; - use_fading_main_menu = FALSE; } else if (button == MB_MENU_CHOICE) { - if (game_status == GAME_MODE_INFO && num_title_screens == 0) + if (game_status_last_screen == GAME_MODE_INFO && num_title_screens == 0) { FadeSetEnterScreen(); + game_status = GAME_MODE_INFO; info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + + DrawInfoScreen(); return; } @@ -1692,19 +1685,21 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { SetMouseCursor(CURSOR_DEFAULT); - if (game_status == GAME_MODE_INFO) - { - int fade_mask = (num_title_screens == 0 ? REDRAW_FIELD : REDRAW_ALL); + /* force full menu screen redraw after displaying title screens */ + redraw_mask = REDRAW_ALL; + if (game_status_last_screen == GAME_MODE_INFO) + { + game_status = GAME_MODE_INFO; info_mode = INFO_MODE_MAIN; - DrawInfoScreenExt(fade_mask, use_fading_main_menu); + DrawInfoScreen(); } else /* default: return to main menu */ { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu); + DrawMainMenu(); } } } @@ -1833,6 +1828,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_LEVEL_NUMBER && !button) { + StopAnimation(); + + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_LEVELNR; ChangeViewportPropertiesIfNeeded(); @@ -1867,6 +1866,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { if (leveldir_first) { + StopAnimation(); + + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_LEVELS; SaveLevelSetup_LastSeries(); @@ -1882,9 +1885,11 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_SCORES) { - game_status = GAME_MODE_SCORES; + StopAnimation(); - ChangeViewportPropertiesIfNeeded(); + CloseDoor(DOOR_CLOSE_2); + + game_status = GAME_MODE_SCORES; DrawHallOfFame(-1); } @@ -1894,6 +1899,8 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) !strEqual(setup.player_name, "Artsoft")) Request("This level is read only!", REQ_CONFIRM); + StopAnimation(); + CloseDoor(DOOR_CLOSE_2); game_status = GAME_MODE_EDITOR; @@ -1904,6 +1911,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_INFO) { + StopAnimation(); + + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_INFO; info_mode = INFO_MODE_MAIN; @@ -1913,10 +1924,16 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_GAME) { + StopAnimation(); + StartGameActions(options.network, setup.autorecord, level.random_seed); } else if (pos == MAIN_CONTROL_SETUP) { + StopAnimation(); + + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_SETUP; setup_mode = SETUP_MODE_MAIN; @@ -2000,7 +2017,7 @@ static void execExitInfo() { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); } static struct TokenInfo info_info_main[] = @@ -2118,10 +2135,17 @@ static void drawMenuInfoList(int first_entry, int num_page_entries, } } -static void DrawInfoScreen_Main(int fade_mask, boolean do_fading) +static void DrawInfoScreen_Main() { + int fade_mask = REDRAW_FIELD; int i; + if (redraw_mask & REDRAW_ALL) + fade_mask = REDRAW_ALL; + + if (CheckIfGlobalBorderHasChanged()) + fade_mask = REDRAW_ALL; + UnmapAllGadgets(); FreeScreenGadgets(); @@ -2136,12 +2160,9 @@ static void DrawInfoScreen_Main(int fade_mask, boolean do_fading) FadeOut(fade_mask); - if (fade_mask == REDRAW_ALL) - { - RedrawGlobalBorder(); + ChangeViewportPropertiesIfNeeded(); - OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - } + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); ClearField(); @@ -2178,10 +2199,10 @@ static void changeSetupValue(int, int, int); void HandleMenuScreen(int mx, int my, int dx, int dy, int button, int mode, int num_page_entries, int max_page_entries) { - static int game_status_last; - static int num_page_entries_last[NUM_SPECIAL_GFX_ARGS]; + static int num_page_entries_all_last[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES]; static int choice_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES]; static int first_entry_stores[NUM_SPECIAL_GFX_ARGS][MAX_MENU_MODES]; + int *num_page_entries_last = num_page_entries_all_last[game_status]; int *choice_store = choice_stores[game_status]; int *first_entry_store = first_entry_stores[game_status]; int choice = choice_store[mode]; /* starts with 0 */ @@ -2198,18 +2219,15 @@ void HandleMenuScreen(int mx, int my, int dx, int dy, int button, // check if number of menu page entries has changed (may happen by change // of custom artwork definition value for 'list_size' for this menu screen) // (in this case, the last menu position most probably has to be corrected) - if (game_status != game_status_last && - num_page_entries != num_page_entries_last[game_status]) + if (num_page_entries != num_page_entries_last[mode]) { - for (i = 0; i < MAX_MENU_MODES; i++) - choice_store[i] = first_entry_store[i] = 0; + choice_store[mode] = first_entry_store[mode] = 0; choice = first_entry = 0; y = y_old = 0; - } - game_status_last = game_status; - num_page_entries_last[game_status] = num_page_entries; + num_page_entries_last[mode] = num_page_entries; + } /* advance to first valid menu entry */ while (choice < num_page_entries && @@ -2647,6 +2665,9 @@ 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; + DrawTitleScreen(); } @@ -2724,7 +2745,7 @@ void HandleInfoScreen_Elements(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -2823,7 +2844,7 @@ void HandleInfoScreen_Music(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -3127,7 +3148,7 @@ void HandleInfoScreen_Credits(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -3206,7 +3227,7 @@ void HandleInfoScreen_Program(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3381,7 +3402,7 @@ void HandleInfoScreen_Version(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3469,7 +3490,7 @@ void HandleInfoScreen_LevelSet(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3477,7 +3498,7 @@ void HandleInfoScreen_LevelSet(int button) } } -static void DrawInfoScreenExt(int fade_mask, boolean do_fading) +static void DrawInfoScreen() { SetMainBackgroundImage(IMG_BACKGROUND_INFO); @@ -3496,7 +3517,7 @@ static void DrawInfoScreenExt(int fade_mask, boolean do_fading) else if (info_mode == INFO_MODE_LEVELSET) DrawInfoScreen_LevelSet(); else - DrawInfoScreen_Main(fade_mask, do_fading); + DrawInfoScreen_Main(); if (info_mode != INFO_MODE_MAIN && info_mode != INFO_MODE_TITLE && @@ -3507,16 +3528,6 @@ static void DrawInfoScreenExt(int fade_mask, boolean do_fading) } } -void DrawAndFadeInInfoScreen(int fade_mask) -{ - DrawInfoScreenExt(fade_mask, TRUE); -} - -void DrawInfoScreen() -{ - DrawInfoScreenExt(REDRAW_FIELD, FALSE); -} - void HandleInfoScreen(int mx, int my, int dx, int dy, int button) { if (info_mode == INFO_MODE_TITLE) @@ -3627,13 +3638,16 @@ void HandleTypeName(int newxpos, Key key) static void DrawChooseTree(TreeInfo **ti_ptr) { - int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); + int fade_mask = REDRAW_FIELD; + + if (CheckIfGlobalBorderHasChanged()) + fade_mask = REDRAW_ALL; if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY)) { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); return; } @@ -3647,11 +3661,15 @@ static void DrawChooseTree(TreeInfo **ti_ptr) FadeOut(fade_mask); + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + ClearField(); HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr); MapScreenTreeGadgets(*ti_ptr); + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); InitAnimation(); @@ -3840,7 +3858,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); } return; @@ -4123,7 +4141,16 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button) void DrawHallOfFame(int highlight_position) { - int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); + int fade_mask = REDRAW_FIELD; + + /* required before door position may be changed in next step */ + CloseDoor(DOOR_CLOSE_ALL); + + /* needed if different viewport properties defined for scores */ + ChangeViewportPropertiesIfNeeded(); + + if (CheckIfGlobalBorderHasChanged()) + fade_mask = REDRAW_ALL; UnmapAllGadgets(); FadeSoundsAndMusic(); @@ -4136,8 +4163,6 @@ void DrawHallOfFame(int highlight_position) SetDrawDeactivationMask(REDRAW_NONE); SetDrawBackgroundMask(REDRAW_FIELD); - CloseDoor(DOOR_CLOSE_ALL); - if (highlight_position < 0) LoadScore(level_nr); @@ -4150,8 +4175,12 @@ void DrawHallOfFame(int highlight_position) PlayMenuSound(); PlayMenuMusic(); + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE); + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); } @@ -4253,7 +4282,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); } if (game_status == GAME_MODE_SCORES) @@ -5243,7 +5272,7 @@ static void execExitSetup() { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); } static void execSaveAndExitSetup() @@ -5289,6 +5318,7 @@ static struct TokenInfo setup_info_game[] = #endif { TYPE_ENTER_LIST, execSetupChooseSnapshotMode,"Game Engine Snapshot Mode:" }, { TYPE_STRING, &snapshot_mode_text, "" }, + { TYPE_SWITCH, &setup.show_snapshot_buttons,"Show Snapshot Buttons:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, @@ -5728,11 +5758,14 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) static void DrawSetupScreen_Generic() { - int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD); + int fade_mask = REDRAW_FIELD; boolean redraw_all = FALSE; char *title_string = NULL; int i; + if (CheckIfGlobalBorderHasChanged()) + fade_mask = REDRAW_ALL; + UnmapAllGadgets(); FreeScreenGadgets(); @@ -5745,6 +5778,8 @@ static void DrawSetupScreen_Generic() FadeOut(fade_mask); + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + ClearField(); if (setup_mode == SETUP_MODE_MAIN) @@ -5832,6 +5867,8 @@ static void DrawSetupScreen_Generic() if (redraw_all) redraw_mask = fade_mask = REDRAW_ALL; + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); InitAnimation();