mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 05:51:20 +00:00
- scriptified the rest of the player menu. This compiles and runs but doesn't work yet, it will be fixed in the next commit.
This commit is contained in:
parent
49a07180c0
commit
5f1241a55c
8 changed files with 256 additions and 338 deletions
|
@ -297,6 +297,11 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
|
|||
return aim;
|
||||
}
|
||||
}
|
||||
// Same but unfiltered.
|
||||
double GetAutoaim() const
|
||||
{
|
||||
return *static_cast<FFloatCVar *>(*CheckKey(NAME_Autoaim));
|
||||
}
|
||||
const char *GetName() const
|
||||
{
|
||||
return *static_cast<FStringCVar *>(*CheckKey(NAME_Name));
|
||||
|
|
|
@ -48,241 +48,10 @@
|
|||
#include "r_data/r_translate.h"
|
||||
#include "v_text.h"
|
||||
|
||||
EXTERN_CVAR (String, playerclass)
|
||||
EXTERN_CVAR (String, name)
|
||||
EXTERN_CVAR (Int, team)
|
||||
EXTERN_CVAR (Float, autoaim)
|
||||
EXTERN_CVAR(Int, team)
|
||||
EXTERN_CVAR(Float, autoaim)
|
||||
EXTERN_CVAR(Bool, neverswitchonpickup)
|
||||
EXTERN_CVAR (Bool, cl_run)
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class DPlayerMenu : public DListMenu
|
||||
{
|
||||
DECLARE_CLASS(DPlayerMenu, DListMenu)
|
||||
|
||||
public:
|
||||
int PlayerClassIndex;
|
||||
FPlayerClass *PlayerClass;
|
||||
TArray<int> PlayerColorSets;
|
||||
TArray<int> PlayerSkins;
|
||||
int mRotation;
|
||||
|
||||
void PickPlayerClass ();
|
||||
void UpdateColorsets();
|
||||
void UpdateSkins();
|
||||
void UpdateTranslation();
|
||||
|
||||
public:
|
||||
|
||||
DPlayerMenu() {}
|
||||
void Init(DMenu *parent, DListMenuDescriptor *desc);
|
||||
bool Responder (event_t *ev);
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(DPlayerMenu, false, false)
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
enum EPDFlags
|
||||
{
|
||||
ListMenuItemPlayerDisplay_PDF_ROTATION = 0x10001,
|
||||
ListMenuItemPlayerDisplay_PDF_SKIN = 0x10002,
|
||||
ListMenuItemPlayerDisplay_PDF_CLASS = 0x10003,
|
||||
ListMenuItemPlayerDisplay_PDF_MODE = 0x10004,
|
||||
ListMenuItemPlayerDisplay_PDF_TRANSLATE = 0x10005,
|
||||
};
|
||||
|
||||
void DPlayerMenu::Init(DMenu *parent, DListMenuDescriptor *desc)
|
||||
{
|
||||
DMenuItemBase *li;
|
||||
|
||||
Super::Init(parent, desc);
|
||||
PickPlayerClass();
|
||||
mRotation = 0;
|
||||
|
||||
li = GetItem(NAME_Playerdisplay);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_ROTATION, 0);
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_MODE, 1);
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_TRANSLATE, 1);
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_CLASS, players[consoleplayer].userinfo.GetPlayerClassNum());
|
||||
if (PlayerClass != NULL && !(GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN) &&
|
||||
players[consoleplayer].userinfo.GetPlayerClassNum() != -1)
|
||||
{
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, players[consoleplayer].userinfo.GetSkin());
|
||||
}
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Playerbox);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetString(0, name);
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Team);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetString(0, "None");
|
||||
for(unsigned i=0;i<Teams.Size(); i++)
|
||||
{
|
||||
li->SetString(i+1, Teams[i].GetName());
|
||||
}
|
||||
li->SetValue(0, team == TEAM_NONE? 0 : team + 1);
|
||||
}
|
||||
|
||||
int mycolorset = players[consoleplayer].userinfo.GetColorSet();
|
||||
int color = players[consoleplayer].userinfo.GetColor();
|
||||
|
||||
UpdateColorsets();
|
||||
|
||||
li = GetItem(NAME_Red);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->Enable(mycolorset == -1);
|
||||
li->SetValue(0, RPART(color));
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Green);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->Enable(mycolorset == -1);
|
||||
li->SetValue(0, GPART(color));
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Blue);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->Enable(mycolorset == -1);
|
||||
li->SetValue(0, BPART(color));
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Class);
|
||||
if (li != NULL)
|
||||
{
|
||||
if (PlayerClasses.Size() == 1)
|
||||
{
|
||||
li->SetString(0, GetPrintableDisplayName(PlayerClasses[0].Type));
|
||||
li->SetValue(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// [XA] Remove the "Random" option if the relevant gameinfo flag is set.
|
||||
if(!gameinfo.norandomplayerclass)
|
||||
li->SetString(0, "Random");
|
||||
for(unsigned i=0; i< PlayerClasses.Size(); i++)
|
||||
{
|
||||
const char *cls = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
li->SetString(gameinfo.norandomplayerclass ? i : i+1, cls);
|
||||
}
|
||||
int pclass = players[consoleplayer].userinfo.GetPlayerClassNum();
|
||||
li->SetValue(0, gameinfo.norandomplayerclass && pclass >= 0 ? pclass : pclass + 1);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSkins();
|
||||
|
||||
li = GetItem(NAME_Gender);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(0, players[consoleplayer].userinfo.GetGender());
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Autoaim);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(0, (int)autoaim);
|
||||
}
|
||||
|
||||
li = GetItem(NAME_Switch);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(0, neverswitchonpickup);
|
||||
}
|
||||
|
||||
li = GetItem(NAME_AlwaysRun);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(0, cl_run);
|
||||
}
|
||||
|
||||
if (mDesc->mSelectedItem < 0) mDesc->mSelectedItem = 1;
|
||||
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
bool DPlayerMenu::Responder (event_t *ev)
|
||||
{
|
||||
if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_Char && ev->data1 == ' ')
|
||||
{
|
||||
// turn the player sprite around
|
||||
mRotation = 8 - mRotation;
|
||||
DMenuItemBase *li = GetItem(NAME_Playerdisplay);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_ROTATION, mRotation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Super::Responder(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void DPlayerMenu::UpdateTranslation()
|
||||
{
|
||||
int PlayerColor = players[consoleplayer].userinfo.GetColor();
|
||||
int PlayerSkin = players[consoleplayer].userinfo.GetSkin();
|
||||
int PlayerColorset = players[consoleplayer].userinfo.GetColorSet();
|
||||
|
||||
if (PlayerClass != NULL)
|
||||
{
|
||||
PlayerSkin = R_FindSkin (Skins[PlayerSkin].Name, int(PlayerClass - &PlayerClasses[0]));
|
||||
R_GetPlayerTranslation(PlayerColor, GetColorSet(PlayerClass->Type, PlayerColorset),
|
||||
&Skins[PlayerSkin], translationtables[TRANSLATION_Players][MAXPLAYERS]);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void DPlayerMenu::PickPlayerClass()
|
||||
{
|
||||
int pclass = 0;
|
||||
// [GRB] Pick a class from player class list
|
||||
if (PlayerClasses.Size () > 1)
|
||||
{
|
||||
pclass = players[consoleplayer].userinfo.GetPlayerClassNum();
|
||||
|
||||
if (pclass < 0)
|
||||
{
|
||||
pclass = (MenuTime>>7) % PlayerClasses.Size ();
|
||||
}
|
||||
}
|
||||
PlayerClassIndex = pclass;
|
||||
PlayerClass = &PlayerClasses[PlayerClassIndex];
|
||||
UpdateTranslation();
|
||||
}
|
||||
EXTERN_CVAR(Bool, cl_run)
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
@ -292,7 +61,7 @@ void DPlayerMenu::PickPlayerClass()
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(r);
|
||||
PARAM_INT(g);
|
||||
PARAM_INT(b);
|
||||
|
@ -308,87 +77,6 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorChanged)
|
|||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void DPlayerMenu::UpdateColorsets()
|
||||
{
|
||||
DMenuItemBase *li = GetItem(NAME_Color);
|
||||
if (li != NULL)
|
||||
{
|
||||
int sel = 0;
|
||||
EnumColorSets(PlayerClass->Type, &PlayerColorSets);
|
||||
li->SetString(0, "Custom");
|
||||
for(unsigned i=0;i<PlayerColorSets.Size(); i++)
|
||||
{
|
||||
FPlayerColorSet *colorset = GetColorSet(PlayerClass->Type, PlayerColorSets[i]);
|
||||
li->SetString(i+1, colorset->Name);
|
||||
}
|
||||
int mycolorset = players[consoleplayer].userinfo.GetColorSet();
|
||||
if (mycolorset != -1)
|
||||
{
|
||||
for(unsigned i=0;i<PlayerColorSets.Size(); i++)
|
||||
{
|
||||
if (PlayerColorSets[i] == mycolorset)
|
||||
{
|
||||
sel = i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
li->SetValue(0, sel);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// done
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void DPlayerMenu::UpdateSkins()
|
||||
{
|
||||
int sel = 0;
|
||||
int skin;
|
||||
DMenuItemBase *li = GetItem(NAME_Skin);
|
||||
if (li != NULL)
|
||||
{
|
||||
if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN ||
|
||||
players[consoleplayer].userinfo.GetPlayerClassNum() == -1)
|
||||
{
|
||||
li->SetString(0, "Base");
|
||||
li->SetValue(0, 0);
|
||||
skin = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerSkins.Clear();
|
||||
for (unsigned i = 0; i < Skins.Size(); i++)
|
||||
{
|
||||
if (PlayerClass->CheckSkin(i))
|
||||
{
|
||||
int j = PlayerSkins.Push(i);
|
||||
li->SetString(j, Skins[i].Name);
|
||||
if (players[consoleplayer].userinfo.GetSkin() == i)
|
||||
{
|
||||
sel = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
li->SetValue(0, sel);
|
||||
skin = PlayerSkins[sel];
|
||||
}
|
||||
li = GetItem(NAME_Playerdisplay);
|
||||
if (li != NULL)
|
||||
{
|
||||
li->SetValue(ListMenuItemPlayerDisplay_PDF_SKIN, skin);
|
||||
}
|
||||
}
|
||||
UpdateTranslation();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// access to the player config is done natively, so that broader access
|
||||
|
@ -398,7 +86,7 @@ void DPlayerMenu::UpdateSkins()
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, PlayerNameChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_STRING(s);
|
||||
const char *pp = s;
|
||||
FString command("name \"");
|
||||
|
@ -428,7 +116,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, PlayerNameChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorSetChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(sel);
|
||||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
|
@ -448,7 +136,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ColorSetChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, ClassChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(sel);
|
||||
PARAM_POINTER(cls, FPlayerClass);
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -468,7 +156,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ClassChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, SkinChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(sel);
|
||||
if (self == DMenu::CurrentMenu)
|
||||
{
|
||||
|
@ -486,7 +174,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, SkinChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, AutoaimChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_FLOAT(val);
|
||||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -504,7 +192,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, AutoaimChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, TeamChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(val);
|
||||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -522,7 +210,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, TeamChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, GenderChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(v);
|
||||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -540,7 +228,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, GenderChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, SwitchOnPickupChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(v);
|
||||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -558,7 +246,7 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, SwitchOnPickupChanged)
|
|||
|
||||
DEFINE_ACTION_FUNCTION(DPlayerMenu, AlwaysRunChanged)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(DPlayerMenu);
|
||||
PARAM_SELF_PROLOGUE(DListMenu);
|
||||
PARAM_INT(v);
|
||||
// only allow if the menu is active to prevent abuse.
|
||||
if (self == DMenu::CurrentMenu)
|
||||
|
@ -567,10 +255,3 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, AlwaysRunChanged)
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DEFINE_FIELD(DPlayerMenu, mRotation)
|
||||
DEFINE_FIELD_NAMED(DPlayerMenu, PlayerClass, mPlayerClass)
|
||||
DEFINE_FIELD(DPlayerMenu, PlayerColorSets)
|
||||
DEFINE_FIELD_NAMED(DPlayerMenu, PlayerSkins, mPlayerSkins)
|
||||
DEFINE_FIELD(DPlayerMenu, PlayerClassIndex)
|
||||
|
|
|
@ -701,6 +701,25 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetSkin)
|
|||
ACTION_RETURN_INT(self->userinfo.GetSkin());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetGender)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
ACTION_RETURN_INT(self->userinfo.GetGender());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetAutoaim)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
ACTION_RETURN_FLOAT(self->userinfo.GetAutoaim());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_PlayerInfo, GetTeam)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(player_t);
|
||||
ACTION_RETURN_INT(self->userinfo.GetTeam());
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APlayerPawn
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include "v_video.h"
|
||||
#include "c_bind.h"
|
||||
#include "menu/menu.h"
|
||||
#include "teaminfo.h"
|
||||
#include "r_data/sprites.h"
|
||||
|
||||
static TArray<FPropertyInfo*> properties;
|
||||
|
@ -764,6 +765,10 @@ void InitThingdef()
|
|||
playerskinstruct->Size = sizeof(FPlayerSkin);
|
||||
playerskinstruct->Align = alignof(FPlayerSkin);
|
||||
|
||||
auto teamstruct = NewNativeStruct("Team", nullptr);
|
||||
teamstruct->Size = sizeof(FTeam);
|
||||
teamstruct->Align = alignof(FTeam);
|
||||
|
||||
// set up the lines array in the sector struct. This is a bit messy because the type system is not prepared to handle a pointer to an array of pointers to a native struct even remotely well...
|
||||
// As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up.
|
||||
sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native);
|
||||
|
@ -807,6 +812,10 @@ void InitThingdef()
|
|||
PField *plrsknf = new PField("PlayerSkins", plrskn, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&Skins);
|
||||
Namespaces.GlobalNamespace->Symbols.AddSymbol(plrsknf);
|
||||
|
||||
auto teamst = NewPointer(NewResizableArray(teamstruct), false);
|
||||
PField *teamf = new PField("Teams", teamst, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&Teams);
|
||||
Namespaces.GlobalNamespace->Symbols.AddSymbol(teamf);
|
||||
|
||||
auto bindcls = NewNativeStruct("KeyBindings", nullptr);
|
||||
PField *binding = new PField("Bindings", bindcls, VARF_Native | VARF_Static, (intptr_t)&Bindings);
|
||||
Namespaces.GlobalNamespace->Symbols.AddSymbol(binding);
|
||||
|
|
|
@ -333,3 +333,6 @@ CCMD (teamlist)
|
|||
|
||||
Printf ("End of team list.\n");
|
||||
}
|
||||
|
||||
|
||||
DEFINE_FIELD_NAMED(FTeam, m_Name, mName)
|
|
@ -63,7 +63,9 @@ private:
|
|||
void ParseTeamDefinition (FScanner &Scan);
|
||||
void ClearTeams ();
|
||||
|
||||
public: // needed for script access.
|
||||
FString m_Name;
|
||||
private:
|
||||
int m_iPlayerColor;
|
||||
FString m_TextColor;
|
||||
FString m_Logo;
|
||||
|
|
|
@ -1,11 +1,45 @@
|
|||
/*
|
||||
** playermenu.cpp
|
||||
** The player setup menu
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2001-2010 Randy Heit
|
||||
** Copyright 2010-2017 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
class PlayerMenu : ListMenu native
|
||||
class PlayerMenu : ListMenu
|
||||
{
|
||||
native int mRotation;
|
||||
native int PlayerClassIndex;
|
||||
native PlayerClass mPlayerClass;
|
||||
native Array<int> PlayerColorSets;
|
||||
native Array<int> mPlayerSkins;
|
||||
int mRotation;
|
||||
int PlayerClassIndex;
|
||||
PlayerClass mPlayerClass;
|
||||
Array<int> PlayerColorSets;
|
||||
Array<int> mPlayerSkins;
|
||||
|
||||
// All write function for the player config are native to prevent abuse.
|
||||
protected native void AutoaimChanged(float val);
|
||||
|
@ -19,6 +53,12 @@ class PlayerMenu : ListMenu native
|
|||
protected native void SkinChanged (int val);
|
||||
protected native void ClassChanged(int sel, PlayerClass cls);
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
protected void UpdateTranslation()
|
||||
{
|
||||
Translation.SetPlayerTranslation(TRANSLATION_Players, MAXPLAYERS, consoleplayer, mPlayerClass);
|
||||
|
@ -30,6 +70,133 @@ class PlayerMenu : ListMenu native
|
|||
UpdateTranslation();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
override void Init(Menu parent, ListMenuDescriptor desc)
|
||||
{
|
||||
MenuItemBase li;
|
||||
PlayerInfo p = players[consoleplayer];
|
||||
|
||||
Super.Init(parent, desc);
|
||||
PickPlayerClass();
|
||||
mRotation = 0;
|
||||
|
||||
li = GetItem('Playerdisplay');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, 0);
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_MODE, 1);
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_TRANSLATE, 1);
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_CLASS, p.GetPlayerClassNum());
|
||||
if (mPlayerClass != NULL && !(GetDefaultByType (mPlayerClass.Type).bNoSkin) &&
|
||||
p.GetPlayerClassNum() != -1)
|
||||
{
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_SKIN, p.GetSkin());
|
||||
}
|
||||
}
|
||||
|
||||
li = GetItem('Playerbox');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetString(0, p.GetUserName());
|
||||
}
|
||||
|
||||
li = GetItem('Team');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetString(0, "None");
|
||||
for(int i=0;i<Teams.Size(); i++)
|
||||
{
|
||||
li.SetString(i+1, Teams[i].mName);
|
||||
}
|
||||
int myteam = players[consoleplayer].GetTeam();
|
||||
li.SetValue(0, myteam == Team.NoTeam? 0 : myteam + 1);
|
||||
}
|
||||
|
||||
int mycolorset = p.GetColorSet();
|
||||
Color colr = p.GetColor();
|
||||
|
||||
UpdateColorsets();
|
||||
|
||||
li = GetItem('Red');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.Enable(mycolorset == -1);
|
||||
li.SetValue(0, colr.r);
|
||||
}
|
||||
|
||||
li = GetItem('Green');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.Enable(mycolorset == -1);
|
||||
li.SetValue(0, colr.g);
|
||||
}
|
||||
|
||||
li = GetItem('Blue');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.Enable(mycolorset == -1);
|
||||
li.SetValue(0, colr.b);
|
||||
}
|
||||
|
||||
li = GetItem('Class');
|
||||
if (li != NULL)
|
||||
{
|
||||
if (PlayerClasses.Size() == 1)
|
||||
{
|
||||
li.SetString(0, PlayerPawn.GetPrintableDisplayName(PlayerClasses[0].Type));
|
||||
li.SetValue(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// [XA] Remove the "Random" option if the relevant gameinfo flag is set.
|
||||
if(!gameinfo.norandomplayerclass)
|
||||
li.SetString(0, "Random");
|
||||
for(int i=0; i< PlayerClasses.Size(); i++)
|
||||
{
|
||||
let cls = PlayerPawn.GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
li.SetString(gameinfo.norandomplayerclass ? i : i+1, cls);
|
||||
}
|
||||
int pclass = p.GetPlayerClassNum();
|
||||
li.SetValue(0, gameinfo.norandomplayerclass && pclass >= 0 ? pclass : pclass + 1);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateSkins();
|
||||
|
||||
li = GetItem('Gender');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(0, p.GetGender());
|
||||
}
|
||||
|
||||
li = GetItem('Autoaim');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(0, int(p.GetAutoaim()));
|
||||
}
|
||||
|
||||
li = GetItem('Switch');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(0, p.GetNeverSwitch());
|
||||
}
|
||||
|
||||
li = GetItem('AlwaysRun');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(0, cl_run);
|
||||
}
|
||||
|
||||
if (mDesc.mSelectedItem < 0) mDesc.mSelectedItem = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
@ -199,6 +366,28 @@ class PlayerMenu : ListMenu native
|
|||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
override bool Responder (InputEventData ev)
|
||||
{
|
||||
if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_Char && ev.data1 == 32)
|
||||
{
|
||||
// turn the player sprite around
|
||||
mRotation = 8 - mRotation;
|
||||
MenuItemBase li = GetItem('Playerdisplay');
|
||||
if (li != NULL)
|
||||
{
|
||||
li.SetValue(ListMenuItemPlayerDisplay.PDF_ROTATION, mRotation);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Super.Responder(ev);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -317,6 +317,9 @@ usercmd_t original_cmd;
|
|||
native int GetPlayerClassNum();
|
||||
native int GetSkin();
|
||||
native bool GetNeverSwitch();
|
||||
native int GetGender();
|
||||
native int GetTeam();
|
||||
native float GetAutoaim();
|
||||
}
|
||||
|
||||
struct PlayerClass native
|
||||
|
@ -343,3 +346,10 @@ struct PlayerSkin native
|
|||
native readonly int crouchsprite;
|
||||
native readonly int namespc;
|
||||
};
|
||||
|
||||
struct Team native
|
||||
{
|
||||
const NoTeam = 255;
|
||||
const Max = 16;
|
||||
native String mName;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue