Browse Source

DiabloUI: Clean up logo handling (#4830)

1. There is no small logo. Simply use 2 variables.
2. The medium logo is much smaller as PCX:
   * Hellfire (`ui_art\hf_logo2.pcx`): 1591816 bytes -> 195850 bytes
   * Diablo (`ui_art\smlogo.pcx`): 341923 bytes -> 333099 bytes

* Move `ArtLogoBig` to `title.cpp`

It is only ever used there
pull/4832/head^2
Gleb Mazovetskiy 4 years ago committed by GitHub
parent
commit
7a58f800f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      Source/DiabloUI/diabloui.cpp
  2. 10
      Source/DiabloUI/diabloui.h
  3. 12
      Source/DiabloUI/title.cpp

17
Source/DiabloUI/diabloui.cpp

@ -45,8 +45,9 @@
namespace devilution { namespace devilution {
std::optional<OwnedPcxSpriteSheet> ArtLogo;
// These are stored as PCX but we load them as CEL to reduce memory usage. // These are stored as PCX but we load them as CEL to reduce memory usage.
std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtLogos;
std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtFocus; std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtFocus;
std::optional<OwnedPcxSprite> ArtBackgroundWidescreen; std::optional<OwnedPcxSprite> ArtBackgroundWidescreen;
@ -572,9 +573,9 @@ void LoadHeros()
void LoadUiGFX() void LoadUiGFX()
{ {
if (gbIsHellfire) { 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 { } 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_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); ArtFocus[FOCUS_MED] = LoadPcxAssetAsCel("ui_art\\focus.pcx", /*numFrames=*/8, /*generateFrameHeaders=*/false, /*transparentColorIndex=*/250);
@ -600,8 +601,7 @@ void UnloadUiGFX()
ArtCursor.Unload(); ArtCursor.Unload();
for (auto &art : ArtFocus) for (auto &art : ArtFocus)
art = std::nullopt; art = std::nullopt;
for (auto &art : ArtLogos) ArtLogo = std::nullopt;
art = std::nullopt;
} }
void UiInitialize() void UiInitialize()
@ -709,11 +709,10 @@ void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter)); vecDialog->push_back(std::make_unique<UiImagePcx>(PcxSpriteSheet { *ArtBackground }.sprite(0), rect, UiFlags::AlignCenter));
} }
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int size, int y) void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog)
{ {
SDL_Rect rect = MakeSdlRect(0, GetUIRectangle().position.y + y, 0, 0); vecDialog->push_back(std::make_unique<UiImageAnimatedPcx>(
vecDialog->push_back(std::make_unique<UiImageCel>( PcxSpriteSheet { *ArtLogo }, MakeSdlRect(0, GetUIRectangle().position.y, 0, 0), UiFlags::AlignCenter));
CelSpriteWithFrameHeight { CelSprite { ArtLogos[size]->sprite }, ArtLogos[size]->frameHeight }, rect, UiFlags::AlignCenter, /*bAnimated=*/true));
} }
void UiFadeIn() void UiFadeIn()

10
Source/DiabloUI/diabloui.h

@ -23,12 +23,6 @@ enum _artFocus : uint8_t {
FOCUS_BIG, FOCUS_BIG,
}; };
enum _artLogo : uint8_t {
LOGO_SMALL,
LOGO_MED,
LOGO_BIG,
};
enum _mainmenu_selections : uint8_t { enum _mainmenu_selections : uint8_t {
MAINMENU_NONE, MAINMENU_NONE,
MAINMENU_SINGLE_PLAYER, MAINMENU_SINGLE_PLAYER,
@ -68,7 +62,7 @@ struct _uiheroinfo {
bool spawned; bool spawned;
}; };
extern std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtLogos; extern std::optional<OwnedPcxSpriteSheet> ArtLogo;
extern std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtFocus; extern std::array<std::optional<OwnedCelSpriteWithFrameHeight>, 3> ArtFocus;
extern std::optional<OwnedPcxSprite> ArtBackgroundWidescreen; extern std::optional<OwnedPcxSprite> ArtBackgroundWidescreen;
extern std::optional<OwnedPcxSpriteSheet> ArtBackground; extern std::optional<OwnedPcxSpriteSheet> ArtBackground;
@ -105,7 +99,7 @@ void LoadPalInMem(const SDL_Color *pPal);
void DrawMouse(); void DrawMouse();
void LoadBackgroundArt(const char *pszFile, int frames = 1); void LoadBackgroundArt(const char *pszFile, int frames = 1);
void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog); void UiAddBackground(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);
void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog, int size = LOGO_MED, int y = 0); void UiAddLogo(std::vector<std::unique_ptr<UiItemBase>> *vecDialog);
void UiFocusNavigationSelect(); void UiFocusNavigationSelect();
void UiFocusNavigationEsc(); void UiFocusNavigationEsc();
void UiFocusNavigationYesNo(); void UiFocusNavigationYesNo();

