- scriptified UpdateSkins.

This commit is contained in:
Christoph Oelckers 2017-02-17 22:12:56 +01:00
parent 498da825a5
commit 97eed1e6df
6 changed files with 63 additions and 11 deletions

View File

@ -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)

View File

@ -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());
}
//===========================================================================
//

View File

@ -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);

View File

@ -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);

View File

@ -5,7 +5,7 @@ class PlayerMenu : ListMenu native
native int PlayerClassIndex;
native PlayerClass mPlayerClass;
native Array<int> PlayerColorSets;
native Array<int> PlayerSkins;
native Array<int> 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();

View File

@ -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;