From 6230ac3e9631b5e139bd425bf04e44a56806868f Mon Sep 17 00:00:00 2001
From: BuddyFriendGuy <bfggeneral@gmail.com>
Date: Mon, 3 Aug 2015 22:32:08 -0400
Subject: [PATCH] function for add all button; tooltip

---
 qcsrc/menu/xonotic/maplist.qc | 16 ++++++++--------
 tooltips.db                   |  1 +
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc
index 03431ba31..875ef7bd3 100644
--- a/qcsrc/menu/xonotic/maplist.qc
+++ b/qcsrc/menu/xonotic/maplist.qc
@@ -53,6 +53,7 @@ void MapList_StringFilterBox_Change(entity box, entity me);
 float MapList_StringFilterBox_keyDown(entity me, float key, float ascii, float shift);
 void MapList_Add_Shown(entity btn, entity me);
 void MapList_Remove_Shown(entity btn, entity me);
+void MapList_Add_All(entity btn, entity me);
 void MapList_Remove_All(entity btn, entity me);
 void MapList_LoadMap(entity btn, entity me);
 #endif
@@ -297,14 +298,13 @@ void MapList_Remove_Shown(entity btn, entity me)
 
 void MapList_Add_All(entity btn, entity me)
 {
-	// TODO make it work
-	float i, n;
-	n = strlen(me.g_maplistCache);
-	for (i = 0 ; i < n; i++)
-	{
-		if (!me.g_maplistCacheQuery(me, i))
-			me.g_maplistCacheToggle(me, i);
-	}
+	float i;
+	string s;
+	MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all
+	s = "";
+	for(i = 0; i < MapInfo_count; ++i)
+		s = strcat(s, " ", MapInfo_BSPName_ByID(i));
+	cvar_set("g_maplist", substring(s, 1, strlen(s) - 1));
 	me.refilter(me);
 }
 
diff --git a/tooltips.db b/tooltips.db
index 57e22b998..02887e6cc 100644
--- a/tooltips.db
+++ b/tooltips.db
@@ -47,6 +47,7 @@
 \XonoticMultiplayerDialog_StringFilterBox\Click here or Ctrl-F to provide a keyword to narrow down the maplist above. Ctrl-Delete to clear; Enter when done.
 \XonoticMultiplayerDialog/Add shown\Add the maps shown in Maplist above to your selection
 \XonoticMultiplayerDialog/Remove shown\Remove the maps shown in Maplist above from your selection
+\XonoticMultiplayerDialog/Add all\Add every available map to your selection
 \XonoticMultiplayerDialog/Remove all\Remove all the maps from your selection
 
 
-- 
2.39.5