mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
If loaded level assets fail to mount, print message to non-console users
This error case can happen, but if it does, non-console users get an ERROR page with no further information. So use setLevelDirError if this failure mode happens. And Menu::errorloadinglevel needs to be changed to accomodate that.
This commit is contained in:
parent
124d77c041
commit
bc47b86645
2 changed files with 49 additions and 38 deletions
|
@ -279,6 +279,41 @@ static void generateVirtualMountPath(char* path, const size_t path_size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char levelDirError[256] = {'\0'};
|
||||||
|
|
||||||
|
static bool levelDirHasError = false;
|
||||||
|
|
||||||
|
bool FILESYSTEM_levelDirHasError(void)
|
||||||
|
{
|
||||||
|
return levelDirHasError;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FILESYSTEM_clearLevelDirError(void)
|
||||||
|
{
|
||||||
|
levelDirHasError = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* FILESYSTEM_getLevelDirError(void)
|
||||||
|
{
|
||||||
|
return levelDirError;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int setLevelDirError(const char* text, ...)
|
||||||
|
{
|
||||||
|
va_list list;
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
levelDirHasError = true;
|
||||||
|
|
||||||
|
va_start(list, text);
|
||||||
|
retval = SDL_vsnprintf(levelDirError, sizeof(levelDirError), text, list);
|
||||||
|
va_end(list);
|
||||||
|
|
||||||
|
puts(levelDirError);
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
static bool FILESYSTEM_mountAssetsFrom(const char *fname)
|
static bool FILESYSTEM_mountAssetsFrom(const char *fname)
|
||||||
{
|
{
|
||||||
const char* real_dir = PHYSFS_getRealDir(fname);
|
const char* real_dir = PHYSFS_getRealDir(fname);
|
||||||
|
@ -286,8 +321,8 @@ static bool FILESYSTEM_mountAssetsFrom(const char *fname)
|
||||||
|
|
||||||
if (real_dir == NULL)
|
if (real_dir == NULL)
|
||||||
{
|
{
|
||||||
printf(
|
setLevelDirError(
|
||||||
"Could not mount %s: real directory doesn't exist\n",
|
"Could not mount %s: real directory doesn't exist",
|
||||||
fname
|
fname
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
@ -347,41 +382,6 @@ static PHYSFS_EnumerateCallbackResult zipCheckCallback(
|
||||||
return PHYSFS_ENUM_OK;
|
return PHYSFS_ENUM_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char levelDirError[256] = {'\0'};
|
|
||||||
|
|
||||||
static bool levelDirHasError = false;
|
|
||||||
|
|
||||||
bool FILESYSTEM_levelDirHasError(void)
|
|
||||||
{
|
|
||||||
return levelDirHasError;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FILESYSTEM_clearLevelDirError(void)
|
|
||||||
{
|
|
||||||
levelDirHasError = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* FILESYSTEM_getLevelDirError(void)
|
|
||||||
{
|
|
||||||
return levelDirError;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int setLevelDirError(const char* text, ...)
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
int retval;
|
|
||||||
|
|
||||||
levelDirHasError = true;
|
|
||||||
|
|
||||||
va_start(list, text);
|
|
||||||
retval = SDL_vsnprintf(levelDirError, sizeof(levelDirError), text, list);
|
|
||||||
va_end(list);
|
|
||||||
|
|
||||||
puts(levelDirError);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For technical reasons, the level file inside a zip named LEVELNAME.zip must
|
/* For technical reasons, the level file inside a zip named LEVELNAME.zip must
|
||||||
* be named LEVELNAME.vvvvvv, else its custom assets won't work;
|
* be named LEVELNAME.vvvvvv, else its custom assets won't work;
|
||||||
* if there are .vvvvvv files other than LEVELNAME.vvvvvv, they would be loaded
|
* if there are .vvvvvv files other than LEVELNAME.vvvvvv, they would be loaded
|
||||||
|
|
|
@ -1389,9 +1389,20 @@ static void menurender(void)
|
||||||
graphics.Print( -1, 95, "ERROR: Could not save settings file!", tr, tg, tb, true);
|
graphics.Print( -1, 95, "ERROR: Could not save settings file!", tr, tg, tb, true);
|
||||||
break;
|
break;
|
||||||
case Menu::errorloadinglevel:
|
case Menu::errorloadinglevel:
|
||||||
|
{
|
||||||
|
const char* str;
|
||||||
|
if (FILESYSTEM_levelDirHasError())
|
||||||
|
{
|
||||||
|
str = FILESYSTEM_getLevelDirError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = graphics.error;
|
||||||
|
}
|
||||||
graphics.bigprint(-1, 45, "ERROR", tr, tg, tb, true);
|
graphics.bigprint(-1, 45, "ERROR", tr, tg, tb, true);
|
||||||
graphics.PrintWrap(-1, 65, graphics.error, tr, tg, tb, true, 10, 304);
|
graphics.PrintWrap(-1, 65, str, tr, tg, tb, true, 10, 304);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Menu::warninglevellist:
|
case Menu::warninglevellist:
|
||||||
graphics.bigprint(-1, 45, "WARNING", tr, tg, tb, true);
|
graphics.bigprint(-1, 45, "WARNING", tr, tg, tb, true);
|
||||||
graphics.PrintWrap(-1, 65, FILESYSTEM_getLevelDirError(), tr, tg, tb, true, 10, 304);
|
graphics.PrintWrap(-1, 65, FILESYSTEM_getLevelDirError(), tr, tg, tb, true, 10, 304);
|
||||||
|
|
Loading…
Reference in a new issue