KF2-YetAnotherScoreboard/ScoreboardExt/Classes/KFScoreBoard.uc

734 lines
21 KiB
Ucode
Raw Normal View History

2021-05-31 01:46:53 +00:00
class KFScoreBoard extends KFGUI_Page
dependson(Types);
2020-01-10 13:14:11 +00:00
2021-06-12 20:11:37 +00:00
`include(Build.uci)
`include(Logger.uci)
2021-06-06 21:22:24 +00:00
var transient float RankXPos, PerkXPos, PlayerXPos, HealthXPos, TimeXPos, KillsXPos, AssistXPos, CashXPos, DeathXPos, PingXPos;
var transient float StatusWBox, PlayerWBox, PerkWBox, CashWBox, KillsWBox, AssistWBox, HealthWBox, PingWBox;
2020-01-10 13:14:11 +00:00
var transient float NextScoreboardRefresh;
var int PlayerIndex;
var KFGUI_List PlayersList;
var Texture2D DefaultAvatar;
var KFGameReplicationInfo KFGRI;
2021-06-13 03:17:40 +00:00
var array<KFPlayerReplicationInfo> KFPRIArray;
2020-01-10 13:14:11 +00:00
var KFPlayerController OwnerPC;
var Color PingColor;
2021-06-13 02:29:47 +00:00
var float PingBars;
2020-01-10 13:14:11 +00:00
2021-06-08 21:21:28 +00:00
// Ranks
2021-06-13 03:17:40 +00:00
var array<RankInfo> CustomRanks;
var array<UIDRankRelation> RankRelations;
2021-05-31 01:46:53 +00:00
2021-06-08 23:22:35 +00:00
var SCESettings Settings;
2021-05-31 01:46:53 +00:00
2020-01-10 13:14:11 +00:00
function InitMenu()
{
Super.InitMenu();
PlayersList = KFGUI_List(FindComponentID('PlayerList'));
OwnerPC = KFPlayerController(GetPlayer());
2020-01-10 13:14:11 +00:00
}
static function CheckAvatar(KFPlayerReplicationInfo KFPRI, KFPlayerController PC)
{
local Texture2D Avatar;
2021-06-13 02:53:33 +00:00
if (KFPRI.Avatar == None || KFPRI.Avatar == default.DefaultAvatar)
{
Avatar = FindAvatar(PC, KFPRI.UniqueId);
2021-06-13 02:53:33 +00:00
if (Avatar == None)
Avatar = default.DefaultAvatar;
KFPRI.Avatar = Avatar;
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
delegate bool InOrder(KFPlayerReplicationInfo P1, KFPlayerReplicationInfo P2)
2020-01-10 13:14:11 +00:00
{
2021-06-13 02:53:33 +00:00
if (P1 == None || P2 == None)
return true;
2021-06-13 02:53:33 +00:00
if (P1.GetTeamNum() < P2.GetTeamNum())
return false;
2021-06-13 02:53:33 +00:00
if (P1.Kills == P2.Kills)
{
2021-06-13 02:53:33 +00:00
if (P1.Assists == P2.Assists)
return true;
return P1.Assists < P2.Assists;
}
return P1.Kills < P2.Kills;
2020-01-10 13:14:11 +00:00
}
2021-06-07 01:30:04 +00:00
function string WaveText()
{
local int CurrentWaveNum;
CurrentWaveNum = KFGRI.WaveNum;
2021-06-13 02:53:33 +00:00
if (KFGRI.IsBossWave())
2021-06-07 01:30:04 +00:00
{
return class'KFGFxHUD_WaveInfo'.default.BossWaveString;
}
else if (KFGRI.IsFinalWave())
{
return class'KFGFxHUD_ScoreboardMapInfoContainer'.default.FinalString;
}
else
{
if (KFGRI.default.bEndlessMode)
{
return "" $ CurrentWaveNum;
}
else
{
return CurrentWaveNum $ " / " $ KFGRI.GetFinalWaveNum();
}
}
}
2020-01-10 13:14:11 +00:00
function DrawMenu()
{
local string S;
local PlayerController PC;
local KFPlayerReplicationInfo KFPRI;
local PlayerReplicationInfo PRI;
local float XPos, YPos, YL, XL, FontScalar, XPosCenter, BoxW, BoxX, BoxH;
2021-06-07 01:30:04 +00:00
local int i, j, NumSpec, NumPlayer, NumAlivePlayer, Width, Edge;
local float BorderSize;
PC = GetPlayer();
2021-06-13 02:53:33 +00:00
if (KFGRI == None)
{
KFGRI = KFGameReplicationInfo(PC.WorldInfo.GRI);
2021-06-13 02:53:33 +00:00
if (KFGRI == None)
return;
}
// Sort player list.
2021-06-13 02:53:33 +00:00
if (NextScoreboardRefresh < PC.WorldInfo.TimeSeconds)
{
NextScoreboardRefresh = PC.WorldInfo.TimeSeconds + 0.1;
2021-06-13 02:53:33 +00:00
for (i=(KFGRI.PRIArray.Length-1); i > 0; --i)
{
2021-06-13 02:53:33 +00:00
for (j=i-1; j >= 0; --j)
{
2021-06-13 02:54:35 +00:00
if (!InOrder(KFPlayerReplicationInfo(KFGRI.PRIArray[i]), KFPlayerReplicationInfo(KFGRI.PRIArray[j])))
{
PRI = KFGRI.PRIArray[i];
KFGRI.PRIArray[i] = KFGRI.PRIArray[j];
KFGRI.PRIArray[j] = PRI;
}
}
}
}
// Check players.
PlayerIndex = -1;
NumPlayer = 0;
2021-06-13 02:53:33 +00:00
for (i=(KFGRI.PRIArray.Length-1); i >= 0; --i)
{
KFPRI = KFPlayerReplicationInfo(KFGRI.PRIArray[i]);
2021-06-13 02:53:33 +00:00
if (KFPRI == None)
continue;
2021-06-13 02:53:33 +00:00
if (KFPRI.bOnlySpectator)
{
++NumSpec;
continue;
}
2021-06-13 02:53:33 +00:00
if (KFPRI.PlayerHealth > 0 && KFPRI.PlayerHealthPercent > 0 && KFPRI.GetTeamNum() == 0)
++NumAlivePlayer;
++NumPlayer;
}
KFPRIArray.Length = NumPlayer;
j = KFPRIArray.Length;
2021-06-13 02:53:33 +00:00
for (i=(KFGRI.PRIArray.Length-1); i >= 0; --i)
{
KFPRI = KFPlayerReplicationInfo(KFGRI.PRIArray[i]);
2021-06-13 02:53:33 +00:00
if (KFPRI != None && !KFPRI.bOnlySpectator)
{
KFPRIArray[--j] = KFPRI;
2021-06-13 02:53:33 +00:00
if (KFPRI == PC.PlayerReplicationInfo)
PlayerIndex = j;
}
}
Canvas.Font = Owner.CurrentStyle.PickFont(FontScalar);
2021-06-07 01:30:04 +00:00
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
BorderSize = Owner.HUDOwner.ScaledBorderSize;
Edge = 8;
// Server Info
XPosCenter = Canvas.ClipX * 0.5;
Width = Canvas.ClipX * 0.4; // Full Box Width
XPos = XPosCenter - Width * 0.5;
YPos = YL;
BoxW = Width;
BoxX = XPos;
BoxH = YL + BorderSize;
// Top Rect (Server name)
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.ServerNameBoxColor);
2021-06-07 01:30:04 +00:00
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Edge, 2);
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.ServerNameTextColor);
S = KFGRI.ServerName;
2021-06-07 01:30:04 +00:00
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar);
2021-06-07 01:30:04 +00:00
YPos += BoxH;
// Mid Left Rect (Info)
BoxW = Width * 0.7;
BoxH = YL * 2 + BorderSize * 2;
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.GameInfoBoxColor);
2021-06-07 01:30:04 +00:00
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Edge, 1);
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.GameInfoTextColor);
2021-06-07 01:30:04 +00:00
S = class'KFCommon_LocalizedStrings'.static.GetFriendlyMapName(PC.WorldInfo.GetMapName(true));
DrawTextShadowHLeftVCenter(S, BoxX + Edge, YPos, FontScalar);
2021-06-09 02:47:15 +00:00
S = KFGRI.GameClass.default.GameName $ " - " $ class'KFCommon_LocalizedStrings'.Static.GetDifficultyString(KFGRI.GameDifficulty);
2021-06-07 01:30:04 +00:00
DrawTextShadowHLeftVCenter(S, BoxX + Edge, YPos + YL, FontScalar);
// Mid Right Rect (Wave)
BoxX = BoxX + BoxW;
BoxW = Width - BoxW;
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.WaveBoxColor);
2021-06-07 01:30:04 +00:00
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Edge, 0);
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.WaveTextColor);
2021-06-07 01:30:04 +00:00
S = class'KFGFxHUD_ScoreboardMapInfoContainer'.default.WaveString;
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar);
DrawTextShadowHVCenter(WaveText(), BoxX, YPos + YL, BoxW, FontScalar);
YPos += BoxH;
// Bottom Rect (Players count)
BoxX = XPos;
BoxW = Width;
BoxH = YL + BorderSize;
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.PlayerCountBoxColor);
2021-06-07 01:30:04 +00:00
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Edge, 4);
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.PlayerCountTextColor);
2021-06-07 02:38:10 +00:00
S = "Players: " $ NumPlayer $ " / " $ KFGRI.MaxHumanCount $ " " $ "Spectators: " $ NumSpec;
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
2021-06-07 01:30:04 +00:00
DrawTextShadowHLeftVCenter(S, BoxX + Edge, YPos, FontScalar);
S = Owner.CurrentStyle.GetTimeString(KFGRI.ElapsedTime);
DrawTextShadowHVCenter(S, XPos + Width * 0.7, YPos, Width * 0.3, FontScalar);
// TODO: ranked / unranked
//if (KFGameInfo(PC.WorldInfo.Game).IsUnrankedGame())
// S = class'KFGFxMenu_ServerBrowser'.default.UnrankedString;
//else
// S = class'KFGFxMenu_ServerBrowser'.default.RankedString;
//DrawTextShadowHVCenter(S, XPos + XL, YPos, Width * 0.7 + XL, FontScalar);
YPos += BoxH;
2021-06-07 01:30:04 +00:00
// Header
2021-06-13 02:29:47 +00:00
Width = Canvas.ClipX * 0.7;
XPos = (Canvas.ClipX - Width) * 0.5;
2021-06-07 01:30:04 +00:00
YPos += YL;
BoxH = YL + BorderSize;
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.ListHeaderBoxColor);
2021-06-13 03:00:19 +00:00
Owner.CurrentStyle.DrawRectBox( XPos - BorderSize * 2,
2021-06-06 21:22:24 +00:00
YPos,
2021-06-07 01:30:04 +00:00
Width + BorderSize * 4,
2021-06-06 21:22:24 +00:00
BoxH,
2021-06-07 01:30:04 +00:00
Edge,
2);
// Calc X offsets
2021-06-07 01:30:04 +00:00
RankXPos = Owner.HUDOwner.ScaledBorderSize * 8 + Edge;
PlayerXPos = Width * 0.20;
PerkXPos = Width * 0.40;
CashXPos = Width * 0.57;
KillsXPos = Width * 0.66;
AssistXPos = Width * 0.75;
HealthXPos = Width * 0.84;
PingXPos = Width * 0.93;
2021-06-06 21:22:24 +00:00
StatusWBox = PlayerXPos - RankXPos;
PlayerWBox = PerkXPos - PlayerXPos;
PerkWBox = CashXPos - PerkXPos;
CashWBox = KillsXPos - CashXPos;
KillsWBox = AssistXPos - KillsXPos;
AssistWBox = HealthXPos - AssistXPos;
HealthWBox = PingXPos - HealthXPos;
PingWBox = Width - PingXPos;
// Header texts
2021-06-09 00:58:31 +00:00
SetDrawColor(Canvas, Settings.Style.ListHeaderTextColor);
2021-06-06 21:22:24 +00:00
DrawTextShadowHLeftVCenter("RANK", XPos + RankXPos, YPos, FontScalar);
2021-05-25 00:45:49 +00:00
DrawTextShadowHLeftVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PlayerString, XPos + PlayerXPos, YPos, FontScalar);
DrawTextShadowHLeftVCenter(class'KFGFxMenu_Inventory'.default.PerkFilterString, XPos + PerkXPos, YPos, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.KillsString, XPos + KillsXPos, YPos, KillsWBox, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.AssistsString, XPos + AssistXPos, YPos, AssistWBox, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.DoshString, XPos + CashXPos, YPos, CashWBox, FontScalar);
2021-06-09 02:47:15 +00:00
DrawTextShadowHVCenter("STATE", XPos + HealthXPos, YPos, HealthWBox, FontScalar);
2021-05-25 00:45:49 +00:00
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, FontScalar);
PlayersList.XPosition = ((Canvas.ClipX - Width) * 0.5) / InputPos[2];
2021-06-07 01:30:04 +00:00
PlayersList.YPosition = (YPos + YL + BorderSize * 4) / InputPos[3];
PlayersList.YSize = (1.f - PlayersList.YPosition) - 0.15;
PlayersList.ChangeListSize(KFPRIArray.Length);
}
2021-05-25 00:45:49 +00:00
function DrawTextShadowHVCenter(string Str, float XPos, float YPos, float BoxWidth, float FontScalar)
{
local float TextWidth;
local float TextHeight;
Canvas.TextSize(Str, TextWidth, TextHeight, FontScalar, FontScalar);
2021-05-16 20:29:34 +00:00
Owner.CurrentStyle.DrawTextShadow(Str, XPos + (BoxWidth - TextWidth)/2 , YPos, 1, FontScalar);
}
2021-05-25 00:45:49 +00:00
function DrawTextShadowHLeftVCenter(string Str, float XPos, float YPos, float FontScalar)
{
2021-05-16 20:28:37 +00:00
Owner.CurrentStyle.DrawTextShadow(Str, XPos, YPos, 1, FontScalar);
2020-01-10 13:14:11 +00:00
}
2021-06-07 01:30:04 +00:00
function DrawTextShadowHRightVCenter(string Str, float XPos, float YPos, float BoxWidth, float FontScalar)
{
local float TextWidth;
local float TextHeight;
Canvas.TextSize(Str, TextWidth, TextHeight, FontScalar, FontScalar);
Owner.CurrentStyle.DrawTextShadow(Str, XPos + BoxWidth - TextWidth, YPos, 1, FontScalar);
}
2021-06-08 23:43:00 +00:00
function SetDrawColor(Canvas C, ColorRGBA RGBA)
2021-06-08 23:22:35 +00:00
{
2021-06-08 23:43:00 +00:00
C.SetDrawColor(RGBA.R, RGBA.G, RGBA.B, RGBA.A);
2021-06-08 23:22:35 +00:00
}
2021-06-13 03:00:19 +00:00
function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus)
2020-01-10 13:14:11 +00:00
{
local string S, StrValue;
local float FontScalar, TextYOffset, XL, YL, PerkIconPosX, PerkIconPosY, PerkIconSize, PrestigeIconScale;
2021-06-06 21:22:24 +00:00
local float XPos, BoxWidth;
local KFPlayerReplicationInfo KFPRI;
local byte Level, PrestigeLevel;
local bool bIsZED;
local int Ping;
2021-05-31 01:46:53 +00:00
2021-06-08 21:21:28 +00:00
local RankInfo CurrentRank;
local bool HasRank;
local int PlayerInfoIndex, PlayerRankIndex;
YOffset *= 1.05;
KFPRI = KFPRIArray[Index];
2021-05-31 01:46:53 +00:00
2021-06-08 21:21:28 +00:00
HasRank = false;
2021-06-13 01:57:20 +00:00
2021-06-12 18:44:20 +00:00
PlayerInfoIndex = RankRelations.Find('UID', KFPRI.UniqueId);
2021-06-13 01:57:20 +00:00
if (PlayerInfoIndex != INDEX_NONE && RankRelations[PlayerInfoIndex].RankID != INDEX_NONE)
2021-05-31 01:46:53 +00:00
{
2021-06-12 18:44:20 +00:00
PlayerRankIndex = CustomRanks.Find('ID', RankRelations[PlayerInfoIndex].RankID);
2021-06-08 21:21:28 +00:00
if (PlayerRankIndex != INDEX_NONE)
2021-05-31 01:46:53 +00:00
{
2021-06-08 21:21:28 +00:00
HasRank = true;
2021-06-08 21:48:03 +00:00
CurrentRank = CustomRanks[PlayerRankIndex];
2021-05-31 01:46:53 +00:00
}
}
if (KFPRI.bAdmin)
{
2021-06-08 21:21:28 +00:00
if (!HasRank || (HasRank && !CurrentRank.OverrideAdminRank))
2021-05-31 01:46:53 +00:00
{
2021-06-09 00:58:31 +00:00
CurrentRank.Rank = Settings.Admin.Rank;
CurrentRank.TextColor = Settings.Admin.TextColor;
CurrentRank.ApplyColorToFields = Settings.Admin.ApplyColorToFields;
2021-06-08 21:21:28 +00:00
HasRank = true;
2021-05-31 01:46:53 +00:00
}
}
else // Player
{
2021-06-08 21:21:28 +00:00
if (!HasRank)
2021-05-31 01:46:53 +00:00
{
2021-06-09 00:58:31 +00:00
CurrentRank.Rank = Settings.Player.Rank;
CurrentRank.TextColor = Settings.Player.TextColor;
CurrentRank.ApplyColorToFields = Settings.Player.ApplyColorToFields;
2021-06-08 21:21:28 +00:00
HasRank = true;
2021-05-31 01:46:53 +00:00
}
}
2021-06-08 21:21:28 +00:00
// Now all players belongs to 'Rank'
2021-06-13 02:53:33 +00:00
if (KFGRI.bVersusGame)
bIsZED = KFTeamInfo_Zeds(KFPRI.Team) != None;
2021-06-06 21:22:24 +00:00
XPos = 0.f;
C.Font = Owner.CurrentStyle.PickFont(FontScalar);
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
2021-06-07 01:30:04 +00:00
// change rect color by HP
2021-06-13 02:53:33 +00:00
if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun)
2021-06-07 01:30:04 +00:00
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
2021-06-07 01:30:04 +00:00
}
2021-06-13 02:53:33 +00:00
else if (!KFGRI.bMatchHasBegun)
2021-06-07 01:30:04 +00:00
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
2021-06-07 01:30:04 +00:00
}
2021-06-13 02:53:33 +00:00
else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None)
2021-06-07 01:30:04 +00:00
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
2021-06-07 01:30:04 +00:00
}
else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0)
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.LeftStateBoxColorDead);
2021-06-07 01:30:04 +00:00
}
else
{
2021-06-09 02:47:15 +00:00
if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.High) / 100.0)
SetDrawColor(C, Settings.Style.LeftStateBoxColorHigh);
else if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.Low) / 100.0)
SetDrawColor(C, Settings.Style.LeftStateBoxColorMid);
2021-06-07 01:30:04 +00:00
else
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.LeftStateBoxColorLow);
2021-06-07 01:30:04 +00:00
}
2021-06-09 02:47:15 +00:00
if (!Settings.State.Dynamic)
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
2021-06-06 21:22:24 +00:00
BoxWidth = Owner.HUDOwner.ScaledBorderSize * 8;
2021-06-13 03:00:19 +00:00
Owner.CurrentStyle.DrawRectBox( XPos,
2021-06-06 21:22:24 +00:00
YOffset,
BoxWidth,
Height,
8, 1);
XPos += BoxWidth;
TextYOffset = YOffset + (Height * 0.5f) - (YL * 0.5f);
if (PlayerIndex == Index)
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.PlayerOwnerBoxColor);
2021-06-06 21:22:24 +00:00
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.PlayerBoxColor);
2021-06-06 21:22:24 +00:00
BoxWidth = CashXPos + Owner.HUDOwner.ScaledBorderSize - BoxWidth;
Owner.CurrentStyle.DrawRectBox(XPos, YOffset, BoxWidth, Height, 8);
XPos += BoxWidth;
// Right stats box
BoxWidth = Width - XPos;
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StatsBoxColor);
2021-06-13 03:00:19 +00:00
Owner.CurrentStyle.DrawRectBox( XPos,
2021-06-06 21:22:24 +00:00
YOffset,
BoxWidth,
Height,
8, 3);
2021-05-31 01:46:53 +00:00
// Rank
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Rank)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.RankTextColor);
2021-06-08 21:21:28 +00:00
S = CurrentRank.Rank;
2021-06-06 21:22:24 +00:00
DrawTextShadowHLeftVCenter(S, RankXPos, TextYOffset, FontScalar);
// Perk
2021-06-13 02:53:33 +00:00
if (bIsZED)
{
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Perk)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.ZedTextColor);
C.SetPos (PerkXPos, YOffset - ((Height-5) * 0.5f));
C.DrawRect (Height-5, Height-5, Texture2D'UI_Widgets.MenuBarWidget_SWF_IF');
S = "ZED";
2021-05-25 00:45:49 +00:00
DrawTextShadowHLeftVCenter(S, PerkXPos + Height, TextYOffset, FontScalar);
}
else
{
2021-06-13 02:53:33 +00:00
if (KFPRI.CurrentPerkClass != None)
{
2020-01-10 13:14:11 +00:00
PrestigeLevel = KFPRI.GetActivePerkPrestigeLevel();
Level = KFPRI.GetActivePerkLevel();
2020-01-10 13:14:11 +00:00
PerkIconPosY = YOffset + (Owner.HUDOwner.ScaledBorderSize * 2);
PerkIconSize = Height-(Owner.HUDOwner.ScaledBorderSize * 4);
PerkIconPosX = PerkXPos - PerkIconSize - (Owner.HUDOwner.ScaledBorderSize*2);
2020-01-10 13:14:11 +00:00
PrestigeIconScale = 0.6625f;
C.DrawColor = HUDOwner.WhiteColor;
2020-01-10 13:14:11 +00:00
if (PrestigeLevel > 0)
{
C.SetPos(PerkIconPosX, PerkIconPosY);
C.DrawTile(KFPRI.CurrentPerkClass.default.PrestigeIcons[PrestigeLevel - 1], PerkIconSize, PerkIconSize, 0, 0, 256, 256);
2020-01-10 13:14:11 +00:00
C.SetPos(PerkIconPosX + ((PerkIconSize/2) - ((PerkIconSize*PrestigeIconScale)/2)), PerkIconPosY + ((PerkIconSize/2) - ((PerkIconSize*PrestigeIconScale)/1.75)));
C.DrawTile(KFPRI.CurrentPerkClass.default.PerkIcon, PerkIconSize * PrestigeIconScale, PerkIconSize * PrestigeIconScale, 0, 0, 256, 256);
}
else
{
C.SetPos(PerkIconPosX, PerkIconPosY);
C.DrawTile(KFPRI.CurrentPerkClass.default.PerkIcon, PerkIconSize, PerkIconSize, 0, 0, 256, 256);
2021-06-07 01:30:04 +00:00
}
2021-06-09 02:47:15 +00:00
if (CurrentRank.ApplyColorToFields.Level)
SetDrawColor(C, CurrentRank.TextColor);
else if (!Settings.Level.Dynamic)
SetDrawColor(C, Settings.Style.LevelTextColor);
else
{
if (Level < Settings.Level.Low[KFGRI.GameDifficulty])
SetDrawColor(C, Settings.Style.LevelTextColorLow);
else if (Level < Settings.Level.High[KFGRI.GameDifficulty])
SetDrawColor(C, Settings.Style.LevelTextColorMid);
else
SetDrawColor(C, Settings.Style.LevelTextColorHigh);
}
S = String(Level);
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar);
if (Len(S) == 1)
Canvas.TextSize(S@" ", XL, YL, FontScalar, FontScalar);
else
Canvas.TextSize(S$" ", XL, YL, FontScalar, FontScalar);
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Perk)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.PerkTextColor);
S = KFPRI.CurrentPerkClass.default.PerkName;
DrawTextShadowHLeftVCenter(S, PerkXPos+XL, TextYOffset, FontScalar);
}
else
{
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Perk)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.PerkTextColor);
S = "No Perk";
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar);
}
}
// Avatar
2021-06-13 02:53:33 +00:00
if (KFPRI.Avatar != None)
{
2021-06-13 02:53:33 +00:00
if (KFPRI.Avatar == default.DefaultAvatar)
CheckAvatar(KFPRI, OwnerPC);
2021-06-13 02:54:35 +00:00
C.SetDrawColor(255, 255, 255, 255);
C.SetPos(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f));
2021-06-13 02:54:35 +00:00
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);
}
2021-06-13 02:53:33 +00:00
else if (!KFPRI.bBot)
CheckAvatar(KFPRI, OwnerPC);
// Player
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Player)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.PlayerNameTextColor);
2021-06-09 02:47:15 +00:00
S = KFPRI.PlayerName;
2021-05-25 00:45:49 +00:00
DrawTextShadowHLeftVCenter(S, PlayerXPos, TextYOffset, FontScalar);
// Kill
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Kills)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.KillsTextColor);
2021-05-25 00:45:49 +00:00
DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, TextYOffset, KillsWBox, FontScalar);
// Assist
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Assists)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.AssistsTextColor);
2021-05-25 00:45:49 +00:00
DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, TextYOffset, AssistWBox, FontScalar);
2021-06-08 23:22:35 +00:00
// Cash
2021-06-13 02:53:33 +00:00
if (bIsZED)
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.ZedTextColor);
StrValue = "Brains!";
}
else
{
2021-06-08 23:22:35 +00:00
if (CurrentRank.ApplyColorToFields.Dosh)
SetDrawColor(C, CurrentRank.TextColor);
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.DoshTextColor);
StrValue = GetNiceSize(int(KFPRI.Score));
}
2021-05-25 00:45:49 +00:00
DrawTextShadowHVCenter(StrValue, CashXPos, TextYOffset, CashWBox, FontScalar);
2021-06-08 23:22:35 +00:00
// State
2021-06-13 02:53:33 +00:00
if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun)
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorLobby);
S = "LOBBY";
}
2021-06-13 02:53:33 +00:00
else if (!KFGRI.bMatchHasBegun)
{
2021-06-08 23:22:35 +00:00
if (KFPRI.bReadyToPlay)
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorReady);
2021-06-08 23:22:35 +00:00
S = "Ready";
}
else
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorNotReady);
2021-06-08 23:22:35 +00:00
S = "Not Ready";
}
}
2021-06-13 02:53:33 +00:00
else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None)
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.StateTextColor);
S = "Unknown";
}
else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0)
{
2021-06-08 23:22:35 +00:00
if (KFPRI.bOnlySpectator)
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorSpectator);
2021-06-08 23:22:35 +00:00
S = "Spectator";
}
else
{
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorDead);
2021-06-08 23:22:35 +00:00
S = "DEAD";
}
}
else
{
2021-06-09 02:47:15 +00:00
if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.High) / 100.0)
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorHighHP);
2021-06-09 02:47:15 +00:00
else if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.Low) / 100.0)
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorMidHP);
2021-06-07 01:30:04 +00:00
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.StateTextColorLowHP);
2021-06-13 02:29:47 +00:00
S = string(KFPRI.PlayerHealth)@"HP";
}
2021-06-07 01:30:04 +00:00
2021-06-08 21:21:28 +00:00
if (CurrentRank.ApplyColorToFields.Health)
2021-06-08 23:22:35 +00:00
SetDrawColor(C, CurrentRank.TextColor);
2021-06-09 02:47:15 +00:00
else if (!Settings.State.Dynamic)
SetDrawColor(C, Settings.Style.StateTextColor);
2021-05-25 00:45:49 +00:00
DrawTextShadowHVCenter(S, HealthXPos, TextYOffset, HealthWBox, FontScalar);
// Ping
if (KFPRI.bBot)
2021-06-08 23:22:35 +00:00
{
2021-06-09 02:47:15 +00:00
SetDrawColor(C, Settings.Style.PingTextColor);
S = "-";
2021-06-08 23:22:35 +00:00
}
else
{
Ping = int(KFPRI.Ping * `PING_SCALE);
2021-06-08 23:22:35 +00:00
if (CurrentRank.ApplyColorToFields.Ping)
SetDrawColor(C, CurrentRank.TextColor);
2021-06-09 00:58:31 +00:00
else if (Ping <= Settings.Ping.Low)
SetDrawColor(C, Settings.Style.PingTextColorLow);
else if (Ping <= Settings.Ping.High)
SetDrawColor(C, Settings.Style.PingTextColorMid);
2021-06-08 23:22:35 +00:00
else
2021-06-09 00:58:31 +00:00
SetDrawColor(C, Settings.Style.PingTextColorHigh);
S = string(Ping);
}
2021-06-13 02:29:47 +00:00
C.TextSize(S, XL, YL, FontScalar, FontScalar);
2021-06-09 02:47:15 +00:00
DrawTextShadowHVCenter(S, PingXPos, TextYOffset, Settings.Ping.ShowPingBars ? PingWBox/2 : PingWBox, FontScalar);
2021-06-13 02:54:35 +00:00
C.SetDrawColor(250, 250, 250, 255);
2021-06-09 02:47:15 +00:00
if (Settings.Ping.ShowPingBars)
DrawPingBars(C, YOffset + (Height/2) - ((Height*0.5)/2), Width - (Height*0.5) - (Owner.HUDOwner.ScaledBorderSize*2), Height*0.5, Height*0.5, float(Ping));
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
final function DrawPingBars(Canvas C, float YOffset, float XOffset, float W, float H, float Ping)
2020-01-10 13:14:11 +00:00
{
local float PingMul, BarW, BarH, BaseH, XPos, YPos;
local byte i;
2021-06-09 00:58:31 +00:00
PingMul = 1.f - FClamp(FMax(Ping - Settings.Ping.Low, 1.f) / Settings.Ping.High, 0.f, 1.f);
BarW = W / PingBars;
BaseH = H / PingBars;
PingColor.R = (1.f - PingMul) * 255;
PingColor.G = PingMul * 255;
2021-06-13 02:53:33 +00:00
for (i=1; i < PingBars; i++)
{
BarH = BaseH * i;
XPos = XOffset + ((i - 1) * BarW);
YPos = YOffset + (H - BarH);
2021-06-13 02:54:35 +00:00
C.SetPos(XPos, YPos);
C.SetDrawColor(20, 20, 20, 255);
2021-06-13 02:54:35 +00:00
Owner.CurrentStyle.DrawWhiteBox(BarW, BarH);
2021-06-13 02:53:33 +00:00
if (PingMul >= (i / PingBars))
{
2021-06-13 02:54:35 +00:00
C.SetPos(XPos, YPos);
C.DrawColor = PingColor;
2021-06-13 02:54:35 +00:00
Owner.CurrentStyle.DrawWhiteBox(BarW, BarH);
}
C.SetDrawColor(80, 80, 80, 255);
2021-06-13 02:54:35 +00:00
Owner.CurrentStyle.DrawBoxHollow(XPos, YPos, BarW, BarH, 1);
}
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
static final function Texture2D FindAvatar(KFPlayerController PC, UniqueNetId ClientID)
2020-01-10 13:14:11 +00:00
{
local string S;
S = PC.GetSteamAvatar(ClientID);
2021-06-13 02:53:33 +00:00
if (S == "")
return None;
2021-06-13 02:54:35 +00:00
return Texture2D(PC.FindObject(S, class'Texture2D'));
2020-01-10 13:14:11 +00:00
}
final static function string GetNiceSize(int Num)
{
2021-06-13 02:53:33 +00:00
if (Num < 1000 ) return string(Num);
else if (Num < 1000000 ) return (Num / 1000) $ "K";
else if (Num < 1000000000 ) return (Num / 1000000) $ "M";
2020-01-10 13:14:11 +00:00
return (Num / 1000000000) $ "B";
2020-01-10 13:14:11 +00:00
}
2021-06-13 03:00:19 +00:00
function ScrollMouseWheel(bool bUp)
2020-01-10 13:14:11 +00:00
{
PlayersList.ScrollMouseWheel(bUp);
2020-01-10 13:14:11 +00:00
}
defaultproperties
{
bEnableInputs=true
2021-06-13 02:54:35 +00:00
PingColor=(R=255, G=255, B=60, A=255)
PingBars=5.0
Begin Object Class=KFGUI_List Name=PlayerList
2021-06-13 02:29:47 +00:00
XSize=0.7
OnDrawItem=DrawPlayerEntry
ID="PlayerList"
bClickable=false
ListItemsPerPage=16
End Object
Components.Add(PlayerList)
DefaultAvatar=Texture2D'UI_HUD.ScoreBoard_Standard_SWF_I26'
2020-01-10 13:14:11 +00:00
}