2017-10-20 02:00:49 +00:00
|
|
|
Class UIP_PerkSelection extends KFGUI_MultiComponent;
|
|
|
|
|
|
|
|
var KFGUI_List PerkList;
|
2020-08-12 15:53:32 +00:00
|
|
|
var KFGUI_Button B_Prestige, B_Reset, B_Unload;
|
2017-10-20 02:00:49 +00:00
|
|
|
var KFGUI_ComponentList StatsList;
|
|
|
|
var UIR_PerkTraitList TraitsList;
|
|
|
|
var KFGUI_TextLable PerkLabel;
|
|
|
|
var ExtPerkManager CurrentManager;
|
|
|
|
var Ext_PerkBase PendingPerk,OldUsedPerk;
|
|
|
|
var class<Ext_PerkBase> PrevPendingPerk;
|
|
|
|
var array<UIR_PerkStat> StatBuyers;
|
|
|
|
var int OldPerkPoints;
|
|
|
|
|
2020-08-12 15:53:32 +00:00
|
|
|
var localized string PrestigeButtonText;
|
|
|
|
var localized string PrestigeButtonToolTip;
|
|
|
|
var localized string ResetButtonText;
|
|
|
|
var localized string ResetButtonToolTip;
|
|
|
|
var localized string UnloadButtonText;
|
|
|
|
var localized string UnloadButtonToolTip;
|
|
|
|
var localized string PrestigeButtonDisabledToolTip;
|
|
|
|
var localized string Level;
|
|
|
|
var localized string Points;
|
|
|
|
var localized string NoPerkSelected;
|
|
|
|
var localized string NotAviable;
|
|
|
|
var localized string MaxStr;
|
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function InitMenu()
|
|
|
|
{
|
|
|
|
PerkList = KFGUI_List(FindComponentID('Perks'));
|
|
|
|
StatsList = KFGUI_ComponentList(FindComponentID('Stats'));
|
|
|
|
TraitsList = UIR_PerkTraitList(FindComponentID('Traits'));
|
|
|
|
PerkLabel = KFGUI_TextLable(FindComponentID('Info'));
|
|
|
|
PerkLabel.SetText("");
|
|
|
|
B_Prestige = KFGUI_Button(FindComponentID('Prestige'));
|
2020-08-12 15:53:32 +00:00
|
|
|
B_Reset = KFGUI_Button(FindComponentID('Reset'));
|
|
|
|
B_Unload = KFGUI_Button(FindComponentID('Unload'));
|
|
|
|
|
|
|
|
B_Prestige.ButtonText=PrestigeButtonText;
|
|
|
|
B_Prestige.ToolTip="-";
|
|
|
|
|
|
|
|
B_Unload.ButtonText=UnloadButtonText;
|
|
|
|
B_Unload.ToolTip=UnloadButtonToolTip;
|
|
|
|
|
|
|
|
B_Reset.ButtonText=ResetButtonText;
|
|
|
|
B_Reset.ToolTip=ResetButtonToolTip;
|
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
Super.InitMenu();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function ShowMenu()
|
|
|
|
{
|
|
|
|
Super.ShowMenu();
|
|
|
|
SetTimer(0.1,true);
|
|
|
|
Timer();
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function CloseMenu()
|
|
|
|
{
|
|
|
|
Super.CloseMenu();
|
|
|
|
CurrentManager = None;
|
|
|
|
PrevPendingPerk = (PendingPerk!=None ? PendingPerk.Class : None);
|
|
|
|
PendingPerk = None;
|
|
|
|
OldUsedPerk = None;
|
|
|
|
SetTimer(0,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Timer()
|
|
|
|
{
|
|
|
|
local int i;
|
|
|
|
|
|
|
|
CurrentManager = ExtPlayerController(GetPlayer()).ActivePerkManager;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (CurrentManager!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PrevPendingPerk!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
PendingPerk = CurrentManager.FindPerk(PrevPendingPerk);
|
|
|
|
PrevPendingPerk = None;
|
|
|
|
}
|
|
|
|
PerkList.ChangeListSize(CurrentManager.UserPerks.Length);
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=None && !PendingPerk.bPerkNetReady)
|
2017-10-20 02:00:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Huge code block to handle stat updating, but actually pretty well optimized.
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=OldUsedPerk)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
OldUsedPerk = PendingPerk;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
OldPerkPoints = -1;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (StatsList.ItemComponents.Length!=PendingPerk.PerkStats.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (StatsList.ItemComponents.Length<PendingPerk.PerkStats.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=StatsList.ItemComponents.Length; i<PendingPerk.PerkStats.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (i>=StatBuyers.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
StatBuyers[StatBuyers.Length] = UIR_PerkStat(StatsList.AddListComponent(class'UIR_PerkStat'));
|
|
|
|
StatBuyers[i].StatIndex = i;
|
|
|
|
StatBuyers[i].InitMenu();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StatsList.ItemComponents.Length = i+1;
|
|
|
|
StatsList.ItemComponents[i] = StatBuyers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (StatsList.ItemComponents.Length>PendingPerk.PerkStats.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=PendingPerk.PerkStats.Length; i<StatsList.ItemComponents.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
StatBuyers[i].CloseMenu();
|
|
|
|
StatsList.ItemComponents.Length = PendingPerk.PerkStats.Length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OldPerkPoints = PendingPerk.CurrentSP;
|
2021-01-17 21:55:45 +00:00
|
|
|
PerkLabel.SetText(Level$PendingPerk.GetLevelString()@PendingPerk.PerkName@"("$Points@PendingPerk.CurrentSP$")");
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<StatsList.ItemComponents.Length; ++i) // Just make sure perk stays the same.
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
StatBuyers[i].SetActivePerk(PendingPerk);
|
|
|
|
StatBuyers[i].CheckBuyLimit();
|
|
|
|
}
|
|
|
|
B_Prestige.SetDisabled(!PendingPerk.CanPrestige());
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk.MinLevelForPrestige<0)
|
2020-08-12 15:53:32 +00:00
|
|
|
B_Prestige.ChangeToolTip(PrestigeButtonDisabledToolTip);
|
|
|
|
else B_Prestige.ChangeToolTip(PrestigeButtonToolTip$" "$PendingPerk.MinLevelForPrestige);
|
2017-10-20 02:00:49 +00:00
|
|
|
UpdateTraits();
|
|
|
|
}
|
|
|
|
else // Empty out if needed.
|
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<StatsList.ItemComponents.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
StatBuyers[i].CloseMenu();
|
|
|
|
StatsList.ItemComponents.Length = 0;
|
2020-08-12 15:53:32 +00:00
|
|
|
PerkLabel.SetText(NoPerkSelected);
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (PendingPerk!=None && OldPerkPoints!=PendingPerk.CurrentSP)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
B_Prestige.SetDisabled(!PendingPerk.CanPrestige());
|
|
|
|
|
|
|
|
OldPerkPoints = PendingPerk.CurrentSP;
|
2021-01-17 21:55:45 +00:00
|
|
|
PerkLabel.SetText(Level$PendingPerk.GetLevelString()@PendingPerk.PerkName@"("$Points@PendingPerk.CurrentSP$")");
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<StatsList.ItemComponents.Length; ++i) // Just make sure perk stays the same.
|
2017-10-20 02:00:49 +00:00
|
|
|
StatBuyers[i].CheckBuyLimit();
|
|
|
|
|
|
|
|
// Update traits list.
|
|
|
|
UpdateTraits();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final function UpdateTraits()
|
|
|
|
{
|
|
|
|
local array< class<Ext_TGroupBase> > CatList;
|
|
|
|
local class<Ext_TGroupBase> N;
|
2021-01-17 21:55:45 +00:00
|
|
|
local Ext_TGroupBase N_obj;
|
2017-10-20 02:00:49 +00:00
|
|
|
local int i,j;
|
|
|
|
local class<Ext_TraitBase> TC;
|
|
|
|
local string S;
|
|
|
|
|
|
|
|
// A bit hacky to delete and refill list again, but at least it works...
|
|
|
|
TraitsList.EmptyList();
|
|
|
|
TraitsList.ToolTip.Length = 0;
|
|
|
|
|
|
|
|
CatList.AddItem(None);
|
|
|
|
|
|
|
|
// First gather all the categories available.
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<PendingPerk.PerkTraits.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
N = PendingPerk.PerkTraits[i].TraitType.Default.TraitGroup;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (N!=None && CatList.Find(N)==-1)
|
2017-10-20 02:00:49 +00:00
|
|
|
CatList.AddItem(N);
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
for (j=0; j<CatList.Length; ++j)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
N = CatList[j];
|
2020-11-28 20:12:58 +00:00
|
|
|
if (j>0)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2021-01-17 21:55:45 +00:00
|
|
|
N_obj = new N;
|
|
|
|
TraitsList.AddLine("--"$N_obj.GetUIInfo(PendingPerk),-1);
|
|
|
|
TraitsList.ToolTip.AddItem(N_obj.GetUIDesc());
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<PendingPerk.PerkTraits.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
TC = PendingPerk.PerkTraits[i].TraitType;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (TC.Default.TraitGroup==N)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk.PerkTraits[i].CurrentLevel>=TC.Default.NumLevels)
|
2020-08-12 15:53:32 +00:00
|
|
|
S = MaxStr$"\n"$NotAviable;
|
2017-10-20 02:00:49 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
S = PendingPerk.PerkTraits[i].CurrentLevel$"/"$TC.Default.NumLevels$"\n";
|
2020-11-28 20:12:58 +00:00
|
|
|
if (TC.Static.MeetsRequirements(PendingPerk.PerkTraits[i].CurrentLevel,PendingPerk))
|
2017-10-20 02:00:49 +00:00
|
|
|
S $= string(TC.Static.GetTraitCost(PendingPerk.PerkTraits[i].CurrentLevel));
|
2020-08-12 15:53:32 +00:00
|
|
|
else S $= NotAviable;
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
|
|
|
TraitsList.AddLine(TC.Default.TraitName$"\n"$S,i);
|
|
|
|
TraitsList.ToolTip.AddItem(TC.Static.GetTooltipInfo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function DrawPerkInfo(Canvas C, int Index, float YOffset, float Height, float Width, bool bFocus)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local Ext_PerkBase P;
|
|
|
|
local float Sc;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (CurrentManager==None || Index>=CurrentManager.UserPerks.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
return;
|
|
|
|
P = CurrentManager.UserPerks[Index];
|
2020-11-28 20:12:58 +00:00
|
|
|
if (P.Class==ExtPlayerReplicationInfo(GetPlayer().PlayerReplicationInfo).ECurrentPerk)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk==None)
|
2017-10-20 02:00:49 +00:00
|
|
|
PendingPerk = P;
|
|
|
|
C.SetDrawColor(164,164,32);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (P==PendingPerk)
|
2017-10-20 02:00:49 +00:00
|
|
|
C.SetDrawColor(164,86,32);
|
|
|
|
else C.SetDrawColor(32,32,128);
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bFocus)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
C.DrawColor.R+=15;
|
|
|
|
C.DrawColor.G+=15;
|
|
|
|
C.DrawColor.B+=15;
|
|
|
|
}
|
|
|
|
C.SetPos(0,YOffset);
|
|
|
|
Owner.CurrentStyle.DrawWhiteBox(Width,Height);
|
|
|
|
|
|
|
|
C.SetDrawColor(240,240,240);
|
|
|
|
C.SetPos(2,YOffset);
|
|
|
|
C.DrawRect(Height,Height,P.PerkIcon);
|
|
|
|
|
|
|
|
C.SetPos(6+Height,YOffset);
|
|
|
|
C.Font = Owner.CurrentStyle.PickFont(Max(Owner.CurrentStyle.DefaultFontSize-1,0),Sc);
|
|
|
|
C.DrawText(P.PerkName,,Sc,Sc);
|
|
|
|
|
|
|
|
C.SetPos(6+Height,YOffset+Height*0.5);
|
2021-01-17 21:55:45 +00:00
|
|
|
C.DrawText("Lv "$P.GetLevelString()$" ("$P.CurrentEXP$"/"$P.NextLevelEXP$" XP)",,Sc,Sc); // TODO: Localization
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function SwitchedPerk(int Index, bool bRight, int MouseX, int MouseY)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (CurrentManager==None || Index>=CurrentManager.UserPerks.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
PendingPerk = CurrentManager.UserPerks[Index];
|
|
|
|
ExtPlayerController(GetPlayer()).SwitchToPerk(PendingPerk.Class);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ShowTraitInfo(KFGUI_ListItem Item, int Row, bool bRight, bool bDblClick)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local UIR_TraitInfoPopup T;
|
2020-11-28 20:12:58 +00:00
|
|
|
if ((bRight || bDblClick) && Item.Value>=0)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
T = UIR_TraitInfoPopup(Owner.OpenMenu(class'UIR_TraitInfoPopup'));
|
|
|
|
T.ShowTraitInfo(Item.Value,PendingPerk);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ButtonClicked(KFGUI_Button Sender)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local KFGUI_Page T;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
switch (Sender.ID)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
case 'Reset':
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
T = Owner.OpenMenu(class'UI_ResetWarning');
|
|
|
|
UI_ResetWarning(T).SetupTo(PendingPerk);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Unload':
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
T = Owner.OpenMenu(class'UI_UnloadInfo');
|
|
|
|
UI_UnloadInfo(T).SetupTo(PendingPerk.Class);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'Prestige':
|
2020-11-28 20:12:58 +00:00
|
|
|
if (PendingPerk!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
T = Owner.OpenMenu(class'UI_PrestigeNote');
|
|
|
|
UI_PrestigeNote(T).SetupTo(PendingPerk);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
Begin Object Class=KFGUI_List Name=PerksList
|
|
|
|
ID="Perks"
|
|
|
|
XPosition=0
|
|
|
|
YPosition=0
|
|
|
|
XSize=0.25
|
|
|
|
YSize=1
|
|
|
|
ListItemsPerPage=12
|
|
|
|
bClickable=true
|
|
|
|
OnDrawItem=DrawPerkInfo
|
|
|
|
OnClickedItem=SwitchedPerk
|
|
|
|
End Object
|
|
|
|
|
|
|
|
Begin Object Class=KFGUI_ComponentList Name=PerkStats
|
|
|
|
ID="Stats"
|
|
|
|
XPosition=0.25
|
|
|
|
YPosition=0.12
|
|
|
|
XSize=0.375
|
|
|
|
YSize=0.88
|
|
|
|
ListItemsPerPage=16
|
|
|
|
End Object
|
|
|
|
|
|
|
|
Begin Object Class=UIR_PerkTraitList Name=PerkTraits
|
|
|
|
ID="Traits"
|
|
|
|
XPosition=0.625
|
|
|
|
YPosition=0.12
|
|
|
|
XSize=0.375
|
|
|
|
YSize=0.88
|
|
|
|
OnSelectedRow=ShowTraitInfo
|
|
|
|
End Object
|
|
|
|
|
|
|
|
Begin Object Class=KFGUI_TextLable Name=CurPerkLabel
|
|
|
|
ID="Info"
|
|
|
|
XPosition=0.4
|
|
|
|
YPosition=0
|
|
|
|
XSize=0.58
|
|
|
|
YSize=0.12
|
|
|
|
AlignX=1
|
|
|
|
AlignY=1
|
|
|
|
TextFontInfo=(bClipText=true)
|
|
|
|
End Object
|
|
|
|
|
|
|
|
Begin Object Class=KFGUI_Button Name=ResetPerkButton
|
|
|
|
ID="Reset"
|
|
|
|
XPosition=0.25
|
|
|
|
YPosition=0.025
|
|
|
|
XSize=0.074
|
2017-10-20 07:02:53 +00:00
|
|
|
YSize=0.045
|
2017-10-20 02:00:49 +00:00
|
|
|
OnClickLeft=ButtonClicked
|
|
|
|
OnClickRight=ButtonClicked
|
|
|
|
ExtravDir=1
|
|
|
|
End Object
|
|
|
|
Begin Object Class=KFGUI_Button Name=UnloadPerkButton
|
|
|
|
ID="Unload"
|
|
|
|
XPosition=0.325
|
|
|
|
YPosition=0.025
|
|
|
|
XSize=0.074
|
2017-10-20 07:02:53 +00:00
|
|
|
YSize=0.045
|
|
|
|
ExtravDir=1
|
2017-10-20 02:00:49 +00:00
|
|
|
OnClickLeft=ButtonClicked
|
|
|
|
OnClickRight=ButtonClicked
|
|
|
|
End Object
|
|
|
|
Begin Object Class=KFGUI_Button Name=PrestigePerkButton
|
|
|
|
ID="Prestige"
|
|
|
|
XPosition=0.4
|
|
|
|
YPosition=0.025
|
|
|
|
XSize=0.074
|
2017-10-20 07:02:53 +00:00
|
|
|
YSize=0.045
|
2017-10-20 02:00:49 +00:00
|
|
|
OnClickLeft=ButtonClicked
|
|
|
|
OnClickRight=ButtonClicked
|
|
|
|
bDisabled=true
|
|
|
|
End Object
|
|
|
|
|
|
|
|
Components.Add(PerksList)
|
|
|
|
Components.Add(PerkStats)
|
|
|
|
Components.Add(PerkTraits)
|
|
|
|
Components.Add(CurPerkLabel)
|
|
|
|
Components.Add(ResetPerkButton)
|
|
|
|
Components.Add(UnloadPerkButton)
|
|
|
|
Components.Add(PrestigePerkButton)
|
|
|
|
}
|