mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- split up DConversationMenu::Drawer for future flexibility.
- fixed: The in-conversation gold display did not work because it relied on an unused global variable.
This commit is contained in:
parent
129787546d
commit
c4a90f39af
1 changed files with 136 additions and 80 deletions
|
@ -112,7 +112,6 @@ static FDialogueMap ClassRoots;
|
||||||
static int ConversationMenuY;
|
static int ConversationMenuY;
|
||||||
|
|
||||||
static int ConversationPauseTic;
|
static int ConversationPauseTic;
|
||||||
static bool ShowGold;
|
|
||||||
static int StaticLastReply;
|
static int StaticLastReply;
|
||||||
|
|
||||||
static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type);
|
static bool LoadScriptFile(int lumpnum, FileReader *lump, int numnodes, bool include, int type);
|
||||||
|
@ -1026,72 +1025,55 @@ public:
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
// DrawConversationMenu
|
// Draw the backdrop, returns true if the text background should be dimmed
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
void Drawer()
|
virtual bool DrawBackdrop()
|
||||||
{
|
{
|
||||||
const char *speakerName;
|
if (mCurNode->Backdrop.isValid())
|
||||||
int x, y, linesize;
|
|
||||||
int width, fontheight;
|
|
||||||
|
|
||||||
player_t *cp = &players[consoleplayer];
|
|
||||||
|
|
||||||
assert (mDialogueLines != NULL);
|
|
||||||
assert (mCurNode != NULL);
|
|
||||||
|
|
||||||
FStrifeDialogueNode *CurNode = mCurNode;
|
|
||||||
|
|
||||||
if (CurNode == NULL)
|
|
||||||
{
|
{
|
||||||
Close ();
|
screen->DrawTexture(TexMan(mCurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE);
|
||||||
return;
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [CW] Freeze the game depending on MAPINFO options.
|
//============================================================================
|
||||||
if (ConversationPauseTic < gametic && !multiplayer && !(level.flags2 & LEVEL2_CONV_SINGLE_UNFREEZE))
|
//
|
||||||
{
|
// Draw the speaker text
|
||||||
menuactive = MENU_On;
|
//
|
||||||
}
|
//============================================================================
|
||||||
|
|
||||||
if (CurNode->Backdrop.isValid())
|
virtual void DrawSpeakerText(bool dimbg)
|
||||||
{
|
{
|
||||||
screen->DrawTexture (TexMan(CurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE);
|
FString speakerName;
|
||||||
}
|
int x = 16 * screen->GetWidth() / 320;
|
||||||
x = 16 * screen->GetWidth() / 320;
|
int y = 16 * screen->GetHeight() / 200;
|
||||||
y = 16 * screen->GetHeight() / 200;
|
int linesize = (OptionSettings.mLinespacing+2) * CleanYfac;
|
||||||
linesize = 10 * CleanYfac;
|
|
||||||
|
|
||||||
// Who is talking to you?
|
// Who is talking to you?
|
||||||
if (CurNode->SpeakerName.IsNotEmpty())
|
if (mCurNode->SpeakerName.IsNotEmpty())
|
||||||
{
|
{
|
||||||
speakerName = CurNode->SpeakerName;
|
speakerName = mCurNode->SpeakerName;
|
||||||
if (speakerName[0] == '$') speakerName = GStrings(speakerName + 1);
|
if (speakerName[0] == '$') speakerName = GStrings(speakerName + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
speakerName = cp->ConversationNPC->GetTag("Person");
|
speakerName = players[consoleplayer].ConversationNPC->GetTag("Person");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dim the screen behind the dialogue (but only if there is no backdrop).
|
// Dim the screen behind the dialogue (but only if there is no backdrop).
|
||||||
if (!CurNode->Backdrop.isValid())
|
if (dimbg)
|
||||||
{
|
{
|
||||||
int i = mDialogueLines->mCount;
|
int i = mDialogueLines->mCount;
|
||||||
screen->Dim(0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200,
|
screen->Dim(0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200,
|
||||||
308 * screen->GetWidth() / 320 - 14 * screen->GetWidth() / 320,
|
308 * screen->GetWidth() / 320 - 14 * screen->GetWidth() / 320,
|
||||||
speakerName == NULL ? linesize * i + 6 * CleanYfac
|
speakerName.IsEmpty() ? linesize * i + 6 * CleanYfac
|
||||||
: linesize * i + 6 * CleanYfac + linesize * 3 / 2);
|
: linesize * i + 6 * CleanYfac + linesize * 3 / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dim the screen behind the PC's choices.
|
if (speakerName.IsNotEmpty())
|
||||||
|
|
||||||
screen->Dim (0, 0.45f, (24-160) * CleanXfac + screen->GetWidth()/2,
|
|
||||||
(mYpos - 2 - 100) * CleanYfac + screen->GetHeight()/2,
|
|
||||||
272 * CleanXfac,
|
|
||||||
MIN<int>(mResponseLines.Size() * OptionSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac);
|
|
||||||
|
|
||||||
if (speakerName != NULL)
|
|
||||||
{
|
{
|
||||||
screen->DrawText(SmallFont, CR_WHITE, x, y, speakerName,
|
screen->DrawText(SmallFont, CR_WHITE, x, y, speakerName,
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
DTA_CleanNoMove, true, TAG_DONE);
|
||||||
|
@ -1104,35 +1086,25 @@ public:
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
DTA_CleanNoMove, true, TAG_DONE);
|
||||||
y += linesize;
|
y += linesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShowGold)
|
|
||||||
{
|
|
||||||
auto cointype = PClass::FindActor("Coin");
|
|
||||||
if (cointype)
|
|
||||||
{
|
|
||||||
AInventory *coin = cp->ConversationPC->FindInventory(cointype);
|
|
||||||
char goldstr[32];
|
|
||||||
|
|
||||||
mysnprintf(goldstr, countof(goldstr), "%d", coin != NULL ? coin->Amount : 0);
|
|
||||||
screen->DrawText(SmallFont, CR_GRAY, 21, 191, goldstr, DTA_320x200, true,
|
|
||||||
DTA_FillColor, 0, DTA_Alpha, HR_SHADOW, TAG_DONE);
|
|
||||||
screen->DrawTexture(TexMan(((AInventory *)GetDefaultByType(cointype))->Icon),
|
|
||||||
3, 190, DTA_320x200, true,
|
|
||||||
DTA_FillColor, 0, DTA_Alpha, HR_SHADOW, TAG_DONE);
|
|
||||||
screen->DrawText(SmallFont, CR_GRAY, 20, 190, goldstr, DTA_320x200, true, TAG_DONE);
|
|
||||||
screen->DrawTexture(TexMan(((AInventory *)GetDefaultByType(cointype))->Icon),
|
|
||||||
2, 189, DTA_320x200, true, TAG_DONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
y = mYpos;
|
|
||||||
fontheight = OptionSettings.mLinespacing;
|
virtual void DrawReplies()
|
||||||
|
{
|
||||||
|
// Dim the screen behind the PC's choices.
|
||||||
|
screen->Dim(0, 0.45f, (24 - 160) * CleanXfac + screen->GetWidth() / 2,
|
||||||
|
(mYpos - 2 - 100) * CleanYfac + screen->GetHeight() / 2,
|
||||||
|
272 * CleanXfac,
|
||||||
|
MIN<int>(mResponseLines.Size() * OptionSettings.mLinespacing + 4, 200 - mYpos) * CleanYfac);
|
||||||
|
|
||||||
|
int y = mYpos;
|
||||||
|
int fontheight = OptionSettings.mLinespacing;
|
||||||
|
|
||||||
int response = 0;
|
int response = 0;
|
||||||
for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight)
|
for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight)
|
||||||
{
|
{
|
||||||
width = SmallFont->StringWidth(mResponseLines[i]);
|
int width = SmallFont->StringWidth(mResponseLines[i]);
|
||||||
x = 64;
|
int x = 64;
|
||||||
|
|
||||||
screen->DrawText(SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE);
|
screen->DrawText(SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE);
|
||||||
|
|
||||||
|
@ -1160,6 +1132,56 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void DrawGold()
|
||||||
|
{
|
||||||
|
if (mShowGold)
|
||||||
|
{
|
||||||
|
auto cointype = PClass::FindActor("Coin");
|
||||||
|
if (cointype)
|
||||||
|
{
|
||||||
|
AInventory *coin = players[consoleplayer].ConversationPC->FindInventory(cointype);
|
||||||
|
char goldstr[32];
|
||||||
|
|
||||||
|
mysnprintf(goldstr, countof(goldstr), "%d", coin != NULL ? coin->Amount : 0);
|
||||||
|
screen->DrawText(SmallFont, CR_GRAY, 21, 191, goldstr, DTA_320x200, true,
|
||||||
|
DTA_FillColor, 0, DTA_Alpha, HR_SHADOW, TAG_DONE);
|
||||||
|
screen->DrawTexture(TexMan(((AInventory *)GetDefaultByType(cointype))->Icon),
|
||||||
|
3, 190, DTA_320x200, true,
|
||||||
|
DTA_FillColor, 0, DTA_Alpha, HR_SHADOW, TAG_DONE);
|
||||||
|
screen->DrawText(SmallFont, CR_GRAY, 20, 190, goldstr, DTA_320x200, true, TAG_DONE);
|
||||||
|
screen->DrawTexture(TexMan(((AInventory *)GetDefaultByType(cointype))->Icon),
|
||||||
|
2, 189, DTA_320x200, true, TAG_DONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
//
|
||||||
|
// DrawConversationMenu
|
||||||
|
//
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
void Drawer()
|
||||||
|
{
|
||||||
|
if (mCurNode == NULL)
|
||||||
|
{
|
||||||
|
Close ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// [CW] Freeze the game depending on MAPINFO options.
|
||||||
|
if (ConversationPauseTic < gametic && !multiplayer && !(level.flags2 & LEVEL2_CONV_SINGLE_UNFREEZE))
|
||||||
|
{
|
||||||
|
menuactive = MENU_On;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dimbg = DrawBackdrop();
|
||||||
|
DrawSpeakerText(dimbg);
|
||||||
|
DrawReplies();
|
||||||
|
DrawGold();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DConversationMenu, true, false)
|
IMPLEMENT_CLASS(DConversationMenu, true, false)
|
||||||
|
@ -1598,3 +1620,37 @@ static void TerminalResponse (const char *str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, DropType);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, ThisNodeNum);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, ItemCheckNode);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, SpeakerType);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, SpeakerName);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, SpeakerVoice);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, Backdrop);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, Dialogue);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, Goodbye);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueNode, Children);
|
||||||
|
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, Next);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, GiveType);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, ActionSpecial);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, Args);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, PrintAmount);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, Reply);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, QuickYes);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, QuickNo);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, LogString);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, NextNode);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, LogNumber);
|
||||||
|
DEFINE_FIELD(FStrifeDialogueReply, NeedsGold);
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE_FIELD(DConversationMenu, mSpeaker);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mDialogueLines);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mResponseLines);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mResponses);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mShowGold);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mCurNode);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mYpos);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mPlayer);
|
||||||
|
DEFINE_FIELD(DConversationMenu, mSelection);
|
||||||
|
|
Loading…
Reference in a new issue