This commit is contained in:
GenZmeY 2022-09-08 16:32:28 +03:00
parent cf6b9cf6c8
commit 40d8ce4f71
4 changed files with 219 additions and 168 deletions

View File

@ -1354,6 +1354,14 @@ final function DrawArrowBox(int Direction, float X, float Y, float Width, float
DrawTileStretched(DirectionMat, X,Y, Width, Height); DrawTileStretched(DirectionMat, X,Y, Width, Height);
} }
function DrawTexture(Texture2D Tex, float X, float Y, float W, float H, Color TexColor)
{
Canvas.SetPos(X, Y);
Canvas.SetDrawColorStruct(TexColor);
Canvas.DrawTile(Tex, W, H, 0, 0, Tex.SizeX, Tex.SizeY);
}
final function DrawTileStretched(Texture Tex, float X, float Y, float XS, float YS) final function DrawTileStretched(Texture Tex, float X, float Y, float XS, float YS)
{ {
local float mW, mH, MidX, MidY, SmallTileW, SmallTileH, fX, fY; local float mW, mH, MidX, MidY, SmallTileW, SmallTileH, fX, fY;

View File

@ -6,13 +6,14 @@ const LatestVersion = 1;
const CfgRanks = class'Ranks'; const CfgRanks = class'Ranks';
const CfgRankRelations = class'RankRelations'; const CfgRankRelations = class'RankRelations';
const UpdateInterval = 1.0f;
const MatchUID = "0x"; const MatchUID = "0x";
const MatchPlayerSteamID64 = "76561"; const MatchPlayerSteamID64 = "76561";
const MatchGroupSteamID64 = "10358279"; 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;
@ -22,7 +23,7 @@ var private KFOnlineGameSettings KFOGS;
var private OnlineSubsystemSteamworks OSS; var private OnlineSubsystemSteamworks OSS;
var private Array<YAS_OwnerRepInfo> RepInfos; var private Array<YAS_RepInfo> RepInfos;
var private Array<CachedRankRelation> PlayerRelations; var private Array<CachedRankRelation> PlayerRelations;
var private Array<CachedRankRelation> GroupRelations; var private Array<CachedRankRelation> GroupRelations;
@ -68,7 +69,6 @@ private function PreInit()
if (Version == `NO_CONFIG) if (Version == `NO_CONFIG)
{ {
LogLevel = LL_Info; LogLevel = LL_Info;
UpdateInterval = 1;
SaveConfig(); SaveConfig();
} }
@ -123,73 +123,19 @@ private function PreInit()
private function InitRanks() // TODO: Ref private function InitRanks() // TODO: Ref
{ {
local Array<RankRelation> Relations; local Array<RankRelation> Relations;
local Array<Rank> Ranks;
local RankRelation Relation; local RankRelation Relation;
local Rank Rank;
local CachedRankRelation CachedRankRelation;
Ranks = CfgRanks.default.Ranks;
Relations = CfgRankRelations.default.Relations; Relations = CfgRankRelations.default.Relations;
foreach Relations(Relation) foreach Relations(Relation)
{ {
if (IsUID(Relation.ObjectID) || IsPlayerSteamID64(Relation.ObjectID)) if (IsUID(Relation.ObjectID) || IsPlayerSteamID64(Relation.ObjectID))
{ {
if (AnyToUID(Relation.ObjectID, CachedRankRelation.UID)) AddRelation(Relation, PlayerRelations);
{
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)) else if (IsGroupSteamID64(Relation.ObjectID))
{ {
if (AnyToUID(Relation.ObjectID, CachedRankRelation.UID)) AddRelation(Relation, GroupRelations);
{
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 else
{ {
@ -198,6 +144,41 @@ private function InitRanks() // TODO: Ref
} }
} }
private function AddRelation(RankRelation Relation, out Array<CachedRankRelation> OutArray)
{
local CachedRankRelation CachedRankRelation;
local Array<Rank> Ranks;
local Rank Rank;
if (AnyToUID(Relation.ObjectID, CachedRankRelation.UID))
{
CachedRankRelation.RawID = Relation.ObjectID;
Ranks = CfgRanks.default.Ranks;
foreach Ranks(Rank)
{
if (Rank.RankID == Relation.RankID)
{
CachedRankRelation.Rank = Rank;
break;
}
}
if (CachedRankRelation.Rank.RankID > 0)
{
OutArray.AddItem(CachedRankRelation);
}
else
{
`Log_Warn("Rank with ID" @ Relation.RankID @ "not found");
}
}
else
{
`Log_Warn("Can't convert to UniqueNetID:" @ Relation.ObjectID);
}
}
private static function bool IsUID(String ID) private static function bool IsUID(String ID)
{ {
return (Left(ID, Len(MatchUID)) ~= MatchUID); return (Left(ID, Len(MatchUID)) ~= MatchUID);
@ -277,12 +258,20 @@ private function PostInit()
private function UpdateTimer() private function UpdateTimer()
{ {
// TODO: Server params monitor local YAS_RepInfo RepInfo;
foreach RepInfos(RepInfo)
{
RepInfo.DynamicServerName = KFOGS.OwningPlayerName;
RepInfo.UsesStats = KFOGS.bUsesStats;
RepInfo.Custom = KFOGS.bCustom;
RepInfo.PasswordRequired = KFOGS.bRequiresPassword;
}
} }
public function NotifyLogin(Controller C) public function NotifyLogin(Controller C)
{ {
local YAS_OwnerRepInfo RepInfo; local YAS_RepInfo RepInfo;
`Log_Trace(); `Log_Trace();
@ -298,7 +287,7 @@ public function NotifyLogin(Controller C)
public function NotifyLogout(Controller C) public function NotifyLogout(Controller C)
{ {
local YAS_OwnerRepInfo RepInfo; local YAS_RepInfo RepInfo;
`Log_Trace(); `Log_Trace();
@ -310,14 +299,14 @@ public function NotifyLogout(Controller C)
} }
} }
public function YAS_OwnerRepInfo CreateRepInfo(Controller C) public function YAS_RepInfo CreateRepInfo(Controller C)
{ {
local YAS_OwnerRepInfo OwnerRepInfo; local YAS_RepInfo OwnerRepInfo;
local YAS_RankRepInfo RankRepInfo; local YAS_RankRepInfo RankRepInfo;
`Log_Trace(); `Log_Trace();
OwnerRepInfo = Spawn(class'YAS_OwnerRepInfo', C); OwnerRepInfo = Spawn(class'YAS_RepInfo', C);
RankRepInfo = Spawn(class'YAS_RankRepInfo', C); RankRepInfo = Spawn(class'YAS_RankRepInfo', C);
if (OwnerRepInfo != None && RankRepInfo != None) if (OwnerRepInfo != None && RankRepInfo != None)
@ -334,9 +323,9 @@ public function YAS_OwnerRepInfo CreateRepInfo(Controller C)
return OwnerRepInfo; return OwnerRepInfo;
} }
private function YAS_OwnerRepInfo FindRepInfo(Controller C) private function YAS_RepInfo FindRepInfo(Controller C)
{ {
local YAS_OwnerRepInfo RepInfo; local YAS_RepInfo RepInfo;
if (C == None) return None; if (C == None) return None;
@ -351,7 +340,7 @@ private function YAS_OwnerRepInfo FindRepInfo(Controller C)
return None; return None;
} }
public function bool DestroyRepInfo(YAS_OwnerRepInfo RepInfo) public function bool DestroyRepInfo(YAS_RepInfo RepInfo)
{ {
`Log_Trace(); `Log_Trace();
@ -364,7 +353,7 @@ public function bool DestroyRepInfo(YAS_OwnerRepInfo RepInfo)
return true; return true;
} }
private function InitRank(YAS_OwnerRepInfo RepInfo) private function InitRank(YAS_RepInfo RepInfo)
{ {
local CachedRankRelation Rel; local CachedRankRelation Rel;
local String JoinedGroupIDs; local String JoinedGroupIDs;

View File

@ -1,4 +1,4 @@
class YAS_OwnerRepInfo extends ReplicationInfo; class YAS_RepInfo extends ReplicationInfo;
var public YAS YAS; var public YAS YAS;
@ -39,6 +39,8 @@ public simulated event ReplicatedEvent(name VarName)
{ {
`Log_Trace(); `Log_Trace();
`Log_Base("ReplicatedEvent:" @ VarName);
switch (VarName) switch (VarName)
{ {
case 'LogLevel': case 'LogLevel':

View File

@ -4,6 +4,18 @@ class YAS_ScoreBoard extends KFGUI_Page
const HeaderWidthRatio = 0.30f; const HeaderWidthRatio = 0.30f;
const PlayerListWidthRatio = 0.6f; const PlayerListWidthRatio = 0.6f;
/*
const IconRanked = Texture2D'YAS.IconRanked';
const IconCustom = Texture2D'UI_Menus.ServerBrowserMenu_SWF_I26';
const IconUnranked = Texture2D'UI_Menus.ServerBrowserMenu_SWF_I28';
const IconPassword = Texture2D'UI_Menus.ServerBrowserMenu_SWF_I20';
const IconDosh = Texture2D'UI_HUD.InGameHUD_SWF_I13A';
const IconPlayer = Texture2D'UI_HUD.InGameHUD_ZED_SWF_I1F5';
const IconClock = Texture2D'UI_HUD.InGameHUD_SWF_I17D';
const IconSkull = Texture2D'UI_Shared.AssetLib_I32';
const IconHealth = Texture2D'UI_VoiceComms_TEX.UI_VoiceCommand_Icon_Heal';
*/
var public E_LogLevel LogLevel; 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;
@ -23,8 +35,7 @@ var KFPlayerController OwnerPC;
var Color PingColor; var Color PingColor;
var float PingBars; var float PingBars;
var localized String Players; var localized String Players, Spectators;
var localized String Spectators;
// Cache // Cache
var public Array<YAS_RankRepInfo> RepInfos; var public Array<YAS_RankRepInfo> RepInfos;
@ -274,22 +285,36 @@ function DrawMenu()
Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor); Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor);
S = (DynamicServerName == "" ? KFGRI.ServerName : DynamicServerName); S = (DynamicServerName == "" ? KFGRI.ServerName : DynamicServerName);
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar); DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, BoxH, FontScalar);
// icons
/*
IconIndent = BoxH * 0.1;
if (PasswordRequired)
{
Owner.CurrentStyle.DrawTexture(IconPassword,
BoxX + IconIndent,
YPos + IconIndent,
BoxH - IconIndent*2,
BoxH - IconIndent*2,
MakeColor(250,250,250,250));
}
*/
YPos += BoxH; YPos += BoxH;
// Mid Left Rect (Info) // Mid Left Rect (Info)
BoxW = Width * 0.7; // TODO ? BoxW = Width * 0.7;
BoxH = YL * 2 + BorderSize * 2; BoxH = YL * 2 + BorderSize * 2;
Canvas.SetDrawColorStruct(Settings.Style.GameInfoBoxColor); Canvas.SetDrawColorStruct(Settings.Style.GameInfoBoxColor);
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeGameInfoBox); Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeGameInfoBox);
Canvas.SetDrawColorStruct(Settings.Style.GameInfoTextColor); Canvas.SetDrawColorStruct(Settings.Style.GameInfoTextColor);
S = class'KFCommon_LocalizedStrings'.static.GetFriendlyMapName(PC.WorldInfo.GetMapName(true)); S = class'KFCommon_LocalizedStrings'.static.GetFriendlyMapName(PC.WorldInfo.GetMapName(true));
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar); DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, BoxH/2, FontScalar);
S = KFGRI.GameClass.default.GameName $ " - " $ class'KFCommon_LocalizedStrings'.Static.GetDifficultyString(KFGRI.GameDifficulty); S = KFGRI.GameClass.default.GameName $ " - " $ class'KFCommon_LocalizedStrings'.Static.GetDifficultyString(KFGRI.GameDifficulty);
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos + YL, FontScalar); DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos + BoxH/2, BoxH/2, FontScalar);
// Mid Right Rect (Wave) // Mid Right Rect (Wave)
BoxX = BoxX + BoxW; BoxX = BoxX + BoxW;
@ -299,8 +324,8 @@ function DrawMenu()
Canvas.SetDrawColorStruct(Settings.Style.WaveTextColor); Canvas.SetDrawColorStruct(Settings.Style.WaveTextColor);
S = class'KFGFxHUD_ScoreboardMapInfoContainer'.default.WaveString; S = class'KFGFxHUD_ScoreboardMapInfoContainer'.default.WaveString;
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar); DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, BoxH / 2, FontScalar);
DrawTextShadowHVCenter(WaveText(), BoxX, YPos + YL, BoxW, FontScalar); DrawTextShadowHVCenter(WaveText(), BoxX, YPos + BoxH / 2, BoxW, BoxH / 2, FontScalar);
YPos += BoxH; YPos += BoxH;
@ -311,13 +336,22 @@ function DrawMenu()
Canvas.SetDrawColorStruct(Settings.Style.PlayerCountBoxColor); Canvas.SetDrawColorStruct(Settings.Style.PlayerCountBoxColor);
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);
/*
Owner.CurrentStyle.DrawTexture(IconPlayer,
BoxX + Settings.Style.EdgeSize + IconIndent,
YPos + IconIndent,
BoxH - IconIndent*2,
BoxH - IconIndent*2,
MakeColor(250,250,250,250));
*/
Canvas.SetDrawColorStruct(Settings.Style.PlayerCountTextColor); Canvas.SetDrawColorStruct(Settings.Style.PlayerCountTextColor);
S = Players $ ":" @ 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, BoxH, FontScalar);
S = Owner.CurrentStyle.GetTimeString(KFGRI.ElapsedTime); S = Owner.CurrentStyle.GetTimeString(KFGRI.ElapsedTime);
DrawTextShadowHVCenter(S, XPos + Width * 0.7, YPos, Width * 0.3, FontScalar); // TODO: ? DrawTextShadowHVCenter(S, XPos + Width * 0.7, YPos, Width * 0.3, BoxH, FontScalar); // TODO: ?
YPos += BoxH; YPos += BoxH;
@ -376,12 +410,12 @@ function DrawMenu()
// Header texts // Header texts
Canvas.SetDrawColorStruct(Settings.Style.ListHeaderTextColor); Canvas.SetDrawColorStruct(Settings.Style.ListHeaderTextColor);
DrawTextShadowHLeftVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PlayerString, XPos + PlayerXPos, YPos, FontScalar); DrawTextShadowHLeftVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PlayerString, XPos + PlayerXPos, YPos, BoxH, FontScalar);
DrawTextShadowHLeftVCenter(class'KFGFxMenu_Inventory'.default.PerkFilterString, XPos + PerkXPos, YPos, FontScalar); DrawTextShadowHLeftVCenter(class'KFGFxMenu_Inventory'.default.PerkFilterString, XPos + PerkXPos, YPos, BoxH, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.KillsString, XPos + KillsXPos, YPos, KillsWBox, FontScalar); DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.KillsString, XPos + KillsXPos, YPos, KillsWBox, BoxH, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.AssistsString, XPos + AssistXPos, YPos, AssistWBox, FontScalar); DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.AssistsString, XPos + AssistXPos, YPos, AssistWBox, BoxH, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.DoshString, XPos + DoshXPos, YPos, DoshWBox, FontScalar); DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.DoshString, XPos + DoshXPos, YPos, DoshWBox, BoxH, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, FontScalar); DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, BoxH, FontScalar);
ColorTMP = Settings.Style.ListHeaderTextColor; ColorTMP = Settings.Style.ListHeaderTextColor;
ColorTMP.A = 150; ColorTMP.A = 150;
@ -416,35 +450,10 @@ function DrawHealthIcon(float X, float Y, float W, float H)
Owner.CurrentStyle.DrawRectBox(XPos, YPos, Part, Part, 4, 100); Owner.CurrentStyle.DrawRectBox(XPos, YPos, Part, Part, 4, 100);
} }
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);
Owner.CurrentStyle.DrawTextShadow(Str, XPos + (BoxWidth - TextWidth)/2 , YPos, 1, FontScalar);
}
function DrawTextShadowHLeftVCenter(string Str, float XPos, float YPos, float FontScalar)
{
Owner.CurrentStyle.DrawTextShadow(Str, XPos, YPos, 1, FontScalar);
}
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);
}
function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus) function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus)
{ {
local string S, StrValue; local string S, StrValue;
local float FontScalar, TextYOffset, XL, YL, PerkIconPosX, PerkIconPosY, PerkIconSize, PrestigeIconScale; local float FontScalar, XL, YL, PerkIconPosX, PerkIconPosY, PerkIconSize, PrestigeIconScale;
local float XPos, BoxWidth, RealPlayerWBox; local float XPos, BoxWidth, RealPlayerWBox;
local KFPlayerReplicationInfo KFPRI; local KFPlayerReplicationInfo KFPRI;
local byte Level, PrestigeLevel; local byte Level, PrestigeLevel;
@ -456,7 +465,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
local int Shape, ShapeHealth; local int Shape, ShapeHealth;
local Color HealthBoxColor, HealthTextColor; local Color HealthBoxColor;
BorderSize = Owner.HUDOwner.ScaledBorderSize; BorderSize = Owner.HUDOwner.ScaledBorderSize;
@ -475,7 +484,6 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
C.Font = Owner.CurrentStyle.PickFont(FontScalar); C.Font = Owner.CurrentStyle.PickFont(FontScalar);
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar); Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
TextYOffset = YOffset + (Height * 0.5f) - (YL * 0.5f);
if (KFPRIArray.Length > 1 && Index == 0) if (KFPRIArray.Length > 1 && Index == 0)
{ {
@ -493,56 +501,22 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun) if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun)
{ {
HealthBoxColor = Settings.Style.StateBoxColorLobby; HealthBoxColor = Settings.Style.StateBoxColorLobby;
HealthTextColor = Settings.Style.StateTextColorLobby;
} }
else if (!KFGRI.bMatchHasBegun) else if (!KFGRI.bMatchHasBegun)
{ {
if (KFPRI.bReadyToPlay) HealthBoxColor = Settings.Style.StateBoxColorLobby;
{
HealthBoxColor = Settings.Style.StateBoxColorReady;
HealthTextColor = Settings.Style.StateBoxColorReady;
}
else
{
HealthBoxColor = Settings.Style.StateBoxColorNotReady;
HealthTextColor = Settings.Style.StateBoxColorNotReady;
}
} }
else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None) else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None)
{ {
HealthBoxColor = Settings.Style.StateTextColorNone; HealthBoxColor = Settings.Style.StateBoxColorLobby;
HealthTextColor = Settings.Style.StateTextColorNone;
} }
else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0) else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0)
{ {
if (KFPRI.bOnlySpectator) HealthBoxColor = Settings.Style.StateBoxColorDead;
{
HealthBoxColor = Settings.Style.StateTextColorSpectator;
HealthTextColor = Settings.Style.StateTextColorSpectator;
}
else
{
HealthBoxColor = Settings.Style.StateTextColorDead;
HealthTextColor = Settings.Style.StateTextColorDead;
}
} }
else else
{ {
if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.Health.High) / 100.0) HealthBoxColor = HealthColorByPercent(ByteToFloat(KFPRI.PlayerHealthPercent));
{
HealthBoxColor = Settings.Style.StateBoxColorHealthHigh;
HealthTextColor = Settings.Style.StateTextColorHealthHigh;
}
else if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.Health.Low) / 100.0)
{
HealthBoxColor = Settings.Style.StateBoxColorHealthMid;
HealthTextColor = Settings.Style.StateTextColorHealthMid;
}
else
{
HealthBoxColor = Settings.Style.StateBoxColorHealthLow;
HealthTextColor = Settings.Style.StateTextColorHealthLow;
}
} }
// Health box // Health box
@ -554,11 +528,11 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
Settings.Style.EdgeSize, Settings.Style.EdgeSize,
ShapeHealth); ShapeHealth);
C.SetDrawColorStruct(HealthTextColor); C.SetDrawColorStruct(Settings.Style.StateTextColorHealthHigh);
if (KFPRI.PlayerHealth > 0) if (KFPRI.PlayerHealth > 0)
{ {
DrawTextShadowHVCenter(String(KFPRI.PlayerHealth), HealthXPos, TextYOffset, HealthWBox, FontScalar); DrawTextShadowHVCenter(String(KFPRI.PlayerHealth), HealthXPos, YOffset, HealthWBox, Height, FontScalar);
} }
XPos += HealthWBox; XPos += HealthWBox;
@ -607,7 +581,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
C.DrawRect (Height-5, Height-5, Texture2D'UI_Widgets.MenuBarWidget_SWF_IF'); C.DrawRect (Height-5, Height-5, Texture2D'UI_Widgets.MenuBarWidget_SWF_IF');
S = class'KFCommon_LocalizedStrings'.default.ZedString; S = class'KFCommon_LocalizedStrings'.default.ZedString;
DrawTextShadowHLeftVCenter(S, PerkXPos + Height, TextYOffset, FontScalar); DrawTextShadowHLeftVCenter(S, PerkXPos + Height, YOffset, Height, FontScalar);
RealPlayerWBox = PerkXPos + Height - PlayerXPos; RealPlayerWBox = PerkXPos + Height - PlayerXPos;
} }
else else
@ -648,17 +622,17 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
C.SetDrawColorStruct(Settings.Style.LevelTextColorHigh); C.SetDrawColorStruct(Settings.Style.LevelTextColorHigh);
S = String(Level); S = String(Level);
DrawTextShadowHLeftVCenter(S, LevelXPos, TextYOffset, FontScalar); DrawTextShadowHLeftVCenter(S, LevelXPos, YOffset, Height, FontScalar);
C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor); C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor);
S = KFPRI.CurrentPerkClass.default.PerkName; S = KFPRI.CurrentPerkClass.default.PerkName;
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar); DrawTextShadowHLeftVCenter(S, PerkXPos, YOffset, Height, FontScalar);
} }
else else
{ {
C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor); C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor);
S = ""; S = "";
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar); DrawTextShadowHLeftVCenter(S, PerkXPos, YOffset, Height, FontScalar);
RealPlayerWBox = PerkXPos - PlayerXPos; RealPlayerWBox = PerkXPos - PlayerXPos;
} }
} }
@ -667,7 +641,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
if (Rank.RankName != "") if (Rank.RankName != "")
{ {
C.SetDrawColorStruct(Rank.RankColor); C.SetDrawColorStruct(Rank.RankColor);
DrawTextShadowHRightVCenter(Rank.RankName, PlayerXPos, TextYOffset, PerkIconPosX - PlayerXPos - (BorderSize * 4), FontScalar); DrawTextShadowHRightVCenter(Rank.RankName, PlayerXPos, YOffset, PerkIconPosX - PlayerXPos - (BorderSize * 4), Height, FontScalar);
} }
// Avatar // Avatar
@ -693,15 +667,15 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
S = Left(S, Len(S)-1); S = Left(S, Len(S)-1);
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar); Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
} }
DrawTextShadowHLeftVCenter(S, PlayerXPos, TextYOffset, FontScalar); DrawTextShadowHLeftVCenter(S, PlayerXPos, YOffset, Height, FontScalar);
// Kill // Kill
C.SetDrawColorStruct(Settings.Style.KillsTextColorMid); // TODO C.SetDrawColorStruct(Settings.Style.KillsTextColorMid);
DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, TextYOffset, KillsWBox, FontScalar); DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, YOffset, KillsWBox, Height, FontScalar);
// Assist // Assist
C.SetDrawColorStruct(Settings.Style.AssistsTextColorMid); // TODO C.SetDrawColorStruct(Settings.Style.AssistsTextColorMid);
DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, TextYOffset, AssistWBox, FontScalar); DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, YOffset, AssistWBox, Height, FontScalar);
// Dosh // Dosh
if (bIsZED) if (bIsZED)
@ -711,10 +685,10 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
} }
else else
{ {
C.SetDrawColorStruct(Settings.Style.DoshTextColorMid); // TODO C.SetDrawColorStruct(Settings.Style.DoshTextColorMid);
StrValue = GetNiceSize(int(KFPRI.Score)); StrValue = GetNiceSize(int(KFPRI.Score));
} }
DrawTextShadowHVCenter(StrValue, DoshXPos, TextYOffset, DoshWBox, FontScalar); DrawTextShadowHVCenter(StrValue, DoshXPos, YOffset, DoshWBox, Height, FontScalar);
// Ping // Ping
if (KFPRI.bBot) if (KFPRI.bBot)
@ -737,7 +711,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float
} }
C.TextSize(S, XL, YL, FontScalar, FontScalar); C.TextSize(S, XL, YL, FontScalar, FontScalar);
DrawTextShadowHVCenter(S, PingXPos, TextYOffset, Settings.Style.ShowPingBars ? PingWBox/2 : PingWBox, FontScalar); DrawTextShadowHVCenter(S, PingXPos, YOffset, Settings.Style.ShowPingBars ? PingWBox/2 : PingWBox, Height, FontScalar);
C.SetDrawColor(250, 250, 250, 255); C.SetDrawColor(250, 250, 250, 255);
if (Settings.Style.ShowPingBars) if (Settings.Style.ShowPingBars)
DrawPingBars(C, YOffset + (Height/2) - ((Height*0.5)/2), Width - (Height*0.5) - (BorderSize*2), Height*0.5, Height*0.5, float(Ping)); DrawPingBars(C, YOffset + (Height/2) - ((Height*0.5)/2), Width - (Height*0.5) - (BorderSize*2), Height*0.5, Height*0.5, float(Ping));
@ -801,6 +775,84 @@ function ScrollMouseWheel(bool bUp)
PlayersList.ScrollMouseWheel(bUp); PlayersList.ScrollMouseWheel(bUp);
} }
function Color HealthColorByPercent(float FloatPercent)
{
local Color CRED, CYLW, CGRN, RV;
CRED = MakeColor(200, 0, 0, 150);
CYLW = MakeColor(200, 200, 0, 150);
CGRN = MakeColor(0, 200, 0, 150);
if (FloatPercent >= 0.9f)
{
RV = CGRN;
}
else if (FloatPercent >= 0.5f)
{
RV = PickDynamicColor(CYLW, CGRN, (FloatPercent - 0.5f) / (0.9f - 0.5f));
}
else if (FloatPercent >= 0.1f)
{
RV = PickDynamicColor(CRED, CYLW, (FloatPercent - 0.1f) / (0.5f - 0.1f));
}
else
{
RV = CRED;
}
return RV;
}
function Color PickDynamicColor(Color LowerColor, Color UpperColor, float FloatPercent)
{
return MakeColor((
LowerColor.R < UpperColor.R ?
LowerColor.R + ((UpperColor.R - LowerColor.R) * FloatPercent) :
LowerColor.R - ((LowerColor.R - UpperColor.R) * FloatPercent)),
(
LowerColor.G < UpperColor.G ?
LowerColor.G + ((UpperColor.G - LowerColor.G) * FloatPercent) :
LowerColor.G - ((LowerColor.G - UpperColor.G) * FloatPercent)),
(
LowerColor.B < UpperColor.B ?
LowerColor.B + ((UpperColor.B - LowerColor.B) * FloatPercent) :
LowerColor.B - ((LowerColor.B - UpperColor.B) * FloatPercent)),
(
LowerColor.A < UpperColor.A ?
LowerColor.A + ((UpperColor.A - LowerColor.A) * FloatPercent) :
LowerColor.A - ((LowerColor.A - UpperColor.A) * FloatPercent)));
}
function DrawTextShadowHVCenter(string Str, float XPos, float YPos, float BoxWidth, float BoxHeight, float FontScalar)
{
local float TextWidth;
local float TextHeight;
Canvas.TextSize(Str, TextWidth, TextHeight, FontScalar, FontScalar);
Owner.CurrentStyle.DrawTextShadow(Str, XPos + (BoxWidth - TextWidth)/2 , YPos + (BoxHeight - TextHeight)/2, 1, FontScalar);
}
function DrawTextShadowHLeftVCenter(string Str, float XPos, float YPos, float BoxHeight, float FontScalar)
{
local float TextWidth;
local float TextHeight;
Canvas.TextSize(Str, TextWidth, TextHeight, FontScalar, FontScalar);
Owner.CurrentStyle.DrawTextShadow(Str, XPos, YPos + (BoxHeight - TextHeight)/2, 1, FontScalar);
}
function DrawTextShadowHRightVCenter(string Str, float XPos, float YPos, float BoxWidth, float BoxHeight, float FontScalar)
{
local float TextWidth;
local float TextHeight;
Canvas.TextSize(Str, TextWidth, TextHeight, FontScalar, FontScalar);
Owner.CurrentStyle.DrawTextShadow(Str, XPos + BoxWidth - TextWidth, YPos + (BoxHeight - TextHeight)/2, 1, FontScalar);
}
defaultproperties defaultproperties
{ {
bEnableInputs=true bEnableInputs=true