Skip to content
Permalink
Browse files

- reimplemented as an OptionsMenu.

This is both for consistency and better localizability. The old code is retained to ensure that mods inheriting from the old menu continue to work.
  • Loading branch information...
coelckers committed Apr 14, 2019
1 parent ad23726 commit c45c7cdb4bc89ca8a0b070e2de2f8a6ebf8e76a7
@@ -489,12 +489,6 @@ int userinfo_t::PlayerClassChanged(const char *classname)
return classnum;
}

int userinfo_t::PlayerClassNumChanged(int classnum)
{
*static_cast<FIntCVar *>((*this)[NAME_PlayerClass]) = classnum;
return classnum;
}

int userinfo_t::ColorSetChanged(int setnum)
{
*static_cast<FIntCVar *>((*this)[NAME_ColorSet]) = setnum;
@@ -264,8 +264,7 @@ struct userinfo_t : TMap<FName,FBaseCVar *>
int SkinNumChanged(int skinnum);
int GenderChanged(const char *gendername);
int PlayerClassChanged(const char *classname);
int PlayerClassNumChanged(int classnum);
uint32_t ColorChanged(const char *colorname);
uint32_t ColorChanged(const char *colorname);
uint32_t ColorChanged(uint32_t colorval);
int ColorSetChanged(int setnum);
};
@@ -66,7 +66,6 @@ CVAR (Bool, show_obituaries, true, CVAR_ARCHIVE)
CVAR (Int, m_showinputgrid, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, m_blockcontrollers, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)


CVAR (Float, snd_menuvolume, 0.6f, CVAR_ARCHIVE)
CVAR(Int, m_use_mouse, 2, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Int, m_show_backbutton, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@@ -518,6 +517,10 @@ void M_SetMenu(FName menu, int param)
void ActivateEndGameMenu();
ActivateEndGameMenu();
return;

case NAME_Playermenu:
menu = NAME_NewPlayerMenu; // redirect the old player menu to the new one.
break;
}

// End of special checks
@@ -48,6 +48,8 @@
#include "i_system.h"
#include "v_video.h"
#include "gstrings.h"
#include "teaminfo.h"
#include "r_data/sprites.h"


void ClearSaveGames();
@@ -1543,6 +1545,95 @@ void M_CreateMenus()
{
I_BuildALResamplersList(*opt);
}
opt = OptionValues.CheckKey(NAME_PlayerTeam);
if (opt != nullptr)
{
auto op = *opt;
op->mValues.Resize(Teams.Size() + 1);
op->mValues[0].Value = 0;
op->mValues[0].Text = "$OPTVAL_NONE";
for (unsigned i = 0; i < Teams.Size(); i++)
{
op->mValues[i+1].Value = i+1;
op->mValues[i+1].Text = Teams[i].GetName();
}
}
opt = OptionValues.CheckKey(NAME_PlayerClass);
if (opt != nullptr)
{
auto op = *opt;
int o = 0;
if (!gameinfo.norandomplayerclass && PlayerClasses.Size() > 1)
{
op->mValues.Resize(PlayerClasses.Size()+1);
op->mValues[0].Value = -1;
op->mValues[0].Text = "$MNU_RANDOM";
o = 1;
}
else op->mValues.Resize(PlayerClasses.Size());
for (unsigned i = 0; i < PlayerClasses.Size(); i++)
{
op->mValues[i+o].Value = i;
op->mValues[i+o].Text = GetPrintableDisplayName(PlayerClasses[i].Type);
}
}
}


DEFINE_ACTION_FUNCTION(DMenu, UpdateColorsets)
{
PARAM_PROLOGUE;
PARAM_POINTER(playerClass, FPlayerClass);

TArray<int> PlayerColorSets;

EnumColorSets(playerClass->Type, &PlayerColorSets);

auto opt = OptionValues.CheckKey(NAME_PlayerColors);
if (opt != nullptr)
{
auto op = *opt;
op->mValues.Resize(PlayerColorSets.Size() + 1);
op->mValues[0].Value = -1;
op->mValues[0].Text = "$OPTVAL_CUSTOM";
for (unsigned i = 0; i < PlayerColorSets.Size(); i++)
{
auto cset = GetColorSet(playerClass->Type, PlayerColorSets[i]);
op->mValues[i + 1].Value = PlayerColorSets[i];
op->mValues[i + 1].Text = cset? cset->Name.GetChars() : "?"; // The null case should never happen here.
}
}
return 0;
}

DEFINE_ACTION_FUNCTION(DMenu, UpdateSkinOptions)
{
PARAM_PROLOGUE;
PARAM_POINTER(playerClass, FPlayerClass);

auto opt = OptionValues.CheckKey(NAME_PlayerSkin);
if (opt != nullptr)
{
auto op = *opt;

if ((GetDefaultByType(playerClass->Type)->flags4 & MF4_NOSKIN) || players[consoleplayer].userinfo.GetPlayerClassNum() == -1)
{
op->mValues.Resize(1);
op->mValues[0].Value = -1;
op->mValues[0].Text = "$OPTVAL_DEFAULT";
}
else
{
op->mValues.Clear();
for (unsigned i = 0; i < Skins.Size(); i++)
{
op->mValues.Reserve(1);
op->mValues.Last().Value = i;
op->mValues.Last().Text = Skins[i].Name;
}
}
}
return 0;
}

