Skip to content

Scriptified scoreboard drawing #3089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/common/2d/v_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,51 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame)
return 0;
}

DEFINE_ACTION_FUNCTION(_Screen, GetTextureWidth)
{
PARAM_PROLOGUE;
PARAM_INT(textureId);
PARAM_BOOL(animated);

FGameTexture *tex = textureId >= 1 ? TexMan.GetGameTexture(FSetTextureID(textureId), animated) : nullptr;

ACTION_RETURN_FLOAT(tex ? tex->GetDisplayWidth() : -1);
}

DEFINE_ACTION_FUNCTION(_Screen, GetTextureHeight)
{
PARAM_PROLOGUE;
PARAM_INT(textureId);
PARAM_BOOL(animated);

FGameTexture *tex = textureId >= 1 ? TexMan.GetGameTexture(FSetTextureID(textureId), animated) : nullptr;

ACTION_RETURN_FLOAT(tex ? tex->GetDisplayHeight() : -1);
}


DEFINE_ACTION_FUNCTION(_Screen, GetTextureLeftOffset)
{
PARAM_PROLOGUE;
PARAM_INT(textureId);
PARAM_BOOL(animated);

FGameTexture *tex = textureId >= 1 ? TexMan.GetGameTexture(FSetTextureID(textureId), animated) : nullptr;

ACTION_RETURN_FLOAT(tex ? tex->GetDisplayLeftOffset() : -1);
}

DEFINE_ACTION_FUNCTION(_Screen, GetTextureTopOffset)
{
PARAM_PROLOGUE;
PARAM_INT(textureId);
PARAM_BOOL(animated);

FGameTexture *tex = textureId >= 1 ? TexMan.GetGameTexture(FSetTextureID(textureId), animated) : nullptr;

ACTION_RETURN_FLOAT(tex ? tex->GetDisplayTopOffset() : -1);
}

DEFINE_ACTION_FUNCTION(FCanvas, DrawLineFrame)
{
PARAM_SELF_PROLOGUE(FCanvas);
Expand Down
46 changes: 46 additions & 0 deletions src/common/scripting/interface/stringformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,52 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Substitute, StringSubst)
return 0;
}

static int StringCompare(FString *self, const FString &other)
{
return self->Compare(other);
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, Compare, StringCompare)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(other);
ACTION_RETURN_INT(StringCompare(self, other));
}

static int StringCompareNoCase(FString *self, const FString &other)
{
return self->CompareNoCase(other);
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, CompareNoCase, StringCompareNoCase)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(other);
ACTION_RETURN_INT(StringCompareNoCase(self, other));
}

static int StringIsEmpty(FString *self)
{
return self->IsEmpty();
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IsEmpty, StringIsEmpty)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
ACTION_RETURN_INT(StringIsEmpty(self));
}

static int StringIsNotEmpty(FString *self)
{
return self->IsNotEmpty();
}

DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, IsNotEmpty, StringIsNotEmpty)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
ACTION_RETURN_INT(StringIsNotEmpty(self));
}

static void StringStripRight(FString* self, const FString& junk)
{
if (junk.IsNotEmpty()) self->StripRight(junk);
Expand Down
4 changes: 3 additions & 1 deletion src/ct_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "c_buttons.h"
#include "d_buttons.h"
#include "v_draw.h"
#include "r_utility.h"

enum
{
Expand Down Expand Up @@ -241,6 +242,7 @@ void CT_PasteChat(const char *clip)

void CT_Drawer (void)
{
auto &vp = r_viewpoint;
auto drawer = twod;
FFont *displayfont = NewConsoleFont;

Expand All @@ -254,7 +256,7 @@ void CT_Drawer (void)
{
// todo: check for summary screen
}
if (!skipit) HU_DrawScores (&players[consoleplayer]);
if (!skipit) HU_DrawScores (consoleplayer, vp.TicFrac);
}
if (chatmodeon)
{
Expand Down
6 changes: 6 additions & 0 deletions src/d_netinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, GetDisplayColor)
ACTION_RETURN_INT(c);
}

DEFINE_ACTION_FUNCTION(_PlayerInfo, GetAverageLatency)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
ACTION_RETURN_INT(ClientStates[self - players].AverageLatency);
}

// Find out which teams are present. If there is only one,
// then another team should be chosen at random.
//
Expand Down
Loading