rename project

This commit is contained in:
2021-06-20 08:04:22 +03:00
parent 3df649a1bb
commit ac680456d8
69 changed files with 86 additions and 41 deletions

2
YAS/Build.uci Normal file
View File

@ -0,0 +1,2 @@
`define bEnableCallstack false
`define bEnableDebug false

411
YAS/Classes/ClassicStyle.uc Normal file
View File

@ -0,0 +1,411 @@
Class ClassicStyle extends KF2Style;
`include(Build.uci)
`include(Logger.uci)
function RenderFramedWindow(KFGUI_FloatingWindow P)
{
local int XS, YS, TitleHeight;
local float XL, YL, FontScale;
XS = Canvas.ClipX-Canvas.OrgX;
YS = Canvas.ClipY-Canvas.OrgY;
TitleHeight = DefaultHeight;
if (P.bWindowFocused)
Canvas.SetDrawColor(105, 105, 105, 255);
else Canvas.SetDrawColor(85, 85, 85, P.FrameOpacity);
// Frame Header
Canvas.SetPos(0, 0);
Canvas.DrawTileStretched(TabTextures[`TAB_TOP], XS, TitleHeight, 0,0, 128, 16);
// Frame itself.
Canvas.SetPos(0, TitleHeight);
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], XS, YS-TitleHeight, 0,0, 128, 128);
// Title.
if (P.WindowTitle != "")
{
Canvas.Font = PickFont(FontScale);
Canvas.TextSize(P.WindowTitle, XL, YL, FontScale, FontScale);
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos((XS*0.5)-(XL*0.5), 0);
Canvas.DrawText(P.WindowTitle, ,FontScale, FontScale);
}
}
function RenderWindow(KFGUI_Page P)
{
local int XS, YS;
XS = Canvas.ClipX-Canvas.OrgX;
YS = Canvas.ClipY-Canvas.OrgY;
// Frame itself.
if (P.bWindowFocused)
Canvas.SetDrawColor(105, 105, 105, 255);
else Canvas.SetDrawColor(85, 85, 85, P.FrameOpacity);
Canvas.SetPos(0, 0);
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], XS, YS, 0,0, 128, 128);
}
function RenderToolTip(KFGUI_Tooltip TT)
{
local int i;
local float X, Y,XS, YS, TX, TY, TS, DefFontHeight;
Canvas.Font = PickFont(TS);
// First compute textbox size.
TY = DefaultHeight*TT.Lines.Length;
for (i=0; i < TT.Lines.Length; ++i)
{
if (TT.Lines[i] != "")
Canvas.TextSize(TT.Lines[i], XS, YS);
TX = FMax(XS, TX);
}
TX*=TS;
// Give some borders.
TX += TOOLTIP_BORDER*2;
TY += TOOLTIP_BORDER*2;
X = TT.CompPos[0];
Y = TT.CompPos[1]+24.f;
// Then check if too close to window edge, then move it to another pivot.
if ((X+TX) > TT.Owner.ScreenSize.X)
X = TT.Owner.ScreenSize.X-TX;
if ((Y+TY) > TT.Owner.ScreenSize.Y)
Y = TT.CompPos[1]-TY;
if (TT.CurrentAlpha < 255)
TT.CurrentAlpha = Min(TT.CurrentAlpha+25, 255);
// Reset clipping.
Canvas.SetOrigin(0, 0);
Canvas.SetClip(TT.Owner.ScreenSize.X, TT.Owner.ScreenSize.Y);
// Draw frame.
Canvas.SetDrawColor(115, 115, 115, TT.CurrentAlpha);
Canvas.SetPos(X-2, Y-2);
DrawBoxHollow(X-2, Y-2, TX+4, TY+4, 2);
Canvas.SetDrawColor(5, 5,5, TT.CurrentAlpha);
Canvas.SetPos(X, Y);
DrawWhiteBox(TX, TY);
DefFontHeight = DefaultHeight;
// Draw text.
Canvas.SetDrawColor(255, 255, 255, TT.CurrentAlpha);
X+=TOOLTIP_BORDER;
Y+=TOOLTIP_BORDER;
for (i=0; i < TT.Lines.Length; ++i)
{
Canvas.SetPos(X, Y);
Canvas.DrawText(TT.Lines[i], ,TS, TS, TT.TextFontInfo);
Y+=DefFontHeight;
}
}
function RenderScrollBar(KFGUI_ScrollBarBase S)
{
local float A;
local byte i;
if (S.bDisabled)
Canvas.SetDrawColor(5, 5, 5, 0);
else if (S.bFocused || S.bGrabbedScroller)
Canvas.SetDrawColor(15, 15, 15, 160);
else Canvas.SetDrawColor(15, 15, 15, 160);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(BorderTextures[`BOX_INNERBORDER], S.CompPos[2], S.CompPos[3], 0,0, 128, 128);
if (S.bDisabled)
return;
if (S.bVertical)
i = 3;
else i = 2;
S.SliderScale = FMax(S.PageStep * (S.CompPos[i] - 32.f) / (S.MaxRange + S.PageStep), S.CalcButtonScale);
if (S.bGrabbedScroller)
{
// Track mouse.
if (S.bVertical)
A = S.Owner.MousePosition.Y - S.CompPos[1] - S.GrabbedOffset;
else A = S.Owner.MousePosition.X - S.CompPos[0] - S.GrabbedOffset;
A /= ((S.CompPos[i]-S.SliderScale) / float(S.MaxRange));
S.SetValue(A);
}
A = float(S.CurrentScroll) / float(S.MaxRange);
S.ButtonOffset = A*(S.CompPos[i]-S.SliderScale);
if (S.bGrabbedScroller)
Canvas.SetDrawColor(125, 125, 125, 200);
else if (S.bFocused)
Canvas.SetDrawColor(200, 200, 200, 200);
else Canvas.SetDrawColor(255, 255, 255, 200);
if (S.bVertical)
{
Canvas.SetPos(0.f, S.ButtonOffset);
Canvas.DrawTileStretched(ScrollTexture, S.CompPos[2], S.SliderScale, 0,0, 32, 32);
}
else
{
Canvas.SetPos(S.ButtonOffset, 0.f);
Canvas.DrawTileStretched(ScrollTexture, S.SliderScale, S.CompPos[3], 0,0, 32, 32);
}
}
function RenderCheckbox(KFGUI_CheckBox C)
{
local Texture CheckMark;
DrawTileStretched(ItemBoxTextures[`ITEMBOX_DISABLED], 0.f, 0.f, C.CompPos[2], C.CompPos[3]);
if (C.bChecked)
{
if (C.bDisabled)
CheckMark = CheckBoxTextures[`CHECKMARK_DISABLED];
else if (C.bFocused)
CheckMark = CheckBoxTextures[`CHECKMARK_HIGHLIGHTED];
else CheckMark = CheckBoxTextures[`CHECKMARK_NORMAL];
Canvas.SetDrawColor(255, 255, 255, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(CheckMark, C.CompPos[2], C.CompPos[3], 0,0, CheckMark.GetSurfaceWidth(), CheckMark.GetSurfaceHeight());
}
}
function RenderComboBox(KFGUI_ComboBox C)
{
if (C.bDisabled)
Canvas.SetDrawColor(64, 64, 64, 255);
else if (C.bPressedDown)
Canvas.SetDrawColor(220, 220, 220, 255);
else if (C.bFocused)
Canvas.SetDrawColor(190, 190, 190, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(BorderTextures[`BOX_INNERBORDER], C.CompPos[2], C.CompPos[3], 0,0, 128, 128);
DrawArrowBox(3, C.CompPos[2]-32, 0.5f, 32, 32);
if (C.SelectedIndex < C.Values.Length && C.Values[C.SelectedIndex] != "")
{
Canvas.SetPos(C.BorderSize, (C.CompPos[3]-C.TextHeight)*0.5);
if (C.bDisabled)
Canvas.DrawColor = C.TextColor*0.5f;
else Canvas.DrawColor = C.TextColor;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX-C.BorderSize, Canvas.ClipY);
Canvas.DrawText(C.Values[C.SelectedIndex], ,C.TextScale, C.TextScale, C.TextFontInfo);
Canvas.PopMaskRegion();
}
}
function RenderComboList(KFGUI_ComboSelector C)
{
local float X, Y,YL, YP, Edge;
local int i;
local bool bCheckMouse;
// Draw background.
Edge = C.Combo.BorderSize;
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], C.CompPos[2], C.CompPos[3], 0,0, 128, 128);
// While rendering, figure out mouse focus row.
X = C.Owner.MousePosition.X - Canvas.OrgX;
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
Canvas.Font = C.Combo.TextFont;
YL = C.Combo.TextHeight;
YP = Edge;
C.CurrentRow = -1;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX, Canvas.ClipY);
for (i=0; i < C.Combo.Values.Length; ++i)
{
if (bCheckMouse && Y >= YP && Y <= (YP+YL))
{
bCheckMouse = false;
C.CurrentRow = i;
Canvas.SetPos(4.f, YP);
Canvas.SetDrawColor(128, 48, 48, 255);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), YL);
}
Canvas.SetPos(Edge, YP);
if (i == C.Combo.SelectedIndex)
Canvas.DrawColor = C.Combo.SelectedTextColor;
else Canvas.DrawColor = C.Combo.TextColor;
Canvas.DrawText(C.Combo.Values[i], ,C.Combo.TextScale, C.Combo.TextScale, C.Combo.TextFontInfo);
YP+=YL;
}
Canvas.PopMaskRegion();
if (C.OldRow != C.CurrentRow)
{
C.OldRow = C.CurrentRow;
C.PlayMenuSound(MN_DropdownChange);
}
}
function RenderRightClickMenu(KFGUI_RightClickMenu C)
{
local float X, Y,XL, YL, YP, Edge, TextScale;
local int i;
local bool bCheckMouse;
local string S;
// Draw background.
Edge = C.EdgeSize;
DrawOutlinedBox(0.f, 0.f, C.CompPos[2], C.CompPos[3], Edge, C.BoxColor, C.OutlineColor);
// While rendering, figure out mouse focus row.
X = C.Owner.MousePosition.X - Canvas.OrgX;
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
PickFont(TextScale);
YP = Edge*2;
C.CurrentRow = -1;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX, Canvas.ClipY);
for (i=0; i < C.ItemRows.Length; ++i)
{
if (C.ItemRows[i].bSplitter)
S = "-------";
else S = C.ItemRows[i].Text;
Canvas.TextSize(S, XL, YL, TextScale, TextScale);
if (bCheckMouse && Y >= YP && Y <= (YP+YL))
{
bCheckMouse = false;
C.CurrentRow = i;
Canvas.SetPos(Edge, YP);
Canvas.SetDrawColor(128, 0,0, 255);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), YL);
}
Canvas.SetPos(Edge*6, YP);
if (C.ItemRows[i].bSplitter)
Canvas.SetDrawColor(255, 255, 255, 255);
else
{
if (C.ItemRows[i].bDisabled)
Canvas.SetDrawColor(148, 148, 148, 255);
else Canvas.SetDrawColor(248, 248, 248, 255);
}
Canvas.DrawText(S, ,TextScale, TextScale);
YP+=YL;
}
Canvas.PopMaskRegion();
if (C.OldRow != C.CurrentRow)
{
C.OldRow = C.CurrentRow;
C.PlayMenuSound(MN_FocusHover);
}
}
function RenderButton(KFGUI_Button B)
{
local float XL, YL, TS, AX, AY, GamepadTexSize;
local Texture2D Mat, ButtonTex;
local bool bDrawOverride;
bDrawOverride = B.DrawOverride(Canvas, B);
if (!bDrawOverride)
{
if (B.bDisabled)
Mat = ButtonTextures[`BUTTON_DISABLED];
else if (B.bPressedDown)
Mat = ButtonTextures[`BUTTON_PRESSED];
else if (B.bFocused || B.bIsHighlighted)
Mat = ButtonTextures[`BUTTON_HIGHLIGHTED];
else Mat = ButtonTextures[`BUTTON_NORMAL];
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Mat, B.CompPos[2], B.CompPos[3], 0,0, 32, 32);
if (B.OverlayTexture.Texture != None)
{
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(B.OverlayTexture.Texture, B.CompPos[2], B.CompPos[3], B.OverlayTexture.U, B.OverlayTexture.V, B.OverlayTexture.UL, B.OverlayTexture.VL);
}
}
if (B.ButtonText != "")
{
Canvas.Font = MainFont;
GamepadTexSize = B.CompPos[3] / 1.25;
TS = GetFontScaler();
TS *= B.FontScale;
while (true)
{
Canvas.TextSize(B.ButtonText, XL, YL, TS, TS);
if (XL < (B.CompPos[2]*0.9) && YL < (B.CompPos[3]*0.9))
break;
TS -= 0.001;
}
Canvas.SetPos((B.CompPos[2]-XL)*0.5, (B.CompPos[3]-YL)*0.5);
if (B.bDisabled)
Canvas.DrawColor = B.TextColor*0.5f;
else Canvas.DrawColor = B.TextColor;
Canvas.DrawText(B.ButtonText, ,TS, TS, B.TextFontInfo);
if (B.GetUsingGamepad())
{
ButtonTex = Texture2D(DynamicLoadObject("UI_Controller."$B.GamepadButtonName$"_Asset", class'Texture2D'));
if (ButtonTex != None)
{
B.GetRealtivePos(AX, AY);
while ((Canvas.CurX-(GamepadTexSize*1.25)) < AX)
{
GamepadTexSize *= 0.95;
}
switch (ButtonTex.Name)
{
case 'XboxTypeS_A_Asset':
case 'XboxTypeS_B_Asset':
case 'XboxTypeS_X_Asset':
case 'XboxTypeS_Y_Asset':
Canvas.SetDrawColor(255, 255, 255, 145);
break;
default:
Canvas.SetDrawColor(0, 0, 0, 145);
break;
}
Canvas.SetPos(Canvas.CurX-(GamepadTexSize*1.25), (B.CompPos[3]-GamepadTexSize)*0.5);
Canvas.DrawRect(GamepadTexSize, GamepadTexSize, ButtonTex);
}
}
}
}
defaultproperties
{
}

View File

@ -0,0 +1,8 @@
class CustomRanks extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config array<RankInfo> Rank;

View File

@ -0,0 +1,66 @@
class DynamicLevelColor extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config bool bEnabled;
var config int Normal_Low;
var config int Normal_High;
var config int Hard_Low;
var config int Hard_High;
var config int Suicide_Low;
var config int Suicide_High;
var config int HellOnEarth_Low;
var config int HellOnEarth_High;
public static function SCESettingsLevel DefaultSettings()
{
local SCESettingsLevel Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCESettingsLevel Settings()
{
local SCESettingsLevel Settings;
`callstack_static("Settings");
Settings.Dynamic = default.bEnabled;
Settings.Low[0] = default.Normal_Low;
Settings.High[0] = default.Normal_High;
Settings.Low[1] = default.Hard_Low;
Settings.High[1] = default.Hard_High;
Settings.Low[2] = default.Suicide_Low;
Settings.High[2] = default.Suicide_High;
Settings.Low[3] = default.HellOnEarth_Low;
Settings.High[3] = default.HellOnEarth_High;
return Settings;
}
public static function WriteSettings(SCESettingsLevel Settings)
{
`callstack_static("WriteSettings");
default.bEnabled = Settings.Dynamic;
default.Normal_Low = Settings.Low[0];
default.Normal_High = Settings.High[0];
default.Hard_Low = Settings.Low[1];
default.Hard_High = Settings.High[1];
default.Suicide_Low = Settings.Low[2];
default.Suicide_High = Settings.High[2];
default.HellOnEarth_Low = Settings.Low[3];
default.HellOnEarth_High = Settings.High[3];
StaticSaveConfig();
}
DefaultProperties
{
}

View File

@ -0,0 +1,51 @@
class DynamicPingColor extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config bool bEnabled;
var config int Low;
var config int High;
var config bool bShowPingBars;
public static function SCESettingsPing DefaultSettings()
{
local SCESettingsPing Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCESettingsPing Settings()
{
local SCESettingsPing Settings;
`callstack_static("Settings");
Settings.Dynamic = default.bEnabled;
Settings.Low = default.Low;
Settings.High = default.High;
Settings.ShowPingBars = default.bShowPingBars;
return Settings;
}
public static function WriteSettings(SCESettingsPing Settings)
{
`callstack_static("WriteSettings");
default.bEnabled = Settings.Dynamic;
default.Low = Settings.Low;
default.High = Settings.High;
default.bShowPingBars = Settings.ShowPingBars;
StaticSaveConfig();
}
DefaultProperties
{
}

View File

@ -0,0 +1,48 @@
class DynamicStateColor extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config bool bEnabled;
var config int Low;
var config int High;
public static function SCESettingsState DefaultSettings()
{
local SCESettingsState Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCESettingsState Settings()
{
local SCESettingsState Settings;
`callstack_static("Settings");
Settings.Dynamic = default.bEnabled;
Settings.Low = default.Low;
Settings.High = default.High;
return Settings;
}
public static function WriteSettings(SCESettingsState Settings)
{
`callstack_static("WriteSettings");
default.bEnabled = Settings.Dynamic;
default.Low = Settings.Low;
default.High = Settings.High;
StaticSaveConfig();
}
DefaultProperties
{
}

1466
YAS/Classes/GUIStyleBase.uc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,900 @@
Class KF2GUIController extends Info
transient;
`include(Build.uci)
`include(Logger.uci)
var() class<GUIStyleBase> DefaultStyle;
var PlayerController PlayerOwner;
var YASHUD HUDOwner;
var transient KF2GUIInput CustomInput;
var transient PlayerInput BackupInput;
var transient GameViewportClient ClientViewport;
var delegate<Interaction.OnReceivedNativeInputKey> OldOnReceivedNativeInputKey;
var delegate<Interaction.OnReceivedNativeInputAxis> OldOnReceivedNativeInputAxis;
var delegate<Interaction.OnReceivedNativeInputChar> OldOnReceivedNativeInputChar;
var delegate<GameViewportClient.HandleInputAxis> OldHandleInputAxis;
var array<KFGUI_Page> ActiveMenus, PersistentMenus;
var transient KFGUI_Base MouseFocus, InputFocus, KeyboardFocus;
var IntPoint MousePosition, ScreenSize, OldMousePos, LastMousePos, LastClickPos[2];
var transient float MousePauseTime, MenuTime, LastClickTimes[2];
var transient GUIStyleBase CurrentStyle;
var transient Console OrgConsole;
var transient KFGUIConsoleHack HackConsole;
var array<Texture2D> CursorTextures;
var Color CursorColor;
var int CurrentCursorIndex, CursorSize;
var Texture DefaultPens[3];
var byte CursorFade, FastCursorFade, CursorFlash;
var int CursorStep, FastCursorStep;
var int FontBlurX, FontBlurX2, FontBlurY, FontBlurY2, FastFontBlurX, FastFontBlurX2, FastFontBlurY, FastFontBlurY2;
var bool bMouseWasIdle, bIsInMenuState, bAbsorbInput, bIsInvalid, bHideCursor, bUsingGamepad, bForceEngineCursor, bNoInputReset;
static function KF2GUIController GetGUIController(PlayerController PC)
{
local KF2GUIController G;
if (PC.Player == None)
{
return None;
}
foreach PC.ChildActors(class'YAS.KF2GUIController', G)
{
if (!G.bIsInvalid)
{
break;
}
}
if (G == None)
{
G = PC.Spawn(class'YAS.KF2GUIController', PC);
}
return G;
}
simulated function PostBeginPlay()
{
PlayerOwner = PlayerController(Owner);
ClientViewport = LocalPlayer(PlayerOwner.Player).ViewportClient;
HUDOwner = YASHUD(PlayerOwner.myHUD);
CurrentStyle = new (None) DefaultStyle;
CurrentStyle.InitStyle();
CurrentStyle.Owner = self;
SetTimer(0.1, true, 'SetupFontBlur');
SetTimer(0.05, true, 'SetupFastFontBlur');
SetTimer(0.75, true, 'SetupCursorFlash');
}
simulated function SetupCursorFlash()
{
if (CursorFlash == 255)
CursorFlash = 0;
else CursorFlash = 255;
}
simulated function SetupFastFontBlur()
{
FastFontBlurX = RandRange(-8, 8);
FastFontBlurX2 = RandRange(-8, 8);
FastFontBlurY = RandRange(-8, 8);
FastFontBlurY2 = RandRange(-8, 8);
}
simulated function SetupFontBlur()
{
FontBlurX = RandRange(-8, 8);
FontBlurX2 = RandRange(-8, 8);
FontBlurY = RandRange(-8, 8);
FontBlurY2 = RandRange(-8, 8);
}
simulated function Tick(float DT)
{
Super.Tick(DT);
DT /= WorldInfo.TimeDilation;
CursorFade += 255 * DT * CursorStep;
if (CursorFade <= 0)
{
CursorFade = 0;
CursorStep = 1;
}
else if (CursorFade >= 255)
{
CursorFade = 255;
CursorStep = -1;
}
FastCursorFade += 8192 * DT * FastCursorStep;
if (FastCursorFade <= 0)
{
FastCursorFade = 0;
FastCursorStep = 1;
}
else if (FastCursorFade >= 255)
{
FastCursorFade = 255;
FastCursorStep = -1;
}
}
simulated function Destroyed()
{
if (PlayerOwner != None)
SetMenuState(false);
}
simulated function HandleDrawMenu()
{
if (HackConsole == None)
{
HackConsole = new(ClientViewport)class'YAS.KFGUIConsoleHack';
HackConsole.OutputObject = Self;
}
if (HackConsole != ClientViewport.ViewportConsole)
{
OrgConsole = ClientViewport.ViewportConsole;
ClientViewport.ViewportConsole = HackConsole;
// Make sure nothing overrides these settings while menu is being open.
if (bIsInMenuState ) PlayerOwner.PlayerInput = CustomInput;
}
}
simulated function RenderMenu(Canvas C)
{
local int i;
local float OrgX, OrgY, ClipX, ClipY;
ClientViewport.ViewportConsole = OrgConsole;
OrgX = C.OrgX;
OrgY = C.OrgY;
ClipX = C.ClipX;
ClipY = C.ClipY;
ScreenSize.X = C.SizeX;
ScreenSize.Y = C.SizeY;
CurrentStyle.Canvas = C;
CurrentStyle.PickDefaultFontSize(C.SizeY);
if (!KFPlayerController(PlayerOwner).MyGFxManager.bMenusActive)
{
HUDOwner.Canvas = C;
for (i=(HUDOwner.HUDWidgets.Length-1); i >= 0; --i)
{
HUDOwner.HUDWidgets[i].InputPos[0] = 0.f;
HUDOwner.HUDWidgets[i].InputPos[1] = 0.f;
HUDOwner.HUDWidgets[i].InputPos[2] = ScreenSize.X;
HUDOwner.HUDWidgets[i].InputPos[3] = ScreenSize.Y;
HUDOwner.HUDWidgets[i].Canvas = C;
HUDOwner.HUDWidgets[i].PreDraw();
}
C.SetOrigin(OrgX, OrgY);
C.SetClip(ClipX, ClipY);
}
if (bIsInMenuState)
{
for (i=(ActiveMenus.Length-1); i >= 0; --i)
{
ActiveMenus[i].bWindowFocused = (i == 0);
ActiveMenus[i].InputPos[0] = 0.f;
ActiveMenus[i].InputPos[1] = 0.f;
ActiveMenus[i].InputPos[2] = ScreenSize.X;
ActiveMenus[i].InputPos[3] = ScreenSize.Y;
ActiveMenus[i].Canvas = C;
ActiveMenus[i].PreDraw();
}
if (InputFocus != None && InputFocus.bFocusedPostDrawItem)
{
InputFocus.InputPos[0] = 0.f;
InputFocus.InputPos[1] = 0.f;
InputFocus.InputPos[2] = ScreenSize.X;
InputFocus.InputPos[3] = ScreenSize.Y;
InputFocus.Canvas = C;
InputFocus.PreDraw();
}
C.SetOrigin(OrgX, OrgY);
C.SetClip(ClipX, ClipY);
if (!bHideCursor)
{
DrawCursor(C, MousePosition.X, MousePosition.Y);
}
}
if (OrgConsole != None)
OrgConsole.PostRender_Console(C);
OrgConsole = None;
}
simulated function DrawCursor(Canvas C, float PosX, float PosY)
{
C.SetPos(PosX, PosY);
C.DrawColor = CursorColor;
C.DrawTile(CursorTextures[CurrentCursorIndex], CurrentStyle.ScreenScale(CursorSize), CurrentStyle.ScreenScale(CursorSize), 0.f, 0.f, CursorTextures[CurrentCursorIndex].SizeX, CursorTextures[CurrentCursorIndex].SizeY, , true);
}
simulated final function InventoryChanged(optional KFWeapon Wep, optional bool bRemove)
{
local int i;
for (i=(ActiveMenus.Length-1); i >= 0; --i)
{
ActiveMenus[i].InventoryChanged(Wep, bRemove);
}
}
simulated final function SetMenuState(bool bActive)
{
if (PlayerOwner.PlayerInput == None)
{
NotifyLevelChange();
bActive = false;
}
if (bIsInMenuState == bActive)
return;
bIsInMenuState = bActive;
bHideCursor = !bActive;
if (bActive)
{
if (CustomInput == None)
{
CustomInput = new (KFPlayerController(PlayerOwner)) class'YAS.KF2GUIInput';
CustomInput.ControllerOwner = Self;
CustomInput.OnReceivedNativeInputKey = ReceivedInputKey;
CustomInput.BaseInput = PlayerOwner.PlayerInput;
BackupInput = PlayerOwner.PlayerInput;
PlayerOwner.Interactions.AddItem(CustomInput);
}
OldOnReceivedNativeInputKey = BackupInput.OnReceivedNativeInputKey;
OldOnReceivedNativeInputAxis = BackupInput.OnReceivedNativeInputAxis;
OldOnReceivedNativeInputChar = BackupInput.OnReceivedNativeInputChar;
BackupInput.OnReceivedNativeInputKey = ReceivedInputKey;
BackupInput.OnReceivedNativeInputAxis = ReceivedInputAxis;
BackupInput.OnReceivedNativeInputChar = ReceivedInputChar;
OldHandleInputAxis = ClientViewport.HandleInputAxis;
ClientViewport.HandleInputAxis = ReceivedInputAxis;
PlayerOwner.PlayerInput = CustomInput;
if (LastMousePos != default.LastMousePos)
ClientViewport.SetMouse(LastMousePos.X, LastMousePos.Y);
}
else
{
LastMousePos = MousePosition;
ClientViewport.HandleInputAxis = None;
if (BackupInput != None)
{
PlayerOwner.PlayerInput = BackupInput;
BackupInput.OnReceivedNativeInputKey = OldOnReceivedNativeInputKey;
BackupInput.OnReceivedNativeInputAxis = OldOnReceivedNativeInputAxis;
BackupInput.OnReceivedNativeInputChar = OldOnReceivedNativeInputChar;
ClientViewport.HandleInputAxis = OldHandleInputAxis;
}
LastClickTimes[0] = 0;
LastClickTimes[1] = 0;
}
if (!bNoInputReset)
{
PlayerOwner.PlayerInput.ResetInput();
}
}
simulated function NotifyLevelChange()
{
local int i;
if (bIsInvalid)
return;
bIsInvalid = true;
if (InputFocus != None)
{
InputFocus.LostInputFocus();
InputFocus = None;
}
for (i=(ActiveMenus.Length-1); i >= 0; --i)
ActiveMenus[i].NotifyLevelChange();
for (i=(PersistentMenus.Length-1); i >= 0; --i)
PersistentMenus[i].NotifyLevelChange();
SetMenuState(false);
}
simulated function MenuInput(float DeltaTime)
{
local int i;
local vector2D V;
if (PlayerOwner.PlayerInput == None)
{
NotifyLevelChange();
return;
}
if (InputFocus != None)
InputFocus.MenuTick(DeltaTime);
for (i=0; i < ActiveMenus.Length; ++i)
ActiveMenus[i].MenuTick(DeltaTime);
// Check idle.
if (Abs(MousePosition.X-OldMousePos.X) > 5.f || Abs(MousePosition.Y-OldMousePos.Y) > 5.f || (bMouseWasIdle && MousePauseTime < 0.5f))
{
if (bMouseWasIdle)
{
bMouseWasIdle = false;
if (InputFocus != None)
InputFocus.InputMouseMoved();
}
OldMousePos = MousePosition;
MousePauseTime = 0.f;
}
else if (!bMouseWasIdle && (MousePauseTime+=DeltaTime) > 0.5f)
{
bMouseWasIdle = true;
if (MouseFocus != None)
MouseFocus.NotifyMousePaused();
}
if (ActiveMenus.Length > 0)
MenuTime+=DeltaTime;
V = ClientViewport.GetMousePosition();
MousePosition.X = Clamp(V.X, 0, ScreenSize.X);
MousePosition.Y = Clamp(V.Y, 0, ScreenSize.Y);
MouseMove();
}
simulated function MouseMove()
{
local int i;
local KFGUI_Base F;
// Capture mouse for GUI
if (InputFocus != None && InputFocus.bCanFocus)
{
if (InputFocus.CaptureMouse())
{
F = InputFocus.GetMouseFocus();
if (F != MouseFocus)
{
MousePauseTime = 0;
if (MouseFocus != None)
MouseFocus.MouseLeave();
MouseFocus = F;
F.MouseEnter();
}
}
else i = ActiveMenus.Length;
}
else
{
for (i=0; i < ActiveMenus.Length; ++i)
{
if (ActiveMenus[i].CaptureMouse())
{
F = ActiveMenus[i].GetMouseFocus();
if (F != MouseFocus)
{
MousePauseTime = 0;
if (MouseFocus != None)
MouseFocus.MouseLeave();
MouseFocus = F;
F.MouseEnter();
}
break;
}
else if (ActiveMenus[i].bOnlyThisFocus ) // Discard any other menus after this one.
{
i = ActiveMenus.Length;
break;
}
}
}
if (MouseFocus != None && i == ActiveMenus.Length ) // Hovering over nothing.
{
MousePauseTime = 0;
if (MouseFocus != None)
MouseFocus.MouseLeave();
MouseFocus = None;
}
}
simulated final function int GetFreeIndex(bool bNewAlwaysTop ) // Find first allowed top index of the stack.
{
local int i;
for (i=0; i < ActiveMenus.Length; ++i)
if (bNewAlwaysTop || !ActiveMenus[i].bAlwaysTop)
{
ActiveMenus.Insert(i, 1);
return i;
}
i = ActiveMenus.Length;
ActiveMenus.Length = i+1;
return i;
}
simulated function KFGUI_Base InitializeHUDWidget(class<KFGUI_Base> GUIClass)
{
local KFGUI_Base Widget;
if (GUIClass == None)
return None;
Widget = New(None) GUIClass;
if (Widget == None)
return None;
HUDOwner.HUDWidgets.AddItem(Widget);
Widget.Owner = Self;
Widget.HUDOwner = HUDOwner;
Widget.InitMenu();
Widget.ShowMenu();
Widget.bIsHUDWidget = true;
return Widget;
}
simulated function KFGUI_Page OpenMenu(class<KFGUI_Page> MenuClass)
{
local int i;
local KFGUI_Page M;
if (MenuClass == None)
return None;
if (KeyboardFocus != None)
GrabInputFocus(None);
if (InputFocus != None)
{
InputFocus.LostInputFocus();
InputFocus = None;
}
// Enable mouse on UI if disabled.
SetMenuState(true);
// Check if should use pre-excisting menu.
if (MenuClass.Default.bUnique)
{
for (i=0; i < ActiveMenus.Length; ++i)
if (ActiveMenus[i].Class == MenuClass)
{
if (i > 0 && ActiveMenus[i].BringPageToFront() ) // Sort it upfront.
{
M = ActiveMenus[i];
ActiveMenus.Remove(i, 1);
i = GetFreeIndex(M.bAlwaysTop);
ActiveMenus[i] = M;
}
return M;
}
if (MenuClass.Default.bPersistant)
{
for (i=0; i < PersistentMenus.Length; ++i)
if (PersistentMenus[i].Class == MenuClass)
{
M = PersistentMenus[i];
PersistentMenus.Remove(i, 1);
i = GetFreeIndex(M.bAlwaysTop);
ActiveMenus[i] = M;
M.ShowMenu();
return M;
}
}
}
M = New(None)MenuClass;
if (M == None ) // Probably abstract class.
return None;
i = GetFreeIndex(M.bAlwaysTop);
ActiveMenus[i] = M;
M.Owner = Self;
M.InitMenu();
M.ShowMenu();
return M;
}
simulated function CloseMenu(class<KFGUI_Page> MenuClass, optional bool bCloseAll)
{
local int i, j;
local KFGUI_Page M;
if (!bCloseAll && MenuClass == None)
return;
if (KeyboardFocus != None)
GrabInputFocus(None);
if (InputFocus != None)
{
InputFocus.LostInputFocus();
InputFocus = None;
}
for (i=(ActiveMenus.Length-1); i >= 0; --i)
{
if (bCloseAll || ActiveMenus[i].Class == MenuClass)
{
M = ActiveMenus[i];
ActiveMenus.Remove(i, 1);
M.CloseMenu();
for (j=0; j < M.TimerNames.Length; j++)
{
M.ClearTimer(M.TimerNames[j]);
}
// Cache menu.
if (M.bPersistant && M.bUnique)
PersistentMenus[PersistentMenus.Length] = M;
}
}
if (ActiveMenus.Length == 0)
{
SetMenuState(false);
}
}
simulated function PopCloseMenu(KFGUI_Base Item)
{
local int i;
local KFGUI_Page M;
if (Item == None)
return;
if (Item.bIsHUDWidget)
{
HUDOwner.HUDWidgets.RemoveItem(Item);
Item.CloseMenu();
return;
}
if (KeyboardFocus != None)
GrabInputFocus(None);
if (InputFocus != None)
{
InputFocus.LostInputFocus();
InputFocus = None;
}
for (i=(ActiveMenus.Length-1); i >= 0; --i)
if (ActiveMenus[i] == Item)
{
M = ActiveMenus[i];
ActiveMenus.Remove(i, 1);
M.CloseMenu();
// Cache menu.
if (M.bPersistant && M.bUnique)
PersistentMenus[PersistentMenus.Length] = M;
break;
}
if (ActiveMenus.Length == 0)
SetMenuState(false);
}
simulated function BringMenuToFront(KFGUI_Page Page)
{
local int i;
if (ActiveMenus[0].bAlwaysTop && !Page.bAlwaysTop)
return; // Can't override this menu.
// Try to remove from current position at stack.
for (i=(ActiveMenus.Length-1); i >= 0; --i)
if (ActiveMenus[i] == Page)
{
ActiveMenus.Remove(i, 1);
break;
}
if (i == -1)
return; // Page isn't open.
// Put on front of stack.
ActiveMenus.Insert(0, 1);
ActiveMenus[0] = Page;
}
simulated final function bool MenuIsOpen(optional class<KFGUI_Page> MenuClass)
{
local int i;
for (i=(ActiveMenus.Length-1); i >= 0; --i)
if (MenuClass == None || ActiveMenus[i].Class == MenuClass)
return true;
return false;
}
simulated final function GrabInputFocus(KFGUI_Base Comp, optional bool bForce)
{
if (Comp == KeyboardFocus && !bForce)
return;
if (KeyboardFocus != None)
KeyboardFocus.LostKeyFocus();
if (Comp == None)
{
OnInputKey = InternalInputKey;
OnReceivedInputChar = InternalReceivedInputChar;
}
else if (KeyboardFocus == None)
{
OnInputKey = Comp.NotifyInputKey;
OnReceivedInputChar = Comp.NotifyInputChar;
OnReceivedInputAxis = Comp.NotifyInputAxis;
}
KeyboardFocus = Comp;
}
simulated final function GUI_InputMouse(bool bPressed, bool bRight)
{
local byte i;
MousePauseTime = 0;
if (bPressed)
{
if (KeyboardFocus != None && KeyboardFocus != MouseFocus)
{
GrabInputFocus(None);
LastClickTimes[0] = 0;
LastClickTimes[1] = 0;
}
if (MouseFocus != None)
{
if (MouseFocus != InputFocus && !MouseFocus.bClickable && !MouseFocus.IsTopMenu() && MouseFocus.BringPageToFront())
{
BringMenuToFront(MouseFocus.GetPageTop());
LastClickTimes[0] = 0;
LastClickTimes[1] = 0;
}
else
{
i = byte(bRight);
if ((MenuTime-LastClickTimes[i]) < 0.2 && Abs(LastClickPos[i].X-MousePosition.X) < 5 && Abs(LastClickPos[i].Y-MousePosition.Y) < 5)
{
LastClickTimes[i] = 0;
MouseFocus.DoubleMouseClick(bRight);
}
else
{
MouseFocus.MouseClick(bRight);
LastClickTimes[i] = MenuTime;
LastClickPos[i] = MousePosition;
}
}
}
else if (InputFocus != None)
{
InputFocus.LostInputFocus();
InputFocus = None;
LastClickTimes[0] = 0;
LastClickTimes[1] = 0;
}
}
else
{
if (InputFocus != None)
InputFocus.MouseRelease(bRight);
else if (MouseFocus != None)
MouseFocus.MouseRelease(bRight);
}
}
simulated final function bool CheckMouse(name Key, EInputEvent Event)
{
if (Event == IE_Pressed)
{
switch (Key)
{
case 'XboxTypeS_A':
case 'LeftMouseButton':
GUI_InputMouse(true, false);
return true;
case 'XboxTypeS_B':
case 'RightMouseButton':
GUI_InputMouse(true, true);
return true;
}
}
else if (Event == IE_Released)
{
switch (Key)
{
case 'XboxTypeS_A':
case 'LeftMouseButton':
GUI_InputMouse(false, false);
return true;
case 'XboxTypeS_B':
case 'RightMouseButton':
GUI_InputMouse(false, true);
return true;
}
}
return false;
}
simulated function bool ReceivedInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
{
local KFPlayerInput KFInput;
local KeyBind BoundKey;
if (!bIsInMenuState)
return false;
bUsingGamepad = bGamepad;
KFInput = KFPlayerInput(BackupInput);
if (KFInput == None)
{
KFInput = KFPlayerInput(PlayerOwner.PlayerInput);
}
if (KeyboardFocus == None)
{
if (KFInput != None)
{
KFInput.GetKeyBindFromCommand(BoundKey, "GBA_VoiceChat", false);
if (string(Key) ~= KFInput.GetBindDisplayName(BoundKey))
{
if (Event == IE_Pressed)
{
KFInput.StartVoiceChat(true);
}
else if (Event == IE_Released)
{
KFInput.StopVoiceChat();
}
return true;
}
}
}
if (!CheckMouse(Key, Event) && !OnInputKey(ControllerId, Key, Event, AmountDepressed, bGamepad))
{
if (bGamepad)
{
if (ActiveMenus[0].ReceievedControllerInput(ControllerId, Key, Event))
return true;
}
switch (Key)
{
case 'XboxTypeS_Start':
case 'Escape':
if (Event == IE_Pressed)
ActiveMenus[0].UserPressedEsc(); // Pop top menu if possible. // IE_Released
return true;
case 'XboxTypeS_DPad_Up':
case 'XboxTypeS_DPad_Down':
case 'XboxTypeS_DPad_Left':
case 'XboxTypeS_DPad_Right':
case 'MouseScrollDown':
case 'MouseScrollUp':
if (Event == IE_Pressed && MouseFocus != None)
MouseFocus.ScrollMouseWheel(Key == 'MouseScrollUp' || Key == 'XboxTypeS_DPad_Up' || Key == 'XboxTypeS_DPad_Left');
return true;
}
return bAbsorbInput;
}
return true;
}
simulated function bool ReceivedInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
{
local Vector2D V;
local KFPlayerInput KFInput;
local float GamepadSensitivity, OldMouseX, OldMouseY, MoveDelta, MoveDeltaInvert;
if (!bIsInMenuState)
return false;
if (bGamepad )
{
if (Abs(Delta) > 0.2f)
{
bUsingGamepad = true;
V = ClientViewport.GetMousePosition();
OldMouseX = V.X;
OldMouseY = V.Y;
KFInput = KFPlayerInput(BackupInput);
GamepadSensitivity = KFInput.GamepadSensitivityScale * 10;
MoveDelta = Delta * (KFInput.bInvertController ? -GamepadSensitivity : GamepadSensitivity);
MoveDeltaInvert = Delta * (KFInput.bInvertController ? GamepadSensitivity : -GamepadSensitivity);
switch (Key)
{
case 'XboxTypeS_LeftX':
case 'XboxTypeS_RightX':
if (Delta < 0)
V.X = Clamp(V.X - MoveDeltaInvert, 0, ScreenSize.X);
else V.X = Clamp(V.X + MoveDelta, 0, ScreenSize.X);
break;
case 'XboxTypeS_LeftY':
if (Delta < 0)
V.Y = Clamp(V.Y + MoveDeltaInvert, 0, ScreenSize.Y);
else V.Y = Clamp(V.Y - MoveDelta, 0, ScreenSize.Y);
break;
case 'XboxTypeS_RightY':
if (Delta < 0)
V.Y = Clamp(V.Y - MoveDeltaInvert, 0, ScreenSize.Y);
else V.Y = Clamp(V.Y + MoveDelta, 0, ScreenSize.Y);
break;
}
if (OldMouseX != V.X || OldMouseY != V.Y)
ClientViewport.SetMouse(V.X, V.Y);
}
}
return OnReceivedInputAxis(ControllerId, Key, Delta, DeltaTime, bGamepad);
}
simulated function bool ReceivedInputChar(int ControllerId, string Unicode)
{
if (!bIsInMenuState)
return false;
return OnReceivedInputChar(ControllerId, Unicode);
}
simulated Delegate bool OnInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
{
return false;
}
simulated Delegate bool OnReceivedInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
{
return false;
}
simulated Delegate bool OnReceivedInputChar(int ControllerId, string Unicode)
{
return false;
}
simulated Delegate bool InternalInputKey(int ControllerId, name Key, EInputEvent Event, optional float AmountDepressed=1.f, optional bool bGamepad)
{
return false;
}
simulated Delegate bool InternalReceivedInputChar(int ControllerId, string Unicode)
{
return false;
}
defaultproperties
{
CursorSize=24
CursorColor=(R=255, G=255, B=255, A=255)
CursorTextures[`CURSOR_DEFAULT]=Texture2D'UI_Managers.LoaderManager_SWF_I13'
CurrentCursorIndex=`CURSOR_DEFAULT
DefaultStyle=class'ClassicStyle'
bAbsorbInput=true
bAlwaysTick=true
bHideCursor=true
}

View File

@ -0,0 +1,66 @@
// Input while in a menu.
class KF2GUIInput extends KFPlayerInput;
`include(Build.uci)
`include(Logger.uci)
var KF2GUIController ControllerOwner;
var PlayerInput BaseInput;
function DrawHUD(HUD H)
{
//ControllerOwner.RenderMenu(H.Canvas);
}
function PostRender(Canvas Canvas)
{
if (ControllerOwner.bIsInMenuState)
ControllerOwner.HandleDrawMenu();
//ControllerOwner.RenderMenu(Canvas);
}
// Postprocess the player's input.
function PlayerInput(float DeltaTime)
{
// Do not move.
ControllerOwner.MenuInput(DeltaTime);
if (!ControllerOwner.bAbsorbInput)
{
aMouseX = 0;
aMouseY = 0;
aBaseX = BaseInput.aBaseX;
aBaseY = BaseInput.aBaseY;
aBaseZ = BaseInput.aBaseZ;
aForward = BaseInput.aForward;
aTurn = BaseInput.aTurn;
aStrafe = BaseInput.aStrafe;
aUp = BaseInput.aUp;
aLookUp = BaseInput.aLookUp;
Super.PlayerInput(DeltaTime);
}
else
{
aMouseX = 0;
aMouseY = 0;
aBaseX = 0;
aBaseY = 0;
aBaseZ = 0;
aForward = 0;
aTurn = 0;
aStrafe = 0;
aUp = 0;
aLookUp = 0;
}
}
function PreClientTravel(string PendingURL, ETravelType TravelType, bool bIsSeamlessTravel)
{
`Log("PreClientTravel"@PendingURL@TravelType@bIsSeamlessTravel);
ControllerOwner.BackupInput.PreClientTravel(PendingURL, TravelType, bIsSeamlessTravel); // Let original mod do stuff too!
ControllerOwner.NotifyLevelChange(); // Close menu NOW!
}
defaultproperties
{
}

455
YAS/Classes/KF2Style.uc Normal file
View File

@ -0,0 +1,455 @@
Class KF2Style extends GUIStyleBase;
`include(Build.uci)
`include(Logger.uci)
var Texture2D LoadedTex[2];
const TOOLTIP_BORDER=4;
function InitStyle()
{
local byte i;
Super.InitStyle();
LoadedTex[0] = Texture2D(DynamicLoadObject("EditorMaterials.CASC_ModuleEnable", class'Texture2D'));
LoadedTex[1] = Texture2D(DynamicLoadObject("EditorMaterials.Tick", class'Texture2D'));
for (i=0; i < ArrayCount(LoadedTex); ++i)
{
if (LoadedTex[i] == None)
LoadedTex[i] = Texture2D'EngineMaterials.DefaultWhiteGrid';
}
}
function RenderFramedWindow(KFGUI_FloatingWindow P)
{
local int XS, YS, CornerSlope, TitleHeight;
XS = Canvas.ClipX-Canvas.OrgX;
YS = Canvas.ClipY-Canvas.OrgY;
CornerSlope = DefaultHeight*0.4;
TitleHeight = DefaultHeight;
// Frame Header
if (P.bWindowFocused)
Canvas.SetDrawColor(220, 2,2, 255);
else Canvas.SetDrawColor(100, 1,1, P.FrameOpacity);
Canvas.SetPos(0, 0);
DrawCornerTex(CornerSlope, 0);
Canvas.SetPos(0, TitleHeight);
DrawCornerTex(CornerSlope, 3);
Canvas.SetPos(XS-CornerSlope, 0);
DrawCornerTex(CornerSlope, 1);
Canvas.SetPos(XS-CornerSlope, TitleHeight);
DrawCornerTex(CornerSlope, 2);
// Header filling
Canvas.SetPos(0, CornerSlope);
DrawWhiteBox(XS, TitleHeight-CornerSlope);
Canvas.SetPos(CornerSlope, 0);
DrawWhiteBox(XS-(CornerSlope*2), CornerSlope);
// Frame itself.
if (P.bWindowFocused)
Canvas.SetDrawColor(32, 6,6, 255);
else Canvas.SetDrawColor(16, 2,2, P.FrameOpacity);
Canvas.SetPos(0, TitleHeight);
DrawCornerTex(CornerSlope, 0);
Canvas.SetPos(XS-CornerSlope, TitleHeight);
DrawCornerTex(CornerSlope, 1);
Canvas.SetPos(0, YS-CornerSlope);
DrawCornerTex(CornerSlope, 2);
Canvas.SetPos(XS-CornerSlope, YS-CornerSlope);
DrawCornerTex(CornerSlope, 3);
// Filling
Canvas.SetPos(CornerSlope, TitleHeight);
DrawWhiteBox(XS-(CornerSlope*2), YS-TitleHeight);
Canvas.SetPos(0, TitleHeight+CornerSlope);
DrawWhiteBox(CornerSlope, YS-(CornerSlope*2)-TitleHeight);
Canvas.SetPos(XS-CornerSlope, TitleHeight+CornerSlope);
DrawWhiteBox(CornerSlope, YS-(CornerSlope*2)-TitleHeight);
// Title.
if (P.WindowTitle != "")
{
Canvas.SetDrawColor(250, 250, 250, P.FrameOpacity);
Canvas.SetPos(CornerSlope, 0);
DrawText(P.WindowTitle);
}
}
function RenderWindow(KFGUI_Page P)
{
local int XS, YS, CornerSlope;
XS = Canvas.ClipX-Canvas.OrgX;
YS = Canvas.ClipY-Canvas.OrgY;
CornerSlope = DefaultHeight*0.4;
// Frame itself.
if (P.bWindowFocused)
Canvas.SetDrawColor(64, 64, 64, 255);
else Canvas.SetDrawColor(32, 32, 32, P.FrameOpacity);
Canvas.SetPos(0, 0);
DrawCornerTex(CornerSlope, 0);
Canvas.SetPos(XS-CornerSlope, 0);
DrawCornerTex(CornerSlope, 1);
Canvas.SetPos(0, YS-CornerSlope);
DrawCornerTex(CornerSlope, 2);
Canvas.SetPos(XS-CornerSlope, YS-CornerSlope);
DrawCornerTex(CornerSlope, 3);
// Filling
Canvas.SetPos(CornerSlope, 0);
DrawWhiteBox(XS-(CornerSlope*2), YS);
Canvas.SetPos(0, CornerSlope);
DrawWhiteBox(CornerSlope, YS-(CornerSlope*2));
Canvas.SetPos(XS-CornerSlope, CornerSlope);
DrawWhiteBox(CornerSlope, YS-(CornerSlope*2));
}
function RenderToolTip(KFGUI_Tooltip TT)
{
local int i;
local float X, Y,XS, YS, TX, TY, TS, DefFontHeight;
Canvas.Font = PickFont(TS);
// First compute textbox size.
TY = DefaultHeight*TT.Lines.Length;
for (i=0; i < TT.Lines.Length; ++i)
{
if (TT.Lines[i] != "")
Canvas.TextSize(TT.Lines[i], XS, YS);
TX = FMax(XS, TX);
}
TX*=TS;
// Give some borders.
TX += TOOLTIP_BORDER*2;
TY += TOOLTIP_BORDER*2;
X = TT.CompPos[0];
Y = TT.CompPos[1]+24.f;
// Then check if too close to window edge, then move it to another pivot.
if ((X+TX) > TT.Owner.ScreenSize.X)
X = TT.Owner.ScreenSize.X-TX;
if ((Y+TY) > TT.Owner.ScreenSize.Y)
Y = TT.CompPos[1]-TY;
if (TT.CurrentAlpha < 255)
TT.CurrentAlpha = Min(TT.CurrentAlpha+25, 255);
// Reset clipping.
Canvas.SetOrigin(0, 0);
Canvas.SetClip(TT.Owner.ScreenSize.X, TT.Owner.ScreenSize.Y);
// Draw frame.
Canvas.SetDrawColor(200, 200, 80, TT.CurrentAlpha);
Canvas.SetPos(X-2, Y-2);
DrawBoxHollow(X-2, Y-2, TX+4, TY+4, 2);
Canvas.SetDrawColor(80, 10, 80, TT.CurrentAlpha);
Canvas.SetPos(X, Y);
DrawWhiteBox(TX, TY);
DefFontHeight = DefaultHeight;
// Draw text.
Canvas.SetDrawColor(255, 255, 255, TT.CurrentAlpha);
X+=TOOLTIP_BORDER;
Y+=TOOLTIP_BORDER;
for (i=0; i < TT.Lines.Length; ++i)
{
Canvas.SetPos(X, Y);
Canvas.DrawText(TT.Lines[i], ,TS, TS, TT.TextFontInfo);
Y+=DefFontHeight;
}
}
function RenderScrollBar(KFGUI_ScrollBarBase S)
{
local float A;
local byte i;
if (S.bDisabled)
Canvas.SetDrawColor(5, 5, 5, 0);
else if (S.bFocused || S.bGrabbedScroller)
Canvas.SetDrawColor(15, 15, 15, 160);
else Canvas.SetDrawColor(15, 15, 15, 160);
DrawRectBox (0.f, 0.f, S.CompPos[2], S.CompPos[3], 4);
if (S.bDisabled)
return;
if (S.bVertical)
i = 3;
else i = 2;
S.SliderScale = FMax(S.PageStep * (S.CompPos[i] - 32.f) / (S.MaxRange + S.PageStep), S.CalcButtonScale);
if (S.bGrabbedScroller)
{
// Track mouse.
if (S.bVertical)
A = S.Owner.MousePosition.Y - S.CompPos[1] - S.GrabbedOffset;
else A = S.Owner.MousePosition.X - S.CompPos[0] - S.GrabbedOffset;
A /= ((S.CompPos[i]-S.SliderScale) / float(S.MaxRange));
S.SetValue(A);
}
A = float(S.CurrentScroll) / float(S.MaxRange);
S.ButtonOffset = A*(S.CompPos[i]-S.SliderScale);
if (S.bGrabbedScroller)
Canvas.SetDrawColor(255, 0,0, 200);
else if (S.bFocused)
Canvas.SetDrawColor(200, 0,0, 200);
else Canvas.SetDrawColor(150, 0,0, 200);
if (S.bVertical)
DrawRectBox (0.f, S.ButtonOffset, S.CompPos[2], S.SliderScale, 4);
else DrawRectBox (S.ButtonOffset, 0.f, S.SliderScale, S.CompPos[3], 4);
}
function RenderColumnHeader(KFGUI_ColumnTop C, float XPos, float Width, int Index, bool bFocus, bool bSort)
{
local int XS;
if (bSort)
{
if (bFocus)
Canvas.SetDrawColor(175, 240, 8,255);
else Canvas.SetDrawColor(128, 200, 56, 255);
}
else if (bFocus)
Canvas.SetDrawColor(220, 220, 8,255);
else Canvas.SetDrawColor(220, 86, 56, 255);
XS = DefaultHeight*0.125;
Canvas.SetPos(XPos, 0.f);
DrawCornerTexNU(XS, C.CompPos[3], 0);
Canvas.SetPos(XPos+XS, 0.f);
DrawWhiteBox(Width-(XS*2), C.CompPos[3]);
Canvas.SetPos(XPos+Width-(XS*2), 0.f);
DrawCornerTexNU(XS, C.CompPos[3], 1);
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(XPos+XS, (C.CompPos[3]-C.ListOwner.TextHeight)*0.5f);
C.ListOwner.DrawStrClipped(C.ListOwner.Columns[Index].Text);
}
function RenderCheckbox(KFGUI_CheckBox C)
{
if (C.bDisabled)
Canvas.SetDrawColor(86, 86, 86, 255);
else if (C.bPressedDown)
Canvas.SetDrawColor(128, 255, 128, 255);
else if (C.bFocused)
Canvas.SetDrawColor(150, 200, 128, 255);
else Canvas.SetDrawColor(128, 186, 128, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(LoadedTex[0], C.CompPos[2], C.CompPos[3], 0,0, LoadedTex[0].GetSurfaceWidth(), LoadedTex[0].GetSurfaceHeight());
if (C.bChecked)
{
if (C.bDisabled)
Canvas.SetDrawColor(128, 128, 128, 255);
else Canvas.SetDrawColor(255, 255, 255, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(LoadedTex[1], C.CompPos[2], C.CompPos[3], 0,0, LoadedTex[1].GetSurfaceWidth(), LoadedTex[1].GetSurfaceHeight());
}
}
function RenderComboBox(KFGUI_ComboBox C)
{
if (C.bDisabled)
Canvas.SetDrawColor(64, 4,4, 255);
else if (C.bPressedDown)
Canvas.SetDrawColor(220, 56, 56, 255);
else if (C.bFocused)
Canvas.SetDrawColor(190, 48, 48, 255);
else Canvas.SetDrawColor(186, 4,4, 255);
Canvas.SetPos(0.f, 0.f);
DrawWhiteBox(C.CompPos[2], C.CompPos[3]);
if (C.SelectedIndex < C.Values.Length && C.Values[C.SelectedIndex] != "")
{
Canvas.SetPos(C.BorderSize, (C.CompPos[3]-C.TextHeight)*0.5);
if (C.bDisabled)
Canvas.DrawColor = C.TextColor*0.5f;
else Canvas.DrawColor = C.TextColor;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX-C.BorderSize, Canvas.ClipY);
Canvas.DrawText(C.Values[C.SelectedIndex], ,C.TextScale, C.TextScale, C.TextFontInfo);
Canvas.PopMaskRegion();
}
}
function RenderComboList(KFGUI_ComboSelector C)
{
local float X, Y,YL, YP, Edge;
local int i;
local bool bCheckMouse;
// Draw background.
Edge = C.Combo.BorderSize;
Canvas.SetPos(0.f, 0.f);
Canvas.SetDrawColor(128, 4,4, 255);
DrawWhiteBox(C.CompPos[2], C.CompPos[3]);
Canvas.SetPos(Edge, Edge);
Canvas.SetDrawColor(64, 4,4, 255);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), C.CompPos[3]-(Edge*2.f));
// While rendering, figure out mouse focus row.
X = C.Owner.MousePosition.X - Canvas.OrgX;
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
Canvas.Font = C.Combo.TextFont;
YL = C.Combo.TextHeight;
YP = Edge;
C.CurrentRow = -1;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX, Canvas.ClipY);
for (i=0; i < C.Combo.Values.Length; ++i)
{
if (bCheckMouse && Y >= YP && Y <= (YP+YL))
{
bCheckMouse = false;
C.CurrentRow = i;
Canvas.SetPos(4.f, YP);
Canvas.SetDrawColor(128, 48, 48, 255);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), YL);
}
Canvas.SetPos(Edge, YP);
if (i == C.Combo.SelectedIndex)
Canvas.DrawColor = C.Combo.SelectedTextColor;
else Canvas.DrawColor = C.Combo.TextColor;
Canvas.DrawText(C.Combo.Values[i], ,C.Combo.TextScale, C.Combo.TextScale, C.Combo.TextFontInfo);
YP+=YL;
}
Canvas.PopMaskRegion();
if (C.OldRow != C.CurrentRow)
{
C.OldRow = C.CurrentRow;
C.PlayMenuSound(MN_DropdownChange);
}
}
function RenderRightClickMenu(KFGUI_RightClickMenu C)
{
local float X, Y,YP, Edge, TextScale, TexDefHieght;
local int i;
local bool bCheckMouse;
// Draw background.
Edge = C.EdgeSize;
Canvas.SetDrawColor(148, 4,4, 255);
DrawBoxHollow(0.f, 0.f, C.CompPos[2], C.CompPos[3], Edge);
Canvas.SetPos(Edge, Edge);
Canvas.SetDrawColor(64, 4,4, 200);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), C.CompPos[3]-(Edge*2.f));
// While rendering, figure out mouse focus row.
X = C.Owner.MousePosition.X - Canvas.OrgX;
Y = C.Owner.MousePosition.Y - Canvas.OrgY;
bCheckMouse = (X > 0.f && X < C.CompPos[2] && Y > 0.f && Y < C.CompPos[3]);
Canvas.Font = PickFont(TextScale);
YP = Edge;
C.CurrentRow = -1;
TexDefHieght = DefaultHeight;
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX, Canvas.ClipY);
for (i=0; i < C.ItemRows.Length; ++i)
{
if (bCheckMouse && Y >= YP && Y <= (YP+TexDefHieght))
{
bCheckMouse = false;
C.CurrentRow = i;
Canvas.SetPos(4.f, YP);
Canvas.SetDrawColor(128, 48, 48, 255);
DrawWhiteBox(C.CompPos[2]-(Edge*2.f), TexDefHieght);
}
Canvas.SetPos(Edge, YP);
if (C.ItemRows[i].bSplitter)
{
Canvas.SetDrawColor(0, 0,0, 255);
Canvas.DrawText("-------", ,TextScale, TextScale);
}
else
{
if (C.ItemRows[i].bDisabled)
Canvas.SetDrawColor(148, 148, 148, 255);
else Canvas.SetDrawColor(248, 248, 248, 255);
Canvas.DrawText(C.ItemRows[i].Text, ,TextScale, TextScale);
}
YP+=TexDefHieght;
}
Canvas.PopMaskRegion();
if (C.OldRow != C.CurrentRow)
{
C.OldRow = C.CurrentRow;
C.PlayMenuSound(MN_DropdownChange);
}
}
function RenderButton(KFGUI_Button B)
{
local float XL, YL, TS;
local byte i;
if (B.bDisabled)
Canvas.SetDrawColor(32, 0,0, 255);
else if (B.bPressedDown)
Canvas.SetDrawColor(255, 64, 64, 255);
else if (B.bFocused)
Canvas.SetDrawColor(180, 45, 45, 255);
else Canvas.SetDrawColor(164, 8,8, 255);
if (B.bIsHighlighted)
{
Canvas.DrawColor.R = Min(Canvas.DrawColor.R+25, 255);
Canvas.DrawColor.G = Min(Canvas.DrawColor.G+25, 255);
Canvas.DrawColor.B = Min(Canvas.DrawColor.B+25, 255);
}
Canvas.SetPos(0.f, 0.f);
if (B.ExtravDir == 255)
DrawWhiteBox(B.CompPos[2], B.CompPos[3]);
else DrawRectBox(0, 0,B.CompPos[2], B.CompPos[3], Min(B.CompPos[2], B.CompPos[3])*0.2, B.ExtravDir);
if (B.OverlayTexture.Texture != None)
{
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(B.OverlayTexture.Texture, B.CompPos[2], B.CompPos[3], B.OverlayTexture.U, B.OverlayTexture.V, B.OverlayTexture.UL, B.OverlayTexture.VL);
}
if (B.ButtonText != "")
{
// Chose the best font to fit this button.
i = Min(B.FontScale, MaxFontScale);
while (true)
{
Canvas.Font = PickFont(TS);
Canvas.TextSize(B.ButtonText, XL, YL, TS, TS);
if (i == 0 || (XL < (B.CompPos[2]*0.95) && YL < (B.CompPos[3]*0.95)))
break;
--i;
}
Canvas.SetPos((B.CompPos[2]-XL)*0.5, (B.CompPos[3]-YL)*0.5);
if (B.bDisabled)
Canvas.DrawColor = B.TextColor*0.5f;
else Canvas.DrawColor = B.TextColor;
Canvas.DrawText(B.ButtonText, ,TS, TS, B.TextFontInfo);
}
}
defaultproperties
{
MaxFontScale=5
}

