mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move global language constants to single file
Deduplicate.
This commit is contained in:
parent
95cd34eb23
commit
0634261c18
@ -51,6 +51,7 @@
|
||||
#include "public/bspflags.h"
|
||||
#include "public/cmodel.h"
|
||||
#include "public/idebugoverlay.h"
|
||||
#include "public/localize/ilocalize.h"
|
||||
#ifndef CLIENT_DLL
|
||||
#include "game/server/detour_impl.h"
|
||||
#include "game/server/gameinterface.h"
|
||||
@ -1022,26 +1023,11 @@ void GFX_NVN_Changed_f(IConVar* pConVar, const char* pOldString, float flOldValu
|
||||
}
|
||||
#endif // !DEDICATED
|
||||
|
||||
|
||||
static const char* s_LanguageNames[] = {
|
||||
"english",
|
||||
"french",
|
||||
"german",
|
||||
"italian",
|
||||
"japanese",
|
||||
"polish",
|
||||
"russian",
|
||||
"spanish",
|
||||
"schinese",
|
||||
"tchinese",
|
||||
"korean"
|
||||
};
|
||||
|
||||
static bool IsValidTextLanguage(const char* pLocaleName)
|
||||
{
|
||||
for (int i = 0; i < SDK_ARRAYSIZE(s_LanguageNames); ++i)
|
||||
for (int i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); ++i)
|
||||
{
|
||||
if (strcmp(pLocaleName, s_LanguageNames[i]) == NULL)
|
||||
if (strcmp(pLocaleName, g_LanguageNames[i]) == NULL)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,4 +8,8 @@ add_sources( SOURCE_GROUP "Runtime"
|
||||
"localize.h"
|
||||
)
|
||||
|
||||
add_sources( SOURCE_GROUP "Public"
|
||||
"${ENGINE_SOURCE_DIR}/public/localize/ilocalize.h"
|
||||
)
|
||||
|
||||
end_sources()
|
||||
|
19
r5dev/public/localize/ilocalize.h
Normal file
19
r5dev/public/localize/ilocalize.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef LOCALIZE_H
|
||||
#define LOCALIZE_H
|
||||
|
||||
inline const char* const g_LanguageNames[] = {
|
||||
"english",
|
||||
"german",
|
||||
"french",
|
||||
"italian",
|
||||
"korean",
|
||||
"spanish",
|
||||
"schinese",
|
||||
"tchinese",
|
||||
"russian",
|
||||
"japanese",
|
||||
"portuguese",
|
||||
"polish",
|
||||
};
|
||||
|
||||
#endif // LOCALIZE_H
|
@ -32,6 +32,7 @@
|
||||
#include "mathlib/sha1.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "vpc/keyvalues.h"
|
||||
#include "localize/ilocalize.h"
|
||||
#include "vpklib/packedstore.h"
|
||||
|
||||
static const std::regex s_DirFileRegex{ R"((?:.*\/)?([^_]*_)(.*)(.bsp.pak000_dir).*)" };
|
||||
@ -794,9 +795,9 @@ VPKPair_t::VPKPair_t(const char* pLocale, const char* pTarget, const char* pLeve
|
||||
{
|
||||
bool bFoundLocale = false;
|
||||
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(DIR_LOCALE); i++)
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); i++)
|
||||
{
|
||||
if (V_strcmp(pLocale, DIR_LOCALE[i]) == NULL)
|
||||
if (V_strcmp(pLocale, g_LanguageNames[i]) == NULL)
|
||||
{
|
||||
bFoundLocale = true;
|
||||
}
|
||||
@ -804,8 +805,8 @@ VPKPair_t::VPKPair_t(const char* pLocale, const char* pTarget, const char* pLeve
|
||||
|
||||
if (!bFoundLocale)
|
||||
{
|
||||
Warning(eDLL_T::FS, "Locale '%s' not supported; using default '%s'\n", pLocale, DIR_LOCALE[0]);
|
||||
pLocale = DIR_LOCALE[0];
|
||||
Warning(eDLL_T::FS, "Locale '%s' not supported; using default '%s'\n", pLocale, g_LanguageNames[0]);
|
||||
pLocale = g_LanguageNames[0];
|
||||
}
|
||||
|
||||
bool bFoundTarget = false;
|
||||
@ -865,9 +866,9 @@ VPKDir_t::VPKDir_t(const CUtlString& dirFilePath, bool bSanitizeName)
|
||||
|
||||
bool bHasLocale = false;
|
||||
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(DIR_LOCALE); i++)
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); i++)
|
||||
{
|
||||
if (sanitizedName.Find(DIR_LOCALE[i]) != -1)
|
||||
if (sanitizedName.Find(g_LanguageNames[i]) != -1)
|
||||
{
|
||||
bHasLocale = true;
|
||||
break;
|
||||
@ -877,7 +878,7 @@ VPKDir_t::VPKDir_t(const CUtlString& dirFilePath, bool bSanitizeName)
|
||||
if (!bHasLocale) // Only sanitize if no locale was provided.
|
||||
{
|
||||
CUtlString packDirPrefix;
|
||||
packDirPrefix.Append(DIR_LOCALE[0]);
|
||||
packDirPrefix.Append(g_LanguageNames[0]);
|
||||
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(DIR_TARGET); i++)
|
||||
{
|
||||
@ -954,9 +955,9 @@ CUtlString VPKDir_t::StripLocalePrefix(const CUtlString& directoryPath) const
|
||||
{
|
||||
CUtlString fileName = directoryPath.UnqualifiedFilename();
|
||||
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(DIR_LOCALE); i++)
|
||||
for (size_t i = 0; i < SDK_ARRAYSIZE(g_LanguageNames); i++)
|
||||
{
|
||||
fileName = fileName.Replace(DIR_LOCALE[i], "");
|
||||
fileName = fileName.Replace(g_LanguageNames[i], "");
|
||||
}
|
||||
|
||||
return fileName;
|
||||
|
@ -29,20 +29,6 @@ static const char* const DIR_TARGET[]
|
||||
"server",
|
||||
"client"
|
||||
};
|
||||
static const char* const DIR_LOCALE[]
|
||||
{
|
||||
"english",
|
||||
"french",
|
||||
"german",
|
||||
"italian",
|
||||
"japanese",
|
||||
"korean",
|
||||
"polish",
|
||||
"portuguese",
|
||||
"russian",
|
||||
"spanish",
|
||||
"tchinese"
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// KeyValues structure for the VPK manifest file. This struct gets populated by
|
||||
|
Loading…
x
Reference in New Issue
Block a user