mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-12-22 16:02:29 +00:00
Small dialogue polish
- Slide in from top - Fix chaining multiple dialogues with the same speaker not working - Unset when changing level - Sped up punctuation pause a bit
This commit is contained in:
parent
ffda097421
commit
3009f1c106
6 changed files with 123 additions and 83 deletions
|
|
@ -676,6 +676,8 @@ bool CallFunc_DialogueWaitDismiss(ACSVM::Thread *thread, const ACSVM::Word *argV
|
|||
(void)argV;
|
||||
(void)argC;
|
||||
|
||||
g_dialogue.SetDismissable(true);
|
||||
|
||||
thread->state = {
|
||||
ACSVM::ThreadState::WaitTag,
|
||||
0,
|
||||
|
|
@ -696,6 +698,8 @@ bool CallFunc_DialogueWaitText(ACSVM::Thread *thread, const ACSVM::Word *argV, A
|
|||
(void)argV;
|
||||
(void)argC;
|
||||
|
||||
g_dialogue.SetDismissable(false);
|
||||
|
||||
thread->state = {
|
||||
ACSVM::ThreadState::WaitTag,
|
||||
1,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
#include "k_vote.h"
|
||||
#include "k_serverstats.h"
|
||||
#include "music.h"
|
||||
#include "k_dialogue.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h" // 3D View Rendering
|
||||
|
|
@ -1012,6 +1013,8 @@ void D_ClearState(void)
|
|||
if (gamedata && gamedata->deferredsave)
|
||||
G_SaveGameData();
|
||||
|
||||
K_UnsetDialogue();
|
||||
|
||||
G_SetGamestate(GS_NULL);
|
||||
wipegamestate = GS_NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,13 +21,22 @@
|
|||
#include "g_game.h"
|
||||
#include "v_video.h"
|
||||
#include "r_draw.h"
|
||||
#include "m_easing.h"
|
||||
#include "r_skins.h"
|
||||
#include "z_zone.h"
|
||||
|
||||
#include "v_draw.hpp"
|
||||
|
||||
#include "acs/interface.h"
|
||||
|
||||
using srb2::Dialogue;
|
||||
|
||||
void Dialogue::Init(void)
|
||||
{
|
||||
active = true;
|
||||
dismissable = false;
|
||||
}
|
||||
|
||||
void Dialogue::SetSpeaker(void)
|
||||
{
|
||||
// Unset speaker
|
||||
|
|
@ -38,9 +47,10 @@ void Dialogue::SetSpeaker(void)
|
|||
|
||||
void Dialogue::SetSpeaker(std::string skinName, int portraitID)
|
||||
{
|
||||
Init();
|
||||
|
||||
// Set speaker based on a skin
|
||||
int skinID = -1;
|
||||
|
||||
if (!skinName.empty())
|
||||
{
|
||||
skinID = R_SkinAvailable(skinName.c_str());
|
||||
|
|
@ -70,6 +80,8 @@ void Dialogue::SetSpeaker(std::string skinName, int portraitID)
|
|||
|
||||
void Dialogue::SetSpeaker(std::string customName, std::string customPatch, UINT8 *customColormap)
|
||||
{
|
||||
Init();
|
||||
|
||||
// Set custom speaker
|
||||
speaker = customName;
|
||||
|
||||
|
|
@ -86,6 +98,15 @@ void Dialogue::SetSpeaker(std::string customName, std::string customPatch, UINT8
|
|||
|
||||
void Dialogue::NewText(std::string newText)
|
||||
{
|
||||
Init();
|
||||
|
||||
newText = V_ScaledWordWrap(
|
||||
290 << FRACBITS,
|
||||
FRACUNIT, FRACUNIT, FRACUNIT,
|
||||
0, HU_FONT,
|
||||
newText.c_str()
|
||||
);
|
||||
|
||||
text.clear();
|
||||
|
||||
textDest = newText;
|
||||
|
|
@ -98,7 +119,7 @@ void Dialogue::NewText(std::string newText)
|
|||
|
||||
bool Dialogue::Active(void)
|
||||
{
|
||||
return (!speaker.empty());
|
||||
return active;
|
||||
}
|
||||
|
||||
bool Dialogue::TextDone(void)
|
||||
|
|
@ -106,6 +127,16 @@ bool Dialogue::TextDone(void)
|
|||
return textDone;
|
||||
}
|
||||
|
||||
bool Dialogue::Dismissable(void)
|
||||
{
|
||||
return dismissable;
|
||||
}
|
||||
|
||||
void Dialogue::SetDismissable(bool value)
|
||||
{
|
||||
dismissable = value;
|
||||
}
|
||||
|
||||
void Dialogue::WriteText(void)
|
||||
{
|
||||
textTimer -= textSpeed;
|
||||
|
|
@ -145,114 +176,109 @@ void Dialogue::CompleteText(void)
|
|||
|
||||
void Dialogue::Tick(void)
|
||||
{
|
||||
if (Active() == false)
|
||||
if (Active())
|
||||
{
|
||||
if (slide < FRACUNIT)
|
||||
{
|
||||
slide += kSlideSpeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slide > 0)
|
||||
{
|
||||
slide -= kSlideSpeed;
|
||||
|
||||
if (slide <= 0)
|
||||
{
|
||||
Unset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slide = std::clamp(slide, 0, FRACUNIT);
|
||||
|
||||
if (slide != FRACUNIT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WriteText();
|
||||
|
||||
bool pressed = (
|
||||
((players[serverplayer].cmd.buttons & BT_VOTE) == BT_VOTE) &&
|
||||
((players[serverplayer].oldcmd.buttons & BT_VOTE) == 0)
|
||||
);
|
||||
|
||||
if (pressed == true)
|
||||
if (Dismissable() == true)
|
||||
{
|
||||
if (textDone)
|
||||
bool pressed = (
|
||||
((players[serverplayer].cmd.buttons & BT_VOTE) == BT_VOTE) &&
|
||||
((players[serverplayer].oldcmd.buttons & BT_VOTE) == 0)
|
||||
);
|
||||
|
||||
if (pressed == true)
|
||||
{
|
||||
SetSpeaker();
|
||||
if (TextDone())
|
||||
{
|
||||
Dismiss();
|
||||
}
|
||||
else
|
||||
{
|
||||
CompleteText();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CompleteText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Dialogue::UpdatePatches(void)
|
||||
{
|
||||
if (bgPatch == nullptr)
|
||||
{
|
||||
bgPatch = static_cast<patch_t *>(W_CachePatchName("TUTDIAG1", PU_HUDGFX) );
|
||||
}
|
||||
|
||||
if (confirmPatch == nullptr)
|
||||
{
|
||||
confirmPatch = static_cast<patch_t *>(W_CachePatchName("TUTDIAG2", PU_HUDGFX) );
|
||||
}
|
||||
}
|
||||
|
||||
void Dialogue::Draw(void)
|
||||
{
|
||||
if (Active() == false)
|
||||
if (slide == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePatches();
|
||||
srb2::Draw drawer =
|
||||
srb2::Draw(
|
||||
0, FixedToFloat(Easing_OutCubic(slide, -78 * FRACUNIT, 0))
|
||||
).flags(V_SNAPTOTOP);
|
||||
|
||||
V_DrawFixedPatch(
|
||||
0, 0,
|
||||
FRACUNIT,
|
||||
V_SNAPTOTOP,
|
||||
bgPatch,
|
||||
nullptr
|
||||
);
|
||||
drawer.patch("TUTDIAG1");
|
||||
|
||||
if (portrait != nullptr)
|
||||
{
|
||||
V_DrawFixedPatch(
|
||||
10 * FRACUNIT, 41 * FRACUNIT,
|
||||
FRACUNIT,
|
||||
V_SNAPTOTOP,
|
||||
portrait,
|
||||
portraitColormap
|
||||
);
|
||||
drawer
|
||||
.xy(10, 41)
|
||||
.colormap(portraitColormap)
|
||||
.patch(portrait);
|
||||
}
|
||||
|
||||
V_DrawString(
|
||||
45, 39,
|
||||
V_SNAPTOTOP,
|
||||
speaker.c_str()
|
||||
);
|
||||
drawer
|
||||
.xy(45, 39)
|
||||
.font(srb2::Draw::Font::kConsole)
|
||||
.text( speaker.c_str() );
|
||||
|
||||
V_DrawString(
|
||||
10, 3,
|
||||
V_SNAPTOTOP,
|
||||
text.c_str()
|
||||
);
|
||||
drawer
|
||||
.xy(10, 3)
|
||||
.font(srb2::Draw::Font::kConsole)
|
||||
.text( text.c_str() );
|
||||
|
||||
if (textDone)
|
||||
if (Dismissable() && TextDone() && Active())
|
||||
{
|
||||
V_DrawFixedPatch(
|
||||
304 * FRACUNIT, 7 * FRACUNIT,
|
||||
FRACUNIT,
|
||||
V_SNAPTOTOP,
|
||||
confirmPatch,
|
||||
nullptr
|
||||
);
|
||||
drawer
|
||||
.xy(304, 7)
|
||||
.patch("TUTDIAG2");
|
||||
}
|
||||
}
|
||||
|
||||
void Dialogue::Dismiss(void)
|
||||
{
|
||||
if (Active() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetSpeaker();
|
||||
active = false;
|
||||
dismissable = false;
|
||||
|
||||
text.clear();
|
||||
textDest.clear();
|
||||
}
|
||||
|
||||
if (G_GamestateUsesLevel() == true && !script.empty())
|
||||
{
|
||||
ACS_Execute(script.c_str(), nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
script.clear();
|
||||
void Dialogue::Unset(void)
|
||||
{
|
||||
Dismiss();
|
||||
SetSpeaker();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -264,9 +290,9 @@ void Dialogue::Dismiss(void)
|
|||
|
||||
Dialogue g_dialogue;
|
||||
|
||||
void K_DismissDialogue(void)
|
||||
void K_UnsetDialogue(void)
|
||||
{
|
||||
g_dialogue.Dismiss();
|
||||
g_dialogue.Unset();
|
||||
}
|
||||
|
||||
void K_DrawDialogue(void)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void K_DismissDialogue(void);
|
||||
void K_UnsetDialogue(void);
|
||||
void K_DrawDialogue(void);
|
||||
void K_TickDialogue(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ private:
|
|||
patch_t *bgPatch;
|
||||
patch_t *confirmPatch;
|
||||
|
||||
bool active;
|
||||
|
||||
std::string speaker;
|
||||
patch_t *portrait;
|
||||
UINT8 *portraitColormap;
|
||||
|
|
@ -39,21 +37,25 @@ private:
|
|||
std::string text;
|
||||
std::string textDest;
|
||||
|
||||
bool active;
|
||||
fixed_t slide;
|
||||
|
||||
fixed_t textTimer;
|
||||
fixed_t textSpeed;
|
||||
bool textDone;
|
||||
|
||||
bool freeze;
|
||||
std::string script;
|
||||
bool dismissable;
|
||||
|
||||
void UpdatePatches(void);
|
||||
void Init(void);
|
||||
//void Unset(void);
|
||||
|
||||
void WriteText(void);
|
||||
void CompleteText(void);
|
||||
|
||||
public:
|
||||
static constexpr fixed_t kTextSpeedDefault = FRACUNIT;
|
||||
static constexpr fixed_t kTextPunctPause = FRACUNIT * TICRATE * 3 / 5;
|
||||
static constexpr fixed_t kTextPunctPause = (FRACUNIT * TICRATE * 2) / 5;
|
||||
static constexpr fixed_t kSlideSpeed = FRACUNIT / (TICRATE / 5);
|
||||
|
||||
void SetSpeaker(void);
|
||||
void SetSpeaker(std::string skinName, int portraitID);
|
||||
|
|
@ -63,11 +65,14 @@ public:
|
|||
|
||||
bool Active(void);
|
||||
bool TextDone(void);
|
||||
bool Dismissable(void);
|
||||
void SetDismissable(bool value);
|
||||
|
||||
void Tick(void);
|
||||
void Draw(void);
|
||||
|
||||
void Dismiss(void);
|
||||
void Unset(void);
|
||||
};
|
||||
|
||||
}; // namespace srb2
|
||||
|
|
|
|||
|
|
@ -8299,6 +8299,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
// Close text prompt before freeing the old level
|
||||
F_EndTextPrompt(false, true);
|
||||
|
||||
K_UnsetDialogue();
|
||||
|
||||
LUA_InvalidateLevel();
|
||||
|
||||
for (ss = sectors; sectors+numsectors != ss; ss++)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue