diff --git a/Classes/VS_ClientSettings.uc b/Classes/VS_ClientSettings.uc index d5eefee..cc74f2d 100644 --- a/Classes/VS_ClientSettings.uc +++ b/Classes/VS_ClientSettings.uc @@ -8,7 +8,14 @@ enum ETheme { TH_Black }; +enum EMapListSort { + MLS_Name, + MLS_Recency, + MLS_PlayCount +}; + var config ETheme Theme; +var config EMapListSort MapListSort; var config float MenuX; var config float MenuY; @@ -25,8 +32,18 @@ static final function ETheme IntToTheme(int A) { return default.Theme; } +static final function EMapListSort IntToMapListSort(int A) { + switch(A) { + case 0: return MLS_Name; + case 1: return MLS_Recency; + case 2: return MLS_PlayCount; + } + return default.MapListSort; +} + defaultproperties { Theme=TH_Bright + MapListSort=MLS_Name; MenuX=-1.0 MenuY=-1.0 diff --git a/Classes/VS_UI_ClientSettingsPage.uc b/Classes/VS_UI_ClientSettingsPage.uc index 2e07160..5a4b6ef 100644 --- a/Classes/VS_UI_ClientSettingsPage.uc +++ b/Classes/VS_UI_ClientSettingsPage.uc @@ -8,6 +8,12 @@ var localized string ThemeBright; var localized string ThemeDark; var localized string ThemeBlack; +var VS_UI_ComboControl Cmb_MapListSort; +var localized string MapListSortText; +var localized string MapListSortName; +var localized string MapListSortRecency; +var localized string MapListSortPlayCount; + function Created() { super.Created(); @@ -17,6 +23,13 @@ function Created() { Cmb_Theme.AddItem(ThemeDark); Cmb_Theme.AddItem(ThemeBlack); Cmb_Theme.SetEditable(false); + + Cmb_MapListSort = VS_UI_ComboControl(CreateControl(class'VS_UI_ComboControl', 8, 28, 188, 16)); + Cmb_MapListSort.SetText(MapListSortText); + Cmb_MapListSort.AddItem(MapListSortName); + Cmb_MapListSort.AddItem(MapListSortRecency); + Cmb_MapListSort.AddItem(MapListSortPlayCount); + Cmb_MapListSort.SetEditable(false); } function LoadSettings(VS_PlayerChannel C) { @@ -25,16 +38,19 @@ function LoadSettings(VS_PlayerChannel C) { Settings = C.Settings; Cmb_Theme.SetSelectedIndex(Settings.Theme); + Cmb_MapListSort.SetSelectedIndex(Settings.MapListSort); } function SaveSettings() { Settings.Theme = Settings.IntToTheme(Cmb_Theme.GetSelectedIndex()); + Settings.MapListSort = Settings.IntToMapListSort(Cmb_MapListSort.GetSelectedIndex()); Settings.SaveConfig(); } function ApplyTheme() { Cmb_Theme.Theme = Theme; + Cmb_MapListSort.Theme = Theme; } defaultproperties { @@ -42,4 +58,9 @@ defaultproperties { ThemeBright="Bright" ThemeDark="Dark" ThemeBlack="Black" + + MapListSortText="Sort Map List By" + MapListSortName="Name" + MapListSortRecency="Recency" + MapListSortPlayCount="Play Count" } diff --git a/Classes/VS_UI_MapListItem.uc b/Classes/VS_UI_MapListItem.uc index 5f496f8..a077632 100644 --- a/Classes/VS_UI_MapListItem.uc +++ b/Classes/VS_UI_MapListItem.uc @@ -3,8 +3,32 @@ class VS_UI_MapListItem extends VS_UI_ListItem; var VS_Map MapRef; var bool bFilteredOut; +// Sentinel Only +var byte SortMode; + function int Compare(UWindowList T, UWindowList B) { - if (Caps(VS_UI_MapListItem(T).MapRef.MapName) < Caps(VS_UI_MapListItem(B).MapRef.MapName)) + local VS_Map M1, M2; + + M1 = VS_UI_MapListItem(T).MapRef; + M2 = VS_UI_MapListItem(B).MapRef; + + switch(VS_UI_MapListItem(Sentinel).SortMode) { + case 1: + if (M1.Sequence > M2.Sequence) + return -1; + else if (M1.Sequence < M2.Sequence) + return 1; + break; + + case 2: + if (M1.PlayCount > M2.PlayCount) + return -1; + else if (M1.PlayCount < M2.PlayCount) + return 1; + break; + } + + if (Caps(M1.MapName) < Caps(M2.MapName)) return -1; return 1; diff --git a/Classes/VS_UI_VoteClientWindow.uc b/Classes/VS_UI_VoteClientWindow.uc index 8899aae..1d90037 100644 --- a/Classes/VS_UI_VoteClientWindow.uc +++ b/Classes/VS_UI_VoteClientWindow.uc @@ -5,6 +5,7 @@ class VS_UI_VoteClientWindow extends UWindowDialogClientWindow; var VS_PlayerChannel Channel; var VS_ClientSettings Settings; var int ActiveTheme; +var byte PreviousMapListSort; var VS_UI_CategoryTabItem ActiveCategory; var VS_Preset ActivePreset; @@ -112,6 +113,8 @@ function BeforePaint(Canvas C, float MouseX, float MouseY) { UpdateCandidateList(Info); UpdatePlayerList(Info); + PreviousMapListSort = Settings.MapListSort; + CategoryTabs.WinWidth = WinWidth; if (ChatEdit.EditBox.bControlDown) @@ -231,7 +234,11 @@ function UpdateActivePreset(VS_Info Info) { local VS_Map M; local bool bEnable; - if (Presets.SelectedPreset != ActivePreset || bWasAdmin != bAdmin || NumPlayers != PreviousNumPlayers) { + if (Presets.SelectedPreset != ActivePreset || + bWasAdmin != bAdmin || + PreviousNumPlayers != NumPlayers || + PreviousMapListSort != Settings.MapListSort + ) { ActivePreset = Presets.SelectedPreset; MapListBox.Items.Clear(); @@ -246,6 +253,9 @@ function UpdateActivePreset(VS_Info Info) { bEnable = true; MapListBox.AppendMap(M, bEnable); } + + VS_UI_MapListItem(MapListBox.Items).SortMode = Settings.MapListSort; + MapListBox.Items.Sort(); } } diff --git a/Docs/ClientSettings.png b/Docs/ClientSettings.png index 845c942..3c4141a 100644 Binary files a/Docs/ClientSettings.png and b/Docs/ClientSettings.png differ diff --git a/System/VoteSys.int b/System/VoteSys.int index ccd4d37..c19f164 100644 --- a/System/VoteSys.int +++ b/System/VoteSys.int @@ -93,6 +93,10 @@ ThemeText="Theme" ThemeBright="Bright" ThemeDark="Dark" ThemeBlack="Black" +MapListSortText="Sort Map List By" +MapListSortName="Name" +MapListSortRecency="Recency" +MapListSortPlayCount="Play Count" [VS_UI_SettingsWindow] WindowTitle="VoteSys Settings"