Add message box errors for missing files

This commit is contained in:
Christian Semmler 2025-05-21 15:59:35 -07:00
parent 92ee03ec4d
commit 1059de9c54
3 changed files with 26 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "mxstl/stlcompat.h" #include "mxstl/stlcompat.h"
#include "mxutilities.h" #include "mxutilities.h"
#include <SDL3/SDL_messagebox.h>
#include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_stdinc.h>
#include <stdio.h> #include <stdio.h>
@ -187,6 +188,12 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
MxString::MapPathToFilesystem(wdbPath); MxString::MapPathToFilesystem(wdbPath);
if ((wdbFile = SDL_IOFromFile(wdbPath, "rb")) == NULL) { if ((wdbFile = SDL_IOFromFile(wdbPath, "rb")) == NULL) {
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
"LEGO® Island Error",
"\"LEGO® Island\" failed to load world.wdb.\nPlease make sure this file is available on HD/CD.",
NULL
);
return FAILURE; return FAILURE;
} }
} }

View File

@ -2,6 +2,7 @@
#include "decomp.h" #include "decomp.h"
#include <SDL3/SDL_messagebox.h>
#include <memory.h> #include <memory.h>
#include <string.h> #include <string.h>
@ -127,6 +128,14 @@ LegoResult LegoFile::Open(const char* p_name, LegoU32 p_mode)
path.MapPathToFilesystem(); path.MapPathToFilesystem();
if (!(m_file = SDL_IOFromFile(path.GetData(), mode))) { if (!(m_file = SDL_IOFromFile(path.GetData(), mode))) {
char buffer[256];
SDL_snprintf(
buffer,
sizeof(buffer),
"\"LEGO® Island\" failed to load %s.\nPlease make sure this file is available on HD/CD.",
path.GetData()
);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "LEGO® Island Error", buffer, NULL);
return FAILURE; return FAILURE;
} }
return SUCCESS; return SUCCESS;

View File

@ -3,6 +3,7 @@
#include "decomp.h" #include "decomp.h"
#include "mxstring.h" #include "mxstring.h"
#include <SDL3/SDL_messagebox.h>
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
@ -72,6 +73,15 @@ MxU16 MXIOINFO::Open(const char* p_filename, MxULong p_flags)
} }
} }
else { else {
char buffer[256];
SDL_snprintf(
buffer,
sizeof(buffer),
"\"LEGO® Island\" failed to load %s.\nPlease make sure this file is available on HD/CD.",
path.GetData()
);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "LEGO® Island Error", buffer, NULL);
result = MMIOERR_CANNOTOPEN; result = MMIOERR_CANNOTOPEN;
} }