2017-10-20 02:00:49 +00:00
|
|
|
// List box with components as items.
|
|
|
|
Class KFGUI_ComponentList extends KFGUI_List;
|
|
|
|
|
|
|
|
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!!!
|
2020-11-28 20:04:55 +00:00
|
|
|
final function KFGUI_Base AddListComponent(class<KFGUI_Base> CompClass, optional float XS=1.f, optional float YS=1.f)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local KFGUI_Base G;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
G = new(Self)CompClass;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (G==None)
|
2017-10-20 02:00:49 +00:00
|
|
|
return None;
|
|
|
|
G.XPosition = (1.f - XS) * 0.5f;
|
|
|
|
G.YPosition = (1.f - YS) * 0.5f;
|
|
|
|
G.XSize = XS;
|
|
|
|
G.YSize = YS;
|
|
|
|
G.Owner = Owner;
|
|
|
|
G.ParentComponent = Self;
|
|
|
|
ItemComponents[ItemComponents.Length] = G;
|
|
|
|
return G;
|
|
|
|
}
|
|
|
|
|
|
|
|
function EmptyList()
|
|
|
|
{
|
|
|
|
ItemComponents.Length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function InitMenu()
|
|
|
|
{
|
|
|
|
Super.InitMenu();
|
|
|
|
ListCount = 0;
|
|
|
|
NumColumns = Max(NumColumns,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
function DrawMenu()
|
|
|
|
{
|
|
|
|
Canvas.DrawColor = BackgroundColor;
|
|
|
|
Canvas.SetPos(0.f,0.f);
|
|
|
|
Owner.CurrentStyle.DrawWhiteBox(CompPos[2],CompPos[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function PreDraw()
|
|
|
|
{
|
|
|
|
local int i,XNum,r;
|
|
|
|
local byte j;
|
|
|
|
local float XS,YS;
|
|
|
|
|
|
|
|
ComputeCoords();
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
// Update list size
|
|
|
|
i = ItemComponents.Length / NumColumns;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i!=NumColumns)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
ListCount = i;
|
|
|
|
UpdateListVis();
|
|
|
|
}
|
|
|
|
|
|
|
|
// First draw scrollbar to allow it to resize itself.
|
2020-11-28 20:12:58 +00:00
|
|
|
for (j=0; j<4; ++j)
|
2017-10-20 02:00:49 +00:00
|
|
|
ScrollBar.InputPos[j] = CompPos[j];
|
2020-11-28 20:12:58 +00:00
|
|
|
if (OldXSize!=InputPos[2])
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
OldXSize = InputPos[2];
|
|
|
|
ScrollBar.XPosition = 1.f - ScrollBar.GetWidth();
|
|
|
|
}
|
|
|
|
ScrollBar.Canvas = Canvas;
|
|
|
|
ScrollBar.PreDraw();
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
// 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();
|
|
|
|
|
|
|
|
// Then draw rest of components.
|
|
|
|
XNum = 0;
|
|
|
|
r = 0;
|
|
|
|
XS = CompPos[2] / NumColumns;
|
|
|
|
YS = CompPos[3] / ListItemsPerPage;
|
|
|
|
VisRange[0] = (ScrollBar.CurrentScroll*NumColumns);
|
|
|
|
VisRange[1] = ItemComponents.Length;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=VisRange[0]; i<VisRange[1]; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (++XNum==NumColumns)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
XNum = 0;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (++r==ListItemsPerPage)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
VisRange[1] = i+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CompPos[2] += ScrollBar.CompPos[2];
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ChangeListSize(int NewSize);
|
2017-10-20 02:00:49 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function MouseClick(bool bRight);
|
|
|
|
function MouseRelease(bool bRight);
|
2017-10-20 02:00:49 +00:00
|
|
|
function MouseLeave()
|
|
|
|
{
|
|
|
|
Super(KFGUI_Base).MouseLeave();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function MouseEnter()
|
|
|
|
{
|
|
|
|
Super(KFGUI_Base).MouseEnter();
|
|
|
|
}
|
|
|
|
|
|
|
|
function bool CaptureMouse()
|
|
|
|
{
|
|
|
|
local int i;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=VisRange[0]; i<VisRange[1] && i<ItemComponents.Length; ++i)
|
|
|
|
if (ItemComponents[i].CaptureMouse())
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
MouseArea = ItemComponents[i];
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return Super.CaptureMouse();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function CloseMenu()
|
|
|
|
{
|
|
|
|
local int i;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<ItemComponents.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
ItemComponents[i].CloseMenu();
|
|
|
|
Super.CloseMenu();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function NotifyLevelChange()
|
|
|
|
{
|
|
|
|
local int i;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<ItemComponents.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
ItemComponents[i].NotifyLevelChange();
|
|
|
|
Super.NotifyLevelChange();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function MenuTick(float DeltaTime)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
|
|
|
|
Super.MenuTick(DeltaTime);
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<ItemComponents.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
ItemComponents[i].MenuTick(DeltaTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
ListCount=0
|
|
|
|
NumColumns=1
|
|
|
|
bClickable=true
|
|
|
|
}
|