mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Use setLevelDirError for level not found & parse errors
This exports the previously-internal setLevelDirError function in FileSystemUtils and uses it for if a level is not found or there was a parsing error. Previously, if a level failed to load in these ways, it would take you to the error screen with no error, while printing it to the console. But this makes it more user-friendly. As a bonus, the text is localizable, just like the existing usage of FILESYSTEM_setLevelDirError for if a path couldn't be mounted.
This commit is contained in:
@@ -1018,13 +1018,22 @@ bool customlevelclass::load(std::string _path)
|
||||
|
||||
if (!FILESYSTEM_loadTiXml2Document(_path.c_str(), doc))
|
||||
{
|
||||
vlog_warn("%s not found", _path.c_str());
|
||||
FILESYSTEM_setLevelDirError(
|
||||
loc::gettext("Level {path} not found"),
|
||||
"path:str",
|
||||
_path.c_str()
|
||||
);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (doc.Error())
|
||||
{
|
||||
vlog_error("Error parsing %s: %s", _path.c_str(), doc.ErrorStr());
|
||||
FILESYSTEM_setLevelDirError(
|
||||
loc::gettext("Error parsing {path}: {error}"),
|
||||
"path:str, error:str",
|
||||
_path.c_str(),
|
||||
doc.ErrorStr()
|
||||
);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ const char* FILESYSTEM_getLevelDirError(void)
|
||||
return levelDirError;
|
||||
}
|
||||
|
||||
static void setLevelDirError(const char* text, const char* args_index, ...)
|
||||
void FILESYSTEM_setLevelDirError(const char* text, const char* args_index, ...)
|
||||
{
|
||||
levelDirHasError = true;
|
||||
|
||||
@@ -475,7 +475,7 @@ static bool FILESYSTEM_mountAssetsFrom(const char *fname)
|
||||
|
||||
if (real_dir == NULL)
|
||||
{
|
||||
setLevelDirError(
|
||||
FILESYSTEM_setLevelDirError(
|
||||
loc::gettext("Could not mount {path}: real directory doesn't exist"),
|
||||
"path:str",
|
||||
fname
|
||||
|
||||
@@ -60,6 +60,7 @@ void FILESYSTEM_freeEnumerate(EnumHandle* handle);
|
||||
bool FILESYSTEM_levelDirHasError(void);
|
||||
void FILESYSTEM_clearLevelDirError(void);
|
||||
const char* FILESYSTEM_getLevelDirError(void);
|
||||
void FILESYSTEM_setLevelDirError(const char* text, const char* args_index, ...);
|
||||
|
||||
bool FILESYSTEM_openDirectoryEnabled(void);
|
||||
bool FILESYSTEM_openDirectory(const char *dname);
|
||||
|
||||
Reference in New Issue
Block a user