diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index fc6cfa92..b35982f3 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -346,6 +347,41 @@ static PHYSFS_EnumerateCallbackResult zipCheckCallback( 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 * be named LEVELNAME.vvvvvv, else its custom assets won't work; * if there are .vvvvvv files other than LEVELNAME.vvvvvv, they would be loaded @@ -420,9 +456,8 @@ static bool checkZipStructure(const char* filename) /* If no .vvvvvv files in zip, don't print warning. */ if (!success && zip_state.has_extension) { - /* FIXME: How do we print this for non-terminal users? */ - printf( - "%s.zip is not structured correctly! It is missing %s.vvvvvv.\n", + setLevelDirError( + "%s.zip is not structured correctly! It is missing %s.vvvvvv.", base_name, base_name ); @@ -434,9 +469,8 @@ static bool checkZipStructure(const char* filename) /* This message is redundant if the correct file already DOESN'T exist. */ if (file_exists && zip_state.other_level_files) { - /* FIXME: How do we print this for non-terminal users? */ - printf( - "%s.zip is not structured correctly! It has .vvvvvv file(s) other than %s.vvvvvv.\n", + setLevelDirError( + "%s.zip is not structured correctly! It has .vvvvvv file(s) other than %s.vvvvvv.", base_name, base_name ); @@ -872,7 +906,9 @@ static PHYSFS_EnumerateCallbackResult enumerateCallback( void FILESYSTEM_enumerateLevelDirFileNames( void (*callback)(const char* filename) ) { - int success = PHYSFS_enumerate("levels", enumerateCallback, (void*) callback); + int success; + + success = PHYSFS_enumerate("levels", enumerateCallback, (void*) callback); if (success == 0) { diff --git a/desktop_version/src/FileSystemUtils.h b/desktop_version/src/FileSystemUtils.h index 6bb90fb3..c0269ce1 100644 --- a/desktop_version/src/FileSystemUtils.h +++ b/desktop_version/src/FileSystemUtils.h @@ -40,6 +40,10 @@ bool FILESYSTEM_loadTiXml2Document(const char *name, tinyxml2::XMLDocument& doc) void FILESYSTEM_enumerateLevelDirFileNames(void (*callback)(const char* filename)); +bool FILESYSTEM_levelDirHasError(void); +void FILESYSTEM_clearLevelDirError(void); +const char* FILESYSTEM_getLevelDirError(void); + bool FILESYSTEM_openDirectoryEnabled(void); bool FILESYSTEM_openDirectory(const char *dname); diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 645f4d0d..d678f122 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6478,7 +6478,9 @@ void Game::createmenu( enum Menu::MenuName t, bool samemenu/*= false*/ ) menuyoff = 10; break; case Menu::errorloadinglevel: + case Menu::warninglevellist: option("ok"); + menuyoff = 50; break; } diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 7f7df630..1138343d 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -36,6 +36,7 @@ namespace Menu errornostart, errorsavingsettings, errorloadinglevel, + warninglevellist, graphicoptions, ed_settings, ed_desc, diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index db850484..53e2d5f0 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -492,6 +492,10 @@ static void menuactionpress(void) ed.getDirectoryData(); game.loadcustomlevelstats(); //Should only load a file if it's needed game.createmenu(Menu::levellist); + if (FILESYSTEM_levelDirHasError()) + { + game.createmenu(Menu::warninglevellist); + } map.nexttowercolour(); break; #if !defined(NO_EDITOR) @@ -1728,6 +1732,7 @@ static void menuactionpress(void) map.nexttowercolour(); break; case Menu::errorloadinglevel: + case Menu::warninglevellist: music.playef(11); game.returnmenu(); map.nexttowercolour(); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index b5267606..1f08eb3c 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1391,6 +1391,10 @@ static void menurender(void) graphics.bigprint(-1, 45, "ERROR", tr, tg, tb, true); graphics.PrintWrap(-1, 65, graphics.error, tr, tg, tb, true, 10, 304); break; + case Menu::warninglevellist: + graphics.bigprint(-1, 45, "WARNING", tr, tg, tb, true); + graphics.PrintWrap(-1, 65, FILESYSTEM_getLevelDirError(), tr, tg, tb, true, 10, 304); + break; default: break; } diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index d26f6357..907d7b7e 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -229,6 +229,8 @@ void editorclass::getDirectoryData(void) ListOfMetaData.clear(); + FILESYSTEM_clearLevelDirError(); + loadZips(); FILESYSTEM_enumerateLevelDirFileNames(levelMetaDataCallback);