From 963d1b682cad268700cd5651efa5ac66fcaa7a6d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Mar 2019 17:46:59 +0100 Subject: [PATCH] - fixed layout issues with Strife's dialogues. They were using some settings from the option menu which they never should have used to begin with. --- src/menu/menu.cpp | 6 +++++- src/menu/menu.h | 2 +- src/p_conversation.cpp | 2 +- wadsrc/static/zscript/ui/menu/conversationmenu.zs | 14 ++++++++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 03a647bbf..38a864e2b 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -61,6 +61,7 @@ #include "scripting/types.h" int DMenu::InMenu; +static ScaleOverrider *CurrentScaleOverrider; // // Todo: Move these elsewhere // @@ -340,7 +341,7 @@ bool DMenu::TranslateKeyboardEvents() // //============================================================================= -void M_StartControlPanel (bool makeSound) +void M_StartControlPanel (bool makeSound, bool scaleoverride) { // intro might call this repeatedly if (CurrentMenu != nullptr) @@ -364,6 +365,7 @@ void M_StartControlPanel (bool makeSound) } BackbuttonTime = 0; BackbuttonAlpha = 0; + if (scaleoverride && !CurrentScaleOverrider) CurrentScaleOverrider = new ScaleOverrider; } //============================================================================= @@ -848,6 +850,8 @@ void M_ClearMenus() } V_SetBorderNeedRefresh(); menuactive = MENU_Off; + if (CurrentScaleOverrider) delete CurrentScaleOverrider; + CurrentScaleOverrider = nullptr; } //============================================================================= diff --git a/src/menu/menu.h b/src/menu/menu.h index b6019ba4a..04e67870f 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -339,7 +339,7 @@ void M_ActivateMenu(DMenu *menu); void M_ClearMenus (); void M_ParseMenuDefs(); void M_StartupSkillMenu(FGameStartup *gs); -void M_StartControlPanel (bool makeSound); +void M_StartControlPanel (bool makeSound, bool scaleoverride = true); void M_SetMenu(FName menu, int param = -1); void M_StartMessage(const char *message, int messagemode, FName action = NAME_None); DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index fdaf8585c..edf5b3eac 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -925,6 +925,7 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang I_SetMusicVolume (dlg_musicvolume); S_Sound (npc, CHAN_VOICE|CHAN_NOPAUSE, CurNode->SpeakerVoice, 1, ATTN_NORM); } + M_StartControlPanel(false, true); // Create the menu. This may be a user-defined class so check if it is good to use. FName cls = CurNode->MenuClassName; @@ -949,7 +950,6 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang } // And open the menu - M_StartControlPanel (false); M_ActivateMenu((DMenu*)cmenu); menuactive = MENU_OnNoPause; } diff --git a/wadsrc/static/zscript/ui/menu/conversationmenu.zs b/wadsrc/static/zscript/ui/menu/conversationmenu.zs index 9e20f305f..1be1097dd 100644 --- a/wadsrc/static/zscript/ui/menu/conversationmenu.zs +++ b/wadsrc/static/zscript/ui/menu/conversationmenu.zs @@ -82,6 +82,7 @@ class ConversationMenu : Menu PlayerInfo mPlayer; int mSelection; int ConversationPauseTic; + int LineHeight; int SpeechWidth; int ReplyWidth; @@ -107,6 +108,7 @@ class ConversationMenu : Menu ReplyWidth = 320-50-10; SpeechWidth = screen.GetWidth()/CleanXfac - 24*2; + LineHeight = SmallFont.GetHeight(); FormatSpeakerMessage(); return FormatReplies(activereply); @@ -174,8 +176,8 @@ class ConversationMenu : Menu mResponseLines.Push(goodbyestr); // Determine where the top of the reply list should be positioned. - mYpos = MIN (140, 192 - mResponseLines.Size() * OptionMenuSettings.mLinespacing); - i = 44 + mResponseLines.Size() * OptionMenuSettings.mLinespacing; + mYpos = MIN (140, 192 - mResponseLines.Size() * LineHeight); + i = 44 + mResponseLines.Size() * LineHeight; if (mYpos - 100 < i - screen.GetHeight() / CleanYfac / 2) { mYpos = i - screen.GetHeight() / CleanYfac / 2 + 100; @@ -305,7 +307,7 @@ class ConversationMenu : Menu override bool MouseEvent(int type, int x, int y) { int sel = -1; - int fh = OptionMenuSettings.mLinespacing; + int fh = LineHeight; // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160; @@ -382,7 +384,7 @@ class ConversationMenu : Menu virtual void DrawSpeakerText(bool dimbg) { String speakerName; - int linesize = OptionMenuSettings.mLinespacing * CleanYfac; + int linesize = LineHeight * CleanYfac; int cnt = mDialogueLines.Count(); // Who is talking to you? @@ -434,10 +436,10 @@ class ConversationMenu : Menu { // Dim the screen behind the PC's choices. screen.Dim(0, 0.45, (24 - 160) * CleanXfac + screen.GetWidth() / 2, (mYpos - 2 - 100) * CleanYfac + screen.GetHeight() / 2, - 272 * CleanXfac, MIN(mResponseLines.Size() * OptionMenuSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac); + 272 * CleanXfac, MIN(mResponseLines.Size() * LineHeight + 4, 200 - mYpos) * CleanYfac); int y = mYpos; - int fontheight = OptionMenuSettings.mLinespacing; + int fontheight = LineHeight; int response = 0; for (int i = 0; i < mResponseLines.Size(); i++)