This commit is contained in:
GenZmeY 2022-09-07 15:57:47 +03:00
parent 86be867a00
commit 85c2fb65bb
8 changed files with 762 additions and 116 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,39 @@
class RankRelations extends Object
dependson(YAS_Types)
config(YAS);
var public config Array<RankRelation> Relations;
public static function InitConfig(int Version, int LatestVersion)
{
switch (Version)
{
case `NO_CONFIG:
ApplyDefault();
default: break;
}
if (LatestVersion != Version)
{
StaticSaveConfig();
}
}
private static function ApplyDefault()
{
local RankRelation NewRankRelation;
default.Relations.Length = 0;
// Example relation:
NewRankRelation.RankID = 1; // "Man of culture" ID
NewRankRelation.ObjectID = "103582791429670253"; // HENTAI Group SteamID64
default.Relations.AddItem(NewRankRelation);
}
defaultproperties
{
}

52
YAS/Classes/Ranks.uc Normal file
View File

@ -0,0 +1,52 @@
class Ranks extends Object
dependson(YAS_Types)
config(YAS);
var public config SystemRank Player;
var public config SystemRank Admin;
var public config Array<Rank> Ranks;
public static function InitConfig(int Version, int LatestVersion)
{
switch (Version)
{
case `NO_CONFIG:
ApplyDefault();
default: break;
}
if (LatestVersion != Version)
{
StaticSaveConfig();
}
}
private static function ApplyDefault()
{
local Rank NewRank;
// System ranks:
default.Player.RankName = "";
default.Player.RankColor = MakeColor(250, 250, 250, 250);
default.Player.PlayerColor = MakeColor(250, 250, 250, 250);
default.Admin.RankName = "Admin";
default.Admin.RankColor = MakeColor(250, 0, 0, 250);
default.Admin.PlayerColor = MakeColor(250, 0, 0, 250);
default.Ranks.Length = 0;
// Example custom rank:
NewRank.RankID = 1;
NewRank.RankName = "Man of culture";
NewRank.RankColor = MakeColor(0, 250, 0, 250);
NewRank.PlayerColor = MakeColor(250, 250, 250, 250);
default.Ranks.AddItem(NewRank);
}
defaultproperties
{
}

View File

