mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- merged string table and system callbacks.
This commit is contained in:
parent
5d76cbcbdb
commit
7f6b02c451
5 changed files with 12 additions and 28 deletions
|
@ -22,6 +22,8 @@ struct SystemCallbacks
|
|||
void (*MenuDim)();
|
||||
FString(*GetPlayerName)(int i);
|
||||
bool (*DispatchEvent)(event_t* ev);
|
||||
bool (*CheckGame)(const char* nm);
|
||||
int (*GetGender)();
|
||||
};
|
||||
|
||||
extern SystemCallbacks sysCallbacks;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "filesystem.h"
|
||||
#include "sc_man.h"
|
||||
#include "printf.h"
|
||||
#include "i_interface.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -237,12 +238,12 @@ bool FStringTable::ParseLanguageCSV(int lumpnum, const TArray<uint8_t> &buffer)
|
|||
if (filterstr.IsNotEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
if (callbacks && callbacks->ValidFilter)
|
||||
if (sysCallbacks.CheckGame)
|
||||
{
|
||||
auto filter = filterstr.Split(" ", FString::TOK_SKIPEMPTY);
|
||||
for (auto& entry : filter)
|
||||
{
|
||||
if (callbacks->ValidFilter(entry))
|
||||
if (sysCallbacks.CheckGame(entry))
|
||||
{
|
||||
ok = true;
|
||||
break;
|
||||
|
@ -356,7 +357,7 @@ void FStringTable::LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer)
|
|||
sc.MustGetStringName("ifgame");
|
||||
sc.MustGetStringName("(");
|
||||
sc.MustGetString();
|
||||
skip |= (!callbacks || !callbacks->ValidFilter || !callbacks->ValidFilter(sc.String));
|
||||
skip |= (!sysCallbacks.CheckGame || !sysCallbacks.CheckGame(sc.String));
|
||||
sc.MustGetStringName(")");
|
||||
sc.MustGetString();
|
||||
|
||||
|
@ -564,7 +565,7 @@ const char *FStringTable::GetString(const char *name, uint32_t *langtable, int g
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (gender == -1 && callbacks && callbacks->GetPlayerGender) gender = callbacks->GetPlayerGender();
|
||||
if (gender == -1 && sysCallbacks.GetGender) gender = sysCallbacks.GetGender();
|
||||
if (gender < 0 || gender > 3) gender = 0;
|
||||
FName nm(name, true);
|
||||
if (nm != NAME_None)
|
||||
|
@ -597,7 +598,7 @@ const char *FStringTable::GetLanguageString(const char *name, uint32_t langtable
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (gender == -1 && callbacks && callbacks->GetPlayerGender) gender = callbacks->GetPlayerGender();
|
||||
if (gender == -1 && sysCallbacks.GetGender) gender = sysCallbacks.GetGender();
|
||||
if (gender < 0 || gender > 3) gender = 0;
|
||||
FName nm(name, true);
|
||||
if (nm != NAME_None)
|
||||
|
|
|
@ -50,13 +50,6 @@
|
|||
#include "name.h"
|
||||
|
||||
|
||||
struct StringtableCallbacks
|
||||
{
|
||||
// These two functions would create a dependency on the game code so they are installed as callbacks.
|
||||
bool (*ValidFilter)(const char* str);
|
||||
int (*GetPlayerGender)();
|
||||
};
|
||||
|
||||
struct TableElement
|
||||
{
|
||||
int filenum;
|
||||
|
@ -108,7 +101,6 @@ public:
|
|||
return GetString(name, nullptr);
|
||||
}
|
||||
bool exists(const char *name);
|
||||
void SetCallbacks(StringtableCallbacks* cb) { callbacks = cb; }
|
||||
|
||||
void InsertString(int lumpnum, int langid, FName label, const FString& string);
|
||||
|
||||
|
@ -118,8 +110,7 @@ private:
|
|||
StringMacroMap allMacros;
|
||||
LangMap allStrings;
|
||||
TArray<std::pair<uint32_t, StringMap*>> currentLanguageSet;
|
||||
StringtableCallbacks* callbacks = nullptr;
|
||||
|
||||
|
||||
void LoadLanguage (int lumpnum, const TArray<uint8_t> &buffer);
|
||||
TArray<TArray<FString>> parseCSV(const TArray<uint8_t> &buffer);
|
||||
bool ParseLanguageCSV(int lumpnum, const TArray<uint8_t> &buffer);
|
||||
|
|
|
@ -159,12 +159,6 @@ int StrTable_GetGender()
|
|||
|
||||
bool validFilter(const char* str);
|
||||
|
||||
static StringtableCallbacks stblcb =
|
||||
{
|
||||
validFilter,
|
||||
StrTable_GetGender
|
||||
};
|
||||
|
||||
extern int chatmodeon;
|
||||
|
||||
bool System_WantGuiCapture()
|
||||
|
@ -516,6 +510,8 @@ int GameMain()
|
|||
nullptr,
|
||||
nullptr,
|
||||
System_DispatchEvent,
|
||||
validFilter,
|
||||
StrTable_GetGender,
|
||||
};
|
||||
|
||||
try
|
||||
|
|
|
@ -175,13 +175,7 @@ FTextureID GetMenuTexture(const char* const name)
|
|||
static void SkipSubBlock(FScanner &sc)
|
||||
{
|
||||
sc.MustGetStringName("{");
|
||||
int depth = 1;
|
||||
while (depth > 0)
|
||||
{
|
||||
sc.MustGetString();
|
||||
if (sc.Compare("{")) depth++;
|
||||
if (sc.Compare("}")) depth--;
|
||||
}
|
||||
sc.SkipToEndOfBlock();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
Loading…
Reference in a new issue