2017-10-20 02:00:49 +00:00
|
|
|
Class xUI_MapVote extends KFGUI_FloatingWindow;
|
|
|
|
|
|
|
|
var xVotingReplication RepInfo;
|
|
|
|
var KFGUI_ColumnList CurrentVotes,MapList;
|
|
|
|
var KFGUI_ComboBox GameModeCombo;
|
2020-08-12 15:14:21 +00:00
|
|
|
var KFGUI_RightClickMenu MapRClicker;
|
|
|
|
var KFGUI_Button CloseButton;
|
2017-10-20 02:00:49 +00:00
|
|
|
var int SelectedMapIndex;
|
|
|
|
var editinline export KFGUI_RightClickMenu MapRightClick;
|
|
|
|
var bool bFirstTime;
|
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
var localized string CloseButtonText;
|
|
|
|
var localized string CloseButtonToolTip;
|
|
|
|
var localized string ColumnMapName;
|
|
|
|
var localized string ColumnSequence;
|
|
|
|
var localized string ColumnPlayCount;
|
|
|
|
var localized string ColumnRating;
|
|
|
|
var localized string ColumnGame;
|
|
|
|
var localized string ColumnNumVotes;
|
2020-08-12 15:21:45 +00:00
|
|
|
var localized string Title;
|
2020-08-12 15:14:21 +00:00
|
|
|
|
|
|
|
function FColumnItem newFColumnItem(string Text, float Width)
|
|
|
|
{
|
|
|
|
local FColumnItem newItem;
|
|
|
|
newItem.Text=Text;
|
|
|
|
newItem.Width=Width;
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
function FRowItem newFRowItem(string Text, bool isDisabled)
|
|
|
|
{
|
|
|
|
local FRowItem newItem;
|
|
|
|
newItem.Text=Text;
|
|
|
|
newItem.bDisabled=isDisabled;
|
|
|
|
return newItem;
|
|
|
|
}
|
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function InitMenu()
|
|
|
|
{
|
|
|
|
Super.InitMenu();
|
|
|
|
CurrentVotes = KFGUI_ColumnList(FindComponentID('Votes'));
|
|
|
|
MapList = KFGUI_ColumnList(FindComponentID('Maps'));
|
|
|
|
GameModeCombo = KFGUI_ComboBox(FindComponentID('Filter'));
|
2020-08-12 15:14:21 +00:00
|
|
|
MapRClicker = KFGUI_RightClickMenu(FindComponentID('RClick'));
|
|
|
|
CloseButton = KFGUI_Button(FindComponentID('Close'));
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
// TODO: i18n this
|
|
|
|
// I don't know why it's not working
|
|
|
|
// MapRClicker.ItemRows.AddItem(newFRowItem("Vote this map", false));
|
|
|
|
// MapRClicker.ItemRows.AddItem(newFRowItem("Admin force this map", true));
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
// And this too:
|
|
|
|
// GameModeCombo.LableString="Game mode:";
|
|
|
|
// GameModeCombo.ToolTip="Select game mode to vote for.";
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
CloseButton.ButtonText=CloseButtonText;
|
|
|
|
CloseButton.ToolTip=CloseButtonToolTip;
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
MapList.Columns.AddItem(newFColumnItem(ColumnMapName,0.5));
|
|
|
|
MapList.Columns.AddItem(newFColumnItem(ColumnSequence,0.18));
|
|
|
|
MapList.Columns.AddItem(newFColumnItem(ColumnPlayCount,0.18));
|
|
|
|
MapList.Columns.AddItem(newFColumnItem(ColumnRating,0.14));
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:14:21 +00:00
|
|
|
CurrentVotes.Columns.AddItem(newFColumnItem(ColumnGame,0.2));
|
|
|
|
CurrentVotes.Columns.AddItem(newFColumnItem(ColumnMapName,0.5));
|
|
|
|
CurrentVotes.Columns.AddItem(newFColumnItem(ColumnNumVotes,0.15));
|
|
|
|
CurrentVotes.Columns.AddItem(newFColumnItem(ColumnRating,0.15));
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-08-12 15:21:45 +00:00
|
|
|
WindowTitle=Title;
|
2017-10-20 02:00:49 +00:00
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function CloseMenu()
|
|
|
|
{
|
|
|
|
Super.CloseMenu();
|
|
|
|
RepInfo = None;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function InitMapvote(xVotingReplication R)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
RepInfo = R;
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
function DrawMenu()
|
|
|
|
{
|
|
|
|
Super.DrawMenu();
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (RepInfo!=None && RepInfo.bListDirty)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
RepInfo.bListDirty = false;
|
|
|
|
UpdateList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final function UpdateList()
|
|
|
|
{
|
|
|
|
local int i,g,m,Sel;
|
|
|
|
local float V;
|
|
|
|
local KFGUI_ListItem Item,SItem;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (GameModeCombo.Values.Length!=RepInfo.GameModes.Length)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
GameModeCombo.Values.Length = RepInfo.GameModes.Length;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<GameModeCombo.Values.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
GameModeCombo.Values[i] = RepInfo.GameModes[i].GameName;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (!bFirstTime)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
bFirstTime = true;
|
|
|
|
GameModeCombo.SelectedIndex = RepInfo.ClientCurrentGame;
|
|
|
|
}
|
|
|
|
ChangeToMaplist(GameModeCombo);
|
|
|
|
}
|
|
|
|
Item = CurrentVotes.GetFromIndex(CurrentVotes.SelectedRowIndex);
|
|
|
|
Sel = (Item!=None ? Item.Value : -1);
|
|
|
|
CurrentVotes.EmptyList();
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<RepInfo.ActiveVotes.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
g = RepInfo.ActiveVotes[i].GameIndex;
|
|
|
|
m = RepInfo.ActiveVotes[i].MapIndex;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (RepInfo.Maps[m].NumPlays==0)
|
2017-10-20 02:00:49 +00:00
|
|
|
Item = CurrentVotes.AddLine(RepInfo.GameModes[g].GameName$"\n"$RepInfo.Maps[m].MapTitle$"\n"$RepInfo.ActiveVotes[i].NumVotes$"\n** NEW **",m,
|
|
|
|
RepInfo.GameModes[g].GameName$"\n"$RepInfo.Maps[m].MapTitle$"\n"$MakeSortStr(RepInfo.ActiveVotes[i].NumVotes)$"\n"$MakeSortStr(0));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
V = (float(RepInfo.Maps[m].UpVotes) / float(RepInfo.Maps[m].UpVotes+RepInfo.Maps[m].DownVotes)) * 100.f;
|
|
|
|
Item = CurrentVotes.AddLine(RepInfo.GameModes[g].GameName$"\n"$RepInfo.Maps[m].MapTitle$"\n"$RepInfo.ActiveVotes[i].NumVotes$"\n"$int(V)$"% ("$RepInfo.Maps[m].UpVotes$"/"$(RepInfo.Maps[m].UpVotes+RepInfo.Maps[m].DownVotes)$")",m,
|
|
|
|
RepInfo.GameModes[g].GameName$"\n"$RepInfo.Maps[m].MapTitle$"\n"$MakeSortStr(RepInfo.ActiveVotes[i].NumVotes)$"\n"$MakeSortStr(int(V*100.f)));
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
if (Sel>=0 && Sel==m)
|
2017-10-20 02:00:49 +00:00
|
|
|
SItem = Item;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep same row selected if possible.
|
|
|
|
CurrentVotes.SelectedRowIndex = (SItem!=None ? SItem.Index : -1);
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ChangeToMaplist(KFGUI_ComboBox Sender)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
local int i,g;
|
|
|
|
local float V;
|
|
|
|
|
2020-11-28 20:12:58 +00:00
|
|
|
if (RepInfo!=None)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
MapList.EmptyList();
|
|
|
|
g = Sender.SelectedIndex;
|
2020-11-28 20:12:58 +00:00
|
|
|
for (i=0; i<RepInfo.Maps.Length; ++i)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (!BelongsToPrefix(RepInfo.Maps[i].MapName,RepInfo.GameModes[g].Prefix))
|
2017-10-20 02:00:49 +00:00
|
|
|
continue;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (RepInfo.Maps[i].NumPlays==0)
|
2017-10-20 02:00:49 +00:00
|
|
|
MapList.AddLine(RepInfo.Maps[i].MapTitle$"\n"$RepInfo.Maps[i].Sequence$"\n"$RepInfo.Maps[i].NumPlays$"\n** NEW **",i,
|
|
|
|
RepInfo.Maps[i].MapTitle$"\n"$MakeSortStr(RepInfo.Maps[i].Sequence)$"\n"$MakeSortStr(RepInfo.Maps[i].NumPlays)$"\n"$MakeSortStr(0));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
V = RepInfo.Maps[i].UpVotes+RepInfo.Maps[i].DownVotes;
|
2020-11-28 20:12:58 +00:00
|
|
|
if (V==0)
|
2017-10-20 02:00:49 +00:00
|
|
|
V = 100.f;
|
|
|
|
else V = (float(RepInfo.Maps[i].UpVotes) / V) * 100.f;
|
|
|
|
MapList.AddLine(RepInfo.Maps[i].MapTitle$"\n"$RepInfo.Maps[i].Sequence$"\n"$RepInfo.Maps[i].NumPlays$"\n"$int(V)$"% ("$RepInfo.Maps[i].UpVotes$"/"$(RepInfo.Maps[i].UpVotes+RepInfo.Maps[i].DownVotes)$")",i,
|
|
|
|
RepInfo.Maps[i].MapTitle$"\n"$MakeSortStr(RepInfo.Maps[i].Sequence)$"\n"$MakeSortStr(RepInfo.Maps[i].NumPlays)$"\n"$MakeSortStr(int(V*100.f)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
static final function bool BelongsToPrefix(string MN, string Prefix)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
return (Prefix=="" || Left(MN,Len(Prefix))~=Prefix);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
switch (Sender.ID)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
case 'Close':
|
|
|
|
DoClose();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function ClickedRow(int RowNum)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (RowNum==0) // Vote this map.
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
RepInfo.ServerCastVote(GameModeCombo.SelectedIndex,SelectedMapIndex,false);
|
|
|
|
}
|
|
|
|
else // Admin force this map.
|
|
|
|
{
|
|
|
|
RepInfo.ServerCastVote(GameModeCombo.SelectedIndex,SelectedMapIndex,true);
|
|
|
|
}
|
|
|
|
}
|
2020-11-28 21:54:57 +00:00
|
|
|
|
2020-11-28 20:04:55 +00:00
|
|
|
function SelectedVoteRow(KFGUI_ListItem Item, int Row, bool bRight, bool bDblClick)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
2020-11-28 20:12:58 +00:00
|
|
|
if (bRight)
|
2017-10-20 02:00:49 +00:00
|
|
|
{
|
|
|
|
SelectedMapIndex = Item.Value;
|
|
|
|
MapRightClick.ItemRows[1].bDisabled = (!GetPlayer().PlayerReplicationInfo.bAdmin);
|
|
|
|
MapRightClick.OpenMenu(Self);
|
|
|
|
}
|
2020-11-28 20:12:58 +00:00
|
|
|
else if (bDblClick)
|
2017-10-20 02:00:49 +00:00
|
|
|
RepInfo.ServerCastVote(GameModeCombo.SelectedIndex,Item.Value,false);
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultproperties
|
|
|
|
{
|
|
|
|
XPosition=0.2
|
|
|
|
YPosition=0.1
|
|
|
|
XSize=0.6
|
|
|
|
YSize=0.8
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
Begin Object Class=KFGUI_ColumnList Name=CurrentVotesList
|
|
|
|
XPosition=0.015
|
|
|
|
YPosition=0.075
|
|
|
|
XSize=0.98
|
|
|
|
YSize=0.25
|
|
|
|
ID="Votes"
|
|
|
|
OnSelectedRow=SelectedVoteRow
|
|
|
|
bShouldSortList=true
|
|
|
|
bLastSortedReverse=true
|
|
|
|
LastSortedColumn=2
|
|
|
|
End Object
|
|
|
|
Begin Object Class=KFGUI_ColumnList Name=MapList
|
|
|
|
XPosition=0.015
|
|
|
|
YPosition=0.375
|
|
|
|
XSize=0.98
|
|
|
|
YSize=0.56
|
|
|
|
ID="Maps"
|
|
|
|
OnSelectedRow=SelectedVoteRow
|
|
|
|
End Object
|
|
|
|
Begin Object Class=KFGUI_ComboBox Name=GameModeFilter
|
|
|
|
XPosition=0.1
|
|
|
|
YPosition=0.325
|
|
|
|
XSize=0.6
|
|
|
|
YSize=0.05
|
|
|
|
OnComboChanged=ChangeToMaplist
|
|
|
|
ID="Filter"
|
|
|
|
LableString="Game mode:"
|
|
|
|
ToolTip="Select game mode to vote for."
|
|
|
|
End Object
|
|
|
|
Begin Object Class=KFGUI_Button Name=CloseButton
|
|
|
|
XPosition=0.85
|
|
|
|
YPosition=0.94
|
|
|
|
XSize=0.1
|
|
|
|
YSize=0.05
|
|
|
|
ID="Close"
|
|
|
|
OnClickLeft=ButtonClicked
|
|
|
|
OnClickRight=ButtonClicked
|
|
|
|
End Object
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
Components.Add(CurrentVotesList)
|
|
|
|
Components.Add(MapList)
|
|
|
|
Components.Add(GameModeFilter)
|
|
|
|
Components.Add(CloseButton)
|
2023-05-14 02:49:12 +00:00
|
|
|
|
2017-10-20 02:00:49 +00:00
|
|
|
Begin Object Class=KFGUI_RightClickMenu Name=MapRClicker
|
2020-08-12 15:14:21 +00:00
|
|
|
ID="RClick"
|
2017-10-20 02:00:49 +00:00
|
|
|
ItemRows(0)=(Text="Vote this map")
|
|
|
|
ItemRows(1)=(Text="Admin force this map",bDisabled=true)
|
|
|
|
OnSelectedItem=ClickedRow
|
|
|
|
End Object
|
|
|
|
MapRightClick=MapRClicker
|
2023-05-14 02:49:12 +00:00
|
|
|
}
|