- scriptified the drawer functions of the conversation menu.
This commit is contained in:
parent
c4a90f39af
commit
3c8a5fdbe7
3 changed files with 248 additions and 161 deletions
|
|
@ -1022,166 +1022,6 @@ public:
|
|||
}
|
||||
return Super::Responder(ev);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Draw the backdrop, returns true if the text background should be dimmed
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
virtual bool DrawBackdrop()
|
||||
{
|
||||
if (mCurNode->Backdrop.isValid())
|
||||
{
|
||||
screen->DrawTexture(TexMan(mCurNode->Backdrop), 0, 0, DTA_320x200, true, TAG_DONE);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// Draw the speaker text
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
virtual void DrawSpeakerText(bool dimbg)
|
||||
{
|
||||
FString speakerName;
|
||||
int x = 16 * screen->GetWidth() / 320;
|
||||
int y = 16 * screen->GetHeight() / 200;
|
||||
int linesize = (OptionSettings.mLinespacing+2) * CleanYfac;
|
||||
|
||||
// Who is talking to you?
|
||||
if (mCurNode->SpeakerName.IsNotEmpty())
|
||||
{
|
||||
speakerName = mCurNode->SpeakerName;
|
||||
if (speakerName[0] == '$') speakerName = GStrings(speakerName + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
speakerName = players[consoleplayer].ConversationNPC->GetTag("Person");
|
||||
}
|
||||
|
||||
// Dim the screen behind the dialogue (but only if there is no backdrop).
|
||||
if (dimbg)
|
||||
{
|
||||
int i = mDialogueLines->mCount;
|
||||
screen->Dim(0, 0.45f, 14 * screen->GetWidth() / 320, 13 * screen->GetHeight() / 200,
|
||||
308 * screen->GetWidth() / 320 - 14 * screen->GetWidth() / 320,
|
||||
speakerName.IsEmpty() ? linesize * i + 6 * CleanYfac
|
||||
: linesize * i + 6 * CleanYfac + linesize * 3 / 2);
|
||||
}
|
||||
|
||||
if (speakerName.IsNotEmpty())
|
||||
{
|
||||
screen->DrawText(SmallFont, CR_WHITE, x, y, speakerName,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
y += linesize * 3 / 2;
|
||||
}
|
||||
x = 24 * screen->GetWidth() / 320;
|
||||
for (int i = 0; i < mDialogueLines->mCount; ++i)
|
||||
{
|
||||
screen->DrawText(SmallFont, CR_UNTRANSLATED, x, y, mDialogueLines->mBroken[i].Text,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
y += linesize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
for (unsigned i = 0; i < mResponseLines.Size(); i++, y += fontheight)
|
||||
{
|
||||
int width = SmallFont->StringWidth(mResponseLines[i]);
|
||||
int x = 64;
|
||||
|
||||
screen->DrawText(SmallFont, CR_GREEN, x, y, mResponseLines[i], DTA_Clean, true, TAG_DONE);
|
||||
|
||||
if (i == mResponses[response])
|
||||
{
|
||||
char tbuf[16];
|
||||
|
||||
response++;
|
||||
mysnprintf(tbuf, countof(tbuf), "%d.", response);
|
||||
x = 50 - SmallFont->StringWidth(tbuf);
|
||||
screen->DrawText(SmallFont, CR_GREY, x, y, tbuf, DTA_Clean, true, TAG_DONE);
|
||||
|
||||
if (response == mSelection + 1)
|
||||
{
|
||||
int color = ((MenuTime % 8) < 4) || CurrentMenu != this ? CR_RED : CR_GREY;
|
||||
|
||||
x = (50 + 3 - 160) * CleanXfac + screen->GetWidth() / 2;
|
||||
int yy = (y + fontheight / 2 - 5 - 100) * CleanYfac + screen->GetHeight() / 2;
|
||||
screen->DrawText(ConFont, color, x, yy, "\xd",
|
||||
DTA_CellX, 8 * CleanXfac,
|
||||
DTA_CellY, 8 * CleanYfac,
|
||||
TAG_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
@ -1316,7 +1156,6 @@ void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveang
|
|||
// And open the menu
|
||||
M_StartControlPanel (false);
|
||||
M_ActivateMenu(cmenu);
|
||||
ConversationPauseTic = gametic + 20;
|
||||
menuactive = MENU_OnNoPause;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue