- scriptified DPlayerMenu::SkinChanged.

This commit is contained in:
Christoph Oelckers 2017-02-17 20:49:04 +01:00
parent 51493cde8c
commit b375657509
4 changed files with 46 additions and 29 deletions

View file

@ -499,42 +499,17 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ClassChanged)
//
//=============================================================================
void DPlayerMenu::SkinChanged (DMenuItemBase *li)
{
if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN ||
players[consoleplayer].userinfo.GetPlayerClassNum() == -1)
{
return;
}
int sel;
if (li->GetValue(0, &sel))
{
sel = PlayerSkins[sel];
players[consoleplayer].userinfo.SkinNumChanged(sel);
UpdateTranslation();
li = GetItem(NAME_Playerdisplay);
if (li != NULL)
{
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, sel);
}
}
}
DEFINE_ACTION_FUNCTION(DPlayerMenu, SkinChanged)
{
PARAM_SELF_PROLOGUE(DPlayerMenu);
PARAM_OBJECT(sel, DMenuItemBase);
PARAM_INT(sel);
if (self == DMenu::CurrentMenu)
{
self->SkinChanged(sel);
players[consoleplayer].userinfo.SkinNumChanged(sel);
}
return 0;
}
//=============================================================================
//
//
@ -629,3 +604,4 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, AlwaysRunChanged)
DEFINE_FIELD(DPlayerMenu, mRotation)
DEFINE_FIELD_NAMED(DPlayerMenu, PlayerClass, mPlayerClass)
DEFINE_FIELD(DPlayerMenu, PlayerColorSets)
DEFINE_FIELD(DPlayerMenu, PlayerSkins)

View file

@ -667,6 +667,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetColor)
ACTION_RETURN_INT(self->userinfo.GetColor());
}
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetPlayerClassNum)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
ACTION_RETURN_INT(self->userinfo.GetPlayerClassNum());
}
//===========================================================================
//

View file

@ -4,6 +4,7 @@ class PlayerMenu : ListMenu native
native int mRotation;
native PlayerClass mPlayerClass;
native Array<int> PlayerColorSets;
native Array<int> PlayerSkins;
// All write function for the player config are native to prevent abuse.
protected native void AutoaimChanged(float val);
@ -14,9 +15,9 @@ class PlayerMenu : ListMenu native
protected native void ColorChanged(int red, int green, int blue);
protected native void ColorSetChanged(int red);
protected native void PlayerNameChanged(String name);
protected native void SkinChanged (int val);
protected native void ClassChanged(ListMenuItem it);
protected native void SkinChanged (ListMenuItem li);
protected void UpdateTranslation()
{
@ -29,6 +30,39 @@ class PlayerMenu : ListMenu native
UpdateTranslation();
}
//=============================================================================
//
//
//
//=============================================================================
protected void ChangeSkin (MenuItemBase li)
{
if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1)
{
return;
}
bool res;
int sel;
[res, sel] = li.GetValue(0);
if (res)
{
sel = PlayerSkins[sel];
SkinChanged(sel);
UpdateTranslation();
li = GetItem('Playerdisplay');
if (li != NULL)
{
li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, sel);
}
}
}
//=============================================================================
//
//
@ -121,7 +155,7 @@ class PlayerMenu : ListMenu native
break;
case 'Skin':
SkinChanged(li);
ChangeSkin(li);
break;
case 'Gender':

View file

@ -311,6 +311,7 @@ userinfo_t userinfo;
native void SetLogText (String text);
native String GetUserName();
native Color GetColor();
native int GetPlayerClassNum();
native bool GetNeverSwitch();
native void DropWeapon();
native void BringUpWeapon();