View File

@ -0,0 +1,124 @@
//All code here was done by Mr Evil.
class KFColorHelper extends Object
transient;
`include(Build.uci)
`include(Logger.uci)
struct HSVColour
{
var() float H, S, V, A;
structdefaultproperties
{
A=1.0
}
};
static final function HSVColour RGBToHSV(const LinearColor RGB)
{
local float Max;
local float Min;
local float Chroma;
local HSVColour HSV;
Min = FMin(FMin(RGB.R, RGB.G), RGB.B);
Max = FMax(FMax(RGB.R, RGB.G), RGB.B);
Chroma = Max - Min;
//If Chroma is 0, then S is 0 by definition, and H is undefined but 0 by convention.
if (Chroma != 0)
{
if (RGB.R == Max)
{
HSV.H = (RGB.G - RGB.B) / Chroma;
if (HSV.H < 0.0)
{
HSV.H += 6.0;
}
}
else if (RGB.G == Max)
{
HSV.H = ((RGB.B - RGB.R) / Chroma) + 2.0;
}
else //RGB.B == Max
{
HSV.H = ((RGB.R - RGB.G) / Chroma) + 4.0;
}
HSV.H *= 60.0;
HSV.S = Chroma / Max;
}
HSV.V = Max;
HSV.A = RGB.A;
return HSV;
}
static final function LinearColor HSVToRGB(const HSVColour HSV)
{
local float Min;
local float Chroma;
local float Hdash;
local float X;
local LinearColor RGB;
Chroma = HSV.S * HSV.V;
Hdash = HSV.H / 60.0;
X = Chroma * (1.0 - Abs((Hdash % 2.0) - 1.0));
if (Hdash < 1.0)
{
RGB.R = Chroma;
RGB.G = X;
}
else if (Hdash < 2.0)
{
RGB.R = X;
RGB.G = Chroma;
}
else if (Hdash < 3.0)
{
RGB.G = Chroma;
RGB.B = X;
}
else if (Hdash < 4.0)
{
RGB.G= X;
RGB.B = Chroma;
}
else if (Hdash < 5.0)
{
RGB.R = X;
RGB.B = Chroma;
}
else if (Hdash < 6.0)
{
RGB.R = Chroma;
RGB.B = X;
}
Min = HSV.V - Chroma;
RGB.R += Min;
RGB.G += Min;
RGB.B += Min;
RGB.A = HSV.A;
return RGB;
}
static final function Color LinearColorToColor(const LinearColor RGB)
{
local Color TrueRGB;
TrueRGB.R = RGB.R * 255;
TrueRGB.G = RGB.G * 255;
TrueRGB.B = RGB.B * 255;
TrueRGB.A = RGB.A * 255;
return TrueRGB;
}

View File

@ -0,0 +1,12 @@
// Ugly hack to draw ontop of flash UI!
Class KFGUIConsoleHack extends Console;
`include(Build.uci)
`include(Logger.uci)
var KF2GUIController OutputObject;
function PostRender_Console(Canvas Canvas)
{
OutputObject.RenderMenu(Canvas);
}

348
YAS/Classes/KFGUI_Base.uc Normal file
View File

