KF2-Server-Extension/ServerExt/Classes/GUIStyleBase.uc

171 lines
3.9 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class GUIStyleBase extends Object
abstract;
var Texture2D ItemTex;
var() byte MaxFontScale;
var byte DefaultFontSize; // Default medium font size of current resolution.
var float DefaultHeight; // Default font text size.
var transient Canvas Canvas;
function InitStyle()
{
ItemTex = Texture2D(DynamicLoadObject("UI_LevelChevrons_TEX.UI_LevelChevron_Icon_02",class'Texture2D'));
2020-11-28 20:12:58 +00:00
if (ItemTex==None)
2017-10-20 02:00:49 +00:00
ItemTex = Texture2D'EngineMaterials.DefaultWhiteGrid';
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
function RenderFramedWindow(KFGUI_FloatingWindow P);
function RenderWindow(KFGUI_Page P);
function RenderToolTip(KFGUI_Tooltip TT);
function RenderButton(KFGUI_Button B);
function RenderEditBox(KFGUI_EditBox E);
function RenderScrollBar(KFGUI_ScrollBarBase S);
function RenderColumnHeader(KFGUI_ColumnTop C, float XPos, float Width, int Index, bool bFocus, bool bSort);
function RenderCheckbox(KFGUI_CheckBox C);
function RenderComboBox(KFGUI_ComboBox C);
function RenderComboList(KFGUI_ComboSelector C);
function RenderRightClickMenu(KFGUI_RightClickMenu C);
2017-10-20 02:00:49 +00:00
2020-11-28 20:04:55 +00:00
function Font PickFont(byte i, out float Scaler);
function PickDefaultFontSize(float YRes)
2017-10-20 02:00:49 +00:00
{
local int XL,YL;
local string S;
DefaultFontSize = 0;
2020-11-28 20:12:58 +00:00
if (YRes>800)
2017-10-20 02:00:49 +00:00
++DefaultFontSize;
2020-11-28 20:12:58 +00:00
if (YRes>1000)
2017-10-20 02:00:49 +00:00
++DefaultFontSize;
2020-11-28 20:12:58 +00:00
//if (YRes>1200)
//++DefaultFontSize;
2020-11-28 20:12:58 +00:00
//if (YRes>1300)
//++DefaultFontSize;
2017-10-20 02:00:49 +00:00
S = "ABC";
PickFont(DefaultFontSize,YRes).GetStringHeightAndWidth(S,YL,XL);
DefaultHeight = float(YL)*YRes;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function DrawText(byte Res, string S)
2017-10-20 02:00:49 +00:00
{
local float Scale;
Canvas.Font = PickFont(Res,Scale);
Canvas.DrawText(S,,Scale,Scale);
}
2020-11-28 20:04:55 +00:00
final function DrawCornerTexNU(int SizeX, int SizeY, byte Dir) // Draw non-uniform corner.
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
switch (Dir)
2017-10-20 02:00:49 +00:00
{
case 0: // Up-left
Canvas.DrawTile(ItemTex,SizeX,SizeY,77,15,-66,58);
break;
case 1: // Up-right
Canvas.DrawTile(ItemTex,SizeX,SizeY,11,15,66,58);
break;
case 2: // Down-left
Canvas.DrawTile(ItemTex,SizeX,SizeY,77,73,-66,-58);
break;
default: // Down-right
Canvas.DrawTile(ItemTex,SizeX,SizeY,11,73,66,-58);
}
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function DrawCornerTex(int Size, byte Dir)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
switch (Dir)
2017-10-20 02:00:49 +00:00
{
case 0: // Up-left
Canvas.DrawTile(ItemTex,Size,Size,77,15,-66,58);
break;
case 1: // Up-right
Canvas.DrawTile(ItemTex,Size,Size,11,15,66,58);
break;
case 2: // Down-left
Canvas.DrawTile(ItemTex,Size,Size,77,73,-66,-58);
break;
default: // Down-right
Canvas.DrawTile(ItemTex,Size,Size,11,73,66,-58);
}
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
final function DrawWhiteBox(int XS, int YS)
2017-10-20 02:00:49 +00:00
{
Canvas.DrawTile(ItemTex,XS,YS,19,45,1,1);
}
2020-11-28 20:04:55 +00:00
final function DrawRectBox(int X, int Y, int XS, int YS, int Edge, optional byte Extrav)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (Extrav==2)
2017-10-20 02:00:49 +00:00
Edge = Min(FMin(Edge,(XS)*0.5),YS);// Verify size.
else Edge = Min(FMin(Edge,(XS)*0.5),(YS)*0.5);// Verify size.
// Top left
Canvas.SetPos(X,Y);
DrawCornerTex(Edge,0);
2020-11-28 20:12:58 +00:00
if (Extrav<=1)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (Extrav==0)
2017-10-20 02:00:49 +00:00
{
// Top right
Canvas.SetPos(X+XS-Edge,Y);
DrawCornerTex(Edge,1);
// Bottom right
Canvas.SetPos(X+XS-Edge,Y+YS-Edge);
DrawCornerTex(Edge,3);
// Fill
Canvas.SetPos(X+Edge,Y);
DrawWhiteBox(XS-Edge*2,YS);
Canvas.SetPos(X,Y+Edge);
DrawWhiteBox(Edge,YS-Edge*2);
Canvas.SetPos(X+XS-Edge,Y+Edge);
DrawWhiteBox(Edge,YS-Edge*2);
}
2020-11-28 20:12:58 +00:00
else if (Extrav==1)
2017-10-20 02:00:49 +00:00
{
// Top right
Canvas.SetPos(X+XS,Y);
DrawCornerTex(Edge,3);
// Bottom right
Canvas.SetPos(X+XS,Y+YS-Edge);
DrawCornerTex(Edge,1);
// Fill
Canvas.SetPos(X+Edge,Y);
DrawWhiteBox(XS-Edge,YS);
Canvas.SetPos(X,Y+Edge);
DrawWhiteBox(Edge,YS-Edge*2);
}
// Bottom left
Canvas.SetPos(X,Y+YS-Edge);
DrawCornerTex(Edge,2);
}
else
{
// Top right
Canvas.SetPos(X+XS-Edge,Y);
DrawCornerTex(Edge,1);
// Bottom right
Canvas.SetPos(X+XS-Edge,Y+YS);
DrawCornerTex(Edge,2);
// Bottom left
Canvas.SetPos(X,Y+YS);
DrawCornerTex(Edge,3);
// Fill
Canvas.SetPos(X,Y+Edge);
DrawWhiteBox(XS,YS-Edge);
Canvas.SetPos(X+Edge,Y);
DrawWhiteBox(XS-Edge*2,Edge);
}
}