1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-24 13:38:29 +02:00

Add warning messages for missing fonts/lang folders

If someone makes a build of the game without copying the correct
folders, their version will have no translations, and display some text
wrong (like credits or button glyphs, or any custom levels that rely on
characters in the fonts being there). So I added a message in the
bottom left corner of the title screen to warn for that.
This commit is contained in:
Dav999 2023-08-30 16:45:04 +02:00 committed by Misa Elizabeth Kai
parent da13f39f5d
commit fd84922a92
3 changed files with 48 additions and 10 deletions

View File

@ -50,6 +50,8 @@ static char saveDir[MAX_PATH] = {'\0'};
static char levelDir[MAX_PATH] = {'\0'};
static char mainLangDir[MAX_PATH] = {'\0'};
static bool isMainLangDirFromRepo = false;
static bool doesLangDirExist = false;
static bool doesFontsDirExist = false;
static char assetDir[MAX_PATH] = {'\0'};
static char virtualMountPath[MAX_PATH] = {'\0'};
@ -74,7 +76,7 @@ static const PHYSFS_Allocator allocator = {
SDL_free
};
static void mount_pre_datazip(
static bool mount_pre_datazip(
char* out_path,
const char* real_dirname,
const char* mount_point,
@ -95,12 +97,11 @@ static void mount_pre_datazip(
{
SDL_strlcpy(out_path, user_path, MAX_PATH);
}
return true;
}
else
{
vlog_warn("User-supplied %s directory is invalid!", real_dirname);
}
return;
vlog_warn("User-supplied %s directory is invalid!", real_dirname);
return false;
}
/* Try to detect the directory, it's next to data.zip in distributed builds */
@ -170,6 +171,8 @@ static void mount_pre_datazip(
{
vlog_warn("Cannot find the %s directory anywhere!", real_dirname);
}
return dir_found;
}
int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langDir, char* fontsDir)
@ -255,10 +258,10 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath, char* langD
basePath = SDL_strdup("./");
}
mount_pre_datazip(mainLangDir, "lang", "lang/", langDir);
doesLangDirExist = mount_pre_datazip(mainLangDir, "lang", "lang/", langDir);
vlog_info("Languages directory: %s", mainLangDir);
mount_pre_datazip(NULL, "fonts", "graphics/", fontsDir);
doesFontsDirExist = mount_pre_datazip(NULL, "fonts", "graphics/", fontsDir);
/* Mount the stock content last */
if (assetsPath)
@ -339,6 +342,16 @@ bool FILESYSTEM_isMainLangDirFromRepo(void)
return isMainLangDirFromRepo;
}
bool FILESYSTEM_doesLangDirExist(void)
{
return doesLangDirExist;
}
bool FILESYSTEM_doesFontsDirExist(void)
{
return doesFontsDirExist;
}
bool FILESYSTEM_restoreWriteDir(void)
{
return PHYSFS_setWriteDir(writeDir);

View File

@ -17,6 +17,8 @@ char *FILESYSTEM_getUserSaveDirectory(void);
char *FILESYSTEM_getUserLevelDirectory(void);
char *FILESYSTEM_getUserMainLangDirectory(void);
bool FILESYSTEM_isMainLangDirFromRepo(void);
bool FILESYSTEM_doesLangDirExist(void);
bool FILESYSTEM_doesFontsDirExist(void);
bool FILESYSTEM_setLangWriteDir(void);
bool FILESYSTEM_restoreWriteDir(void);

View File

@ -220,8 +220,31 @@ static void menurender(void)
#endif
font::print(PR_RIGHT, 310, 230, RELEASE_VERSION, tr/2, tg/2, tb/2);
if(music.mmmmmm){
font::print(0, 10, 230, loc::gettext("[MMMMMM Mod Installed]"), tr/2, tg/2, tb/2);
const char* left_msg = NULL;
const bool fonts_error = !FILESYSTEM_doesFontsDirExist();
const bool lang_error = !FILESYSTEM_doesLangDirExist();
if (fonts_error && lang_error)
{
left_msg = "[No fonts&lang folders]";
}
else if (fonts_error)
{
left_msg = "[No fonts folder]";
}
else if (lang_error)
{
left_msg = "[No lang folder]";
}
else if (music.mmmmmm)
{
left_msg = loc::gettext("[MMMMMM Mod Installed]");
}
if (left_msg != NULL)
{
font::print(0, 10, 230, left_msg, tr/2, tg/2, tb/2);
}
break;
}