@ -3,18 +3,30 @@ class YAS extends Info
const LatestVersion = 1; const LatestVersion = 1;
//const CfgExampleConfig = class'ExampleConfig'; const CfgRanks = class'Ranks';
const CfgRankRelations = class'RankRelations';
const MatchUID = "0x";
const MatchPlayerSteamID64 = "76561";
const MatchGroupSteamID64 = "10358279";
var private config int Version; var private config int Version;
var private config E_LogLevel LogLevel; var private config E_LogLevel LogLevel;
var private config int UpdateInterval;
var private KFGameInfo KFGI; var private KFGameInfo KFGI;
var private KFGameInfo_Survival KFGIS; var private KFGameInfo_Survival KFGIS;
var private KFGameInfo_Endless KFGIE; var private KFGameInfo_Endless KFGIE;
var private KFGameReplicationInfo KFGRI; var private KFGameReplicationInfo KFGRI;
var private KFOnlineGameSettings KFOGS;
var private OnlineSubsystemSteamworks OSS;
var private Array<YAS_RepInfo> RepInfos; var private Array<YAS_RepInfo> RepInfos;
var private Array<CachedRankRelation> PlayerRelations;
var private Array<CachedRankRelation> GroupRelations;
public simulated function bool SafeDestroy() public simulated function bool SafeDestroy()
{ {
`Log_Trace(); `Log_Trace();
@ -56,10 +68,12 @@ private function PreInit()
if (Version == `NO_CONFIG) if (Version == `NO_CONFIG)
{ {
LogLevel = LL_Info; LogLevel = LL_Info;
UpdateInterval = 1;
SaveConfig(); SaveConfig();
} }
//CfgExampleConfig.static.InitConfig(Version, LatestVersion); CfgRanks.static.InitConfig(Version, LatestVersion);
CfgRankRelations.static.InitConfig(Version, LatestVersion);
switch (Version) switch (Version)
{ {
@ -95,7 +109,113 @@ private function PreInit()
} }
`Log_Base("LogLevel:" @ LogLevel); `Log_Base("LogLevel:" @ LogLevel);
//ExampleConfig = CfgExampleConfig.static.Load(LogLevel); OSS = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
if (OSS != None)
{
InitRanks();
}
else
{
`Log_Error("Can't get online subsystem!");
}
}
private function InitRanks() // TODO: Ref
{
local Array<RankRelation> Relations;
local Array<Rank> Ranks;
local RankRelation Relation;
local Rank Rank;
local CachedRankRelation CachedRankRelation;
Ranks = CfgRanks.default.Ranks;
Relations = CfgRankRelations.default.Relations;
foreach Relations(Relation)
{
if (IsUID(Relation.ObjectID) || IsPlayerSteamID64(Relation.ObjectID))
{
if (AnyToUID(Relation.ObjectID, CachedRankRelation.UID))
{
CachedRankRelation.RawID = Relation.ObjectID;
foreach Ranks(Rank)
{
if (Rank.RankID == Relation.RankID)
{
CachedRankRelation.Rank = Rank;
break;
}
}
if (CachedRankRelation.Rank.RankID > 0)
{
PlayerRelations.AddItem(CachedRankRelation);
}
else
{
`Log_Warn("Rank with ID" @ Relation.RankID @ "not found");
}
}
else
{
`Log_Warn("Can't convert to UniqueNetID:" @ Relation.ObjectID);
}
}
else if (IsGroupSteamID64(Relation.ObjectID))
{
if (AnyToUID(Relation.ObjectID, CachedRankRelation.UID))
{
CachedRankRelation.RawID = Relation.ObjectID;
foreach Ranks(Rank)
{
if (Rank.RankID == Relation.RankID)
{
CachedRankRelation.Rank = Rank;
break;
}
}
if (CachedRankRelation.Rank.RankID > 0)
{
GroupRelations.AddItem(CachedRankRelation);
}
else
{
`Log_Warn("Rank with ID" @ Relation.RankID @ "not found");
}
}
else
{
`Log_Warn("Can't convert to UniqueNetID:" @ Relation.ObjectID);
}
}
else
{
`Log_Warn("Can't parse ID:" @ Relation.ObjectID);
}
}
}
private static function bool IsUID(String ID)
{
return (Left(ID, Len(MatchUID)) ~= MatchUID);
}
private static function bool IsPlayerSteamID64(String ID)
{
return (Left(ID, Len(MatchPlayerSteamID64)) ~= MatchPlayerSteamID64);
}
private static function bool IsGroupSteamID64(String ID)
{
return (Left(ID, Len(MatchGroupSteamID64)) ~= MatchGroupSteamID64);
}
private function bool AnyToUID(String ID, out UniqueNetId UID)
{
return IsUID(ID) ? OSS.StringToUniqueNetId(ID, UID) : OSS.Int64ToUniqueNetId(ID, UID);
} }
private function PostInit() private function PostInit()
@ -132,68 +252,214 @@ private function PostInit()
return; return;
} }
if (KFGI.PlayfabInter != None && KFGI.PlayfabInter.GetGameSettings() != None)
{
KFOGS = KFOnlineGameSettings(KFGI.PlayfabInter.GetGameSettings());
}
else if (KFGI.GameInterface != None)
{
KFOGS = KFOnlineGameSettings(
KFGI.GameInterface.GetGameSettings(
KFGI.PlayerReplicationInfoClass.default.SessionName));
}
if (KFOGS == None)
{
SetTimer(1.0f, false, nameof(PostInit));
return;
}
KFGIS = KFGameInfo_Survival(KFGI); KFGIS = KFGameInfo_Survival(KFGI);
KFGIE = KFGameInfo_Endless(KFGI); KFGIE = KFGameInfo_Endless(KFGI);
SetTimer(UpdateInterval, true, nameof(UpdateTimer));
}
private function UpdateTimer()
{
// TODO: Server params monitor
} }
public function NotifyLogin(Controller C) public function NotifyLogin(Controller C)
{ {
local YAS_RepInfo RepInfo;
`Log_Trace(); `Log_Trace();
if (!CreateRepInfo(C)) RepInfo = CreateRepInfo(C);
if (RepInfo == None)
{ {
`Log_Error("Can't create RepInfo for:" @ C); `Log_Error("Can't create RepInfo for:" @ C);
return;
} }
ApplyCurrentRankRelations(RepInfo);
InitRank(RepInfo);
} }
public function NotifyLogout(Controller C) public function NotifyLogout(Controller C)
{ {
local YAS_RepInfo RepInfo;
`Log_Trace(); `Log_Trace();
if (!DestroyRepInfo(C)) RepInfo = FindRepInfo(C);
if (RepInfo == None)
{
`Log_Error("Can't find repinfo for:" @ C);
return;
}
BroadcastRemoveRankRelation(RepInfo.ActiveRankRelation, C);
if (!DestroyRepInfo(RepInfo))
{ {
`Log_Error("Can't destroy RepInfo of:" @ C); `Log_Error("Can't destroy RepInfo of:" @ C);
} }
} }
public function bool CreateRepInfo(Controller C) public function YAS_RepInfo CreateRepInfo(Controller C)
{ {
local YAS_RepInfo RepInfo; local YAS_RepInfo RepInfo;
`Log_Trace(); `Log_Trace();
if (C == None) return false;
RepInfo = Spawn(class'YAS_RepInfo', C); RepInfo = Spawn(class'YAS_RepInfo', C);
if (RepInfo == None) return false; if (RepInfo != None)
{
// Do something
RepInfos.AddItem(RepInfo); RepInfos.AddItem(RepInfo);
return true; RepInfo.YAS = Self;
RepInfo.LogLevel = LogLevel;
RepInfo.RankPlayer = CfgRanks.default.Player;
RepInfo.RankAdmin = CfgRanks.default.Admin;
} }
public function bool DestroyRepInfo(Controller C) return RepInfo;
}
private function YAS_RepInfo FindRepInfo(Controller C)
{ {
local YAS_RepInfo RepInfo; local YAS_RepInfo RepInfo;
`Log_Trace(); if (C == None) return None;
if (C == None) return false;
foreach RepInfos(RepInfo) foreach RepInfos(RepInfo)
{ {
if (RepInfo.Owner == C) if (RepInfo.Owner == C)
{ {
RepInfos.RemoveItem(RepInfo); return RepInfo;
RepInfo.SafeDestroy();
return true;
} }
} }
return false; return None;
}
public function bool DestroyRepInfo(YAS_RepInfo RepInfo)
{
`Log_Trace();
if (RepInfo == None) return false;
RepInfos.RemoveItem(RepInfo);
RepInfo.SafeDestroy();
return true;
}
private function ApplyCurrentRankRelations(YAS_RepInfo RepInfo)
{
}
private function InitRank(YAS_RepInfo RepInfo)
{
local CachedRankRelation Rel;
local String JoinedGroupIDs;
local PlayerReplicationInfo PRI;
local KFPlayerController KFPC;
local bool HasPlayerRank;
local Array<String> StringGroupIDs;
`Log_Trace();
KFPC = RepInfo.GetKFPC();
if (KFPC == None) return;
PRI = KFPC.PlayerReplicationInfo;
if (PRI == None) return;
HasPlayerRank = false;
foreach PlayerRelations(Rel)
{
if (Rel.UID.Uid == PRI.UniqueID.Uid)
{
HasPlayerRank = true;
RepInfo.ActiveRankRelation = Rel;
break;
}
}
if (HasPlayerRank)
{
BroadcastAddRankRelation(RepInfo.ActiveRankRelation);
}
else if (!KFPC.bIsEosPlayer)
{
foreach GroupRelations(Rel)
{
StringGroupIDs.AddItem(Rel.RawID);
}
JoinArray(StringGroupIDs, JoinedGroupIDs);
RepInfo.CheckGroupRanks(JoinedGroupIDs);
}
}
public function ApplyMembership(UniqueNetId GroupUID, UniqueNetId PlayerUID)
{
local CachedRankRelation RR;
local int Index;
`Log_Trace();
Index = GroupRelations.Find('UID', GroupUID);
if (Index != INDEX_NONE)
{
RR.UID = PlayerUID;
RR.Rank = GroupRelations[Index].Rank;
BroadcastAddRankRelation(RR);
}
else
{
`Log_Error("Can't find related GroupID rank");
}
}
public function BroadcastAddRankRelation(CachedRankRelation RR)
{
local YAS_RepInfo RepInfo;
`Log_Trace();
foreach RepInfos(RepInfo)
{
RepInfo.AddRankRelation(RR);
}
}
public function BroadcastRemoveRankRelation(CachedRankRelation RR, optional Controller Except)
{
local YAS_RepInfo RepInfo;
foreach RepInfos(RepInfo)
{
if (RepInfo.Owner != Except)
{
RepInfo.RemoveRankRelation(RR);
}
}
} }
DefaultProperties DefaultProperties

View File

@ -1,12 +1,74 @@
class YAS_RepInfo extends ReplicationInfo; class YAS_RepInfo extends ReplicationInfo;
// Server var public YAS YAS;
var public YASMut Mut;
var public E_LogLevel LogLevel;
// Client var public repnotify E_LogLevel LogLevel;
var public repnotify SystemRank RankPlayer, RankAdmin;
var public repnotify String DynamicServerName;
var public repnotify bool UsesStats, Custom, PasswordRequired;
var public CachedRankRelation ActiveRankRelation;
var private KFPlayerController KFPC;
var private YAS_ScoreBoard SC; var private YAS_ScoreBoard SC;
var private OnlineSubsystemSteamworks SW; var private OnlineSubsystemSteamworks OSS;
var private Array<UniqueNetID> PendingGroupIDs;
var private Array<CachedRankRelation> PendingAddRankRelations;
var private Array<CachedRankRelation> PendingRemoveRankRelations;
const CheckGroupTimer = 0.2f;
const MaxRetries = 3;
var private int Retries;
replication
{
if (bNetInitial)
LogLevel, RankPlayer, RankAdmin;
if (bNetDirty)
DynamicServerName, UsesStats, Custom, PasswordRequired;
}
public simulated event ReplicatedEvent(name VarName)
{
`Log_Trace();
switch (VarName)
{
case 'LogLevel':
if (SC != None) SC.LogLevel = LogLevel;
break;
case 'RankPlayer':
if (SC != None) SC.RankPlayer = RankPlayer;
break;
case 'RankAdmin':
if (SC != None) SC.RankAdmin = RankAdmin;
break;
case 'DynamicServerName':
if (SC != None) SC.DynamicServerName = DynamicServerName;
break;
case 'UsesStats':
if (SC != None) SC.UsesStats = UsesStats;
break;
case 'Custom':
if (SC != None) SC.Custom = Custom;
break;
case 'PasswordRequired':
if (SC != None) SC.PasswordRequired = PasswordRequired;
break;
default:
super.ReplicatedEvent(VarName);
break;
}
}
public simulated function bool SafeDestroy() public simulated function bool SafeDestroy()
{ {
@ -17,6 +79,8 @@ public simulated function bool SafeDestroy()
public simulated event PreBeginPlay() public simulated event PreBeginPlay()
{ {
`Log_Trace();
if (bPendingDelete || bDeleteMe) return; if (bPendingDelete || bDeleteMe) return;
Super.PreBeginPlay(); Super.PreBeginPlay();
@ -24,8 +88,9 @@ public simulated event PreBeginPlay()
if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone) if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
{ {
GetScoreboard(); GetScoreboard();
GetOnlineSubsystem();
} }
GetOnlineSubsystem();
} }
public simulated event PostBeginPlay() public simulated event PostBeginPlay()
@ -35,26 +100,185 @@ public simulated event PostBeginPlay()
Super.PostBeginPlay(); Super.PostBeginPlay();
} }
private reliable client function GetScoreboard() // TODO: ! public reliable client function AddRankRelation(CachedRankRelation RR)
{ {
if (SC == None) local int Index;
{
SC = YAS_HUD(GetALocalPlayerController().myHUD).Scoreboard; // GetKFPC? `Log_Trace();
}
if (SC == None) if (SC == None)
{ {
SetTimer(0.1f, false, nameof(GetScoreboard)); PendingAddRankRelations.AddItem(RR);
return;
}
Index = SC.RankRelations.Find('UID', RR.UID);
if (Index != INDEX_NONE)
{
SC.RankRelations[Index] = RR;
} }
else else
{ {
ClearTimer(nameof(GetScoreboard)); SC.RankRelations.AddItem(RR);
} }
} }
private reliable client function GetOnlineSubsystem() public reliable client function RemoveRankRelation(CachedRankRelation RR)
{ {
// TODO: ! `Log_Trace();
if (SC == None)
{
PendingRemoveRankRelations.AddItem(RR);
return;
}
SC.RankRelations.RemoveItem(RR);
}
public reliable client function CheckGroupRanks(String JoinedGroupIDs)
{
local Array<String> StringGroupIDs;
local String StringGroupID;
local UniqueNetId GroupUID;
`Log_Trace();
StringGroupIDs = SplitString(JoinedGroupIDs);
if (GetOnlineSubsystem() == None)
{
`Log_Error("Can't get online subsystem");
return;
}
foreach StringGroupIDs(StringGroupID)
{
if (OSS.Int64ToUniqueNetId(StringGroupID, GroupUID))
{
PendingGroupIDs.AddItem(GroupUID);
}
}
Retries = 0;
CheckGroupsCycle();
}
private simulated function CheckGroupsCycle()
{
local UniqueNetId GroupUID;
`Log_Trace();
if (Retries++ >= MaxRetries) return;
// CheckPlayerGroup doesn't return real values right away,
// so we do a dry run and a few checks just in case
foreach PendingGroupIDs(GroupUID) OSS.CheckPlayerGroup(GroupUID);
foreach PendingGroupIDs(GroupUID)
{
if (OSS.CheckPlayerGroup(GroupUID))
{
PendingGroupIDs.Length = 0;
ServerApplyMembership(GroupUID);
return;
}
}
SetTimer(0.2f, false, nameof(CheckGroupsCycle));
}
private reliable server function ServerApplyMembership(UniqueNetId GroupUID)
{
`Log_Trace();
if (GetKFPC() != None && KFPC.PlayerReplicationInfo != None)
{
YAS.ApplyMembership(GroupUID, KFPC.PlayerReplicationInfo.UniqueID);
}
else
{
`Log_Error("Can't apply membership for:" @ Self @ GetKFPC());
}
}
public simulated function KFPlayerController GetKFPC()
{
`Log_Trace();
if (KFPC != None) return KFPC;
KFPC = KFPlayerController(Owner);
if (KFPC == None && ROLE < ROLE_Authority)
{
KFPC = KFPlayerController(GetALocalPlayerController());
}
return KFPC;
}
private simulated function OnlineSubsystemSteamworks GetOnlineSubsystem()
{
`Log_Trace();
if (OSS == None)
{
OSS = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
}
return OSS;
}
private reliable client function GetScoreboard()
{
`Log_Trace();
if (SC == None)
{
if (GetKFPC() != None && KFPC.myHUD != None)
{
SC = YAS_HUD(KFPC.myHUD).Scoreboard;
}
}
if (SC == None)
{
SetTimer(0.2f, false, nameof(GetScoreboard));
return;
}
InitScoreboard();
}
private simulated function InitScoreboard()
{
local CachedRankRelation RR;
`Log_Trace();
if (SC == None) return;
SC.LogLevel = LogLevel;
SC.RankPlayer = RankPlayer;
SC.RankAdmin = RankAdmin;
SC.DynamicServerName = DynamicServerName;
SC.UsesStats = UsesStats;
SC.Custom = Custom;
SC.PasswordRequired = PasswordRequired;
foreach PendingRemoveRankRelations(RR)
{
RemoveRankRelation(RR);
}
PendingRemoveRankRelations.Length = 0;
foreach PendingAddRankRelations(RR)
{
AddRankRelation(RR);
}
PendingAddRankRelations.Length = 0;
} }
defaultproperties defaultproperties
@ -65,4 +289,6 @@ defaultproperties
bAlwaysRelevant = false bAlwaysRelevant = false
bOnlyRelevantToOwner = true bOnlyRelevantToOwner = true
bSkipActorPropertyReplication = false bSkipActorPropertyReplication = false
Retries = 0
} }

View File

@ -1,9 +1,11 @@
class YAS_ScoreBoard extends KFGUI_Page class YAS_ScoreBoard extends KFGUI_Page
dependson(YAS_Types); dependson(YAS_Types);
const HeaderWidthRatio = 0.35f; const HeaderWidthRatio = 0.30f;
const PlayerListWidthRatio = 0.6f; const PlayerListWidthRatio = 0.6f;
var public E_LogLevel LogLevel;
var transient float HealthXPos, RankXPos, PlayerXPos, LevelXPos, PerkXPos, DoshXPos, KillsXPos, AssistXPos, PingXPos, ScrollXPos; var transient float HealthXPos, RankXPos, PlayerXPos, LevelXPos, PerkXPos, DoshXPos, KillsXPos, AssistXPos, PingXPos, ScrollXPos;
var transient float HealthWBox, RankWBox, PlayerWBox, LevelWBox, PerkWBox, DoshWBox, KillsWBox, AssistWBox, PingWBox, ScrollWBox; var transient float HealthWBox, RankWBox, PlayerWBox, LevelWBox, PerkWBox, DoshWBox, KillsWBox, AssistWBox, PingWBox, ScrollWBox;
var transient float NextScoreboardRefresh; var transient float NextScoreboardRefresh;
@ -21,20 +23,62 @@ var KFPlayerController OwnerPC;
var Color PingColor; var Color PingColor;
var float PingBars; var float PingBars;
var localized String Players;
var localized String Spectators;
// Cache // Cache
var array<String> PerkNames; var public YAS_Settings Settings;
var public String DynamicServerName;
var public bool UsesStats, Custom, PasswordRequired;
var YAS_Settings Settings; var public SystemRank RankPlayer;
var public SystemRank RankAdmin;
var public Array<CachedRankRelation> RankRelations;
function InitMenu() function Rank PlayerRank(KFPlayerReplicationInfo KFPRI)
{ {
Super.InitMenu(); local CachedRankRelation RankRelation;
PlayersList = KFGUI_List(FindComponentID('PlayerList')); local Rank Rank;
OwnerPC = KFPlayerController(GetPlayer());
// TODO: Remove this crunch `Log_Trace();
if (PerkNames.Length == 0)
Rank = FromSystemRank(RankPlayer);
foreach RankRelations(RankRelation)
{ {
if (RankRelation.UID.Uid == KFPRI.UniqueId.Uid)
{
Rank = RankRelation.Rank;
break;
}
}
if (KFPRI.bAdmin && !Rank.OverrideAdmin)
{
Rank = FromSystemRank(RankAdmin);
}
return Rank;
}
function Rank FromSystemRank(SystemRank SysRank)
{
local Rank Rank;
Rank.RankID = 0;
Rank.RankName = SysRank.RankName;
Rank.RankColor = SysRank.RankColor;
Rank.PlayerColor = SysRank.PlayerColor;
Rank.OverrideAdmin = false;
return Rank;
}
function float MinPerkBoxWidth(float FontScalar)
{
local Array<String> PerkNames;
local String PerkName;
local float XL, YL, MaxWidth;
PerkNames.AddItem(class'KFGFxMenu_Inventory'.default.PerkFilterString); PerkNames.AddItem(class'KFGFxMenu_Inventory'.default.PerkFilterString);
PerkNames.AddItem(class'KFPerk_Berserker'.default.PerkName); PerkNames.AddItem(class'KFPerk_Berserker'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Commando'.default.PerkName); PerkNames.AddItem(class'KFPerk_Commando'.default.PerkName);
@ -46,7 +90,21 @@ function InitMenu()
PerkNames.AddItem(class'KFPerk_Sharpshooter'.default.PerkName); PerkNames.AddItem(class'KFPerk_Sharpshooter'.default.PerkName);
PerkNames.AddItem(class'KFPerk_SWAT'.default.PerkName); PerkNames.AddItem(class'KFPerk_SWAT'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Survivalist'.default.PerkName); PerkNames.AddItem(class'KFPerk_Survivalist'.default.PerkName);
foreach PerkNames(PerkName)
{
Canvas.TextSize(PerkName $ "A", XL, YL, FontScalar, FontScalar);
if (XL > MaxWidth) MaxWidth = XL;
} }
return MaxWidth;
}
function InitMenu()
{
Super.InitMenu();
PlayersList = KFGUI_List(FindComponentID('PlayerList'));
OwnerPC = KFPlayerController(GetPlayer());
} }
static function CheckAvatar(KFPlayerReplicationInfo KFPRI, KFPlayerController PC) static function CheckAvatar(KFPlayerReplicationInfo KFPRI, KFPlayerController PC)
@ -108,22 +166,6 @@ function string WaveText()
} }
} }
function String ServerName()
{
local KFOnlineGameSettings KFGS;
local KFGameInfo KFGI;
KFGI = KFGameInfo(KFGRI.WorldInfo.Game);
if (KFGI != None && KFGI.PlayfabInter != None && KFGI.PlayfabInter.GetGameSettings() != None)
{
KFGS = KFOnlineGameSettings(KFGI.PlayfabInter.GetGameSettings());
return KFGS.OwningPlayerName;
}
return KFGRI.ServerName;
}
function DrawMenu() function DrawMenu()
{ {
local string S; local string S;
@ -212,7 +254,7 @@ function DrawMenu()
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeServerNameBox); Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeServerNameBox);
Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor); Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor);
S = ServerName(); S = (DynamicServerName == "" ? KFGRI.ServerName : DynamicServerName);
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar); DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar);
YPos += BoxH; YPos += BoxH;
@ -251,7 +293,7 @@ function DrawMenu()
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapePlayersCountBox); Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapePlayersCountBox);
Canvas.SetDrawColorStruct(Settings.Style.PlayerCountTextColor); Canvas.SetDrawColorStruct(Settings.Style.PlayerCountTextColor);
S = NumPlayer $ " / " $ KFGRI.MaxHumanCount; // $ " " $ Spectators $ ": " $ NumSpec; S = Players $ ":" @ NumPlayer @ "/" @ KFGRI.MaxHumanCount $ " " $ Spectators $ ":" @ NumSpec;
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar); Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar); DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar);
@ -305,12 +347,7 @@ function DrawMenu()
DoshWBox = XL < DoshSize ? DoshSize : XL; DoshWBox = XL < DoshSize ? DoshSize : XL;
DoshXPos = KillsXPos - DoshWBox; DoshXPos = KillsXPos - DoshWBox;
BoxW = 0; BoxW = MinPerkBoxWidth(FontScalar);
foreach PerkNames(S)
{
Canvas.TextSize(S$"A", XL, YL, FontScalar, FontScalar);
if (XL > BoxW) BoxW = XL;
}
PerkWBox = BoxW < MinBoxW ? MinBoxW : BoxW; PerkWBox = BoxW < MinBoxW ? MinBoxW : BoxW;
PerkXPos = DoshXPos - PerkWBox; PerkXPos = DoshXPos - PerkWBox;
@ -394,6 +431,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
local byte Level, PrestigeLevel; local byte Level, PrestigeLevel;
local bool bIsZED; local bool bIsZED;
local int Ping; local int Ping;
local Rank Rank;
local float BorderSize; local float BorderSize;
@ -406,6 +444,8 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
YOffset *= 1.05; YOffset *= 1.05;
KFPRI = KFPRIArray[Index]; KFPRI = KFPRIArray[Index];
Rank = PlayerRank(KFPRI);
if (KFGRI.bVersusGame) if (KFGRI.bVersusGame)
{ {
bIsZED = KFTeamInfo_Zeds(KFPRI.Team) != None; bIsZED = KFTeamInfo_Zeds(KFPRI.Team) != None;
@ -605,24 +645,28 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
} }
// Rank // Rank
DrawTextShadowHRightVCenter("<Player>", PlayerXPos, TextYOffset, PerkIconPosX - PlayerXPos - (BorderSize * 2), FontScalar); if (Rank.RankName != "")
{
C.SetDrawColorStruct(Rank.RankColor);
DrawTextShadowHRightVCenter(Rank.RankName, PlayerXPos, TextYOffset, PerkIconPosX - PlayerXPos - (BorderSize * 4), FontScalar);
}
// Avatar // Avatar
if (KFPRI.Avatar == None || (!KFPRI.bBot && KFPRI.Avatar == default.DefaultAvatar))
{
CheckAvatar(KFPRI, OwnerPC);
}
if (KFPRI.Avatar != None) if (KFPRI.Avatar != None)
{ {
if (KFPRI.Avatar == default.DefaultAvatar)
CheckAvatar(KFPRI, OwnerPC);
C.SetDrawColor(255, 255, 255, 255); C.SetDrawColor(255, 255, 255, 255);
C.SetPos(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f)); C.SetPos(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f));
C.DrawTile(KFPRI.Avatar, Height - 6, Height - 6, 0,0, KFPRI.Avatar.SizeX, KFPRI.Avatar.SizeY); C.DrawTile(KFPRI.Avatar, Height - 6, Height - 6, 0,0, KFPRI.Avatar.SizeX, KFPRI.Avatar.SizeY);
Owner.CurrentStyle.DrawBoxHollow(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f), Height - 6, Height - 6, 1); Owner.CurrentStyle.DrawBoxHollow(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f), Height - 6, Height - 6, 1);
} }
else if (!KFPRI.bBot)
CheckAvatar(KFPRI, OwnerPC);
// Player // Player
C.SetDrawColorStruct(Settings.Style.PlayerNameTextColor); C.SetDrawColorStruct(Rank.PlayerColor);
S = KFPRI.PlayerName; S = KFPRI.PlayerName;
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar); Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
while (XL > RealPlayerWBox) while (XL > RealPlayerWBox)

