diff --git a/src/p_user.cpp b/src/p_user.cpp index 79f691ec0..0d69810d9 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -584,6 +584,14 @@ void EnumColorSets(PClassActor *cls, TArray *out) qsort(&(*out)[0], out->Size(), sizeof(int), intcmp); } +DEFINE_ACTION_FUNCTION(FPlayerClass, EnumColorSets) +{ + PARAM_SELF_STRUCT_PROLOGUE(FPlayerClass); + PARAM_POINTER(out, TArray); + EnumColorSets(self->Type, out); + return 0; +} + //========================================================================== // // @@ -603,6 +611,14 @@ FPlayerColorSet *GetColorSet(PClassActor *cls, int setnum) return nullptr; } +DEFINE_ACTION_FUNCTION(FPlayerClass, GetColorSetName) +{ + PARAM_SELF_STRUCT_PROLOGUE(FPlayerClass); + PARAM_INT(setnum); + auto p = GetColorSet(self->Type, setnum); + ACTION_RETURN_INT(p ? p->Name.GetIndex() : 0); +} + //========================================================================== // // @@ -667,6 +683,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetColor) ACTION_RETURN_INT(self->userinfo.GetColor()); } +DEFINE_ACTION_FUNCTION(_PlayerInfo, GetColorSet) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + ACTION_RETURN_INT(self->userinfo.GetColorSet()); +} + DEFINE_ACTION_FUNCTION(_PlayerInfo, GetPlayerClassNum) { PARAM_SELF_STRUCT_PROLOGUE(player_t); diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index a240c1973..c802dda36 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -1361,22 +1361,19 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n break; case AST_DynArrayType: - if (allowarraytypes) + { + auto atype = static_cast(ztype); + auto ftype = DetermineType(outertype, field, name, atype->ElementType, false, true); + if (ftype->GetRegType() == REGT_NIL || ftype->GetRegCount() > 1) { - auto atype = static_cast(ztype); - auto ftype = DetermineType(outertype, field, name, atype->ElementType, false, true); - if (ftype->GetRegType() == REGT_NIL || ftype->GetRegCount() > 1) - { - Error(field, "%s: Base type for dynamic array types nust be integral, but got %s", name.GetChars(), ftype->DescriptiveName()); - } - else - { - retval = NewDynArray(ftype); - } - break; + Error(field, "%s: Base type for dynamic array types nust be integral, but got %s", name.GetChars(), ftype->DescriptiveName()); + } + else + { + retval = NewDynArray(ftype); } break; - + } case AST_ClassType: { auto ctype = static_cast(ztype); @@ -2135,7 +2132,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool { auto type = DetermineType(c->Type(), p, f->Name, p->Type, false, false); int flags = 0; - if (type->IsA(RUNTIME_CLASS(PStruct)) && type != TypeVector2 && type != TypeVector3) + if ((type->IsA(RUNTIME_CLASS(PStruct)) && type != TypeVector2 && type != TypeVector3) || type->IsA(RUNTIME_CLASS(PDynArray))) { // Structs are being passed by pointer, but unless marked 'out' that pointer must be readonly. type = NewPointer(type /*, !(p->Flags & ZCC_Out)*/); diff --git a/wadsrc/static/zscript/menu/playermenu.txt b/wadsrc/static/zscript/menu/playermenu.txt index 4a6a94b2d..8c4c66f56 100644 --- a/wadsrc/static/zscript/menu/playermenu.txt +++ b/wadsrc/static/zscript/menu/playermenu.txt @@ -61,6 +61,40 @@ class PlayerMenu : ListMenu native // //============================================================================= + protected void UpdateColorsets() + { + let li = GetItem('Color'); + if (li != NULL) + { + int sel = 0; + mPlayerClass.EnumColorSets(PlayerColorSets); + li.SetString(0, "Custom"); + for(int i = 0; i < PlayerColorSets.Size(); i++) + { + let cname = mPlayerClass.GetColorSetName(PlayerColorSets[i]); + li.SetString(i+1, cname); + } + int mycolorset = players[consoleplayer].GetColorSet(); + if (mycolorset != -1) + { + for(int i = 0; i < PlayerColorSets.Size(); i++) + { + if (PlayerColorSets[i] == mycolorset) + { + sel = i + 1; + } + } + } + li.SetValue(0, sel); + } + } + + //============================================================================= + // + // + // + //============================================================================= + protected void UpdateSkins() { int sel = 0; @@ -101,7 +135,7 @@ class PlayerMenu : ListMenu native UpdateTranslation(); } -//============================================================================= + //============================================================================= // // // diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index 9203dee0e..f7333220b 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -313,10 +313,10 @@ usercmd_t original_cmd; native String GetUserName(); native Color GetColor(); + native int GetColorSet(); native int GetPlayerClassNum(); native int GetSkin(); native bool GetNeverSwitch(); - } struct PlayerClass native @@ -326,6 +326,8 @@ struct PlayerClass native native Array Skins; native bool CheckSkin(int skin); + native void EnumColorsets(out Array data); + native Name GetColorsetName(int setnum); } struct PlayerSkin native