mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- scriptified ClassChanged.
This commit is contained in:
parent
50d2846e40
commit
49a07180c0
4 changed files with 54 additions and 45 deletions
|
@ -50,6 +50,7 @@ DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, Armor2Percent)
|
|||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, ArmorIcon1)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, ArmorIcon2)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, gametype)
|
||||
DEFINE_FIELD_X(GameInfoStruct, gameinfo_t, norandomplayerclass)
|
||||
|
||||
|
||||
const char *GameNames[17] =
|
||||
|
|
|
@ -77,12 +77,6 @@ public:
|
|||
void UpdateSkins();
|
||||
void UpdateTranslation();
|
||||
|
||||
void PlayerNameChanged(DMenuItemBase *li);
|
||||
void ColorSetChanged (DMenuItemBase *li);
|
||||
void ClassChanged (DMenuItemBase *li);
|
||||
void SkinChanged (DMenuItemBase *li);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DPlayerMenu() {}
|
||||
|
@ -248,7 +242,7 @@ bool DPlayerMenu::Responder (event_t *ev)
|
|||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
@ -268,7 +262,7 @@ void DPlayerMenu::UpdateTranslation()
|
|||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
@ -305,7 +299,10 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorChanged)
|
|||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
char command[24];
|
||||
players[consoleplayer].userinfo.ColorChanged(MAKERGB(r, g, b));
|
||||
mysnprintf(command, countof(command), "color \"%02x %02x %02x\"", r, g, b);
|
||||
C_DoCommand(command);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -313,7 +310,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorChanged)
|
|||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
@ -347,7 +344,7 @@ void DPlayerMenu::UpdateColorsets()
|
|||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
@ -436,6 +433,9 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorSetChanged)
|
|||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
players[consoleplayer].userinfo.ColorSetChanged(sel);
|
||||
char command[24];
|
||||
mysnprintf(command, countof(command), "colorset %d", sel);
|
||||
C_DoCommand(command);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -446,41 +446,15 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorSetChanged)
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void DPlayerMenu::ClassChanged (DMenuItemBase *li)
|
||||
{
|
||||
if (PlayerClasses.Size () == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int sel;
|
||||
|
||||
if (li->GetValue(0, &sel))
|
||||
{
|
||||
players[consoleplayer].userinfo.PlayerClassNumChanged(gameinfo.norandomplayerclass ? sel : sel-1);
|
||||
PickPlayerClass();
|
||||
|
||||
cvar_set ("playerclass", sel == 0 && !gameinfo.norandomplayerclass ? "Random" : GetPrintableDisplayName(PlayerClass->Type).GetChars());
|
||||
|
||||
UpdateSkins();
|
||||
UpdateColorsets();
|
||||
UpdateTranslation();
|
||||
|
||||
li = GetItem(NAME_Playerdisplay);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, ClassChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_OBJECT(sel, DMenuItemBase);
|
||||
PARAM_INT(sel);
|
||||
PARAM_POINTER(cls, FPlayerClass);
|
||||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
self->ClassChanged(sel);
|
||||
players[consoleplayer].userinfo.PlayerClassNumChanged(gameinfo.norandomplayerclass ? sel : sel - 1);
|
||||
cvar_set("playerclass", sel == 0 && !gameinfo.norandomplayerclass ? "Random" : GetPrintableDisplayName(cls->Type).GetChars());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -499,6 +473,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, SkinChanged)
|
|||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
players[consoleplayer].userinfo.SkinNumChanged(sel);
|
||||
cvar_set("skin", Skins[sel].Name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -309,6 +309,7 @@ struct GameInfoStruct native
|
|||
native String ArmorIcon1;
|
||||
native String ArmorIcon2;
|
||||
native int gametype;
|
||||
native bool norandomplayerclass;
|
||||
}
|
||||
|
||||
class Object native
|
||||
|
|
|
@ -17,8 +17,7 @@ class PlayerMenu : ListMenu native
|
|||
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 ClassChanged(int sel, PlayerClass cls);
|
||||
|
||||
protected void UpdateTranslation()
|
||||
{
|
||||
|
@ -37,13 +36,13 @@ class PlayerMenu : ListMenu native
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
protected void PickPlayerClass()
|
||||
protected void PickPlayerClass(int pick = -100)
|
||||
{
|
||||
int pclass = 0;
|
||||
// [GRB] Pick a class from player class list
|
||||
if (PlayerClasses.Size () > 1)
|
||||
{
|
||||
pclass = players[consoleplayer].GetPlayerClassNum();
|
||||
pclass = pick == -100? players[consoleplayer].GetPlayerClassNum() : pick;
|
||||
|
||||
if (pclass < 0)
|
||||
{
|
||||
|
@ -141,6 +140,39 @@ class PlayerMenu : ListMenu native
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void ChangeClass (MenuItemBase li)
|
||||
{
|
||||
if (PlayerClasses.Size () == 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool res;
|
||||
int sel;
|
||||
|
||||
[res, sel] = li.GetValue(0);
|
||||
if (res)
|
||||
{
|
||||
PickPlayerClass(gameinfo.norandomplayerclass ? sel : sel-1);
|
||||
ClassChanged(sel, mPlayerClass);
|
||||
UpdateSkins();
|
||||
UpdateColorsets();
|
||||
UpdateTranslation();
|
||||
|
||||
li = GetItem('Playerdisplay');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, players[consoleplayer].GetPlayerClassNum());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
protected void ChangeSkin (MenuItemBase li)
|
||||
{
|
||||
if (GetDefaultByType (mPlayerClass.Type).bNoSkin || players[consoleplayer].GetPlayerClassNum() == -1)
|
||||
|
@ -254,7 +286,7 @@ class PlayerMenu : ListMenu native
|
|||
[res, v] = li.GetValue(0);
|
||||
if (res)
|
||||
{
|
||||
ClassChanged(li);
|
||||
ChangeClass(li);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue