Browse Source

Fix black background palette (#4831)

Diablo and Hellfire have different palettes in `ui_art\black.pcx`.

We now ship our own tiny `black.pcx` that takes priority over the
other ones. This `black.pcx` had the Diablo palette which resulted in an
incorrect palette in the Settings screen.

Split our own `black.pcx` file into `black_diablo.pcx` and
`black_hellfire.pcx` and load the correct one depending on the mode.
pull/4850/head
Gleb Mazovetskiy 4 years ago committed by GitHub
parent
commit
ad7ca97ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      CMake/Assets.cmake
  2. 0
      Packaging/resources/assets/ui_art/black_diablo.pcx
  3. BIN
      Packaging/resources/assets/ui_art/black_hellfire.pcx
  4. 27
      Source/DiabloUI/diabloui.cpp
  5. 1
      Source/DiabloUI/diabloui.h
  6. 4
      Source/DiabloUI/dialogs.cpp
  7. 2
      Source/DiabloUI/progress.cpp
  8. 2
      Source/DiabloUI/selok.cpp
  9. 2
      Source/DiabloUI/selyesno.cpp
  10. 2
      Source/DiabloUI/settingsmenu.cpp

3
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

0
Packaging/resources/assets/ui_art/black.pcx → Packaging/resources/assets/ui_art/black_diablo.pcx

BIN
Packaging/resources/assets/ui_art/black_hellfire.pcx

Binary file not shown.

27
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<uint16_t>(frames), /*transparentColor=*/std::nullopt, pPal);
if (!ArtBackground)
@ -700,14 +714,13 @@ void LoadBackgroundArt(const char *pszFile, int frames)
void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *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<UiImagePcx>(PcxSprite { *ArtBackgroundWidescreen }, rectw, UiFlags::AlignCenter));
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSprite { *ArtBackgroundWidescreen }, rect, UiFlags::AlignCenter));
}
if (ArtBackground) {
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter));
}
SDL_Rect rect = MakeSdlRect(0, uiPositionY, 0, 0);
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter));
}
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *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);
}

1
Source/DiabloUI/diabloui.h

@ -96,6 +96,7 @@ bool UiItemMouseEvents(SDL_Event *event, const std::vector<std::unique_ptr<UiIte
Sint16 GetCenterOffset(Sint16 w, Sint16 bw = 0);
void LoadPalInMem(const SDL_Color *pPal);
void DrawMouse();
bool UiLoadBlackBackground();
void LoadBackgroundArt(const char *pszFile, int frames = 1);
void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);

4
Source/DiabloUI/dialogs.cpp

@ -55,9 +55,7 @@ std::optional<PcxSprite> 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());
}

2
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");
}

2
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");

2
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);

2
Source/DiabloUI/settingsmenu.cpp

@ -247,7 +247,7 @@ void UiSettingsMenu()
do {
endMenu = false;
LoadBackgroundArt("ui_art\\black.pcx");
UiLoadBlackBackground();
LoadScrollBar();
UiAddBackground(&vecDialog);
UiAddLogo(&vecDialog);

Loading…
Cancel
Save