From 789eb6d51db806441d0bdd031bb21bcfe96a95a5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Oct 2020 20:32:43 +0200 Subject: [PATCH] - Most of Duke's menus work again. --- source/blood/src/d_menu.cpp | 36 ---- source/core/menu/razemenu.cpp | 15 +- source/games/duke/src/d_menu.cpp | 161 +----------------- source/games/duke/src/dispatch.cpp | 1 - source/games/duke/src/duke3d.h | 1 - source/games/duke/src/flags_d.cpp | 1 - source/games/duke/src/flags_r.cpp | 1 - source/games/duke/src/namelist_d.h | 9 +- source/games/duke/src/namelist_r.h | 17 +- source/games/duke/src/names.h | 1 - source/games/duke/src/sbar_r.cpp | 2 +- wadsrc/static/menudef.txt | 69 +++----- wadsrc/static/zscript/games/duke/ui/menu.zs | 115 +++++++++++++ .../static/zscript/ui/menu/menucustomize.zs | 2 +- 14 files changed, 180 insertions(+), 251 deletions(-) diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index d4ba90fe0..7842c4ddf 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -152,42 +152,6 @@ void UpdateNetworkMenus(void) } } - -#if 0 - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -class BloodImageScreen : public ImageScreen -{ - CGameMenuItemQAV anim; -public: - BloodImageScreen(FImageScrollerDescriptor::ScrollerItem* desc) - : ImageScreen(desc), anim(169, 100, mDesc->text.GetChars(), false, true) - { - - } - - void Drawer() override - { - anim.Draw(); - } -}; - -class DBloodImageScrollerMenu : public DImageScrollerMenu -{ - ImageScreen* newImageScreen(FImageScrollerDescriptor::ScrollerItem* desc) override - { - if (desc->type >= 0) return DImageScrollerMenu::newImageScreen(desc); - return new BloodImageScreen(desc); - } -}; - -#endif - //---------------------------------------------------------------------------- // // Menu related game interface functions diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index cd25fcfae..5dab7a6d3 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -98,6 +98,10 @@ bool M_SetSpecialMenu(FName& menu, int param) switch (menu.GetIndex()) { + case NAME_Mainmenu: + if (gi->CanSave()) menu = NAME_IngameMenu; + break; + case NAME_Skillmenu: // sent from the episode menu NewGameStartupInfo.Episode = param; @@ -387,7 +391,7 @@ static void BuildEpisodeMenu() { int isShareware = ((g_gameType & GAMEFLAG_DUKE) && (g_gameType & GAMEFLAG_SHAREWARE) && i > 0); auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, gVolumeNames[i][0], - gVolumeNames[i], ld->mFont, ld->mFontColor, isShareware, NAME_Skillmenu, i); // font colors are not used, so hijack one for the shareware flag. + gVolumeNames[i], ld->mFont, 0, isShareware, NAME_Skillmenu, i); // font colors are not used, so hijack one for the shareware flag. y += ld->mLinespacing; ld->mItems.Push(it); @@ -407,7 +411,7 @@ static void BuildEpisodeMenu() //ld->mItems.Push(it); y += ld->mLinespacing / 3; - auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, 'U', "$MNU_USERMAP", ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_UsermapMenu); + auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, 'U', "$MNU_USERMAP", ld->mFont, 0, 0, NAME_UsermapMenu); ld->mItems.Push(it); addedVolumes++; } @@ -438,8 +442,7 @@ static void BuildEpisodeMenu() { if (gSkillNames[i].IsNotEmpty()) { - auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, gSkillNames[i][0], - gSkillNames[i], ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Startgame, i); + auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, gSkillNames[i][0], gSkillNames[i], ld->mFont, 0, 0, NAME_Startgame, i); y += ld->mLinespacing; ld->mItems.Push(it); addedSkills++; @@ -448,7 +451,7 @@ static void BuildEpisodeMenu() if (addedSkills == 0) { // Need to add one item with the default skill so that the menu does not break. - auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, 0, "", ld->mFont, ld->mFontColor, ld->mFontColor2, NAME_Startgame, gDefaultSkill); + auto it = CreateCustomListMenuItemText(ld->mXpos, y, ld->mLinespacing, 0, "", ld->mFont, 0, 0, NAME_Startgame, gDefaultSkill); ld->mItems.Push(it); } if (addedSkills == 1) @@ -633,7 +636,7 @@ CCMD(reset2saved) CCMD(menu_main) { M_StartControlPanel(true); - M_SetMenu(gi->CanSave() ? NAME_IngameMenu : NAME_Mainmenu, -1); + M_SetMenu(NAME_Mainmenu, -1); } CCMD(openhelpmenu) diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index 9fadefc63..902566378 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -57,168 +57,12 @@ static void Menu_DrawBackground(const DVector2 &origin) DrawTexture(twod, tileGetTexture(TILE_MENUSCREEN), origin.X + 160, origin.Y + 100, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, 0xff808080, DTA_CenterOffset, true, TAG_DONE); } -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -static void Menu_DrawCursor(double x, double y, double scale, bool right) -{ - int mclock = I_GetBuildTime(); - const int frames = isRR() ? 16 : 7; - int picnum; - if (!right) picnum = TILE_SPINNINGNUKEICON + ((mclock >> 3) % frames); - else picnum = TILE_SPINNINGNUKEICON + frames - 1 - ((frames - 1 + (mclock >> 3)) % frames); - int light = 231 + (calcSinTableValue(mclock<<5) / 768.); - PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(picnum), x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); -} - -//---------------------------------------------------------------------------- -// -// Implements the native looking menu used for the main menu -// and the episode/skill selection screens, i.e. the parts -// that need to look authentic -// -//---------------------------------------------------------------------------- - -#if 0 -class DukeListMenu : public DListMenu -{ - using Super = DListMenu; -protected: - - void Ticker() override - { - // Lay out the menu. - int y_upper = mDesc->mYpos; - int y_lower = y_upper + mDesc->mYbotton; - int y = 0; - int spacing = 0; - const int height = 15; // cannot take value from the font because it would be inconsistent - - int totalheight = 0, numvalidentries = mDesc->mItems.Size(); - - for (unsigned e = 0; e < mDesc->mItems.Size(); ++e) - { - auto entry = mDesc->mItems[e]; - entry->mHidden = false; - entry->SetHeight(height); - totalheight += height; - } - if (mDesc->mSpacing <= 0) spacing = std::max(0, (y_lower - y_upper - totalheight) / (numvalidentries > 1 ? numvalidentries - 1 : 1)); - if (spacing <= 0) spacing = mDesc->mSpacing; - - int totalHeight; - for (unsigned e = 0; e < mDesc->mItems.Size(); ++e) - { - auto entry = mDesc->mItems[e]; - if (!entry->mHidden) - { - entry->SetY(y_upper + y); - y += height; - totalHeight = y; - y += spacing; - } - } - } -}; - -//---------------------------------------------------------------------------- -// -// -// -//---------------------------------------------------------------------------- - -class DukeMainMenu : public DukeListMenu -{ - virtual void Init(DMenu* parent = nullptr, FListMenuDescriptor* desc = nullptr) override - { - DukeListMenu::Init(parent, desc); - } - - void PreDraw() override - { - DukeListMenu::PreDraw(); - double x = origin.X + 160; - if (isRRRA()) - { - DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true, TAG_DONE); - } - else if (isRR()) - { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x+5, origin.Y + 24, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true, TAG_DONE); - } - else - { - DrawTexture(twod, tileGetTexture(TILE_INGAMEDUKETHREEDEE), x, origin.Y + 29, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, TAG_DONE); - if (PLUTOPAK) - { - int mclock = I_GetBuildTime(); - int light = 223 + (calcSinTableValue(mclock<<4) / 512.); - PalEntry pe(255, light, light, light); - DrawTexture(twod, tileGetTexture(TILE_PLUTOPAKSPRITE + 2), x + 100, origin.Y + 36, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_Color, pe, DTA_CenterOffsetRel, true, TAG_DONE); - } - } - - } -}; -#endif - //---------------------------------------------------------------------------- // // Menu related game interface functions // //---------------------------------------------------------------------------- -void GameInterface::DrawNativeMenuText(int fontnum, int state, double oxpos, double ypos, float fontscale, const char* text, int flags) -{ -#if 0 - double xpos = oxpos; - int trans; - PalEntry pe; - - double scale = isRR() ? 0.4 : 1.; - if (flags & LMF_Centered) xpos -= BigFont->StringWidth(text) * scale * 0.5; - - if (state == NIT_InactiveState) - { - trans = TRANSLATION(Translation_Remap, 1); - pe = 0xffffffff; - } - else if (state == NIT_SelectedState) - { - trans = 0; - int mclock = I_GetBuildTime(); - int light = 231 + (calcSinTableValue(mclock<<5) / 768.); - pe = PalEntry(255, light, light, light); - } - else - { - trans = 0; - pe = 0xffa0a0a0; - } - - DrawText(twod, BigFont, CR_UNDEFINED, xpos, ypos, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, - DTA_TranslationIndex, trans, TAG_DONE); - - if (state == NIT_SelectedState) - { - const int cursorOffset = 110; - const double cursorScale = isRR() ? 0.2 : 1.0; - const double ymid = ypos + 7; // half height must be hardcoded or layouts will break. - if (flags & LMF_Centered) - { - Menu_DrawCursor(oxpos + cursorOffset, ymid, cursorScale, false); - Menu_DrawCursor(oxpos - cursorOffset, ymid, cursorScale, true); - } - else - Menu_DrawCursor(oxpos - cursorOffset, ymid, cursorScale, false); - } -#endif -} - void GameInterface::MenuOpened() { StopCommentary(); @@ -285,7 +129,6 @@ bool GameInterface::StartGame(FNewGameStartup& gs) static const short sounds_r[] = { 427, 428, 196, 195, 197 }; if (gs.Skill >=0 && gs.Skill <= 5) skillsound = isRR()? sounds_r[gs.Skill] : sounds_d[gs.Skill]; -#if 0 if (menu_sounds && skillsound >= 0 && SoundEnabled() && !netgame) { S_PlaySound(skillsound, CHAN_AUTO, CHANF_UI); @@ -298,7 +141,7 @@ bool GameInterface::StartGame(FNewGameStartup& gs) } Net_ClearFifo(); } -#endif + auto map = FindMapByLevelNum(levelnum(gs.Episode, gs.Level)); if (map) { @@ -319,7 +162,7 @@ void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *t if (bg) Menu_DrawBackground(origin); else if (!isRR()) { - Menu_DrawCursor(160, 130, 1, false); + //Menu_DrawCursor(160, 130, 1, false); } ::GameInterface::DrawCenteredTextScreen(origin, text, position, bg); } diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index c34984cf0..e1cb71262 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -252,7 +252,6 @@ int TILE_CAMCORNER; int TILE_CAMLIGHT; int TILE_STATIC; int TILE_BOTTOMSTATUSBAR; -int TILE_SPINNINGNUKEICON; int TILE_THREEDEE; int TILE_INGAMEDUKETHREEDEE; int TILE_PLUTOPAKSPRITE; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index b6acf7a7c..aef65aea9 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -36,7 +36,6 @@ struct GameInterface : public ::GameInterface bool GenerateSavePic() override; void PlayHudSound() override; GameStats getStats() override; - void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override; void MenuOpened() override; void MenuSound(EMenuSounds snd) override; void MenuClosed() override; diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 3332f1e45..11f2dec90 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -253,7 +253,6 @@ void initactorflags_d() TILE_CAMLIGHT = CAMLIGHT; TILE_STATIC = STATIC; TILE_BOTTOMSTATUSBAR = isWorldTour()? WIDESCREENSTATUSBAR : BOTTOMSTATUSBAR; - TILE_SPINNINGNUKEICON = SPINNINGNUKEICON; TILE_THREEDEE = THREEDEE; TILE_INGAMEDUKETHREEDEE = INGAMEDUKETHREEDEE; TILE_PLUTOPAKSPRITE = PLUTOPAKSPRITE; diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index b1fd79c1b..900dc7ac7 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -222,7 +222,6 @@ void initactorflags_r() TILE_CAMLIGHT = CAMLIGHT; TILE_STATIC = STATIC; TILE_BOTTOMSTATUSBAR = BOTTOMSTATUSBAR; - TILE_SPINNINGNUKEICON = SPINNINGNUKEICON; TILE_THREEDEE = THREEDEE; TILE_INGAMEDUKETHREEDEE = INGAMEDUKETHREEDEE; TILE_PLUTOPAKSPRITE = PLUTOPAKSPRITE; diff --git a/source/games/duke/src/namelist_d.h b/source/games/duke/src/namelist_d.h index b4cf80585..7f62378b0 100644 --- a/source/games/duke/src/namelist_d.h +++ b/source/games/duke/src/namelist_d.h @@ -517,6 +517,7 @@ x(THREEDEE, 2498) x(INGAMEDUKETHREEDEE, 2499) x(TENSCREEN, 2500) x(PLUTOPAKSPRITE, 2501) +x(MENUPLUTOPAKSPRITE, 2503) x(DEVISTATOR, 2510) x(KNEE, 2521) x(CROSSHAIR, 2523) @@ -555,7 +556,13 @@ x(BOSS1LOB, 2670) x(BOSSTOP, 2696) x(BOSS2, 2710) x(BOSS3, 2760) -x(SPINNINGNUKEICON, 2813) +x(SPINNINGNUKEICON0, 2813) +x(SPINNINGNUKEICON1, 2814) +x(SPINNINGNUKEICON2, 2815) +x(SPINNINGNUKEICON3, 2816) +x(SPINNINGNUKEICON4, 2817) +x(SPINNINGNUKEICON5, 2818) +x(SPINNINGNUKEICON6, 2819) x(BIGFNTCURSOR, 2820) x(SMALLFNTCURSOR, 2821) x(STARTALPHANUM, 2822) diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 7a63c7da2..7f0348e99 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -209,7 +209,22 @@ x(BLANK, 820) x(RESPAWNMARKERRED, 866) x(RESPAWNMARKERYELLOW, 876) x(RESPAWNMARKERGREEN, 886) -x(SPINNINGNUKEICON, 896) +x(SPINNINGNUKEICON0, 896) +x(SPINNINGNUKEICON1, 897) +x(SPINNINGNUKEICON2, 898) +x(SPINNINGNUKEICON3, 899) +x(SPINNINGNUKEICON4, 900) +x(SPINNINGNUKEICON5, 901) +x(SPINNINGNUKEICON6, 902) +x(SPINNINGNUKEICON7, 903) +x(SPINNINGNUKEICON8, 904) +x(SPINNINGNUKEICON9, 905) +x(SPINNINGNUKEICON10, 906) +x(SPINNINGNUKEICON11, 907) +x(SPINNINGNUKEICON12, 908) +x(SPINNINGNUKEICON13, 909) +x(SPINNINGNUKEICON14, 910) +x(SPINNINGNUKEICON15, 911) x(GUTMETER_LIGHT1, 920) x(GUTMETER_LIGHT2, 921) x(GUTMETER_LIGHT3, 922) diff --git a/source/games/duke/src/names.h b/source/games/duke/src/names.h index f41e8f39d..2318c9bd1 100644 --- a/source/games/duke/src/names.h +++ b/source/games/duke/src/names.h @@ -22,7 +22,6 @@ extern int TILE_CAMCORNER; extern int TILE_CAMLIGHT; extern int TILE_STATIC; extern int TILE_BOTTOMSTATUSBAR; -extern int TILE_SPINNINGNUKEICON; extern int TILE_THREEDEE; extern int TILE_INGAMEDUKETHREEDEE; extern int TILE_PLUTOPAKSPRITE; diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp index 181b510f5..945267b52 100644 --- a/source/games/duke/src/sbar_r.cpp +++ b/source/games/duke/src/sbar_r.cpp @@ -102,7 +102,7 @@ public: // // Health // - img = tileGetTexture(SPINNINGNUKEICON+1); + img = tileGetTexture(SPINNINGNUKEICON1); imgScale = baseScale / img->GetDisplayHeight(); DrawGraphic(img, 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index dfda19da6..91ba12cdd 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -7,21 +7,19 @@ LISTMENU "MainMenu" { Size 320, 200 - //class "$.MainMenu" ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) { - /* - position 160, 55, 115 - centermenu - animatedtransition - NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" - //NativeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder. - NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" - NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" - NativeTextItem "$MNU_HELP", "h", "HelpMenu" - NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu" - NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu" - */ + position 160, 55 + Linespacing 20 + //animatedtransition + DukeLogo + DukeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" + //DukeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder. + DukeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + DukeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" + DukeTextItem "$MNU_HELP", "h", "HelpMenu" + DukeTextItem "$MNU_CREDITS", "c", "CreditsMenu" + DukeTextItem "$MNU_QUITGAME", "q", "QuitMenu" } ifgame(Blood) { @@ -81,22 +79,20 @@ LISTMENU "MainMenu" LISTMENU "IngameMenu" { - /* - class "$.MainMenu" ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) { position 160, 55 - centermenu - animatedtransition - NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" - NativeTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu" - NativeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" - NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" - NativeTextItem "$MNU_HELP", "h", "HelpMenu" - NativeTextItem "$MNU_ENDGAME", "e", "EndgameMenu" - NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu" + linespacing 18 + //animatedtransition + DukeLogo + DukeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" + DukeTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu" + DukeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu" + DukeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" + DukeTextItem "$MNU_HELP", "h", "HelpMenu" + DukeTextItem "$MNU_ENDGAME", "e", "EndgameMenu" + DukeTextItem "$MNU_QUITGAME", "q", "QuitMenu" } - */ ifgame(Blood) { position 160, 45 @@ -154,17 +150,13 @@ LISTMENU "IngameMenu" LISTMENU "EpisodeMenu" { - /* ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) { - class "$.ListMenu" - caption "$MNU_SELECTEPISODE" position 160, 48 - centermenu - fixedspacing 5 - animatedtransition + Linespacing 20 + captionItem "$MNU_SELECTEPISODE" + //animatedtransition } - */ ifgame(blood) { position 160, 45 @@ -184,18 +176,13 @@ LISTMENU "EpisodeMenu" LISTMENU "SkillMenu" { - /* ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) { - class "$.ListMenu" - position 160, 55, 115 - centermenu - animatedtransition - caption "$MNU_SELECTSKILL" - fixedspacing 5 - animatedtransition + position 160, 48 + Linespacing 20 + captionItem "$MNU_SELECTSKILL" + //animatedtransition } - */ ifgame(blood) { position 160, 60 diff --git a/wadsrc/static/zscript/games/duke/ui/menu.zs b/wadsrc/static/zscript/games/duke/ui/menu.zs index 27167bdeb..720c57565 100644 --- a/wadsrc/static/zscript/games/duke/ui/menu.zs +++ b/wadsrc/static/zscript/games/duke/ui/menu.zs @@ -24,4 +24,119 @@ class DukeMenuDelegate : RazeMenuDelegate int h = texid.isValid()? texsize.Y : fonth; return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels. } + + static int calcSinTableValue(int ang) + { + return int(16384 * sin((360./2048) * ang)); + } + + //---------------------------------------------------------------------------- + // + // + // + //---------------------------------------------------------------------------- + + void DrawCursor(double x, double y, double scale, bool right) + { + int mclock = MSTime() * 120 / 1000; + int frames = (gameinfo.gametype & GAMEFLAG_RR) ? 16 : 7; + String picname; + if (!right) picname= String.Format("SPINNINGNUKEICON%d", ((mclock >> 3) % frames)); + else picname = String.Format("SPINNINGNUKEICON%d", frames - 1 - ((frames - 1 + (mclock >> 3)) % frames)); + int light = 231 + (calcSinTableValue(mclock<<5) / 768.); + let pe = color(255, light, light, light); + Screen.DrawTexture(TexMan.CheckForTexture(picname), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true); + } + + override bool DrawSelector(ListMenuDescriptor desc) + { + int cursorOffset = 110; + double cursorScale = (gameinfo.gametype & GAMEFLAG_RR) ? 0.2 : 1.0; + double ymid = desc.mItems[desc.mSelectedItem].GetY() + 7; // half height must be hardcoded or layouts will break. + DrawCursor(160 + cursorOffset, ymid, cursorScale, false); + DrawCursor(169 - cursorOffset, ymid, cursorScale, true); + return true; + } +} + +//---------------------------------------------------------------------------- +// +// Logo +// +//---------------------------------------------------------------------------- + +class ListMenuItemDukeLogo : ListMenuItem +{ + const x = 160; + + void Init(ListMenuDescriptor desc) + { + Super.Init(0, 0); + } + + override void Draw(bool selected, ListMenuDescriptor desc) + { + if (gameinfo.gametype & GAMEFLAG_RRRA) + { + Screen.DrawTexture(TexMan.CheckForTexture("THREEDEE"), false, x-5, 57, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true); + } + else if (gameinfo.gametype & GAMEFLAG_RR) + { + Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), false, x+5, 24, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true); + } + else + { + Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), false, x, 29, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true); + if (gameinfo.gametype & GAMEFLAG_PLUTOPAK) + { + int mclock = MSTime() * 120 / 1000; + int light = 223 + (DukeMenuDelegate.calcSinTableValue(mclock<<4) / 512.); + let pe = Color(255, light, light, light); + Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), false, x + 100, 36, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_Color, pe, DTA_CenterOffsetRel, true); + } + } + + } +} + +//---------------------------------------------------------------------------- +// +// text item +// +//---------------------------------------------------------------------------- + +class ListMenuItemDukeTextItem : ListMenuItemTextItem +{ + void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0) + { + Super.Init(desc, text, hotkey, child, param); + mColorSelected = 0; + } + + void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0) + { + Super.InitDirect(x, y, height, hotkey, text, font, color, color2, child, param); + } + + override void Draw(bool selected, ListMenuDescriptor desc) + { + int trans = mColorSelected? Translation.MakeID(Translation_Remap, 1) : 0; + Color pe; + double scale = (gameinfo.gametype & GAMEFLAG_RR) ? 0.4 : 1.; + let xpos = mXpos - BigFont.StringWidth(mText) * scale * 0.5; + + if (selected) + { + int mclock = MSTime() * 120 / 1000; + int light = 231 + (DukeMenuDelegate.calcSinTableValue(mclock<<5) / 512.); + pe = Color(255, light, light, light); + } + else + { + pe = Color(255, 160, 160, 160); + } + + Screen.DrawText(BigFont, Font.CR_UNDEFINED, xpos, mYpos, mText, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_TranslationIndex, trans); + } + } diff --git a/wadsrc/static/zscript/ui/menu/menucustomize.zs b/wadsrc/static/zscript/ui/menu/menucustomize.zs index 35d330d6a..3d3ee1431 100644 --- a/wadsrc/static/zscript/ui/menu/menucustomize.zs +++ b/wadsrc/static/zscript/ui/menu/menucustomize.zs @@ -1,6 +1,6 @@ // This class allows global customization of certain menu aspects, e.g. replacing the menu caption. -class MenuDelegateBase +class MenuDelegateBase ui { virtual int DrawCaption(String title, Font fnt, int y, bool drawit) {