diff --git a/src/gamedata/teaminfo.cpp b/src/gamedata/teaminfo.cpp index 3a28da984..1838d1b39 100644 --- a/src/gamedata/teaminfo.cpp +++ b/src/gamedata/teaminfo.cpp @@ -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()); +} diff --git a/src/gamedata/teaminfo.h b/src/gamedata/teaminfo.h index 1c84d9b9b..1a3db705c 100644 --- a/src/gamedata/teaminfo.h +++ b/src/gamedata/teaminfo.h @@ -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; diff --git a/wadsrc/static/zscript/actors/player/player.zs b/wadsrc/static/zscript/actors/player/player.zs index e6c66fa44..65fc28943 100644 --- a/wadsrc/static/zscript/actors/player/player.zs +++ b/wadsrc/static/zscript/actors/player/player.zs @@ -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; }