Exported FTeam getters

This commit is contained in:
Boondorl 2024-04-19 09:10:31 -04:00 committed by Rachael Alexanderson
parent f2d7bbea99
commit b0137e50ee
3 changed files with 88 additions and 6 deletions

View file

@ -38,6 +38,7 @@
#include "gi.h"
#include "teaminfo.h"
#include "texturemanager.h"
#include "v_font.h"
#include "v_video.h"
#include "filesystem.h"
@ -244,7 +245,7 @@ void FTeam::ClearTeams ()
//
//==========================================================================
bool FTeam::IsValidTeam (unsigned int uiTeam)
bool FTeam::IsValidTeam (unsigned int uiTeam) const
{
if (uiTeam >= Teams.Size ())
return false;
@ -303,7 +304,7 @@ int FTeam::GetTextColor () const
//
//==========================================================================
FString FTeam::GetLogo () const
const FString& FTeam::GetLogo () const
{
return m_Logo;
}
@ -338,3 +339,75 @@ CCMD (teamlist)
DEFINE_GLOBAL(Teams)
DEFINE_FIELD_NAMED(FTeam, m_Name, mName)
static int IsValid(unsigned int id)
{
return TeamLibrary.IsValidTeam(id);
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, IsValid, IsValid)
{
PARAM_PROLOGUE;
PARAM_UINT(id);
ACTION_RETURN_BOOL(TeamLibrary.IsValidTeam(id));
}
static int GetPlayerColor(FTeam* self)
{
return self->GetPlayerColor();
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetPlayerColor, GetPlayerColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(self->GetPlayerColor());
}
static int GetTextColor(FTeam* self)
{
return self->GetTextColor();
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetTextColor, GetTextColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(self->GetTextColor());
}
static int GetLogo(FTeam* self)
{
const FString& name = self->GetLogo();
if (name.IsEmpty())
return -1;
return TexMan.CheckForTexture(name.GetChars(), ETextureType::Any).GetIndex();
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogo, GetLogo)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_INT(GetLogo(self));
}
static void GetLogoName(FTeam* self, FString* res)
{
*res = self->GetLogo();
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, GetLogoName, GetLogoName)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_STRING(self->GetLogo());
}
static int AllowsCustomPlayerColor(FTeam* self)
{
return self->GetAllowCustomPlayerColor();
}
DEFINE_ACTION_FUNCTION_NATIVE(FTeam, AllowsCustomPlayerColor, AllowsCustomPlayerColor)
{
PARAM_SELF_STRUCT_PROLOGUE(FTeam);
ACTION_RETURN_BOOL(self->GetAllowCustomPlayerColor());
}

View file

@ -46,12 +46,12 @@ class FTeam
public:
FTeam ();
void ParseTeamInfo ();
bool IsValidTeam (unsigned int uiTeam);
bool IsValidTeam (unsigned int uiTeam) const;
const char *GetName () const;
int GetPlayerColor () const;
int GetTextColor () const;
FString GetLogo () const;
const FString& GetLogo () const;
bool GetAllowCustomPlayerColor () const;
int m_iPlayerCount;

View file

@ -2969,7 +2969,16 @@ struct PlayerSkin native
struct Team native
{
const NoTeam = 255;
const Max = 16;
const NOTEAM = 255;
const MAX = 16;
native String mName;
native static bool IsValid(uint teamIndex);
native Color GetPlayerColor() const;
native int GetTextColor() const;
native TextureID GetLogo() const;
native string GetLogoName() const;
native bool AllowsCustomPlayerColor() const;
}