mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- scriptified the input methods of DConversationMenu.
- fixed handling of DimAllowed.
This commit is contained in:
parent
3c8a5fdbe7
commit
d85b9cdd71
10 changed files with 169 additions and 157 deletions
|
@ -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)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -271,13 +271,13 @@ public:
|
|||
TObjPtr<DMenu> 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);
|
||||
|
|
|
@ -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<mResponses.Size(); i++)
|
||||
{
|
||||
if ((int)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;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
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)
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,7 +80,150 @@ 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);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -89,6 +89,7 @@ class Menu : Object native
|
|||
native Menu mParentMenu;
|
||||
native bool mMouseCapture;
|
||||
native bool mBackbuttonSelected;
|
||||
native bool DontDim;
|
||||
|
||||
void Init(Menu parent)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue