From 06b00887f5b3586c1a4fe00ecf161936c80de09c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 6 Oct 2020 23:49:34 +0200 Subject: [PATCH] - added a menu control for Blood's dripping blood. --- source/blood/src/d_menu.cpp | 47 +++++++------------- source/core/menu/razemenu.cpp | 46 ++++++++++++++----- wadsrc/static/menudef.txt | 8 ++-- wadsrc/static/zscript/games/blood/ui/menu.zs | 22 +++++++++ 4 files changed, 78 insertions(+), 45 deletions(-) diff --git a/source/blood/src/d_menu.cpp b/source/blood/src/d_menu.cpp index 6a4066bda..fe5c6a6ba 100644 --- a/source/blood/src/d_menu.cpp +++ b/source/blood/src/d_menu.cpp @@ -2,8 +2,9 @@ /* Copyright (C) 2010-2019 EDuke32 developers and contributors Copyright (C) 2019 Nuke.YKT +Copyright (C) 2020 Christoph Oelckers -This file is part of NBlood. +This file is part of Raze. NBlood is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -37,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "sound.h" #include "v_video.h" #include "v_draw.h" +#include "vm.h" bool ShowOptionMenu(); @@ -119,56 +121,39 @@ void CGameMenuItemQAV::Draw(void) } - static std::unique_ptr itemBloodQAV; // This must be global to ensure that the animation remains consistent across menus. +DEFINE_ACTION_FUNCTION(DListMenuItemBloodDripDrawer, Draw) +{ + // For narrow screens this would be mispositioned so skip drawing it there. + double ratio = screen->GetWidth() / double(screen->GetHeight()); + if (ratio > 1.32) itemBloodQAV->Draw(); + return 0; +} + void UpdateNetworkMenus(void) { -#if 0 - // For now disable the network menu item as it is not yet functional. + // For now disable the network menu item as it is not functional. for (auto name : { NAME_Mainmenu, NAME_IngameMenu }) { - FMenuDescriptor** desc = MenuDescriptors.CheckKey(name); - if (desc != NULL && (*desc)->mType == MDESC_ListMenu) + DMenuDescriptor** desc = MenuDescriptors.CheckKey(name); + if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DListMenuDescriptor))) { - FListMenuDescriptor* ld = static_cast(*desc); + DListMenuDescriptor* ld = static_cast(*desc); for (auto& li : ld->mItems) { - if (li->GetAction(nullptr) == NAME_MultiMenu) + if (li->mAction == NAME_MultiMenu) { li->mEnabled = false; } } } } -#endif } #if 0 -//---------------------------------------------------------------------------- -// -// 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 -// -//---------------------------------------------------------------------------- - -class BloodListMenu : public DListMenu -{ - using Super = DListMenu; -protected: - - void PostDraw() - { - // For narrow screens this would be mispositioned so skip drawing it there. - double ratio = screen->GetWidth() / double(screen->GetHeight()); - if (ratio > 1.32) itemBloodQAV->Draw(); - } - -}; - //---------------------------------------------------------------------------- // diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index e8579827d..4d6bc227c 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -56,12 +56,27 @@ #include "i_system.h" #include "gameconfigfile.h" #include "gamecontrol.h" +#include "raze_sound.h" +#include "gamestruct.h" + +enum EMenuSounds : int +{ + ActivateSound, + CursorSound, + AdvanceSound, + BackSound, + CloseSound, + PageSound, + ChangeSound, + ChooseSound +}; EXTERN_CVAR(Int, cl_gfxlocalization) EXTERN_CVAR(Bool, m_quickexit) EXTERN_CVAR(Bool, saveloadconfirmation) // [mxd] EXTERN_CVAR(Bool, quicksaverotation) EXTERN_CVAR(Bool, show_messages) +CVAR(Bool, menu_sounds, true, CVAR_ARCHIVE) // added mainly because RR's sounds are so supremely annoying. typedef void(*hfunc)(); DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr); @@ -158,24 +173,33 @@ bool M_SetSpecialMenu(FName& menu, int param) // //============================================================================= -void M_StartControlPanel(bool makeSound, bool scaleoverride) +void M_MenuSound(EMenuSounds snd) { -#if 0 - if (hud_toggled) - D_ToggleHud(); + if (menu_sounds) gi->MenuSound(snd); +} +//============================================================================= +// +// +// +//============================================================================= + +void M_StartControlPanel(bool makeSound, bool) +{ + static bool created = false; // intro might call this repeatedly - if (CurrentMenu != nullptr) + if (CurrentMenu != NULL) return; - P_CheckTickerPaused(); - - if (makeSound) + if (!created) // Cannot do this earlier. { - S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE); + created = true; + M_CreateMenus(); } - M_DoStartControlPanel(scaleoverride); -#endif + GSnd->SetSfxPaused(true, PAUSESFX_MENU); + gi->MenuOpened(); + if (makeSound) M_MenuSound(ActivateSound); + M_DoStartControlPanel(false); } diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index b5e1bd91c..b70f99896 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -6,6 +6,7 @@ LISTMENU "MainMenu" { + Size 320, 200 //class "$.MainMenu" ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides) { @@ -25,10 +26,10 @@ LISTMENU "MainMenu" ifgame(Blood) { CaptionItem "Blood" - /* - position 160, 45, 150 - centermenu + position 160, 45 Linespacing 20 + /* + centermenu NativeTextItem "$MNU_NEWGAME", "n", "EpisodeMenu" NativeTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu" NativeTextItem "$MNU_OPTIONS", "o", "OptionsMenu" @@ -37,6 +38,7 @@ LISTMENU "MainMenu" NativeTextItem "$MNU_CREDITS", "c", "CreditsMenu" NativeTextItem "$MNU_QUITGAME", "q", "QuitMenu" */ + BloodDripDrawer } ifgame(ShadowWarrior) { diff --git a/wadsrc/static/zscript/games/blood/ui/menu.zs b/wadsrc/static/zscript/games/blood/ui/menu.zs index d617ab5db..e9724f394 100644 --- a/wadsrc/static/zscript/games/blood/ui/menu.zs +++ b/wadsrc/static/zscript/games/blood/ui/menu.zs @@ -1,4 +1,10 @@ +//------------------------------------------------------------------------------------------- +// +// Caption drawer +// +//------------------------------------------------------------------------------------------- + class MenuCustomizerBlood : MenuCustomize { override int DrawCaption(String title, Font fnt, int y, bool drawit) @@ -24,3 +30,19 @@ class MenuCustomizerBlood : MenuCustomize return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels. } } + +//------------------------------------------------------------------------------------------- +// +// The dripping blood - partially native. +// +//------------------------------------------------------------------------------------------- + +class ListMenuItemBloodDripDrawer : ListMenuItem +{ + void Init(ListMenuDescriptor desc) + { + Super.Init(0, 0); + } + + native override void Draw(bool selected, ListMenuDescriptor desc); +} \ No newline at end of file