From 85c2fb65bb86f4d41a1f70cb4410527f1d7e946b Mon Sep 17 00:00:00 2001 From: GenZmeY Date: Wed, 7 Sep 2022 15:57:47 +0300 Subject: [PATCH] wip --- Localization/INT/YAS.INT | Bin 116 -> 120 bytes Localization/RUS/YAS.RUS | Bin 116 -> 120 bytes YAS/Classes/RankRelations.uc | 39 +++++ YAS/Classes/Ranks.uc | 52 ++++++ YAS/Classes/YAS.uc | 312 +++++++++++++++++++++++++++++++--- YAS/Classes/YAS_RepInfo.uc | 256 ++++++++++++++++++++++++++-- YAS/Classes/YAS_ScoreBoard.uc | 148 ++++++++++------ YAS/Classes/YAS_Types.uc | 71 +++++--- 8 files changed, 762 insertions(+), 116 deletions(-) create mode 100644 YAS/Classes/RankRelations.uc create mode 100644 YAS/Classes/Ranks.uc diff --git a/Localization/INT/YAS.INT b/Localization/INT/YAS.INT index 6da12c675536430e53e59601028f1af1768c6091..8538fdc7833e65748c539e46b2400caa258b92ea 100644 GIT binary patch delta 17 YcmXS^;Qs$Fnjw 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 +{ + +} diff --git a/YAS/Classes/Ranks.uc b/YAS/Classes/Ranks.uc new file mode 100644 index 0000000..676b698 --- /dev/null +++ b/YAS/Classes/Ranks.uc @@ -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 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 +{ + +} diff --git a/YAS/Classes/YAS.uc b/YAS/Classes/YAS.uc index 9158775..74dfb3d 100644 --- a/YAS/Classes/YAS.uc +++ b/YAS/Classes/YAS.uc @@ -3,18 +3,30 @@ class YAS extends Info 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 E_LogLevel LogLevel; +var private config int UpdateInterval; var private KFGameInfo KFGI; var private KFGameInfo_Survival KFGIS; var private KFGameInfo_Endless KFGIE; var private KFGameReplicationInfo KFGRI; +var private KFOnlineGameSettings KFOGS; + +var private OnlineSubsystemSteamworks OSS; var private Array RepInfos; +var private Array PlayerRelations; +var private Array GroupRelations; + public simulated function bool SafeDestroy() { `Log_Trace(); @@ -56,10 +68,12 @@ private function PreInit() if (Version == `NO_CONFIG) { LogLevel = LL_Info; + UpdateInterval = 1; SaveConfig(); } - //CfgExampleConfig.static.InitConfig(Version, LatestVersion); + CfgRanks.static.InitConfig(Version, LatestVersion); + CfgRankRelations.static.InitConfig(Version, LatestVersion); switch (Version) { @@ -95,7 +109,113 @@ private function PreInit() } `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 Relations; + local Array 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() @@ -132,68 +252,214 @@ private function PostInit() 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); KFGIE = KFGameInfo_Endless(KFGI); + + SetTimer(UpdateInterval, true, nameof(UpdateTimer)); +} + +private function UpdateTimer() +{ + // TODO: Server params monitor } public function NotifyLogin(Controller C) { + local YAS_RepInfo RepInfo; + `Log_Trace(); - if (!CreateRepInfo(C)) + RepInfo = CreateRepInfo(C); + if (RepInfo == None) { `Log_Error("Can't create RepInfo for:" @ C); + return; } + + ApplyCurrentRankRelations(RepInfo); + InitRank(RepInfo); } public function NotifyLogout(Controller C) { + local YAS_RepInfo RepInfo; + `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); } } -public function bool CreateRepInfo(Controller C) +public function YAS_RepInfo CreateRepInfo(Controller C) { local YAS_RepInfo RepInfo; `Log_Trace(); - if (C == None) return false; - RepInfo = Spawn(class'YAS_RepInfo', C); - if (RepInfo == None) return false; + if (RepInfo != None) + { + RepInfos.AddItem(RepInfo); + + RepInfo.YAS = Self; + RepInfo.LogLevel = LogLevel; + RepInfo.RankPlayer = CfgRanks.default.Player; + RepInfo.RankAdmin = CfgRanks.default.Admin; + } - // Do something - - RepInfos.AddItem(RepInfo); - - return true; + return RepInfo; } -public function bool DestroyRepInfo(Controller C) +private function YAS_RepInfo FindRepInfo(Controller C) { local YAS_RepInfo RepInfo; - `Log_Trace(); - - if (C == None) return false; + if (C == None) return None; foreach RepInfos(RepInfo) { if (RepInfo.Owner == C) { - RepInfos.RemoveItem(RepInfo); - RepInfo.SafeDestroy(); - return true; + return RepInfo; } } - 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 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 diff --git a/YAS/Classes/YAS_RepInfo.uc b/YAS/Classes/YAS_RepInfo.uc index a68e835..34cc73c 100644 --- a/YAS/Classes/YAS_RepInfo.uc +++ b/YAS/Classes/YAS_RepInfo.uc @@ -1,12 +1,74 @@ class YAS_RepInfo extends ReplicationInfo; -// Server -var public YASMut Mut; -var public E_LogLevel LogLevel; +var public YAS YAS; -// 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 OnlineSubsystemSteamworks SW; +var private OnlineSubsystemSteamworks OSS; + +var private Array PendingGroupIDs; +var private Array PendingAddRankRelations; +var private Array 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() { @@ -17,6 +79,8 @@ public simulated function bool SafeDestroy() public simulated event PreBeginPlay() { + `Log_Trace(); + if (bPendingDelete || bDeleteMe) return; Super.PreBeginPlay(); @@ -24,8 +88,9 @@ public simulated event PreBeginPlay() if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone) { GetScoreboard(); - GetOnlineSubsystem(); } + + GetOnlineSubsystem(); } public simulated event PostBeginPlay() @@ -35,26 +100,185 @@ public simulated event PostBeginPlay() Super.PostBeginPlay(); } -private reliable client function GetScoreboard() // TODO: ! +public reliable client function AddRankRelation(CachedRankRelation RR) { + local int Index; + + `Log_Trace(); + if (SC == None) { - SC = YAS_HUD(GetALocalPlayerController().myHUD).Scoreboard; // GetKFPC? + PendingAddRankRelations.AddItem(RR); + return; + } + + Index = SC.RankRelations.Find('UID', RR.UID); + if (Index != INDEX_NONE) + { + SC.RankRelations[Index] = RR; + } + else + { + SC.RankRelations.AddItem(RR); + } +} + +public reliable client function RemoveRankRelation(CachedRankRelation RR) +{ + `Log_Trace(); + + if (SC == None) + { + PendingRemoveRankRelations.AddItem(RR); + return; + } + + SC.RankRelations.RemoveItem(RR); +} + +public reliable client function CheckGroupRanks(String JoinedGroupIDs) +{ + local Array 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.1f, false, nameof(GetScoreboard)); - } - else - { - ClearTimer(nameof(GetScoreboard)); + SetTimer(0.2f, false, nameof(GetScoreboard)); + return; } + + InitScoreboard(); } -private reliable client function GetOnlineSubsystem() +private simulated function InitScoreboard() { - // TODO: ! + 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 @@ -65,4 +289,6 @@ defaultproperties bAlwaysRelevant = false bOnlyRelevantToOwner = true bSkipActorPropertyReplication = false + + Retries = 0 } \ No newline at end of file diff --git a/YAS/Classes/YAS_ScoreBoard.uc b/YAS/Classes/YAS_ScoreBoard.uc index c44bef0..29017fd 100644 --- a/YAS/Classes/YAS_ScoreBoard.uc +++ b/YAS/Classes/YAS_ScoreBoard.uc @@ -1,9 +1,11 @@ class YAS_ScoreBoard extends KFGUI_Page dependson(YAS_Types); -const HeaderWidthRatio = 0.35f; +const HeaderWidthRatio = 0.30f; 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 HealthWBox, RankWBox, PlayerWBox, LevelWBox, PerkWBox, DoshWBox, KillsWBox, AssistWBox, PingWBox, ScrollWBox; var transient float NextScoreboardRefresh; @@ -21,32 +23,88 @@ var KFPlayerController OwnerPC; var Color PingColor; var float PingBars; -// Cache -var array PerkNames; +var localized String Players; +var localized String Spectators; -var YAS_Settings Settings; +// Cache +var public YAS_Settings Settings; +var public String DynamicServerName; +var public bool UsesStats, Custom, PasswordRequired; + +var public SystemRank RankPlayer; +var public SystemRank RankAdmin; +var public Array RankRelations; + +function Rank PlayerRank(KFPlayerReplicationInfo KFPRI) +{ + local CachedRankRelation RankRelation; + local Rank Rank; + + `Log_Trace(); + + 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 PerkNames; + local String PerkName; + local float XL, YL, MaxWidth; + + PerkNames.AddItem(class'KFGFxMenu_Inventory'.default.PerkFilterString); + PerkNames.AddItem(class'KFPerk_Berserker'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Commando'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Support'.default.PerkName); + PerkNames.AddItem(class'KFPerk_FieldMedic'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Demolitionist'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Firebug'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Gunslinger'.default.PerkName); + PerkNames.AddItem(class'KFPerk_Sharpshooter'.default.PerkName); + PerkNames.AddItem(class'KFPerk_SWAT'.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()); - - // TODO: Remove this crunch - if (PerkNames.Length == 0) - { - PerkNames.AddItem(class'KFGFxMenu_Inventory'.default.PerkFilterString); - PerkNames.AddItem(class'KFPerk_Berserker'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Commando'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Support'.default.PerkName); - PerkNames.AddItem(class'KFPerk_FieldMedic'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Demolitionist'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Firebug'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Gunslinger'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Sharpshooter'.default.PerkName); - PerkNames.AddItem(class'KFPerk_SWAT'.default.PerkName); - PerkNames.AddItem(class'KFPerk_Survivalist'.default.PerkName); - } } 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() { local string S; @@ -212,7 +254,7 @@ function DrawMenu() Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeServerNameBox); Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor); - S = ServerName(); + S = (DynamicServerName == "" ? KFGRI.ServerName : DynamicServerName); DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar); YPos += BoxH; @@ -251,7 +293,7 @@ function DrawMenu() Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapePlayersCountBox); 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); DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar); @@ -305,12 +347,7 @@ function DrawMenu() DoshWBox = XL < DoshSize ? DoshSize : XL; DoshXPos = KillsXPos - DoshWBox; - BoxW = 0; - foreach PerkNames(S) - { - Canvas.TextSize(S$"A", XL, YL, FontScalar, FontScalar); - if (XL > BoxW) BoxW = XL; - } + BoxW = MinPerkBoxWidth(FontScalar); PerkWBox = BoxW < MinBoxW ? MinBoxW : BoxW; PerkXPos = DoshXPos - PerkWBox; @@ -394,6 +431,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float local byte Level, PrestigeLevel; local bool bIsZED; local int Ping; + local Rank Rank; local float BorderSize; @@ -405,7 +443,9 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float YOffset *= 1.05; KFPRI = KFPRIArray[Index]; - + + Rank = PlayerRank(KFPRI); + if (KFGRI.bVersusGame) { bIsZED = KFTeamInfo_Zeds(KFPRI.Team) != None; @@ -605,24 +645,28 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float } // Rank - DrawTextShadowHRightVCenter("", 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 + if (KFPRI.Avatar == None || (!KFPRI.bBot && KFPRI.Avatar == default.DefaultAvatar)) + { + CheckAvatar(KFPRI, OwnerPC); + } + if (KFPRI.Avatar != None) { - if (KFPRI.Avatar == default.DefaultAvatar) - CheckAvatar(KFPRI, OwnerPC); - C.SetDrawColor(255, 255, 255, 255); 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); 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 - C.SetDrawColorStruct(Settings.Style.PlayerNameTextColor); + C.SetDrawColorStruct(Rank.PlayerColor); S = KFPRI.PlayerName; Canvas.TextSize(S, XL, YL, FontScalar, FontScalar); while (XL > RealPlayerWBox) diff --git a/YAS/Classes/YAS_Types.uc b/YAS/Classes/YAS_Types.uc index c2dc859..544a110 100644 --- a/YAS/Classes/YAS_Types.uc +++ b/YAS/Classes/YAS_Types.uc @@ -1,31 +1,5 @@ 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 { 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 { var YAS_Style Style;