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

305 lines
7.7 KiB
Ucode
Raw Normal View History

2017-10-20 02:00:49 +00:00
Class UIP_PlayerSpecs extends KFGUI_MultiComponent;
struct FPageExtraInfo
{
var array<UniqueNetId> UserID;
};
2020-09-01 06:25:21 +00:00
2017-10-20 02:00:49 +00:00
var FPageExtraInfo ExtraInfo[3];
var KFGUI_ColumnList PlayersList,TopPlayers[3];
var KFGUI_SwitchComponent MultiPager;
var int CurrentPageIndex;
var byte CurrentPageStatus[3];
var KFGUI_Button PreviousButton;
var bool bDownloadingPage;
2020-09-01 06:25:21 +00:00
var KFGUI_Button TopPlaytimeButton;
var KFGUI_Button TopKillsButton;
var KFGUI_Button TopExpButton;
var localized string ShowStatsButtonText;
var localized string ShowStatsButtonToolTip;
var localized string TopPlaytimeButtonText;
var localized string TopPlaytimeButtonToolTip;
var localized string TopKillsButtonText;
var localized string TopKillsButtonToolTip;
var localized string TopExpButtonText;
var localized string TopExpButtonToolTip;
var localized string PlayerColumnText;
var localized string TotalKillsColumnText;
var localized string TotalExpColumnText;
var localized string TotalPlaytimeColumnText;
function FColumnItem NewFColumnItem(string Text, float Width)
{
local FColumnItem NewItem;
NewItem.Text = Text;
NewItem.Width = Width;
return NewItem;
}
2017-10-20 02:00:49 +00:00
function InitMenu()
{
PreviousButton = KFGUI_Button(FindComponentID('Init'));
PreviousButton.bIsHighlighted = true;
PlayersList = KFGUI_ColumnList(FindComponentID('Players'));
TopPlayers[0] = KFGUI_ColumnList(FindComponentID('PlayTimes'));
TopPlayers[1] = KFGUI_ColumnList(FindComponentID('Kills'));
TopPlayers[2] = KFGUI_ColumnList(FindComponentID('EXP'));
MultiPager = KFGUI_SwitchComponent(FindComponentID('Pager'));
2020-09-01 06:25:21 +00:00
2020-09-06 17:05:05 +00:00
TopPlaytimeButton=KFGUI_Button(FindComponentID('BPlaytime'));
TopKillsButton=KFGUI_Button(FindComponentID('BKills'));
TopExpButton=KFGUI_Button(FindComponentID('BExp'));
2020-09-01 06:25:21 +00:00
PreviousButton.ButtonText=ShowStatsButtonText;
PreviousButton.Tooltip=ShowStatsButtonToolTip;
TopPlaytimeButton.ButtonText=TopPlaytimeButtonText;
TopPlaytimeButton.Tooltip=TopPlaytimeButtonToolTip;
TopKillsButton.ButtonText=TopKillsButtonText;
TopKillsButton.Tooltip=TopKillsButtonToolTip;
TopExpButton.ButtonText=TopExpButtonText;
TopExpButton.Tooltip=TopExpButtonToolTip;
PlayersList.Columns.AddItem(NewFColumnItem(PlayerColumnText,0.55));
PlayersList.Columns.AddItem(NewFColumnItem(TotalKillsColumnText,0.15));
PlayersList.Columns.AddItem(NewFColumnItem(TotalExpColumnText,0.15));
PlayersList.Columns.AddItem(NewFColumnItem(TotalPlaytimeColumnText,0.15));
TopPlayers[0].Columns.AddItem(NewFColumnItem("#",0.05));
TopPlayers[0].Columns.AddItem(NewFColumnItem(PlayerColumnText,0.7));
TopPlayers[0].Columns.AddItem(NewFColumnItem(TotalPlaytimeColumnText,0.25));
TopPlayers[1].Columns.AddItem(NewFColumnItem("#",0.05));
TopPlayers[1].Columns.AddItem(NewFColumnItem(PlayerColumnText,0.7));
TopPlayers[1].Columns.AddItem(NewFColumnItem(TotalKillsColumnText,0.25));
TopPlayers[2].Columns.AddItem(NewFColumnItem("#",0.05));
TopPlayers[2].Columns.AddItem(NewFColumnItem(PlayerColumnText,0.7));
TopPlayers[2].Columns.AddItem(NewFColumnItem(TotalExpColumnText,0.25));
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(2,true);
Timer();
}
2020-11-28 21:54:57 +00:00
2017-10-20 02:00:49 +00:00
function CloseMenu()
{
Super.CloseMenu();
SetTimer(0,false);
}
2020-11-28 20:04:55 +00:00
function ReceivedStat(byte ListNum, bool bFinal, string N, UniqueNetId UserID, int V)
2017-10-20 02:00:49 +00:00
{
local int i;
2020-11-28 20:12:58 +00:00
if (bFinal)
2017-10-20 02:00:49 +00:00
{
CurrentPageStatus[ListNum] = 1;
bDownloadingPage = false;
}
else
{
i = ExtraInfo[ListNum].UserID.Length;
TopPlayers[ListNum].AddLine((i+1)$"\n"$N$"\n"$(ListNum==0 ? FormatTimeSMH(V) : FormatInteger(V)),i,MakeSortStr(i)$"\n"$N$"\n"$MakeSortStr(V));
ExtraInfo[ListNum].UserID.AddItem(UserID);
}
}
function Timer()
{
2020-11-28 20:12:58 +00:00
if (CurrentPageIndex==0)
2017-10-20 02:00:49 +00:00
UpdatePlayerList(PlayersList,GetPlayer().WorldInfo.GRI);
2020-11-28 20:12:58 +00:00
else if (CurrentPageStatus[CurrentPageIndex-1]==0 && !bDownloadingPage)
2017-10-20 02:00:49 +00:00
{
bDownloadingPage = true;
ExtPlayerController(GetPlayer()).OnClientReceiveStat = ReceivedStat;
ExtPlayerController(GetPlayer()).ServerRequestStats(CurrentPageIndex-1);
}
}
2020-11-28 20:04:55 +00:00
static final function UpdatePlayerList(KFGUI_ColumnList PL, GameReplicationInfo GRI)
2017-10-20 02:00:49 +00:00
{
local int i;
local ExtPlayerReplicationInfo PRI;
local string S;
PL.EmptyList();
2020-11-28 20:12:58 +00:00
if (GRI==None)
2017-10-20 02:00:49 +00:00
return;
2020-11-28 20:12:58 +00:00
for (i=0; i<GRI.PRIArray.Length; ++i)
2017-10-20 02:00:49 +00:00
{
PRI = ExtPlayerReplicationInfo(GRI.PRIArray[i]);
2020-11-28 20:12:58 +00:00
if (PRI==None || PRI.bHiddenUser)
2017-10-20 02:00:49 +00:00
continue;
S = PRI.PlayerName;
2020-11-28 20:12:58 +00:00
if (PRI.ShowAdminName())
2017-10-20 02:00:49 +00:00
S $= " ("$PRI.GetAdminName()$")";
PL.AddLine(S$"\n"$FormatInteger(PRI.RepKills)$"\n"$FormatInteger(PRI.RepEXP)$"\n"$FormatTimeSMH(PRI.RepPlayTime),PRI.PlayerID,S$"\n"$MakeSortStr(PRI.RepKills)$"\n"$MakeSortStr(PRI.RepEXP)$"\n"$MakeSortStr(PRI.RepPlayTime));
}
}
2020-11-28 20:04:55 +00:00
static final function string FormatTimeSMH(float Sec)
2017-10-20 02:00:49 +00:00
{
local int Seconds,Minutes,Hours,Days;
local string S;
Sec = Abs(Sec);
Seconds = int(Sec);
Minutes = Seconds/60;
Seconds-=(Minutes*60);
Hours = Minutes/60;
Minutes-=(Hours*60);
Days = Hours/24;
Hours-=(Days*24);
S = Hours$":"$(Minutes<10 ? "0"$Minutes : string(Minutes))$":"$(Seconds<10 ? "0"$Seconds : string(Seconds));
2020-11-28 20:12:58 +00:00
if (Days>0)
2017-10-20 02:00:49 +00:00
S = Days$"d "$S;
return S;
}
2020-11-28 21:54:57 +00:00
2020-11-28 20:04:55 +00:00
static final function string FormatInteger(int Val)
2017-10-20 02:00:49 +00:00
{
local string S,O;
S = string(Val);
Val = Len(S);
2020-11-28 20:12:58 +00:00
if (Val<=3)
2017-10-20 02:00:49 +00:00
return S;
2020-11-28 20:12:58 +00:00
while (Val>3)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (O=="")
2017-10-20 02:00:49 +00:00
O = Right(S,3);
else O = Right(S,3)$","$O;
S = Left(S,Val-3);
Val-=3;
}
2020-11-28 20:12:58 +00:00
if (Val>0)
2017-10-20 02:00:49 +00:00
O = S$","$O;
return O;
}
2020-11-28 20:04:55 +00:00
function ButtonClicked(KFGUI_Button Sender)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPageIndex==Sender.IDValue)
2017-10-20 02:00:49 +00:00
return;
2020-11-28 20:12:58 +00:00
if (PreviousButton!=None)
2017-10-20 02:00:49 +00:00
PreviousButton.bIsHighlighted = false;
Sender.bIsHighlighted = true;
PreviousButton = Sender;
CurrentPageIndex = Sender.IDValue;
MultiPager.SelectPageIndex(CurrentPageIndex);
Timer();
}
2020-11-28 20:04:55 +00:00
function SelectedRow(KFGUI_ListItem Item, int Row, bool bRight, bool bDblClick)
2017-10-20 02:00:49 +00:00
{
local UniqueNetId Res;
local PlayerReplicationInfo PRI;
2020-11-28 20:12:58 +00:00
if (bRight || bDblClick)
2017-10-20 02:00:49 +00:00
{
2020-11-28 20:12:58 +00:00
if (CurrentPageIndex==0)
2017-10-20 02:00:49 +00:00
{
foreach GetPlayer().WorldInfo.GRI.PRIArray(PRI)
2020-11-28 20:12:58 +00:00
if (PRI.PlayerID==Item.Value)
2017-10-20 02:00:49 +00:00
break;
2020-11-28 20:12:58 +00:00
if (PRI==None || PRI.PlayerID!=Item.Value || PRI.bBot)
2017-10-20 02:00:49 +00:00
return;
Res = PRI.UniqueId;
}
else Res = ExtraInfo[CurrentPageIndex-1].UserID[Item.Value];
OnlineSubsystemSteamworks(class'GameEngine'.static.GetOnlineSubsystem()).ShowProfileUI(0,,Res);
}
}
defaultproperties
{
Begin Object Class=KFGUI_Button Name=B_ShowStats
XPosition=0.05
YPosition=0.05
XSize=0.1
YSize=0.045
IDValue=0
ID="Init"
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Begin Object Class=KFGUI_Button Name=B_ShowTopTime
2020-09-06 17:05:05 +00:00
ID="BPlaytime"
2017-10-20 02:00:49 +00:00
XPosition=0.35
YPosition=0.05
XSize=0.1
YSize=0.045
IDValue=1
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Begin Object Class=KFGUI_Button Name=B_ShowTopKills
2020-09-06 17:05:05 +00:00
ID="BKills"
2017-10-20 02:00:49 +00:00
XPosition=0.6
YPosition=0.05
XSize=0.1
YSize=0.045
IDValue=2
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Begin Object Class=KFGUI_Button Name=B_ShowTopEXP
2020-09-06 17:05:05 +00:00
ID="BExp"
2017-10-20 02:00:49 +00:00
XPosition=0.85
YPosition=0.05
XSize=0.1
YSize=0.045
IDValue=3
OnClickLeft=ButtonClicked
OnClickRight=ButtonClicked
End Object
Components.Add(B_ShowStats)
Components.Add(B_ShowTopTime)
Components.Add(B_ShowTopKills)
Components.Add(B_ShowTopEXP)
Begin Object Class=KFGUI_SwitchComponent Name=MultiPager
XPosition=0.05
YPosition=0.12
XSize=0.9
YSize=0.85
ID="Pager"
Begin Object Class=KFGUI_ColumnList Name=PlayerList
ID="Players"
OnSelectedRow=SelectedRow
End Object
Begin Object Class=KFGUI_ColumnList Name=TopPlaytimes
ID="PlayTimes"
OnSelectedRow=SelectedRow
End Object
Begin Object Class=KFGUI_ColumnList Name=TopKills
ID="Kills"
OnSelectedRow=SelectedRow
End Object
Begin Object Class=KFGUI_ColumnList Name=TopExp
ID="EXP"
OnSelectedRow=SelectedRow
End Object
Components.Add(PlayerList)
Components.Add(TopPlaytimes)
Components.Add(TopKills)
Components.Add(TopExp)
End Object
Components.Add(MultiPager)
}