From 032bf1c114cd285c2c54ab114d1563c0b10d4daa Mon Sep 17 00:00:00 2001 From: Forrest Keller Date: Wed, 25 Oct 2017 17:21:13 -0500 Subject: [PATCH] Added a new scoreboard Attempt to fix font scales being super huge on 1440p and higher resolutions --- ServerExt/Classes/GUIStyleBase.uc | 8 +- ServerExt/Classes/KFExtendedHUD.uc | 4 +- ServerExt/Classes/KFGUI_Button_CD.uc | 56 ++ ServerExt/Classes/KFGUI_List_CD.uc | 22 + ServerExt/Classes/KFGUI_RightClickMenu_CD.uc | 67 +++ ServerExt/Classes/KFGUI_ScrollBarV_CD.uc | 52 ++ ServerExt/Classes/KFGUI_Tooltip_CD.uc | 67 +++ ServerExt/Classes/UI_Scoreboard_CD.uc | 522 +++++++++++++++++++ 8 files changed, 792 insertions(+), 6 deletions(-) create mode 100644 ServerExt/Classes/KFGUI_Button_CD.uc create mode 100644 ServerExt/Classes/KFGUI_List_CD.uc create mode 100644 ServerExt/Classes/KFGUI_RightClickMenu_CD.uc create mode 100644 ServerExt/Classes/KFGUI_ScrollBarV_CD.uc create mode 100644 ServerExt/Classes/KFGUI_Tooltip_CD.uc create mode 100644 ServerExt/Classes/UI_Scoreboard_CD.uc diff --git a/ServerExt/Classes/GUIStyleBase.uc b/ServerExt/Classes/GUIStyleBase.uc index 4d9ac88..417c034 100644 --- a/ServerExt/Classes/GUIStyleBase.uc +++ b/ServerExt/Classes/GUIStyleBase.uc @@ -36,10 +36,10 @@ function PickDefaultFontSize( float YRes ) ++DefaultFontSize; if( YRes>1000 ) ++DefaultFontSize; - if( YRes>1200 ) - ++DefaultFontSize; - if( YRes>1300 ) - ++DefaultFontSize; + //if( YRes>1200 ) + //++DefaultFontSize; + //if( YRes>1300 ) + //++DefaultFontSize; S = "ABC"; PickFont(DefaultFontSize,YRes).GetStringHeightAndWidth(S,YL,XL); diff --git a/ServerExt/Classes/KFExtendedHUD.uc b/ServerExt/Classes/KFExtendedHUD.uc index 6250bff..c723aef 100644 --- a/ServerExt/Classes/KFExtendedHUD.uc +++ b/ServerExt/Classes/KFExtendedHUD.uc @@ -325,8 +325,8 @@ exec function SetShowScores(bool bNewValue) if( GUIController!=None ) { if( bShowScores ) - GUIController.OpenMenu(class'UI_Scoreboard'); - else GUIController.CloseMenu(class'UI_Scoreboard'); + GUIController.OpenMenu(class'UI_Scoreboard_CD'); + else GUIController.CloseMenu(class'UI_Scoreboard_CD'); } } final function RenderKillMsg() diff --git a/ServerExt/Classes/KFGUI_Button_CD.uc b/ServerExt/Classes/KFGUI_Button_CD.uc new file mode 100644 index 0000000..ee2edc9 --- /dev/null +++ b/ServerExt/Classes/KFGUI_Button_CD.uc @@ -0,0 +1,56 @@ +Class KFGUI_Button_CD extends KFGUI_Button; + +function DrawMenu() +{ + local float XL,YL,TS; + local byte i, FrameOpacity; + + FrameOpacity = 200; + if( bDisabled ) + Canvas.SetDrawColor(10, 10, 10, FrameOpacity); + else if( bPressedDown ) + Canvas.SetDrawColor(20, 20, 20, FrameOpacity); + else if( bFocused ) + Canvas.SetDrawColor(75, 75, 75, FrameOpacity); + else Canvas.SetDrawColor(45, 45, 45, FrameOpacity); + + if( bIsHighlighted ) + { + Canvas.DrawColor.R = Min(Canvas.DrawColor.R + 25, FrameOpacity); + Canvas.DrawColor.G = Min(Canvas.DrawColor.G + 25, FrameOpacity); + Canvas.DrawColor.B = Min(Canvas.DrawColor.B + 25, FrameOpacity); + } + + Canvas.SetPos(0.f,0.f); + if( ExtravDir==255 ) + Owner.CurrentStyle.DrawWhiteBox(CompPos[2],CompPos[3]); + else Owner.CurrentStyle.DrawRectBox(0,0,CompPos[2],CompPos[3],Min(CompPos[2],CompPos[3])*0.2,ExtravDir); + + if( OverlayTexture.Texture!=None ) + { + Canvas.SetPos(0.f,0.f); + Canvas.DrawTile(OverlayTexture.Texture,CompPos[2],CompPos[3],OverlayTexture.U,OverlayTexture.V,OverlayTexture.UL,OverlayTexture.VL); + } + if( ButtonText!="" ) + { + // Chose the best font to fit this button. + i = Min(FontScale+Owner.CurrentStyle.DefaultFontSize,Owner.CurrentStyle.MaxFontScale); + while( true ) + { + Canvas.Font = Owner.CurrentStyle.PickFont(i,TS); + Canvas.TextSize(ButtonText,XL,YL,TS,TS); + if( i==0 || (XL<(CompPos[2]*0.95) && YL<(CompPos[3]*0.95)) ) + break; + --i; + } + Canvas.SetPos((CompPos[2]-XL)*0.5,(CompPos[3]-YL)*0.5); + if( bDisabled ) + Canvas.DrawColor = TextColor*0.5f; + else Canvas.DrawColor = TextColor; + Canvas.DrawText(ButtonText,,TS,TS,TextFontInfo); + } +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/ServerExt/Classes/KFGUI_List_CD.uc b/ServerExt/Classes/KFGUI_List_CD.uc new file mode 100644 index 0000000..93d1551 --- /dev/null +++ b/ServerExt/Classes/KFGUI_List_CD.uc @@ -0,0 +1,22 @@ +Class KFGUI_List_CD extends KFGUI_List; + +function InitMenu() +{ + Super(KFGUI_MultiComponent).InitMenu(); + ScrollBar = KFGUI_ScrollBarV_CD(FindComponentID('Scrollbar')); + UpdateListVis(); +} + +defaultproperties +{ + Components.Empty + + Begin Object Class=KFGUI_ScrollBarV_CD Name=ListScroller + XPosition=0.96 + YPosition=0 + XSize=0.04 + YSize=1 + ID="Scrollbar" + End Object + Components.Add(ListScroller) +} \ No newline at end of file diff --git a/ServerExt/Classes/KFGUI_RightClickMenu_CD.uc b/ServerExt/Classes/KFGUI_RightClickMenu_CD.uc new file mode 100644 index 0000000..3355fdf --- /dev/null +++ b/ServerExt/Classes/KFGUI_RightClickMenu_CD.uc @@ -0,0 +1,67 @@ +Class KFGUI_RightClickMenu_CD extends KFGUI_RightClickMenu; + +function DrawMenu() +{ + local float X,Y,YP,Edge,TextScale; + local int i; + local bool bCheckMouse; + + // Draw background. + Edge = EdgeSize; + Canvas.SetPos(0.f,0.f); + Canvas.SetDrawColor(45, 45, 45, 200); + Owner.CurrentStyle.DrawWhiteBox(CompPos[2],CompPos[3]); + Canvas.SetPos(Edge,Edge); + Canvas.SetDrawColor(10, 10, 10, 160); + Owner.CurrentStyle.DrawWhiteBox(CompPos[2]-(Edge*2.f),CompPos[3]-(Edge*2.f)); + + // While rendering, figure out mouse focus row. + X = Owner.MousePosition.X - Canvas.OrgX; + Y = Owner.MousePosition.Y - Canvas.OrgY; + + bCheckMouse = (X>0.f && X0.f && Y=YP && Y<=(YP+Owner.CurrentStyle.DefaultHeight) ) + { + bCheckMouse = false; + CurrentRow = i; + Canvas.SetPos(4.f,YP); + Canvas.SetDrawColor(110,110,110,255); + Owner.CurrentStyle.DrawWhiteBox(CompPos[2]-(Edge*2.f),Owner.CurrentStyle.DefaultHeight); + } + + Canvas.SetPos(Edge,YP); + if( ItemRows[i].bSplitter ) + { + Canvas.SetDrawColor(255,255,255,255); + Canvas.DrawText("-------",,TextScale,TextScale); + } + else + { + if( ItemRows[i].bDisabled ) + Canvas.SetDrawColor(148,148,148,255); + else Canvas.SetDrawColor(248,248,248,255); + Canvas.DrawText(ItemRows[i].Text,,TextScale,TextScale); + } + + YP+=Owner.CurrentStyle.DefaultHeight; + } + Canvas.PopMaskRegion(); + if( OldRow!=CurrentRow ) + { + OldRow = CurrentRow; + PlayMenuSound(MN_DropdownChange); + } +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/ServerExt/Classes/KFGUI_ScrollBarV_CD.uc b/ServerExt/Classes/KFGUI_ScrollBarV_CD.uc new file mode 100644 index 0000000..46c2306 --- /dev/null +++ b/ServerExt/Classes/KFGUI_ScrollBarV_CD.uc @@ -0,0 +1,52 @@ +Class KFGUI_ScrollBarV_CD extends KFGUI_ScrollBarV; + +function DrawMenu() +{ + local float A; + local byte i; + + if( bDisabled ) + Canvas.SetDrawColor(5, 5, 5, 0); + else if( bFocused || bGrabbedScroller ) + Canvas.SetDrawColor(30, 30, 30, 160); + else Canvas.SetDrawColor(30, 30, 30, 160); + + Owner.CurrentStyle.DrawRectBox (0.f, 0.f, CompPos[2], CompPos[3], 4); + + if( bDisabled ) + return; + + if( bVertical ) + i = 3; + else i = 2; + + SliderScale = FMax(PageStep * (CompPos[i] - 32.f) / (MaxRange + PageStep),CalcButtonScale); + + if( bGrabbedScroller ) + { + // Track mouse. + if( bVertical ) + A = Owner.MousePosition.Y - CompPos[1] - GrabbedOffset; + else A = Owner.MousePosition.X - CompPos[0] - GrabbedOffset; + + A /= ((CompPos[i]-SliderScale) / float(MaxRange)); + SetValue(A); + } + + A = float(CurrentScroll) / float(MaxRange); + ButtonOffset = A*(CompPos[i]-SliderScale); + + if( bGrabbedScroller ) + Canvas.SetDrawColor(90,90,90,255); + else if( bFocused ) + Canvas.SetDrawColor(65,65,65,255); + else Canvas.SetDrawColor(40,40,40,255); + + if( bVertical ) + Owner.CurrentStyle.DrawRectBox (0.f, ButtonOffset, CompPos[2], SliderScale, 4); + else Owner.CurrentStyle.DrawRectBox (ButtonOffset, 0.f, SliderScale, CompPos[3], 4); +} + +defaultproperties +{ +} \ No newline at end of file diff --git a/ServerExt/Classes/KFGUI_Tooltip_CD.uc b/ServerExt/Classes/KFGUI_Tooltip_CD.uc new file mode 100644 index 0000000..cf5453e --- /dev/null +++ b/ServerExt/Classes/KFGUI_Tooltip_CD.uc @@ -0,0 +1,67 @@ +Class KFGUI_Tooltip_CD extends KFGUI_Tooltip; + +function PreDraw() +{ + local int i; + local float X,Y,XS,YS,TX,TY,TS; + + if( Owner.CurrentStyle == None ) + return; + + Canvas.Font = Owner.CurrentStyle.PickFont(Owner.CurrentStyle.DefaultFontSize,TS); + + // First compute textbox size. + TY = Owner.CurrentStyle.DefaultHeight*Lines.Length; + for( i=0; iOwner.ScreenSize.X ) + X = Owner.ScreenSize.X-TX; + if( (Y+TY)>Owner.ScreenSize.Y ) + Y = CompPos[1]-TY; + + if( CurrentAlpha<255 ) + CurrentAlpha = Min(CurrentAlpha+25,255); + + // Reset clipping. + Canvas.SetOrigin(0,0); + Canvas.SetClip(Owner.ScreenSize.X,Owner.ScreenSize.Y); + + // Draw frame. + //Canvas.SetDrawColor(200,200,80,CurrentAlpha); + Canvas.SetDrawColor(45, 45, 45, 160); + Canvas.SetPos(X-2,Y-2); + Owner.CurrentStyle.DrawWhiteBox(TX+4,TY+4); + //Canvas.SetDrawColor(80,10,80,CurrentAlpha); + Canvas.SetDrawColor(10, 10, 10, 160); + Canvas.SetPos(X,Y); + Owner.CurrentStyle.DrawWhiteBox(TX,TY); + + // Draw text. + Canvas.SetDrawColor(255,255,255,CurrentAlpha); + X+=KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER; + Y+=KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER; + for( i=0; i 0; --i) { + for (j = i - 1; j >= 0; --j) { + if (!InOrder (KFGRI.PRIArray [i], KFGRI.PRIArray [j])) { + PRI = KFGRI.PRIArray [i]; + KFGRI.PRIArray [i] = KFGRI.PRIArray [j]; + KFGRI.PRIArray [j] = PRI; + } + } + } + + // Check players. + NumPlayer = 0; + for (i = (KFGRI.PRIArray.Length - 1); i >= 0; --i) { + KFPRI = ExtPlayerReplicationInfo (KFGRI.PRIArray [i]); + if (KFPRI == None) + continue; + + if (KFPRI.bOnlySpectator) { + ++NumSpec; + continue; + } + + if (KFPRI.PlayerHealth > 0 && KFPRI.PlayerHealthPercent > 0 && KFPRI.GetTeamNum () == 0) + ++NumAlivePlayer; + ++NumPlayer; + } + + //`Log ("DrawMenu (): PlayList.Length = " @PRIList.Length); + + // Header font info. + DefFont = Owner.CurrentStyle.DefaultFontSize; + Canvas.Font = Owner.CurrentStyle.PickFont(DefFont, FontScalar); + + YL = Owner.CurrentStyle.DefaultHeight; + XPosCenter = (Canvas.ClipX * 0.5); + + // ServerName + + XPos = XPosCenter; + YPos = Canvas.ClipY * 0.05; + + S = " " $KFGRI.ServerName $" "; + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos -= (XL * 0.5); + + Canvas.SetDrawColor (10, 10, 10, 200); + Owner.CurrentStyle.DrawRectBox (XPos, YPos, XL, YL, 4); + + Canvas.DrawColor = MakeColor (250, 0, 0, 255); + XPos += 5; + + S = KFGRI.ServerName; + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + + // Deficulty | Wave | MapName | ElapsedTime + + XPos = XPosCenter; + YPos += YL; + + S = " " $Class'KFCommon_LocalizedStrings'.Static.GetDifficultyString (KFGRI.GameDifficulty) $" | WAVE " $KFGRI.WaveNum $" | " $PC.WorldInfo.Title $" | 00 : 00 : 00 "; + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos -= (XL * 0.5); + + Canvas.SetDrawColor (10, 10, 10, 200); + Owner.CurrentStyle.DrawRectBox (XPos, YPos, XL, YL, 4); + + Canvas.DrawColor = MakeColor (0, 250, 0, 255); + XPos += 5; + + S = Class'KFCommon_LocalizedStrings'.Static.GetDifficultyString (KFGRI.GameDifficulty); + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos += XL; + S = " | WAVE " $KFGRI.WaveNum; + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos += XL; + S = " | " $class'KFCommon_LocalizedStrings'.static.GetFriendlyMapName(PC.WorldInfo.GetMapName(true)); + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos += XL; + S = " | " $FormatTimeSMH (KFGRI.ElapsedTime); + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + + // Players | Alive | Spectators + + XPos = XPosCenter; + YPos += YL; + + S = " Players : " $NumPlayer $" | Alive : " $NumAlivePlayer $" | Spectators : " $NumSpec $" "; + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos -= (XL * 0.5); + + Canvas.SetDrawColor (10, 10, 10, 200); + Owner.CurrentStyle.DrawRectBox (XPos, YPos, XL, YL, 4); + + Canvas.DrawColor = MakeColor (250, 250, 0, 255); + XPos += 5; + + S = "Players : " $NumPlayer; + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos += XL; + S = " | Alive : " $NumAlivePlayer; + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + Canvas.TextSize (S, XL, YL, FontScalar, FontScalar); + + XPos += XL; + S = " | Spectators : " $NumSpec; + Canvas.SetPos (XPos, YPos); + Canvas.DrawText (S, , FontScalar, FontScalar); + + Width = Canvas.ClipX * 0.7; + + XPos = (Canvas.ClipX - Width) * 0.5; + YPos += YL * 2.0; + + Canvas.SetDrawColor (10, 10, 10, 200); + Owner.CurrentStyle.DrawRectBox (XPos, YPos, Width, YL, 4); + + Canvas.DrawColor = MakeColor (250, 250, 250, 255); + + // Calc X offsets + + AdminXPos = Width * 0.0; + PerkXPos = Width * 0.1; + PlayerXPos = Width * 0.3; + KillsXPos = Width * 0.5; + AssistXPos = Width * 0.6; + CashXPos = Width * 0.7; + StateXPos = Width * 0.8; + PingXPos = Width * 0.95; + + // Header texts + if( !bShowSpectatorsOnly ) + { + Canvas.SetPos (XPos + PerkXPos, YPos); + Canvas.DrawText ("PERK", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + KillsXPos, YPos); + Canvas.DrawText ("KILLS", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + AssistXPos, YPos); + Canvas.DrawText ("ASSISTS", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + CashXPos, YPos); + Canvas.DrawText ("DOSH", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + StateXPos, YPos); + Canvas.DrawText ("STATE", , FontScalar, FontScalar); + } + + Canvas.SetPos (XPos, YPos); + Canvas.DrawText ("RANK", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + PlayerXPos, YPos); + Canvas.DrawText ("PLAYER", , FontScalar, FontScalar); + + Canvas.SetPos (XPos + PingXPos, YPos); + Canvas.DrawText ("PING", , FontScalar, FontScalar); + + PRIList.Length = (bShowSpectatorsOnly ? NumSpec : NumPlayer); + j = PRIList.Length; + for( i=(KFGRI.PRIArray.Length-1); i>=0; --i ) + { + KFPRI = ExtPlayerReplicationInfo(KFGRI.PRIArray[i]); + if( KFPRI!=None && bShowSpectatorsOnly==KFPRI.bOnlySpectator ) + { + PRIList[--j] = KFPRI; + if( KFPRI==PC.PlayerReplicationInfo ) + PlayerIndex = j; + } + } + + CurrentBoxY = (YL + 4) * MaxPlayerCount; + while( CurrentBoxY > (Canvas.ClipY-YPos) ) + { + if( ++i>=5 ) + { + NotShownCount = MaxPlayerCount-int((Canvas.ClipY-YPos)/CurrentBoxY)+1; + MaxPlayerCount-=NotShownCount; + break; + } + } + + PlayersList.XPosition = ((Canvas.ClipX - Width) * 0.5) / InputPos[2]; + PlayersList.YPosition = (YPos + (YL + 4)) / InputPos[3]; + PlayersList.XSize = (Width * 1.022) / InputPos[2]; + PlayersList.YSize = CurrentBoxY / InputPos[3]; + PlayersList.ListItemsPerPage = MaxPlayerCount; + PlayersList.ChangeListSize(PRIList.Length); +} + +function DrawPlayerEntry( Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus ) +{ + local float FontScalar; + local ExtPlayerReplicationInfo KFPRI; + local string S, StrValue; + local byte DefFont; + local int Ping; + + KFPRI = PRIList[Index]; + + bFocus = bFocus || (bHasSelectedPlayer && RightClickPlayer==KFPRI); + + DefFont = Owner.CurrentStyle.DefaultFontSize; + C.Font = Owner.CurrentStyle.PickFont(DefFont, FontScalar); + + if (KFPRI == GetPlayer().PlayerReplicationInfo) + { + if( bFocus ) + C.SetDrawColor(0, 83, 255, 150); + else C.SetDrawColor (51, 30, 101, 150); + } + else + { + if( bFocus ) + C.SetDrawColor(0, 83, 255, 150); + else C.SetDrawColor (30, 30, 30, 150); + } + + Owner.CurrentStyle.DrawRectBox (0.f, YOffset, Width, Height, 4); + + C.DrawColor = MakeColor (250, 250, 250, 255); + + // Perk + if( !bShowSpectatorsOnly ) + { + C.DrawColor = KFPRI.HUDPerkColor; + if( KFPRI.ECurrentPerk!=None ) + { + C.SetPos (0.f + PerkXPos, YOffset + 2.5); + C.DrawRect (Height-5, Height-5, KFPRI.ECurrentPerk.Default.PerkIcon); + + S = KFPRI.GetPerkLevelStr()@KFPRI.ECurrentPerk.Default.PerkName; + C.SetPos (0.f + PerkXPos + Height, YOffset); + C.DrawText (S, , FontScalar, FontScalar); + } + else if( KFPRI.bBot && KFPRI.CurrentPerkClass!=None ) + { + C.SetPos (0.f + PerkXPos, YOffset + 2.5); + C.DrawRect (Height-5, Height-5, KFPRI.CurrentPerkClass.Default.PerkIcon); + + S = KFPRI.CurrentPerkClass.Default.PerkName; + C.SetPos (0.f + PerkXPos + Height, YOffset); + C.DrawText (S, , FontScalar, FontScalar); + } + else + { + C.DrawColor = MakeColor (250, 250, 250, 255); + S = "No Perk"; + C.SetPos (0.f + PerkXPos + Height, YOffset); + C.DrawText (S, , FontScalar, FontScalar); + } + } + + // Avatar + if( KFPRI.Avatar!=None ) + { + C.SetDrawColor(255,255,255,255); + C.SetPos(0.f + PlayerXPos - (Height * 1.2), YOffset); + C.DrawTile(KFPRI.Avatar,Height,Height,0,0,KFPRI.Avatar.SizeX,KFPRI.Avatar.SizeY); + } + else + { + // Try to obtain avatar. + if( !KFPRI.bBot ) + KFPRI.Avatar = FindAvatar(KFPRI.UniqueId); + } + + // Rank + if( KFPRI.ShowAdminName() ) + { + S = KFPRI.GetAdminName(); + C.DrawColor = KFPRI.GetAdminColorC(); + } + else if( KFPRI.bIsDev ) + { + S = "Developer"; + C.DrawColor = MakeColor(130,255,235,255); + } + else + { + S = "Player"; + C.DrawColor = MakeColor(255,255,255,255); + } + + // Rank + C.SetPos (0.f + AdminXPos, YOffset); + C.DrawText (S, , FontScalar, FontScalar); + + // Player + C.SetPos (0.f + PlayerXPos, YOffset); + C.DrawText (KFPRI.PlayerName, , FontScalar, FontScalar); + + C.DrawColor = MakeColor(255,255,255,255); + + if( !bShowSpectatorsOnly ) + { + // Kill + C.SetDrawColor(255,51,51,255); + C.SetPos (0.f + KillsXPos, YOffset); + C.DrawText (string (KFPRI.Kills), , FontScalar, FontScalar); + + // Assist + C.SetDrawColor(255,255,51,255); + C.SetPos (0.f + AssistXPos, YOffset); + C.DrawText (string (KFPRI.Assists), , FontScalar, FontScalar); + + // Dosh + C.SetDrawColor(51,255,51,255); + C.SetPos (0.f + CashXPos, YOffset); + StrValue = ConvertValueLarge(KFPRI.Score); + C.DrawText (StrValue, , FontScalar, FontScalar); + + // State + if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0) + { + C.DrawColor = MakeColor (250, 0, 0, 255); + S = "DEAD"; + } + else + { + if (KFPRI.PlayerHealth >= 80) + C.DrawColor = MakeColor (0, 250, 0, 255); + else if (KFPRI.PlayerHealth >= 30) + C.DrawColor = MakeColor (250, 250, 0, 255); + else C.DrawColor = MakeColor (250, 100, 100, 255); + + S = string (KFPRI.PlayerHealth) @"HP"; + } + + C.SetPos (0.f + StateXPos, YOffset); + C.DrawText (S, , FontScalar, FontScalar); + + C.DrawColor = MakeColor (250, 250, 250, 255); + } + + // Ping + if (KFPRI.bBot) + S = "-"; + else + { + Ping = int(KFPRI.Ping * `PING_SCALE); + + if (Ping <= 100) + C.DrawColor = MakeColor (0, 250, 0, 255); + else if (Ping <= 200) + C.DrawColor = MakeColor (250, 250, 0, 255); + else C.DrawColor = MakeColor (250, 100, 100, 255); + + S = string(Ping); + } + + C.SetPos (0.f + PingXPos, YOffset); + C.DrawText (S, , FontScalar, FontScalar); +} + +function ShowPlayerTooltip( int Index ) +{ + local ExtPlayerReplicationInfo PRI; + local string S; + + PRI = PRIList[Index]; + if( PRI!=None ) + { + if( ToolTipItem==None ) + { + ToolTipItem = New(None)Class'KFGUI_Tooltip_CD'; + ToolTipItem.Owner = Owner; + ToolTipItem.ParentComponent = Self; + ToolTipItem.InitMenu(); + } + S = "Player: "$PRI.TaggedPlayerName$"|Health: "$(PRI.PlayerHealthPercent<=0 ? "0" : string(PRI.PlayerHealth)); + if( PRI.ShowAdminName() ) + S = S$"|"$PRI.GetAdminName(); + S = S$"|(Right click for options)"; + ToolTipItem.SetText(S); + ToolTipItem.ShowMenu(); + ToolTipItem.CompPos[0] = Owner.MousePosition.X; + ToolTipItem.CompPos[1] = Owner.MousePosition.Y; + ToolTipItem.GetInputFocus(); + } +} + +function string ConvertValueLarge(int FValue) +{ + local string StrValue, StrType; + local float FltValue; + local int i; + + FltValue = float(FValue); + StrValue = string(FltValue); + if(FltValue < 10000.f) + { + StrValue = string(int(FltValue)); + StrType = ""; + } + else if(FltValue < 1000000.f) + { + StrValue = string(FltValue / 1000);//.0 + StrType = "k"; + } + else + { + StrValue = string(FltValue / 1000000);//.0 + StrType = "m"; + } + i = InStr(StrValue,"."); + if(i != -1 && StrType != "") + return Left(StrValue,i+2) $ StrType; + return StrValue; +} + +function SelectedRCItem( int Index ) +{ + local PlayerController PC; + local KFPlayerReplicationInfo KFPRI; + + PC = GetPlayer(); + KFPRI = KFPlayerReplicationInfo(PC.PlayerReplicationInfo); + + switch( Index ) + { + case 3: // Vote kick. + KFPRI.ServerStartKickVote(RightClickPlayer, KFPRI); + break; + default: + Super.SelectedRCItem(Index); + break; + } +} + +defaultproperties +{ + MaxPlayerCount=25 + + Components.Empty + + Begin Object Class=KFGUI_List_CD Name=PlayerList + bDrawBackground=false + OnDrawItem=DrawPlayerEntry + OnClickedItem=ClickedPlayer + ID="PlayerList" + bClickable=true + OnMouseRest=ShowPlayerTooltip + End Object + Begin Object Class=KFGUI_Button_CD Name=B_ShowSpecs + ID="Spec" + ButtonText="Show Spectators" + Tooltip="Toggle show server spectators" + XPosition=0.67 + YPosition=0.965 + XSize=0.09 + YSize=0.03 + OnClickLeft=ButtonClicked + OnClickRight=ButtonClicked + End Object + Components.Add(PlayerList) + Components.Add(B_ShowSpecs) + + Begin Object Class=KFGUI_RightClickMenu_CD Name=PlayerContextMenu + ItemRows.Add((Text="Spectate this player")) + ItemRows.Add((Text="View player Steam profile")) + ItemRows.Add((Text="Mute Player")) + ItemRows.Add((Text="Vote kick player")) + ItemRows.Add((bSplitter=true)) + OnSelectedItem=SelectedRCItem + OnBecameHidden=HidRightClickMenu + End Object + PlayerContext=PlayerContextMenu +} \ No newline at end of file