diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 555f2a2ab..af8c402ce 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -236,6 +236,7 @@ struct GameInterface f.VFormat(fmt, ap); DoPrintMessage(prio, f); } + virtual void DrawPlayerSprite(const DVector2& origin, bool onteam) {} }; extern GameInterface* gi; diff --git a/source/common/gamecvars.cpp b/source/common/gamecvars.cpp index baf242034..c9c4df80a 100644 --- a/source/common/gamecvars.cpp +++ b/source/common/gamecvars.cpp @@ -571,7 +571,7 @@ CUSTOM_CVAR(Int, playerteam, 0, CVAR_USERINFO) // this one is transient and won' else ;// gi->UpdatePlayerTeam(); // this part is game specific } -// Will only become useful if the obituary system gets overhauled. +// Will only become useful if the obituary system gets overhauled and for localization CUSTOM_CVAR(Int, playergender, 0, CVAR_USERINFO|CVAR_ARCHIVE) { if (self < 0 || self > 3) self = 0; diff --git a/source/common/menu/menu.cpp b/source/common/menu/menu.cpp index 350b2cabd..e2b6994cc 100644 --- a/source/common/menu/menu.cpp +++ b/source/common/menu/menu.cpp @@ -57,6 +57,7 @@ void RegisterRedneckMenus(); void RegisterBloodMenus(); void RegisterSWMenus(); void RegisterLoadsaveMenus(); +void RegisterOptionMenus(); extern bool rotatesprite_2doverride; bool help_disabled, credits_disabled; int g_currentMenu; // accessible by CON scripts - contains the current menu's script ID if defined or INT_MAX if none given. @@ -546,10 +547,23 @@ bool M_SetMenu(FName menu, int param, FName caller) else if ((*desc)->mType == MDESC_OptionsMenu) { FOptionMenuDescriptor *ld = static_cast(*desc); - //const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DOptionMenu) : ld->mClass; - - ld->CalcIndent(); - DOptionMenu *newmenu = new DOptionMenu; + DOptionMenu* newmenu; + if (ld->mClass != NAME_None) + { + auto ndx = menuClasses.FindEx([=](const auto p) { return p->mName == ld->mClass; }); + if (ndx == menuClasses.Size()) + { + I_Error("Bad menu class %s\n", ld->mClass.GetChars()); + } + else + { + newmenu = (DOptionMenu*)menuClasses[ndx]->CreateNew(); + } + } + else + { + newmenu = new DOptionMenu; + } newmenu->Init(DMenu::CurrentMenu, ld); M_ActivateMenu(newmenu); } @@ -922,6 +936,7 @@ void M_Init (void) RegisterBloodMenus(); RegisterSWMenus(); RegisterLoadsaveMenus(); + RegisterOptionMenus(); timerSetCallback(M_Ticker); M_ParseMenuDefs(); } diff --git a/source/common/menu/optionmenu.cpp b/source/common/menu/optionmenu.cpp index a7dbf2cf8..c5e1d5f14 100644 --- a/source/common/menu/optionmenu.cpp +++ b/source/common/menu/optionmenu.cpp @@ -539,3 +539,23 @@ FOptionMenuItem *FOptionMenuDescriptor::GetItem(FName name) } return NULL; } + +class PlayerMenu : public DOptionMenu +{ + using Super = DOptionMenu; + +public: + void Drawer() + { + // Hack: The team item is #3. This part doesn't work properly yet. + gi->DrawPlayerSprite(origin, (mDesc->mSelectedItem == 3)); + Super::Drawer(); + } +}; + +static TMenuClassDescriptor _ppm("NewPlayerMenu"); + +void RegisterOptionMenus() +{ + menuClasses.Push(&_ppm); +} diff --git a/source/duke3d/src/d_menu.cpp b/source/duke3d/src/d_menu.cpp index 0930c3aa2..9dff0969f 100644 --- a/source/duke3d/src/d_menu.cpp +++ b/source/duke3d/src/d_menu.cpp @@ -757,12 +757,10 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t mgametextcenter(int(origin.X * 65536), int((origin.Y + position) * 65536), text); } -#if 0 -void GameInterface::DrawPlayerSprite(int x, int y) +void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) { - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(playerteam) : playercolor,10); + rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y*65536) + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10); } -#endif END_DUKE_NS diff --git a/source/duke3d/src/duke3d.h b/source/duke3d/src/duke3d.h index 85978763d..231aa76f2 100644 --- a/source/duke3d/src/duke3d.h +++ b/source/duke3d/src/duke3d.h @@ -169,6 +169,7 @@ struct GameInterface : ::GameInterface bool SaveGame(FSaveGameNode*) override; bool LoadGame(FSaveGameNode*) override; void DoPrintMessage(int prio, const char*) override; + void DrawPlayerSprite(const DVector2& origin, bool onteam) override; }; diff --git a/source/rr/src/d_menu.cpp b/source/rr/src/d_menu.cpp index 5c3334abb..ec69acf1b 100644 --- a/source/rr/src/d_menu.cpp +++ b/source/rr/src/d_menu.cpp @@ -475,15 +475,13 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t } -#if 0 -void GameInterface::DrawPlayerSprite(int x, int y) +void GameInterface::DrawPlayerSprite(const DVector2& origin, bool onteam) { if (RR) - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t) totalclock>>4)))&7)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(playerteam) : playercolor,10); + rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[APLAYER].y>>2))<<16), 24576L,0,3845+36-((((8-((int32_t) totalclock>>4)))&7)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10); else - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(playerteam) : playercolor,10); + rotatesprite_fs(int(origin.X * 65536) + (260<<16), int(origin.Y * 65536) + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,onteam ? G_GetTeamPalette(playerteam) : G_CheckPlayerColor(playercolor),10); } -#endif END_RR_NS diff --git a/source/rr/src/duke3d.h b/source/rr/src/duke3d.h index 52b1985e2..523cf612c 100644 --- a/source/rr/src/duke3d.h +++ b/source/rr/src/duke3d.h @@ -169,6 +169,7 @@ struct GameInterface : ::GameInterface bool SaveGame(FSaveGameNode*) override; bool LoadGame(FSaveGameNode*) override; void DoPrintMessage(int prio, const char* text) override; + void DrawPlayerSprite(const DVector2& origin, bool onteam) override; }; END_RR_NS diff --git a/source/rr/src/game.h b/source/rr/src/game.h index b3791e105..7b451136e 100644 --- a/source/rr/src/game.h +++ b/source/rr/src/game.h @@ -307,7 +307,7 @@ void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t ste //void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile); void G_InitTimer(int32_t ticspersec); -static inline int32_t G_GetTeamPalette(int32_t team) +inline int32_t G_GetTeamPalette(int32_t team) { int8_t pal[] = { 3, 10, 11, 12 }; diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 8b7b51e9b..4f00dda81 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -965,15 +965,15 @@ OptionValue "PlayerColors" { 0, "$OPTVAL_AUTO" 1, "$TXT_COLOR_BLUE" - 2, "TXT_COLOR_RED" - 3, "TXT_COLOR_GREEN" - 4, "TXT_COLOR_GRAY" - 5, "TXT_COLOR_DARKGRAY" - 6, "TXT_COLOR_DARKGREEN" - 7, "TXT_COLOR_BROWN" - 8, "TXT_COLOR_DARKBLUE" - 9, "TXT_COLOR_LIGHTRED" - 10, "TXT_COLOR_YELLOW" + 2, "$TXT_COLOR_RED" + 3, "$TXT_COLOR_GREEN" + 4, "$TXT_COLOR_GRAY" + 5, "$TXT_COLOR_DARKGRAY" + 6, "$TXT_COLOR_DARKGREEN" + 7, "$TXT_COLOR_BROWN" + 8, "$TXT_COLOR_DARKBLUE" + 9, "$TXT_COLOR_LIGHTRED" + //10, "TXT_COLOR_YELLOW" } OptionValue "PlayerTeam" @@ -997,9 +997,9 @@ OptionMenu "NewPlayerMenu" //protected { Title "$MNU_PLAYERSETUP" TextField "$PLYRMNU_NAME", playername - Option "$PLYRMNU_TEAM", "playerteam", "PlayerTeam" Option "$PLYRMNU_PLAYERCOLOR", "playercolor", "PlayerColors" Option "$PLYRMNU_PLAYERGENDER", "playergender", "Gender" + Option "$PLYRMNU_TEAM", "playerteam", "PlayerTeam" Submenu "$PLRMNU_TAUNTS", "TauntsMenu" Class "NewPlayerMenu" } @@ -1048,7 +1048,6 @@ OptionValue "WeapSwitch" OptionMenu GameplayOptions //protected { - Position -35 Title "$GMPLYMNU_TITLE" Option "$PLRMNU_AUTOAIM", "cl_autoaim", "AimMode" Option "$PLRMNU_ALWAYSRUN", "cl_autorun", "OnOff"