From 602209d4a4f4ffd38f442e8f9e54b1870352619f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 19 Feb 2013 02:50:47 +0000 Subject: [PATCH] - Add NoRandomPlayerclass flag for MAPINFO. SVN r4147 (trunk) --- src/gi.cpp | 1 + src/gi.h | 1 + src/menu/menudef.cpp | 2 +- src/menu/playermenu.cpp | 13 ++++++++----- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gi.cpp b/src/gi.cpp index 0e010724a..2df1fdde0 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -338,6 +338,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_FONT(mStatscreenEnteringFont, "statscreen_enteringfont") GAMEINFOKEY_PATCH(mStatscreenFinishedFont, "statscreen_finishedpatch") GAMEINFOKEY_PATCH(mStatscreenEnteringFont, "statscreen_enteringpatch") + GAMEINFOKEY_BOOL(norandomplayerclass, "norandomplayerclass") else { diff --git a/src/gi.h b/src/gi.h index 647db1a9b..ff678df07 100644 --- a/src/gi.h +++ b/src/gi.h @@ -139,6 +139,7 @@ struct gameinfo_t FGIFont mStatscreenMapNameFont; FGIFont mStatscreenFinishedFont; FGIFont mStatscreenEnteringFont; + bool norandomplayerclass; const char *GetFinalePage(unsigned int num) const; }; diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 0d9b89989..8167f6592 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1098,7 +1098,7 @@ static void BuildPlayerclassMenu() } } } - if (n > 1) + if (n > 1 && !gameinfo.norandomplayerclass) { FListMenuItemText *it = new FListMenuItemText(ld->mXpos, ld->mYpos, ld->mLinespacing, 'r', "$MNU_RANDOM", ld->mFont,ld->mFontColor, NAME_Episodemenu, -1); diff --git a/src/menu/playermenu.cpp b/src/menu/playermenu.cpp index 99eedfe66..a76817055 100644 --- a/src/menu/playermenu.cpp +++ b/src/menu/playermenu.cpp @@ -606,13 +606,16 @@ void DPlayerMenu::Init(DMenu *parent, FListMenuDescriptor *desc) } else { - li->SetString(0, "Random"); + // [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(i+1, cls); + li->SetString(gameinfo.norandomplayerclass ? i : i+1, cls); } - li->SetValue(0, players[consoleplayer].userinfo.PlayerClass + 1); + int pclass = players[consoleplayer].userinfo.PlayerClass; + li->SetValue(0, gameinfo.norandomplayerclass && pclass >= 0 ? pclass : pclass + 1); } } @@ -907,10 +910,10 @@ void DPlayerMenu::ClassChanged (FListMenuItem *li) if (li->GetValue(0, &sel)) { - players[consoleplayer].userinfo.PlayerClass = sel-1; + players[consoleplayer].userinfo.PlayerClass = gameinfo.norandomplayerclass ? sel : sel-1; PickPlayerClass(); - cvar_set ("playerclass", sel == 0 ? "Random" : PlayerClass->Type->Meta.GetMetaString (APMETA_DisplayName)); + cvar_set ("playerclass", sel == 0 && !gameinfo.norandomplayerclass ? "Random" : PlayerClass->Type->Meta.GetMetaString (APMETA_DisplayName)); UpdateSkins(); UpdateColorsets();