- add support for not localizing some text functions, and modify menu text fields to use this

This commit is contained in:
Gutawer 2022-11-25 13:50:34 +00:00 committed by Christoph Oelckers
commit 91d3c4b606
7 changed files with 48 additions and 35 deletions

View file

@ -631,9 +631,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetBottomAlignOffset, GetBottomAlignOffset)
ACTION_RETURN_FLOAT(GetBottomAlignOffset(self, code));
}
static int StringWidth(FFont *font, const FString &str)
static int StringWidth(FFont *font, const FString &str, bool localize)
{
const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars();
const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->StringWidth(txt);
}
@ -641,12 +641,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, StringWidth, StringWidth)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_STRING(str);
ACTION_RETURN_INT(StringWidth(self, str));
PARAM_BOOL(localize);
ACTION_RETURN_INT(StringWidth(self, str, localize));
}
static int GetMaxAscender(FFont* font, const FString& str)
static int GetMaxAscender(FFont* font, const FString& str, bool localize)
{
const char* txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars();
const char* txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->GetMaxAscender(txt);
}
@ -654,12 +655,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetMaxAscender, GetMaxAscender)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_STRING(str);
ACTION_RETURN_INT(GetMaxAscender(self, str));
PARAM_BOOL(localize);
ACTION_RETURN_INT(GetMaxAscender(self, str, localize));
}
static int CanPrint(FFont *font, const FString &str)
static int CanPrint(FFont *font, const FString &str, bool localize)
{
const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars();
const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars();
return font->CanPrint(txt);
}
@ -667,7 +669,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, CanPrint, CanPrint)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
PARAM_STRING(str);
ACTION_RETURN_INT(CanPrint(self, str));
PARAM_BOOL(localize);
ACTION_RETURN_INT(CanPrint(self, str, localize));
}
static int FindFontColor(int name)