12
Source/DiabloUI/title.cpp

@ -4,13 +4,15 @@
#include "controls/menu_controls.h" #include "controls/menu_controls.h"
#include "discord/discord.h" #include "discord/discord.h"
#include "engine/load_pcx.hpp" #include "engine/load_pcx.hpp"
#include "engine/load_pcx_as_cel.hpp"
#include "utils/language.h" #include "utils/language.h"
#include "utils/sdl_geometry.h" #include "utils/sdl_geometry.h"
#include "utils/stdcompat/optional.hpp"
namespace devilution { namespace devilution {
namespace { namespace {
std::optional<OwnedPcxSpriteSheet> DiabloTitleLogo;
std::vector<std::unique_ptr<UiItemBase>> vecTitleScreen; std::vector<std::unique_ptr<UiItemBase>> vecTitleScreen;
void TitleLoad() void TitleLoad()
@ -20,7 +22,7 @@ void TitleLoad()
ArtBackgroundWidescreen = LoadPcxAsset("ui_art\\hf_titlew.pcx"); ArtBackgroundWidescreen = LoadPcxAsset("ui_art\\hf_titlew.pcx");
} else { } else {
LoadBackgroundArt("ui_art\\title.pcx"); 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; ArtBackground = std::nullopt;
ArtBackgroundWidescreen = std::nullopt; ArtBackgroundWidescreen = std::nullopt;
ArtLogos[LOGO_BIG] = std::nullopt; DiabloTitleLogo = std::nullopt;
vecTitleScreen.clear(); vecTitleScreen.clear();
} }
@ -46,7 +48,9 @@ void UiTitleDialog()
vecTitleScreen.push_back(std::make_unique<UiImageAnimatedPcx>(PcxSpriteSheet { *ArtBackground }, rect, UiFlags::AlignCenter)); vecTitleScreen.push_back(std::make_unique<UiImageAnimatedPcx>(PcxSpriteSheet { *ArtBackground }, rect, UiFlags::AlignCenter));
} else { } else {
UiAddBackground(&vecTitleScreen); UiAddBackground(&vecTitleScreen);
UiAddLogo(&vecTitleScreen, LOGO_BIG, 182);
vecTitleScreen.push_back(std::make_unique<UiImageAnimatedPcx>(
PcxSpriteSheet { *DiabloTitleLogo }, MakeSdlRect(0, uiPosition.y + 182, 0, 0), UiFlags::AlignCenter));
SDL_Rect rect = MakeSdlRect(uiPosition.x, uiPosition.y + 410, 640, 26); SDL_Rect rect = MakeSdlRect(uiPosition.x, uiPosition.y + 410, 640, 26);
vecTitleScreen.push_back(std::make_unique<UiArtText>(_("Copyright © 1996-2001 Blizzard Entertainment").data(), rect, UiFlags::AlignCenter | UiFlags::FontSize24 | UiFlags::ColorUiSilver)); vecTitleScreen.push_back(std::make_unique<UiArtText>(_("Copyright © 1996-2001 Blizzard Entertainment").data(), rect, UiFlags::AlignCenter | UiFlags::FontSize24 | UiFlags::ColorUiSilver));

Loading…
Cancel
Save