mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- try to encapsulate access to the player class's display name for printing purposes.
SVN r2839 (trunk)
This commit is contained in:
parent
0619a2677e
commit
583cbd49a6
6 changed files with 24 additions and 10 deletions
|
@ -74,6 +74,7 @@ enum
|
|||
|
||||
FPlayerColorSet *P_GetPlayerColorSet(FName classname, int setnum);
|
||||
void P_EnumPlayerColorSets(FName classname, TArray<int> *out);
|
||||
const char *GetPrintableDisplayName(const PClass *cls);
|
||||
|
||||
class player_t;
|
||||
|
||||
|
|
|
@ -684,7 +684,7 @@ class CommandDrawString : public SBarInfoCommand
|
|||
if(statusBar->CPlayer->userinfo.PlayerClass != cache)
|
||||
{
|
||||
cache = statusBar->CPlayer->userinfo.PlayerClass;
|
||||
str = statusBar->CPlayer->cls->Meta.GetMetaString(APMETA_DisplayName);
|
||||
str = GetPrintableDisplayName(statusBar->CPlayer->cls);
|
||||
RealignString();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -351,7 +351,7 @@ void M_SetMenu(FName menu, int param)
|
|||
GameStartupInfo.Episode = -1;
|
||||
GameStartupInfo.PlayerClass =
|
||||
param == -1000? NULL :
|
||||
param == -1? "Random" : PlayerClasses[param].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
param == -1? "Random" : GetPrintableDisplayName(PlayerClasses[param].Type);
|
||||
break;
|
||||
|
||||
case NAME_Skillmenu:
|
||||
|
|
|
@ -995,7 +995,7 @@ static void BuildPlayerclassMenu()
|
|||
{
|
||||
if (!(PlayerClasses[i].Flags & PCF_NOMENU))
|
||||
{
|
||||
const char *pname = PlayerClasses[i].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
const char *pname = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
if (pname != NULL)
|
||||
{
|
||||
numclassitems++;
|
||||
|
@ -1032,7 +1032,7 @@ static void BuildPlayerclassMenu()
|
|||
{
|
||||
if (!(PlayerClasses[i].Flags & PCF_NOMENU))
|
||||
{
|
||||
const char *pname = PlayerClasses[i].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
const char *pname = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
if (pname != NULL)
|
||||
{
|
||||
FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
||||
|
@ -1051,7 +1051,7 @@ static void BuildPlayerclassMenu()
|
|||
}
|
||||
if (n == 0)
|
||||
{
|
||||
const char *pname = PlayerClasses[0].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
const char *pname = GetPrintableDisplayName(PlayerClasses[0].Type);
|
||||
if (pname != NULL)
|
||||
{
|
||||
FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, *pname,
|
||||
|
@ -1086,7 +1086,7 @@ static void BuildPlayerclassMenu()
|
|||
{
|
||||
if (!(PlayerClasses[i].Flags & PCF_NOMENU))
|
||||
{
|
||||
const char *pname = PlayerClasses[i].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
const char *pname = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
if (pname != NULL)
|
||||
{
|
||||
FOptionMenuItemSubmenu *it = new FOptionMenuItemSubmenu(pname, "Episodemenu", i);
|
||||
|
|
|
@ -592,7 +592,7 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
|
|||
{
|
||||
if (PlayerClasses.Size() == 1)
|
||||
{
|
||||
li->SetString(0, PlayerClasses[0].Type->Meta.GetMetaString (APMETA_DisplayName));
|
||||
li->SetString(0, GetPrintableDisplayName(PlayerClasses[0].Type));
|
||||
li->SetValue(0, 0);
|
||||
}
|
||||
else
|
||||
|
@ -600,7 +600,7 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc)
|
|||
li->SetString(0, "Random");
|
||||
for(unsigned i=0; i< PlayerClasses.Size(); i++)
|
||||
{
|
||||
const char *cls = PlayerClasses[i].Type->Meta.GetMetaString (APMETA_DisplayName);
|
||||
const char *cls = GetPrintableDisplayName(PlayerClasses[i].Type);
|
||||
li->SetString(i+1, cls);
|
||||
}
|
||||
li->SetValue(0, players[consoleplayer].userinfo.PlayerClass + 1);
|
||||
|
@ -901,8 +901,7 @@ void DPlayerMenu::ClassChanged (FListMenuItem *li)
|
|||
players[consoleplayer].userinfo.PlayerClass = sel-1;
|
||||
PickPlayerClass();
|
||||
|
||||
cvar_set ("playerclass",
|
||||
sel == 0 ? "Random" : PlayerClass->Type->Meta.GetMetaString (APMETA_DisplayName));
|
||||
cvar_set ("playerclass", sel == 0 ? "Random" : PlayerClass->Type->TypeName);
|
||||
|
||||
UpdateSkins();
|
||||
UpdateColorsets();
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "thingdef/thingdef.h"
|
||||
#include "g_level.h"
|
||||
#include "d_net.h"
|
||||
#include "gstrings.h"
|
||||
|
||||
static FRandom pr_skullpop ("SkullPop");
|
||||
|
||||
|
@ -95,6 +96,19 @@ bool FPlayerClass::CheckSkin (int skin)
|
|||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// GetDisplayName
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
const char *GetPrintableDisplayName(const PClass *cls)
|
||||
{
|
||||
// Fixme; This needs a decent way to access the string table without creating a mess.
|
||||
const char *name = cls->Meta.GetMetaString(APMETA_DisplayName);
|
||||
return name;
|
||||
}
|
||||
|
||||
bool ValidatePlayerClass(const PClass *ti, const char *name)
|
||||
{
|
||||
if (!ti)
|
||||
|
|
Loading…
Reference in a new issue