diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index ec2d76a5c..ac4732329 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -597,5 +597,5 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, AlwaysRunChanged) DEFINE_FIELD(DPlayerMenu, mRotation) DEFINE_FIELD_NAMED(DPlayerMenu, PlayerClass, mPlayerClass) DEFINE_FIELD(DPlayerMenu, PlayerColorSets) -DEFINE_FIELD(DPlayerMenu, PlayerSkins) +DEFINE_FIELD_NAMED(DPlayerMenu, PlayerSkins, mPlayerSkins) DEFINE_FIELD(DPlayerMenu, PlayerClassIndex) diff --git a/src/p_user.cpp b/src/p_user.cpp index bd6b2be4e..79f691ec0 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -673,6 +673,11 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetPlayerClassNum) ACTION_RETURN_INT(self->userinfo.GetPlayerClassNum()); } +DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkin) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + ACTION_RETURN_INT(self->userinfo.GetSkin()); +} //=========================================================================== // diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 72199cece..45167580f 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -992,7 +992,7 @@ void R_InitSprites () } -DEFINE_FIELD(FPlayerSkin, Name); +DEFINE_FIELD_NAMED(FPlayerSkin, Name, SkinName); DEFINE_FIELD(FPlayerSkin, Face); DEFINE_FIELD(FPlayerSkin, gender); DEFINE_FIELD(FPlayerSkin, range0start); diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index c9679c4b2..3550a78c9 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -804,7 +804,7 @@ void InitThingdef() Namespaces.GlobalNamespace->Symbols.AddSymbol(plrclsf); auto plrskn = NewPointer(NewResizableArray(playerskinstruct), false); - PField *plrsknf = new PField("PlayerSkins", plrcls, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&Skins); + PField *plrsknf = new PField("PlayerSkins", plrskn, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&Skins); Namespaces.GlobalNamespace->Symbols.AddSymbol(plrsknf); auto bindcls = NewNativeStruct("KeyBindings", nullptr); diff --git a/wadsrc/static/zscript/menu/playermenu.txt b/wadsrc/static/zscript/menu/playermenu.txt index 0ac5328a0..4a6a94b2d 100644 --- a/wadsrc/static/zscript/menu/playermenu.txt +++ b/wadsrc/static/zscript/menu/playermenu.txt @@ -5,7 +5,7 @@ class PlayerMenu : ListMenu native native int PlayerClassIndex; native PlayerClass mPlayerClass; native Array PlayerColorSets; - native Array PlayerSkins; + native Array mPlayerSkins; // All write function for the player config are native to prevent abuse. protected native void AutoaimChanged(float val); @@ -61,6 +61,52 @@ class PlayerMenu : ListMenu native // //============================================================================= + protected void UpdateSkins() + { + int sel = 0; + int skin; + let li = GetItem('Skin'); + if (li != NULL) + { + if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1) + { + li.SetString(0, "Base"); + li.SetValue(0, 0); + skin = 0; + } + else + { + mPlayerSkins.Clear(); + for (int i = 0; i < PlayerSkins.Size(); i++) + { + if (mPlayerClass.CheckSkin(i)) + { + int j = mPlayerSkins.Push(i); + li.SetString(j, PlayerSkins[i].SkinName); + if (players[consoleplayer].GetSkin() == i) + { + sel = j; + } + } + } + li.SetValue(0, sel); + skin = mPlayerSkins[sel]; + } + li = GetItem('Playerdisplay'); + if (li != NULL) + { + li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, skin); + } + } + UpdateTranslation(); + } + +//============================================================================= + // + // + // + //============================================================================= + protected void ChangeSkin (MenuItemBase li) { if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1) @@ -74,7 +120,7 @@ class PlayerMenu : ListMenu native [res, sel] = li.GetValue(0); if (res) { - sel = PlayerSkins[sel]; + sel = mPlayerSkins[sel]; SkinChanged(sel); UpdateTranslation(); diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index ab3019dcd..9203dee0e 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -295,7 +295,6 @@ struct PlayerInfo native // this is what internally is known as player_t /* these are not doable yet ticcmd_t cmd; usercmd_t original_cmd; -userinfo_t userinfo; */ @@ -309,13 +308,15 @@ userinfo_t userinfo; native PSprite FindPSprite(int id); native void SetLogNumber (int text); native void SetLogText (String text); - native String GetUserName(); - native Color GetColor(); - native int GetPlayerClassNum(); - native bool GetNeverSwitch(); native void DropWeapon(); native void BringUpWeapon(); + native String GetUserName(); + native Color GetColor(); + native int GetPlayerClassNum(); + native int GetSkin(); + native bool GetNeverSwitch(); + } struct PlayerClass native @@ -329,7 +330,7 @@ struct PlayerClass native struct PlayerSkin native { - native readonly String Name; + native readonly String SkinName; native readonly String Face; native readonly uint8 gender; native readonly uint8 range0start;