View File

@ -1,31 +1,5 @@
class YAS_Types extends Object; class YAS_Types extends Object;
struct Fields
{
var bool Rank;
var bool Player;
var bool Level;
var bool Perk;
var bool Dosh;
var bool Kills;
var bool Assists;
var bool Health;
var bool Ping;
Structdefaultproperties
{
Rank = true;
Player = true;
Level = false;
Perk = false;
Dosh = false;
Kills = false;
Assists = false;
Health = false;
Ping = false;
}
};
struct YAS_SettingsHealth struct YAS_SettingsHealth
{ {
var int Low; var int Low;
@ -314,6 +288,51 @@ struct YAS_Style
} }
}; };
struct SystemRank
{
var String RankName;
var Color RankColor;
var Color PlayerColor;
structdefaultproperties
{
RankName = ""
RankColor = (R=250, G=250, B=250, A=255)
PlayerColor = (R=250, G=250, B=250, A=255)
}
};
struct Rank
{
var int RankID;
var String RankName;
var Color RankColor;
var Color PlayerColor;
var bool OverrideAdmin;
structdefaultproperties
{
RankID = 0
RankName = ""
RankColor = (R=250, G=250, B=250, A=255)
PlayerColor = (R=250, G=250, B=250, A=255)
OverrideAdmin = false
}
};
struct RankRelation
{
var int RankID;
var String ObjectID;
};
struct CachedRankRelation
{
var String RawID;
var UniqueNetId UID;
var Rank Rank;
};
struct YAS_Settings struct YAS_Settings
{ {
var YAS_Style Style; var YAS_Style Style;