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

59 lines
1.2 KiB
Ucode
Raw Normal View History

2017-10-19 21:00:49 -05:00
Class KFGUI_FloatingWindow extends KFGUI_Page
abstract;
var() string WindowTitle; // Title of this window.
var float DragOffset[2];
var KFGUI_FloatingWindowHeader HeaderComp;
var bool bDragWindow;
function InitMenu()
{
Super.InitMenu();
HeaderComp = new (Self) class'KFGUI_FloatingWindowHeader';
AddComponent(HeaderComp);
}
2020-11-29 00:54:57 +03:00
2017-10-19 21:00:49 -05:00
function DrawMenu()
{
Owner.CurrentStyle.RenderFramedWindow(Self);
2020-11-28 23:12:58 +03:00
if (HeaderComp!=None)
2017-10-19 21:00:49 -05:00
{
HeaderComp.CompPos[3] = Owner.CurrentStyle.DefaultHeight;
HeaderComp.YSize = HeaderComp.CompPos[3] / CompPos[3]; // Keep header height fit the window height.
}
}
2020-11-29 00:54:57 +03:00
2020-11-28 23:04:55 +03:00
function SetWindowDrag(bool bDrag)
2017-10-19 21:00:49 -05:00
{
bDragWindow = bDrag;
2020-11-28 23:12:58 +03:00
if (bDrag)
2017-10-19 21:00:49 -05:00
{
DragOffset[0] = Owner.MousePosition.X-CompPos[0];
DragOffset[1] = Owner.MousePosition.Y-CompPos[1];
}
}
2020-11-29 00:54:57 +03:00
2017-10-19 21:00:49 -05:00
function bool CaptureMouse()
{
2020-11-28 23:12:58 +03:00
if (bDragWindow && HeaderComp!=None) // Always keep focus on window frame now!
2017-10-19 21:00:49 -05:00
{
MouseArea = HeaderComp;
return true;
}
return Super.CaptureMouse();
}
2020-11-29 00:54:57 +03:00
2017-10-19 21:00:49 -05:00
function PreDraw()
{
2020-11-28 23:12:58 +03:00
if (bDragWindow)
2017-10-19 21:00:49 -05:00
{
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
{
}