Skip to content

Commit

Permalink
- implemented subtitles for intermission slideshows.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed May 19, 2019
1 parent 6b51c05 commit 2c226af
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 64 deletions.
28 changes: 25 additions & 3 deletions src/d_main.cpp
Expand Up @@ -132,6 +132,7 @@ void D_DoAdvanceDemo ();
void D_AddWildFile (TArray<FString> &wadfiles, const char *pattern);
void D_LoadWadSettings ();
void ParseGLDefs();
void DrawFullscreenSubtitle(const char *text);

// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------

Expand Down Expand Up @@ -227,6 +228,7 @@ gamestate_t wipegamestate = GS_DEMOSCREEN; // can be -1 to force a wipe
bool PageBlank;
FTexture *Advisory;
FTextureID Page;
const char *Subtitle;
bool nospriterename;
FStartupInfo DoomStartupInfo;
FString lastIWAD;
Expand Down Expand Up @@ -984,6 +986,7 @@ void D_DoomLoop ()
// Clamp the timer to TICRATE until the playloop has been entered.
r_NoInterpolate = true;
Page.SetInvalid();
Subtitle = nullptr;
Advisory = nullptr;

vid_cursor.Callback();
Expand Down Expand Up @@ -1077,7 +1080,11 @@ void D_PageDrawer (void)
DTA_BilinearFilter, true,
TAG_DONE);
}
if (Advisory != NULL)
if (Subtitle != nullptr)
{
DrawFullscreenSubtitle(GStrings[Subtitle]);
}
if (Advisory != nullptr)
{
screen->DrawTexture (Advisory, 4, 160, DTA_320x200, true, TAG_DONE);
}
Expand Down Expand Up @@ -1113,7 +1120,8 @@ void D_DoStrifeAdvanceDemo ()
"svox/voc91", "svox/voc92", "svox/voc93", "svox/voc94", "svox/voc95", "svox/voc96"
};
const char *const *voices = gameinfo.flags & GI_SHAREWARE ? teaserVoices : fullVoices;
const char *pagename = NULL;
const char *pagename = nullptr;
const char *subtitle = nullptr;

gamestate = GS_DEMOSCREEN;
PageBlank = false;
Expand Down Expand Up @@ -1152,6 +1160,7 @@ void D_DoStrifeAdvanceDemo ()
case 3:
pagetic = 7 * TICRATE;
pagename = "PANEL1";
subtitle = "TXT_SUB_INTRO1";
S_Sound (CHAN_VOICE | CHAN_UI, voices[0], 1, ATTN_NORM);
// The new Strife teaser has D_FMINTR.
// The full retail Strife has D_INTRO.
Expand All @@ -1162,30 +1171,35 @@ void D_DoStrifeAdvanceDemo ()
case 4:
pagetic = 9 * TICRATE;
pagename = "PANEL2";
subtitle = "TXT_SUB_INTRO2";
S_Sound (CHAN_VOICE | CHAN_UI, voices[1], 1, ATTN_NORM);
break;

case 5:
pagetic = 12 * TICRATE;
pagename = "PANEL3";
subtitle = "TXT_SUB_INTRO3";
S_Sound (CHAN_VOICE | CHAN_UI, voices[2], 1, ATTN_NORM);
break;

case 6:
pagetic = 11 * TICRATE;
pagename = "PANEL4";
subtitle = "TXT_SUB_INTRO4";
S_Sound (CHAN_VOICE | CHAN_UI, voices[3], 1, ATTN_NORM);
break;

case 7:
pagetic = 10 * TICRATE;
pagename = "PANEL5";
subtitle = "TXT_SUB_INTRO5";
S_Sound (CHAN_VOICE | CHAN_UI, voices[4], 1, ATTN_NORM);
break;

case 8:
pagetic = 16 * TICRATE;
pagename = "PANEL6";
subtitle = "TXT_SUB_INTRO6";
S_Sound (CHAN_VOICE | CHAN_UI, voices[5], 1, ATTN_NORM);
break;

Expand All @@ -1206,7 +1220,15 @@ void D_DoStrifeAdvanceDemo ()
if (demosequence == 9 && !(gameinfo.flags & GI_SHAREWARE))
demosequence = 10;

