diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 421ef6ae5..9c36f0e49 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -53,6 +53,7 @@ #include "vm.h" #include "p_checkposition.h" #include "r_sky.h" +#include "v_font.h" static TArray properties; static TArray AFTable; @@ -801,34 +802,51 @@ void InitThingdef() pstruct->Size = sizeof(player_t); pstruct->Align = alignof(player_t); PArray *parray = NewArray(pstruct, MAXPLAYERS); - PField *playerf = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + PField *fieldptr = new PField("players", parray, VARF_Native | VARF_Static, (intptr_t)&players); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); pstruct->AddNativeField("weapons", NewNativeStruct("WeaponSlots", nullptr), myoffsetof(player_t, weapons), VARF_Native); parray = NewArray(TypeBool, MAXPLAYERS); - playerf = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("playeringame", parray, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&playeringame); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); - playerf = new PField("gameaction", TypeUInt8, VARF_Native | VARF_Static, (intptr_t)&gameaction); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("gameaction", TypeUInt8, VARF_Native | VARF_Static, (intptr_t)&gameaction); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); - playerf = new PField("skyflatnum", TypeTextureID, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&skyflatnum); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("skyflatnum", TypeTextureID, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&skyflatnum); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); - playerf = new PField("globalfreeze", TypeUInt8, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&bglobal.freeze); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("globalfreeze", TypeUInt8, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&bglobal.freeze); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); - playerf = new PField("consoleplayer", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&consoleplayer); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("consoleplayer", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&consoleplayer); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + + auto fontptr = NewPointer(NewNativeStruct("Font", nullptr)); + + fieldptr = new PField("smallfont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&SmallFont); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + + fieldptr = new PField("smallfont2", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&SmallFont2); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + + fieldptr = new PField("bigfont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&BigFont); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + + fieldptr = new PField("confont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&ConFont); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + + fieldptr = new PField("intermissionfont", fontptr, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&IntermissionFont); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); // Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag. // It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution' // is to create a static variable from it and reference that in the script. Yuck!!! static AWeapon *wpnochg = WP_NOCHANGE; - playerf = new PField("WP_NOCHANGE", NewPointer(RUNTIME_CLASS(AWeapon), false), VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&wpnochg); - Namespaces.GlobalNamespace->Symbols.AddSymbol(playerf); + fieldptr = new PField("WP_NOCHANGE", NewPointer(RUNTIME_CLASS(AWeapon), false), VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&wpnochg); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); // synthesize a symbol for each flag from the flag name tables to avoid redundant declaration of them. for (auto &fl : FlagLists) diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 9db885efb..cf1e4c688 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -91,6 +91,17 @@ CVAR (Bool, hud_scale, true, CVAR_ARCHIVE); static int LastPal = -1; static uint32 LastRGB; +DEFINE_ACTION_FUNCTION(_Screen, GetWidth) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(screen->GetWidth()); +} + +DEFINE_ACTION_FUNCTION(_Screen, GetHeight) +{ + PARAM_PROLOGUE; + ACTION_RETURN_INT(screen->GetHeight()); +} static int PalFromRGB(uint32 rgb) { diff --git a/src/v_font.cpp b/src/v_font.cpp index f024e2d2b..2854be8c2 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -525,6 +525,13 @@ FFont *FFont::FindFont (const char *name) return font; } +DEFINE_ACTION_FUNCTION(FFont, FindFont) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + ACTION_RETURN_POINTER(FFont::FindFont(name)); +} + //========================================================================== // // RecordTextureColors diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 73909e83d..b84d72a51 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -63,9 +63,16 @@ struct Screen native NUM_TEXT_COLORS }; + native static int GetWidth(); + native static int GetHeight(); native static void DrawHUDTexture(TextureID tex, double x, double y); } +struct Font native +{ + native static Font FindFont(String name); +} + struct Console native { native static void HideConsole();