diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index 9412ed2df..7c1beb0c8 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -831,7 +831,7 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags) //========================================================================== template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha, bool scriptDifferences) +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha) { INTBOOL boolval; int intval; @@ -886,7 +886,6 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->scalex = parms->scaley = 1; parms->cellx = parms->celly = 0; parms->maxstrlen = INT_MAX; - parms->localize = scriptDifferences ? false : true; parms->virtBottom = false; parms->srcx = 0.; parms->srcy = 0.; @@ -1324,10 +1323,6 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double parms->maxstrlen = ListGetInt(tags); break; - case DTA_Localize: - parms->localize = ListGetInt(tags); - break; - case DTA_CellX: parms->cellx = ListGetInt(tags); break; @@ -1439,8 +1434,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double } // explicitly instantiate both versions for v_text.cpp. -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha, bool scriptDifferences); -template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha, bool scriptDifferences); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha); +template bool ParseDrawTextureTags(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, int type, PalEntry fill, double fillalpha); //========================================================================== // diff --git a/src/common/2d/v_draw.h b/src/common/2d/v_draw.h index c2503a543..686e5dc46 100644 --- a/src/common/2d/v_draw.h +++ b/src/common/2d/v_draw.h @@ -100,7 +100,6 @@ enum // For DrawText calls: DTA_TextLen, // stop after this many characters, even if \0 not hit - DTA_Localize, // localize text DTA_CellX, // horizontal size of character cell DTA_CellY, // vertical size of character cell @@ -195,7 +194,6 @@ struct DrawParms int monospace; int spacing; int maxstrlen; - bool localize; bool fortext; bool virtBottom; bool burn; @@ -268,7 +266,7 @@ enum }; template -bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, int type, PalEntry fill = ~0u, double fillalpha = 0.0, bool scriptDifferences = false); +bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, int type, PalEntry fill = ~0u, double fillalpha = 0.0); template void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); diff --git a/src/common/2d/v_drawtext.cpp b/src/common/2d/v_drawtext.cpp index ea760b4b6..2bdb64dca 100644 --- a/src/common/2d/v_drawtext.cpp +++ b/src/common/2d/v_drawtext.cpp @@ -380,7 +380,6 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double { return; } - const char *txt = (parms.localize && string[0] == '$') ? GStrings(&string[1]) : string; DrawTextCommon(drawer, font, normalcolor, x, y, (const uint8_t*)string, parms); } @@ -400,27 +399,24 @@ void DrawText(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double { return; } - // [Gutawer] right now nothing needs the char32_t version to have localisation support, and i don't know how to do it - assert(parms.localize == false); DrawTextCommon(drawer, font, normalcolor, x, y, string, parms); } -void DrawText(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double y, const FString& string, VMVa_List &args) +void DrawText(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double y, const char *string, VMVa_List &args) { DrawParms parms; - if (font == NULL) + if (font == NULL || string == NULL) return; uint32_t tag = ListGetInt(args); - bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, DrawTexture_Text, ~0u, 0.0, true); + bool res = ParseDrawTextureTags(drawer, nullptr, 0, 0, tag, args, &parms, DrawTexture_Text); if (!res) { return; } - const char *txt = (parms.localize && string[0] == '$') ? GStrings(&string[1]) : string.GetChars(); - DrawTextCommon(drawer, font, normalcolor, x, y, (uint8_t*)txt, parms); + DrawTextCommon(drawer, font, normalcolor, x, y, (const uint8_t*)string, parms); } DEFINE_ACTION_FUNCTION(_Screen, DrawText) @@ -436,7 +432,8 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawText) if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); VMVa_List args = { param + 5, 0, numparam - 6, va_reginfo + 5 }; - DrawText(twod, font, cr, x, y, chr, args); + const char *txt = chr[0] == '$' ? GStrings(&chr[1]) : chr.GetChars(); + DrawText(twod, font, cr, x, y, txt, args); return 0; } @@ -453,7 +450,8 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawText) PARAM_VA_POINTER(va_reginfo) // Get the hidden type information array VMVa_List args = { param + 6, 0, numparam - 7, va_reginfo + 6 }; - DrawText(&self->Drawer, font, cr, x, y, chr, args); + const char *txt = chr[0] == '$' ? GStrings(&chr[1]) : chr.GetChars(); + DrawText(&self->Drawer, font, cr, x, y, txt, args); self->Tex->NeedUpdate(); return 0; } diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 9b8da1d38..a29a6b711 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -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, bool localize) +static int StringWidth(FFont *font, const FString &str) { - const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); + const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); return font->StringWidth(txt); } @@ -641,13 +641,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, StringWidth, StringWidth) { PARAM_SELF_STRUCT_PROLOGUE(FFont); PARAM_STRING(str); - PARAM_BOOL(localize); - ACTION_RETURN_INT(StringWidth(self, str, localize)); + ACTION_RETURN_INT(StringWidth(self, str)); } -static int GetMaxAscender(FFont* font, const FString& str, bool localize) +static int GetMaxAscender(FFont* font, const FString& str) { - const char* txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); + const char* txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); return font->GetMaxAscender(txt); } @@ -655,13 +654,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetMaxAscender, GetMaxAscender) { PARAM_SELF_STRUCT_PROLOGUE(FFont); PARAM_STRING(str); - PARAM_BOOL(localize); - ACTION_RETURN_INT(GetMaxAscender(self, str, localize)); + ACTION_RETURN_INT(GetMaxAscender(self, str)); } -static int CanPrint(FFont *font, const FString &str, bool localize) +static int CanPrint(FFont *font, const FString &str) { - const char *txt = (localize && str[0] == '$') ? GStrings(&str[1]) : str.GetChars(); + const char *txt = str[0] == '$' ? GStrings(&str[1]) : str.GetChars(); return font->CanPrint(txt); } @@ -669,8 +667,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, CanPrint, CanPrint) { PARAM_SELF_STRUCT_PROLOGUE(FFont); PARAM_STRING(str); - PARAM_BOOL(localize); - ACTION_RETURN_INT(CanPrint(self, str, localize)); + ACTION_RETURN_INT(CanPrint(self, str)); } static int FindFontColor(int name) diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 0d615453d..cd2269661 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -429,7 +429,6 @@ enum DrawTextureTags // For DrawText calls only: DTA_TextLen, // stop after this many characters, even if \0 not hit - DTA_Localize, // localize drawn string DTA_CellX, // horizontal size of character cell DTA_CellY, // vertical size of character cell @@ -641,9 +640,9 @@ struct Font native // native Font(const Name name); native int GetCharWidth(int code); - native int StringWidth(String code, bool localize = true); - native int GetMaxAscender(String code, bool localize = true); - native bool CanPrint(String code, bool localize = true); + native int StringWidth(String code); + native int GetMaxAscender(String code); + native bool CanPrint(String code); native int GetHeight(); native int GetDisplacement(); native String GetCursor(); diff --git a/wadsrc/static/zscript/engine/ui/menu/menu.zs b/wadsrc/static/zscript/engine/ui/menu/menu.zs index 8d1060f56..181234808 100644 --- a/wadsrc/static/zscript/engine/ui/menu/menu.zs +++ b/wadsrc/static/zscript/engine/ui/menu/menu.zs @@ -346,16 +346,16 @@ class Menu : Object native ui version("2.4") return OptionFont().GetHeight(); } - static int OptionWidth(String s, bool localize = true) + static int OptionWidth(String s) { - return OptionFont().StringWidth(s, localize); + return OptionFont().StringWidth(s); } - static void DrawOptionText(int x, int y, int color, String text, bool grayed = false, bool localize = true) + static void DrawOptionText(int x, int y, int color, String text, bool grayed = false) { - String label = localize ? Stringtable.Localize(text) : text; + String label = Stringtable.Localize(text); int overlay = grayed? Color(96,48,0,0) : 0; - screen.DrawText (OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay, DTA_Localize, localize); + screen.DrawText (OptionFont(), color, x, y, text, DTA_CleanNoMove_1, true, DTA_ColorOverlay, overlay); } @@ -377,4 +377,4 @@ class GenericMenu : Menu { Super.Init(parent); } -} +} \ No newline at end of file diff --git a/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs b/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs index 53ef2d8e3..4733d5b3b 100644 --- a/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs +++ b/wadsrc/static/zscript/engine/ui/menu/optionmenuitems.zs @@ -61,9 +61,9 @@ class OptionMenuItem : MenuItemBase return x; } - protected void drawValue(int indent, int y, int color, String text, bool grayed = false, bool localize = true) + protected void drawValue(int indent, int y, int color, String text, bool grayed = false) { - Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed, localize); + Menu.DrawOptionText(indent + CursorSpace(), y, color, text, grayed); } @@ -999,7 +999,7 @@ class OptionMenuFieldBase : OptionMenuItem { bool grayed = mGrayCheck != null && !mGrayCheck.GetInt(); drawLabel(indent, y, selected ? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor, grayed); - drawValue(indent, y, OptionMenuSettings.mFontColorValue, Represent(), grayed, false); + drawValue(indent, y, OptionMenuSettings.mFontColorValue, Represent(), grayed); return indent; } @@ -1068,7 +1068,7 @@ class OptionMenuItemTextField : OptionMenuFieldBase { // reposition the text so that the cursor is visible when in entering mode. String text = Represent(); - int tlen = Menu.OptionWidth(text, false) * CleanXfac_1; + int tlen = Menu.OptionWidth(text) * CleanXfac_1; int newindent = screen.GetWidth() - tlen - CursorSpace(); if (newindent < indent) indent = newindent; } @@ -1295,4 +1295,4 @@ class OptionMenuItemFlagOption : OptionMenuItemOption } } } -} +} \ No newline at end of file