Skip to content

Commit a350d79

Browse files
Add tier selection menu to mapsleft and mapsdone menus (with "All" option, for current functionality) (#1262)
1 parent a5bec04 commit a350d79

File tree

2 files changed

+96
-11
lines changed

2 files changed

+96
-11
lines changed

addons/sourcemod/scripting/shavit-stats.sp

Lines changed: 92 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ int gI_MapType[MAXPLAYERS+1];
5656
int gI_Style[MAXPLAYERS+1];
5757
int gI_MenuPos[MAXPLAYERS+1];
5858
int gI_Track[MAXPLAYERS+1];
59+
int gI_Tier[MAXPLAYERS+1];
5960
int gI_TargetSteamID[MAXPLAYERS+1];
6061
char gS_TargetName[MAXPLAYERS+1][MAX_NAME_LENGTH];
6162

@@ -753,10 +754,47 @@ public int MenuHandler_MapsDoneLeft_Track(Menu menu, MenuAction action, int para
753754
{
754755
if(action == MenuAction_Select)
755756
{
756-
char sInfo[8];
757+
char sInfo[8], sTier[16];
757758
menu.GetItem(param2, sInfo, 8);
758759
gI_Track[param1] = StringToInt(sInfo);
759760

761+
if(gB_Rankings)
762+
{
763+
Menu submenu = new Menu(MenuHandler_MapsDoneLeft_Tier);
764+
submenu.SetTitle("%T\n ", "SelectTier", param1);
765+
766+
submenu.AddItem("0", "All");
767+
768+
for(int i = 1; i <= 10; ++i)
769+
{
770+
IntToString(i, sInfo, 8);
771+
FormatEx(sTier, 16, "Tier %d", i);
772+
submenu.AddItem(sInfo, sTier);
773+
}
774+
775+
submenu.Display(param1, MENU_TIME_FOREVER);
776+
}
777+
else
778+
{
779+
ShowMaps(param1);
780+
}
781+
}
782+
else if(action == MenuAction_End)
783+
{
784+
delete menu;
785+
}
786+
787+
return 0;
788+
}
789+
790+
public int MenuHandler_MapsDoneLeft_Tier(Menu menu, MenuAction action, int param1, int param2)
791+
{
792+
if(action == MenuAction_Select)
793+
{
794+
char sInfo[8];
795+
menu.GetItem(param2, sInfo, 8);
796+
gI_Tier[param1] = StringToInt(sInfo);
797+
760798
ShowMaps(param1);
761799
}
762800
else if(action == MenuAction_End)
@@ -1180,7 +1218,7 @@ public int MenuHandler_TypeHandler(Menu menu, MenuAction action, int param1, int
11801218
{
11811219
if(action == MenuAction_Select)
11821220
{
1183-
char sInfo[32];
1221+
char sInfo[32], sTier[16];
11841222
menu.GetItem(param2, sInfo, 32);
11851223

11861224
char sExploded[2][4];
@@ -1189,7 +1227,26 @@ public int MenuHandler_TypeHandler(Menu menu, MenuAction action, int param1, int
11891227
gI_Track[param1] = StringToInt(sExploded[0]);
11901228
gI_MapType[param1] = StringToInt(sExploded[1]);
11911229

1192-
ShowMaps(param1);
1230+
if(gB_Rankings)
1231+
{
1232+
Menu submenu = new Menu(MenuHandler_MapsDoneLeft_Tier);
1233+
submenu.SetTitle("%T\n ", "SelectTier", param1);
1234+
1235+
submenu.AddItem("0", "All");
1236+
1237+
for(int i = 1; i <= 10; ++i)
1238+
{
1239+
IntToString(i, sInfo, 8);
1240+
FormatEx(sTier, 16, "Tier %d", i);
1241+
submenu.AddItem(sInfo, sTier);
1242+
}
1243+
1244+
submenu.Display(param1, MENU_TIME_FOREVER);
1245+
}
1246+
else
1247+
{
1248+
ShowMaps(param1);
1249+
}
11931250
}
11941251
else if(action == MenuAction_Cancel && param2 == MenuCancel_ExitBack)
11951252
{
@@ -1210,21 +1267,39 @@ void ShowMaps(int client)
12101267
return;
12111268
}
12121269

1213-
char sQuery[512];
1270+
char sQuery[512], tierStr[32];
1271+
1272+
if(gI_Tier[client] > 0)
1273+
{
1274+
FormatEx(tierStr, 32, " AND t.tier = %d", gI_Tier[client]);
1275+
}
1276+
else
1277+
{
1278+
gI_Tier[client] = 0;
1279+
}
12141280

12151281
if(gI_MapType[client] == MAPSDONE)
12161282
{
1217-
FormatEx(sQuery, 512,
1218-
"SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 as 'rank', a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = %d AND a.style = %d AND a.track = %d GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.%s;",
1219-
gS_MySQLPrefix, gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client], (gB_Rankings)? "points DESC":"map");
1283+
if(gB_Rankings)
1284+
{
1285+
FormatEx(sQuery, 512,
1286+
"SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 as 'rank', a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track LEFT JOIN %smaptiers t ON a.map = t.map WHERE a.auth = %d AND a.style = %d AND a.track = %d%s GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.points DESC;",
1287+
gS_MySQLPrefix, gS_MySQLPrefix, gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client], tierStr);
1288+
}
1289+
else
1290+
{
1291+
FormatEx(sQuery, 512,
1292+
"SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 as 'rank', a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = %d AND a.style = %d AND a.track = %d GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.map;",
1293+
gS_MySQLPrefix, gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client]);
1294+
}
12201295
}
12211296
else
12221297
{
12231298
if(gB_Rankings)
12241299
{
12251300
FormatEx(sQuery, 512,
1226-
"SELECT DISTINCT m.map, t.tier FROM %smapzones m LEFT JOIN %smaptiers t ON m.map = t.map WHERE m.type = 0 AND m.track = %d AND m.map NOT IN (SELECT DISTINCT map FROM %splayertimes WHERE auth = %d AND style = %d AND track = %d) ORDER BY m.map;",
1227-
gS_MySQLPrefix, gS_MySQLPrefix, gI_Track[client], gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client]);
1301+
"SELECT DISTINCT m.map, t.tier FROM %smapzones m LEFT JOIN %smaptiers t ON m.map = t.map WHERE m.type = 0 AND m.track = %d%s AND m.map NOT IN (SELECT DISTINCT map FROM %splayertimes WHERE auth = %d AND style = %d AND track = %d) ORDER BY m.map;",
1302+
gS_MySQLPrefix, gS_MySQLPrefix, gI_Track[client], tierStr, gS_MySQLPrefix, gI_TargetSteamID[client], gI_Style[client], gI_Track[client]);
12281303
}
12291304
else
12301305
{
@@ -1328,13 +1403,19 @@ public void ShowMapsCallback(Database db, DBResultSet results, const char[] erro
13281403
menu.AddItem(sRecordID, sDisplay);
13291404
}
13301405

1406+
char sTier[8];
1407+
if(gI_Tier[client] > 0)
1408+
{
1409+
FormatEx(sTier, 8, "T%d ", gI_Tier[client]);
1410+
}
1411+
13311412
if(gI_MapType[client] == MAPSDONE)
13321413
{
1333-
menu.SetTitle("%T (%s)", "MapsDoneFor", client, gS_StyleStrings[gI_Style[client]].sShortName, gS_TargetName[client], rows, sTrack);
1414+
menu.SetTitle("%s%T (%s)", sTier, "MapsDoneFor", client, gS_StyleStrings[gI_Style[client]].sShortName, gS_TargetName[client], rows, sTrack);
13341415
}
13351416
else
13361417
{
1337-
menu.SetTitle("%T (%s)", "MapsLeftFor", client, gS_StyleStrings[gI_Style[client]].sShortName, gS_TargetName[client], rows, sTrack);
1418+
menu.SetTitle("%s%T (%s)", sTier, "MapsLeftFor", client, gS_StyleStrings[gI_Style[client]].sShortName, gS_TargetName[client], rows, sTrack);
13381419
}
13391420

13401421
if(menu.ItemCount == 0)

addons/sourcemod/translations/shavit-stats.phrases.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
{
1717
"en" "Select timer track:"
1818
}
19+
"SelectTier"
20+
{
21+
"en" "Select map tier:"
22+
}
1923
"MapsDone"
2024
{
2125
"en" "Maps done"

0 commit comments

Comments
 (0)