@ -0,0 +1,348 @@
// Menu system written by Marco.
Class KFGUI_Base extends Object
abstract;
`include(Build.uci)
`include(Logger.uci)
var KF2GUIController Owner;
var YASHUD HUDOwner;
var KFGUI_Base ParentComponent; // Parent component if any.
var transient Canvas Canvas;
enum EMenuSound
{
MN_Focus,
MN_LostFocus,
MN_FocusHover,
MN_ClickButton,
MN_ClickCheckboxOn,
MN_ClickCheckboxOff,
MN_Dropdown,
MN_DropdownChange,
};
var() float XPosition, YPosition, XSize, YSize;
var() name ID; // Just for internal purposes, you can give the components unique ID values.
var() int IDValue; // Integer ID value.
var transient float CompPos[4], InputPos[4];
var transient KFGUI_Base MouseArea; // Next in recurse line of the mouse pointer focus area.
var() bool bDisabled, bClickable, bCanFocus;
var bool bFocusedPostDrawItem; // If this component has been given input focus, should it receive draw menu call after everything else been drawn?
var transient bool bFocused, bTextureInit, bVisible;
var bool bIsHUDWidget, bEnableInputs, bNoLookInputs;
var array<name> TimerNames;
function InitMenu(); // Menu was initialized for the first time.
function ShowMenu(); // Menu was opened.
function PreDraw()
{
if (!bVisible)
return;
ComputeCoords();
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
}
function DrawMenu(); // Draw menu now.
function CloseMenu(); // Menu was closed.
function InventoryChanged(optional KFWeapon Wep, optional bool bRemove); // Called when a players inventory is changed.
function MenuTick(float DeltaTime);
final function SetTimer(float InRate, optional bool inbLoop, optional Name inTimerFunc='Timer')
{
if (InRate <= 0.f)
{
ClearTimer(inTimerFunc);
return;
}
if (TimerNames.Find(inTimerFunc) == INDEX_NONE)
{
TimerNames.AddItem(inTimerFunc);
}
`TimerHelper.SetTimer(InRate, inbLoop, inTimerFunc, self);
}
final function ClearTimer(optional Name inTimerFunc='Timer')
{
if (TimerNames.Find(inTimerFunc) != INDEX_NONE)
{
TimerNames.RemoveItem(inTimerFunc);
}
`TimerHelper.ClearTimer(inTimerFunc, self);
}
function Timer();
function MouseEnter()
{
bFocused = true;
OnFocus(Self, True);
}
function MouseLeave()
{
bFocused = false;
OnFocus(Self, False);
}
function MouseClick(bool bRight);
function MouseRelease(bool bRight);
function DoubleMouseClick(bool bRight ) // User rapidly double clicked this component.
{
MouseClick(bRight);
}
function ScrollMouseWheel(bool bUp);
function bool ReceievedControllerInput(int ControllerId, name Key, EInputEvent Event)
{
return false;
}
final function PlayerController GetPlayer()
{
return Owner.PlayerOwner;
}
function SetDisabled(bool bDisable)
{
bDisabled = bDisable;
}
Delegate OnFocus(KFGUI_Base Sender, bool bBecame);
final function ComputeCoords()
{
CompPos[0] = XPosition*InputPos[2]+InputPos[0];
CompPos[1] = YPosition*InputPos[3]+InputPos[1];
CompPos[2] = XSize*InputPos[2];
CompPos[3] = YSize*InputPos[3];
}
function bool CaptureMouse()
{
return bVisible && ( Owner.MousePosition.X >= CompPos[0] && Owner.MousePosition.Y >= CompPos[1] && Owner.MousePosition.X <= (CompPos[0]+CompPos[2]) && Owner.MousePosition.Y <= (CompPos[1]+CompPos[3]));
}
final function KFGUI_Base GetMouseFocus()
{
local KFGUI_Base M;
for (M=Self; M.MouseArea != None; M=M.MouseArea)
{}
return M;
}
function SetVisibility(bool Visible)
{
bVisible = Visible;
}
function DoClose()
{
local int i;
for (i=0; i < TimerNames.Length; i++)
{
ClearTimer(TimerNames[i]);
}
if (ParentComponent != None)
ParentComponent.DoClose();
else Owner.PopCloseMenu(Self);
}
function byte GetCursorStyle()
{
return (bClickable ? `PEN_BLACK : `PEN_WHITE);
}
function UserPressedEsc() // user pressed escape while this menu was active.
{
if (ParentComponent != None)
ParentComponent.UserPressedEsc();
else DoClose();
}
function bool BringPageToFront()
{
if (ParentComponent != None)
return ParentComponent.BringPageToFront();
return true; // Allow user to bring this page to front.
}
final function bool IsTopMenu()
{
return (Owner.ActiveMenus.Length > 0 && GetPageTop() == Owner.ActiveMenus[0]);
}
final function KFGUI_Page GetPageTop()
{
local KFGUI_Base M;
for (M=Self; M.ParentComponent != None; M=M.ParentComponent)
{}
return KFGUI_Page(M);
}
function KFGUI_Base FindComponentID(name InID)
{
if (ID == InID)
return Self;
return None;
}
function FindAllComponentID(name InID, out array<KFGUI_Base> Res)
{
if (ID == InID)
Res[Res.Length] = Self;
}
function RemoveComponent(KFGUI_Base B);
function GetInputFocus()
{
if (Owner.InputFocus != None)
Owner.InputFocus.LostInputFocus();
Owner.InputFocus = Self;
}
function DropInputFocus()
{
if (Owner.InputFocus == Self)
{
Owner.InputFocus.LostInputFocus();
Owner.InputFocus = None;
}
}
function LostInputFocus();
// Obtain keyboard focus.
final function GrabKeyFocus()
{
Owner.GrabInputFocus(Self);
}
final function ReleaseKeyFocus()
{
if (Owner.KeyboardFocus == Self)
Owner.GrabInputFocus(None);
}
function LostKeyFocus();
function bool NotifyInputKey(int ControllerId, name Key, EInputEvent Event, float AmountDepressed, bool bGamepad)
{
if (bIsHUDWidget && bEnableInputs)
{
switch (Key)
{
case 'XboxTypeS_Start':
case 'Escape':
if (Event == IE_Pressed)
UserPressedEsc();
return true;
case 'XboxTypeS_DPad_Up':
case 'XboxTypeS_DPad_Down':
case 'XboxTypeS_DPad_Left':
case 'XboxTypeS_DPad_Right':
case 'MouseScrollDown':
case 'MouseScrollUp':
case 'MouseScrollDown':
case 'MouseScrollUp':
if (Event == IE_Pressed)
ScrollMouseWheel(Key == 'MouseScrollUp' || Key == 'XboxTypeS_DPad_Up' || Key == 'XboxTypeS_DPad_Left');
return true;
}
}
return false;
}
function bool NotifyInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, bool bGamepad)
{
return false;
}
function bool NotifyInputChar(int ControllerId, string Unicode)
{
return false;
}
// While on input focus mode, notify that mouse just moved over the threshold.
function InputMouseMoved();
// Notify any focused menu element that mouse has been idle over it.
function NotifyMousePaused();
final function GetActualPos(out float X, out float Y)
{
X = ((XPosition+X)*InputPos[2]) + InputPos[0];
Y = ((YPosition+Y)*InputPos[3]) + InputPos[1];
}
final function GetRealtivePos(out float X, out float Y)
{
X = X / CompPos[2];
Y = Y / CompPos[2];
}
simulated final function PlayMenuSound(EMenuSound Slot)
{
local SoundCue S;
local KFGameEngine Engine;
Engine = KFGameEngine(class'Engine'.static.GetEngine());
switch (Slot)
{
case MN_FocusHover:
case MN_Focus:
S = Owner.CurrentStyle.MenuHover;
break;
case MN_LostFocus:
S = Owner.CurrentStyle.MenuFade;
break;
case MN_ClickButton:
case MN_ClickCheckboxOff:
S = Owner.CurrentStyle.MenuClick;
break;
case MN_Dropdown:
S = Owner.CurrentStyle.MenuDown;
break;
case MN_DropdownChange:
S = Owner.CurrentStyle.MenuEdit;
break;
}
if (S != None)
{
S.VolumeMultiplier = (Engine.SFxVolumeMultiplier/100.f) * (Engine.MasterVolumeMultiplier/100.f);
GetPlayer().PlaySound(S, true, ,false);
}
}
// Pre level change notification.
function NotifyLevelChange();
final function SetPosition(float X, float Y, float XS, float YS)
{
XPosition = X;
YPosition = Y;
XSize = XS;
YSize = YS;
}
static final function string MakeSortStr(int Value)
{
local string S;
local int i;
// Prefix with zeroes to properly sort this string.
S = string(Value);
i = Len(S);
if (i < 10)
return Mid("0000000000", i)$S;
return S;
}
defaultproperties
{
XSize=1
YSize=1
bCanFocus=true
bVisible=true
}

View File

@ -0,0 +1,45 @@
Class KFGUI_Button extends KFGUI_Clickable;
`include(Build.uci)
`include(Logger.uci)
var() Canvas.CanvasIcon OverlayTexture;
var() string ButtonText, GamepadButtonName;
var() color TextColor;
var() Canvas.FontRenderInfo TextFontInfo;
var() byte FontScale, ExtravDir;
var bool bIsHighlighted;
function DrawMenu()
{
Owner.CurrentStyle.RenderButton(Self);
}
function bool GetUsingGamepad()
{
return Owner.bUsingGamepad && GamepadButtonName != "";
}
function HandleMouseClick(bool bRight)
{
if (bRight)
OnClickRight(Self);
else OnClickLeft(Self);
}
Delegate OnClickLeft(KFGUI_Button Sender);
Delegate OnClickRight(KFGUI_Button Sender);
Delegate bool DrawOverride(Canvas C, KFGUI_Button B)
{
return false;
}
defaultproperties
{
ButtonText="Button!"
TextColor=(R=0, G=0, B=0, A=255)
TextFontInfo=(bClipText=true, bEnableShadow=true)
FontScale=1
}

View File

@ -0,0 +1,84 @@
class KFGUI_CategoryButton extends KFGUI_Button;
`include(Build.uci)
`include(Logger.uci)
var transient bool bOpened;
var Texture2D Icon;
var Color IconColor;
function DrawMenu()
{
local float XL, YL, TS, TextX, TextY;
local Texture2D Mat;
local bool bDrawOverride;
bDrawOverride = DrawOverride(Canvas, Self);
if (!bDrawOverride)
{
if (bDisabled)
Mat = Owner.CurrentStyle.ButtonTextures[`BUTTON_DISABLED];
else if (bPressedDown)
Mat = Owner.CurrentStyle.ButtonTextures[`BUTTON_PRESSED];
else if (bFocused || bIsHighlighted)
Mat = Owner.CurrentStyle.ButtonTextures[`BUTTON_NORMAL];
else Mat = Owner.CurrentStyle.ButtonTextures[`BUTTON_HIGHLIGHTED];
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Mat, CompPos[2], CompPos[3], 0,0, 32, 32);
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 != "")
{
Canvas.Font = Owner.CurrentStyle.MainFont;
TS = Owner.CurrentStyle.GetFontScaler();
TS *= FontScale;
while (true)
{
Canvas.TextSize(ButtonText, XL, YL, TS, TS);
if (XL < (CompPos[2]*0.9) && YL < (CompPos[3]*0.9))
break;
TS -= 0.001;
}
TextX = (CompPos[2]-XL)*0.5;
TextY = (CompPos[3]-YL)*0.5;
Canvas.SetPos(TextX, TextY);
if (bDisabled)
Canvas.DrawColor = TextColor*0.5f;
else Canvas.DrawColor = TextColor;
Canvas.DrawText(ButtonText, ,TS, TS, TextFontInfo);
if (Icon != None)
{
Canvas.DrawColor = IconColor;
Canvas.SetPos(TextX-CompPos[3], 0.f);
Canvas.DrawRect(CompPos[3], CompPos[3], Icon);
Canvas.SetPos(TextX+XL, 0.f);
Canvas.DrawRect(CompPos[3], CompPos[3], Icon);
}
}
Canvas.DrawColor = class'HUD'.default.WhiteColor;
Canvas.SetPos(0.f, 0.f);
Canvas.DrawRect(CompPos[3], CompPos[3], bOpened ? Owner.CurrentStyle.ArrowTextures[`ARROW_DOWN] : Owner.CurrentStyle.ArrowTextures[`ARROW_RIGHT]);
Canvas.SetPos(CompPos[2]-CompPos[3], 0.f);
Canvas.DrawRect(CompPos[3], CompPos[3], bOpened ? Owner.CurrentStyle.ArrowTextures[`ARROW_DOWN] : Owner.CurrentStyle.ArrowTextures[`ARROW_LEFT]);
}
defaultproperties
{
}

View File

@ -0,0 +1,93 @@
class KFGUI_CategoryList extends KFGUI_ComponentList;
`include(Build.uci)
`include(Logger.uci)
// Broken, does not work correctly when closing a menu and re-opening it if a category is open
struct FCategoryItems
{
var name ID;
var KFGUI_Base Item;
};
var array<FCategoryItems> CategoryItems;
function AddCategory(name CatID, string CatName, optional Texture2D IconMat, optional Color IconClr, optional float XS=1.f, optional float YS=1.f)
{
local KFGUI_CategoryButton B;
B = KFGUI_CategoryButton(AddListComponent(class'KFGUI_CategoryButton', XS, YS));
B.ButtonText = CatName;
B.ID = CatID;
B.Icon = IconMat;
B.IconColor = IconClr;
B.OnClickLeft = SelectedCategory;
B.OnClickRight = SelectedCategory;
}
function KFGUI_Base AddItemToCategory(name CatID, class<KFGUI_Base> Item)
{
local FCategoryItems CatItem;
local KFGUI_Base G;
G = CreateComponent(Item);
G.ID = CatID;
G.Owner = Owner;
G.ParentComponent = Self;
CatItem.ID = CatID;
CatItem.Item = G;
CategoryItems.AddItem(CatItem);
return G;
}
function SelectedCategory(KFGUI_Button Sender)
{
local int i, j, Index;
local KFGUI_CategoryButton CatB;
CatB = KFGUI_CategoryButton(Sender);
if (CatB == None)
return;
Index = ItemComponents.Find(Sender);
if (Index != INDEX_NONE)
{
if (!CatB.bOpened)
{
CatB.bOpened = true;
j = Index+1;
for (i=0; i < CategoryItems.Length; i++)
{
if (CategoryItems[i].ID == CatB.ID)
AddItemAtIndex(j++, CategoryItems[i].Item);
}
}
else
{
CatB.bOpened = false;
for (i=0; i < CategoryItems.Length; i++)
{
if (CategoryItems[i].ID == CatB.ID)
ItemComponents.RemoveItem(CategoryItems[i].Item);
}
}
}
}
function EmptyList()
{
local int i;
for (i=0; i < ItemComponents.Length; i++)
{
if (KFGUI_CategoryButton(ItemComponents[i]) == None)
ItemComponents.Remove(i, 1);
}
CategoryItems.Length = 0;
}
defaultproperties
{
}

View File

@ -0,0 +1,34 @@
Class KFGUI_CheckBox extends KFGUI_EditControl;
`include(Build.uci)
`include(Logger.uci)
var() Texture CheckMark, CheckDisabled, CheckIdle, CheckFocus, CheckClicked;
var() bool bForceUniform, bChecked;
function UpdateSizes()
{
Super.UpdateSizes();
if (bForceUniform)
XSize = (YSize*InputPos[3]) / InputPos[2];
}
function DrawMenu()
{
Owner.CurrentStyle.RenderCheckbox(Self);
}
function HandleMouseClick(bool bRight)
{
bChecked = !bChecked;
OnCheckChange(Self);
}
Delegate OnCheckChange(KFGUI_CheckBox Sender);
defaultproperties
{
bForceUniform=true
LableWidth=0.85
}

View File

@ -0,0 +1,99 @@
Class KFGUI_Clickable extends KFGUI_Base
abstract;
`include(Build.uci)
`include(Logger.uci)
var() int IntIndex; // More user variables.
var() string ToolTip;
var KFGUI_Tooltip ToolTipItem;
var byte PressedDown[2];
var bool bPressedDown;
var bool bHoverSound;
function InitMenu()
{
Super.InitMenu();
bClickable = !bDisabled;
}
function MouseClick(bool bRight)
{
if (!bDisabled)
{
PressedDown[byte(bRight)] = 1;
bPressedDown = true;
}
}
function MouseRelease(bool bRight)
{
if (!bDisabled && PressedDown[byte(bRight)] == 1)
{
PlayMenuSound(MN_ClickButton);
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
HandleMouseClick(bRight);
}
}
function MouseLeave()
{
Super.MouseLeave();
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
function MouseEnter()
{
Super.MouseEnter();
if (!bDisabled && bHoverSound)
PlayMenuSound(MN_FocusHover);
}
function SetDisabled(bool bDisable)
{
Super.SetDisabled(bDisable);
bClickable = !bDisable;
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
function NotifyMousePaused()
{
if (Owner.InputFocus == None && ToolTip != "")
{
if (ToolTipItem == None)
{
ToolTipItem = New(None)Class'KFGUI_Tooltip';
ToolTipItem.Owner = Owner;
ToolTipItem.ParentComponent = Self;
ToolTipItem.InitMenu();
ToolTipItem.SetText(ToolTip);
}
ToolTipItem.ShowMenu();
ToolTipItem.CompPos[0] = Owner.MousePosition.X;
ToolTipItem.CompPos[1] = Owner.MousePosition.Y;
ToolTipItem.GetInputFocus();
}
}
final function ChangeToolTip(string S)
{
if (ToolTipItem != None)
ToolTipItem.SetText(S);
else ToolTip = S;
}
function SetVisibility(bool Visible)
{
Super.SetVisibility(Visible);
SetDisabled(!Visible);
}
function HandleMouseClick(bool bRight);
defaultproperties
{
bHoverSound=true
}

View File

@ -0,0 +1,125 @@
class KFGUI_ColorSlider extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
var KFGUI_Slider RSlider, GSlider, BSlider, ASlider;
var KFGUI_TextLable TextLable, RedLabel, GreenLabel, BlueLabel, AlphaLabel, RedValue, GreenValue, BlueValue, AlphaValue;
var KFGUI_ComponentList SettingsBox;
var Color DefaultColor;
var string CaptionText;
function InitMenu()
{
Super.InitMenu();
SettingsBox = KFGUI_ComponentList(FindComponentID('SettingsBox'));
TextLable = KFGUI_TextLable(FindComponentID('CaptionText'));
TextLable.SetText(CaptionText);
RSlider = AddSlider("Red:", 'ColorSliderR', 0,255, RedLabel, RedValue);
GSlider = AddSlider("Green:", 'ColorSliderG', 0,255, GreenLabel, GreenValue);
BSlider = AddSlider("Blue:", 'ColorSliderB', 0,255, BlueLabel, BlueValue);
ASlider = AddSlider("Alpha:", 'ColorSliderA', 0,255, AlphaLabel, AlphaValue);
SetDefaultColor(DefaultColor);
}
function SetDefaultColor(Color Def)
{
RSlider.SetValue(Def.R);
RSlider.UpdateListVis();
GSlider.SetValue(Def.G);
GSlider.UpdateListVis();
BSlider.SetValue(Def.B);
BSlider.UpdateListVis();
ASlider.SetValue(Def.A);
ASlider.UpdateListVis();
}
final function KFGUI_Slider AddSlider(string Cap, name IDN, int MinValue, int MaxValue, out KFGUI_TextLable Label, out KFGUI_TextLable ColorValueLabel)
{
local KFGUI_Slider SL;
local KFGUI_MultiComponent MC;
MC = KFGUI_MultiComponent(SettingsBox.AddListComponent(class'KFGUI_MultiComponent'));
MC.InitMenu();
Label = new(MC) class'KFGUI_TextLable';
Label.SetText(Cap);
Label.XSize = 0.45;
Label.FontScale = 1;
MC.AddComponent(Label);
ColorValueLabel = new(MC) class'KFGUI_TextLable';
ColorValueLabel.XPosition = 0.95;
ColorValueLabel.XSize = 0.1;
ColorValueLabel.FontScale = 1;
MC.AddComponent(ColorValueLabel);
SL = new(MC) class'KFGUI_Slider';
SL.XPosition = 0.575;
SL.XSize = 0.35;
SL.MinValue = MinValue;
SL.MaxValue = MaxValue;
SL.ID = IDN;
SL.OnValueChanged = OnValueChanged;
MC.AddComponent(SL);
return SL;
}
function OnValueChanged(KFGUI_Slider Sender, int Value)
{
switch (Sender.ID)
{
case 'ColorSliderR':
RedValue.SetText(string(Value));
TextLable.TextColor.R = Value;
break;
case 'ColorSliderG':
GreenValue.SetText(string(Value));
TextLable.TextColor.G = Value;
break;
case 'ColorSliderB':
BlueValue.SetText(string(Value));
TextLable.TextColor.B = Value;
break;
case 'ColorSliderA':
AlphaValue.SetText(string(Value));
TextLable.TextColor.A = Value;
break;
}
OnColorSliderValueChanged(self, Sender, Value);
}
delegate OnColorSliderValueChanged(KFGUI_ColorSlider Sender, KFGUI_Slider Slider, int Value);
function DrawMenu()
{
Owner.CurrentStyle.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_SMALL], 0,0, CompPos[2], CompPos[3]);
}
defaultproperties
{
Begin Object Class=KFGUI_ComponentList Name=ClientSettingsBox
XPosition=0.05
YPosition=0.1
XSize=0.95
YSize=0.95
ID="SettingsBox"
ListItemsPerPage=4
End Object
Components.Add(ClientSettingsBox)
Begin Object Class=KFGUI_TextLable Name=CaptionLabel
XSize=1
YSize=0.125
AlignX=1
AlignY=1
ID="CaptionText"
End Object
Components.Add(CaptionLabel)
}

View File

@ -0,0 +1,448 @@
// Columned list box (only for text lines).
Class KFGUI_ColumnList extends KFGUI_List;
`include(Build.uci)
`include(Logger.uci)
struct FColumnItem
{
var() string Text;
var() float Width;
var() bool bOnlyTextures;
var transient bool bHidden;
var transient int X, XSize;
};
var() array<FColumnItem> Columns;
var() class<KFGUI_ListItem> ListItemClass;
var() float FontSize;
var() color FocusedLineColor, SelectedLineColor;
var() float EdgeSize;
var KFGUI_ColumnTop ColumnComp;
var Canvas.FontRenderInfo LineFontInfo;
var int SelectedRowIndex;
var int LastSortedColumn;
var transient float TextHeight, ScalerSize, TextScaler;
var transient int OldItemsPerFrame;
var KFGUI_ListItem FirstItem, UnusedItem;
var transient bool bListSizeDirty;
var bool bLastSortedReverse;
var() bool bShouldSortList; // Should sort any new items added to the list instantly.
var() bool bCanSortColumn; // Allow user to sort columns.
delegate OnSelectedRow(KFGUI_ListItem Item, int Row, bool bRight, bool bDblClick);
function KFGUI_ListItem AddLine(string Value, optional int iValue, optional string SortValue, optional int Index=-1)
{
local KFGUI_ListItem N, O;
local int i;
// Allocate list item object.
if (UnusedItem != None)
{
N = UnusedItem;
UnusedItem = N.Next;
N.Next = None;
}
else N = new (None) ListItemClass;
// Setup column text value.
N.SetValue(Value, iValue, SortValue);
// Insert into list.
if (bShouldSortList && Index == -1)
{
N.Temp = N.GetSortStr(LastSortedColumn);
if (ListCount == 0 ) // No sorting needed yet.
{
N.Next = FirstItem;
FirstItem = N;
}
else if (bLastSortedReverse)
{
if (FirstItem.Temp < N.Temp)
{
N.Next = FirstItem;
FirstItem = N;
}
else
{
for (O=FirstItem; O != None; O=O.Next)
{
if (O.Next == None || O.Next.Temp < N.Temp)
{
N.Next = O.Next;
O.Next = N;
break;
}
}
}
}
else if (FirstItem.Temp > N.Temp)
{
N.Next = FirstItem;
FirstItem = N;
}
else
{
for (O=FirstItem; O != None; O=O.Next)
{
if (O.Next == None || O.Next.Temp > N.Temp)
{
N.Next = O.Next;
O.Next = N;
break;
}
}
}
}
else if (Index == -1 || Index > ListCount)
Index = ListCount;
if (Index == 0)
{
N.Next = FirstItem;
FirstItem = N;
}
else
{
i = 0;
for (O=FirstItem; O != None; O=O.Next)
{
if ((++i) == Index)
{
N.Next = O.Next;
O.Next = N;
break;
}
}
}
UpdateListSize();
return N;
}
final function RemoveLine(KFGUI_ListItem I)
{
local KFGUI_ListItem N;
if (I.Index == -1)
return;
// Update selected row info.
if (SelectedRowIndex == I.Index)
SelectedRowIndex = -1;
else if (SelectedRowIndex > I.Index)
--SelectedRowIndex;
// Remove from list.
if (FirstItem == I)
FirstItem = I.Next;
else
{
for (N=FirstItem; N != None; N=N.Next)
if (N.Next == I)
{
N.Next = I.Next;
break;
}
}
// Add to unused list.
I.Next = UnusedItem;
UnusedItem = I;
I.Index = -1;
UpdateListSize();
}
final function EmptyList()
{
local KFGUI_ListItem N, I;
for (I=FirstItem; I != None; I=N)
{
N = I.Next;
// Add to unused list.
I.Next = UnusedItem;
UnusedItem = I;
I.Index = -1;
}
FirstItem = None;
UpdateListSize();
}
final function KFGUI_ListItem GetFromIndex(int Index)
{
local KFGUI_ListItem N;
if (Index < 0 || Index >= ListCount)
return None;
for (N=FirstItem; N != None; N=N.Next)
if ((Index--) == 0)
return N;
return None;
}
function SortColumn(int Column, optional bool bReverse)
{
local array<KFGUI_ListItem> List;
local KFGUI_ListItem Sel, N,P;
local int i;
if (!bCanSortColumn || Column < 0 || Column >= Columns.Length)
return;
LastSortedColumn = Column;
bLastSortedReverse = bReverse;
bShouldSortList = true;
// Allocate memory space first.
List.Length = ListCount;
List.Length = 0;
// Grab current selected line.
Sel = GetFromIndex(SelectedRowIndex);
SelectedRowIndex = -1;
// Slow, sort it all.
for (N=FirstItem; N != None; N=N.Next)
{
N.Temp = N.GetSortStr(Column);
if (bReverse)
{
for (i=0; i < List.Length; ++i)
if (List[i].Temp < N.Temp)
break;
}
else
{
for (i=0; i < List.Length; ++i)
if (List[i].Temp > N.Temp)
break;
}
List.Insert(i, 1);
List[i] = N;
}
// Rebuild list.
FirstItem = None;
P = None;
for (i=0; i < List.Length; ++i)
{
N = List[i];
if (Sel == N)
SelectedRowIndex = i;
N.Index = i;
N.Next = None;
if (P == None)
FirstItem = N;
else P.Next = N;
P = N;
}
}
function ChangeListSize(int NewSize);
final function UpdateListSize()
{
local KFGUI_ListItem N;
ListCount = 0;
for (N=FirstItem; N != None; N=N.Next)
N.Index = ListCount++;
bListSizeDirty = true;
}
function InitMenu()
{
ListCount = 0;
Super.InitMenu();
ColumnComp = KFGUI_ColumnTop(FindComponentID('Columns'));
}
final function DrawStrClipped(string S, optional bool bOnlyTextures)
{
Canvas.PushMaskRegion(Canvas.OrgX, Canvas.OrgY, Canvas.ClipX, Canvas.ClipY);
Owner.CurrentStyle.DrawTexturedString(S, Canvas.CurX, Canvas.CurY, TextScaler, LineFontInfo, false, bOnlyTextures);
Canvas.PopMaskRegion();
}
function DrawMenu()
{
local int i, n,j;
local float Y, TextY, XOffset;
local KFGUI_ListItem C;
local bool bCheckMouse;
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_SMALL_SLIGHTTRANSPARENT], CompPos[2], CompPos[3], 0,0, 128, 128);
// Mouse focused item check.
bCheckMouse = bClickable && bFocused;
FocusMouseItem = -1;
if (bCheckMouse)
MouseYHit = Owner.MousePosition.Y - CompPos[1];
n = ScrollBar.CurrentScroll;
i = 0;
for (C=FirstItem; C != None; C=C.Next)
if ((i++) == n)
break;
Y = 0.f;
TextY = (ItemHeight-TextHeight)*0.5f;
XOffset = TextY*0.75;
Canvas.SetDrawColor(250, 250, 250, 255);
for (i=0; (i < ListItemsPerPage && C != None); ++i)
{
// Check for mouse hit.
if (bCheckMouse && FocusMouseItem == -1)
{
if (MouseYHit < ItemHeight)
FocusMouseItem = n;
else MouseYHit -= ItemHeight;
}
// Draw selection background.
if (SelectedRowIndex == n ) // Selected
{
Canvas.SetPos(EdgeSize, Y);
Canvas.DrawColor = SelectedLineColor;
Owner.CurrentStyle.DrawWhiteBox(CompPos[2]-(EdgeSize*2), ItemHeight);
Canvas.SetDrawColor(250, 250, 250, 255);
}
else if (FocusMouseItem == n ) // Focused
{
Canvas.SetPos(EdgeSize, Y);
Canvas.DrawColor = FocusedLineColor;
Owner.CurrentStyle.DrawWhiteBox(CompPos[2]-(EdgeSize*2), ItemHeight);
Canvas.SetDrawColor(250, 250, 250, 255);
}
// Draw columns of text
for (j=0; j < Columns.Length; ++j)
if (!Columns[j].bHidden)
{
//Canvas.SetClip(Columns[j].X+Columns[j].XSize+EdgeSize, YClip);
Canvas.SetPos(Columns[j].X+XOffset+EdgeSize, TextY);
DrawStrClipped(C.GetDisplayStr(j), Columns[j].bOnlyTextures);
}
Y+=ItemHeight;
TextY+=ItemHeight;
++n;
C = C.Next;
}
}
function PreDraw()
{
local byte j;
local float XS, SpaceX;
if (!bVisible)
return;
ComputeCoords();
// Check font to use.
Canvas.Font = Owner.CurrentStyle.PickFont(TextScaler);
TextScaler *= FontSize;
Canvas.TextSize("ABC", XS, TextHeight, TextScaler, TextScaler);
for (j=0; j < 4; ++j)
{
ScrollBar.InputPos[j] = CompPos[j];
ColumnComp.InputPos[j] = CompPos[j];
}
// Setup positioning.
// First compute the width scrollbar.
if (OldXSize != InputPos[2])
{
OldXSize = InputPos[2];
ScalerSize = ScrollBar.GetWidth();
ScrollBar.XPosition = 1.f - ScalerSize;
ColumnComp.XSize = ScrollBar.XPosition;
}
SpaceX = ScalerSize*CompPos[2];
CompPos[2] -= SpaceX;
ScrollBar.InputPos[3] = CompPos[3];
// Draw columns.
ColumnComp.YSize = (TextHeight*1.05) / CompPos[3];
ColumnComp.Canvas = Canvas;
ColumnComp.PreDraw();
// Move down to give space for columns.
CompPos[1] += ColumnComp.CompPos[3];
CompPos[3] -= ColumnComp.CompPos[3];
// Compute how many rows fit in with this setting.
ItemHeight = TextHeight*1.025;
ListItemsPerPage = CompPos[3]/ItemHeight;
ItemHeight = CompPos[3]/ListItemsPerPage;
if (OldItemsPerFrame != ListItemsPerPage || bListSizeDirty)
{
if (SelectedRowIndex >= ListCount)
SelectedRowIndex = -1;
OldItemsPerFrame = ListItemsPerPage;
bListSizeDirty = false;
UpdateListVis();
}
// Draw vertical scrollbar
ScrollBar.Canvas = Canvas;
ScrollBar.PreDraw();
// Draw self.
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
// Reset scaling to allow mouse to capture input.
CompPos[1] -= ColumnComp.CompPos[3];
CompPos[2] += SpaceX;
CompPos[3] += ColumnComp.CompPos[3];
}
function InternalClickedItem(int Index, bool bRight, int MouseX, int MouseY)
{
SelectedRowIndex = Index;
OnSelectedRow(GetFromIndex(Index), Index, bRight, false);
}
function InternalDblClickedItem(int Index, bool bRight, int MouseX, int MouseY)
{
SelectedRowIndex = Index;
OnSelectedRow(GetFromIndex(Index), Index, bRight, true);
}
defaultproperties
{
ListItemClass=class'KFGUI_ListItem'
OnClickedItem=InternalClickedItem
OnDblClickedItem=InternalDblClickedItem
SelectedRowIndex=-1
FontSize=1.f
EdgeSize=5.f
bClickable=true
FocusedLineColor=(R=64, G=3, B=48, A=255)
SelectedLineColor=(R=84, G=26, B=128, A=255)
bCanSortColumn=true
Begin Object Class=KFGUI_ColumnTop Name=ColumnComps
XPosition=0
YPosition=0
XSize=1
YSize=0.04
ID="Columns"
End Object
Components.Add(ColumnComps)
LineFontInfo=(bClipText=true, bEnableShadow=false)
}

View File

