Browse Source

Add widescreen menus

pull/982/head
Anders Jenbo 5 years ago
parent
commit
47004ddd35
  1. BIN
      Packaging/resources/devilutionx.mpq
  2. 6
      Source/init.cpp
  3. 1
      Source/init.h
  4. 6
      SourceX/DiabloUI/art.cpp
  5. 3
      SourceX/DiabloUI/credits.cpp
  6. 10
      SourceX/DiabloUI/diabloui.cpp
  7. 1
      SourceX/DiabloUI/diabloui.h
  8. 15
      SourceX/DiabloUI/mainmenu.cpp
  9. 3
      SourceX/DiabloUI/title.cpp
  10. 3
      SourceX/storm/storm.cpp

BIN
Packaging/resources/devilutionx.mpq

Binary file not shown.

6
Source/init.cpp

@ -38,6 +38,7 @@ HANDLE hfmusic_mpq;
HANDLE hfvoice_mpq;
HANDLE hfopt1_mpq;
HANDLE hfopt2_mpq;
HANDLE devilutionx_mpq;
namespace {
@ -116,6 +117,10 @@ void init_cleanup()
SFileCloseArchive(hfopt2_mpq);
hfopt2_mpq = NULL;
}
if (devilutionx_mpq) {
SFileCloseArchive(patch_rt_mpq);
patch_rt_mpq = NULL;
}
NetClose();
}
@ -161,6 +166,7 @@ void init_archives()
hfvoice_mpq = init_test_access("hfvoice.mpq", "DiabloInstall", 8500, FS_PC);
hfopt1_mpq = init_test_access("hfopt1.mpq", "DiabloInstall", 8600, FS_PC);
hfopt2_mpq = init_test_access("hfopt2.mpq", "DiabloInstall", 8610, FS_PC);
devilutionx_mpq = init_test_access("devilutionx.mpq", "DiabloInstall", 9000, FS_PC);
}
void init_create_window()

1
Source/init.h

@ -28,6 +28,7 @@ extern HANDLE hfmusic_mpq;
extern HANDLE hfvoice_mpq;
extern HANDLE hfopt1_mpq;
extern HANDLE hfopt2_mpq;
extern HANDLE devilutionx_mpq;
void init_cleanup();
void init_archives();

6
SourceX/DiabloUI/art.cpp