//=============================================================================
@@ -133,8 +133,9 @@ DEFINE_ACTION_FUNCTION(DPlayerMenu, ClassChanged)
PARAM_POINTER(cls, FPlayerClass);
if (DMenu::InMenu)
{
players[consoleplayer].userinfo.PlayerClassNumChanged(gameinfo.norandomplayerclass ? sel : sel - 1);
cvar_set("playerclass", sel == 0 && !gameinfo.norandomplayerclass ? "Random" : GetPrintableDisplayName(cls->Type).GetChars());
const char *pclass = sel == -1 ? "Random" : GetPrintableDisplayName(cls->Type).GetChars();
players[consoleplayer].userinfo.PlayerClassChanged(pclass);
cvar_set("playerclass", pclass);
}
return 0;
}
@@ -1083,3 +1083,7 @@ xx(MapMarker)
xx(Spawn2)
xx(LevelLocals)
xx(Level)
xx(PlayerTeam)
xx(PlayerColors)
xx(PlayerSkin)
xx(NewPlayerMenu)
@@ -369,7 +369,7 @@ OptionMenu "OptionsMenu" protected
Submenu "$OPTMNU_MOUSE", "MouseOptions"
Submenu "$OPTMNU_JOYSTICK", "JoystickOptions"
StaticText " "
Submenu "$OPTMNU_PLAYER", "PlayerMenu"
Submenu "$OPTMNU_PLAYER", "NewPlayerMenu"
Submenu "$OPTMNU_GAMEPLAY", "GameplayOptions"
Submenu "$OPTMNU_COMPATIBILITY", "CompatibilityOptions"
Submenu "$OPTMNU_AUTOMAP", "AutomapOptions"
@@ -401,6 +401,58 @@ OptionValue "Gender"
3, "$OPTVAL_OTHER"
}

OptionValue "PlayerTeam"
{
// Filled in programmatically
}

OptionValue "PlayerColors"
{
// Filled in programmatically
}

OptionValue "PlayerClass"
{
// Filled in programmatically
}

OptionValue "PlayerSkin"
{
// Filled in programmatically
}

/*
IfGame(Doom, Heretic, Strife, Chex)
{
MouseWindow 0, 220
PlayerDisplay 220, 48, "20 00 00", "80 00 40", 1, "PlayerDisplay"
}
IfGame(Hexen)
{
MouseWindow 0, 220
PlayerDisplay 220, 48, "00 07 00", "40 53 40", 1, "PlayerDisplay"
}
*/

OptionMenu "NewPlayerMenu"
{
Title "$MNU_PLAYERSETUP"
PlayerNameField "$PLYRMNU_NAME"
PlayerTeamItem "$PLYRMNU_TEAM", "PlayerTeam"
PlayerColorItem "$PLYRMNU_PLAYERCOLOR", "PlayerColors"
PlayerColorSlider "$PLYRMNU_RED", 0
PlayerColorSlider "$PLYRMNU_GREEN", 1
PlayerColorSlider "$PLYRMNU_BLUE", 2
PlayerClassItem "$PLYRMNU_PLAYERCLASS", "PlayerClass"
PlayerSkinItem "$PLYRMNU_PLAYERSKIN", "PlayerSkin"
PlayerGenderItem "$PLYRMNU_PLAYERGENDER", "Gender"
AutoaimSlider "$PLYRMNU_AUTOAIM"
PlayerSwitchOnPickupItem "$PLYRMNU_SWITCHONPICKUP", "OffOn"
Option "$PLYRMNU_ALWAYSRUN", cl_run, "OnOff"
Class "NewPlayerMenu"
}

// The old player menu is kept for mods that redefine it.
ListMenu "PlayerMenu"
{
StaticTextCentered 160, 6, "$MNU_PLAYERSETUP"
@@ -246,6 +246,7 @@ version "3.8"
#include "zscript/ui/menu/messagebox.zs"
#include "zscript/ui/menu/optionmenu.zs"
#include "zscript/ui/menu/optionmenuitems.zs"
#include "zscript/ui/menu/newplayermenu.zs"
#include "zscript/ui/menu/playercontrols.zs"
#include "zscript/ui/menu/playerdisplay.zs"
#include "zscript/ui/menu/playermenu.zs"
@@ -98,6 +98,8 @@ class Menu : Object native ui version("2.4")
native static void SetMouseCapture(bool on);
native void Close();
native void ActivateMenu();
native static void UpdateColorsets(PlayerClass cls);
native static void UpdateSkinOptions(PlayerClass cls);

//=============================================================================
//
Oops, something went wrong.

0 comments on commit c45c7cd

Please sign in to comment.
You can’t perform that action at this time.