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

139 lines
3.2 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
// Columned list box (only for text lines).
Class UIR_PerkTraitList extends KFGUI_ColumnList;
var array<string> ToolTip;
var KFGUI_Tooltip ToolTipItem;
2020-09-01 04:28:45 +00:00
var localized string TraitNameText;
var localized string TraitLevelText;
var localized string TraitCostText;
function InitMenu()
{
local FColumnItem NameItem;
local FColumnItem LevelItem;
local FColumnItem CostItem;
Super.InitMenu();
NameItem.Text=TraitNameText;
NameItem.Width=0.6;
LevelItem.Text=TraitLevelText;
LevelItem.Width=0.2;
CostItem.Text=TraitCostText;
CostItem.Width=0.2;
Columns.AddItem(NameItem);
Columns.AddItem(LevelItem);
Columns.AddItem(CostItem);
}
2017-10-20 02:00:49 +00:00
function DrawMenu()
{
local int i,n,j;
local float Y,TextY,YClip,XOffset;
local KFGUI_ListItem C;
local bool bCheckMouse,bHideRow;
Canvas.DrawColor = BackgroundColor;
Canvas.SetPos(0.f,0.f);
Owner.CurrentStyle.DrawWhiteBox(CompPos[2],CompPos[3]);
// Mouse focused item check.
bCheckMouse = bClickable && bFocused;
FocusMouseItem = -1;
2020-11-28 20:12:58 +00:00
if (bCheckMouse)
2017-10-20 02:00:49 +00:00
MouseYHit = Owner.MousePosition.Y - CompPos[1];
n = ScrollBar.CurrentScroll;
i = 0;
2020-11-28 20:12:58 +00:00
for (C=FirstItem; C!=None; C=C.Next)
if ((i++)==n)
2017-10-20 02:00:49 +00:00
break;
Y = 0.f;
TextY = (ItemHeight-TextHeight)*0.5f;
XOffset = TextY*0.75;
YClip = CompPos[1]+CompPos[3];
Canvas.SetDrawColor(250,250,250,255);
2020-11-28 20:12:58 +00:00
for (i=0; (i<ListItemsPerPage && C!=None); ++i)
2017-10-20 02:00:49 +00:00
{
// Check for mouse hit.
2020-11-28 20:12:58 +00:00
if (bCheckMouse && FocusMouseItem==-1)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (MouseYHit<ItemHeight)
2017-10-20 02:00:49 +00:00
FocusMouseItem = n;
else MouseYHit-=ItemHeight;
}
// Draw selection background.
bHideRow = false;
2020-11-28 20:12:58 +00:00
if (Left(C.GetDisplayStr(0),2)=="--") // Group name.
2017-10-20 02:00:49 +00:00
{
Canvas.SetPos(0,Y);
Canvas.SetDrawColor(32,128,32);
bHideRow = true;
Owner.CurrentStyle.DrawWhiteBox(CompPos[2],ItemHeight);
Canvas.SetDrawColor(250,250,250,255);
Canvas.SetClip(CompPos[0]+CompPos[2],YClip);
Canvas.SetPos(2,TextY);
DrawStrClipped(Mid(C.GetDisplayStr(0),2));
}
2020-11-28 20:12:58 +00:00
else if (SelectedRowIndex==n) // Selected
2017-10-20 02:00:49 +00:00
{
Canvas.SetPos(0,Y);
Canvas.DrawColor = SelectedLineColor;
Owner.CurrentStyle.DrawWhiteBox(CompPos[2],ItemHeight);
Canvas.SetDrawColor(250,250,250,255);
}
2020-11-28 20:12:58 +00:00
else if (FocusMouseItem==n) // Focused
2017-10-20 02:00:49 +00:00
{
Canvas.SetPos(0,Y);
Canvas.DrawColor = FocusedLineColor;
Owner.CurrentStyle.DrawWhiteBox(CompPos[2],ItemHeight);
Canvas.SetDrawColor(250,250,250,255);
}
2020-11-28 20:12:58 +00:00
if (!bHideRow)
2017-10-20 02:00:49 +00:00
{
// Draw columns of text
2020-11-28 20:12:58 +00:00
for (j=0; j<Columns.Length; ++j)
if (!Columns[j].bHidden)
2017-10-20 02:00:49 +00:00
{
Canvas.SetClip(Columns[j].X+Columns[j].XSize,YClip);
Canvas.SetPos(Columns[j].X+XOffset,TextY);
DrawStrClipped(C.GetDisplayStr(j));
}
}
Y+=ItemHeight;
TextY+=ItemHeight;
++n;
C = C.Next;
}
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function NotifyMousePaused()
{
2020-11-28 20:12:58 +00:00
if (Owner.InputFocus==None && FocusMouseItem!=-1 && ToolTip[FocusMouseItem]!="")
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (ToolTipItem==None)
2017-10-20 02:00:49 +00:00
{
ToolTipItem = New(None)Class'KFGUI_Tooltip';
ToolTipItem.Owner = Owner;
ToolTipItem.ParentComponent = Self;
ToolTipItem.InitMenu();
}
ToolTipItem.SetText(ToolTip[FocusMouseItem]);
ToolTipItem.ShowMenu();
ToolTipItem.CompPos[0] = Owner.MousePosition.X;
ToolTipItem.CompPos[1] = Owner.MousePosition.Y;
ToolTipItem.GetInputFocus();
}
}
defaultproperties
{
bCanSortColumn=false
}