diff --git a/src/c_console.cpp b/src/c_console.cpp index 493625bf9..42b6034f2 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -1332,6 +1332,14 @@ DEFINE_ACTION_FUNCTION(_Console, HideConsole) return 0; } +DEFINE_ACTION_FUNCTION(_Console, Printf) +{ + PARAM_PROLOGUE; + FString s = FStringFormat(param, defaultparam, numparam, ret, numret); + Printf("%s\n", s.GetChars()); + return 0; +} + static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) { int data1 = ev->data1; diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index ed9b0f29a..c79a76fb3 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -192,7 +192,7 @@ DEFINE_ACTION_FUNCTION(_CVar, GetFloat) { PARAM_SELF_STRUCT_PROLOGUE(FBaseCVar); auto v = self->GetGenericRep(CVAR_Float); - ACTION_RETURN_FLOAT(v.Int); + ACTION_RETURN_FLOAT(v.Float); } DEFINE_ACTION_FUNCTION(_CVar, GetString) diff --git a/src/cmdlib.cpp b/src/cmdlib.cpp index 266ef47be..f7fb94510 100644 --- a/src/cmdlib.cpp +++ b/src/cmdlib.cpp @@ -614,16 +614,16 @@ int strbin (char *str) case '6': case '7': c = 0; - for (i = 0; i < 3; i++) { - c <<= 3; + for (i = 0; i < 2; i++) + { + p++; if (*p >= '0' && *p <= '7') - c += *p-'0'; + c = (c << 3) + *p - '0'; else { p--; break; } - p++; } *str++ = c; break; @@ -717,16 +717,16 @@ FString strbin1 (const char *start) case '6': case '7': c = 0; - for (i = 0; i < 3; i++) { - c <<= 3; + for (i = 0; i < 2; i++) + { + p++; if (*p >= '0' && *p <= '7') - c += *p-'0'; + c = (c << 3) + *p - '0'; else { p--; break; } - p++; } result << c; break; diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 6b137d12a..a598a45e9 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -1402,7 +1402,7 @@ bool DMenuItemBase::GetValue(int i, int *pvalue) { IFVIRTUAL(DMenuItemBase, GetValue) { - VMValue params[] = { (DObject*)this }; + VMValue params[] = { (DObject*)this, i }; int retval[2]; VMReturn ret[2]; ret[0].IntAt(&retval[0]); ret[1].IntAt(&retval[1]); GlobalVMStack.Call(func, params, countof(params), ret, 2, nullptr); diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index ae35935f5..d4a1254d6 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -142,8 +142,6 @@ std2: 'true' { RET(TK_True); } 'false' { RET(TK_False); } 'none' { RET(TK_None); } - 'new' { RET(TK_New); } - 'instanceof' { RET(TK_InstanceOf); } 'auto' { RET(TK_Auto); } 'exec' { RET(TK_Exec); } 'property' { RET(TK_Property); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index 9f88e2242..0227dffa9 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -81,7 +81,6 @@ xx(TK_ForEach, "'foreach'") xx(TK_True, "'true'") xx(TK_False, "'false'") xx(TK_None, "'none'") -xx(TK_New, "'new'") xx(TK_InstanceOf, "'instanceof'") xx(TK_Auto, "'auto'") xx(TK_Exec, "'exec'") diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 1aa35895d..819cfd178 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -1009,7 +1009,7 @@ DEFINE_ACTION_FUNCTION(FStringStruct, Replace) return 0; } -static FString FStringFormat(VM_ARGS) +FString FStringFormat(VM_ARGS) { assert(param[0].Type == REGT_STRING); FString fmtstring = param[0].s().GetChars(); diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 36619ef5b..aa191c34e 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -1213,6 +1213,6 @@ class PFunction; VMFunction *FindVMFunction(PClass *cls, const char *name); #define DECLARE_VMFUNC(cls, name) static VMFunction *name; if (name == nullptr) name = FindVMFunction(RUNTIME_CLASS(cls), #name); - +FString FStringFormat(VM_ARGS); #endif diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index e7820583b..b7b356cca 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -219,6 +219,7 @@ struct Console native { native static void HideConsole(); native static void MidPrint(Font fontname, string textlabel, bool bold = false); + native static vararg void Printf(string fmt, ...); native static void DoCommand(String cmd); } diff --git a/wadsrc/static/zscript/menu/optionmenuitems.txt b/wadsrc/static/zscript/menu/optionmenuitems.txt index 7c482e3e9..61d8794ce 100644 --- a/wadsrc/static/zscript/menu/optionmenuitems.txt +++ b/wadsrc/static/zscript/menu/optionmenuitems.txt @@ -168,8 +168,7 @@ class OptionMenuItemSafeCommand : OptionMenuItemCommand String actionLabel = StringTable.localize(mLabel); String FullString; - FullString.Format("%s%s%s\n\n%s", TEXTCOLOR_WHITE, actionLabel, TEXTCOLOR_NORMAL, msg); - + FullString = String.Format("%s%s%s\n\n%s", TEXTCOLOR_WHITE, actionLabel, TEXTCOLOR_NORMAL, msg); Menu.StartMessage(FullString, 0); return true; } @@ -187,7 +186,7 @@ class OptionMenuItemOptionBase : OptionMenuItem Name mValues; // Entry in OptionValues table CVar mGrayCheck; int mCenter; - + const OP_VALUES = 0x11001; protected void Init(String label, Name command, Name values, CVar graycheck, int center) @@ -650,7 +649,7 @@ class OptionMenuSliderBase : OptionMenuItem private void DrawSlider (int x, int y, double min, double max, double cur, int fracdigits, int indent) { - String formater = String.format("%%.%f", fracdigits); // The format function cannot do the '%.*f' syntax. + String formater = String.format("%%.%df", fracdigits); // The format function cannot do the '%.*f' syntax. String textbuf; double range; int maxlen = 0; @@ -810,7 +809,7 @@ class OptionMenuItemColorPicker : OptionMenuItem { Super.Init(label, command); CVar cv = CVar.FindCVar(command); - if (cv != null && cv.GetRealType() == CVar.CVAR_Color) cv = null; + if (cv != null && cv.GetRealType() != CVar.CVAR_Color) cv = null; mCVar = cv; } @@ -823,7 +822,7 @@ class OptionMenuItemColorPicker : OptionMenuItem { int box_x = indent + CursorSpace(); int box_y = y + CleanYfac_1; - screen.Clear (box_x, box_y, box_x + 32*CleanXfac_1, box_y + OptionMenuSettings.mLinespacing*CleanYfac_1, -1, mCVar.GetInt() | 0xff000000); + screen.Clear (box_x, box_y, box_x + 32*CleanXfac_1, box_y + OptionMenuSettings.mLinespacing*CleanYfac_1, mCVar.GetInt() | 0xff000000); } return indent; } @@ -1102,7 +1101,6 @@ class OptionMenuItemTextField : OptionMenuFieldBase //Menu* input = new DTextEnterMenu (Menu.CurrentMenu, mEditName, sizeof mEditName, 2, fromcontroller); //M_ActivateMenu(input); - //OpenTextEnterMenu(mEditName, 2, fromcontroller); // needs a native workaround until menu creation is scriptable. return true; } else if (mkey == Menu.MKEY_Input)