@ -0,0 +1,209 @@
// Do not use this on your own, it is used by ColumnList
Class KFGUI_ColumnTop extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var() float ColumnMinSize; // Minimum pixels width allowed.
var KFGUI_ColumnList ListOwner;
var transient int PrevSortedColumn, MouseColumn, ScalingColumn;
var transient byte PressedDown[2];
var transient bool bPressedDown, bScaleColumn, bMouseScaler;
function InitMenu()
{
Super.InitMenu();
ListOwner = KFGUI_ColumnList(ParentComponent);
}
function DrawMenu()
{
local int i, j;
local float X, XS, MouseX, GrabWidth, MinSize, Wd;
local bool bCheckMouse;
bClickable = ListOwner.bClickable;
MinSize = ColumnMinSize / CompPos[2];
// Scale column
if (bScaleColumn)
{
MouseX = Owner.MousePosition.X - CompPos[0];
for (i=0; i < ScalingColumn; ++i)
MouseX -= (ListOwner.Columns[i].Width * CompPos[2]);
ListOwner.Columns[ScalingColumn].Width = MouseX / CompPos[2];
// Make sure no column is scrolled off screen.
X = 0;
for (i=0; i < (ListOwner.Columns.Length-1); ++i)
{
if (ListOwner.Columns[i].Width < MinSize)
ListOwner.Columns[i].Width = MinSize;
X+=ListOwner.Columns[i].Width;
if (X >= (1.f-MinSize))
{
MouseX = X-(1.f-MinSize); // Grab overshoot.
// Then push back!
for (j=i; j >= 0; --j)
{
if ((ListOwner.Columns[j].Width-MouseX) > MinSize ) // This column has enough space to retract.
{
ListOwner.Columns[j].Width -= MouseX;
MouseX = 0;
break;
}
else if (ListOwner.Columns[j].Width > MinSize ) // This column has limited space to retract.
{
MouseX -= (ListOwner.Columns[j].Width-MinSize);
ListOwner.Columns[j].Width = MinSize;
}
}
X = (1.f-MinSize); // Continue at maximum size.
}
}
}
// Init mouse check.
MouseColumn = -1;
bCheckMouse = (bClickable && bFocused);
if (bCheckMouse)
{
GrabWidth = CompPos[3]*0.175;
MouseX = Owner.MousePosition.X - CompPos[0] - GrabWidth;
GrabWidth *= -2.f;
}
// Draw the columns and compute the scalings.
X = 0;
j = (ListOwner.bShouldSortList ? ListOwner.LastSortedColumn : -1);
for (i=0; i < ListOwner.Columns.Length; ++i)
{
if (ListOwner.Columns[i].Width < MinSize)
ListOwner.Columns[i].Width = MinSize;
Wd = ListOwner.Columns[i].Width * CompPos[2];
if (i == (ListOwner.Columns.Length-1) ) // Final column, give infinitive width.
{
Wd = (CompPos[2]-X);
}
if (Wd <= 0 ) // Impossible.
{
ListOwner.Columns[i].bHidden = true;
continue;
}
ListOwner.Columns[i].X = X;
ListOwner.Columns[i].XSize = Wd;
if (bCheckMouse && (MouseX -= Wd) <= 0.f)
{
MouseColumn = i;
bCheckMouse = false;
bMouseScaler = (MouseX >= GrabWidth) && ((i+1) < ListOwner.Columns.Length);
}
if (X >= CompPos[2])
ListOwner.Columns[i].bHidden = true;
else
{
ListOwner.Columns[i].bHidden = false;
//Canvas.SetClip(X+Wd, CompPos[1]+CompPos[3]);
// Draw column.
if (i == j)
{
if (MouseColumn == i && !bMouseScaler)
Canvas.SetDrawColor(175, 240, 8,255);
else Canvas.SetDrawColor(128, 200, 56, 255);
}
else if (MouseColumn == i && !bMouseScaler)
Canvas.SetDrawColor(220, 220, 8,255);
XS = Owner.CurrentStyle.DefaultHeight*0.5;
Canvas.SetPos(X, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.TabTextures[`TAB_TOP], Min(Wd, CompPos[2]-X), CompPos[3], 0,0, 128, 16);
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(X+XS, (CompPos[3]-ListOwner.TextHeight)*0.5f);
ListOwner.DrawStrClipped(ListOwner.Columns[i].Text);
}
X+=Wd;
}
}
function MouseClick(bool bRight)
{
if (!ListOwner.bDisabled && bClickable)
{
PressedDown[byte(bRight)] = 1;
bPressedDown = true;
if (!bRight && bMouseScaler)
{
PlayMenuSound(MN_ClickButton);
bScaleColumn = true;
ScalingColumn = MouseColumn;
GetInputFocus();
}
}
}
function MouseRelease(bool bRight)
{
if (bScaleColumn && !bRight)
{
bScaleColumn = false;
DropInputFocus();
return;
}
if (!bDisabled && bClickable && PressedDown[byte(bRight)] == 1)
{
PlayMenuSound(MN_ClickButton);
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
if (MouseColumn >= 0)
{
ListOwner.SortColumn(MouseColumn, (PrevSortedColumn == MouseColumn));
if (PrevSortedColumn == MouseColumn)
PrevSortedColumn = -1;
else PrevSortedColumn = MouseColumn;
}
}
}
function byte GetCursorStyle()
{
if (bClickable)
return (bMouseScaler ? 2 : 1);
return 0;
}
function MouseLeave()
{
Super.MouseLeave();
if (!bScaleColumn)
{
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
}
function MouseEnter()
{
Super.MouseEnter();
}
function LostInputFocus()
{
bScaleColumn = false;
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
defaultproperties
{
bClickable=true
ColumnMinSize=8
}

View File

@ -0,0 +1,67 @@
Class KFGUI_ComboBox extends KFGUI_EditControl;
`include(Build.uci)
`include(Logger.uci)
var KFGUI_ComboSelector Selection;
var float BorderSize;
var() array<string> Values;
var() int SelectedIndex;
var() color SelectedTextColor, TextColor;
var() bool bButtonStretched;
function UpdateSizes()
{
// Update height.
if (bScaleByFontSize)
YSize = (TextHeight + (BorderSize*2)) / InputPos[3];
}
function DrawMenu()
{
Owner.CurrentStyle.RenderComboBox(Self);
}
function HandleMouseClick(bool bRight)
{
PlayMenuSound(MN_Dropdown);
if (Selection == None)
{
Selection = New(None)Class'KFGUI_ComboSelector';
Selection.Owner = Owner;
Selection.Combo = Self;
Selection.InitMenu();
}
Selection.XPosition = CompPos[0] / Owner.ScreenSize.X;
Selection.YPosition = (CompPos[1]+CompPos[3]) / Owner.ScreenSize.Y;
Selection.XSize = CompPos[2] / Owner.ScreenSize.X;
Selection.YSize = (TextHeight / Owner.ScreenSize.Y) * Values.Length + ((BorderSize*2) / Owner.ScreenSize.Y);
if ((Selection.YPosition+Selection.YSize) > 1.f)
Selection.YPosition -= ((Selection.YPosition+Selection.YSize)-1.f);
Selection.GetInputFocus();
}
final function string GetCurrent()
{
if (SelectedIndex < Values.Length)
return Values[SelectedIndex];
return "";
}
final function bool SetValue(string S)
{
local int i;
i = Values.Find(S);
if (i == -1)
return false;
SelectedIndex = i;
return true;
}
Delegate OnComboChanged(KFGUI_ComboBox Sender);
defaultproperties
{
SelectedTextColor=(R=255, G=128, B=128, A=255)
TextColor=(R=255, G=255, B=255, A=255)
BorderSize=4
}

View File

@ -0,0 +1,30 @@
Class KFGUI_ComboSelector extends KFGUI_Clickable;
`include(Build.uci)
`include(Logger.uci)
var KFGUI_ComboBox Combo;
var int CurrentRow, OldRow;
function DrawMenu()
{
Owner.CurrentStyle.RenderComboList(Self);
}
function HandleMouseClick(bool bRight)
{
PlayMenuSound(MN_ClickButton);
DropInputFocus();
if (CurrentRow >= 0)
{
Combo.SelectedIndex = CurrentRow;
Combo.OnComboChanged(Combo);
}
}
defaultproperties
{
CurrentRow=-1
OldRow=-1
bFocusedPostDrawItem=true
}

View File

@ -0,0 +1,225 @@
// List box with components as items.
Class KFGUI_ComponentList extends KFGUI_List;
`include(Build.uci)
`include(Logger.uci)
var int VisRange[2];
var() int NumColumns;
var array<KFGUI_Base> ItemComponents;
// REMEMBER to call InitMenu() on the newly created component after values are init!!!
final function KFGUI_Base AddListComponent(class<KFGUI_Base> CompClass, optional float XS=1.f, optional float YS=1.f)
{
return AddComponentAtIndex(ItemComponents.Length, CompClass, XS, YS);
}
final function KFGUI_Base CreateComponent(class<KFGUI_Base> CompClass, optional float XS=1.f, optional float YS=1.f)
{
local KFGUI_Base G;
G = new(Self)CompClass;
if (G == None)
return None;
G.XPosition = (1.f - XS) * 0.5f;
G.YPosition = (1.f - YS) * 0.5f;
G.XSize = XS;
G.YSize = YS;
return G;
}
final function AddItem(KFGUI_Base Item)
{
AddItemAtIndex(ItemComponents.Length, Item);
}
final function AddItemAtIndex(int i, KFGUI_Base Item)
{
ItemComponents.InsertItem(i, Item);
}
final function KFGUI_Base AddComponentAtIndex(int i, class<KFGUI_Base> CompClass, optional float XS=1.f, optional float YS=1.f)
{
local KFGUI_Base G;
G = CreateComponent(CompClass, XS, YS);
G.Owner = Owner;
G.ParentComponent = Self;
ItemComponents.InsertItem(i, G);
return G;
}
function EmptyList()
{
ItemComponents.Length = 0;
}
function InitMenu()
{
Super.InitMenu();
ListCount = 0;
NumColumns = Max(NumColumns, 1);
}
function DrawMenu()
{
if (bDrawBackground)
{
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_INNERBORDER], CompPos[2], CompPos[3], 0,0, 128, 128);
}
}
function PreDraw()
{
local int i;
local byte j;
if (!bVisible)
return;
ComputeCoords();
// Update list size
i = ItemComponents.Length / NumColumns;
if (i != NumColumns)
{
ListCount = i;
UpdateListVis();
}
if (!ScrollBar.bDisabled && !ScrollBar.bHideScrollbar)
{
// First draw scrollbar to allow it to resize itself.
for (j=0; j < 4; ++j)
ScrollBar.InputPos[j] = CompPos[j];
if (OldXSize != InputPos[2])
{
OldXSize = InputPos[2];
}
ScrollBar.Canvas = Canvas;
ScrollBar.PreDraw();
// Then downscale our selves to give room for scrollbar.
CompPos[2] -= ScrollBar.CompPos[2];
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
PreDrawListItems();
CompPos[2] += ScrollBar.CompPos[2];
}
else
{
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
PreDrawListItems();
}
}
function PreDrawListItems()
{
local int i, XNum, r;
local float XS, YS;
XNum = 0;
r = 0;
XS = CompPos[2] / NumColumns;
YS = CompPos[3] / ListItemsPerPage;
VisRange[0] = (ScrollBar.CurrentScroll*NumColumns);
VisRange[1] = ItemComponents.Length;
for (i=VisRange[0]; i < VisRange[1]; ++i)
{
ItemComponents[i].Canvas = Canvas;
ItemComponents[i].InputPos[0] = CompPos[0]+XS*XNum;
ItemComponents[i].InputPos[1] = CompPos[1]+YS*r;
ItemComponents[i].InputPos[2] = XS;
ItemComponents[i].InputPos[3] = YS;
ItemComponents[i].PreDraw();
if (++XNum == NumColumns)
{
XNum = 0;
if (++r == ListItemsPerPage)
{
VisRange[1] = i+1;
break;
}
}
}
}
function ChangeListSize(int NewSize);
function MouseClick(bool bRight);
function MouseRelease(bool bRight);
function MouseLeave()
{
Super(KFGUI_Base).MouseLeave();
}
function MouseEnter()
{
Super(KFGUI_Base).MouseEnter();
}
function bool CaptureMouse()
{
local int i;
if (ItemComponents.Length > 0)
{
for (i=VisRange[1] - 1; i >= VisRange[0] && i < ItemComponents.Length; i--)
{
if (ItemComponents[i].CaptureMouse())
{
MouseArea = ItemComponents[i];
return true;
}
}
}
return Super.CaptureMouse();
}
function CloseMenu()
{
local int i;
for (i=0; i < ItemComponents.Length; ++i)
ItemComponents[i].CloseMenu();
Super.CloseMenu();
}
function NotifyLevelChange()
{
local int i;
for (i=0; i < ItemComponents.Length; ++i)
ItemComponents[i].NotifyLevelChange();
Super.NotifyLevelChange();
}
function InventoryChanged(optional KFWeapon Wep, optional bool bRemove)
{
local int i;
for (i=0; i < ItemComponents.Length; ++i)
ItemComponents[i].InventoryChanged(Wep, bRemove);
}
function MenuTick(float DeltaTime)
{
local int i;
Super.MenuTick(DeltaTime);
for (i=0; i < ItemComponents.Length; ++i)
ItemComponents[i].MenuTick(DeltaTime);
}
defaultproperties
{
ListCount=0
NumColumns=1
bClickable=true
bDrawBackground=false
}

View File

@ -0,0 +1,431 @@
Class KFGUI_EditBox extends KFGUI_Clickable;
`include(Build.uci)
`include(Logger.uci)
var enum eTextCase
{
TXTC_None,
TXTC_Upper,
TXTC_Lower,
} TextCase;
var Color FontColor;
var string TextStr, AllowedCharSet;
var bool bDrawBackground, bNoClearOnEnter, bMaskText, bIntOnly, bFloatOnly, bIncludeSign, bConvertSpaces, bCtrl, bAllSelected, bForceShowCaret;
var int MaxWidth;
var bool bReadOnly, bAlwaysNotify;
var int CaretPos, FirstVis, LastSizeX, LastCaret, LastLength;
var float TextScale;
function InitMenu()
{
Super.InitMenu();
if (bIntOnly || bFloatOnly)
{
AllowedCharSet = "0123456789";
if (bFloatOnly)
AllowedCharSet $= ".";
}
bAllSelected = true;
}
function SetText(string NewText, optional bool bIgnoreDelegate)
{
local bool bChanged;
bChanged = bAlwaysNotify || TextStr != NewText;
TextStr = NewText;
CaretPos = Len(TextStr);
if (bChanged && !bIgnoreDelegate)
TextChanged();
bAllSelected=true;
}
function bool NotifyInputChar(int Key, string Unicode)
{
local string Temp, S;
if (bReadOnly)
return false;
if (UniCode != "")
S = Unicode;
else S = Chr(Key);
if (Asc(S) == 13 || Asc(S) == 8 || Asc(S) == 27)
return false;
if (bCtrl)
return false;
if (bAllSelected)
{
TextStr="";
CaretPos=0;
bAllSelected=false;
}
if ((AllowedCharSet == "") || ( (bIncludeSign) && ( (S == "-") || (S == "+") ) && (TextStr == "") ) || (InStr(AllowedCharSet, S) >= 0))
{
if ((MaxWidth == 0) || (Len(TextStr) < MaxWidth))
{
if ((bConvertSpaces) && ((S == " ") || (S == "?") || (S == "\\")))
S = "_";
if ((TextStr == "") || ( CaretPos == Len(TextStr)))
{
TextStr = TextStr$S;
CaretPos=Len(TextStr);
}
else
{
Temp = Left(TextStr, CaretPos)$S$Mid(TextStr, CaretPos);
TextStr = Temp;
CaretPos++;
}
TextChanged();
return true;
}
}
return false;
}
function SetInputText(string S)
{
switch (TextCase)
{
case TXTC_Upper:
S = Caps(S);
break;
case TXTC_Lower:
S = Locs(S);
break;
}
TextStr = S;
TextChanged();
}
function AppendInputText(string Text)
{
local int Character;
while (Len(Text) > 0)
{
Character = Asc(Left(Text, 1));
Text = Mid(Text, 1);
if (Character >= 0x20 && Character < 0x100)
{
SetInputText(Left(TextStr, CaretPos) $ Chr(Character) $ Right(TextStr, Len(TextStr) - CaretPos));
CaretPos += 1;
}
}
}
function bool ProcessControlKey(name Key, EInputEvent Event)
{
if (Key == 'LeftControl' || Key == 'RightControl')
{
if (Event == IE_Released)
{
bCtrl = false;
}
else if (Event == IE_Pressed)
{
bCtrl = true;
}
return true;
}
else if (bCtrl && Event == IE_Pressed && GetPlayer() != None)
{
if (Key == 'V')
{
// paste
AppendInputText(GetPlayer().PasteFromClipboard());
return true;
}
else if (Key == 'C')
{
// copy
GetPlayer().CopyToClipboard(TextStr);
return true;
}
else if (Key == 'X')
{
// cut
if (TextStr != "")
{
GetPlayer().CopyToClipboard(TextStr);
SetInputText("");
CaretPos = 0;
}
return true;
}
}
return false;
}
function bool NotifyInputKey(int ControllerId, name Key, EInputEvent Event, float AmountDepressed, bool bGamepad)
{
local string Temp;
if (bReadOnly)
{
return false;
}
if (ProcessControlKey(Key, Event))
{
return false;
}
else if (Key == 'Escape' && Event == IE_Pressed)
{
if (TextStr != "")
{
SetInputText("");
CaretPos = 0;
return true;
}
else
{
if (ParentComponent != None)
{
ParentComponent.UserPressedEsc();
return true;
}
}
}
else if (Key == 'Enter' && Event == IE_Released)
{
if (TextStr != "")
{
Temp = TextStr;
OnTextFinished(self, Temp);
if (!bNoClearOnEnter)
{
SetInputText("");
CaretPos = 0;
}
}
return true;
}
else if (Key == 'Home')
{
CaretPos = 0;
return true;
}
else if (Key == 'End')
{
CaretPos = Len(TextStr);
return true;
}
else if (Event == IE_Pressed || Event == IE_Repeat)
{
if (Key == 'Backspace' || Key == 'Delete')
{
if (bAllSelected)
{
SetInputText("");
CaretPos = 0;
}
else if (CaretPos > 0)
{
SetInputText(Left(TextStr, CaretPos-1) $ Right(TextStr, Len(TextStr) - CaretPos));
CaretPos -= 1;
}
return true;
}
else if (Key == 'Left')
{
CaretPos = Max(0, CaretPos - 1);
return true;
}
else if (Key == 'Right')
{
CaretPos = Min(Len(TextStr), CaretPos + 1);
return true;
}
}
return true;
}
function string ConvertIllegal(string InputStr)
{
local int i, Max;
local string Retval;
local string C;
i = 0;
Max = Len(InputStr);
while ( i < Max)
{
C = Mid(InputStr, i,1);
if (AllowedCharSet != "" && InStr(AllowedCharSet, C) < 0)
{
C = "";
}
if (bConvertSpaces &&
((C == " ") || (C =="?") || (C == "\\")))
{
C = "_";
}
Retval = Retval $ C;
i++;
}
if (MaxWidth > 0)
return Left(Retval, MaxWidth);
return Retval;
}
function string GetText()
{
return TextStr;
}
function TextChanged()
{
OnChange(Self);
}
function DrawMenu()
{
local string Storage, FinalDraw, TmpString;
local int MaskIndex, StorageLength;
local float XL, YL, BoxWidth, FontScale, CursorY, BorderSize;
local FontRenderInfo FRI;
Super.DrawMenu();
if (bDrawBackground)
{
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_SMALL], CompPos[2], CompPos[3], 0,0, Owner.CurrentStyle.BorderTextures[`BOX_SMALL].GetSurfaceWidth(), Owner.CurrentStyle.BorderTextures[`BOX_SMALL].GetSurfaceHeight());
}
BorderSize = Owner.CurrentStyle.ScreenScale(4.f);
FRI.bClipText = true;
FRI.bEnableShadow = true;
Storage = TextStr;
if (bMaskText && Len(Storage) > 0)
{
StorageLength = Len(Storage);
Storage = "";
for (MaskIndex=1; MaskIndex <= StorageLength; MaskIndex++)
{
Storage $= "*";
}
}
Canvas.Font = Owner.CurrentStyle.PickFont(FontScale);
FontScale *= TextScale;
BoxWidth=CompPos[2]*0.9875;
if ((Len(Storage) != LastLength) || (CaretPos != LastCaret))
{
if (CaretPos <= FirstVis)
FirstVis = Max(0, CaretPos-1);
else
{
FinalDraw = Mid(Storage, FirstVis, CaretPos-FirstVis);
Canvas.TextSize(FinalDraw, XL, YL, FontScale, FontScale);
while ( (XL >= BoxWidth) && (FirstVis < Len(Storage)))
{
FirstVis++;
FinalDraw = Mid(Storage, FirstVis, CaretPos-FirstVis);
Canvas.TextSize(FinalDraw, XL, YL, FontScale, FontScale);
}
}
}
LastLength = Len(Storage);
if (bReadOnly)
{
FirstVis = 0;
}
FinalDraw = Mid(Storage, FirstVis, Len(Storage)-FirstVis);
if (!bReadOnly && (Owner.KeyboardFocus == self || bForceShowCaret))
{
if ((FirstVis == CaretPos) || (Len(FinalDraw) == 0))
{
Canvas.TextSize("W", XL, YL, FontScale, FontScale);
XL = BorderSize;
bAllSelected=false;
}
else
{
TmpString = Mid(FinalDraw, 0, CaretPos-FirstVis);
Canvas.TextSize(TmpString, XL, YL, FontScale, FontScale);
}
CursorY = (CompPos[3]/2) - ((YL-Owner.HUDOwner.ScaledBorderSize)/2);
if (bAllSelected)
{
Canvas.SetDrawColor(255, 255, 255, 195);
Canvas.SetPos(BorderSize, CursorY);
Canvas.DrawTile(Owner.DefaultPens[`PEN_WHITE], XL, YL-Owner.HUDOwner.ScaledBorderSize, 0, 0, Owner.DefaultPens[`PEN_WHITE].GetSurfaceWidth(), Owner.DefaultPens[`PEN_WHITE].GetSurfaceHeight());
}
else
{
Canvas.SetDrawColor(255, 255, 255, Owner.CursorFlash);
Canvas.SetPos(XL + (Len(FinalDraw) == 0 ? 0 : 3), CursorY);
Canvas.DrawTile(Owner.DefaultPens[`PEN_WHITE], 3, YL-Owner.HUDOwner.ScaledBorderSize, 0, 0, Owner.DefaultPens[`PEN_WHITE].GetSurfaceWidth(), Owner.DefaultPens[`PEN_WHITE].GetSurfaceHeight());
}
}
Canvas.DrawColor = FontColor;
Canvas.SetPos(BorderSize, (CompPos[3]/2) - (YL/2));
Canvas.DrawText(FinalDraw, ,FontScale, FontScale, FRI);
}
function HandleMouseClick(bool bRight)
{
if (Owner.KeyboardFocus != self)
{
GrabKeyFocus();
}
CaretPos = Len(TextStr);
bAllSelected = !bAllSelected;
}
Delegate OnChange(KFGUI_EditBox Sender);
Delegate OnTextFinished(KFGUI_EditBox Sender, string S);
defaultproperties
{
FontColor=(R=255, G=255, B=255, A=255)
MaxWidth=768
TextScale=1
TextCase=TXTC_None
LastCaret=-1
LastLength=-1
YSize=0.06
}

View File

@ -0,0 +1,105 @@
Class KFGUI_EditControl extends KFGUI_Clickable;
`include(Build.uci)
`include(Logger.uci)
var export editinline KFGUI_TextLable TextLable;
var transient float TextHeight, TextScale;
var transient Font TextFont;
var Canvas.FontRenderInfo TextFontInfo;
var(Lable) float LableWidth;
var(Lable) string LableString;
var(Lable) color LableColor; // Label text color.
var(Lable) byte FontScale;
var(Lable) bool bScaleByFontSize; // Scale this component height by font height.
function InitMenu()
{
if (LableString == "")
TextLable = None;
else
{
TextLable.SetText(LableString);
TextLable.FontScale = FontScale;
TextLable.XPosition = XPosition;
TextLable.YPosition = YPosition;
TextLable.XSize = (XSize*LableWidth*0.975);
TextLable.YSize = YSize;
TextLable.Owner = Owner;
TextLable.TextColor = LableColor;
TextLable.ParentComponent = Self;
TextLable.InitMenu();
XPosition+=(XSize*LableWidth);
XSize*=(1.f-LableWidth);
}
Super.InitMenu();
bClickable = !bDisabled;
}
function UpdateSizes()
{
// Update height.
if (bScaleByFontSize)
YSize = ((TextHeight*1.05) + 6) / InputPos[3];
}
function PreDraw()
{
local float XS;
local byte i;
Canvas.Font = Owner.CurrentStyle.PickFont(TextScale);
TextScale *= FontScale;
TextFont = Canvas.Font;
Canvas.TextSize("ABC", XS, TextHeight, TextScale, TextScale);
UpdateSizes();
Super.PreDraw();
if (TextLable != None)
{
TextLable.YSize = YSize;
TextLable.Canvas = Canvas;
for (i=0; i < 4; ++i)
TextLable.InputPos[i] = InputPos[i];
TextLable.PreDraw();
}
}
final function DrawClippedText(string S, float TScale, float MaxX)
{
local int i, l;
local float X, XL, YL;
l = Len(S);
for (i=0; i < l; ++i)
{
Canvas.TextSize(Mid(S, i,1), XL, YL, TScale, TScale);
if ((Canvas.CurX+X+XL) > MaxX)
{
--i;
break;
}
X+=XL;
}
Canvas.DrawText(Left(S, i), ,TScale, TScale, TextFontInfo);
}
defaultproperties
{
LableColor=(R=255, G=255, B=255, A=255)
FontScale=1
LableWidth=0.5
bScaleByFontSize=true
TextFontInfo=(bClipText=true, bEnableShadow=true)
Begin Object Class=KFGUI_TextLable Name=MyBoxLableText
AlignX=0
AlignY=1
TextFontInfo=(bClipText=true, bEnableShadow=true)
End Object
TextLable=MyBoxLableText
}

View File

@ -0,0 +1,110 @@
Class KFGUI_FloatingWindow extends KFGUI_Page
abstract;
`include(Build.uci)
`include(Logger.uci)
var() string WindowTitle; // Title of this window.
var float DragOffset[2], OpenAnimSpeed;
var KFGUI_FloatingWindowHeader HeaderComp;
var bool bDragWindow, bUseAnimation;
var float WindowFadeInTime;
var transient float OpenStartTime, OpenEndTime;
function InitMenu()
{
Super.InitMenu();
HeaderComp = new (Self) class'KFGUI_FloatingWindowHeader';
AddComponent(HeaderComp);
}
function ShowMenu()
{
Super.ShowMenu();
OpenStartTime = GetPlayer().WorldInfo.RealTimeSeconds;
OpenEndTime = GetPlayer().WorldInfo.RealTimeSeconds + OpenAnimSpeed;
}
function DrawMenu()
{
local float TempSize;
if (bUseAnimation)
{
TempSize = `TimeSinceEx(GetPlayer(), OpenStartTime);
if (WindowFadeInTime - TempSize > 0 && FrameOpacity != default.FrameOpacity)
FrameOpacity = (1.f - ((WindowFadeInTime - TempSize) / WindowFadeInTime)) * default.FrameOpacity;
}
Owner.CurrentStyle.RenderFramedWindow(Self);
if (HeaderComp != None)
{
HeaderComp.CompPos[3] = Owner.CurrentStyle.DefaultHeight;
HeaderComp.YSize = HeaderComp.CompPos[3] / CompPos[3]; // Keep header height fit the window height.
}
}
function SetWindowDrag(bool bDrag)
{
bDragWindow = bDrag;
if (bDrag)
{
DragOffset[0] = Owner.MousePosition.X-CompPos[0];
DragOffset[1] = Owner.MousePosition.Y-CompPos[1];
}
}
function bool CaptureMouse()
{
local int i;
if (bDragWindow && HeaderComp != None ) // Always keep focus on window frame now!
{
MouseArea = HeaderComp;
return true;
}
for (i=0; i < Components.Length; i++)
{
if (Components[i].CaptureMouse())
{
MouseArea = Components[i];
return true;
}
}
MouseArea = None;
return Super(KFGUI_Base).CaptureMouse();
}
function PreDraw()
{
local float Frac, CenterX, CenterY;
if (bUseAnimation)
{
Frac = Owner.CurrentStyle.TimeFraction(OpenStartTime, OpenEndTime, GetPlayer().WorldInfo.RealTimeSeconds);
XSize = Lerp(default.XSize*0.75, default.XSize, Frac);
YSize = Lerp(default.YSize*0.75, default.YSize, Frac);
CenterX = (default.XPosition + default.XSize * 0.5) - ((default.XSize*0.75)/2);
CenterY = (default.YPosition + default.YSize * 0.5) - ((default.YSize*0.75)/2);
XPosition = Lerp(CenterX, default.XPosition, Frac);
YPosition = Lerp(CenterY, default.YPosition, Frac);
if (bDragWindow)
{
XPosition = FClamp(Owner.MousePosition.X-DragOffset[0], 0,InputPos[2]-CompPos[2]) / InputPos[2];
YPosition = FClamp(Owner.MousePosition.Y-DragOffset[1], 0,InputPos[3]-CompPos[3]) / InputPos[3];
}
}
Super.PreDraw();
}
defaultproperties
{
bUseAnimation=true
OpenAnimSpeed=0.05f
WindowFadeInTime=0.2f
}

View File

@ -0,0 +1,26 @@
Class KFGUI_FloatingWindowHeader extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var bool bDragWindow;
function PreDraw()
{
ComputeCoords();
}
function MouseClick(bool bRight)
{
if (!bRight)
KFGUI_FloatingWindow(ParentComponent).SetWindowDrag(true);
}
function MouseRelease(bool bRight)
{
if (!bRight)
KFGUI_FloatingWindow(ParentComponent).SetWindowDrag(false);
}
defaultproperties
{
bClickable=true
}

131
YAS/Classes/KFGUI_Frame.uc Normal file
View File

@ -0,0 +1,131 @@
Class KFGUI_Frame extends KFGUI_FloatingWindow;
`include(Build.uci)
`include(Logger.uci)
var() float EdgeSize[4]; // Pixels wide for edges (left, top, right, bottom).
var() float HeaderSize[2]; // Pixels wide for edges (left, top).
var() Texture FrameTex;
var() bool bDrawHeader, bHeaderCenter, bUseLegacyDrawTile, bDrawBackground;
var() float FontScale;
function InitMenu()
{
Super(KFGUI_Page).InitMenu();
}
function DrawMenu()
{
local float TempSize;
if (bUseAnimation)
{
TempSize = `TimeSinceEx(GetPlayer(), OpenStartTime);
if (WindowFadeInTime - TempSize > 0 && FrameOpacity != default.FrameOpacity)
FrameOpacity = (1.f - ((WindowFadeInTime - TempSize) / WindowFadeInTime)) * default.FrameOpacity;
}
if (bDrawBackground)
{
OnDrawFrame(Canvas, CompPos[2], CompPos[3]);
}
}
delegate OnDrawFrame(Canvas C, float W, Float H)
{
local float T, XL, YL, HeaderH;
local FontRenderInfo FRI;
if (FrameTex == None)
{
return;
}
C.SetDrawColor(255, 255, 255, FrameOpacity);
if (bUseLegacyDrawTile)
{
Owner.CurrentStyle.DrawTileStretched(FrameTex, 0,0, W,H);
}
else
{
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(FrameTex, W,H, 0,0, FrameTex.GetSurfaceWidth(), FrameTex.GetSurfaceHeight());
}
if (bDrawHeader && WindowTitle != "")
{
FRI.bClipText = true;
FRI.bEnableShadow = true;
C.Font = Owner.CurrentStyle.MainFont;
T = Owner.CurrentStyle.ScreenScale(FontScale);
C.SetDrawColor(250, 250, 250, FrameOpacity);
C.TextSize(WindowTitle, XL, YL, T, T);
HeaderH = EdgeSize[1]-HeaderSize[1];
if (bHeaderCenter)
C.SetPos((W/2) - (XL/2), (HeaderH/2) - (YL/2));
else C.SetPos(HeaderSize[0], (HeaderH/2) - (YL/2));
C.DrawText(WindowTitle, ,T, T,FRI);
}
}
function PreDraw()
{
local int i;
local byte j;
local float Frac, CenterX, CenterY;
if (!bVisible)
return;
if (bUseAnimation)
{
Frac = Owner.CurrentStyle.TimeFraction(OpenStartTime, OpenEndTime, GetPlayer().WorldInfo.RealTimeSeconds);
XSize = Lerp(default.XSize*0.75, default.XSize, Frac);
YSize = Lerp(default.YSize*0.75, default.YSize, Frac);
CenterX = (default.XPosition + default.XSize * 0.5) - ((default.XSize*0.75)/2);
CenterY = (default.YPosition + default.YSize * 0.5) - ((default.YSize*0.75)/2);
XPosition = Lerp(CenterX, default.XPosition, Frac);
YPosition = Lerp(CenterY, default.YPosition, Frac);
}
ComputeCoords();
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
for (i=0; i < Components.Length; ++i)
{
Components[i].Canvas = Canvas;
for (j=0; j < 4; ++j)
{
Components[i].InputPos[j] = CompPos[j]+EdgeSize[j];
}
Components[i].PreDraw();
}
}
defaultproperties
{
bUseAnimation=false
bDrawHeader=true
bUseLegacyDrawTile=true
bDrawBackground=true
FontScale=0.35f
FrameOpacity=255
HeaderSize(0)=26.f
HeaderSize(1)=8.f
EdgeSize(0)=20
EdgeSize(1)=35
EdgeSize(2)=-40
EdgeSize(3)=-50
}

146
YAS/Classes/KFGUI_Image.uc Normal file
View File

@ -0,0 +1,146 @@
Class KFGUI_Image extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var enum eImageStyle
{
ISTY_Normal,
ISTY_Stretched
} ImageStyle;
var enum eScaleStyle
{
ISTY_Height,
ISTY_Width
} ScaleStyle;
var Color ImageColor;
var Texture Image;
var bool bAlignCenter, bForceUniformSize;
var int X1, Y1, X2, Y2;
var float ImageScale;
function DrawMenu()
{
local float X, Y, XL, YL;
if (Image == None)
return;
DrawBackground(Canvas, CompPos[2], CompPos[3]);
Canvas.DrawColor = ImageColor;
switch (ImageStyle)
{
case ISTY_Normal:
if (X1 != -1)
X = X1;
else X = 0;
if (Y1 != -1)
Y = Y1;
else Y = 0;
if (bForceUniformSize)
{
if (ScaleStyle == ISTY_Height)
{
YL = CompPos[3];
XL = YL;
}
else
{
XL = CompPos[2];
YL = XL;
}
}
else
{
if (Y2 == -1)
YL = FMin(CompPos[3], Image.GetSurfaceHeight());
else YL = (Y2-Y1);
if (X2 == -1)
XL = FMin(CompPos[2], Image.GetSurfaceWidth());
else XL = (X2-X1);
}
if (bAlignCenter)
{
Canvas.SetPos((CompPos[2]/2) - (XL/2), (CompPos[3]/2) - (YL/2));
Canvas.DrawTile(Image, XL, YL, X, Y, Image.GetSurfaceWidth(), Image.GetSurfaceHeight());
}
else
{
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(Image, XL, YL, X, Y, Image.GetSurfaceWidth(), Image.GetSurfaceHeight());
}
break;
case ISTY_Stretched:
if (X1 < 0 && X2 < 0 && Y1 < 0 && Y2 < 0 )
Owner.CurrentStyle.DrawTileStretched(Image, 0.f, 0.f, CompPos[2], CompPos[3]);
else
{
if (X1 != -1)
X = X1;
else X = 0;
if (Y1 != -1)
Y = Y1;
else Y = 0;
if (bForceUniformSize)
{
if (ScaleStyle == ISTY_Height)
{
YL = CompPos[3];
XL = YL;
}
else
{
XL = CompPos[2];
YL = XL;
}
}
else
{
if (Y2 == -1)
YL = FMin(CompPos[3], Image.GetSurfaceHeight());
else YL = (Y2-Y1);
if (X2 == -1)
XL = FMin(CompPos[2], Image.GetSurfaceWidth());
else XL = (X2-X1);
}
if (bAlignCenter)
{
Canvas.SetPos((CompPos[2]/2) - (XL/2), (CompPos[3]/2) - (YL/2));
Canvas.DrawTile(Image, CompPos[2], CompPos[3], X, Y, Image.GetSurfaceWidth(), Image.GetSurfaceHeight());
}
else
{
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTile(Image, CompPos[2], CompPos[3], X, Y, Image.GetSurfaceWidth(), Image.GetSurfaceHeight());
}
break;
}
break;
}
}
delegate DrawBackground(Canvas C, float W, Float H);
defaultproperties
{
ImageColor=(R=255, G=255, B=255, A=255)
ImageStyle=ISTY_Normal
X1=-1
X2=-1
Y1=-1
Y2=-1
}

222
YAS/Classes/KFGUI_List.uc Normal file
View File

@ -0,0 +1,222 @@
// List box with custom render code for the items.
Class KFGUI_List extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
var() bool bDrawBackground, bHideScrollbar, bUseFocusSound;
var() protectedwrite int ListCount;
var() int ListItemsPerPage;
var() color BackgroundColor;
var KFGUI_ScrollBarV ScrollBar;
var transient float OldXSize, ItemHeight, MouseYHit;
var transient int FocusMouseItem, LastFocusItem;
var byte PressedDown[2];
var bool bPressedDown;
delegate OnDrawItem(Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus);
// Requires bClickable=true to receive this event.
delegate OnClickedItem(int Index, bool bRight, int MouseX, int MouseY);
delegate OnDblClickedItem(int Index, bool bRight, int MouseX, int MouseY);
function InitMenu()
{
Super.InitMenu();
ScrollBar = KFGUI_ScrollBarV(FindComponentID('Scrollbar'));
ScrollBar.bHideScrollbar = bHideScrollbar;
UpdateListVis();
}
function DrawMenu()
{
local int i, n;
local float Y;
local bool bCheckMouse;
if (bDrawBackground)
{
Canvas.DrawColor = BackgroundColor;
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_INNERBORDER], CompPos[2], CompPos[3], 0,0, 128, 128);
}
// Mouse focused item check.
bCheckMouse = bClickable && bFocused;
FocusMouseItem = -1;
if (bCheckMouse)
MouseYHit = Owner.MousePosition.Y - CompPos[1];
n = ScrollBar.CurrentScroll;
ItemHeight = CompPos[3] / ListItemsPerPage;
Y = 0.f;
for (i=0; i < ListItemsPerPage; ++i)
{
if (n >= ListCount)
break;
if (bCheckMouse && FocusMouseItem == -1)
{
if (MouseYHit < ItemHeight)
FocusMouseItem = n;
else MouseYHit -= ItemHeight;
}
OnDrawItem(Canvas, n,Y, ItemHeight, CompPos[2], (FocusMouseItem == n));
Y+=ItemHeight;
++n;
}
if (LastFocusItem != FocusMouseItem)
{
LastFocusItem = FocusMouseItem;
if (bUseFocusSound)
{
PlayMenuSound(MN_FocusHover);
}
}
}
function PreDraw()
{
local int i;
local byte j;
if (!bVisible)
return;
ComputeCoords();
if (!ScrollBar.bDisabled && !ScrollBar.bHideScrollbar)
{
// First draw scrollbar to allow it to resize itself.
for (j=0; j < 4; ++j)
ScrollBar.InputPos[j] = CompPos[j];
if (OldXSize != InputPos[2])
{
OldXSize = InputPos[2];
ScrollBar.XPosition = 1.f - ScrollBar.GetWidth();
}
ScrollBar.Canvas = Canvas;
ScrollBar.PreDraw();
// Then downscale our selves to give room for scrollbar.
CompPos[2] -= ScrollBar.CompPos[2];
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
CompPos[2] += ScrollBar.CompPos[2];
}
else
{
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
}
// Then draw rest of components.
for (i=0; i < Components.Length; ++i)
{
if (Components[i] != ScrollBar)
{
Components[i].Canvas = Canvas;
for (j=0; j < 4; ++j)
Components[i].InputPos[j] = CompPos[j];
Components[i].PreDraw();
}
}
}
function UpdateListVis()
{
if (ListCount <= ListItemsPerPage)
{
ScrollBar.UpdateScrollSize(0, 1,1, 1);
ScrollBar.SetDisabled(true);
}
else
{
ScrollBar.UpdateScrollSize(ScrollBar.CurrentScroll, (ListCount-ListItemsPerPage), 1,ListItemsPerPage);
ScrollBar.SetDisabled(false);
}
}
function ChangeListSize(int NewSize)
{
if (ListCount == NewSize)
return;
ListCount = NewSize;
UpdateListVis();
}
final function int GetListSize()
{
return ListCount;
}
function DoubleMouseClick(bool bRight)
{
if (!bDisabled && bClickable)
{
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
OnDblClickedItem(FocusMouseItem, bRight, Owner.MousePosition.X-CompPos[0], MouseYHit);
}
}
function MouseClick(bool bRight)
{
if (!bDisabled && bClickable)
{
PressedDown[byte(bRight)] = 1;
bPressedDown = true;
}
}
function MouseRelease(bool bRight)
{
if (!bDisabled && bClickable && PressedDown[byte(bRight)] == 1)
{
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
OnClickedItem(FocusMouseItem, bRight, Owner.MousePosition.X-CompPos[0], MouseYHit);
}
}
function MouseLeave()
{
Super.MouseLeave();
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
function MouseEnter()
{
Super.MouseEnter();
LastFocusItem = -1;
}
function ScrollMouseWheel(bool bUp)
{
if (!ScrollBar.bDisabled)
ScrollBar.ScrollMouseWheel(bUp);
}
function NotifyMousePaused()
{
if (Owner.InputFocus == None && FocusMouseItem >= 0)
OnMouseRest(FocusMouseItem);
}
Delegate OnMouseRest(int Item);
defaultproperties
{
ListItemsPerPage=7
ListCount=1
BackgroundColor=(R=0, G=0, B=0, A=75)
bDrawBackground=false
bUseFocusSound=false
Begin Object Class=KFGUI_ScrollBarV Name=ListScroller
XPosition=0.96
YPosition=0
XSize=0.04
YSize=1.05
ID="Scrollbar"
End Object
Components.Add(ListScroller)
}

View File

@ -0,0 +1,228 @@
Class KFGUI_ListHorz extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
var() bool bDrawBackground, bHideScrollbar, bUseFocusSound;
var() protected int ListCount;
var() int ListItemsPerPage;
var() float ButtonScale;
var() color BackgroundColor;
var KFGUI_ScrollBarH ScrollBar;
var transient float OldYSize, ItemWidth, MouseXHit;
var transient int FocusMouseItem, LastFocusItem;
var byte PressedDown[2];
var bool bPressedDown;
delegate OnDrawItem(Canvas C, int Index, float XOffset, float Height, float Width, bool bFocus);
// Requires bClickable=true to receive this event.
delegate OnClickedItem(int Index, bool bRight, int MouseX, int MouseY);
delegate OnDblClickedItem(int Index, bool bRight, int MouseX, int MouseY);
function InitMenu()
{
Super.InitMenu();
ScrollBar = KFGUI_ScrollBarH(FindComponentID('Scrollbar'));
ScrollBar.bHideScrollbar = bHideScrollbar;
ScrollBar.ButtonScale = ButtonScale <= 0.f ? 1.f : ButtonScale;
UpdateListVis();
}
function DrawMenu()
{
local int i, n;
local float X;
local bool bCheckMouse;
if (bDrawBackground)
{
//Canvas.DrawColor = BackgroundColor;
Canvas.SetDrawColor(250, 250, 250, 255);
Canvas.SetPos(0.f, 0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_INNERBORDER], CompPos[2], CompPos[3], 0,0, 128, 128);
}
// Mouse focused item check.
bCheckMouse = bClickable && bFocused;
FocusMouseItem = -1;
if (bCheckMouse)
MouseXHit = Owner.MousePosition.X - CompPos[0];
n = ScrollBar.CurrentScroll;
ItemWidth = CompPos[2] / ListItemsPerPage;
X = 0.f;
for (i=0; i < ListItemsPerPage; ++i)
{
if (n >= ListCount)
break;
if (bCheckMouse && FocusMouseItem == -1)
{
if (MouseXHit < ItemWidth)
FocusMouseItem = n;
else MouseXHit -= ItemWidth;
}
OnDrawItem(Canvas, n,X, CompPos[3], ItemWidth, (FocusMouseItem == n));
X+=ItemWidth;
++n;
}
if (LastFocusItem != FocusMouseItem)
{
LastFocusItem = FocusMouseItem;
if (bUseFocusSound)
{
PlayMenuSound(MN_FocusHover);
}
}
}
function PreDraw()
{
local int i;
local byte j;
if (!bVisible)
return;
ComputeCoords();
if (!ScrollBar.bDisabled && !ScrollBar.bHideScrollbar)
{
// First draw scrollbar to allow it to resize itself.
for (j=0; j < 4; ++j)
ScrollBar.InputPos[j] = CompPos[j];
if (OldYSize != InputPos[3])
{
OldYSize = InputPos[3];
ScrollBar.YPosition = 1.f - ScrollBar.GetWidth();
}
ScrollBar.Canvas = Canvas;
ScrollBar.PreDraw();
// Then downscale our selves to give room for scrollbar.
CompPos[3] -= ScrollBar.CompPos[3]*1.15f;
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
CompPos[3] += ScrollBar.CompPos[3]*1.15f;
}
else
{
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
}
// Then draw rest of components.
for (i=0; i < Components.Length; ++i)
{
if (Components[i] != ScrollBar)
{
Components[i].Canvas = Canvas;
for (j=0; j < 4; ++j)
Components[i].InputPos[j] = CompPos[j];
Components[i].PreDraw();
}
}
}
function UpdateListVis()
{
if (ListCount <= ListItemsPerPage)
{
ScrollBar.UpdateScrollSize(0, 1,1, 1);
ScrollBar.SetDisabled(true);
}
else
{
ScrollBar.UpdateScrollSize(ScrollBar.CurrentScroll, (ListCount-ListItemsPerPage), 1,ListItemsPerPage);
ScrollBar.SetDisabled(false);
}
}
function ChangeListSize(int NewSize)
{
if (ListCount == NewSize)
return;
ListCount = NewSize;
UpdateListVis();
}
final function int GetListSize()
{
return ListCount;
}
function DoubleMouseClick(bool bRight)
{
if (!bDisabled && bClickable)
{
PlayMenuSound(MN_ClickButton);
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
OnDblClickedItem(FocusMouseItem, bRight, MouseXHit, Owner.MousePosition.Y-CompPos[1]);
}
}
function MouseClick(bool bRight)
{
if (!bDisabled && bClickable)
{
PressedDown[byte(bRight)] = 1;
bPressedDown = true;
}
}
function MouseRelease(bool bRight)
{
if (!bDisabled && bClickable && PressedDown[byte(bRight)] == 1)
{
PlayMenuSound(MN_ClickButton);
PressedDown[byte(bRight)] = 0;
bPressedDown = (PressedDown[0] != 0 || PressedDown[1] != 0);
OnClickedItem(FocusMouseItem, bRight, MouseXHit, Owner.MousePosition.Y-CompPos[1]);
}
}
function MouseLeave()
{
Super.MouseLeave();
PressedDown[0] = 0;
PressedDown[1] = 0;
bPressedDown = false;
}
function MouseEnter()
{
Super.MouseEnter();
LastFocusItem = -1;
if (!bDisabled && bClickable && bUseFocusSound)
PlayMenuSound(MN_FocusHover);
}
function ScrollMouseWheel(bool bUp)
{
if (!ScrollBar.bDisabled)
ScrollBar.ScrollMouseWheel(bUp);
}
function NotifyMousePaused()
{
if (Owner.InputFocus == None && FocusMouseItem >= 0)
OnMouseRest(FocusMouseItem);
}
Delegate OnMouseRest(int Item);
defaultproperties
{
ListItemsPerPage=7
ListCount=1
BackgroundColor=(R=0, G=0, B=0, A=75)
bDrawBackground=false
bUseFocusSound=false
Begin Object Class=KFGUI_ScrollBarH Name=ListScroller
XPosition=0
YPosition=0.96
XSize=1
YSize=0.04
ID="Scrollbar"
End Object
Components.Add(ListScroller)
}

View File

@ -0,0 +1,47 @@
Class KFGUI_ListItem extends Object
transient;
`include(Build.uci)
`include(Logger.uci)
var KFGUI_ListItem Next;
var array<string> Columns, SortColumns;
var int Index, Value;
var transient string Temp; // Cache sorting key.
function SetValue(string S, int i, string SortStr)
{
ParseStringIntoArray(S, Columns, "\n", false);
if (SortStr == "")
SortColumns.Length = 0;
else ParseStringIntoArray(Caps(SortStr), SortColumns, "\n", false);
Value = i;
}
// Return string to draw on HUD.
function string GetDisplayStr(int Column)
{
if (Column < Columns.Length)
return Columns[Column];
return "";
}
// Return string to compare string with.
function string GetSortStr(int Column)
{
if (SortColumns.Length > 0)
{
if (Column < SortColumns.Length)
return SortColumns[Column];
}
if (Column < Columns.Length)
return Caps(Columns[Column]);
return "";
}
// Clear
function Clear()
{
Columns.Length = 0;
}

View File

@ -0,0 +1,150 @@
Class KFGUI_MultiComponent extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var() export editinline array<KFGUI_Base> Components;
function InitMenu()
{
local int i;
for (i=0; i < Components.Length; ++i)
{
Components[i].Owner = Owner;
Components[i].ParentComponent = Self;
Components[i].InitMenu();
}
}
function ShowMenu()
{
local int i;
for (i=0; i < Components.Length; ++i)
Components[i].ShowMenu();
}
function PreDraw()
{
local int i;
local byte j;
if (!bVisible)
return;
ComputeCoords();
Canvas.SetDrawColor(255, 255, 255);
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
for (i=0; i < Components.Length; ++i)
{
Components[i].Canvas = Canvas;
for (j=0; j < 4; ++j)
Components[i].InputPos[j] = CompPos[j];
Components[i].PreDraw();
}
}
function InventoryChanged(optional KFWeapon Wep, optional bool bRemove)
{
local int i;
for (i=0; i < Components.Length; ++i)
Components[i].InventoryChanged(Wep, bRemove);
}
function MenuTick(float DeltaTime)
{
local int i;
Super.MenuTick(DeltaTime);
for (i=0; i < Components.Length; ++i)
Components[i].MenuTick(DeltaTime);
}
function AddComponent(KFGUI_Base C)
{
Components[Components.Length] = C;
C.Owner = Owner;
C.ParentComponent = Self;
C.InitMenu();
}
function CloseMenu()
{
local int i;
for (i=0; i < Components.Length; ++i)
Components[i].CloseMenu();
}
function bool CaptureMouse()
{
local int i;
for (i=Components.Length - 1; i >= 0; i--)
{
if (Components[i].CaptureMouse())
{
MouseArea = Components[i];
return true;
}
}
MouseArea = None;
return Super.CaptureMouse(); // check with frame itself.
}
function bool ReceievedControllerInput(int ControllerId, name Key, EInputEvent Event)
{
local int i;
for (i=Components.Length - 1; i >= 0; i--)
{
if (Components[i].ReceievedControllerInput(ControllerId, Key, Event))
{
return true;
}
}
return Super.ReceievedControllerInput(ControllerId, Key, Event);
}
function KFGUI_Base FindComponentID(name InID)
{
local int i;
local KFGUI_Base Result;
if (ID == InID)
Result = Self;
else
{
for (i=0; i < Components.Length && Result == None; ++i)
Result = Components[i].FindComponentID(InID);
}
return Result;
}
function FindAllComponentID(name InID, out array < KFGUI_Base> Res)
{
local int i;
if (ID == InID)
Res[Res.Length] = Self;
for (i=0; i < Components.Length; ++i)
Components[i].FindAllComponentID(InID, Res);
}
function RemoveComponent(KFGUI_Base B)
{
local int i;
for (i=0; i < Components.Length; ++i)
if (Components[i] == B)
{
Components.Remove(i, 1);
B.CloseMenu();
return;
}
for (i=0; i < Components.Length; ++i)
Components[i].RemoveComponent(B);
}
function NotifyLevelChange()
{
local int i;
for (i=0; i < Components.Length; ++i)
Components[i].NotifyLevelChange();
}

29
YAS/Classes/KFGUI_Page.uc Normal file
View File

@ -0,0 +1,29 @@
Class KFGUI_Page extends KFGUI_MultiComponent
abstract;
`include(Build.uci)
`include(Logger.uci)
var() byte FrameOpacity; // Transperancy of the frame.
var() bool bPersistant, // Reuse the same menu object throughout the level.
bUnique, // If calling OpenMenu multiple times with same menu class, only open one instance of it.
bAlwaysTop, // This menu should stay always on top.
bOnlyThisFocus, // Only this menu should stay focused.
bNoBackground; // Don't draw the background.
var bool bWindowFocused; // This page is currently focused.
function DrawMenu()
{
if (!bNoBackground)
{
Owner.CurrentStyle.RenderWindow(Self);
}
}
defaultproperties
{
bUnique=true
bPersistant=true
FrameOpacity=175
}

View File

@ -0,0 +1,137 @@
class KFGUI_ProgressBar extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var Texture BarBack;
var Texture BarTop;
var Color BarColor;
var float Low;
var float High;
var float Value;
var float CaptionWidth;
var byte CaptionAlign;
var byte ValueRightAlign;
var string Caption;
var float GraphicMargin;
var float ValueRightWidth;
var bool bShowLow;
var bool bShowHigh;
var bool bShowValue;
var int NumDecimals;
var byte BorderSize;
function DrawMenu()
{
local float Left, Top, Width, Height;
local float W, Sc;
local string S;
Super.DrawMenu();
Left = 0.f;
Top = 0.f;
Width = CompPos[2];
Height = CompPos[3];
// Select the right font in the Canvas
Canvas.Font = Owner.CurrentStyle.PickFont(Sc);
if (CaptionWidth > 0.0 && Width > 0 && Len(Caption) > 0)
{
W = CaptionWidth;
if (W < 1.0)
{
W *= Width;
}
if (W > Width)
{
W = Width;
}
// Draw the label
Owner.CurrentStyle.DrawTextJustified(CaptionAlign, Left, Top, Left + W, Top + Height, Caption, Sc, Sc);
Left += W;
Width -= W;
}
if ((bShowHigh || bShowValue) && ValueRightWidth > 0.0 && Width > 0.0)
{
W = ValueRightWidth;
if (W < 1.0)
{
W *= Width;
}
if (W > Width)
{
W = Width;
}
if (bShowValue && bShowHigh)
{
S = int(Value)$"/"$int(High);
}
else if (bShowValue)
{
S = string(int(Value));
}
else
{
S = string(int(High));
}
Owner.CurrentStyle.DrawTextJustified(ValueRightAlign, Left + Width - W, Top, Left + Width, Top + Height, S, Sc, Sc);
Width -= W;
}
if (Width > GraphicMargin)
{
Width -= GraphicMargin;
Left += GraphicMargin / 2;
}
Canvas.SetDrawColor(255, 255, 255, 255);
if (Width > 0.0 && BarBack != None)
{
Owner.CurrentStyle.DrawTileStretched(BarBack, Left, Top, Width, Height);
}
if (Width > 0.0 && BarTop != None && Value > Low)
{
Canvas.DrawColor = BarColor;
Owner.CurrentStyle.DrawTileStretched(BarTop, Left + BorderSize, Top + BorderSize, (Width - (BorderSize * 2)) * (Value/High), Height - (BorderSize * 2));
}
}
function SetValue(float val)
{
Value=val;
}
function float GetValue()
{
return Value;
}
defaultproperties
{
BarColor=(R=255, G=255, B=255, A=255)
Low=0.f
High=100.f
Value=0.f
bShowLow=false
bShowHigh=false
bShowValue=true
CaptionWidth=0.45
ValueRightWidth=0.2
ValueRightAlign=0
NumDecimals=0
}

View File

@ -0,0 +1,166 @@
Class KFGUI_RightClickMenu extends KFGUI_Clickable;
`include(Build.uci)
`include(Logger.uci)
struct FRowItem
{
var string Text, ToolTip;
var bool bSplitter, bDisabled;
};
var array<FRowItem> ItemRows;
var int CurrentRow, OldRow;
var int EdgeSize;
var int OldSizeX;
var transient bool bDrawToolTip;
var Color BoxColor, OutlineColor;
function OpenMenu(KFGUI_Base Menu)
{
Owner = Menu.Owner;
InitMenu();
PlayMenuSound(MN_Dropdown);
GetInputFocus();
OldSizeX = 0;
}
final function ComputeSize()
{
local float XS, YS, XL, YL, Scalar;
local int i;
local string S;
if (OldSizeX == Owner.ScreenSize.X)
return;
if (ItemRows.Length == 0)
{
YS = 0;
XS = 50;
}
else
{
Canvas.Font = Owner.CurrentStyle.PickFont(Scalar);
for (i=0; i < ItemRows.Length; ++i)
{
if (ItemRows[i].bSplitter)
S = "----";
else S = ItemRows[i].Text;
Canvas.TextSize(S, XL, YL, Scalar, Scalar);
XS = FMax(XS, XL);
YS += YL;
}
}
XSize = (XS+(EdgeSize*12)) / Owner.ScreenSize.X;
YSize = (YS+(EdgeSize*4)) / Owner.ScreenSize.Y;
ComputePosition();
OldSizeX = Owner.ScreenSize.X;
}
function ComputePosition()
{
XPosition = float(Owner.MousePosition.X+4) / Owner.ScreenSize.X;
YPosition = float(Owner.MousePosition.Y+4) / Owner.ScreenSize.Y;
if ((XPosition+XSize) > 1.f)
YPosition = (float(Owner.MousePosition.X) / Owner.ScreenSize.X) - XSize; // Move to left side of mouse pointer.
if ((YPosition+YSize) > 1.f)
YPosition -= ((YPosition+YSize)-1.f); // Move up until fit on screen.
}
final function AddRow(string Text, bool bDisable, optional string AltToolTip)
{
local int i;
i = ItemRows.Length;
ItemRows.Length = i+1;
if (Text == "-")
ItemRows[i].bSplitter = true;
else
{
ItemRows[i].Text = Text;
ItemRows[i].ToolTip = AltToolTip;
ItemRows[i].bDisabled = bDisable;
}
}
function PreDraw()
{
ComputeSize();
Super.PreDraw();
}
function DrawMenu()
{
Owner.CurrentStyle.RenderRightClickMenu(Self);
if (bDrawToolTip)
{
if (OldRow != CurrentRow)
bDrawToolTip = false;
DrawToolTip();
}
}
function DrawToolTip()
{
local float X, Y,XL, YL, BoxW, BoxH, TextX, TextY, Scalar, CursorSize;
local string S;
Canvas.Reset();
Canvas.SetClip(float(Owner.ScreenSize.X), float(Owner.ScreenSize.Y));
S = ItemRows[CurrentRow].ToolTip;
Canvas.Font = Owner.CurrentStyle.PickFont(Scalar);
Canvas.TextSize(S, XL, YL, Scalar, Scalar);
CursorSize = Owner.CurrentStyle.ScreenScale(Owner.CursorSize);
X = Owner.MousePosition.X+CursorSize;
Y = Owner.MousePosition.Y+CursorSize;
BoxW = XL * 1.05f;
BoxH = YL * 1.25f;
while ((X + BoxW) > Canvas.ClipX)
{
X -= 0.01;
}
Owner.CurrentStyle.DrawOutlinedBox(X, Y, BoxW, BoxH, EdgeSize, MakeColor(5, 5,5, 255), MakeColor(115, 115, 115, 255));
TextX = X + (BoxW/2) - (XL/2) - (EdgeSize/2);
TextY = Y + (BoxH/2) - (YL/2) - (EdgeSize/2);
Canvas.DrawColor = class'HUD'.default.WhiteColor;
Canvas.SetPos(TextX, TextY);
Canvas.DrawText(S, ,Scalar, Scalar);
}
function HandleMouseClick(bool bRight)
{
if (CurrentRow >= 0 && (ItemRows[CurrentRow].bSplitter || ItemRows[CurrentRow].bDisabled))
return;
OnSelectedItem(CurrentRow);
PlayMenuSound(MN_ClickButton);
DropInputFocus();
}
function LostInputFocus()
{
OnBecameHidden(Self);
OldRow = -1;
CurrentRow = -1;
}
function NotifyMousePaused()
{
if (CurrentRow != -1 && ItemRows[CurrentRow].ToolTip != "")
bDrawToolTip = true;
}
Delegate OnSelectedItem(int Index);
Delegate OnBecameHidden(KFGUI_RightClickMenu M);
defaultproperties
{
CurrentRow=-1
OldRow=-1
bFocusedPostDrawItem=true
bHoverSound=false
EdgeSize=2
BoxColor=(R=5, G=5, B=5, A=200)
OutlineColor=(R=115, G=115, B=115, A=255)
}

View File

@ -0,0 +1,126 @@
Class KFGUI_ScrollBarBase extends KFGUI_Clickable
abstract;
`include(Build.uci)
`include(Logger.uci)
var() int MinRange, MaxRange, ScrollStride, PageStep;
var() float ButtonScale; // Button width (scaled by default font height).
var int CurrentScroll;
// In-runtime values.
var transient float CalcButtonScale;
var transient int SliderScale, ButtonOffset, GrabbedOffset;
var transient bool bGrabbedScroller;
var bool bVertical, bHideScrollbar;
final function UpdateScrollSize(int Current, int MxRange, int Stride, int StepStride, optional int MnRange)
{
MaxRange = MxRange;
MinRange = MnRange;
ScrollStride = Stride;
PageStep = StepStride;
SetValue(Current);
}
final function AddValue(int V)
{
SetValue(CurrentScroll+V);
}
final function SetValue(int V)
{
CurrentScroll = Clamp((V / ScrollStride) * ScrollStride, MinRange, MaxRange);
OnScrollChange(Self, CurrentScroll);
}
final function int GetValue()
{
return CurrentScroll;
}
Delegate OnScrollChange(KFGUI_ScrollBarBase Sender, int Value);
// Get UI width.
function float GetWidth()
{
CalcButtonScale = ButtonScale*Owner.CurrentStyle.DefaultHeight;
return CalcButtonScale / (bVertical ? InputPos[2] : InputPos[3]);
}
function PreDraw()
{
// Auto scale to match width to screen size.
if (bVertical)
XSize = GetWidth();
else YSize = GetWidth();
Super.PreDraw();
}
function DrawMenu()
{
if (!bHideScrollbar)
{
Owner.CurrentStyle.RenderScrollBar(Self);
}
}
function MouseClick(bool bRight)
{
if (bRight || bDisabled)
return;
bPressedDown = true;
PlayMenuSound(MN_ClickButton);
if (bVertical)
{
if (Owner.MousePosition.Y >= (CompPos[1]+ButtonOffset) && Owner.MousePosition.Y <= (CompPos[1]+ButtonOffset+SliderScale) ) // Grabbed scrollbar!
{
GrabbedOffset = Owner.MousePosition.Y - (CompPos[1]+ButtonOffset);
bGrabbedScroller = true;
GetInputFocus();
}
else if (Owner.MousePosition.Y < (CompPos[1]+ButtonOffset) ) // Page up.
AddValue(-PageStep);
else AddValue(PageStep);
}
else
{
if (Owner.MousePosition.X >= (CompPos[0]+ButtonOffset) && Owner.MousePosition.X <= (CompPos[0]+ButtonOffset+SliderScale) ) // Grabbed scrollbar!
{
GrabbedOffset = Owner.MousePosition.X - (CompPos[0]+ButtonOffset);
bGrabbedScroller = true;
GetInputFocus();
}
else if (Owner.MousePosition.X < (CompPos[0]+ButtonOffset) ) // Page left.
AddValue(-PageStep);
else AddValue(PageStep);
}
}
function MouseRelease(bool bRight)
{
if (!bRight)
DropInputFocus();
}
function LostInputFocus()
{
bGrabbedScroller = false;
bPressedDown = false;
}
function ScrollMouseWheel(bool bUp)
{
if (bDisabled)
return;
if (bUp)
AddValue(-ScrollStride);
else AddValue(ScrollStride);
}
function SetVisibility(bool Visible)
{
bHideScrollbar = Visible;
}
defaultproperties
{
MaxRange=100
ScrollStride=1
PageStep=10
ButtonScale=1
}

View File

@ -0,0 +1,9 @@
Class KFGUI_ScrollBarH extends KFGUI_ScrollBarBase;
`include(Build.uci)
`include(Logger.uci)
defaultproperties
{
bVertical=false
}

View File

@ -0,0 +1,9 @@
Class KFGUI_ScrollBarV extends KFGUI_ScrollBarBase;
`include(Build.uci)
`include(Logger.uci)
defaultproperties
{
bVertical=true
}

View File

@ -0,0 +1,55 @@
class KFGUI_Slider extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
var KFGUI_ScrollBarH ScrollBar;
var int MinValue, MaxValue;
var transient int CurrentValue;
delegate OnValueChanged(KFGUI_Slider Sender, int Value);
function InitMenu()
{
Super.InitMenu();
ScrollBar = KFGUI_ScrollBarH(FindComponentID('Scrollbar'));
ScrollBar.OnScrollChange = ValueChanged;
}
function int GetValue()
{
return CurrentValue;
}
function SetValue(int Value)
{
CurrentValue = Clamp(Value, MinValue, MaxValue);
OnValueChanged(self, CurrentValue);
}
function ValueChanged(KFGUI_ScrollBarBase Sender, int Value)
{
SetValue(Value);
}
function UpdateListVis()
{
ScrollBar.UpdateScrollSize(CurrentValue, MaxValue, 1,1, MinValue);
}
function ScrollMouseWheel(bool bUp)
{
if (!ScrollBar.bDisabled)
ScrollBar.ScrollMouseWheel(bUp);
}
defaultproperties
{
Begin Object Class=KFGUI_ScrollBarH Name=SliderScroll
XSize=1
YSize=0.5
ID="Scrollbar"
End Object
Components.Add(SliderScroll)
}

View File

@ -0,0 +1,168 @@
// Same as SwitchComponent, but with buttons.
Class KFGUI_SwitchMenuBar extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
var array<KFGUI_Base> SubPages;
var() byte ButtonPosition; // 0 = top, 1 = bottom, 2 = left, 3 = right
var() float BorderWidth, ButtonAxisSize; // Width for buttons.
var() float PagePadding; // Padding for pages
var int NumButtons, CurrentPageNum, PageComponentIndex;
var array<KFGUI_Button> PageButtons;
function ShowMenu()
{
GrabKeyFocus();
Super.ShowMenu();
}
function CloseMenu()
{
ReleaseKeyFocus();
Super.CloseMenu();
}
// Remember to call InitMenu() on the newly created page after.
final function KFGUI_Base AddPage(class<KFGUI_Base> PageClass, string Caption, string Hint, optional out KFGUI_Button Button)
{
local KFGUI_Base P;
local KFGUI_Button B;
// Add page.
P = new (Self) PageClass;
P.Owner = Owner;
P.ParentComponent = Self;
SubPages.AddItem(P);
// Add page switch button.
B = new (Self) class'KFGUI_Button';
B.ButtonText = Caption;
B.ToolTip = Hint;
B.OnClickLeft = PageSwitched;
B.OnClickRight = PageSwitched;
B.IDValue = NumButtons;
if (ButtonPosition < 2)
{
B.XPosition = NumButtons*ButtonAxisSize;
B.XSize = ButtonAxisSize*0.99;
if (ButtonPosition == 0)
B.YPosition = 0.f;
else B.YPosition = YSize-BorderWidth*0.99;
B.YSize = BorderWidth*0.99;
if (NumButtons > 0)
PageButtons[PageButtons.Length-1].ExtravDir = 1;
}
else
{
if (ButtonPosition == 2)
B.XPosition = 0.f;
else B.XPosition = XSize-BorderWidth*0.99;
B.XSize = BorderWidth*0.99;
B.YPosition = NumButtons*ButtonAxisSize;
B.YSize = ButtonAxisSize*0.99;
if (NumButtons > 0)
PageButtons[PageButtons.Length-1].ExtravDir = 2;
}
++NumButtons;
PageButtons.AddItem(B);
AddComponent(B);
Button = B;
return P;
}
function PageSwitched(KFGUI_Button Sender)
{
SelectPage(Sender.IDValue);
}
final function SelectPage(int Index)
{
PlayMenuSound(MN_LostFocus);
if (CurrentPageNum >= 0)
{
PageButtons[CurrentPageNum].bIsHighlighted = false;
SubPages[CurrentPageNum].CloseMenu();
Components.Remove(PageComponentIndex, 1);
PageComponentIndex = -1;
}
CurrentPageNum = (Index >= 0 && Index < SubPages.Length) ? Index : -1;
if (CurrentPageNum >= 0)
{
PageButtons[CurrentPageNum].bIsHighlighted = true;
SubPages[CurrentPageNum].ShowMenu();
PageComponentIndex = Components.Length;
Components.AddItem(SubPages[CurrentPageNum]);
}
}
function PreDraw()
{
local int i;
local byte j;
if (!bVisible)
return;
if (CurrentPageNum == -1 && NumButtons > 0)
SelectPage(0);
ComputeCoords();
Canvas.SetOrigin(CompPos[0], CompPos[1]);
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
DrawMenu();
for (i=0; i < Components.Length; ++i)
{
Components[i].Canvas = Canvas;
for (j=0; j < 4; ++j)
Components[i].InputPos[j] = CompPos[j];
if (i == PageComponentIndex)
{
switch(ButtonPosition)
{
case 0:
Components[i].InputPos[1] += (InputPos[3]*BorderWidth*PagePadding);
case 1:
Components[i].InputPos[3] -= (InputPos[3]*BorderWidth*PagePadding);
break;
case 2:
Components[i].InputPos[0] += (InputPos[2]*BorderWidth*PagePadding);
default:
Components[i].InputPos[2] -= (InputPos[2]*BorderWidth*PagePadding);
}
}
Components[i].PreDraw();
}
}
function bool ReceievedControllerInput(int ControllerId, name Key, EInputEvent Event)
{
switch(Key)
{
case 'XboxTypeS_LeftShoulder':
if (Event == IE_Pressed)
SelectPage(Clamp(CurrentPageNum - 1, 0, NumButtons));
return true;
case 'XboxTypeS_RightShoulder':
if (Event == IE_Pressed)
SelectPage(Clamp(CurrentPageNum + 1, 0, NumButtons));
return true;
}
return false;
}
defaultproperties
{
PagePadding=1.0
BorderWidth=0.05
ButtonAxisSize=0.08
CurrentPageNum=-1
PageComponentIndex=-1
}

View File

@ -0,0 +1,493 @@
Class KFGUI_TextField extends KFGUI_MultiComponent;
`include(Build.uci)
`include(Logger.uci)
enum ETextFieldStyles
{
TEXT_FIELD_NONE,
TEXT_FIELD_HSV,
TEXT_FIELD_SCAN,
TEXT_FIELD_FLASH
};
struct FTextPart
{
var string S;
var ETextFieldStyles TextType;
var Color C;
var float X;
structdefaultproperties
{
TextType=TEXT_FIELD_NONE
}
};
struct FTextLineInfo
{
var array<FTextPart> Text;
var float Y;
};
var KFGUI_ScrollBarV ScrollBar;
var() string LineSplitter;
var() protected string Text;
var() Color TextColor;
var() Canvas.FontRenderInfo TextFontInfo;
var() float FontScale, MessageDisplayTime, MessageFadeInTime, MessageFadeOutTime;
var() bool bNoReset, bFadeInOut, bUseOutlineText;
var() int MaxHistory, OutlineSize;
var protected transient array<FTextLineInfo> Lines, OrgLines;
var transient float MaxHeight, ScrollWidth, OldSize[2], InitFontScale, TextHeight, FadeStartTime;
var transient Font InitFont;
var transient bool bShowScrollbar, bTextParsed;
function SetText(string S)
{
if (Text == S)
return;
Text = S;
OldSize[0] = -1; // Force to refresh.
Lines.Length = 0;
OrgLines.Length = 0;
bTextParsed = false;
}
function AddText(string S, optional bool bIgnoreSpam)
{
Text $= S;
OldSize[0] = -1;
Lines.Length = 0;
OrgLines.Length = 0;
bTextParsed = false;
}
final function string GetText()
{
return Text;
}
final function ParseTextLines()
{
local array<string> SA;
local int i, j,z;
local string S;
local color C;
local ETextFieldStyles TextType;
ParseStringIntoArray(Text, SA, LineSplitter, false);
Lines.Length = SA.Length;
C.A = 0;
TextType = TEXT_FIELD_NONE;
for (i=0; i < SA.Length; ++i)
{
Lines[i].Text.Length = 0;
S = SA[i];
if (S == "")
continue;
z = 0;
while (true)
{
j = InStr(S, "#{");
if (j > 0)
{
Lines[i].Text.Length = z+1;
Lines[i].Text[z].S = Left(S, j);
Lines[i].Text[z].C = C;
Lines[i].Text[z].TextType = TextType;
++z;
}
else if (j == -1)
break;
S = Mid(S, j+2);
if (Left(S, 4) == "DEF}")
{
C.A = 0;
S = Mid(S, 4);
TextType = TEXT_FIELD_NONE;
}
else if (Left(S, 4) == "HSV}")
{
C.A = 0;
S = Mid(S, 4);
TextType = TEXT_FIELD_HSV;
}
else if (Left(S, 6) == "FLASH}")
{
C.A = 0;
S = Mid(S, 6);
TextType = TEXT_FIELD_FLASH;
}
else if (Left(S, 7) == "CFLASH=")
{
C.A = 0;
S = Mid(S, 7);
TextType = TEXT_FIELD_FLASH;
C.R = GrabHexValue(Mid(S, 0,2));
C.G = GrabHexValue(Mid(S, 2,2));
C.B = GrabHexValue(Mid(S, 4,2));
S = Mid(S, 7);
C.A = 255;
}
else
{
C.R = GrabHexValue(Mid(S, 0,2));
C.G = GrabHexValue(Mid(S, 2,2));
C.B = GrabHexValue(Mid(S, 4,2));
S = Mid(S, 7);
C.A = 255;
TextType = TEXT_FIELD_NONE;
}
}
Lines[i].Text.Length = z+1;
Lines[i].Text[z].S = S;
Lines[i].Text[z].C = C;
Lines[i].Text[z].TextType = TextType;
}
OrgLines = Lines; // Create a backup.
}
final function byte GrabHexValue(string S)
{
local byte n;
n = (HexToInt(Asc(Left(S, 1))) << 4) | HexToInt(Asc(Right(S, 1)));
S = Mid(S, 2);
return n;
}
final function byte HexToInt(byte n)
{
if (n >= 48 && n <= 57 ) // '0' - '9'
return n-48;
if (n >= 65 && n <= 70 ) // 'A' - 'F'
return n-55; // 'A' - 10
if (n >= 97 && n <= 102 ) // 'a' - 'f'
return n-87; // 'a' - 10
return 0;
}
function InitSize()
{
local byte i;
local float XS;
local int MaxScrollRange;
if (Canvas == None)
return;
OldSize[0] = CompPos[2];
OldSize[1] = CompPos[3];
if (!bTextParsed)
{
ParseTextLines();
bTextParsed = true;
}
else Lines = OrgLines;
InitFont = Owner.CurrentStyle.PickFont(InitFontScale);
InitFontScale *= FontScale;
// Compute Y-offsets of each line.
Canvas.Font = InitFont;
Canvas.TextSize("ABC", XS, TextHeight, InitFontScale, InitFontScale);
ParseLines(CompPos[2] / InitFontScale);
MaxHeight = (Lines.Length * TextHeight);
bShowScrollbar = (MaxHeight >= CompPos[3]);
bClickable = bShowScrollbar;
bCanFocus = bShowScrollbar;
if (bShowScrollbar)
{
if (ScrollBar == None)
{
ScrollBar = new(Self) class'KFGUI_ScrollBarV';
ScrollBar.SetPosition(0.9, 0.0, 0.1, 1.0);
ScrollBar.Owner = Owner;
ScrollBar.ParentComponent = Self;
ScrollBar.InitMenu();
ScrollBar.SetVisibility(bVisible);
}
// Compute scrollbar size and X-position.
for (i=0; i < 4; ++i)
ScrollBar.InputPos[i] = CompPos[i];
ScrollWidth = ScrollBar.GetWidth();
ScrollBar.XPosition = 1.f - ScrollWidth;
ScrollWidth *= CompPos[2];
ScrollBar.ComputeCoords();
// Recompute line sizes because we now have a scrollbar.
Lines = OrgLines;
ParseLines((CompPos[2]-ScrollWidth) / InitFontScale);
if (Components.Find(ScrollBar) == -1)
Components.AddItem(ScrollBar);
MaxHeight = (Lines.Length * TextHeight);
MaxScrollRange = Max(((MaxHeight-CompPos[3])/TextHeight), 1);
ScrollBar.UpdateScrollSize(bNoReset ? MaxScrollRange : 0, MaxScrollRange, 1,1);
}
else if (ScrollBar != None)
Components.RemoveItem(ScrollBar);
}
// Parse textlines to see if they're too long.
final function ParseLines(float ClipX)
{
local float X, XS, YS;
local int i, j,z, n;
for (i=0; i < Lines.Length; ++i)
{
Lines[i].Y = i*TextHeight;
X = 0.f;
for (j=0; j < Lines[i].Text.Length; ++j)
{
Lines[i].Text[j].X = (X*InitFontScale);
Canvas.TextSize(Lines[i].Text[j].S, XS, YS);
if ((X+XS) > ClipX)
{
z = FindSplitPoint(Lines[i].Text[j].S, X,ClipX);
// Add new line.
Lines.Insert(i+1, 1);
// Append the remaining lines there.
for (n=j; n < Lines[i].Text.Length; ++n)
Lines[i+1].Text.AddItem(Lines[i].Text[n]);
// Split the string at wrapping point.
Lines[i+1].Text[0].S = Mid(Lines[i].Text[j].S, z);
// Remove whitespaces in front of the string.
Lines[i+1].Text[0].S = StripWhiteSpaces(Lines[i+1].Text[0].S);
// If empty, clean it up.
if (Lines[i+1].Text[0].S == "")
Lines[i+1].Text.Remove(0, 1);
// End the current line at wrapping point.
Lines[i].Text[j].S = Left(Lines[i].Text[j].S, z);
Lines[i].Text.Length = j+1;
break;
}
X+=XS;
}
}
}
// Slow, find wrapped splitting point in text.
final function int FindSplitPoint(string S, float X, float ClipX)
{
local int i, l,PrevWord;
local float XL, YL;
local bool bWasWhite, bStartedZero;
bStartedZero = (X == 0.f);
Canvas.TextSize(Mid(S, 0,1), XL, YL);
X += XL;
i = 1;
l = Len(S);
PrevWord = 0;
bWasWhite = true;
while (i < l)
{
if (Mid(S, i,1) == " ")
{
if (!bWasWhite)
{
PrevWord = i;
bWasWhite = true;
}
}
else
{
bWasWhite = false;
}
Canvas.TextSize(Mid(S, i,1), XL, YL);
X+=XL;
if (X > ClipX ) // Split here if possible.
{
if (PrevWord == 0)
return (bStartedZero ? i : 0); // No wrap.
return PrevWord;
}
++i;
}
return l;
}
final function string StripWhiteSpaces(string S)
{
if (Left(S, 1) == " ")
S = Mid(S, 1);
return S;
}
function byte GetCursorStyle()
{
return `PEN_WHITE;
}
function DrawMenu()
{
local int i, j,Index;
local float Y;
if (Text == "" || !bVisible)
return;
// Need to figure out best fitting font.
if (OldSize[0] != CompPos[2] || OldSize[1] != CompPos[3])
InitSize();
if (MaxHistory != 0)
{
if (Lines.Length >= MaxHistory)
{
Index = InStr(Text, LineSplitter);
if (Index == INDEX_NONE)
Lines.Remove(0, 1);
else SetText(Mid(Text, Index+Len(LineSplitter)));
}
}
Canvas.Font = InitFont;
if (bShowScrollbar)
{
Canvas.SetClip(CompPos[0]+(CompPos[2]-ScrollWidth), CompPos[1]+CompPos[3]);
i = ScrollBar.GetValue();
}
else i = 0;
if (i < Lines.Length)
{
Y = Lines[i].Y;
for (i=i; i < Lines.Length; ++i)
{
if (Lines[i].Text.Length != 0)
{
if ((Lines[i].Y-Y+TextHeight) >= CompPos[3])
break;
for (j=0; j < Lines[i].Text.Length; ++j)
{
DrawTextField(Lines[i].Text[j].S, i, Lines[i].Text[j].X, Lines[i].Y-Y, Lines[i].Text[j].C, Lines[i].Text[j].TextType);
}
}
}
}
}
function DrawTextField(string S, int Index, float X, float Y, optional Color C, optional ETextFieldStyles TextStyle)
{
local float TempSize;
local int FadeAlpha;
local Color MainColor;
MainColor = C;
if (MainColor.A == 0)
MainColor = TextColor;
Canvas.DrawColor = GetColorFromStyle(MainColor, TextStyle);
if (bFadeInOut)
{
TempSize = `TimeSinceEx(GetPlayer(), FadeStartTime);
if (TempSize > MessageDisplayTime)
{
return;
}
if (TempSize < MessageFadeInTime)
{
FadeAlpha = int((TempSize / MessageFadeInTime) * 255.0);
}
else if (TempSize > MessageDisplayTime - MessageFadeOutTime)
{
FadeAlpha = int((1.0 - ((TempSize - (MessageDisplayTime - MessageFadeOutTime)) / MessageFadeOutTime)) * 255.0);
}
else
{
FadeAlpha = 255;
}
Canvas.DrawColor.A = FadeAlpha;
}
if (bUseOutlineText)
{
Owner.CurrentStyle.DrawTextShadow(S, X,Y, OutlineSize, InitFontScale);
}
else
{
Canvas.SetPos(X, Y);
Canvas.DrawText(S, ,InitFontScale, InitFontScale, TextFontInfo);
}
}
function Color GetColorFromStyle(Color MainColor, ETextFieldStyles TextStyle)
{
local float ColorHUE, Value;
local HSVColour HSV;
if (TextStyle == TEXT_FIELD_HSV)
{
ColorHUE = Abs(Sin(GetPlayer().WorldInfo.TimeSeconds * 0.9) * 335);
HSV.H = ColorHUE;
HSV.S = 1.f;
HSV.V = 1.f;
HSV.A = MainColor.A / 255;
return class'KFColorHelper'.static.LinearColorToColor(class'KFColorHelper'.static.HSVToRGB(HSV));
}
else if (TextStyle == TEXT_FIELD_FLASH)
{
Value = Abs(Sin(GetPlayer().WorldInfo.TimeSeconds * 0.9) * 1);
HSV = class'KFColorHelper'.static.RGBToHSV(ColorToLinearColor(MainColor));
HSV.V = Value;
return class'KFColorHelper'.static.LinearColorToColor(class'KFColorHelper'.static.HSVToRGB(HSV));
}
return MainColor;
}
function bool CaptureMouse()
{
return (bShowScrollbar ? Super.CaptureMouse() : false); // Nope.
}
function ScrollMouseWheel(bool bUp)
{
if (bShowScrollbar)
ScrollBar.ScrollMouseWheel(bUp);
}
function SetVisibility(bool Visible)
{
Super.SetVisibility(Visible);
if (ScrollBar != None)
{
ScrollBar.SetVisibility(Visible);
}
}
defaultproperties
{
bNoReset=false
LineSplitter="|"
FontScale=1
MaxHistory=0
OutlineSize=1
Text="TextField"
TextColor=(R=255, G=255, B=255, A=255)
TextFontInfo=(bClipText=true, bEnableShadow=true)
bCanFocus=false
bClickable=false
bUseOutlineText=false
}

View File

@ -0,0 +1,123 @@
Class KFGUI_TextLable extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var() protected string Text;
var() color TextColor;
var() Canvas.FontRenderInfo TextFontInfo;
var() byte AlignX, AlignY; // Alignment, 0=Left/Up, 1=Center, 2=Right/Down
var() float FontScale;
var() bool bUseOutline;
var() int OutlineSize;
var transient Font InitFont;
var transient float OldSize[2], InitOffset[2], InitFontScale;
function InitSize()
{
local float XL, YL, TS;
OldSize[0] = CompPos[2];
OldSize[1] = CompPos[3];
TS = Owner.CurrentStyle.GetFontScaler();
TS *= FontScale;
while (true)
{
Canvas.Font = Owner.CurrentStyle.MainFont;
if (TextFontInfo.bClipText)
Canvas.TextSize(Text, XL, YL, TS, TS);
else
{
Canvas.SetPos(0, 0);
if (TS == 1)
Canvas.StrLen(Text, XL, YL);
else
{
Canvas.SetClip(CompPos[2]/TS, CompPos[3]); // Hacky, since StrLen has no TextSize support.
Canvas.StrLen(Text, XL, YL);
XL*=TS;
YL*=TS;
}
}
if ((XL < (CompPos[2]*0.99) && YL < (CompPos[3]*0.99)))
break;
TS -= 0.001;
}
Canvas.SetClip(CompPos[0]+CompPos[2], CompPos[1]+CompPos[3]);
InitFont = Canvas.Font;
InitFontScale = TS;
switch (AlignX)
{
case 0:
InitOffset[0] = 0;
break;
case 1:
InitOffset[0] = FMax((CompPos[2]-XL)*0.5, 0.f);
break;
default:
InitOffset[0] = CompPos[2]-(XL+1);
}
switch (AlignY)
{
case 0:
InitOffset[1] = 0;
break;
case 1:
InitOffset[1] = FMax((CompPos[3]-YL)*0.5, 0.f);
break;
default:
InitOffset[1] = CompPos[3]-YL;
}
}
function SetText(string S)
{
if (Text == S)
return;
Text = S;
OldSize[0] = -1; // Force to refresh.
}
final function string GetText()
{
return Text;
}
function DrawMenu()
{
if (Text == "")
return;
// Need to figure out best fitting font.
if (OldSize[0] != CompPos[2] || OldSize[1] != CompPos[3])
InitSize();
Canvas.Font = InitFont;
Canvas.DrawColor = TextColor;
if (bUseOutline)
{
Owner.CurrentStyle.DrawTextShadow(Text, InitOffset[0], InitOffset[1], OutlineSize, InitFontScale);
}
else
{
Canvas.SetPos(InitOffset[0], InitOffset[1]);
Canvas.DrawText(Text, ,InitFontScale, InitFontScale, TextFontInfo);
}
}
function bool CaptureMouse()
{
return false;
}
defaultproperties
{
Text="Label"
TextColor=(R=255, G=255, B=255, A=255)
TextFontInfo=(bClipText=false, bEnableShadow=true)
FontScale=1.f
OutlineSize=1
bCanFocus=false
}

View File

@ -0,0 +1,188 @@
Class KFGUI_TextScroll extends KFGUI_TextField;
`include(Build.uci)
`include(Logger.uci)
var float ScrollSpeed;
var transient float CharStartTime;
var transient bool bScrollCompleted, bTextDirty;
var transient array<bool> RowsCompleted;
var transient int MaxIndex, RowsDropped;
function SetText(string S)
{
Super.SetText(S);
MaxIndex = 0;
RowsCompleted.Length = 0;
RowsDropped = 0;
bScrollCompleted = false;
bTextDirty = true;
CharStartTime = GetPlayer().WorldInfo.TimeSeconds;
}
function DrawMenu()
{
local int i, j,k, SLen, CurrentIndex;
local float Y, DTime, XL, YL, MainY, MainX, CharTime;
local string MainString;
local Color MainTextColor;
local Texture CurrentCursor;
local ETextFieldStyles TextStyle;
if (bScrollCompleted)
{
Super.DrawMenu();
return;
}
if (Text == "")
return;
// Need to figure out best fitting font.
if (OldSize[0] != CompPos[2] || OldSize[1] != CompPos[3])
InitSize();
Canvas.Font = InitFont;
if (bShowScrollbar)
{
Canvas.SetClip(CompPos[0]+(CompPos[2]-ScrollWidth), CompPos[1]+CompPos[3]);
i = ScrollBar.GetValue();
}
else i = 0;
if (ScrollBar != None)
{
if (bTextDirty)
{
ScrollBar.bDisabled = true;
RowsCompleted.Length = Lines.Length;
bTextDirty = false;
}
if (RowsCompleted[Lines.Length-1])
{
ScrollBar.AddValue(1);
ScrollBar.bDisabled = false;
bScrollCompleted = true;
//Temp fix! The last line in the string seems to be skipped
AddText(LineSplitter);
return;
}
else if (MaxIndex != 0 && RowsCompleted[MaxIndex])
{
MaxIndex = 0;
ScrollBar.AddValue(1);
RowsDropped++;
i = ScrollBar.GetValue();
}
}
if (RowsDropped > 0)
{
for (i=0; i <= RowsDropped; ++i)
{
for (j=0; j < Lines[i].Text.Length; ++j)
{
for (k=0; k <= Len(Lines[i].Text[j].S); ++k)
{
CharTime += ScrollSpeed;
}
}
}
}
DTime = `TimeSinceEx(GetPlayer(), CharStartTime);
if (i < Lines.Length)
{
CurrentCursor = Owner.DefaultPens[GetCursorStyle()];
Y = Lines[i].Y;
for (i=i; i < Lines.Length; ++i)
{
if ((Lines[i].Y-Y+TextHeight) >= CompPos[3])
{
MaxIndex = i-1;
break;
}
if (Lines[i].Text.Length != 0)
{
for (j=0; j < Lines[i].Text.Length; ++j)
{
MainTextColor = Lines[i].Text[j].C;
if (MainTextColor.A == 0)
MainTextColor = TextColor;
TextStyle = Lines[i].Text[j].TextType;
MainX = Lines[i].Text[j].X;
MainY = Lines[i].Y-Y;
MainString = Lines[i].Text[j].S;
SLen = Len(MainString);
CurrentIndex = 0;
for (k=0; k <= SLen; ++k)
{
CharTime += ScrollSpeed;
Canvas.TextSize(Mid(MainString, 0, k), XL, YL, InitFontScale, InitFontScale);
if (CharTime > DTime)
{
if (CurrentIndex == k)
{
Canvas.SetDrawColor(255, 255, 255, 255);
Canvas.SetPos(MainX+XL, MainY);
Canvas.DrawTile(CurrentCursor, YL/2, YL, 0, 0, CurrentCursor.GetSurfaceWidth(), CurrentCursor.GetSurfaceHeight());
}
continue;
}
Canvas.DrawColor = GetColorFromStyle(MainTextColor, TextStyle);
Canvas.SetPos(MainX+XL, MainY);
Canvas.DrawText(Mid(MainString, k, 1), ,InitFontScale, InitFontScale, TextFontInfo);
CurrentIndex = k+1;
if (k >= SLen)
{
RowsCompleted[i] = true;
}
}
}
}
}
}
}
function bool CaptureMouse()
{
return (!bScrollCompleted && Super(KFGUI_MultiComponent).CaptureMouse()) || Super.CaptureMouse();
}
function MouseClick(bool bRight)
{
if (bScrollCompleted)
return;
if (ScrollBar != None)
ScrollBar.bDisabled = false;
bScrollCompleted = true;
//Temp fix! The last line in the string seems to be skipped
AddText(LineSplitter);
}
defaultproperties
{
ScrollSpeed=0.01
}

View File

@ -0,0 +1,45 @@
Class KFGUI_Tooltip extends KFGUI_Base;
`include(Build.uci)
`include(Logger.uci)
var() array<string> Lines;
var() Canvas.FontRenderInfo TextFontInfo;
var byte CurrentAlpha;
function InputMouseMoved()
{
DropInputFocus();
}
function MouseClick(bool bRight)
{
DropInputFocus();
}
function MouseRelease(bool bRight)
{
DropInputFocus();
}
function ShowMenu()
{
CurrentAlpha = 1;
}
final function SetText(string S)
{
ParseStringIntoArray(S, Lines, "<SEPERATOR>", false);
}
function PreDraw()
{
if (!bVisible)
return;
Owner.CurrentStyle.RenderToolTip(Self);
}
defaultproperties
{
TextFontInfo=(bClipText=true, bEnableShadow=true)
bCanFocus=false
bFocusedPostDrawItem=true
}

819
YAS/Classes/KFScoreBoard.uc Normal file
View File

@ -0,0 +1,819 @@
class KFScoreBoard extends KFGUI_Page
dependson(Types);
`include(Build.uci)
`include(Logger.uci)
var transient float RankXPos, LevelXPos, PerkXPos, PlayerXPos, HealthXPos, TimeXPos, KillsXPos, AssistXPos, CashXPos, DeathXPos, PingXPos;
var transient float StatusWBox, PlayerWBox, LevelWBox, PerkWBox, CashWBox, KillsWBox, AssistWBox, HealthWBox, PingWBox;
var transient float NextScoreboardRefresh;
var int PlayerIndex;
var KFGUI_List PlayersList;
var Texture2D DefaultAvatar;
var KFGameReplicationInfo KFGRI;
var array<KFPlayerReplicationInfo> KFPRIArray;
var KFPlayerController OwnerPC;
var Color PingColor;
var float PingBars;
// Cache
var array<String> PerkNames;
// Ranks
var array<RankInfo> CustomRanks;
var array<UIDRankRelation> RankRelations;
var SCESettings Settings;
// Localization
var localized string Players;
var localized string Spectators;
var localized string Rank;
var localized string State;
var localized string NoPerk;
var localized string Ready;
var localized string NotReady;
var localized string Unknown;
var localized string Dead;
function InitMenu()
{
`callstack();
Super.InitMenu();
PlayersList = KFGUI_List(FindComponentID('PlayerList'));
OwnerPC = KFPlayerController(GetPlayer());
if (PerkNames.Length == 0)
{
PerkNames.AddItem(class'KFGFxMenu_Inventory'.default.PerkFilterString);
PerkNames.AddItem(class'KFPerk_Berserker'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Commando'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Support'.default.PerkName);
PerkNames.AddItem(class'KFPerk_FieldMedic'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Demolitionist'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Firebug'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Gunslinger'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Sharpshooter'.default.PerkName);
PerkNames.AddItem(class'KFPerk_SWAT'.default.PerkName);
PerkNames.AddItem(class'KFPerk_Survivalist'.default.PerkName);
}
}
static function CheckAvatar(KFPlayerReplicationInfo KFPRI, KFPlayerController PC)
{
local Texture2D Avatar;
if (KFPRI.Avatar == None || KFPRI.Avatar == default.DefaultAvatar)
{
Avatar = FindAvatar(PC, KFPRI.UniqueId);
if (Avatar == None)
Avatar = default.DefaultAvatar;
KFPRI.Avatar = Avatar;
}
}
delegate bool InOrder(KFPlayerReplicationInfo P1, KFPlayerReplicationInfo P2)
{
if (P1 == None || P2 == None)
return true;
if (P1.GetTeamNum() < P2.GetTeamNum())
return false;
if (P1.Kills == P2.Kills)
{
if (P1.Assists == P2.Assists)
return true;
return P1.Assists < P2.Assists;
}
return P1.Kills < P2.Kills;
}
function string WaveText()
{
local int CurrentWaveNum;
CurrentWaveNum = KFGRI.WaveNum;
if (KFGRI.IsBossWave())
{
return class'KFGFxHUD_WaveInfo'.default.BossWaveString;
}
else if (KFGRI.IsFinalWave())
{
return class'KFGFxHUD_ScoreboardMapInfoContainer'.default.FinalString;
}
else
{
if (KFGRI.default.bEndlessMode)
{
return "" $ CurrentWaveNum;
}
else
{
return CurrentWaveNum $ " / " $ KFGRI.GetFinalWaveNum();
}
}
}
function DrawMenu()
{
local string S;
local PlayerController PC;
local KFPlayerReplicationInfo KFPRI;
local PlayerReplicationInfo PRI;
local float XPos, YPos, YL, XL, FontScalar, XPosCenter, BoxW, BoxX, BoxH, MinBoxW, DoshSize;
local int i, j, NumSpec, NumPlayer, NumAlivePlayer, Width;
local float BorderSize;
PC = GetPlayer();
if (KFGRI == None)
{
KFGRI = KFGameReplicationInfo(PC.WorldInfo.GRI);
if (KFGRI == None)
return;
}
// Sort player list.
if (NextScoreboardRefresh < PC.WorldInfo.TimeSeconds)
{
NextScoreboardRefresh = PC.WorldInfo.TimeSeconds + 0.1;
for (i=(KFGRI.PRIArray.Length-1); i > 0; --i)
{
for (j=i-1; j >= 0; --j)
{
if (!InOrder(KFPlayerReplicationInfo(KFGRI.PRIArray[i]), KFPlayerReplicationInfo(KFGRI.PRIArray[j])))
{
PRI = KFGRI.PRIArray[i];
KFGRI.PRIArray[i] = KFGRI.PRIArray[j];
KFGRI.PRIArray[j] = PRI;
}
}
}
}
// Check players.
PlayerIndex = -1;
NumPlayer = 0;
for (i=(KFGRI.PRIArray.Length-1); i >= 0; --i)
{
KFPRI = KFPlayerReplicationInfo(KFGRI.PRIArray[i]);
if (KFPRI == None)
continue;
if (KFPRI.bOnlySpectator)
{
++NumSpec;
continue;
}
if (KFPRI.PlayerHealth > 0 && KFPRI.PlayerHealthPercent > 0 && KFPRI.GetTeamNum() == 0)
++NumAlivePlayer;
++NumPlayer;
}
KFPRIArray.Length = NumPlayer;
j = KFPRIArray.Length;
for (i=(KFGRI.PRIArray.Length-1); i >= 0; --i)
{
KFPRI = KFPlayerReplicationInfo(KFGRI.PRIArray[i]);
if (KFPRI != None && !KFPRI.bOnlySpectator)
{
KFPRIArray[--j] = KFPRI;
if (KFPRI == PC.PlayerReplicationInfo)
PlayerIndex = j;
}
}
Canvas.Font = Owner.CurrentStyle.PickFont(FontScalar);
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
BorderSize = Owner.HUDOwner.ScaledBorderSize;
// Server Info
XPosCenter = Canvas.ClipX * 0.5;
Width = Canvas.ClipX * 0.4; // Full Box Width
XPos = XPosCenter - Width * 0.5;
YPos = YL;
BoxW = Width;
BoxX = XPos;
BoxH = YL + BorderSize;
// Top Rect (Server name)
SetDrawColor(Canvas, Settings.Style.ServerNameBoxColor);
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeServerNameBox);
SetDrawColor(Canvas, Settings.Style.ServerNameTextColor);
S = KFGRI.ServerName;
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar);
YPos += BoxH;
// Mid Left Rect (Info)
BoxW = Width * 0.7;
BoxH = YL * 2 + BorderSize * 2;
SetDrawColor(Canvas, Settings.Style.GameInfoBoxColor);
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeGameInfoBox);
SetDrawColor(Canvas, Settings.Style.GameInfoTextColor);
S = class'KFCommon_LocalizedStrings'.static.GetFriendlyMapName(PC.WorldInfo.GetMapName(true));
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar);
S = KFGRI.GameClass.default.GameName $ " - " $ class'KFCommon_LocalizedStrings'.Static.GetDifficultyString(KFGRI.GameDifficulty);
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos + YL, FontScalar);
// Mid Right Rect (Wave)
BoxX = BoxX + BoxW;
BoxW = Width - BoxW;
SetDrawColor(Canvas, Settings.Style.WaveBoxColor);
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapeWaveInfoBox);
SetDrawColor(Canvas, Settings.Style.WaveTextColor);
S = class'KFGFxHUD_ScoreboardMapInfoContainer'.default.WaveString;
DrawTextShadowHVCenter(S, BoxX, YPos, BoxW, FontScalar);
DrawTextShadowHVCenter(WaveText(), BoxX, YPos + YL, BoxW, FontScalar);
YPos += BoxH;
// Bottom Rect (Players count)
BoxX = XPos;
BoxW = Width;
BoxH = YL + BorderSize;
SetDrawColor(Canvas, Settings.Style.PlayerCountBoxColor);
Owner.CurrentStyle.DrawRectBox(BoxX, YPos, BoxW, BoxH, Settings.Style.EdgeSize, Settings.Style.ShapePlayersCountBox);
SetDrawColor(Canvas, Settings.Style.PlayerCountTextColor);
S = Players$": " $ NumPlayer $ " / " $ KFGRI.MaxHumanCount $ " " $ Spectators $ ": " $ NumSpec;
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
DrawTextShadowHLeftVCenter(S, BoxX + Settings.Style.EdgeSize, YPos, FontScalar);
S = Owner.CurrentStyle.GetTimeString(KFGRI.ElapsedTime);
DrawTextShadowHVCenter(S, XPos + Width * 0.7, YPos, Width * 0.3, FontScalar);
// TODO: ranked / unranked
//if (KFGameInfo(PC.WorldInfo.Game).IsUnrankedGame())
// S = class'KFGFxMenu_ServerBrowser'.default.UnrankedString;
//else
// S = class'KFGFxMenu_ServerBrowser'.default.RankedString;
//DrawTextShadowHVCenter(S, XPos + XL, YPos, Width * 0.7 + XL, FontScalar);
YPos += BoxH;
// Header
Width = Canvas.ClipX * 0.7;
XPos = (Canvas.ClipX - Width) * 0.5;
YPos += YL;
BoxH = YL + BorderSize;
SetDrawColor(Canvas, Settings.Style.ListHeaderBoxColor);
Owner.CurrentStyle.DrawRectBox( XPos - BorderSize * 2,
YPos,
Width + BorderSize * 4,
BoxH,
Settings.Style.EdgeSize,
Settings.Style.ShapeHeaderBox);
// Calc X offsets
MinBoxW = Width * 0.07; // minimum width for column
RankXPos = Owner.HUDOwner.ScaledBorderSize * 8 + Settings.Style.EdgeSize;
PlayerXPos = Width * 0.20;
Canvas.TextSize(class'KFGFxHUD_ScoreboardWidget'.default.PingString$" ", XL, YL, FontScalar, FontScalar);
PingXPos = Width - (XL < MinBoxW ? MinBoxW : XL);
Canvas.TextSize(State$" ", XL, YL, FontScalar, FontScalar);
HealthXPos = PingXPos - (XL < MinBoxW ? MinBoxW : XL);
Canvas.TextSize(class'KFGFxHUD_ScoreboardWidget'.default.AssistsString$" ", XL, YL, FontScalar, FontScalar);
AssistXPos = HealthXPos - (XL < MinBoxW ? MinBoxW : XL);
Canvas.TextSize(class'KFGFxHUD_ScoreboardWidget'.default.KillsString$" ", XL, YL, FontScalar, FontScalar);
KillsXPos = AssistXPos - (XL < MinBoxW ? MinBoxW : XL);
Canvas.TextSize(class'KFGFxHUD_ScoreboardWidget'.default.DoshString$" ", XL, YL, FontScalar, FontScalar);
Canvas.TextSize("999999", DoshSize, YL, FontScalar, FontScalar);
CashXPos = KillsXPos - (XL < DoshSize ? DoshSize : XL);
BoxW = 0;
foreach PerkNames(S)
{
Canvas.TextSize(S$"A", XL, YL, FontScalar, FontScalar);
if (XL > BoxW) BoxW = XL;
}
PerkXPos = CashXPos - (BoxW < MinBoxW ? MinBoxW : BoxW);
Canvas.TextSize("000", XL, YL, FontScalar, FontScalar);
LevelXPos = PerkXPos - XL;
StatusWBox = PlayerXPos - RankXPos;
PlayerWBox = LevelXPos - PlayerXPos;
LevelWBox = PerkXPos - LevelXPos;
PerkWBox = CashXPos - PerkXPos;
CashWBox = KillsXPos - CashXPos;
KillsWBox = AssistXPos - KillsXPos;
AssistWBox = HealthXPos - AssistXPos;
HealthWBox = PingXPos - HealthXPos;
PingWBox = Width - PingXPos;
// Header texts
SetDrawColor(Canvas, Settings.Style.ListHeaderTextColor);
DrawTextShadowHLeftVCenter(Rank, XPos + RankXPos, YPos, FontScalar);
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 + CashXPos, YPos, CashWBox, FontScalar);
DrawTextShadowHVCenter(State, XPos + HealthXPos, YPos, HealthWBox, FontScalar);
DrawTextShadowHVCenter(class'KFGFxHUD_ScoreboardWidget'.default.PingString, XPos + PingXPos, YPos, PingWBox, FontScalar);
PlayersList.XPosition = ((Canvas.ClipX - Width) * 0.5) / InputPos[2];
PlayersList.YPosition = (YPos + YL + BorderSize * 4) / InputPos[3];
PlayersList.YSize = (1.f - PlayersList.YPosition) - 0.15;
PlayersList.ChangeListSize(KFPRIArray.Length);
}
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 SetDrawColor(Canvas C, ColorRGBA RGBA)
{
C.SetDrawColor(RGBA.R, RGBA.G, RGBA.B, RGBA.A);
}
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 XPos, BoxWidth, RealPlayerWBox;
local KFPlayerReplicationInfo KFPRI;
local byte Level, PrestigeLevel;
local bool bIsZED;
local int Ping;
local RankInfo CurrentRank;
local bool HasRank;
local int PlayerInfoIndex, PlayerRankIndex;
local int Shape;
YOffset *= 1.05;
KFPRI = KFPRIArray[Index];
HasRank = false;
PlayerInfoIndex = RankRelations.Find('UID', KFPRI.UniqueId);
if (PlayerInfoIndex != INDEX_NONE && RankRelations[PlayerInfoIndex].RankID != INDEX_NONE)
{
PlayerRankIndex = CustomRanks.Find('ID', RankRelations[PlayerInfoIndex].RankID);
if (PlayerRankIndex != INDEX_NONE)
{
HasRank = true;
CurrentRank = CustomRanks[PlayerRankIndex];
}
}
if (KFPRI.bAdmin)
{
if (!HasRank || (HasRank && !CurrentRank.OverrideAdminRank))
{
CurrentRank.Rank = Settings.Admin.Rank;
CurrentRank.TextColor = Settings.Admin.TextColor;
CurrentRank.ApplyColorToFields = Settings.Admin.ApplyColorToFields;
HasRank = true;
}
}
else // Player
{
if (!HasRank)
{
CurrentRank.Rank = Settings.Player.Rank;
CurrentRank.TextColor = Settings.Player.TextColor;
CurrentRank.ApplyColorToFields = Settings.Player.ApplyColorToFields;
HasRank = true;
}
}
// Now all players belongs to 'Rank'
if (KFGRI.bVersusGame)
bIsZED = KFTeamInfo_Zeds(KFPRI.Team) != None;
XPos = 0.f;
C.Font = Owner.CurrentStyle.PickFont(FontScalar);
Canvas.TextSize("ABC", XL, YL, FontScalar, FontScalar);
// change rect color by HP
if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun)
{
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
}
else if (!KFGRI.bMatchHasBegun)
{
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
}
else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None)
{
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
}
else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0)
{
SetDrawColor(C, Settings.Style.LeftStateBoxColorDead);
}
else
{
if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.High) / 100.0)
SetDrawColor(C, Settings.Style.LeftStateBoxColorHigh);
else if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.Low) / 100.0)
SetDrawColor(C, Settings.Style.LeftStateBoxColorMid);
else
SetDrawColor(C, Settings.Style.LeftStateBoxColorLow);
}
if (!Settings.State.Dynamic)
SetDrawColor(C, Settings.Style.LeftStateBoxColor);
if (KFPRIArray.Length > 1 && Index == 0)
Shape = Settings.Style.ShapeLeftStateBoxTopPlayer;
else if (KFPRIArray.Length > 1 && Index == KFPRIArray.Length - 1)
Shape = Settings.Style.ShapeLeftStateBoxBottomPlayer;
else
Shape = Settings.Style.ShapeLeftStateBoxMidPlayer;
BoxWidth = Owner.HUDOwner.ScaledBorderSize * 8;
Owner.CurrentStyle.DrawRectBox( XPos,
YOffset,
BoxWidth,
Height,
Settings.Style.EdgeSize,
Shape);
XPos += BoxWidth;
TextYOffset = YOffset + (Height * 0.5f) - (YL * 0.5f);
if (PlayerIndex == Index)
SetDrawColor(C, Settings.Style.PlayerOwnerBoxColor);
else
SetDrawColor(C, Settings.Style.PlayerBoxColor);
if (KFPRIArray.Length > 1 && Index == 0)
Shape = Settings.Style.ShapePlayerBoxTopPlayer;
else if (KFPRIArray.Length > 1 && Index == KFPRIArray.Length - 1)
Shape = Settings.Style.ShapePlayerBoxBottomPlayer;
else
Shape = Settings.Style.ShapePlayerBoxMidPlayer;
BoxWidth = CashXPos - BoxWidth - Owner.HUDOwner.ScaledBorderSize * 2;
Owner.CurrentStyle.DrawRectBox(XPos, YOffset, BoxWidth, Height, Settings.Style.EdgeSize, Shape);
XPos += BoxWidth;
// Right stats box
if (KFPRIArray.Length > 1 && Index == 0)
Shape = Settings.Style.ShapeStatsBoxTopPlayer;
else if (KFPRIArray.Length > 1 && Index == KFPRIArray.Length - 1)
Shape = Settings.Style.ShapeStatsBoxBottomPlayer;
else
Shape = Settings.Style.ShapeStatsBoxMidPlayer;
BoxWidth = Width - XPos;
SetDrawColor(C, Settings.Style.StatsBoxColor);
Owner.CurrentStyle.DrawRectBox( XPos,
YOffset,
BoxWidth,
Height,
Settings.Style.EdgeSize,
Shape);
// Rank
if (CurrentRank.ApplyColorToFields.Rank)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.RankTextColor);
S = CurrentRank.Rank;
DrawTextShadowHLeftVCenter(S, RankXPos, TextYOffset, FontScalar);
// Perk
RealPlayerWBox = PlayerWBox;
if (bIsZED)
{
if (CurrentRank.ApplyColorToFields.Perk)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.ZedTextColor);
C.SetPos (PerkXPos, YOffset - ((Height-5) * 0.5f));
C.DrawRect (Height-5, Height-5, Texture2D'UI_Widgets.MenuBarWidget_SWF_IF');
S = class'KFCommon_LocalizedStrings'.default.ZedString;
DrawTextShadowHLeftVCenter(S, PerkXPos + Height, TextYOffset, FontScalar);
RealPlayerWBox = PerkXPos + Height - PlayerXPos;
}
else
{
if (KFPRI.CurrentPerkClass != None)
{
PrestigeLevel = KFPRI.GetActivePerkPrestigeLevel();
Level = KFPRI.GetActivePerkLevel();
PerkIconPosY = YOffset + (Owner.HUDOwner.ScaledBorderSize * 2);
PerkIconSize = Height-(Owner.HUDOwner.ScaledBorderSize * 4);
PerkIconPosX = LevelXPos - PerkIconSize - (Owner.HUDOwner.ScaledBorderSize*2);
PrestigeIconScale = 0.6625f;
RealPlayerWBox = PerkIconPosX - PlayerXPos;
C.DrawColor = HUDOwner.WhiteColor;
if (PrestigeLevel > 0)
{
C.SetPos(PerkIconPosX, PerkIconPosY);
C.DrawTile(KFPRI.CurrentPerkClass.default.PrestigeIcons[PrestigeLevel - 1], PerkIconSize, PerkIconSize, 0, 0, 256, 256);
C.SetPos(PerkIconPosX + ((PerkIconSize/2) - ((PerkIconSize*PrestigeIconScale)/2)), PerkIconPosY + ((PerkIconSize/2) - ((PerkIconSize*PrestigeIconScale)/1.75)));
C.DrawTile(KFPRI.CurrentPerkClass.default.PerkIcon, PerkIconSize * PrestigeIconScale, PerkIconSize * PrestigeIconScale, 0, 0, 256, 256);
}
else
{
C.SetPos(PerkIconPosX, PerkIconPosY);
C.DrawTile(KFPRI.CurrentPerkClass.default.PerkIcon, PerkIconSize, PerkIconSize, 0, 0, 256, 256);
}
if (CurrentRank.ApplyColorToFields.Level)
SetDrawColor(C, CurrentRank.TextColor);
else if (!Settings.Level.Dynamic)
SetDrawColor(C, Settings.Style.LevelTextColor);
else
{
if (Level < Settings.Level.Low[KFGRI.GameDifficulty])
SetDrawColor(C, Settings.Style.LevelTextColorLow);
else if (Level < Settings.Level.High[KFGRI.GameDifficulty])
SetDrawColor(C, Settings.Style.LevelTextColorMid);
else
SetDrawColor(C, Settings.Style.LevelTextColorHigh);
}
S = String(Level);
DrawTextShadowHLeftVCenter(S, LevelXPos, TextYOffset, FontScalar);
if (CurrentRank.ApplyColorToFields.Level)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.LevelTextColor);
S = KFPRI.CurrentPerkClass.default.PerkName;
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar);
}
else
{
if (CurrentRank.ApplyColorToFields.Perk)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.PerkTextColor);
S = NoPerk;
DrawTextShadowHLeftVCenter(S, PerkXPos, TextYOffset, FontScalar);
RealPlayerWBox = PerkXPos - PlayerXPos;
}
}
// Avatar
if (KFPRI.Avatar != None)
{
if (KFPRI.Avatar == default.DefaultAvatar)
CheckAvatar(KFPRI, OwnerPC);
C.SetDrawColor(255, 255, 255, 255);
C.SetPos(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f));
C.DrawTile(KFPRI.Avatar, Height - 6, Height - 6, 0,0, KFPRI.Avatar.SizeX, KFPRI.Avatar.SizeY);
Owner.CurrentStyle.DrawBoxHollow(PlayerXPos - (Height * 1.075), YOffset + (Height * 0.5f) - ((Height - 6) * 0.5f), Height - 6, Height - 6, 1);
}
else if (!KFPRI.bBot)
CheckAvatar(KFPRI, OwnerPC);
// Player
if (CurrentRank.ApplyColorToFields.Player)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.PlayerNameTextColor);
S = KFPRI.PlayerName;
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
while (XL > RealPlayerWBox)
{
S = Left(S, Len(S)-1);
Canvas.TextSize(S, XL, YL, FontScalar, FontScalar);
}
DrawTextShadowHLeftVCenter(S, PlayerXPos, TextYOffset, FontScalar);
// Kill
if (CurrentRank.ApplyColorToFields.Kills)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.KillsTextColor);
DrawTextShadowHVCenter(string (KFPRI.Kills), KillsXPos, TextYOffset, KillsWBox, FontScalar);
// Assist
if (CurrentRank.ApplyColorToFields.Assists)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.AssistsTextColor);
DrawTextShadowHVCenter(string (KFPRI.Assists), AssistXPos, TextYOffset, AssistWBox, FontScalar);
// Cash
if (bIsZED)
{
SetDrawColor(C, Settings.Style.ZedTextColor);
StrValue = "-";
}
else
{
if (CurrentRank.ApplyColorToFields.Dosh)
SetDrawColor(C, CurrentRank.TextColor);
else
SetDrawColor(C, Settings.Style.DoshTextColor);
StrValue = String(int(KFPRI.Score)); //StrValue = GetNiceSize(int(KFPRI.Score));
}
DrawTextShadowHVCenter(StrValue, CashXPos, TextYOffset, CashWBox, FontScalar);
// State
if (!KFPRI.bReadyToPlay && KFGRI.bMatchHasBegun)
{
SetDrawColor(C, Settings.Style.StateTextColorLobby);
S = class'KFGFxMenu_ServerBrowser'.default.InLobbyString;;
}
else if (!KFGRI.bMatchHasBegun)
{
if (KFPRI.bReadyToPlay)
{
SetDrawColor(C, Settings.Style.StateTextColorReady);
S = Ready;
}
else
{
SetDrawColor(C, Settings.Style.StateTextColorNotReady);
S = NotReady;
}
}
else if (bIsZED && KFTeamInfo_Zeds(GetPlayer().PlayerReplicationInfo.Team) == None)
{
SetDrawColor(C, Settings.Style.StateTextColor);
S = Unknown;
}
else if (KFPRI.PlayerHealth <= 0 || KFPRI.PlayerHealthPercent <= 0)
{
if (KFPRI.bOnlySpectator)
{
SetDrawColor(C, Settings.Style.StateTextColorSpectator);
S = class'KFCommon_LocalizedStrings'.default.SpectatorString;
}
else
{
SetDrawColor(C, Settings.Style.StateTextColorDead);
S = Dead;
}
}
else
{
if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.High) / 100.0)
SetDrawColor(C, Settings.Style.StateTextColorHighHP);
else if (ByteToFloat(KFPRI.PlayerHealthPercent) >= float(Settings.State.Low) / 100.0)
SetDrawColor(C, Settings.Style.StateTextColorMidHP);
else
SetDrawColor(C, Settings.Style.StateTextColorLowHP);
S = string(KFPRI.PlayerHealth)@"HP";
}
if (CurrentRank.ApplyColorToFields.Health)
SetDrawColor(C, CurrentRank.TextColor);
else if (!Settings.State.Dynamic)
SetDrawColor(C, Settings.Style.StateTextColor);
DrawTextShadowHVCenter(S, HealthXPos, TextYOffset, HealthWBox, FontScalar);
// Ping
if (KFPRI.bBot)
{
SetDrawColor(C, Settings.Style.PingTextColor);
S = "-";
}
else
{
Ping = int(KFPRI.Ping * `PING_SCALE);
if (CurrentRank.ApplyColorToFields.Ping)
SetDrawColor(C, CurrentRank.TextColor);
else if (Ping <= Settings.Ping.Low)
SetDrawColor(C, Settings.Style.PingTextColorLow);
else if (Ping <= Settings.Ping.High)
SetDrawColor(C, Settings.Style.PingTextColorMid);
else
SetDrawColor(C, Settings.Style.PingTextColorHigh);
S = string(Ping);
}
C.TextSize(S, XL, YL, FontScalar, FontScalar);
DrawTextShadowHVCenter(S, PingXPos, TextYOffset, Settings.Ping.ShowPingBars ? PingWBox/2 : PingWBox, FontScalar);
C.SetDrawColor(250, 250, 250, 255);
if (Settings.Ping.ShowPingBars)
DrawPingBars(C, YOffset + (Height/2) - ((Height*0.5)/2), Width - (Height*0.5) - (Owner.HUDOwner.ScaledBorderSize*2), Height*0.5, Height*0.5, float(Ping));
}
final function DrawPingBars(Canvas C, float YOffset, float XOffset, float W, float H, float Ping)
{
local float PingMul, BarW, BarH, BaseH, XPos, YPos;
local byte i;
PingMul = 1.f - FClamp(FMax(Ping - Settings.Ping.Low, 1.f) / Settings.Ping.High, 0.f, 1.f);
BarW = W / PingBars;
BaseH = H / PingBars;
PingColor.R = (1.f - PingMul) * 255;
PingColor.G = PingMul * 255;
for (i=1; i < PingBars; i++)
{
BarH = BaseH * i;
XPos = XOffset + ((i - 1) * BarW);
YPos = YOffset + (H - BarH);
C.SetPos(XPos, YPos);
C.SetDrawColor(20, 20, 20, 255);
Owner.CurrentStyle.DrawWhiteBox(BarW, BarH);
if (PingMul >= (i / PingBars))
{
C.SetPos(XPos, YPos);
C.DrawColor = PingColor;
Owner.CurrentStyle.DrawWhiteBox(BarW, BarH);
}
C.SetDrawColor(80, 80, 80, 255);
Owner.CurrentStyle.DrawBoxHollow(XPos, YPos, BarW, BarH, 1);
}
}
static final function Texture2D FindAvatar(KFPlayerController PC, UniqueNetId ClientID)
{
local string S;
S = PC.GetSteamAvatar(ClientID);
if (S == "")
return None;
return Texture2D(PC.FindObject(S, class'Texture2D'));
}
final static function string GetNiceSize(int Num)
{
if (Num < 1000 ) return string(Num);
else if (Num < 1000000 ) return (Num / 1000) $ "K";
else if (Num < 1000000000 ) return (Num / 1000000) $ "M";
return (Num / 1000000000) $ "B";
}
function ScrollMouseWheel(bool bUp)
{
PlayersList.ScrollMouseWheel(bUp);
}
defaultproperties
{
bEnableInputs=true
PingColor=(R=255, G=255, B=60, A=255)
PingBars=5.0
Begin Object Class=KFGUI_List Name=PlayerList
XSize=0.7
OnDrawItem=DrawPlayerEntry
ID="PlayerList"
bClickable=false
ListItemsPerPage=16
End Object
Components.Add(PlayerList)
DefaultAvatar=Texture2D'UI_HUD.ScoreBoard_Standard_SWF_I26'
}

View File

@ -0,0 +1,8 @@
class PlayerRankRelations extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config array<RankRelation> Relation;

View File

@ -0,0 +1,201 @@
class ScoreboardStyle extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config int EdgeSize;
var config int ShapeServerNameBox;
var config int ShapeGameInfoBox;
var config int ShapeWaveInfoBox;
var config int ShapePlayersCountBox;
var config int ShapeHeaderBox;
var config int ShapeLeftStateBoxTopPlayer;
var config int ShapeLeftStateBoxMidPlayer;
var config int ShapeLeftStateBoxBottomPlayer;
var config int ShapePlayerBoxTopPlayer;
var config int ShapePlayerBoxMidPlayer;
var config int ShapePlayerBoxBottomPlayer;
var config int ShapeStatsBoxTopPlayer;
var config int ShapeStatsBoxMidPlayer;
var config int ShapeStatsBoxBottomPlayer;
var config ColorRGBA ServerNameBoxColor;
var config ColorRGBA ServerNameTextColor;
var config ColorRGBA GameInfoBoxColor;
var config ColorRGBA GameInfoTextColor;
var config ColorRGBA WaveBoxColor;
var config ColorRGBA WaveTextColor;
var config ColorRGBA PlayerCountBoxColor;
var config ColorRGBA PlayerCountTextColor;
var config ColorRGBA ListHeaderBoxColor;
var config ColorRGBA ListHeaderTextColor;
var config ColorRGBA LeftStateBoxColor;
var config ColorRGBA LeftStateBoxColorDead;
var config ColorRGBA LeftStateBoxColorLow;
var config ColorRGBA LeftStateBoxColorMid;
var config ColorRGBA LeftStateBoxColorHigh;
var config ColorRGBA PlayerOwnerBoxColor;
var config ColorRGBA PlayerBoxColor;
var config ColorRGBA StatsBoxColor;
var config ColorRGBA RankTextColor;
var config ColorRGBA ZedTextColor;
var config ColorRGBA PerkTextColor;
var config ColorRGBA LevelTextColor;
var config ColorRGBA PlayerNameTextColor;
var config ColorRGBA KillsTextColor;
var config ColorRGBA AssistsTextColor;
var config ColorRGBA DoshTextColor;
var config ColorRGBA StateTextColorLobby;
var config ColorRGBA StateTextColorReady;
var config ColorRGBA StateTextColorNotReady;
var config ColorRGBA StateTextColor;
var config ColorRGBA StateTextColorSpectator;
var config ColorRGBA StateTextColorDead;
var config ColorRGBA StateTextColorLowHP;
var config ColorRGBA StateTextColorMidHP;
var config ColorRGBA StateTextColorHighHP;
var config ColorRGBA PingTextColor;
var config ColorRGBA PingTextColorLow;
var config ColorRGBA PingTextColorMid;
var config ColorRGBA PingTextColorHigh;
public static function SCEStyle DefaultSettings()
{
local SCEStyle Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCEStyle Settings()
{
local SCEStyle Settings;
`callstack_static("Settings");
Settings.EdgeSize = default.EdgeSize;
Settings.ShapeServerNameBox = default.ShapeServerNameBox;
Settings.ShapeGameInfoBox = default.ShapeGameInfoBox;
Settings.ShapeWaveInfoBox = default.ShapeWaveInfoBox;
Settings.ShapePlayersCountBox = default.ShapePlayersCountBox;
Settings.ShapeHeaderBox = default.ShapeHeaderBox;
Settings.ShapeLeftStateBoxTopPlayer = default.ShapeLeftStateBoxTopPlayer;
Settings.ShapeLeftStateBoxMidPlayer = default.ShapeLeftStateBoxMidPlayer;
Settings.ShapeLeftStateBoxBottomPlayer = default.ShapeLeftStateBoxBottomPlayer;
Settings.ShapePlayerBoxTopPlayer = default.ShapePlayerBoxTopPlayer;
Settings.ShapePlayerBoxMidPlayer = default.ShapePlayerBoxMidPlayer;
Settings.ShapePlayerBoxBottomPlayer = default.ShapePlayerBoxBottomPlayer;
Settings.ShapeStatsBoxTopPlayer = default.ShapeStatsBoxTopPlayer;
Settings.ShapeStatsBoxMidPlayer = default.ShapeStatsBoxMidPlayer;
Settings.ShapeStatsBoxBottomPlayer = default.ShapeStatsBoxBottomPlayer;
Settings.ServerNameBoxColor = default.ServerNameBoxColor;
Settings.ServerNameTextColor = default.ServerNameTextColor;
Settings.GameInfoBoxColor = default.GameInfoBoxColor;
Settings.GameInfoTextColor = default.GameInfoTextColor;
Settings.WaveBoxColor = default.WaveBoxColor;
Settings.WaveTextColor = default.WaveTextColor;
Settings.PlayerCountBoxColor = default.PlayerCountBoxColor;
Settings.PlayerCountTextColor = default.PlayerCountTextColor;
Settings.ListHeaderBoxColor = default.ListHeaderBoxColor;
Settings.ListHeaderTextColor = default.ListHeaderTextColor;
Settings.LeftStateBoxColor = default.LeftStateBoxColor;
Settings.LeftStateBoxColorDead = default.LeftStateBoxColorDead;
Settings.LeftStateBoxColorLow = default.LeftStateBoxColorLow;
Settings.LeftStateBoxColorMid = default.LeftStateBoxColorMid;
Settings.LeftStateBoxColorHigh = default.LeftStateBoxColorHigh;
Settings.PlayerOwnerBoxColor = default.PlayerOwnerBoxColor;
Settings.PlayerBoxColor = default.PlayerBoxColor;
Settings.StatsBoxColor = default.StatsBoxColor;
Settings.RankTextColor = default.RankTextColor;
Settings.ZedTextColor = default.ZedTextColor;
Settings.PerkTextColor = default.PerkTextColor;
Settings.LevelTextColor = default.LevelTextColor;
Settings.PlayerNameTextColor = default.PlayerNameTextColor;
Settings.KillsTextColor = default.KillsTextColor;
Settings.AssistsTextColor = default.AssistsTextColor;
Settings.DoshTextColor = default.DoshTextColor;
Settings.StateTextColorLobby = default.StateTextColorLobby;
Settings.StateTextColorReady = default.StateTextColorReady;
Settings.StateTextColorNotReady = default.StateTextColorNotReady;
Settings.StateTextColor = default.StateTextColor;
Settings.StateTextColorSpectator = default.StateTextColorSpectator;
Settings.StateTextColorDead = default.StateTextColorDead;
Settings.StateTextColorLowHP = default.StateTextColorLowHP;
Settings.StateTextColorMidHP = default.StateTextColorMidHP;
Settings.StateTextColorHighHP = default.StateTextColorHighHP;
Settings.PingTextColor = default.PingTextColor;
Settings.PingTextColorLow = default.PingTextColorLow;
Settings.PingTextColorMid = default.PingTextColorMid;
Settings.PingTextColorHigh = default.PingTextColorHigh;
return Settings;
}
public static function WriteSettings(SCEStyle Settings)
{
`callstack_static("WriteSettings");
default.EdgeSize = Settings.EdgeSize;
default.ShapeServerNameBox = Settings.ShapeServerNameBox;
default.ShapeGameInfoBox = Settings.ShapeGameInfoBox;
default.ShapeWaveInfoBox = Settings.ShapeWaveInfoBox;
default.ShapePlayersCountBox = Settings.ShapePlayersCountBox;
default.ShapeHeaderBox = Settings.ShapeHeaderBox;
default.ShapeLeftStateBoxTopPlayer = Settings.ShapeLeftStateBoxTopPlayer;
default.ShapeLeftStateBoxMidPlayer = Settings.ShapeLeftStateBoxMidPlayer;
default.ShapeLeftStateBoxBottomPlayer = Settings.ShapeLeftStateBoxBottomPlayer;
default.ShapePlayerBoxTopPlayer = Settings.ShapePlayerBoxTopPlayer;
default.ShapePlayerBoxMidPlayer = Settings.ShapePlayerBoxMidPlayer;
default.ShapePlayerBoxBottomPlayer = Settings.ShapePlayerBoxBottomPlayer;
default.ShapeStatsBoxTopPlayer = Settings.ShapeStatsBoxTopPlayer;
default.ShapeStatsBoxMidPlayer = Settings.ShapeStatsBoxMidPlayer;
default.ShapeStatsBoxBottomPlayer = Settings.ShapeStatsBoxBottomPlayer;
default.ServerNameBoxColor = Settings.ServerNameBoxColor;
default.ServerNameTextColor = Settings.ServerNameTextColor;
default.GameInfoBoxColor = Settings.GameInfoBoxColor;
default.GameInfoTextColor = Settings.GameInfoTextColor;
default.WaveBoxColor = Settings.WaveBoxColor;
default.WaveTextColor = Settings.WaveTextColor;
default.PlayerCountBoxColor = Settings.PlayerCountBoxColor;
default.PlayerCountTextColor = Settings.PlayerCountTextColor;
default.ListHeaderBoxColor = Settings.ListHeaderBoxColor;
default.ListHeaderTextColor = Settings.ListHeaderTextColor;
default.LeftStateBoxColor = Settings.LeftStateBoxColor;
default.LeftStateBoxColorDead = Settings.LeftStateBoxColorDead;
default.LeftStateBoxColorLow = Settings.LeftStateBoxColorLow;
default.LeftStateBoxColorMid = Settings.LeftStateBoxColorMid;
default.LeftStateBoxColorHigh = Settings.LeftStateBoxColorHigh;
default.PlayerOwnerBoxColor = Settings.PlayerOwnerBoxColor;
default.PlayerBoxColor = Settings.PlayerBoxColor;
default.StatsBoxColor = Settings.StatsBoxColor;
default.RankTextColor = Settings.RankTextColor;
default.ZedTextColor = Settings.ZedTextColor;
default.PerkTextColor = Settings.PerkTextColor;
default.LevelTextColor = Settings.LevelTextColor;
default.PlayerNameTextColor = Settings.PlayerNameTextColor;
default.KillsTextColor = Settings.KillsTextColor;
default.AssistsTextColor = Settings.AssistsTextColor;
default.DoshTextColor = Settings.DoshTextColor;
default.StateTextColorLobby = Settings.StateTextColorLobby;
default.StateTextColorReady = Settings.StateTextColorReady;
default.StateTextColorNotReady = Settings.StateTextColorNotReady;
default.StateTextColor = Settings.StateTextColor;
default.StateTextColorSpectator = Settings.StateTextColorSpectator;
default.StateTextColorDead = Settings.StateTextColorDead;
default.StateTextColorLowHP = Settings.StateTextColorLowHP;
default.StateTextColorMidHP = Settings.StateTextColorMidHP;
default.StateTextColorHighHP = Settings.StateTextColorHighHP;
default.PingTextColor = Settings.PingTextColor;
default.PingTextColorLow = Settings.PingTextColorLow;
default.PingTextColorMid = Settings.PingTextColorMid;
default.PingTextColorHigh = Settings.PingTextColorHigh;
StaticSaveConfig();
}
defaultProperties
{
}

View File

@ -0,0 +1,12 @@
class ScoreboardStyleClient extends ScoreboardStyle
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config bool bEnabled;
defaultProperties
{
}

View File

@ -0,0 +1,13 @@
class SteamGroupRankRelations extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config array<RankRelation> Relation;
DefaultProperties
{
}

View File

@ -0,0 +1,48 @@
class SystemAdminRank extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config string Rank;
var config ColorRGBA TextColor;
var config Fields ApplyColorToFields;
public static function SCESettingsAdmin DefaultSettings()
{
local SCESettingsAdmin Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCESettingsAdmin Settings()
{
local SCESettingsAdmin Settings;
`callstack_static("Settings");
Settings.Rank = default.Rank;
Settings.TextColor = default.TextColor;
Settings.ApplyColorToFields = default.ApplyColorToFields;
return Settings;
}
public static function WriteSettings(SCESettingsAdmin Settings)
{
`callstack_static("WriteSettings");
default.Rank = Settings.Rank;
default.TextColor = Settings.TextColor;
default.ApplyColorToFields = Settings.ApplyColorToFields;
StaticSaveConfig();
}
DefaultProperties
{
}

View File

@ -0,0 +1,48 @@
class SystemPlayerRank extends Object
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
var config string Rank;
var config ColorRGBA TextColor;
var config Fields ApplyColorToFields;
public static function SCESettingsPlayer DefaultSettings()
{
local SCESettingsPlayer Settings;
`callstack_static("DefaultSettings");
return Settings;
}
public static function SCESettingsPlayer Settings()
{
local SCESettingsPlayer Settings;
`callstack_static("Settings");
Settings.Rank = default.Rank;
Settings.TextColor = default.TextColor;
Settings.ApplyColorToFields = default.ApplyColorToFields;
return Settings;
}
public static function WriteSettings(SCESettingsPlayer Settings)
{
`callstack_static("WriteSettings");
default.Rank = Settings.Rank;
default.TextColor = Settings.TextColor;
default.ApplyColorToFields = Settings.ApplyColorToFields;
StaticSaveConfig();
}
DefaultProperties
{
}

308
YAS/Classes/Types.uc Normal file
View File

@ -0,0 +1,308 @@
class Types extends Object;
`include(Build.uci)
`include(Logger.uci)
struct ColorRGBA
{
var byte R, G, B, A;
StructDefaultProperties
{
R = 250
G = 250
B = 250
A = 255
}
};
struct Fields
{
var bool Rank;
var bool Player;
var bool Level;
var bool Perk;
var bool Dosh;
var bool Kills;
var bool Assists;
var bool Health;
var bool Ping;
StructDefaultProperties
{
Rank = true;
Player = true;
Level = false;
Perk = false;
Dosh = false;
Kills = false;
Assists = false;
Health = false;
Ping = false;
}
};
struct RankInfo
{
var int ID;
var string Rank;
var ColorRGBA TextColor;
var bool OverrideAdminRank;
var Fields ApplyColorToFields;
};
struct RankRelation
{
var string ObjectID;
var int RankID;
StructDefaultProperties
{
RankID = -999
}
};
struct UIDRankRelation
{
var UniqueNetId UID;
var int RankID;
StructDefaultProperties
{
RankID = -999
}
};
struct SCESettingsAdmin
{
var string Rank;
var ColorRGBA TextColor;
var Fields ApplyColorToFields;
StructDefaultProperties
{
Rank = "Admin"
TextColor = (R=250, G=0, B=0, A=255)
ApplyColorToFields = (Rank=True, Player=True, Level=False, Perk=False, Dosh=False, Kills=False, Assists=False, Health=False, Ping=False)
}
};
struct SCESettingsPlayer
{
var string Rank;
var ColorRGBA TextColor;
var Fields ApplyColorToFields;
StructDefaultProperties
{
Rank = "Player"
TextColor = (R=250, G=250, B=250, A=255)
ApplyColorToFields = (Rank=True, Player=True, Level=False, Perk=False, Dosh=False, Kills=False, Assists=False, Health=False, Ping=False)
}
};
struct SCESettingsState
{
var bool Dynamic;
var int Low;
var int High;
StructDefaultProperties
{
Dynamic = True
Low = 40
High = 80
}
};
struct SCESettingsPing
{
var bool Dynamic;
var int Low;
var int High;
var bool ShowPingBars;
StructDefaultProperties
{
Dynamic = True
Low = 60
High = 120
ShowPingBars = True
}
};
struct SCESettingsLevel
{
var bool Dynamic;
var int Low[4];
var int High[4];
StructDefaultProperties
{
Dynamic = True
Low [0] = 0
High[0] = 0
Low [1] = 5
High[1] = 15
Low [2] = 15
High[2] = 20
Low [3] = 20
High[3] = 25
}
};
struct SCEStyle
{
var int EdgeSize;
var int ShapeServerNameBox;
var int ShapeGameInfoBox;
var int ShapeWaveInfoBox;
var int ShapePlayersCountBox;
var int ShapeHeaderBox;
var int ShapeLeftStateBoxTopPlayer;
var int ShapeLeftStateBoxMidPlayer;
var int ShapeLeftStateBoxBottomPlayer;
var int ShapePlayerBoxTopPlayer;
var int ShapePlayerBoxMidPlayer;
var int ShapePlayerBoxBottomPlayer;
var int ShapeStatsBoxTopPlayer;
var int ShapeStatsBoxMidPlayer;
var int ShapeStatsBoxBottomPlayer;
var ColorRGBA ServerNameBoxColor;
var ColorRGBA ServerNameTextColor;
var ColorRGBA GameInfoBoxColor;
var ColorRGBA GameInfoTextColor;
var ColorRGBA WaveBoxColor;
var ColorRGBA WaveTextColor;
var ColorRGBA PlayerCountBoxColor;
var ColorRGBA PlayerCountTextColor;
var ColorRGBA ListHeaderBoxColor;
var ColorRGBA ListHeaderTextColor;
var ColorRGBA LeftStateBoxColor;
var ColorRGBA LeftStateBoxColorDead;
var ColorRGBA LeftStateBoxColorLow;
var ColorRGBA LeftStateBoxColorMid;
var ColorRGBA LeftStateBoxColorHigh;
var ColorRGBA PlayerOwnerBoxColor;
var ColorRGBA PlayerBoxColor;
var ColorRGBA StatsBoxColor;
var ColorRGBA RankTextColor;
var ColorRGBA ZedTextColor;
var ColorRGBA PerkTextColor;
var ColorRGBA LevelTextColor;
var ColorRGBA PlayerNameTextColor;
var ColorRGBA KillsTextColor;
var ColorRGBA AssistsTextColor;
var ColorRGBA DoshTextColor;
var ColorRGBA StateTextColor;
var ColorRGBA PingTextColor;
var ColorRGBA LevelTextColorLow;
var ColorRGBA LevelTextColorMid;
var ColorRGBA LevelTextColorHigh;
var ColorRGBA StateTextColorLobby;
var ColorRGBA StateTextColorReady;
var ColorRGBA StateTextColorNotReady;
var ColorRGBA StateTextColorSpectator;
var ColorRGBA StateTextColorDead;
var ColorRGBA StateTextColorLowHP;
var ColorRGBA StateTextColorMidHP;
var ColorRGBA StateTextColorHighHP;
var ColorRGBA PingTextColorLow;
var ColorRGBA PingTextColorMid;
var ColorRGBA PingTextColorHigh;
StructDefaultProperties
{
EdgeSize = 8
ShapeServerNameBox = 150
ShapeGameInfoBox = 151
ShapeWaveInfoBox = 0
ShapePlayersCountBox = 152
ShapeHeaderBox = 150
ShapeLeftStateBoxTopPlayer = 151
ShapeLeftStateBoxMidPlayer = 151
ShapeLeftStateBoxBottomPlayer = 151
ShapePlayerBoxTopPlayer = 0
ShapePlayerBoxMidPlayer = 0
ShapePlayerBoxBottomPlayer = 0
ShapeStatsBoxTopPlayer = 153
ShapeStatsBoxMidPlayer = 153
ShapeStatsBoxBottomPlayer = 153
ServerNameBoxColor = (R=75, G=0, B=0, A=200)
ServerNameTextColor = (R=250, G=250, B=250, A=255)
GameInfoBoxColor = (R=30, G=30, B=30, A=200)
GameInfoTextColor = (R=250, G=250, B=250, A=255)
WaveBoxColor = (R=10, G=10, B=10, A=200)
WaveTextColor = (R=250, G=250, B=250, A=255)
PlayerCountBoxColor = (R=75, G=0, B=0, A=200)
PlayerCountTextColor = (R=250, G=250, B=250, A=255)
ListHeaderBoxColor = (R=10, G=10, B=10, A=200)
ListHeaderTextColor = (R=250, G=250, B=250, A=255)
LeftStateBoxColor = (R=150, G=150, B=150, A=150)
LeftStateBoxColorDead = (R=200, G=0, B=0, A=150)
LeftStateBoxColorLow = (R=200, G=50, B=50, A=150)
LeftStateBoxColorMid = (R=200, G=200, B=0, A=150)
LeftStateBoxColorHigh = (R=0, G=200, B=0, A=150)
PlayerOwnerBoxColor = (R=100, G=10, B=10, A=150)
PlayerBoxColor = (R=30, G=30, B=30, A=150)
StatsBoxColor = (R=10, G=10, B=10, A=150)
RankTextColor = (R=250, G=250, B=250, A=255)
ZedTextColor = (R=255, G=0, B=0, A=255)
PerkTextColor = (R=250, G=250, B=250, A=255)
LevelTextColor = (R=250, G=250, B=250, A=255)
PlayerNameTextColor = (R=250, G=250, B=250, A=255)
KillsTextColor = (R=250, G=250, B=250, A=255)
AssistsTextColor = (R=250, G=250, B=250, A=255)
DoshTextColor = (R=250, G=250, B=100, A=255)
StateTextColor = (R=150, G=150, B=150, A=150)
PingTextColor = (R=250, G=250, B=250, A=255)
LevelTextColorLow = (R=250, G=100, B=100, A=255)
LevelTextColorMid = (R=250, G=250, B=0, A=255)
LevelTextColorHigh = (R=0, G=250, B=0, A=255)
StateTextColorLobby = (R=150, G=150, B=150, A=150)
StateTextColorReady = (R=150, G=150, B=150, A=150)
StateTextColorNotReady = (R=150, G=150, B=150, A=150)
StateTextColorSpectator = (R=150, G=150, B=150, A=150)
StateTextColorDead = (R=250, G=0, B=0, A=255)
StateTextColorLowHP = (R=250, G=100, B=100, A=255)
StateTextColorMidHP = (R=250, G=250, B=0, A=255)
StateTextColorHighHP = (R=0, G=250, B=0, A=255)
PingTextColorLow = (R=0, G=250, B=0, A=255)
PingTextColorMid = (R=250, G=250, B=0, A=255)
PingTextColorHigh = (R=250, G=0, B=0, A=255)
}
};
struct SCESettings
{
var SCEStyle Style;
var SCESettingsAdmin Admin;
var SCESettingsPlayer Player;
var SCESettingsState State;
var SCESettingsPing Ping;
var SCESettingsLevel Level;
};

114
YAS/Classes/YASHUD.uc Normal file
View File

@ -0,0 +1,114 @@
class YASHUD extends KFGFxHudWrapper
config(YASMut);
`include(Build.uci)
`include(Logger.uci)
const HUDBorderSize = 3;
var float ScaledBorderSize;
var array<KFGUI_Base> HUDWidgets;
var class<KFScoreBoard> ScoreboardClass;
var KFScoreBoard Scoreboard;
var transient KF2GUIController GUIController;
var transient GUIStyleBase GUIStyle;
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
PlayerOwner.PlayerInput.OnReceivedNativeInputKey = NotifyInputKey;
PlayerOwner.PlayerInput.OnReceivedNativeInputAxis = NotifyInputAxis;
PlayerOwner.PlayerInput.OnReceivedNativeInputChar = NotifyInputChar;
RemoveMovies();
CreateHUDMovie();
}
function PostRender()
{
if (KFGRI == None)
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
if (GUIController != None && PlayerOwner.PlayerInput == None)
GUIController.NotifyLevelChange();
if (GUIController == None || GUIController.bIsInvalid)
{
GUIController = Class'YAS.KF2GUIController'.Static.GetGUIController(PlayerOwner);
if (GUIController != None)
{
GUIStyle = GUIController.CurrentStyle;
GUIStyle.HUDOwner = self;
LaunchHUDMenus();
}
}
GUIStyle.Canvas = Canvas;
GUIStyle.PickDefaultFontSize(Canvas.ClipY);
if (!GUIController.bIsInMenuState)
GUIController.HandleDrawMenu();
ScaledBorderSize = FMax(GUIStyle.ScreenScale(HUDBorderSize), 1.f);
Super.PostRender();
}
function LaunchHUDMenus()
{
Scoreboard = KFScoreBoard(GUIController.InitializeHUDWidget(ScoreboardClass));
Scoreboard.SetVisibility(false);
}
function bool NotifyInputKey(int ControllerId, Name Key, EInputEvent Event, float AmountDepressed, bool bGamepad)
{
local int i;
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputKey(ControllerId, Key, Event, AmountDepressed, bGamepad))
return true;
}
return false;
}
function bool NotifyInputAxis(int ControllerId, name Key, float Delta, float DeltaTime, optional bool bGamepad)
{
local int i;
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputAxis(ControllerId, Key, Delta, DeltaTime, bGamepad))
return true;
}
return false;
}
function bool NotifyInputChar(int ControllerId, string Unicode)
{
local int i;
for (i=(HUDWidgets.Length-1); i >= 0; --i)
{
if (HUDWidgets[i].bVisible && HUDWidgets[i].NotifyInputChar(ControllerId, Unicode))
return true;
}
return false;
}
exec function SetShowScores(bool bNewValue)
{
if (Scoreboard != None)
Scoreboard.SetVisibility(bNewValue);
else Super.SetShowScores(bNewValue);
}
defaultproperties
{
ScoreboardClass=class'KFScoreBoard'
}

281
YAS/Classes/YASMut.uc Normal file
View File

@ -0,0 +1,281 @@
class YASMut extends KFMutator
dependson(Types)
config(YAS);
`include(Build.uci)
`include(Logger.uci)
const CurrentVersion = 1;
var config int ConfigVersion;
var private OnlineSubsystem Steamworks;
struct SClient
{
var YASRepInfo RepInfo;
var KFPlayerController KFPC;
};
var private array<SClient> RepClients;
var private array<UIDRankRelation> UIDRankRelationsPlayers;
var private array<UIDRankRelation> UIDRankRelationsSteamGroups;
var private array<UIDRankRelation> UIDRankRelationsActive;
var private SCESettings Settings;
function PostBeginPlay()
{
`callstack();
Super.PostBeginPlay();
WorldInfo.Game.HUDType = class'YASHUD';
Steamworks = class'GameEngine'.static.GetOnlineSubsystem();
InitConfig();
LoadRelations();
Settings.Style = class'ScoreboardStyle'.static.Settings();
Settings.Admin = class'SystemAdminRank'.static.Settings();
Settings.Player = class'SystemPlayerRank'.static.Settings();
Settings.State = class'DynamicStateColor'.static.Settings();
Settings.Ping = class'DynamicPingColor'.static.Settings();
Settings.Level = class'DynamicLevelColor'.static.Settings();
}
function NotifyLogin(Controller C)
{
`callstack();
AddPlayer(C);
Super.NotifyLogin(C);
}
function NotifyLogout(Controller C)
{
`callstack();
RemovePlayer(C);
Super.NotifyLogout(C);
}
private function bool IsUID(String ID)
{
`callstack();
return (Left(ID, 2) ~= "0x");
}
private function InitConfig()
{
local RankInfo ExampleRank;
local RankRelation ExamplePlayer;
local RankRelation ExampleSteamGroup;
`callstack();
// Update from config version to current version if needed
switch (ConfigVersion)
{
case 0: // which means there is no config right now
SaveConfig(); // because I want the main settings to be at the beginning of the config :)
class'SystemAdminRank'.static.WriteSettings(class'SystemAdminRank'.static.DefaultSettings());
class'SystemPlayerRank'.static.WriteSettings(class'SystemPlayerRank'.static.DefaultSettings());
class'ScoreboardStyle'.static.WriteSettings(class'ScoreboardStyle'.static.DefaultSettings());
class'DynamicStateColor'.static.WriteSettings(class'DynamicStateColor'.static.DefaultSettings());
class'DynamicPingColor'.static.WriteSettings(class'DynamicPingColor'.static.DefaultSettings());
class'DynamicLevelColor'.static.WriteSettings(class'DynamicLevelColor'.static.DefaultSettings());
// Example rank for player(s)
ExampleRank.ID = 0;
ExampleRank.Rank = "SCE Creator";
ExampleRank.TextColor.R = 130;
ExampleRank.TextColor.G = 250;
ExampleRank.TextColor.B = 235;
ExampleRank.OverrideAdminRank = true;
class'CustomRanks'.default.Rank.AddItem(ExampleRank);
// Example player
ExamplePlayer.ObjectID = "76561198001617867"; // GenZmeY SteamID64
ExamplePlayer.RankID = ExampleRank.ID;
class'PlayerRankRelations'.default.Relation.AddItem(ExamplePlayer);
// Example rank for steam group members
ExampleRank.ID = 1;
ExampleRank.Rank = "MSK-GS";
ExampleRank.TextColor.R = 130;
ExampleRank.TextColor.G = 250;
ExampleRank.TextColor.B = 130;
ExampleRank.OverrideAdminRank = false;
class'CustomRanks'.default.Rank.AddItem(ExampleRank);
// Example steam group
ExampleSteamGroup.ObjectID = "103582791465384046"; // MSK-GS SteamID64
ExampleSteamGroup.RankID = ExampleRank.ID;
class'SteamGroupRankRelations'.default.Relation.AddItem(ExampleSteamGroup);
class'CustomRanks'.static.StaticSaveConfig();
class'PlayerRankRelations'.static.StaticSaveConfig();
class'SteamGroupRankRelations'.static.StaticSaveConfig();
case 2147483647:
`info("Config updated to version"@CurrentVersion);
break;
case CurrentVersion:
`info("Config is up-to-date");
break;
default:
`warning("The config version is higher than the current version (are you using an old mutator?)");
`warning("Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
`warning("The config version will be changed to "@CurrentVersion);
break;
}
if (ConfigVersion != CurrentVersion)
{
ConfigVersion = CurrentVersion;
SaveConfig();
}
}
private function LoadRelations()
{
local RankRelation Player, SteamGroup;
local UIDRankRelation UIDInfo;
`callstack();
foreach class'PlayerRankRelations'.default.Relation(Player)
{
UIDInfo.RankID = Player.RankID;
if (IsUID(Player.ObjectID) && Steamworks.StringToUniqueNetId(Player.ObjectID, UIDInfo.UID))
{
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDRankRelationsPlayers.AddItem(UIDInfo);
}
else if (Steamworks.Int64ToUniqueNetId(Player.ObjectID, UIDInfo.UID))
{
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDRankRelationsPlayers.AddItem(UIDInfo);
}
else `warning("Can't add player:"@Player.ObjectID);
}
foreach class'SteamGroupRankRelations'.default.Relation(SteamGroup)
{
UIDInfo.RankID = SteamGroup.RankID;
if (IsUID(SteamGroup.ObjectID) && Steamworks.StringToUniqueNetId(SteamGroup.ObjectID, UIDInfo.UID))
{
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDRankRelationsPlayers.AddItem(UIDInfo);
}
else if (Steamworks.Int64ToUniqueNetId(SteamGroup.ObjectID, UIDInfo.UID))
{
if (UIDRankRelationsSteamGroups.Find('Uid', UIDInfo.UID) == INDEX_NONE)
UIDRankRelationsSteamGroups.AddItem(UIDInfo);
}
else `warning("Can't add steamgroup:"@SteamGroup.ObjectID);
}
}
private function AddPlayer(Controller C)
{
local KFPlayerController KFPC;
local UIDRankRelation Relation;
local SClient RepClient, RepClientNew;
`callstack();
KFPC = KFPlayerController(C);
if (KFPC == None)
return;
RepClientNew.KFPC = KFPC;
RepClientNew.RepInfo = Spawn(class'YASRepInfo', KFPC);
RepClientNew.RepInfo.Mut = Self;
RepClientNew.RepInfo.CustomRanks = class'CustomRanks'.default.Rank;
RepClientNew.RepInfo.SteamGroupRelations = UIDRankRelationsSteamGroups;
RepClientNew.RepInfo.Settings = Settings;
RepClientNew.RepInfo.RankRelation.UID = KFPC.PlayerReplicationInfo.UniqueId;
RepClientNew.RepInfo.RankRelation.RankID = UIDRankRelationsPlayers.Find('UID', RepClientNew.RepInfo.RankRelation.UID);
RepClients.AddItem(RepClientNew);
foreach UIDRankRelationsActive(Relation)
RepClientNew.RepInfo.AddRankRelation(Relation);
RepClientNew.RepInfo.StartFirstTimeReplication();
if (RepClientNew.RepInfo.RankRelation.RankID != INDEX_NONE)
{
UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation);
foreach RepClients(RepClient)
RepClient.RepInfo.AddRankRelation(RepClientNew.RepInfo.RankRelation);
}
}
private function RemovePlayer(Controller C)
{
local KFPlayerController KFPC;
local int Index, i;
local UniqueNetId UID;
`callstack();
KFPC = KFPlayerController(C);
if (KFPC == None)
return;
UID = KFPC.PlayerReplicationInfo.UniqueId;
Index = UIDRankRelationsActive.Find('UID', UID);
if (Index != INDEX_NONE)
for (i = 0; i < UIDRankRelationsActive.Length; ++i)
if (Index != i)
RepClients[i].RepInfo.RemoveRankRelation(UIDRankRelationsActive[Index]);
Index = RepClients.Find('KFPC', KFPC);
if (Index == INDEX_NONE)
return;
if (RepClients[Index].RepInfo != None)
RepClients[Index].RepInfo.Destroy();
RepClients.Remove(Index, 1);
}
public function UpdatePlayerRank(UIDRankRelation Rel)
{
local SClient RepClient;
local int Index;
`callstack();
Index = UIDRankRelationsActive.Find('UID', Rel.UID);
if (Index != INDEX_NONE)
UIDRankRelationsActive[Index] = Rel;
else
UIDRankRelationsActive.AddItem(Rel);
foreach RepClients(RepClient)
RepClient.RepInfo.UpdateRankRelation(Rel);
}
public function AddPlayerRank(UIDRankRelation Rel)
{
local SClient RepClient;
`callstack();
foreach RepClients(RepClient)
RepClient.RepInfo.AddRankRelation(Rel);
}
DefaultProperties
{
}

258
YAS/Classes/YASRepInfo.uc Normal file
View File

@ -0,0 +1,258 @@
class YASRepInfo extends ReplicationInfo;
`include(Build.uci)
`include(Logger.uci)
// Server vars
var public YASMut Mut;
// Client vars
var private KFScoreBoard SC;
var private OnlineSubsystemSteamworks SW;
// Fitst time replication
var public array<UIDRankRelation> SteamGroupRelations;
var private array<UIDRankRelation> RankRelations;
var public array<RankInfo> CustomRanks;
var public SCESettings Settings;
var public UIDRankRelation RankRelation; // Current player rank relation
var private int CustomRanksRepProgress, SteamGroupsRepProgress;
simulated event PostBeginPlay()
{
`callstack();
super.PostBeginPlay();
if (bDeleteMe) return;
if (Role < ROLE_Authority || WorldInfo.NetMode == NM_StandAlone)
{
GetScoreboard();
GetOnlineSubsystem();
}
}
private reliable client function GetScoreboard()
{
`callstack();
if (SC == None)
SC = YASHUD(GetALocalPlayerController().myHUD).Scoreboard;
if (SC == None)
SetTimer(0.1f, false, nameof(GetScoreboard));
else
ClearTimer(nameof(GetScoreboard));
}
private reliable client function GetOnlineSubsystem()
{
`callstack();
if (SW == None)
SW = OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem());
if (SW == None)
SetTimer(0.1f, false, nameof(GetOnlineSubsystem));
else
ClearTimer(nameof(GetOnlineSubsystem));
}
public function StartFirstTimeReplication()
{
`callstack();
ClientAddSettings(Settings);
SetTimer(0.01f, true, nameof(ReplicateCustomRanks));
SetTimer(0.01f, true, nameof(ReplicateSteamGroupRelations));
}
private reliable client function ClientAddSettings(SCESettings Set)
{
`callstack();
Settings = Set;
ClientApplySettings();
}
private reliable client function ClientApplySettings()
{
`callstack();
if (SC == None)
{
SetTimer(0.1f, false, nameof(ClientApplySettings));
return;
}
ClearTimer(nameof(ClientApplySettings));
if (class'ScoreboardStyleClient'.default.bEnabled)
Settings.Style = class'ScoreboardStyleClient'.static.Settings();
SC.Settings = Settings;
}
private reliable client function ClientApplyCustomRanks()
{
`callstack();
if (SC == None)
{
SetTimer(0.1f, false, nameof(ClientApplyCustomRanks));
return;
}
ClearTimer(nameof(ClientApplyCustomRanks));
SC.CustomRanks = CustomRanks;
}
private reliable client function ClientApplyRankRelations()
{
`callstack();
if (SC == None)
{
SetTimer(0.1f, false, nameof(ClientApplyRankRelations));
return;
}
ClearTimer(nameof(ClientApplyRankRelations));
SC.RankRelations = RankRelations;
}
private function ReplicateCustomRanks()
{
`callstack();
if (WorldInfo.NetMode != NM_StandAlone && CustomRanksRepProgress < CustomRanks.Length)
{
ClientAddCustomRank(CustomRanks[CustomRanksRepProgress]);
++CustomRanksRepProgress;
}
else
{
ClearTimer(nameof(ReplicateCustomRanks));
ClientApplyCustomRanks();
}
}
private reliable client function ClientAddCustomRank(RankInfo Rank)
{
`callstack();
CustomRanks.AddItem(Rank);
}
private function ReplicateSteamGroupRelations()
{
`callstack();
if (WorldInfo.NetMode != NM_StandAlone && SteamGroupsRepProgress < SteamGroupRelations.Length)
{
ClientAddSteamGroupRelation(SteamGroupRelations[SteamGroupsRepProgress]);
++SteamGroupsRepProgress;
}
else
{
ClearTimer(nameof(ReplicateSteamGroupRelations));
if (RankRelation.RankID == INDEX_NONE)
FindMyRankInSteamGroups();
}
}
private reliable client function ClientAddSteamGroupRelation(UIDRankRelation Rel)
{
`callstack();
SteamGroupRelations.AddItem(Rel);
}
private reliable client function FindMyRankInSteamGroups()
{
local UIDRankRelation SteamGroupRel;
`callstack();
foreach SteamGroupRelations(SteamGroupRel)
if (SW.CheckPlayerGroup(SteamGroupRel.UID))
RankRelation.RankID = SteamGroupRel.RankID;
if (RankRelation.RankID != INDEX_NONE)
ServerApplyRank(RankRelation.RankID);
}
private reliable server function ServerApplyRank(int RankID)
{
`callstack();
RankRelation.RankID = RankID;
Mut.UpdatePlayerRank(RankRelation);
}
public function AddRankRelation(UIDRankRelation Rel)
{
`callstack();
ClientAddRankRelation(Rel);
}
private reliable client function ClientAddRankRelation(UIDRankRelation Rel)
{
`callstack();
RankRelations.AddItem(Rel);
ClientApplyRankRelations();
}
public function RemoveRankRelation(UIDRankRelation Rel)
{
`callstack();
ClientRemoveRankRelation(Rel);
}
private reliable client function ClientRemoveRankRelation(UIDRankRelation Rel)
{
`callstack();
RankRelations.RemoveItem(Rel);
ClientApplyRankRelations();
}
public function UpdateRankRelation(UIDRankRelation Rel)
{
`callstack();
ClientUpdateRankRelation(Rel);
}
private reliable client function ClientUpdateRankRelation(UIDRankRelation Rel)
{
local int Index;
`callstack();
Index = RankRelations.Find('UID', Rel.UID);
if (Index != INDEX_NONE)
RankRelations[Index] = Rel;
else
RankRelations.AddItem(Rel);
ClientApplyRankRelations();
}
defaultproperties
{
bAlwaysRelevant = false;
bOnlyRelevantToOwner = true;
Role = ROLE_Authority;
RemoteRole = ROLE_SimulatedProxy;
bSkipActorPropertyReplication = false; // This is needed, otherwise the client-to-server RPC fails
CustomRanksRepProgress = 0;
SteamGroupsRepProgress = 0;
}

46
YAS/Globals.uci Normal file
View File

@ -0,0 +1,46 @@
`define BOX_INNERBORDER 0
`define BOX_INNERBORDER_TRANSPARENT 1
`define BOX_MEDIUM 2
`define BOX_MEDIUM_SLIGHTTRANSPARENT 3
`define BOX_MEDIUM_TRANSPARENT 4
`define BOX_LARGE 5
`define BOX_LARGE_SLIGHTTRANSPARENT 6
`define BOX_LARGE_TRANSPARENT 7
`define BOX_SMALL 8
`define BOX_SMALL_SLIGHTTRANSPARENT 9
`define BOX_SMALL_TRANSPARENT 10
`define BOX_CORNER_8 11
`define BOX_CORNER_16 12
`define BOX_CORNER_32 13
`define BOX_CORNER_64 14
`define BOX_CORNER_512 15
`define ITEMBOX_NORMAL 0
`define ITEMBOX_DISABLED 1
`define ITEMBOX_HIGHLIGHTED 2
`define CHECKMARK_NORMAL 0
`define CHECKMARK_DISABLED 1
`define CHECKMARK_HIGHLIGHTED 2
`define ARROW_DOWN 0
`define ARROW_LEFT 1
`define ARROW_RIGHT 2
`define ARROW_UP 3
`define BUTTON_NORMAL 0
`define BUTTON_DISABLED 1
`define BUTTON_HIGHLIGHTED 2
`define BUTTON_PRESSED 3
`define TAB_TOP 0
`define TAB_BOTTOM 1
`define PEN_WHITE 0
`define PEN_BLACK 1
`define PEN_GRAY 2
`define CURSOR_DEFAULT 0
`define CURSOR_SELECTION 1
`define CURSOR_RESIZEVERT 2
`define CURSOR_RESIZEHORZ 3

9
YAS/Logger.uci Normal file
View File

@ -0,0 +1,9 @@
`define scelog(text, cond) `log(`text, `cond, 'YetAnotherScoreboard')
`define info(text) `scelog("[INFO]"@`text, true)
`define warning(text) `scelog("[WARNING]"@`text, true)
`define error(text) `scelog("[ERROR]"@`text, true)
`define debug(text) if (`bEnableDebug) { `scelog("[DEBUG]"@`text, `bEnableDebug); }
`define callstack() if (`bEnableCallstack) { `scelog("[CALLSTACK]"@`Location, `bEnableCallstack); }
`define callstack_static(text) if (`bEnableCallstack) { `scelog("[CALLSTACK]"@`text, `bEnableCallstack); }