From 4da5ce74ca432682a7d66ba846e43593da1ca783 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Sep 2010 16:20:39 +0000 Subject: [PATCH] - fixed: The menu should not override the user's player class if there is no player class menu. SVN r2798 (trunk) --- src/g_level.cpp | 2 +- src/menu/menu.cpp | 1 + src/menu/menudef.cpp | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index 10ed1f83e..1c125324a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -233,7 +233,7 @@ void G_DeferedInitNew (const char *mapname, int newskill) void G_DeferedInitNew (FGameStartup *gs) { - playerclass = gs->PlayerClass; + if (gs->PlayerClass != NULL) playerclass = gs->PlayerClass; d_mapname = AllEpisodes[gs->Episode].mEpisodeMap; d_skill = gs->Skill; CheckWarpTransMap (d_mapname, true); diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 6d60344b1..d54b27c1c 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -350,6 +350,7 @@ void M_SetMenu(FName menu, int param) GameStartupInfo.Skill = -1; GameStartupInfo.Episode = -1; GameStartupInfo.PlayerClass = + param == -1000? NULL : param == -1? "Random" : PlayerClasses[param].Type->Meta.GetMetaString (APMETA_DisplayName); break; diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 8b865cbc6..8d37f570c 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1006,7 +1006,14 @@ static void BuildPlayerclassMenu() // center the menu on the screen if the top space is larger than the bottom space int totalheight = posy + (numclassitems+1) * ld->mLinespacing - topy; - if (totalheight <= 190 || numclassitems == 1) + if (numclassitems <= 1) + { + // create a dummy item that auto-chooses the default class. + FListMenuItemText *it = new FListMenuItemText(0, 0, 0, 'p', "player", + ld->mFont,ld->mFontColor, NAME_Episodemenu, -1000); + ld->mAutoselect = 0; + } + else if (totalheight <= 190) { int newtop = (200 - totalheight + topy) / 2; int topdelta = newtop - topy; @@ -1051,10 +1058,6 @@ static void BuildPlayerclassMenu() ld->mItems.Push(it); } } - if (n < 2) - { - ld->mAutoselect = ld->mSelectedItem; - } success = true; } }