Skip to content

Commit

Permalink
- text screen stuff for cutscene system.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed May 22, 2021
1 parent 13d2588 commit 50045dd
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/common/console/c_commandbuffer.cpp
Expand Up @@ -98,8 +98,7 @@ unsigned FCommandBuffer::CalcCellSize(unsigned length)
unsigned cellcount = 0;
for (unsigned i = 0; i < length; i++)
{
int w;
NewConsoleFont->GetChar(Text[i], CR_UNTRANSLATED, &w);
int w = NewConsoleFont->GetCharWidth(Text[i]);
cellcount += w / 9;
}
return cellcount;
Expand All @@ -112,8 +111,7 @@ unsigned FCommandBuffer::CharsForCells(unsigned cellin, bool *overflow)
int cells = cellin;
while (cells > 0)
{
int w;
NewConsoleFont->GetChar(Text[chars++], CR_UNTRANSLATED, &w);
int w = NewConsoleFont->GetCharWidth(Text[chars++]);
cells -= w / 9;
}
*overflow = (cells < 0);
Expand Down
2 changes: 2 additions & 0 deletions src/common/cutscenes/screenjob.cpp
Expand Up @@ -51,6 +51,8 @@
#include "s_music.h"
#include "m_argv.h"

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

DObject* runner;
PClass* runnerclass;
PType* runnerclasstype;
Expand Down
3 changes: 3 additions & 0 deletions src/common/cutscenes/screenjob.h
Expand Up @@ -6,6 +6,9 @@
#include "s_soundinternal.h"
#include "gamestate.h"
#include "zstring.h"
#include "c_cvars.h"

EXTERN_CVAR(Bool, inter_subtitles)

using CompletionFunc = std::function<void(bool)>;

Expand Down
11 changes: 7 additions & 4 deletions src/common/rendering/v_framebuffer.cpp
Expand Up @@ -291,16 +291,19 @@ FMaterial* DFrameBuffer::CreateMaterial(FGameTexture* tex, int scaleflags)
//
//==========================================================================

DEFINE_ACTION_FUNCTION(_Screen, GetWidth)
static int ScreenGetWidth() { return twod->GetWidth(); }
static int ScreenGetHeight() { return twod->GetHeight(); }

DEFINE_ACTION_FUNCTION_NATIVE(_Screen, GetWidth, ScreenGetWidth)
{
PARAM_PROLOGUE;
ACTION_RETURN_INT(screen->GetWidth());
ACTION_RETURN_INT(twod->GetWidth());
}

DEFINE_ACTION_FUNCTION(_Screen, GetHeight)
DEFINE_ACTION_FUNCTION_NATIVE(_Screen, GetHeight, ScreenGetHeight)
{
PARAM_PROLOGUE;
ACTION_RETURN_INT(screen->GetHeight());
ACTION_RETURN_INT(twod->GetHeight());
}

DEFINE_ACTION_FUNCTION(_Screen, PaletteColor)
Expand Down
14 changes: 14 additions & 0 deletions src/common/scripting/interface/stringformat.cpp
Expand Up @@ -564,6 +564,20 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Substitute, StringSubst)
return 0;
}

static void StringStripRight(FString* self, const FString& junk)
{
if (junk.IsNotEmpty()) self->StripRight(junk);
else self->StripRight();
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripRight, StringStripRight)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(junk);
StringStripRight(self, junk);
return 0;
}

static void StringSplit(FString* self, TArray<FString>* tokens, const FString& delimiter, int keepEmpty)
{
self->Split(*tokens, delimiter, static_cast<FString::EmptyTokenType>(keepEmpty));
Expand Down
12 changes: 12 additions & 0 deletions src/common/scripting/interface/vmnatives.cpp
Expand Up @@ -698,6 +698,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetGlyphHeight, GetGlyphHeight)
PARAM_INT(code);
ACTION_RETURN_INT(GetGlyphHeight(self, code));
}

static int GetDefaultKerning(FFont* font)
{
return font->GetDefaultKerning();
}

DEFINE_ACTION_FUNCTION_NATIVE(FFont, GetDefaultKerning, GetDefaultKerning)
{
PARAM_SELF_STRUCT_PROLOGUE(FFont);
ACTION_RETURN_INT(self->GetDefaultKerning());
}

//==========================================================================
//
// file system
Expand Down
14 changes: 11 additions & 3 deletions src/intermission/intermission.cpp
Expand Up @@ -56,6 +56,8 @@
#include "v_draw.h"
#include "doommenu.h"
#include "sbar.h"
#include "screenjob.h"
#include "vm.h"

FIntermissionDescriptorList IntermissionDescriptors;

Expand All @@ -73,10 +75,17 @@ IMPLEMENT_POINTERS_END
extern int NoWipe;

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

CVAR(Bool, inter_classic_scaling, true, CVAR_ARCHIVE);

DEFINE_ACTION_FUNCTION(_Screen, GetTextScreenSize)
{
auto scale = active_con_scaletext(twod, generic_ui);
int hudwidth = twod->GetWidth() / scale;
int hudheight = twod->GetHeight() / scale;
ACTION_RETURN_VEC2(DVector2(hudwidth, hudheight));
}

//==========================================================================
//
// This also gets used by the title loop.
Expand Down Expand Up @@ -376,7 +385,6 @@ void DIntermissionScreenText::Drawer ()
Super::Drawer();
if (mTicker >= mTextDelay)
{
FGameTexture *pic;
int w;
size_t count;
int c;
Expand Down Expand Up @@ -446,7 +454,7 @@ void DIntermissionScreenText::Drawer ()
continue;
}

pic = font->GetChar (c, mTextColor, &w);
w = font->GetCharWidth(c);
w += kerning;
w *= fontscale;
if (cx + w > twod->GetWidth())
Expand Down
3 changes: 3 additions & 0 deletions wadsrc/static/zscript/engine/base.zs
Expand Up @@ -410,6 +410,7 @@ struct Screen native
native static Color PaletteColor(int index);
native static int GetWidth();
native static int GetHeight();
native static Vector2 GetTextScreenSize();
native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1);
native static void Dim(Color col, double amount, int x, int y, int w, int h);

Expand Down Expand Up @@ -516,6 +517,7 @@ struct Font native
native static Font GetFont(Name fontname);
native BrokenLines BreakLines(String text, int maxlen);
native int GetGlyphHeight(int code);
native int GetDefaultKerning();
}

struct Console native
Expand Down Expand Up @@ -686,6 +688,7 @@ struct StringStruct native
native int CodePointCount() const;
native int, int GetNextCodePoint(int position) const;
native void Substitute(String str, String replace);
native void StripRight(String junk = "");
}

struct Translation version("2.4")
Expand Down

0 comments on commit 50045dd

Please sign in to comment.