Skip to content

Commit

Permalink
Implement Settings UI for Map Lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Deaod committed Oct 14, 2024
1 parent 74cc796 commit acfac85
Show file tree
Hide file tree
Showing 15 changed files with 622 additions and 38 deletions.
Binary file added Docs/AdminMapListsSettings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions Docs/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,9 @@ Admin settings are split into three parts: Voting, UI, and Setup. The tab-cards
This tab-card is only visible when logged in as admin. It allows changing preset settings.

![Admin Presets Settings](AdminPresetsSettings.png)

### Map Lists Settings

This tab-card is only visible when logged in as admin. It allows editing map lists, including adding and removing them.

![Admin Map Lists Settings](AdminMapListsSettings.png)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ A new, independent implementation of map vote.
* Automatic management of ServerPackages
* Opt-in ([`bManageServerPackages`](#bmanageserverpackages))
* Before server version 469c [`DefaultPackages`](#defaultpackages) have to be configured correctly
* With 469c no further configuration is necessary
* With 469c or later no further configuration is necessary
* Map repeat limits ([`MinimumMapRepeatDistance`](#minimummaprepeatdistance))

Servers must run at least UT v469.
Clients must run at least UT v436.
Admin UI functionality also requires at least UT v469.
Admin UI functionality also requires at least UT v469 clients.

## [UI Documentation](Docs/ui.md)

Expand Down
31 changes: 24 additions & 7 deletions System/VoteSys.int
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ ErrMapLoadFailed="Loading map {1} failed, randomly selecting {2}"
ErrNoConnection="VoteSys has no connection to server, check server firewall"
ErrNotAllowed="Sorry, you are not allowed to vote"

[VS_UIS_PageAdminMapLists]
Text_MapListName="Map List Name"
Text_Map="Include Maps"
Text_IgnoreMap="Exclude Maps"
Text_IncludeMapsWithPrefix="Include Prefixes"
Text_IgnoreMapsWithPrefix="Exclude Prefixes"
Text_IncludeList="Include Lists"
Text_IgnoreList="Exclude Lists"

[VS_UIV_Window]
WindowTitle="VoteSys Menu"

Expand Down Expand Up @@ -111,6 +120,21 @@ Text_DefaultMap="Default Map"
Text_AlwaysUseDefaultMap="Always Use Default Map"
Text_IdleTimeout="Idle Timeout"

[VS_UI_PlayerMenu]
PlayerIdText="ID:"
PlayerKickText="&Kick"
PlayerBanText="&Ban"
PlayerBanTitle="Ban Player"
PlayerBanMessage="Do you want to permanently ban {1}?"

[VS_UIS_ClientWindow]
PageClientSettingsName="Client"
PageAdminVotingName="[A] Voting"
PageAdminUIName="[A] UI"
PageAdminSetupName="[A] Setup"
PageAdminPresetsName="[A] Presets"
PageAdminMapListsName="[A] Map Lists"

[VS_UIS_PageClient]
ThemeText="Theme"
ThemeBright="Bright"
Expand All @@ -123,13 +147,6 @@ MapListSortPlayCount="Play Count"
FavoritesFirstText="Sort Favorites First"
ShowPlayerListText="Show Player List"

[VS_UI_PlayerMenu]
PlayerIdText="ID:"
PlayerKickText="&Kick"
PlayerBanText="&Ban"
PlayerBanTitle="Ban Player"
PlayerBanMessage="Do you want to permanently ban {1}?"

[VS_UI_ScreenshotWindow]
TextPlayerCount="Players:"

Expand Down
15 changes: 10 additions & 5 deletions USrc/MutVoteSys.uc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var int PresetMaxIndex;
var Object MapConfigDummy;
var Object MapListDummy;
var VS_MapList MapLists;
var array<VS_MapListConfig> MapListArray;

var Object HistoryDummy;
var VS_HistoryConfig History;
Expand Down Expand Up @@ -1390,6 +1391,8 @@ function VS_MapList LoadMapListByName(name ListName) {
return ML;
MC = new(MapConfigDummy, ListName) class'VS_MapListConfig';
MapListArray.Insert(MapListArray.Length, 1);
MapListArray[MapListArray.Length - 1] = MC;
MLIgnore = new(MapListDummy) class'VS_MapList';
Expand All @@ -1400,6 +1403,8 @@ function VS_MapList LoadMapListByName(name ListName) {
ML = new(MapListDummy) class'VS_MapList';
ML.ListName = string(ListName);
ML.Storage = MC;
ML.Next = MapLists;
MapLists = ML;
AddAllMapsToMapList(MC.Map, ML);
AddMapPrefixesToMapList(MC.IncludeMapsWithPrefix, ML);
Expand All @@ -1423,9 +1428,9 @@ function VS_MapList LoadMapListByPrefix(string Prefix) {
return ML;
ML = new(MapListDummy) class'VS_MapList';
ML.Prefix = Prefix;
ML.Next = MapLists;
MapLists = ML;
ML.Prefix = Prefix;
FirstMap = GetMapName(Prefix, "", 0);
if (FirstMap == "")
Expand Down Expand Up @@ -1479,15 +1484,15 @@ function AddMapPrefixesToMapList(array<string> MapPrefixArray, VS_MapList MapLis
}
}

function AddMapListsToMapList(array<name> MapListArray, VS_MapList MapList) {
function AddMapListsToMapList(array<name> MLArr, VS_MapList MapList) {
local VS_MapList IncludeList;
local int i;

for (i = 0; i < MapListArray.Length; i++) {
if (MapListArray[i] == '')
for (i = 0; i < MLArr.Length; i++) {
if (MLArr[i] == '')
continue;

IncludeList = LoadMapListByName(MapListArray[i]);
IncludeList = LoadMapListByName(MLArr[i]);
if (IncludeList != none)
MapList.AddMapList(IncludeList);
}
Expand Down
90 changes: 89 additions & 1 deletion USrc/VS_DataClient.uc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var VS_Preset Preset;
var VS_Map LastMap;
var VS_ServerSettings ServerSettings;
var VS_ClientPresetList ServerPresets;
var VS_ClientMapListsContainer ServerMapLists;

var float ResolveDelay;

Expand Down Expand Up @@ -186,6 +187,19 @@ function ParseLine(string Line) {
} else if (Line == "/ENDSERVERPRESETCONFIG/") {
ServerPresets.TransmissionState = TS_Complete;
Log("VS_DataClient GetServerPresets End", 'VoteSys');
} else if (Left(Line, 21) == "/BEGINSERVERMAPLISTS/") {
ServerMapLists.TransmissionState = TS_New;
ServerMapLists.AllocateMapLists(int(Mid(Line, 21)));
Log("VS_DataClient GetServerMapLists Begin", 'VoteSys');
} else if (Left(Line, 20) == "/BEGINSERVERMAPLIST/") {
ParseMapListName(Line);
} else if (Left(Line, 23) == "/SERVERMAPLISTPROPERTY/") {
ParseMapListProperty(Line);
} else if (Left(Line, 18) == "/ENDSERVERMAPLIST/") {
//
} else if (Line == "/ENDSERVERMAPLISTS/") {
ServerMapLists.TransmissionState = TS_Complete;
Log("VS_DataClient GetServerMapLists End", 'VoteSys');
} else if (Left(Line, 5) == "/PONG") {
// nothing to do
} else {
Expand Down Expand Up @@ -310,7 +324,7 @@ function VS_ClientPresetList GetServerPresets() {
Log("VS_DataClient GetServerPresets Version OK", 'VoteSys');

if (ServerPresets == none) {
ServerPresets = new(none) class'VS_ClientPresetList';
ServerPresets = new(XLevel) class'VS_ClientPresetList';
SendLine("/SENDSERVERPRESETCONFIG/");
Log("VS_DataClient GetServerPresets Presets Requested", 'VoteSys');
}
Expand Down Expand Up @@ -376,6 +390,80 @@ function SaveServerPresets(VS_ClientPresetList S) {
Log("VS_DataClient SaveServerPresets Done", 'VoteSys');
}

function DiscardServerMapLists() {
ServerMapLists = none;
}

function VS_ClientMapListsContainer GetServerMapLists() {
Log("DataClient GetServerMapLists", 'VoteSys');
if (int(Level.EngineVersion) < 469)
return none; // not supported without 469

if (ServerMapLists == none) {
ServerMapLists = new(XLevel) class'VS_ClientMapListsContainer';
SendLine("/SENDSERVERMAPLISTS/");
Log("VS_DataClient GetServerMapLists Map Lists Requested", 'VoteSys');
}

return ServerMapLists;
}

function ParseMapListName(string Line) {
local int Index;

Line = Mid(Line, 20);
Index = int(Line); S11N.NextVariable(Line);
ServerMapLists.MapLists[Index].MapListName = S11N.DecodeString(Line);

Log("VS_DataClient GetServerMapList"@ServerMapLists.MapLists[Index].MapListName, 'VoteSys');
}

function ParseMapListProperty(string Line) {
local int Index;
local string PropName, PropValue;

Line = Mid(Line, 23);

Index = int(Line); S11N.NextVariable(Line);
S11N.ParseProperty(Line, PropName, PropValue);

ServerMapLists.MapLists[Index].SetPropertyText(PropName, PropValue);
}

function SaveServerMapListProperty(VS_ClientMapList M, string Prefix, string Prop) {
SendLine(Prefix$S11N.SerializeProperty(Prop, M.GetPropertyText(Prop)));
}

function SaveServerMapList(VS_ClientMapList M, int i) {
local string Prefix;
Prefix = "/SAVESERVERMAPLISTPROPERTY/"$i$"/";
SendLine("/SAVESERVERMAPLISTBEGIN/"$i$"/"$S11N.EncodeString(M.MapListName));
SaveServerMapListProperty(M, Prefix, "Map");
SaveServerMapListProperty(M, Prefix, "IgnoreMap");
SaveServerMapListProperty(M, Prefix, "IncludeMapsWithPrefix");
SaveServerMapListProperty(M, Prefix, "IgnoreMapsWithPrefix");
SaveServerMapListProperty(M, Prefix, "IncludeList");
SaveServerMapListProperty(M, Prefix, "IgnoreList");
}

function SaveServerMapLists(VS_ClientMapListsContainer S) {
local int i;
if (S == none)
return;

Log("VS_DataClient SaveServerMapLists", 'VoteSys');

for (i = 0; i < S.MapLists.Length; i++)
if (S.MapLists[i] != none && S.MapLists[i].MapListName != "")
SaveServerMapList(S.MapLists[i], i);

SendLine("/SAVESERVERMAPLISTSFILE/");

Log("VS_DataClient SaveServerMapLists Done", 'VoteSys');
}

defaultproperties {
RemoteRole=ROLE_None
}
Loading

0 comments on commit acfac85

Please sign in to comment.