From: Holger Schemel Date: Tue, 9 Jun 2015 22:01:16 +0000 (+0200) Subject: cleanup of screen fading code X-Git-Tag: 4.0.0.0-rc1~177 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f89a490028c36509216b97a96b779b779c2065c9;p=rocksndiamonds.git cleanup of screen fading code --- diff --git a/src/editor.c b/src/editor.c index 6414dbd4..9f8182d6 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7612,8 +7612,6 @@ void InitZoomLevelSettings() MAX_ED_FIELDY = getMaxEdFieldY(FALSE); } -static boolean playfield_area_changed = FALSE; - void DrawLevelEd() { int fade_mask = REDRAW_FIELD; @@ -7652,8 +7650,6 @@ void DrawLevelEd() InitZoomLevelSettings(); - playfield_area_changed = DrawingAreaChanged(); - OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY); #if DEBUG @@ -7712,11 +7708,6 @@ void DrawLevelEd() DrawEditModeWindow(); - fade_mask = (playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD); - - if (CheckIfRedrawGlobalBorderIsNeeded()) - fade_mask = REDRAW_ALL; - FadeIn(fade_mask); /* copy actual editor door content to door double buffer for OpenDoor() */ @@ -12291,7 +12282,7 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(playfield_area_changed ? REDRAW_ALL : REDRAW_FIELD); + DrawMainMenu(); } else { diff --git a/src/game.c b/src/game.c index 1f0270d9..73505d24 100644 --- a/src/game.c +++ b/src/game.c @@ -4424,7 +4424,7 @@ void GameEnd() { game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); return; } @@ -4435,7 +4435,7 @@ void GameEnd() game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); return; } @@ -4454,9 +4454,6 @@ void GameEnd() { game_status = GAME_MODE_SCORES; - /* needed if different viewport properties defined for scores */ - ChangeViewportPropertiesIfNeeded(); - DrawHallOfFame(hi_pos); if (raise_level) @@ -4477,7 +4474,7 @@ void GameEnd() TapeErase(); } - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); } } @@ -14489,13 +14486,13 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); } else { game_status = GAME_MODE_MAIN; - DrawAndFadeInMainMenu(REDRAW_FIELD); + DrawMainMenu(); } } } diff --git a/src/libgame/system.c b/src/libgame/system.c index 3bd825fd..2efe6dd9 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -171,8 +171,6 @@ void InitGfxFieldInfo(int sx, int sy, int sxsize, int sysize, gfx.field_save_buffer = field_save_buffer; - gfx.drawing_area_changed = FALSE; - SetDrawDeactivationMask(REDRAW_NONE); /* do not deactivate drawing */ SetDrawBackgroundMask(REDRAW_NONE); /* deactivate masked drawing */ } @@ -501,16 +499,6 @@ boolean DrawingOnBackground(int x, int y) CheckDrawingArea(x, y, 1, 1, gfx.draw_background_mask)); } -boolean DrawingAreaChanged() -{ - int drawing_area_changed = gfx.drawing_area_changed; - - // reset flag for change of drawing area after querying it - gfx.drawing_area_changed = FALSE; - - return drawing_area_changed; -} - static boolean InClippedRectangle(Bitmap *bitmap, int *x, int *y, int *width, int *height, boolean is_dest) { diff --git a/src/libgame/system.h b/src/libgame/system.h index df223fe7..6eca6f9b 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -786,8 +786,6 @@ struct GfxInfo int draw_deactivation_mask; int draw_background_mask; - boolean drawing_area_changed; - Bitmap *field_save_buffer; Bitmap *background_bitmap; diff --git a/src/screens.c b/src/screens.c index 99dedcef..83e508ea 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); @@ -1368,10 +1366,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); @@ -1440,9 +1439,6 @@ void DrawMainMenuExt(int fade_mask, boolean do_fading) SetDrawtoField(DRAW_BACKBUFFER); - /* reset drawing area change flag */ - DrawingAreaChanged(); - if (CheckTitleScreen(levelset_has_changed)) { game_status = GAME_MODE_TITLE; @@ -1521,16 +1517,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 */ @@ -1567,7 +1553,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; @@ -1642,7 +1627,6 @@ 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) { @@ -1651,7 +1635,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeSetEnterScreen(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -1712,19 +1696,20 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) { SetMouseCursor(CURSOR_DEFAULT); + /* force full menu screen redraw after displaying title screens */ + redraw_mask = REDRAW_ALL; + if (game_status == GAME_MODE_INFO) { - int fade_mask = (num_title_screens == 0 ? REDRAW_FIELD : REDRAW_ALL); - 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(); } } } @@ -1904,13 +1889,6 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) { game_status = GAME_MODE_SCORES; -#if 1 - /* required before door position may be changed in next step */ - CloseDoor(DOOR_CLOSE_ALL); -#endif - - ChangeViewportPropertiesIfNeeded(); - DrawHallOfFame(-1); } else if (pos == MAIN_CONTROL_EDITOR) @@ -2025,7 +2003,7 @@ static void execExitInfo() { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); } static struct TokenInfo info_info_main[] = @@ -2143,10 +2121,14 @@ 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 (CheckIfRedrawGlobalBorderIsNeeded()) fade_mask = REDRAW_ALL; @@ -2749,7 +2731,7 @@ void HandleInfoScreen_Elements(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -2848,7 +2830,7 @@ void HandleInfoScreen_Music(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -3152,7 +3134,7 @@ void HandleInfoScreen_Credits(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); return; } @@ -3231,7 +3213,7 @@ void HandleInfoScreen_Program(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3406,7 +3388,7 @@ void HandleInfoScreen_Version(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3494,7 +3476,7 @@ void HandleInfoScreen_LevelSet(int button) FadeSoundsAndMusic(); info_mode = INFO_MODE_MAIN; - DrawAndFadeInInfoScreen(REDRAW_FIELD); + DrawInfoScreen(); } else { @@ -3502,7 +3484,7 @@ void HandleInfoScreen_LevelSet(int button) } } -static void DrawInfoScreenExt(int fade_mask, boolean do_fading) +static void DrawInfoScreen() { SetMainBackgroundImage(IMG_BACKGROUND_INFO); @@ -3521,7 +3503,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 && @@ -3532,16 +3514,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) @@ -3652,13 +3624,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 (CheckIfRedrawGlobalBorderIsNeeded()) + fade_mask = REDRAW_ALL; if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY)) { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); return; } @@ -3865,7 +3840,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; @@ -4148,7 +4123,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 (CheckIfRedrawGlobalBorderIsNeeded()) + fade_mask = REDRAW_ALL; UnmapAllGadgets(); FadeSoundsAndMusic(); @@ -4161,8 +4145,6 @@ void DrawHallOfFame(int highlight_position) SetDrawDeactivationMask(REDRAW_NONE); SetDrawBackgroundMask(REDRAW_FIELD); - CloseDoor(DOOR_CLOSE_ALL); - if (highlight_position < 0) LoadScore(level_nr); @@ -4278,7 +4260,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) @@ -5268,7 +5250,7 @@ static void execExitSetup() { game_status = GAME_MODE_MAIN; - DrawMainMenuExt(REDRAW_FIELD, FALSE); + DrawMainMenu(); } static void execSaveAndExitSetup() @@ -5754,7 +5736,7 @@ 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; diff --git a/src/screens.h b/src/screens.h index c23c14e8..2ee562e6 100644 --- a/src/screens.h +++ b/src/screens.h @@ -21,7 +21,7 @@ int effectiveGameStatus(); -void DrawMainMenuExt(int, boolean); +void DrawMainMenuExt(int); void DrawAndFadeInMainMenu(int); void DrawMainMenu(void); void DrawHallOfFame(int); diff --git a/src/tools.c b/src/tools.c index a7867f87..da879fa6 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8085,7 +8085,6 @@ void ChangeViewportPropertiesIfNeeded() boolean init_video_buffer = FALSE; boolean init_gadgets_and_toons = FALSE; boolean init_em_graphics = FALSE; - boolean drawing_area_changed = FALSE; if (viewport.window.width != WIN_XSIZE || viewport.window.height != WIN_YSIZE) @@ -8144,19 +8143,6 @@ void ChangeViewportPropertiesIfNeeded() init_em_graphics = TRUE; } - if (new_sx != SX || - new_sy != SY || - new_sxsize != SXSIZE || - new_sysize != SYSIZE || - new_real_sx != REAL_SX || - new_real_sy != REAL_SY || - new_full_sxsize != FULL_SXSIZE || - new_full_sysize != FULL_SYSIZE) - { - if (!init_video_buffer) - drawing_area_changed = TRUE; - } - SX = new_sx; SY = new_sy; DX = new_dx; @@ -8198,8 +8184,6 @@ void ChangeViewportPropertiesIfNeeded() SCR_FIELDX = new_scr_fieldx; SCR_FIELDY = new_scr_fieldy; - gfx.drawing_area_changed = drawing_area_changed; - SetDrawDeactivationMask(REDRAW_NONE); SetDrawBackgroundMask(REDRAW_FIELD); }