@ -11,8 +11,10 @@ void LoadArt(const char *pszFile, Art *art, int frames, SDL_Color *pPalette)
art->frames = frames;
DWORD width, height, bpp;
if (!SBmpLoadImage(pszFile, 0, 0, 0, &width, &height, &bpp))
if (!SBmpLoadImage(pszFile, 0, 0, 0, &width, &height, &bpp)) {
SDL_Log("Failed to load image meta");
return;
}
Uint32 format;
switch (bpp) {
@ -57,7 +59,7 @@ void LoadArt(Art *art, const BYTE *artData, int w, int h, int frames)
{
art->frames = frames;
art->surface = SDL_CreateRGBSurfaceWithFormatFrom(
const_cast<BYTE *>(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8);
const_cast<BYTE *>(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8);
art->logical_width = w;
art->frame_height = h / frames;
ScaleSurfaceToOutput(&art->surface);

3
SourceX/DiabloUI/credits.cpp

@ -105,6 +105,7 @@ class CreditsRenderer {
public:
CreditsRenderer()
{
LoadArt("ui_art\\creditsw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\credits.pcx");
LoadTtfFont();
ticks_begin_ = SDL_GetTicks();
@ -114,6 +115,7 @@ public:
~CreditsRenderer()
{
ArtBackgroundWidescreen.Unload();
ArtBackground.Unload();
UnloadTtfFont();
@ -145,6 +147,7 @@ void CreditsRenderer::Render()
prev_offset_y_ = offset_y;
SDL_FillRect(GetOutputSurface(), NULL, 0x000000);
DrawArt(PANEL_LEFT - 320, UI_OFFSET_Y, &ArtBackgroundWidescreen);
DrawArt(PANEL_LEFT, UI_OFFSET_Y, &ArtBackground);
if (font == NULL)
return;

10
SourceX/DiabloUI/diabloui.cpp

@ -30,6 +30,7 @@ const std::size_t *ListOffset = NULL;
Art ArtLogos[3];
Art ArtFocus[3];
Art ArtBackgroundWidescreen;
Art ArtBackground;
Art ArtCursor;
Art ArtHero;
@ -607,8 +608,13 @@ void LoadBackgroundArt(const char *pszFile, int frames)
void UiAddBackground(std::vector<UiItemBase *> *vecDialog)
{
SDL_Rect rect = { PANEL_LEFT, UI_OFFSET_Y, 640, 480 };
vecDialog->push_back(new UiImage(&ArtBackground, rect));
if (ArtBackgroundWidescreen.surface != NULL) {
SDL_Rect rectw = { 0, UI_OFFSET_Y, 0, 0 };
vecDialog->push_back(new UiImage(&ArtBackgroundWidescreen, /*animated=*/false, /*frame=*/0, rectw, UIS_CENTER));
}
SDL_Rect rect = { 0, UI_OFFSET_Y, 0, 0 };
vecDialog->push_back(new UiImage(&ArtBackground, /*animated=*/false, /*frame=*/0, rect, UIS_CENTER));
}
void UiAddLogo(std::vector<UiItemBase *> *vecDialog, int size, int y)

1
SourceX/DiabloUI/diabloui.h

@ -26,6 +26,7 @@ typedef enum _artLogo {
extern Art ArtLogos[3];
extern Art ArtFocus[3];
extern Art ArtBackground;
extern Art ArtBackgroundWidescreen;
extern Art ArtCursor;
extern Art ArtHero;
extern bool gbSpawned;

15
SourceX/DiabloUI/mainmenu.cpp

@ -48,6 +48,14 @@ void mainmenu_Load(const char *name, void (*fnSound)(const char *file))
vecMenuItems.push_back(new UiListItem("Exit Diablo", MAINMENU_EXIT_DIABLO));
}
if (!gbSpawned || gbIsHellfire) {
if (gbIsHellfire)
LoadArt("ui_art\\mainmenuw.pcx", &ArtBackgroundWidescreen);
LoadBackgroundArt("ui_art\\mainmenu.pcx");
} else {
LoadBackgroundArt("ui_art\\swmmenu.pcx");
}
UiAddBackground(&vecMainMenuDialog);
UiAddLogo(&vecMainMenuDialog);
@ -56,17 +64,12 @@ void mainmenu_Load(const char *name, void (*fnSound)(const char *file))
SDL_Rect rect = { 17, (SCREEN_HEIGHT - 36), 605, 21 };
vecMainMenuDialog.push_back(new UiArtText(name, rect, UIS_SMALL));
if (!gbSpawned || gbIsHellfire) {
LoadBackgroundArt("ui_art\\mainmenu.pcx");
} else {
LoadBackgroundArt("ui_art\\swmmenu.pcx");
}
UiInitList(vecMenuItems.size(), NULL, UiMainMenuSelect, mainmenu_Esc, vecMainMenuDialog, true);
}
void mainmenu_Free()
{
ArtBackgroundWidescreen.Unload();
ArtBackground.Unload();
for (std::size_t i = 0; i < vecMainMenuDialog.size(); i++) {

3
SourceX/DiabloUI/title.cpp

@ -10,6 +10,7 @@ void title_Load()
{
if (gbIsHellfire) {
LoadBackgroundArt("ui_art\\hf_logo1.pcx", 16);
LoadArt("ui_art\\hf_titlew.pcx", &ArtBackgroundWidescreen);
} else {
LoadBackgroundArt("ui_art\\title.pcx");
LoadMaskedArt("ui_art\\logo.pcx", &ArtLogos[LOGO_BIG], 15);
@ -19,6 +20,7 @@ void title_Load()
void title_Free()
{
ArtBackground.Unload();
ArtBackgroundWidescreen.Unload();
ArtLogos[LOGO_BIG].Unload();
for (std::size_t i = 0; i < vecTitleScreen.size(); i++) {
@ -32,6 +34,7 @@ void UiTitleDialog()
{
if (gbIsHellfire) {
SDL_Rect rect = { 0, UI_OFFSET_Y, 0, 0 };
vecTitleScreen.push_back(new UiImage(&ArtBackgroundWidescreen, /*animated=*/true, /*frame=*/0, rect, UIS_CENTER));
vecTitleScreen.push_back(new UiImage(&ArtBackground, /*animated=*/true, /*frame=*/0, rect, UIS_CENTER));
} else {
UiAddBackground(&vecTitleScreen);

3
SourceX/storm/storm.cpp

@ -153,6 +153,9 @@ BOOL SFileOpenFile(const char *filename, HANDLE *phFile)
result = SFileOpenFileEx((HANDLE)0, path.c_str(), 0xFFFFFFFF, phFile);
}
if (!result) {
result = SFileOpenFileEx((HANDLE)devilutionx_mpq, filename, 0, phFile);
}
if (gbIsHellfire) {
if (!result) {
result = SFileOpenFileEx((HANDLE)hfopt2_mpq, filename, 0, phFile);

Loading…
Cancel
Save