diff --git a/CMake/Assets.cmake b/CMake/Assets.cmake index 5e37f152e..4da83d212 100644 --- a/CMake/Assets.cmake +++ b/CMake/Assets.cmake @@ -161,8 +161,8 @@ set(devilutionx_assets levels/l2data/bonechat.dun nlevels/l5data/cornerstone.dun nlevels/l5data/uberroom.dun - ui_art/black_diablo.pcx - ui_art/black_hellfire.pcx + ui_art/diablo.pal + ui_art/hellfire.pal ui_art/creditsw.clx ui_art/dvl_but_sml.clx ui_art/dvl_lrpopup.clx diff --git a/Packaging/resources/assets/ui_art/black_diablo.pcx b/Packaging/resources/assets/ui_art/black_diablo.pcx deleted file mode 100644 index d1cfd330d..000000000 Binary files a/Packaging/resources/assets/ui_art/black_diablo.pcx and /dev/null differ diff --git a/Packaging/resources/assets/ui_art/diablo.pal b/Packaging/resources/assets/ui_art/diablo.pal new file mode 100644 index 000000000..78c16b6bf Binary files /dev/null and b/Packaging/resources/assets/ui_art/diablo.pal differ diff --git a/Packaging/resources/assets/ui_art/black_hellfire.pcx b/Packaging/resources/assets/ui_art/hellfire.pal similarity index 79% rename from Packaging/resources/assets/ui_art/black_hellfire.pcx rename to Packaging/resources/assets/ui_art/hellfire.pal index d1cb7cf7c..8fec9adb4 100644 Binary files a/Packaging/resources/assets/ui_art/black_hellfire.pcx and b/Packaging/resources/assets/ui_art/hellfire.pal differ diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 3686ed782..3c9d165cd 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -319,6 +319,23 @@ bool HandleMenuAction(MenuAction menuAction) } } +void UiOnBackgroundChange() +{ + fadeTc = 0; + fadeValue = 0; + + if (IsHardwareCursorEnabled() && ArtCursor && ControlDevice == ControlTypes::KeyboardAndMouse && GetCurrentCursorInfo().type() != CursorType::UserInterface) { + SetHardwareCursor(CursorInfo::UserInterfaceCursor()); + } + + BlackPalette(); + + SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000); + if (DiabloUiSurface() == PalSurface) + BltFast(nullptr, nullptr); + RenderPresent(); +} + } // namespace void UiFocusNavigation(SDL_Event *event) @@ -664,16 +681,17 @@ Sint16 GetCenterOffset(Sint16 w, Sint16 bw) return (bw - w) / 2; } -bool UiLoadBlackBackground() +void UiLoadDefaultPalette() { - LoadBackgroundArt(gbIsHellfire ? "ui_art\\black_hellfire.pcx" : "ui_art\\black_diablo.pcx"); - - if (!ArtBackground) - return false; + LoadPalette(gbIsHellfire ? "ui_art\\hellfire.pal" : "ui_art\\diablo.pal", /*blend=*/false); + ApplyGamma(logical_palette, orig_palette, 256); +} - // We only needed the black background for the palette, can now deallocate it. +bool UiLoadBlackBackground() +{ ArtBackground = std::nullopt; - + UiLoadDefaultPalette(); + UiOnBackgroundChange(); return true; } @@ -687,20 +705,7 @@ void LoadBackgroundArt(const char *pszFile, int frames) LoadPalInMem(pPal); ApplyGamma(logical_palette, orig_palette, 256); - - fadeTc = 0; - fadeValue = 0; - - if (IsHardwareCursorEnabled() && ArtCursor && ControlDevice == ControlTypes::KeyboardAndMouse && GetCurrentCursorInfo().type() != CursorType::UserInterface) { - SetHardwareCursor(CursorInfo::UserInterfaceCursor()); - } - - BlackPalette(); - - SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000); - if (DiabloUiSurface() == PalSurface) - BltFast(nullptr, nullptr); - RenderPresent(); + UiOnBackgroundChange(); } void UiAddBackground(std::vector> *vecDialog) diff --git a/Source/DiabloUI/diabloui.h b/Source/DiabloUI/diabloui.h index 52aeed533..6e49424c6 100644 --- a/Source/DiabloUI/diabloui.h +++ b/Source/DiabloUI/diabloui.h @@ -94,6 +94,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector> *vecDialog);