diff --git a/YAS/Classes/GUIStyleBase.uc b/YAS/Classes/GUIStyleBase.uc index bde0dac..c8b1895 100644 --- a/YAS/Classes/GUIStyleBase.uc +++ b/YAS/Classes/GUIStyleBase.uc @@ -1354,6 +1354,14 @@ final function DrawArrowBox(int Direction, float X, float Y, float Width, float 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) { local float mW, mH, MidX, MidY, SmallTileW, SmallTileH, fX, fY; diff --git a/YAS/Classes/YAS.uc b/YAS/Classes/YAS.uc index ff1b146..d5c41dc 100644 --- a/YAS/Classes/YAS.uc +++ b/YAS/Classes/YAS.uc @@ -6,13 +6,14 @@ const LatestVersion = 1; const CfgRanks = class'Ranks'; const CfgRankRelations = class'RankRelations'; +const UpdateInterval = 1.0f; + 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; @@ -22,7 +23,7 @@ var private KFOnlineGameSettings KFOGS; var private OnlineSubsystemSteamworks OSS; -var private Array RepInfos; +var private Array RepInfos; var private Array PlayerRelations; var private Array GroupRelations; @@ -68,7 +69,6 @@ private function PreInit() if (Version == `NO_CONFIG) { LogLevel = LL_Info; - UpdateInterval = 1; SaveConfig(); } @@ -123,73 +123,19 @@ private function PreInit() 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); - } + AddRelation(Relation, PlayerRelations); } 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); - } + AddRelation(Relation, GroupRelations); } else { @@ -198,6 +144,41 @@ private function InitRanks() // TODO: Ref } } +private function AddRelation(RankRelation Relation, out Array OutArray) +{ + local CachedRankRelation CachedRankRelation; + local Array 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) { return (Left(ID, Len(MatchUID)) ~= MatchUID); @@ -277,12 +258,20 @@ private function PostInit() 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) { - local YAS_OwnerRepInfo RepInfo; + local YAS_RepInfo RepInfo; `Log_Trace(); @@ -298,7 +287,7 @@ public function NotifyLogin(Controller C) public function NotifyLogout(Controller C) { - local YAS_OwnerRepInfo RepInfo; + local YAS_RepInfo RepInfo; `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; `Log_Trace(); - OwnerRepInfo = Spawn(class'YAS_OwnerRepInfo', C); + OwnerRepInfo = Spawn(class'YAS_RepInfo', C); RankRepInfo = Spawn(class'YAS_RankRepInfo', C); if (OwnerRepInfo != None && RankRepInfo != None) @@ -334,9 +323,9 @@ public function YAS_OwnerRepInfo CreateRepInfo(Controller C) 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; @@ -351,7 +340,7 @@ private function YAS_OwnerRepInfo FindRepInfo(Controller C) return None; } -public function bool DestroyRepInfo(YAS_OwnerRepInfo RepInfo) +public function bool DestroyRepInfo(YAS_RepInfo RepInfo) { `Log_Trace(); @@ -364,7 +353,7 @@ public function bool DestroyRepInfo(YAS_OwnerRepInfo RepInfo) return true; } -private function InitRank(YAS_OwnerRepInfo RepInfo) +private function InitRank(YAS_RepInfo RepInfo) { local CachedRankRelation Rel; local String JoinedGroupIDs; diff --git a/YAS/Classes/YAS_OwnerRepInfo.uc b/YAS/Classes/YAS_RepInfo.uc similarity index 98% rename from YAS/Classes/YAS_OwnerRepInfo.uc rename to YAS/Classes/YAS_RepInfo.uc index 04b629d..8a817a8 100644 --- a/YAS/Classes/YAS_OwnerRepInfo.uc +++ b/YAS/Classes/YAS_RepInfo.uc @@ -1,4 +1,4 @@ -class YAS_OwnerRepInfo extends ReplicationInfo; +class YAS_RepInfo extends ReplicationInfo; var public YAS YAS; @@ -39,6 +39,8 @@ public simulated event ReplicatedEvent(name VarName) { `Log_Trace(); + `Log_Base("ReplicatedEvent:" @ VarName); + switch (VarName) { case 'LogLevel': diff --git a/YAS/Classes/YAS_ScoreBoard.uc b/YAS/Classes/YAS_ScoreBoard.uc index c23d59f..75d8c16 100644 --- a/YAS/Classes/YAS_ScoreBoard.uc +++ b/YAS/Classes/YAS_ScoreBoard.uc @@ -4,6 +4,18 @@ class YAS_ScoreBoard extends KFGUI_Page const HeaderWidthRatio = 0.30f; 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 transient float HealthXPos, RankXPos, PlayerXPos, LevelXPos, PerkXPos, DoshXPos, KillsXPos, AssistXPos, PingXPos, ScrollXPos; @@ -23,8 +35,7 @@ var KFPlayerController OwnerPC; var Color PingColor; var float PingBars; -var localized String Players; -var localized String Spectators; +var localized String Players, Spectators; // Cache var public Array RepInfos; @@ -274,22 +285,36 @@ function DrawMenu() Canvas.SetDrawColorStruct(Settings.Style.ServerNameTextColor); 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; // Mid Left Rect (Info) - BoxW = Width * 0.7; // TODO ? + BoxW = Width * 0.7; BoxH = YL * 2 + BorderSize * 2; Canvas.SetDrawColorStruct(Settings.Style.GameInfoBoxColor); Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeGameInfoBox); Canvas.SetDrawColorStruct(Settings.Style.GameInfoTextColor); 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); - 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) BoxX = BoxX + BoxW; @@ -299,8 +324,8 @@ function DrawMenu() Canvas.SetDrawColorStruct(Settings.Style.WaveTextColor); S = class'KFGFxHUD_ScoreboardMapInfoContainer'.default.WaveString; - DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar); - DrawTextShadowHVCenter(WaveText(), BoxX, YPos + YL, BoxW, FontScalar); + DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, BoxH / 2, FontScalar); + DrawTextShadowHVCenter(WaveText(), BoxX, YPos + BoxH / 2, BoxW, BoxH / 2, FontScalar); YPos += BoxH; @@ -311,13 +336,22 @@ function DrawMenu() Canvas.SetDrawColorStruct(Settings.Style.PlayerCountBoxColor); 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); - S = Players $ ":" @ 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); + DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, BoxH, FontScalar); 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; @@ -376,12 +410,12 @@ function DrawMenu() // Header texts Canvas.SetDrawColorStruct(Settings.Style.ListHeaderTextColor); - 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 + DoshXPos, YPos, DoshWBox, FontScalar); - DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, FontScalar); + DrawTextShadowHLeftVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PlayerString, XPos + PlayerXPos, YPos, BoxH, FontScalar); + DrawTextShadowHLeftVCenter(class'KFGFxMenu_Inventory'.default.PerkFilterString, XPos + PerkXPos, YPos, BoxH, FontScalar); + DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.KillsString, XPos + KillsXPos, YPos, KillsWBox, BoxH, FontScalar); + DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.AssistsString, XPos + AssistXPos, YPos, AssistWBox, BoxH, FontScalar); + DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.DoshString, XPos + DoshXPos, YPos, DoshWBox, BoxH, FontScalar); + DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, BoxH, FontScalar); ColorTMP = Settings.Style.ListHeaderTextColor; 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); } -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) { 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 KFPlayerReplicationInfo KFPRI; local byte Level, PrestigeLevel; @@ -456,7 +465,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float local int Shape, ShapeHealth; - local Color HealthBoxColor, HealthTextColor; + local Color HealthBoxColor; 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); Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar); - TextYOffset = YOffset + (Height * 0.5f) - (YL * 0.5f); 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) { HealthBoxColor = Settings.Style.StateBoxColorLobby; - HealthTextColor = Settings.Style.StateTextColorLobby; } else if (!KFGRI.bMatchHasBegun) { - if (KFPRI.bReadyToPlay) - { - HealthBoxColor = Settings.Style.StateBoxColorReady; - HealthTextColor = Settings.Style.StateBoxColorReady; - } - else - { - HealthBoxColor = Settings.Style.StateBoxColorNotReady; - HealthTextColor = Settings.Style.StateBoxColorNotReady; - } + HealthBoxColor = Settings.Style.StateBoxColorLobby; } else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None) { - HealthBoxColor = Settings.Style.StateTextColorNone; - HealthTextColor = Settings.Style.StateTextColorNone; + HealthBoxColor = Settings.Style.StateBoxColorLobby; } else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0) { - if (KFPRI.bOnlySpectator) - { - HealthBoxColor = Settings.Style.StateTextColorSpectator; - HealthTextColor = Settings.Style.StateTextColorSpectator; - } - else - { - HealthBoxColor = Settings.Style.StateTextColorDead; - HealthTextColor = Settings.Style.StateTextColorDead; - } + HealthBoxColor = Settings.Style.StateBoxColorDead; } else { - if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.Health.High) / 100.0) - { - 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; - } + HealthBoxColor = HealthColorByPercent(ByteToFloat(KFPRI.PlayerHealthPercent)); } // Health box @@ -554,11 +528,11 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float Settings.Style.EdgeSize, ShapeHealth); - C.SetDrawColorStruct(HealthTextColor); + C.SetDrawColorStruct(Settings.Style.StateTextColorHealthHigh); if (KFPRI.PlayerHealth > 0) { - DrawTextShadowHVCenter(String(KFPRI.PlayerHealth), HealthXPos, TextYOffset, HealthWBox, FontScalar); + DrawTextShadowHVCenter(String(KFPRI.PlayerHealth), HealthXPos, YOffset, HealthWBox, Height, FontScalar); } 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'); S = class'KFCommon_LocalizedStrings'.default.ZedString; - DrawTextShadowHLeftVCenter(S, PerkXPos + Height, TextYOffset, FontScalar); + DrawTextShadowHLeftVCenter(S, PerkXPos + Height, YOffset, Height, FontScalar); RealPlayerWBox = PerkXPos + Height - PlayerXPos; } else @@ -648,17 +622,17 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float C.SetDrawColorStruct(Settings.Style.LevelTextColorHigh); S = String(Level); - DrawTextShadowHLeftVCenter(S, LevelXPos, TextYOffset, FontScalar); + DrawTextShadowHLeftVCenter(S, LevelXPos, YOffset, Height, FontScalar); C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor); S = KFPRI.CurrentPerkClass.default.PerkName; - DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar); + DrawTextShadowHLeftVCenter(S, PerkXPos, YOffset, Height, FontScalar); } else { C.SetDrawColorStruct(Settings.Style.PerkNoneTextColor); S = ""; - DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar); + DrawTextShadowHLeftVCenter(S, PerkXPos, YOffset, Height, FontScalar); RealPlayerWBox = PerkXPos - PlayerXPos; } } @@ -667,7 +641,7 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float if (Rank.RankName != "") { 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 @@ -693,15 +667,15 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float S = Left(S, Len(S)-1); Canvas.TextSize(S, XL, YL, FontScalar, FontScalar); } - DrawTextShadowHLeftVCenter(S, PlayerXPos, TextYOffset, FontScalar); + DrawTextShadowHLeftVCenter(S, PlayerXPos, YOffset, Height, FontScalar); // Kill - C.SetDrawColorStruct(Settings.Style.KillsTextColorMid); // TODO - DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, TextYOffset, KillsWBox, FontScalar); + C.SetDrawColorStruct(Settings.Style.KillsTextColorMid); + DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, YOffset, KillsWBox, Height, FontScalar); // Assist - C.SetDrawColorStruct(Settings.Style.AssistsTextColorMid); // TODO - DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, TextYOffset, AssistWBox, FontScalar); + C.SetDrawColorStruct(Settings.Style.AssistsTextColorMid); + DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, YOffset, AssistWBox, Height, FontScalar); // Dosh if (bIsZED) @@ -711,10 +685,10 @@ function DrawPlayerEntry(Canvas C, int Index, float YOffset, float Height, float } else { - C.SetDrawColorStruct(Settings.Style.DoshTextColorMid); // TODO + C.SetDrawColorStruct(Settings.Style.DoshTextColorMid); StrValue = GetNiceSize(int(KFPRI.Score)); } - DrawTextShadowHVCenter(StrValue, DoshXPos, TextYOffset, DoshWBox, FontScalar); + DrawTextShadowHVCenter(StrValue, DoshXPos, YOffset, DoshWBox, Height, FontScalar); // Ping 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); - 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); 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)); @@ -801,6 +775,84 @@ function ScrollMouseWheel(bool 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 { bEnableInputs=true