diff --git a/src/g_level.cpp b/src/g_level.cpp index eafdd7209..5bc7d44e0 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1936,6 +1936,7 @@ DEFINE_FIELD_BIT(FLevelLocals, flags2, polygrind, LEVEL2_POLYGRIND) DEFINE_FIELD_BIT(FLevelLocals, flags2, nomonsters, LEVEL2_NOMONSTERS) DEFINE_FIELD_BIT(FLevelLocals, flags2, frozen, LEVEL2_FROZEN) DEFINE_FIELD_BIT(FLevelLocals, flags2, infinite_flight, LEVEL2_INFINITE_FLIGHT) +DEFINE_FIELD_BIT(FLevelLocals, flags2, no_dlg_freeze, LEVEL2_CONV_SINGLE_UNFREEZE) //========================================================================== // diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 6569c00c7..b0bf096f8 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -160,6 +160,7 @@ DMenu::DMenu(DMenu *parent) mParentMenu = parent; mMouseCapture = false; mBackbuttonSelected = false; + DontDim = false; GC::WriteBarrier(this, parent); } @@ -445,11 +446,6 @@ DEFINE_ACTION_FUNCTION(DMenu, Close) return 0; } -bool DMenu::DimAllowed() -{ - return true; -} - bool DMenu::TranslateKeyboardEvents() { IFVIRTUAL(DMenu, TranslateKeyboardEvents) @@ -928,7 +924,7 @@ void M_Drawer (void) if (CurrentMenu != nullptr && menuactive != MENU_Off) { - if (CurrentMenu->DimAllowed()) + if (!CurrentMenu->DontDim) { screen->Dim(fade); V_SetBorderNeedRefresh(); @@ -1203,6 +1199,7 @@ CCMD(undocolorpic) DEFINE_FIELD(DMenu, mParentMenu) DEFINE_FIELD(DMenu, mMouseCapture); DEFINE_FIELD(DMenu, mBackbuttonSelected); +DEFINE_FIELD(DMenu, DontDim); DEFINE_FIELD(DMenuDescriptor, mMenuName) DEFINE_FIELD(DMenuDescriptor, mNetgameMessage) diff --git a/src/menu/menu.h b/src/menu/menu.h index 415e3dff6..7d1236ccf 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -271,13 +271,13 @@ public: TObjPtr mParentMenu; bool mMouseCapture; bool mBackbuttonSelected; + bool DontDim; DMenu(DMenu *parent = NULL); virtual bool Responder (event_t *ev); virtual bool MenuEvent (int mkey, bool fromcontroller); virtual void Ticker (); virtual void Drawer (); - virtual bool DimAllowed (); bool TranslateKeyboardEvents(); virtual void Close(); virtual bool MouseEvent(int type, int x, int y); diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index dbee57a4e..10562428b 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -689,8 +689,18 @@ static bool ShouldSkipReply(FStrifeDialogueReply *reply, player_t *player) return false; } -static void SendConversationReply(int node, int reply) +DEFINE_ACTION_FUNCTION(FStrifeDialogueReply, ShouldSkipReply) { + PARAM_SELF_STRUCT_PROLOGUE(FStrifeDialogueReply); + PARAM_POINTER(player, player_t); + ACTION_RETURN_BOOL(ShouldSkipReply(self, player)); +} + +DEFINE_ACTION_FUNCTION(DConversationMenu, SendConversationReply) +{ + PARAM_PROLOGUE; + PARAM_INT(node); + PARAM_INT(reply); switch (node) { case -1: @@ -708,6 +718,7 @@ static void SendConversationReply(int node, int reply) break; } StaticLastReply = reply; + return 0; } @@ -874,154 +885,6 @@ public: } } - //============================================================================= - // - // - // - //============================================================================= - - void OnDestroy() override - { - mDialogueLines->Destroy(); - mDialogueLines = NULL; - I_SetMusicVolume (1.f); - Super::OnDestroy(); - } - - bool DimAllowed() - { - return false; - } - - int GetReplyNum() - { - assert((unsigned)mCurNode->ThisNodeNum < StrifeDialogues.Size()); - assert(StrifeDialogues[mCurNode->ThisNodeNum] == mCurNode); - - // This is needed because mSelection represents the replies currently being displayed which will - // not match up with what's supposed to be selected if there are any hidden/skipped replies. [FishyClockwork] - FStrifeDialogueReply *reply = mCurNode->Children; - int replynum = mSelection; - for (int i = 0; i <= mSelection && reply != nullptr; reply = reply->Next) - { - if (ShouldSkipReply(reply, mPlayer)) - replynum++; - else - i++; - } - return replynum; - } - - //============================================================================= - // - // - // - //============================================================================= - - bool MenuEvent(int mkey, bool fromcontroller) - { - if (demoplayback) - { // During demo playback, don't let the user do anything besides close this menu. - if (mkey == MKEY_Back) - { - Close(); - return true; - } - return false; - } - if (mkey == MKEY_Up) - { - if (--mSelection < 0) mSelection = mResponses.Size() - 1; - return true; - } - else if (mkey == MKEY_Down) - { - if (++mSelection >= (int)mResponses.Size()) mSelection = 0; - return true; - } - else if (mkey == MKEY_Back) - { - SendConversationReply(-1, GetReplyNum()); - Close(); - return true; - } - else if (mkey == MKEY_Enter) - { - int replynum = GetReplyNum(); - if ((unsigned)mSelection >= mResponses.Size()) - { - SendConversationReply(-1, replynum); - } - else - { - // Send dialogue and reply numbers across the wire. - SendConversationReply(mCurNode->ThisNodeNum, replynum); - } - Close(); - return true; - } - return false; - } - - //============================================================================= - // - // - // - //============================================================================= - - bool MouseEvent(int type, int x, int y) - { - int sel = -1; - int fh = OptionSettings.mLinespacing; - - // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture - x = ((x - (screen->GetWidth() / 2)) / CleanXfac) + 160; - y = ((y - (screen->GetHeight() / 2)) / CleanYfac) + 100; - - if (x >= 24 && x <= 320-24 && y >= mYpos && y < mYpos + fh * (int)mResponseLines.Size()) - { - sel = (y - mYpos) / fh; - for(unsigned i=0;i sel) - { - sel = i-1; - break; - } - } - } - if (sel != -1 && sel != mSelection) - { - //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); - } - mSelection = sel; - if (type == MOUSE_Release) - { - return MenuEvent(MKEY_Enter, true); - } - return true; - } - - - //============================================================================= - // - // - // - //============================================================================= - - bool Responder(event_t *ev) - { - if (demoplayback) - { // No interaction during demo playback - return false; - } - if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_Char && ev->data1 >= '0' && ev->data1 <= '9') - { // Activate an item of type numberedmore (dialogue only) - mSelection = ev->data1 == '0' ? 9 : ev->data1 - '1'; - return MenuEvent(MKEY_Enter, false); - } - return Super::Responder(ev); - } }; IMPLEMENT_CLASS(DConversationMenu, true, false) diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 3808194e1..b527832fd 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -909,6 +909,9 @@ void InitThingdef() fieldptr = new PField("gametic", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&gametic); Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + fieldptr = new PField("demoplayback", TypeSInt32, VARF_Native | VARF_Static | VARF_ReadOnly, (intptr_t)&demoplayback); + Namespaces.GlobalNamespace->Symbols.AddSymbol(fieldptr); + // Argh. It sucks when bad hacks need to be supported. WP_NOCHANGE is just a bogus pointer but it used everywhere as a special flag. // It cannot be defined as constant because constants can either be numbers or strings but nothing else, so the only 'solution' diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index fcad86814..b2eff2601 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -463,6 +463,7 @@ struct LevelLocals native native bool nomonsters; native bool frozen; native bool infinite_flight; + native bool no_dlg_freeze; // level_info_t *info cannot be done yet. native String GetUDMFString(int type, int index, Name key); diff --git a/wadsrc/static/zscript/menu/conversationmenu.txt b/wadsrc/static/zscript/menu/conversationmenu.txt index 474fd50f2..efe843c51 100644 --- a/wadsrc/static/zscript/menu/conversationmenu.txt +++ b/wadsrc/static/zscript/menu/conversationmenu.txt @@ -63,6 +63,8 @@ struct StrifeDialogueReply native native int NextNode; // index into StrifeDialogues native int LogNumber; native bool NeedsGold; + + native bool ShouldSkipReply(PlayerInfo player); } @@ -78,8 +80,151 @@ class ConversationMenu : Menu native native PlayerInfo mPlayer; native int mSelection; + native static void SendConversationReply(int node, int reply); + //ConversationPauseTic = gametic + 20; + // DontDim = true; + //============================================================================= + // + // + // + //============================================================================= + + override void OnDestroy() + { + mDialogueLines.Destroy(); + SetMusicVolume (1); + Super.OnDestroy(); + } + + protected int GetReplyNum() + { + // This is needed because mSelection represents the replies currently being displayed which will + // not match up with what's supposed to be selected if there are any hidden/skipped replies. [FishyClockwork] + let reply = mCurNode.Children; + int replynum = mSelection; + for (int i = 0; i <= mSelection && reply != null; reply = reply.Next) + { + if (reply.ShouldSkipReply(mPlayer)) + replynum++; + else + i++; + } + return replynum; + } + + //============================================================================= + // + // + // + //============================================================================= + + override bool MenuEvent(int mkey, bool fromcontroller) + { + if (demoplayback) + { // During demo playback, don't let the user do anything besides close this menu. + if (mkey == MKEY_Back) + { + Close(); + return true; + } + return false; + } + if (mkey == MKEY_Up) + { + if (--mSelection < 0) mSelection = mResponses.Size() - 1; + return true; + } + else if (mkey == MKEY_Down) + { + if (++mSelection >= mResponses.Size()) mSelection = 0; + return true; + } + else if (mkey == MKEY_Back) + { + SendConversationReply(-1, GetReplyNum()); + Close(); + return true; + } + else if (mkey == MKEY_Enter) + { + int replynum = GetReplyNum(); + if (mSelection >= mResponses.Size()) + { + SendConversationReply(-2, replynum); + } + else + { + // Send dialogue and reply numbers across the wire. + SendConversationReply(mCurNode.ThisNodeNum, replynum); + } + Close(); + return true; + } + return false; + } + + //============================================================================= + // + // + // + //============================================================================= + + override bool MouseEvent(int type, int x, int y) + { + int sel = -1; + int fh = OptionMenuSettings.mLinespacing; + + // convert x/y from screen to virtual coordinates, according to CleanX/Yfac use in DrawTexture + x = ((x - (screen.GetWidth() / 2)) / CleanXfac) + 160; + y = ((y - (screen.GetHeight() / 2)) / CleanYfac) + 100; + + if (x >= 24 && x <= 320-24 && y >= mYpos && y < mYpos + fh * mResponseLines.Size()) + { + sel = (y - mYpos) / fh; + for(int i = 0; i < mResponses.Size(); i++) + { + if (mResponses[i] > sel) + { + sel = i-1; + break; + } + } + } + if (sel != -1 && sel != mSelection) + { + //S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE); + } + mSelection = sel; + if (type == MOUSE_Release) + { + return MenuEvent(MKEY_Enter, true); + } + return true; + } + + + //============================================================================= + // + // + // + //============================================================================= + + override bool Responder(InputEventData ev) + { + if (demoplayback) + { // No interaction during demo playback + return false; + } + if (ev.type == InputEventData.GUI_Event && ev.subtype == InputEventData.GUI_Char && ev.data1 >= 48 && ev.data1 <= 57) + { // Activate an item of type numberedmore (dialogue only) + mSelection = ev.data1 == 48 ? 9 : ev.data1 - 49; + return MenuEvent(MKEY_Enter, false); + } + return Super.Responder(ev); + } + //============================================================================ // // Draw the backdrop, returns true if the text background should be dimmed diff --git a/wadsrc/static/zscript/menu/listmenu.txt b/wadsrc/static/zscript/menu/listmenu.txt index db1a4a19c..5821d0323 100644 --- a/wadsrc/static/zscript/menu/listmenu.txt +++ b/wadsrc/static/zscript/menu/listmenu.txt @@ -47,7 +47,7 @@ class ListMenu : Menu virtual void Init(Menu parent = NULL, ListMenuDescriptor desc = NULL) { - mParentMenu = parent; + Super.Init(parent); mDesc = desc; if (desc.mCenter) { diff --git a/wadsrc/static/zscript/menu/menu.txt b/wadsrc/static/zscript/menu/menu.txt index 2f5d9454a..7d0c030df 100644 --- a/wadsrc/static/zscript/menu/menu.txt +++ b/wadsrc/static/zscript/menu/menu.txt @@ -89,6 +89,7 @@ class Menu : Object native native Menu mParentMenu; native bool mMouseCapture; native bool mBackbuttonSelected; + native bool DontDim; void Init(Menu parent) { diff --git a/wadsrc/static/zscript/menu/optionmenu.txt b/wadsrc/static/zscript/menu/optionmenu.txt index c6f0247a7..ed6189335 100644 --- a/wadsrc/static/zscript/menu/optionmenu.txt +++ b/wadsrc/static/zscript/menu/optionmenu.txt @@ -104,6 +104,7 @@ class OptionMenu : Menu { mParentMenu = parent; mDesc = desc; + DontDim = desc.mDontDim; if (mDesc != NULL && mDesc.mSelectedItem == -1) mDesc.mSelectedItem = FirstSelectable(); mDesc.CalcIndent(); }