diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index c78c9fce8..df12aa77f 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -45,8 +45,9 @@ namespace devilution { +std::optional ArtLogo; + // These are stored as PCX but we load them as CEL to reduce memory usage. -std::array, 3> ArtLogos; std::array, 3> ArtFocus; std::optional ArtBackgroundWidescreen; @@ -572,9 +573,9 @@ void LoadHeros() void LoadUiGFX() { if (gbIsHellfire) { - ArtLogos[LOGO_MED] = LoadPcxAssetAsCel("ui_art\\hf_logo2.pcx", /*numFrames=*/16); + ArtLogo = LoadPcxSpriteSheetAsset("ui_art\\hf_logo2.pcx", /*numFrames=*/16, /*transparentColor=*/1); } else { - ArtLogos[LOGO_MED] = LoadPcxAssetAsCel("ui_art\\smlogo.pcx", /*numFrames=*/15, /*generateFrameHeaders=*/false, /*transparentColorIndex=*/250); + ArtLogo = LoadPcxSpriteSheetAsset("ui_art\\smlogo.pcx", /*numFrames=*/15, /*transparentColor=*/250); } ArtFocus[FOCUS_SMALL] = LoadPcxAssetAsCel("ui_art\\focus16.pcx", /*numFrames=*/8, /*generateFrameHeaders=*/false, /*transparentColorIndex=*/250); ArtFocus[FOCUS_MED] = LoadPcxAssetAsCel("ui_art\\focus.pcx", /*numFrames=*/8, /*generateFrameHeaders=*/false, /*transparentColorIndex=*/250); @@ -600,8 +601,7 @@ void UnloadUiGFX() ArtCursor.Unload(); for (auto &art : ArtFocus) art = std::nullopt; - for (auto &art : ArtLogos) - art = std::nullopt; + ArtLogo = std::nullopt; } void UiInitialize() @@ -709,11 +709,10 @@ void UiAddBackground(std::vector> *vecDialog) vecDialog->push_back(std::make_unique(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter)); } -void UiAddLogo(std::vector> *vecDialog, int size, int y) +void UiAddLogo(std::vector> *vecDialog) { - SDL_Rect rect = MakeSdlRect(0, GetUIRectangle().position.y + y, 0, 0); - vecDialog->push_back(std::make_unique( - CelSpriteWithFrameHeight { CelSprite { ArtLogos[size]->sprite }, ArtLogos[size]->frameHeight }, rect, UiFlags::AlignCenter, /*bAnimated=*/true)); + vecDialog->push_back(std::make_unique( + PcxSpriteSheet { *ArtLogo }, MakeSdlRect(0, GetUIRectangle().position.y, 0, 0), UiFlags::AlignCenter)); } void UiFadeIn() diff --git a/Source/DiabloUI/diabloui.h b/Source/DiabloUI/diabloui.h index 1710a1011..47d27fdf0 100644 --- a/Source/DiabloUI/diabloui.h +++ b/Source/DiabloUI/diabloui.h @@ -23,12 +23,6 @@ enum _artFocus : uint8_t { FOCUS_BIG, }; -enum _artLogo : uint8_t { - LOGO_SMALL, - LOGO_MED, - LOGO_BIG, -}; - enum _mainmenu_selections : uint8_t { MAINMENU_NONE, MAINMENU_SINGLE_PLAYER, @@ -68,7 +62,7 @@ struct _uiheroinfo { bool spawned; }; -extern std::array, 3> ArtLogos; +extern std::optional ArtLogo; extern std::array, 3> ArtFocus; extern std::optional ArtBackgroundWidescreen; extern std::optional ArtBackground; @@ -105,7 +99,7 @@ void LoadPalInMem(const SDL_Color *pPal); void DrawMouse(); void LoadBackgroundArt(const char *pszFile, int frames = 1); void UiAddBackground(std::vector> *vecDialog); -void UiAddLogo(std::vector> *vecDialog, int size = LOGO_MED, int y = 0); +void UiAddLogo(std::vector> *vecDialog); void UiFocusNavigationSelect(); void UiFocusNavigationEsc(); void UiFocusNavigationYesNo(); diff --git a/Source/DiabloUI/title.cpp b/Source/DiabloUI/title.cpp index 75f143c55..6df7809d2 100644 --- a/Source/DiabloUI/title.cpp +++ b/Source/DiabloUI/title.cpp @@ -4,13 +4,15 @@ #include "controls/menu_controls.h" #include "discord/discord.h" #include "engine/load_pcx.hpp" -#include "engine/load_pcx_as_cel.hpp" #include "utils/language.h" #include "utils/sdl_geometry.h" +#include "utils/stdcompat/optional.hpp" namespace devilution { namespace { +std::optional DiabloTitleLogo; + std::vector> vecTitleScreen; void TitleLoad() @@ -20,7 +22,7 @@ void TitleLoad() ArtBackgroundWidescreen = LoadPcxAsset("ui_art\\hf_titlew.pcx"); } else { LoadBackgroundArt("ui_art\\title.pcx"); - ArtLogos[LOGO_BIG] = LoadPcxAssetAsCel("ui_art\\logo.pcx", /*numFrames=*/15, /*generateFrameHeaders=*/false, /*transparentColorIndex=*/250); + DiabloTitleLogo = LoadPcxSpriteSheetAsset("ui_art\\logo.pcx", /*numFrames=*/15, /*transparentColor=*/250); } } @@ -28,7 +30,7 @@ void TitleFree() { ArtBackground = std::nullopt; ArtBackgroundWidescreen = std::nullopt; - ArtLogos[LOGO_BIG] = std::nullopt; + DiabloTitleLogo = std::nullopt; vecTitleScreen.clear(); } @@ -46,7 +48,9 @@ void UiTitleDialog() vecTitleScreen.push_back(std::make_unique(PcxSpriteSheet { *ArtBackground }, rect, UiFlags::AlignCenter)); } else { UiAddBackground(&vecTitleScreen); - UiAddLogo(&vecTitleScreen, LOGO_BIG, 182); + + vecTitleScreen.push_back(std::make_unique( + PcxSpriteSheet { *DiabloTitleLogo }, MakeSdlRect(0, uiPosition.y + 182, 0, 0), UiFlags::AlignCenter)); SDL_Rect rect = MakeSdlRect(uiPosition.x, uiPosition.y + 410, 640, 26); vecTitleScreen.push_back(std::make_unique(_("Copyright © 1996-2001 Blizzard Entertainment").data(), rect, UiFlags::AlignCenter | UiFlags::FontSize24 | UiFlags::ColorUiSilver));