diff --git a/CMake/Assets.cmake b/CMake/Assets.cmake index 0ad621bab..7226b12c1 100644 --- a/CMake/Assets.cmake +++ b/CMake/Assets.cmake @@ -159,7 +159,8 @@ set(devilutionx_assets gendata/cutstartw.pcx Levels/L1Data/SklKngT.dun Levels/L2Data/BonechaT.dun - ui_art/black.pcx + ui_art/black_diablo.pcx + ui_art/black_hellfire.pcx ui_art/creditsw.pcx ui_art/dvl_but_sml.pcx ui_art/dvl_lrpopup.pcx diff --git a/Packaging/resources/assets/ui_art/black.pcx b/Packaging/resources/assets/ui_art/black_diablo.pcx similarity index 100% rename from Packaging/resources/assets/ui_art/black.pcx rename to Packaging/resources/assets/ui_art/black_diablo.pcx diff --git a/Packaging/resources/assets/ui_art/black_hellfire.pcx b/Packaging/resources/assets/ui_art/black_hellfire.pcx new file mode 100644 index 000000000..d1cb7cf7c Binary files /dev/null and b/Packaging/resources/assets/ui_art/black_hellfire.pcx differ diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 72c9602f2..e296a6e2f 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -673,8 +673,22 @@ Sint16 GetCenterOffset(Sint16 w, Sint16 bw) return (bw - w) / 2; } +bool UiLoadBlackBackground() +{ + LoadBackgroundArt(gbIsHellfire ? "ui_art\\black_hellfire.pcx" : "ui_art\\black_diablo.pcx"); + + if (!ArtBackground) + return false; + + // We only needed the black background for the palette, can now deallocate it. + ArtBackground = std::nullopt; + + return true; +} + void LoadBackgroundArt(const char *pszFile, int frames) { + ArtBackground = std::nullopt; SDL_Color pPal[256]; ArtBackground = LoadPcxSpriteSheetAsset(pszFile, static_cast(frames), /*transparentColor=*/std::nullopt, pPal); if (!ArtBackground) @@ -700,14 +714,13 @@ void LoadBackgroundArt(const char *pszFile, int frames) void UiAddBackground(std::vector> *vecDialog) { - int uiPositionY = GetUIRectangle().position.y; + const SDL_Rect rect = MakeSdlRect(0, GetUIRectangle().position.y, 0, 0); if (ArtBackgroundWidescreen) { - SDL_Rect rectw = MakeSdlRect(0, uiPositionY, 0, 0); - vecDialog->push_back(std::make_unique(PcxSprite { *ArtBackgroundWidescreen }, rectw, UiFlags::AlignCenter)); + vecDialog->push_back(std::make_unique(PcxSprite { *ArtBackgroundWidescreen }, rect, UiFlags::AlignCenter)); + } + if (ArtBackground) { + vecDialog->push_back(std::make_unique(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter)); } - - SDL_Rect rect = MakeSdlRect(0, uiPositionY, 0, 0); - vecDialog->push_back(std::make_unique(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter)); } void UiAddLogo(std::vector> *vecDialog) @@ -769,7 +782,7 @@ void DrawSelector(const SDL_Rect &rect) void UiClearScreen() { - if (gnScreenWidth > 640) // Background size + if (!ArtBackground || gnScreenWidth > PcxSpriteSheet { *ArtBackground }.width() || gnScreenHeight > PcxSpriteSheet { *ArtBackground }.frameHeight()) SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000); } diff --git a/Source/DiabloUI/diabloui.h b/Source/DiabloUI/diabloui.h index 05042db48..5bb9c94dd 100644 --- a/Source/DiabloUI/diabloui.h +++ b/Source/DiabloUI/diabloui.h @@ -96,6 +96,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector> *vecDialog); void UiAddLogo(std::vector> *vecDialog); diff --git a/Source/DiabloUI/dialogs.cpp b/Source/DiabloUI/dialogs.cpp index a3703727c..fec3003ee 100644 --- a/Source/DiabloUI/dialogs.cpp +++ b/Source/DiabloUI/dialogs.cpp @@ -55,9 +55,7 @@ std::optional LoadDialogSprite(bool hasCaption, bool isError) bool Init(string_view caption, string_view text, bool error, bool renderBehind) { if (!renderBehind) { - ArtBackground = std::nullopt; - LoadBackgroundArt("ui_art\\black.pcx"); - if (!ArtBackground) { + if (!UiLoadBlackBackground()) { if (SDL_ShowCursor(SDL_ENABLE) <= -1) LogError("{}", SDL_GetError()); } diff --git a/Source/DiabloUI/progress.cpp b/Source/DiabloUI/progress.cpp index c41c81bfe..52b7a8064 100644 --- a/Source/DiabloUI/progress.cpp +++ b/Source/DiabloUI/progress.cpp @@ -30,7 +30,7 @@ void DialogActionCancel() void ProgressLoadBackground() { - LoadBackgroundArt("ui_art\\black.pcx"); + UiLoadBlackBackground(); ArtPopupSm = LoadPcxAsset("ui_art\\spopup.pcx"); ArtProgBG = LoadPcxAsset("ui_art\\prog_bg.pcx"); } diff --git a/Source/DiabloUI/selok.cpp b/Source/DiabloUI/selok.cpp index cf3becc1c..4d81b681d 100644 --- a/Source/DiabloUI/selok.cpp +++ b/Source/DiabloUI/selok.cpp @@ -43,7 +43,7 @@ void selok_Esc() void UiSelOkDialog(const char *title, const char *body, bool background) { if (!background) { - LoadBackgroundArt("ui_art\\black.pcx"); + UiLoadBlackBackground(); } else { if (!gbIsSpawn) { LoadBackgroundArt("ui_art\\mainmenu.pcx"); diff --git a/Source/DiabloUI/selyesno.cpp b/Source/DiabloUI/selyesno.cpp index 0b33c7562..7ff62982b 100644 --- a/Source/DiabloUI/selyesno.cpp +++ b/Source/DiabloUI/selyesno.cpp @@ -42,7 +42,7 @@ void SelyesnoEsc() bool UiSelHeroYesNoDialog(const char *title, const char *body) { - LoadBackgroundArt("ui_art\\black.pcx"); + UiLoadBlackBackground(); UiAddBackground(&vecSelYesNoDialog); UiAddLogo(&vecSelYesNoDialog); diff --git a/Source/DiabloUI/settingsmenu.cpp b/Source/DiabloUI/settingsmenu.cpp index 0f17f3b99..3164d33ce 100644 --- a/Source/DiabloUI/settingsmenu.cpp +++ b/Source/DiabloUI/settingsmenu.cpp @@ -247,7 +247,7 @@ void UiSettingsMenu() do { endMenu = false; - LoadBackgroundArt("ui_art\\black.pcx"); + UiLoadBlackBackground(); LoadScrollBar(); UiAddBackground(&vecDialog); UiAddLogo(&vecDialog);