Skip to content

Commit

Permalink
Added a new scoreboard
Browse files Browse the repository at this point in the history
Attempt to fix font scales being super huge on 1440p and higher resolutions
  • Loading branch information
ForrestMarkX committed Oct 25, 2017
1 parent 6b79616 commit 032bf1c
Show file tree
Hide file tree
Showing 8 changed files with 792 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ServerExt/Classes/GUIStyleBase.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions ServerExt/Classes/KFExtendedHUD.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
56 changes: 56 additions & 0 deletions ServerExt/Classes/KFGUI_Button_CD.uc
Original file line number Diff line number Diff line change
@@ -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
{
}
22 changes: 22 additions & 0 deletions ServerExt/Classes/KFGUI_List_CD.uc
Original file line number Diff line number Diff line change
@@ -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)
}
67 changes: 67 additions & 0 deletions ServerExt/Classes/KFGUI_RightClickMenu_CD.uc
Original file line number Diff line number Diff line change
@@ -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 && X<CompPos[2] && Y>0.f && Y<CompPos[3]);

Canvas.Font = Owner.CurrentStyle.PickFont(Owner.CurrentStyle.DefaultFontSize,TextScale);

YP = Edge;
CurrentRow = -1;

Canvas.PushMaskRegion(Canvas.OrgX,Canvas.OrgY,Canvas.ClipX,Canvas.ClipY);
for( i=0; i<ItemRows.Length; ++i )
{
if( bCheckMouse && 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
{
}
52 changes: 52 additions & 0 deletions ServerExt/Classes/KFGUI_ScrollBarV_CD.uc
Original file line number Diff line number Diff line change
@@ -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
{
}
67 changes: 67 additions & 0 deletions ServerExt/Classes/KFGUI_Tooltip_CD.uc
Original file line number Diff line number Diff line change
@@ -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; i<Lines.Length; ++i )
{
if( Lines[i]!="" )
Canvas.TextSize(Lines[i],XS,YS);
TX = FMax(XS,TX);
}
TX*=TS;

// Give some borders.
TX += KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER*2;
TY += KF2Style(Owner.CurrentStyle).TOOLTIP_BORDER*2;

X = CompPos[0];
Y = CompPos[1]+24.f;

// Then check if too close to window edge, then move it to another pivot.
if( (X+TX)>Owner.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<Lines.Length; ++i )
{
Canvas.SetPos(X,Y);
Canvas.DrawText(Lines[i],,TS,TS,TextFontInfo);
Y+=Owner.CurrentStyle.DefaultHeight;
}
}

defaultproperties
{
}
Loading

0 comments on commit 032bf1c

Please sign in to comment.