From 3ad7e21e71d0c2f1ddd0d2eece192c81318d3f56 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sun, 9 Feb 2020 04:04:01 +0100 Subject: [PATCH] Fix flashing menu transitions Fixes #591 --- SourceX/DiabloUI/credits.cpp | 1 - SourceX/DiabloUI/diabloui.cpp | 9 ++++++--- SourceX/DiabloUI/mainmenu.cpp | 1 - SourceX/DiabloUI/progress.cpp | 1 - SourceX/DiabloUI/selconn.cpp | 1 - SourceX/DiabloUI/selgame.cpp | 4 ---- SourceX/DiabloUI/selhero.cpp | 4 ---- SourceX/DiabloUI/selok.cpp | 2 -- SourceX/DiabloUI/selyesno.cpp | 2 -- SourceX/DiabloUI/title.cpp | 1 - 10 files changed, 6 insertions(+), 20 deletions(-) diff --git a/SourceX/DiabloUI/credits.cpp b/SourceX/DiabloUI/credits.cpp index 485c67cae..d405d6443 100644 --- a/SourceX/DiabloUI/credits.cpp +++ b/SourceX/DiabloUI/credits.cpp @@ -275,7 +275,6 @@ BOOL UiCreditsDialog(int a1) UiHandleEvents(&event); } } while (!endMenu && !credits_renderer.Finished()); - BlackPalette(); return true; } diff --git a/SourceX/DiabloUI/diabloui.cpp b/SourceX/DiabloUI/diabloui.cpp index dc927ddde..3641a811f 100644 --- a/SourceX/DiabloUI/diabloui.cpp +++ b/SourceX/DiabloUI/diabloui.cpp @@ -564,15 +564,18 @@ int GetCenterOffset(int w, int bw) void LoadBackgroundArt(const char *pszFile) { SDL_Color pPal[256]; - - fadeTc = 0; - fadeValue = 0; LoadArt(pszFile, &ArtBackground, 1, pPal); if (ArtBackground.surface == nullptr) return; LoadPalInMem(pPal); ApplyGamma(logical_palette, orig_palette, 256); + + fadeTc = 0; + fadeValue = 0; + BlackPalette(); + SDL_FillRect(GetOutputSurface(), NULL, 0x000000); + RenderPresent(); } void UiFadeIn() diff --git a/SourceX/DiabloUI/mainmenu.cpp b/SourceX/DiabloUI/mainmenu.cpp index 1b5738b9c..60204b4fb 100644 --- a/SourceX/DiabloUI/mainmenu.cpp +++ b/SourceX/DiabloUI/mainmenu.cpp @@ -72,7 +72,6 @@ BOOL UiMainMenuDialog(char *name, int *pdwResult, void (*fnSound)(char *file), i } } - BlackPalette(); mainmenu_Free(); if (gbSpawned && MainMenuResult == MAINMENU_REPLAY_INTRO) { diff --git a/SourceX/DiabloUI/progress.cpp b/SourceX/DiabloUI/progress.cpp index 48ac5409e..ab9004dc6 100644 --- a/SourceX/DiabloUI/progress.cpp +++ b/SourceX/DiabloUI/progress.cpp @@ -128,7 +128,6 @@ BOOL UiProgressDialog(HWND window, char *msg, int enable, int (*fnfunc)(), int r UiHandleEvents(&event); } } - BlackPalette(); progress_Free(); return progress == 100; diff --git a/SourceX/DiabloUI/selconn.cpp b/SourceX/DiabloUI/selconn.cpp index e67e2dfee..bef1bf1ea 100644 --- a/SourceX/DiabloUI/selconn.cpp +++ b/SourceX/DiabloUI/selconn.cpp @@ -118,7 +118,6 @@ int UiSelectProvider( while (!selconn_EndMenu) { UiPollAndRender(); } - BlackPalette(); selconn_Free(); return selconn_ReturnValue; diff --git a/SourceX/DiabloUI/selgame.cpp b/SourceX/DiabloUI/selgame.cpp index e43e946bb..6dd05e09f 100644 --- a/SourceX/DiabloUI/selgame.cpp +++ b/SourceX/DiabloUI/selgame.cpp @@ -176,7 +176,6 @@ bool IsDifficultyAllowed(int value) } selgame_Free(); - BlackPalette(); if (value == 1) UiSelOkDialog(title, "Your character must reach level 20 before you can enter a multiplayer game of Nightmare difficulty.", false); @@ -235,7 +234,6 @@ void selgame_Password_Select(int value) selgame_endMenu = true; } else { selgame_Free(); - BlackPalette(); UiSelOkDialog("Multi Player Game", SDL_GetError(), false); LoadBackgroundArt("ui_art\\selgame.pcx"); selgame_Password_Init(selgame_selectedGame); @@ -251,7 +249,6 @@ void selgame_Password_Select(int value) selgame_endMenu = true; } else { selgame_Free(); - BlackPalette(); UiSelOkDialog("Multi Player Game", SDL_GetError(), false); LoadBackgroundArt("ui_art\\selgame.pcx"); selgame_Password_Init(0); @@ -275,7 +272,6 @@ int UiSelectGame(int a1, _SNETPROGRAMDATA *client_info, _SNETPLAYERDATA *user_in while (!selgame_endMenu) { UiPollAndRender(); } - BlackPalette(); selgame_Free(); return selgame_enteringGame; diff --git a/SourceX/DiabloUI/selhero.cpp b/SourceX/DiabloUI/selhero.cpp index be3c2d5c9..c017f8c56 100644 --- a/SourceX/DiabloUI/selhero.cpp +++ b/SourceX/DiabloUI/selhero.cpp @@ -240,7 +240,6 @@ void selhero_ClassSelector_Select(int value) { if (gbSpawned && (value == 1 || value == 2)) { selhero_Free(); - BlackPalette(); UiSelOkDialog(nullptr, "The Rogue and Sorcerer are only available in the full retail version of Diablo. Visit https://www.gog.com/game/diablo to purchase.", false); LoadBackgroundArt("ui_art\\selhero.pcx"); selhero_List_Select(selhero_SaveCount); @@ -273,7 +272,6 @@ void selhero_Name_Select(int value) if (!UiValidPlayerName(selhero_heroInfo.name)) { selhero_Free(); - BlackPalette(); UiSelOkDialog(title, "Invalid name. A name cannot contain spaces, reserved characters, or reserved words.\n", false); LoadBackgroundArt("ui_art\\selhero.pcx"); } else { @@ -281,7 +279,6 @@ void selhero_Name_Select(int value) for (std::size_t i = 0; i < selhero_SaveCount; i++) { if (strcasecmp(selhero_heros[i].name, selhero_heroInfo.name) == 0) { selhero_Free(); - BlackPalette(); char dialogText[256]; sprintf(dialogText, "Character already exists. Do you want to overwrite \"%s\"?", selhero_heroInfo.name); overwrite = UiSelHeroYesNoDialog(title, dialogText); @@ -370,7 +367,6 @@ BOOL UiSelHeroDialog( UiRenderItems(SELHERO_DIALOG, size(SELHERO_DIALOG)); UiPollAndRender(); } - BlackPalette(); selhero_Free(); if (selhero_navigateYesNo) { diff --git a/SourceX/DiabloUI/selok.cpp b/SourceX/DiabloUI/selok.cpp index 2023ed49f..f28e00508 100644 --- a/SourceX/DiabloUI/selok.cpp +++ b/SourceX/DiabloUI/selok.cpp @@ -79,8 +79,6 @@ void UiSelOkDialog(const char *title, const char *body, bool background) UiPollAndRender(); } - BlackPalette(); - selok_Free(); } } // namespace dvl diff --git a/SourceX/DiabloUI/selyesno.cpp b/SourceX/DiabloUI/selyesno.cpp index 0f20339a8..a53344fa4 100644 --- a/SourceX/DiabloUI/selyesno.cpp +++ b/SourceX/DiabloUI/selyesno.cpp @@ -59,8 +59,6 @@ bool UiSelHeroYesNoDialog(const char *title, const char *body) UiPollAndRender(); } - BlackPalette(); - selyesno_Free(); return selyesno_value; diff --git a/SourceX/DiabloUI/title.cpp b/SourceX/DiabloUI/title.cpp index c86db113e..8c40834e6 100644 --- a/SourceX/DiabloUI/title.cpp +++ b/SourceX/DiabloUI/title.cpp @@ -54,7 +54,6 @@ void UiTitleDialog() UiHandleEvents(&event); } } - BlackPalette(); title_Free(); }