more readability

This commit is contained in:
GenZmeY 2021-06-09 00:48:03 +03:00
parent 8b15531abd
commit bb8452fa0b
9 changed files with 61 additions and 62 deletions

View File

@ -0,0 +1,5 @@
class CustomRanks extends Object
dependson(Types)
config(ScoreboardExt);
var config array<RankInfo> Rank;

View File

@ -18,8 +18,8 @@ var Color PingColor;
var float PingBars,IdealPing,MaxPing; var float PingBars,IdealPing,MaxPing;
// Ranks // Ranks
var array<RankInfo> PlayerRanks; var array<RankInfo> CustomRanks;
var array<UIDRankRelation> PlayerInfos; var array<UIDRankRelation> PlayerRankRelations;
var string SystemAdminRank; var string SystemAdminRank;
var ColorRGB SystemAdminColor; var ColorRGB SystemAdminColor;
@ -333,14 +333,14 @@ function DrawPlayerEntry( Canvas C, int Index, float YOffset, float Height, floa
KFPRI = KFPRIArray[Index]; KFPRI = KFPRIArray[Index];
HasRank = false; HasRank = false;
PlayerInfoIndex = PlayerInfos.Find('UID', KFPRI.UniqueId); PlayerInfoIndex = PlayerRankRelations.Find('UID', KFPRI.UniqueId);
if (PlayerInfoIndex != INDEX_NONE ) if (PlayerInfoIndex != INDEX_NONE )
{ {
PlayerRankIndex = PlayerRanks.Find('ID', PlayerInfos[PlayerInfoIndex].RankID); PlayerRankIndex = CustomRanks.Find('ID', PlayerRankRelations[PlayerInfoIndex].RankID);
if (PlayerRankIndex != INDEX_NONE) if (PlayerRankIndex != INDEX_NONE)
{ {
HasRank = true; HasRank = true;
CurrentRank = PlayerRanks[PlayerRankIndex]; CurrentRank = CustomRanks[PlayerRankIndex];
} }
} }

View File

@ -1,5 +0,0 @@
class PlayerInfos extends Object
dependson(Types)
config(ScoreboardExt);
var config array<PlayerRankRelation> PlayerInfo;

View File

@ -0,0 +1,5 @@
class PlayerRankRelations extends Object
dependson(Types)
config(ScoreboardExt);
var config array<PlayerRankRelation> Relation;

View File

@ -1,5 +0,0 @@
class PlayerRanks extends Object
dependson(Types)
config(ScoreboardExt);
var config array<RankInfo> PlayerRank;

View File

@ -1,5 +1,5 @@
class ScoreboardExtMut extends KFMutator class ScoreboardExtMut extends KFMutator
dependson(PlayerRanks, PlayerInfos) dependson(CustomRanks, PlayerRankRelations)
config(ScoreboardExt); config(ScoreboardExt);
const SteamIDLen = 17; const SteamIDLen = 17;
@ -16,34 +16,33 @@ struct SClient
}; };
var private array<SClient> RepClients; var private array<SClient> RepClients;
var private array<UIDRankRelation> UIDRelations;
var private array<UIDRankRelation> UIDInfos;
function PostBeginPlay() function PostBeginPlay()
{ {
Super.PostBeginPlay(); Super.PostBeginPlay();
WorldInfo.Game.HUDType = class'ScoreboardExtHUD'; WorldInfo.Game.HUDType = class'ScoreboardExtHUD';
InitConfig(); InitConfig();
LoadGroupPlayers(); LoadPlayerRelations();
} }
function NotifyLogin(Controller C) function NotifyLogin(Controller C)
{ {
AddPlayerInfo(C); AddPlayer(C);
Super.NotifyLogin(C); Super.NotifyLogin(C);
} }
function NotifyLogout(Controller C) function NotifyLogout(Controller C)
{ {
RemovePlayerInfo(C); RemovePlayer(C);
Super.NotifyLogout(C); Super.NotifyLogout(C);
} }
private function InitConfig() private function InitConfig()
{ {
local RankInfo ExampleRank; local RankInfo ExampleRank;
local PlayerRankRelation ExamplePlayer; local PlayerRankRelation ExamplePlayer;
local SteamGroupRankRelation ExampleSteamGroup; local SteamGroupRankRelation ExampleSteamGroup;
// Update from config version to current version if needed // Update from config version to current version if needed
switch (ConfigVersion) switch (ConfigVersion)
@ -70,12 +69,12 @@ private function InitConfig()
ExampleRank.TextColor.G = 250; ExampleRank.TextColor.G = 250;
ExampleRank.TextColor.B = 235; ExampleRank.TextColor.B = 235;
ExampleRank.OverrideAdminRank = true; ExampleRank.OverrideAdminRank = true;
class'PlayerRanks'.default.PlayerRank.AddItem(ExampleRank); class'CustomRanks'.default.Rank.AddItem(ExampleRank);
// Example player // Example player
ExamplePlayer.PlayerID = "76561198001617867"; // GenZmeY SteamID64 ExamplePlayer.PlayerID = "76561198001617867"; // GenZmeY SteamID64
ExamplePlayer.RankID = ExampleRank.ID; ExamplePlayer.RankID = ExampleRank.ID;
class'PlayerInfos'.default.PlayerInfo.AddItem(ExamplePlayer); class'PlayerRankRelations'.default.Relation.AddItem(ExamplePlayer);
// Example rank for steam group members // Example rank for steam group members
ExampleRank.ID = 1; ExampleRank.ID = 1;
@ -84,18 +83,18 @@ private function InitConfig()
ExampleRank.TextColor.G = 250; ExampleRank.TextColor.G = 250;
ExampleRank.TextColor.B = 130; ExampleRank.TextColor.B = 130;
ExampleRank.OverrideAdminRank = false; ExampleRank.OverrideAdminRank = false;
class'PlayerRanks'.default.PlayerRank.AddItem(ExampleRank); class'CustomRanks'.default.Rank.AddItem(ExampleRank);
// Example steam group // Example steam group
ExampleSteamGroup.SteamGroupID = "103582791465384046"; // MSK-GS SteamID64 ExampleSteamGroup.SteamGroupID = "103582791465384046"; // MSK-GS SteamID64
ExampleSteamGroup.RankID = ExampleRank.ID; ExampleSteamGroup.RankID = ExampleRank.ID;
class'SteamGroups'.default.SteamGroup.AddItem(ExampleSteamGroup); class'SteamGroupRankRelations'.default.Relation.AddItem(ExampleSteamGroup);
class'SystemAdminRank'.static.StaticSaveConfig(); class'SystemAdminRank'.static.StaticSaveConfig();
class'SystemPlayerRank'.static.StaticSaveConfig(); class'SystemPlayerRank'.static.StaticSaveConfig();
class'PlayerRanks'.static.StaticSaveConfig(); class'CustomRanks'.static.StaticSaveConfig();
class'PlayerInfos'.static.StaticSaveConfig(); class'PlayerRankRelations'.static.StaticSaveConfig();
class'SteamGroups'.static.StaticSaveConfig(); class'SteamGroupRankRelations'.static.StaticSaveConfig();
case 2147483647: case 2147483647:
`log("[ScoreboardExt] Config updated to version"@CurrentVersion); `log("[ScoreboardExt] Config updated to version"@CurrentVersion);
@ -117,7 +116,7 @@ private function InitConfig()
} }
} }
private function LoadGroupPlayers() private function LoadPlayerRelations()
{ {
local PlayerRankRelation Player; local PlayerRankRelation Player;
local OnlineSubsystem steamworks; local OnlineSubsystem steamworks;
@ -125,24 +124,24 @@ private function LoadGroupPlayers()
steamworks = class'GameEngine'.static.GetOnlineSubsystem(); steamworks = class'GameEngine'.static.GetOnlineSubsystem();
foreach class'PlayerInfos'.default.PlayerInfo(Player) foreach class'PlayerRankRelations'.default.Relation(Player)
{ {
UIDInfo.RankID = Player.RankID; UIDInfo.RankID = Player.RankID;
if (Len(Player.PlayerID) == UniqueIDLen && steamworks.StringToUniqueNetId(Player.PlayerID, UIDInfo.UID)) if (Len(Player.PlayerID) == UniqueIDLen && steamworks.StringToUniqueNetId(Player.PlayerID, UIDInfo.UID))
{ {
if (UIDInfos.Find('Uid', UIDInfo.UID) == INDEX_NONE) if (UIDRelations.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDInfos.AddItem(UIDInfo); UIDRelations.AddItem(UIDInfo);
} }
else if (Len(Player.PlayerID) == SteamIDLen && steamworks.Int64ToUniqueNetId(Player.PlayerID, UIDInfo.UID)) else if (Len(Player.PlayerID) == SteamIDLen && steamworks.Int64ToUniqueNetId(Player.PlayerID, UIDInfo.UID))
{ {
if (UIDInfos.Find('Uid', UIDInfo.UID) == INDEX_NONE) if (UIDRelations.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDInfos.AddItem(UIDInfo); UIDRelations.AddItem(UIDInfo);
} }
else `Log("[ScoreboardExt] WARN: Can't add player:"@Player.PlayerID); else `Log("[ScoreboardExt] WARN: Can't add player:"@Player.PlayerID);
} }
} }
function AddPlayerInfo(Controller C) function AddPlayer(Controller C)
{ {
local KFPlayerController KFPC; local KFPlayerController KFPC;
local SClient RepClient; local SClient RepClient;
@ -156,8 +155,8 @@ function AddPlayerInfo(Controller C)
RepClients.AddItem(RepClient); RepClients.AddItem(RepClient);
RepClient.RepInfo.PlayerInfos = UIDInfos; RepClient.RepInfo.PlayerRankRelations = UIDRelations;
RepClient.RepInfo.PlayerRanks = class'PlayerRanks'.default.PlayerRank; RepClient.RepInfo.CustomRanks = class'CustomRanks'.default.Rank;
RepClient.RepInfo.SystemAdminRank = class'SystemAdminRank'.default.Rank; RepClient.RepInfo.SystemAdminRank = class'SystemAdminRank'.default.Rank;
RepClient.RepInfo.SystemAdminColor = class'SystemAdminRank'.default.TextColor; RepClient.RepInfo.SystemAdminColor = class'SystemAdminRank'.default.TextColor;
RepClient.RepInfo.SystemAdminApplyColorToFields = class'SystemAdminRank'.default.ApplyColorToFields; RepClient.RepInfo.SystemAdminApplyColorToFields = class'SystemAdminRank'.default.ApplyColorToFields;
@ -168,7 +167,7 @@ function AddPlayerInfo(Controller C)
RepClient.RepInfo.ClientStartReplication(); RepClient.RepInfo.ClientStartReplication();
} }
function RemovePlayerInfo(Controller C) function RemovePlayer(Controller C)
{ {
local KFPlayerController KFPC; local KFPlayerController KFPC;
local int Index; local int Index;

View File

@ -1,7 +1,7 @@
class ScoreboardExtRepInfo extends ReplicationInfo; class ScoreboardExtRepInfo extends ReplicationInfo;
var public array<UIDRankRelation> PlayerInfos; var public array<UIDRankRelation> PlayerRankRelations;
var public array<RankInfo> PlayerRanks; var public array<RankInfo> CustomRanks;
var public string SystemAdminRank; var public string SystemAdminRank;
var public ColorRGB SystemAdminColor; var public ColorRGB SystemAdminColor;
@ -34,9 +34,9 @@ public function ClientStartReplication()
public function ClientReplicateRanks() public function ClientReplicateRanks()
{ {
if (RanksReplicateProgress < PlayerRanks.Length) if (RanksReplicateProgress < CustomRanks.Length)
{ {
ClientAddPlayerRank(PlayerRanks[RanksReplicateProgress]); ClientAddPlayerRank(CustomRanks[RanksReplicateProgress]);
++RanksReplicateProgress; ++RanksReplicateProgress;
} }
else else
@ -48,9 +48,9 @@ public function ClientReplicateRanks()
public function ClientReplicateInfos() public function ClientReplicateInfos()
{ {
if (InfosReplicateProgress < PlayerInfos.Length) if (InfosReplicateProgress < PlayerRankRelations.Length)
{ {
ClientAddPlayerInfo(PlayerInfos[InfosReplicateProgress]); ClientAddPlayerInfo(PlayerRankRelations[InfosReplicateProgress]);
++InfosReplicateProgress; ++InfosReplicateProgress;
} }
else else
@ -74,12 +74,12 @@ private reliable client function GetScoreboard()
private reliable client function ClientAddPlayerRank(RankInfo Rank) private reliable client function ClientAddPlayerRank(RankInfo Rank)
{ {
PlayerRanks.AddItem(Rank); CustomRanks.AddItem(Rank);
} }
private reliable client function ClientAddPlayerInfo(UIDRankRelation PlayerInfo) private reliable client function ClientAddPlayerInfo(UIDRankRelation PlayerInfo)
{ {
PlayerInfos.AddItem(PlayerInfo); PlayerRankRelations.AddItem(PlayerInfo);
} }
private reliable client function RankReplicationFinished() private reliable client function RankReplicationFinished()
@ -139,7 +139,7 @@ private reliable client function ClientRanksApply()
return; return;
} }
SC.PlayerRanks = PlayerRanks; SC.CustomRanks = CustomRanks;
RanksFinished = true; RanksFinished = true;
Finished(); Finished();
} }
@ -152,7 +152,7 @@ private reliable client function ClientInfosApply()
return; return;
} }
SC.PlayerInfos = PlayerInfos; SC.PlayerRankRelations = PlayerRankRelations;
RanksFinished = true; RanksFinished = true;
Finished(); Finished();
} }

View File

@ -0,0 +1,10 @@
class SteamGroupRankRelations extends Object
dependson(Types)
config(ScoreboardExt);
var config array<SteamGroupRankRelation> Relation;
DefaultProperties
{
}

View File

@ -1,10 +0,0 @@
class SteamGroups extends Object
dependson(Types)
config(ScoreboardExt);
var config array<SteamGroupRankRelation> SteamGroup;
DefaultProperties
{
}