diff --git a/src/d_player.h b/src/d_player.h index fc338b32f9..f701d89f9a 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -289,6 +289,7 @@ public: void SetLogNumber (int num); void SetLogText (const char *text); void SendPitchLimits() const; + void SetSubtitle(int num); AActor *mo = nullptr; uint8_t playerstate = 0; @@ -387,6 +388,8 @@ public: float BlendA = 0; FString LogText; // [RH] Log for Strife + FString SubtitleText; + int SubtitleCounter; DAngle MinPitch = 0.; // Viewpitch limits (negative is up, positive is down) DAngle MaxPitch = 0.; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index b1896bea48..f659dd714a 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -84,6 +84,7 @@ EXTERN_CVAR (Bool, am_showtotaltime) EXTERN_CVAR (Bool, noisedebug) EXTERN_CVAR (Int, con_scaletext) EXTERN_CVAR(Bool, vid_fps) +EXTERN_CVAR(Bool, inter_subtitles) CVAR(Int, hud_scale, 0, CVAR_ARCHIVE); @@ -1216,7 +1217,8 @@ void DBaseStatusBar::DrawLog () FFont *font = C_GetDefaultHUDFont(); int linelen = hudwidth<640? Scale(hudwidth,9,10)-40 : 560; - auto lines = V_BreakLines (font, linelen, CPlayer->LogText[0] == '$'? GStrings(CPlayer->LogText.GetChars()+1) : CPlayer->LogText.GetChars()); + const FString & text = (inter_subtitles && CPlayer->SubtitleCounter) ? CPlayer->SubtitleText : CPlayer->LogText; + auto lines = V_BreakLines (font, linelen, text[0] == '$'? GStrings(text.GetChars()+1) : text.GetChars()); int height = 20; for (unsigned i = 0; i < lines.Size(); i++) height += font->GetHeight (); @@ -1232,7 +1234,7 @@ void DBaseStatusBar::DrawLog () else { x=(hudwidth>>1)-300; - y=hudheight*3/10-(height>>1); + y=hudheight/8-(height>>1); if (y<0) y=0; w=600; } @@ -1242,7 +1244,7 @@ void DBaseStatusBar::DrawLog () y+=10; for (const FBrokenLines &line : lines) { - screen->DrawText (font, CR_UNTRANSLATED, x, y, line.Text, + screen->DrawText (font, CPlayer->SubtitleCounter? CR_CYAN : CR_UNTRANSLATED, x, y, line.Text, DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE); y += font->GetHeight (); @@ -1321,7 +1323,7 @@ void DBaseStatusBar::DrawTopStuff (EHudState state) DrawConsistancy (); DrawWaiting (); - if (ShowLog && MustDrawLog(state)) DrawLog (); + if ((ShowLog && MustDrawLog(state)) || (inter_subtitles && CPlayer->SubtitleCounter > 0)) DrawLog (); if (noisedebug) { diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 4bdfcbebd7..623095b1f7 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3196,6 +3196,7 @@ FUNC(LS_SendToCommunicator) if (it->CheckLocalView()) { S_StopSound (CHAN_VOICE); + it->player->SetSubtitle(arg0); S_Sound (CHAN_VOICE, name, 1, ATTN_NORM); // Get the message from the LANGUAGE lump. diff --git a/src/p_user.cpp b/src/p_user.cpp index f2e82cc7ad..da35b4047e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetLogNumber) void player_t::SetLogText (const char *text) { - LogText = text; + LogText = text; if (mo && mo->CheckLocalView()) { @@ -438,6 +438,30 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, SetLogText) return 0; } +void player_t::SetSubtitle(int num) +{ + char lumpname[36]; + + // Do we have a subtitle for this log entry's voice file? + mysnprintf(lumpname, countof(lumpname), "$TXT_SUB_LOG%d", num); + auto text = GStrings.GetLanguageString(lumpname+1, FStringTable::default_table); + if (text != nullptr) + { + SubtitleText = lumpname; + SubtitleCounter = 7 * TICRATE; + } +} + +DEFINE_ACTION_FUNCTION(_PlayerInfo, SetSubtitleNumber) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + PARAM_INT(log); + self->SetSubtitle(log); + return 0; +} + + + int player_t::GetSpawnClass() { const PClass * type = PlayerClasses[CurrentPlayerClass].Type; @@ -1633,6 +1657,8 @@ void player_t::Serialize(FSerializer &arc) ("blenda", BlendA) ("weaponstate", WeaponState) ("logtext", LogText) + ("subtitletext", SubtitleText) + ("subtitlecounter", SubtitleCounter) ("conversionnpc", ConversationNPC) ("conversionpc", ConversationPC) ("conversionnpcangle", ConversationNPCAngle) diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index 1acd84b28d..c6e3a370e2 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -2693,6 +2693,7 @@ struct PlayerInfo native play // self is what internally is known as player_t native PSprite FindPSprite(int id) const; native void SetLogNumber (int text); native void SetLogText (String text); + native void SetSubtitleNumber (int text); native bool Resurrect(); native String GetUserName() const; diff --git a/wadsrc/static/zscript/actors/strife/acolyte.zs b/wadsrc/static/zscript/actors/strife/acolyte.zs index f7457dd56f..b2951a9b1e 100644 --- a/wadsrc/static/zscript/actors/strife/acolyte.zs +++ b/wadsrc/static/zscript/actors/strife/acolyte.zs @@ -102,6 +102,7 @@ class Acolyte : StrifeHumanoid { players[i].mo.GiveInventoryType ("QuestItem7"); players[i].SetLogNumber (14); + players[i].SetSubtitleNumber (14); A_StopSound (CHAN_VOICE); A_PlaySound ("svox/voc14", CHAN_VOICE, 1, false, ATTN_NONE); } diff --git a/wadsrc/static/zscript/actors/strife/alienspectres.zs b/wadsrc/static/zscript/actors/strife/alienspectres.zs index 306c55c391..16b4668dc2 100644 --- a/wadsrc/static/zscript/actors/strife/alienspectres.zs +++ b/wadsrc/static/zscript/actors/strife/alienspectres.zs @@ -181,6 +181,7 @@ class AlienSpectre1 : SpectralMonster String voc = "svox/voc" .. log; A_PlaySound(voc, CHAN_VOICE, 1, false, ATTN_NONE); player.player.SetLogNumber (log); + player.player.SetSubtitleNumber (log); } } diff --git a/wadsrc/static/zscript/actors/strife/strifestuff.zs b/wadsrc/static/zscript/actors/strife/strifestuff.zs index d4af744c24..9c35145ab9 100644 --- a/wadsrc/static/zscript/actors/strife/strifestuff.zs +++ b/wadsrc/static/zscript/actors/strife/strifestuff.zs @@ -1865,6 +1865,7 @@ class PowerCoupling : Actor players[i].mo.GiveInventoryType ("QuestItem6"); S_Sound ("svox/voc13", CHAN_VOICE); players[i].SetLogNumber (13); + players[i].SetSubtitleNumber (13); A_DropItem ("BrokenPowerCoupling", -1, 256); Destroy (); }