if (pagename != nullptr) Page = TexMan.CheckForTexture(pagename, ETextureType::MiscPatch);
if (pagename != nullptr)
{
Page = TexMan.CheckForTexture(pagename, ETextureType::MiscPatch);
Subtitle = subtitle;
}
else
{
Subtitle = nullptr;
}
}

//==========================================================================
Expand Down
59 changes: 59 additions & 0 deletions src/intermission/intermission.cpp
Expand Up @@ -68,6 +68,58 @@ IMPLEMENT_POINTERS_END
extern int NoWipe;

CVAR(Bool, nointerscrollabort, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
CVAR(Bool, inter_subtitles, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);

//==========================================================================
//
// This also gets used by the title loop.
//
//==========================================================================

void DrawFullscreenSubtitle(const char *text)
{
if (!text || !*text || !inter_subtitles) return;

// This uses the same scaling as regular HUD messages
auto scale = active_con_scaletext(generic_ui);
int hudwidth = SCREENWIDTH / scale;
int hudheight = SCREENHEIGHT / scale;
FFont *font = C_GetDefaultHUDFont();

int linelen = hudwidth < 640 ? Scale(hudwidth, 9, 10) - 40 : 560;
auto lines = V_BreakLines(font, linelen, text);
int height = 20;

for (unsigned i = 0; i < lines.Size(); i++) height += font->GetHeight();

int x, y, w;

if (linelen < 560)
{
x = hudwidth / 20;
y = hudheight * 9 / 10 - height;
w = hudwidth - 2 * x;
}
else
{
x = (hudwidth >> 1) - 300;
y = hudheight * 9 / 10 - height;
if (y < 0) y = 0;
w = 600;
}
screen->Dim(0, 0.5f, Scale(x, SCREENWIDTH, hudwidth), Scale(y, SCREENHEIGHT, hudheight),
Scale(w, SCREENWIDTH, hudwidth), Scale(height, SCREENHEIGHT, hudheight));
x += 20;
y += 10;
for (const FBrokenLines &line : lines)
{
screen->DrawText(font, CR_UNTRANSLATED, x, y, line.Text,
DTA_KeepRatio, true,
DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, TAG_DONE);
y += font->GetHeight();
}
}

//==========================================================================
//
//
Expand Down Expand Up @@ -127,6 +179,7 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first)
mOverlays[i].mPic = TexMan.CheckForTexture(desc->mOverlays[i].mName, ETextureType::MiscPatch);
}
mTicker = 0;
mSubtitle = desc->mSubtitle;
}


Expand Down Expand Up @@ -181,6 +234,12 @@ void DIntermissionScreen::Drawer ()
screen->DrawTexture (TexMan.GetTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, TAG_DONE);
}
if (!mFlatfill) screen->FillBorder (NULL);
if (mSubtitle)
{
const char *sub = mSubtitle.GetChars();
if (sub && *sub == '$') sub = GStrings[sub + 1];
if (sub) DrawFullscreenSubtitle(sub);
}
}

void DIntermissionScreen::OnDestroy()
Expand Down
2 changes: 2 additions & 0 deletions src/intermission/intermission.h
Expand Up @@ -76,6 +76,7 @@ struct FIntermissionAction
int mDuration;
FString mBackground;
FString mSound;
FString mSubtitle;
bool mFlatfill;
bool mMusicLooping;
TArray<FIntermissionPatch> mOverlays;
Expand Down Expand Up @@ -163,6 +164,7 @@ class DIntermissionScreen : public DObject
protected:
int mDuration;
FTextureID mBackground;
FString mSubtitle;
bool mFlatfill;
TArray<FIIntermissionPatch> mOverlays;

Expand Down
7 changes: 7 additions & 0 deletions src/intermission/intermission_parse.cpp
Expand Up @@ -150,6 +150,13 @@ bool FIntermissionAction::ParseKey(FScanner &sc)
mSound = sc.String;
return true;
}
else if (sc.Compare("Subtitle"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_StringConst);
mSubtitle = sc.String;
return true;
}
else if (sc.Compare("Draw"))
{
FIntermissionPatch *pat = &mOverlays[mOverlays.Reserve(1)];
Expand Down

0 comments on commit 2c226af

Please sign in to comment.