From: Holger Schemel Date: Thu, 25 Jun 2015 18:47:43 +0000 (+0200) Subject: fixed a lot of bugs when using custom global borders with masked viewports X-Git-Tag: 4.0.0.0-rc1~166 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=38b4bf3fec7d93aa252f57270246b3e4ff41cf8d;p=rocksndiamonds.git fixed a lot of bugs when using custom global borders with masked viewports --- diff --git a/src/editor.c b/src/editor.c index c7e23051..6509cbbe 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7616,8 +7616,6 @@ void DrawLevelEd() { int fade_mask = REDRAW_FIELD; - StopAnimation(); - CloseDoor(DOOR_CLOSE_ALL); /* needed if different viewport properties defined for editor */ @@ -7690,6 +7688,8 @@ void DrawLevelEd() DrawEditModeWindow(); + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); /* copy actual editor door content to door double buffer for OpenDoor() */ diff --git a/src/game.c b/src/game.c index 8273cb71..e895519f 100644 --- a/src/game.c +++ b/src/game.c @@ -3091,9 +3091,10 @@ void InitGame() int initial_move_dir = MV_DOWN; int i, j, x, y; - game_status = GAME_MODE_PLAYING; + // required here to update video display before fading (FIX THIS) + DrawMaskedBorder(REDRAW_DOOR_2); - StopAnimation(); + game_status = GAME_MODE_PLAYING; if (!game.restart_level) CloseDoor(DOOR_CLOSE_1); @@ -3925,6 +3926,8 @@ void InitGame() BlitScreenToBitmap(backbuffer); /* !!! FIX THIS (END) !!! */ + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); #if 1 diff --git a/src/screens.c b/src/screens.c index 1f01c599..4f7d783a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1490,7 +1490,7 @@ void DrawMainMenu() OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - DrawMaskedBorder(REDRAW_ALL); + DrawMaskedBorder(fade_mask); FadeIn(fade_mask); FadeSetEnterMenu(); @@ -1827,6 +1827,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(); @@ -1861,6 +1865,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(); @@ -1876,6 +1884,10 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) } else if (pos == MAIN_CONTROL_SCORES) { + StopAnimation(); + + CloseDoor(DOOR_CLOSE_2); + game_status = GAME_MODE_SCORES; DrawHallOfFame(-1); @@ -1886,6 +1898,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; @@ -1896,6 +1910,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; @@ -1905,10 +1923,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; @@ -3641,6 +3665,8 @@ static void DrawChooseTree(TreeInfo **ti_ptr) HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr); MapScreenTreeGadgets(*ti_ptr); + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); InitAnimation(); @@ -4148,6 +4174,8 @@ void DrawHallOfFame(int highlight_position) HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE); + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); } @@ -5832,6 +5860,8 @@ static void DrawSetupScreen_Generic() if (redraw_all) redraw_mask = fade_mask = REDRAW_ALL; + DrawMaskedBorder(fade_mask); + FadeIn(fade_mask); InitAnimation(); diff --git a/src/tools.c b/src/tools.c index 5b830772..be29c200 100644 --- a/src/tools.c +++ b/src/tools.c @@ -286,7 +286,7 @@ void RedrawPlayfield() void DrawMaskedBorder_Rect(int x, int y, int width, int height) { - Bitmap *bitmap = graphic_info[IMG_GLOBAL_BORDER].bitmap; + Bitmap *bitmap = getGlobalBorderBitmapFromGameStatus(); BlitBitmapMasked(bitmap, backbuffer, x, y, width, height, x, y); } @@ -709,11 +709,13 @@ Bitmap *getGlobalBorderBitmap(int graphic) Bitmap *getGlobalBorderBitmapFromGameStatus() { - int graphic = (game_status == GAME_MODE_MAIN ? IMG_GLOBAL_BORDER_MAIN : - game_status == GAME_MODE_SCORES ? IMG_GLOBAL_BORDER_SCORES : - game_status == GAME_MODE_EDITOR ? IMG_GLOBAL_BORDER_EDITOR : - game_status == GAME_MODE_PLAYING ? IMG_GLOBAL_BORDER_PLAYING : - IMG_GLOBAL_BORDER); + int graphic = + (game_status == GAME_MODE_MAIN || + game_status == GAME_MODE_PSEUDO_TYPENAME ? IMG_GLOBAL_BORDER_MAIN : + game_status == GAME_MODE_SCORES ? IMG_GLOBAL_BORDER_SCORES : + game_status == GAME_MODE_EDITOR ? IMG_GLOBAL_BORDER_EDITOR : + game_status == GAME_MODE_PLAYING ? IMG_GLOBAL_BORDER_PLAYING : + IMG_GLOBAL_BORDER); return getGlobalBorderBitmap(graphic); } @@ -3401,7 +3403,6 @@ static int RequestHandleEvents(unsigned int req_state) { boolean level_solved = (game_status == GAME_MODE_PLAYING && local_player->LevelSolved_GameEnd); - int last_game_status = game_status; /* save current game status */ int width = request.width; int height = request.height; int sx, sy; @@ -3566,11 +3567,7 @@ static int RequestHandleEvents(unsigned int req_state) Delay(10); } - game_status = GAME_MODE_PSEUDO_DOOR; - BackToFront(); - - game_status = last_game_status; /* restore current game status */ } return result; diff --git a/src/tools.h b/src/tools.h index 8c8f0184..b7e7de9b 100644 --- a/src/tools.h +++ b/src/tools.h @@ -95,6 +95,8 @@ void FadeSetDisabled(); void FadeSkipNextFadeIn(); void FadeSkipNextFadeOut(); +Bitmap *getGlobalBorderBitmapFromGameStatus(); + void ClearField(); void SetWindowBackgroundImageIfDefined(int); void SetMainBackgroundImageIfDefined(int);