mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- scriptified UpdateColorsets.
This commit is contained in:
parent
97eed1e6df
commit
50d2846e40
4 changed files with 71 additions and 16 deletions
|
@ -584,6 +584,14 @@ void EnumColorSets(PClassActor *cls, TArray<int> *out)
|
|||
qsort(&(*out)[0], out->Size(), sizeof(int), intcmp);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FPlayerClass, EnumColorSets)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FPlayerClass);
|
||||
PARAM_POINTER(out, TArray<int>);
|
||||
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);
|
||||
|
|
|
@ -1361,22 +1361,19 @@ PType *ZCCCompiler::DetermineType(PType *outertype, ZCC_TreeNode *field, FName n
|
|||
break;
|
||||
|
||||
case AST_DynArrayType:
|
||||
if (allowarraytypes)
|
||||
{
|
||||
auto atype = static_cast<ZCC_DynArrayType *>(ztype);
|
||||
auto ftype = DetermineType(outertype, field, name, atype->ElementType, false, true);
|
||||
if (ftype->GetRegType() == REGT_NIL || ftype->GetRegCount() > 1)
|
||||
{
|
||||
auto atype = static_cast<ZCC_DynArrayType *>(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<ZCC_ClassType *>(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)*/);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
|
|
|
@ -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<int> Skins;
|
||||
|
||||
native bool CheckSkin(int skin);
|
||||
native void EnumColorsets(out Array<int> data);
|
||||
native Name GetColorsetName(int setnum);
|
||||
}
|
||||
|
||||
struct PlayerSkin native
|
||||
|
|
Loading…
Reference in a new issue