aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod
diff options
context:
space:
mode:
authorEmma Miler <27428383+emma-miler@users.noreply.github.com>2022-04-29 23:28:41 +0200
committerGitHub <noreply@github.com>2022-04-29 23:28:41 +0200
commit44894dfde583f7fb3a4491b4f17893a907336d1f (patch)
treea10c75668fed9d044bb785ab93bf5f0a5def9ff5 /Northstar.Client/mod
parent88bc3168b7a832d2b09e60d61f31d531fadeb583 (diff)
downloadNorthstarMods-44894dfde583f7fb3a4491b4f17893a907336d1f.tar.gz
NorthstarMods-44894dfde583f7fb3a4491b4f17893a907336d1f.zip
Add default sort method for server browser (#303)
* Add default sort method * Do gecko's change * Fixed it * Set default sort mode when opening browser * Update Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com> * remove trailing space <3 gecko Co-authored-by: GeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>
Diffstat (limited to 'Northstar.Client/mod')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut39
1 files changed, 37 insertions, 2 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
index c77000e9d..5f6cda1a8 100644
--- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
@@ -33,6 +33,7 @@ struct {
enum sortingBy
{
NONE,
+ DEFAULT,
NAME,
PLAYERS,
MAP,
@@ -48,8 +49,8 @@ struct {
bool serverMap = true
bool serverGamemode = true
bool serverLatency = true
- // 0 = none; 1 = name; 2 = players; 3 = map; 5 = gamemode; 6 = latency
- int sortingBy = 0
+ // 0 = none; 1 = default; 2 = name; 3 = players; 4 = map; 5 = gamemode; 6 = latency
+ int sortingBy = 1
} filterDirection
struct serverStruct {
@@ -425,6 +426,8 @@ void function OnServerBrowserMenuOpened()
NSRequestServerList()
}
+ filterDirection.sortingBy = sortingBy.DEFAULT
+
thread WaitForServerListRequest()
@@ -652,6 +655,10 @@ void function FilterAndUpdateList( var n )
case sortingBy.NONE:
UpdateShownPage()
break
+ case sortingBy.DEFAULT:
+ filterDirection.serverName = !filterDirection.serverName
+ SortServerListByDefault_Activate(0)
+ break
case sortingBy.NAME:
filterDirection.serverName = !filterDirection.serverName
SortServerListByName_Activate(0)
@@ -1119,6 +1126,22 @@ int function ServerSortLogic ( serverStruct a, serverStruct b )
// We can hard code this cause adding entire columns isn't as easy
switch ( filterDirection.sortingBy )
{
+ case sortingBy.DEFAULT:
+ aTemp = a.serverPlayers
+ bTemp = b.serverPlayers
+
+ // `1000` is assumed to always be higher than `serverPlayersMax`
+ if (aTemp + 1 < a.serverPlayersMax)
+ aTemp = aTemp+2000
+ if (bTemp + 1 < b.serverPlayersMax)
+ bTemp = bTemp+2000
+ if (aTemp + 1 == a.serverPlayersMax)
+ aTemp = aTemp+1000
+ if (bTemp + 1 == b.serverPlayersMax)
+ bTemp = bTemp+1000
+
+ direction = filterDirection.serverName
+ break;
case sortingBy.NAME:
aTemp = a.serverName.tolower()
bTemp = b.serverName.tolower()
@@ -1159,6 +1182,18 @@ int function ServerSortLogic ( serverStruct a, serverStruct b )
return 0
}
+void function SortServerListByDefault_Activate ( var button )
+{
+ filterDirection.sortingBy = sortingBy.DEFAULT
+
+ file.serversArrayFiltered.sort( ServerSortLogic )
+
+ filterDirection.serverName = !filterDirection.serverName
+
+ UpdateShownPage()
+}
+
+
void function SortServerListByName_Activate ( var button )
{
filterDirection.sortingBy = sortingBy.NAME