1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01: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:
Misa 2023-05-17 10:09:59 -07:00
parent a5eb361448
commit 9387186083
15 changed files with 38 additions and 4 deletions

View file

@ -759,6 +759,8 @@ Has trobat el laboratori secret!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="MÀSTER DE LUNIVERS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Passat el joc en el mode|sense cap mort" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="No sha pogut muntar {path}: el directori real no existeix" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: No sha pogut escriure|a la carpeta de llengua! Assegurat|que no hi hagi cap carpeta «lang»|al costat de les partides desades normals." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Du hast das Geheimlabor gefunden!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="HERRSCHER DES UNIVERSUMS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Beende das Spiel im Keine-Tode-Modus" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Konnte {Pfad} nicht mounten: echtes Verzeichnis existiert nicht" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="FEHLER: Konnte nicht in den Sprachordner schreiben! Stelle sicher, dass es keinen &quot;lang&quot;-Ordner neben den regulären Spielständen gibt." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -753,6 +753,8 @@ You have found the secret lab!" translation="" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="" explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Vi trovis la sekretan labon!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="MAJSTRO DE L&apos; UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Kompletigi la ludon en mortula reĝimo" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Ne eblis munti {path}: vera dosierujo ne ekzistas" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERARO: Ne eblis skribi en lingvo-dosierujo! Certigu, ke ne estas dosierujo &quot;lang&quot; apud la normalaj konservaĵoj." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ You have found the secret lab!" translation="¡Enhorabuena!
<string english="MASTER OF THE UNIVERSE" translation="LÍDER DEL UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Completa el juego en el modo sin muerte" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="No se ha podido seguir {path}: El directorio real no existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: No se ha podido escribir en la carpeta de idioma. Comprueba que no haya una carpeta &quot;lang&quot; junto a los guardados normales." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -753,6 +753,8 @@ You have found the secret lab!" translation="Félicitations ! Vous avez trouvé
<string english="MASTER OF THE UNIVERSE" translation="MAÎTRE DE L&apos;UNIVERS" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Terminer le jeu en mode sans mort" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Impossible de monter {path} : le véritable dossier n&apos;existe pas" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERREUR : impossible d&apos;écrire dans le dossier de langue ! Assurez-vous qu&apos;il n&apos;y ait pas de dossier « lang » à côté des sauvegardes standard." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Hai trovato il laboratorio segreto!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="DOMINATORE DELL&apos;UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Completa il gioco in modalità Una vita" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Impossibile installare {path}: la directory reale non esiste" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRORE: impossibile scrivere sulla cartella lingua! Assicurati che non ci sia una cartella &quot;lang&quot; insieme ai normali salvataggi." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -760,6 +760,8 @@ Je hebt het geheime lab gevonden!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="MEESTER VAN HET UNIVERSUM" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Voltooi het spel in de éénlevenmodus" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Kon {path} niet aankoppelen: echte map bestaat niet" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERROR: Kan niet schrijven naar talenmap! Zorg dat er geen &quot;lang&quot;-map naast de normale opgeslagen bestanden staat." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Você encontrou o laboratório secreto!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="MESTRE DO UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Complete o jogo no modo sem mortes" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Não foi possível montar {path}: o diretório real não existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRO: não foi possível gravar na pasta do idioma! Não pode ter &quot;lang&quot; ao lado dos salvamentos comuns." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Encontraste o laboratório secreto!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="MESTRE DO UNIVERSO" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Conclui o jogo em Imortal." explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Não foi possível montar {path}: o diretório não existe" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ERRO: Não foi possível escrever na pasta de idioma! Certifica-te de que não há uma pasta &apos;&apos;lang&apos;&apos; junto dos dados guardados." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ You have found the secret lab!" translation="Поздравляем!
<string english="MASTER OF THE UNIVERSE" translation="ВЛАСТЕЛИН ВСЕЛЕННОЙ" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Пройдите игру в режиме &quot;не умирая&quot;" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="Не удалось монтировать {path}: настоящего каталога по данному пути не существует" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="ОШИБКА: Не удалось записать данные в папку локализации! Убедитесь, что рядом с обычными сохранениями нет папки &quot;lang&quot;." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -759,6 +759,8 @@ Gizli laboratuvarı buldun!" explanation="" max="34*4"/>
<string english="MASTER OF THE UNIVERSE" translation="EVRENİN USTASI" explanation="achievement/trophy title - no death mode complete" max="38*2"/>
<string english="Complete the game in no death mode" translation="Oyunu ölümsüz modunda tamamla" explanation="achievement/trophy description" max="38*2"/>
<string english="Could not mount {path}: real directory doesn&apos;t exist" translation="{path} bağlanamadı: gerçek klasör yok" explanation="mount: link/attach a directory (folder) in the filesystem into the game&apos;s filesystem so we can access it" max="38*6"/>
<string english="Level {path} not found" translation="" explanation="" max="38*6"/>
<string english="Error parsing {path}: {error}" translation="" explanation="we tried to parse the level file, but failed" max="38*6"/>
<string english="ERROR: Could not write to language folder! Make sure there is no &quot;lang&quot; folder next to the regular saves." translation="HATA: Dil klasörüne yazılamadı! Normal kayıt dosyalarının yanında &quot;lang&quot; adlı bir klasör olmadığından emin ol." explanation="" max="38*5"/>
<string english="" translation="" explanation=""/>
<string english="" translation="" explanation=""/>

View file

@ -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;
}

View file

@ -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

View file

@ -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);