- decoupled the string table from game implementation details.

Using callbacks now to query needed game state.
This commit is contained in:
Christoph Oelckers 2020-04-11 18:12:28 +02:00
commit b3c7b81893
6 changed files with 94 additions and 40 deletions

View file

@ -2539,6 +2539,7 @@ static const char *DoomButtons[] =
"moveup" };
CVAR(Bool, lookspring, true, CVAR_ARCHIVE); // Generate centerview when -mlook encountered?
EXTERN_CVAR(String, language)
void Mlook_ReleaseHandler()
{
@ -2548,6 +2549,17 @@ void Mlook_ReleaseHandler()
}
}
int StrTable_GetGender()
{
return players[consoleplayer].userinfo.GetGender();
}
bool StrTable_ValidFilter(const char* str)
{
if (gameinfo.gametype == GAME_Strife && (gameinfo.flags & GI_SHAREWARE) && !stricmp(str, "strifeteaser")) return true;
return stricmp(str, GameNames[gameinfo.gametype]) == 0;
}
//==========================================================================
//
// D_DoomMain
@ -2570,7 +2582,12 @@ static int D_DoomMain_Internal (void)
buttonMap.GetButton(Button_Mlook)->bReleaseLock = true;
buttonMap.GetButton(Button_Klook)->bReleaseLock = true;
// button != &Button_Mlook && button != &Button_Klook)
static StringtableCallbacks stblcb =
{
StrTable_ValidFilter,
StrTable_GetGender
};
GStrings.SetCallbacks(&stblcb);
std::set_new_handler(NewFailure);
const char *batchout = Args->CheckValue("-errorlog");
@ -2778,7 +2795,7 @@ static int D_DoomMain_Internal (void)
}
// [RH] Initialize localizable strings.
GStrings.LoadStrings ();
GStrings.LoadStrings (language);
V_InitFontColors ();