]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/xonotic/maplist.qc
Merge branch 'TimePath/soundregistry' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / xonotic / maplist.qc
index 03431ba31ce277ea8b4a5f19939aeb8aaa061690..91d8eaa3de36d6bf14896d31cea4895f8aaf3e20 100644 (file)
@@ -2,16 +2,16 @@
 #define MAPLIST_H
 #include "listbox.qc"
 CLASS(XonoticMapList, XonoticListBox)
-       METHOD(XonoticMapList, configureXonoticMapList, void(entity))
+       METHOD(XonoticMapList, configureXonoticMapList, void(entity));
        ATTRIB(XonoticMapList, rowsPerItem, float, 4)
-       METHOD(XonoticMapList, draw, void(entity))
-       METHOD(XonoticMapList, drawListBoxItem, void(entity, float, vector, float))
-       METHOD(XonoticMapList, clickListBoxItem, void(entity, float, vector))
-       METHOD(XonoticMapList, doubleClickListBoxItem, void(entity, float, vector))
-       METHOD(XonoticMapList, resizeNotify, void(entity, vector, vector, vector, vector))
-       METHOD(XonoticMapList, refilter, void(entity))
-       METHOD(XonoticMapList, refilterCallback, void(entity, entity))
-       METHOD(XonoticMapList, keyDown, float(entity, float, float, float))
+       METHOD(XonoticMapList, draw, void(entity));
+       METHOD(XonoticMapList, drawListBoxItem, void(entity, int, vector, bool, bool));
+       METHOD(XonoticMapList, clickListBoxItem, void(entity, float, vector));
+       METHOD(XonoticMapList, doubleClickListBoxItem, void(entity, float, vector));
+       METHOD(XonoticMapList, resizeNotify, void(entity, vector, vector, vector, vector));
+       METHOD(XonoticMapList, refilter, void(entity));
+       METHOD(XonoticMapList, refilterCallback, void(entity, entity));
+       METHOD(XonoticMapList, keyDown, float(entity, float, float, float));
 
        ATTRIB(XonoticMapList, realFontSize, vector, '0 0 0')
        ATTRIB(XonoticMapList, columnPreviewOrigin, float, 0)
@@ -30,29 +30,29 @@ CLASS(XonoticMapList, XonoticListBox)
        ATTRIB(XonoticMapList, itemAbsSize, vector, '0 0 0')
 
        ATTRIB(XonoticMapList, g_maplistCache, string, string_null)
-       METHOD(XonoticMapList, g_maplistCacheToggle, void(entity, float))
-       METHOD(XonoticMapList, g_maplistCacheQuery, float(entity, float))
+       METHOD(XonoticMapList, g_maplistCacheToggle, void(entity, float));
+       METHOD(XonoticMapList, g_maplistCacheQuery, float(entity, float));
 
        ATTRIB(XonoticMapList, stringFilter, string, string_null)
        ATTRIB(XonoticMapList, stringFilterBox, entity, NULL)
 
        ATTRIB(XonoticMapList, startButton, entity, NULL)
 
-       METHOD(XonoticMapList, loadCvars, void(entity))
+       METHOD(XonoticMapList, loadCvars, void(entity));
 
        ATTRIB(XonoticMapList, typeToSearchString, string, string_null)
        ATTRIB(XonoticMapList, typeToSearchTime, float, 0)
 
-       METHOD(XonoticMapList, destroy, void(entity))
+       METHOD(XonoticMapList, destroy, void(entity));
 
        ATTRIB(XonoticMapList, alphaBG, float, 0)
 ENDCLASS(XonoticMapList)
 entity makeXonoticMapList();
-entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar);
 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
@@ -63,10 +63,6 @@ void XonoticMapList_destroy(entity me)
        MapInfo_Shutdown();
 }
 
-entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar)
-{
-       return makeXonoticInputBox(doEditColorCodes, theCvar);
-}
 entity makeXonoticMapList()
 {
        entity me;
@@ -179,7 +175,7 @@ void XonoticMapList_doubleClickListBoxItem(entity me, float i, vector where)
                }
 }
 
-void XonoticMapList_drawListBoxItem(entity me, float i, vector absSize, float isSelected)
+void XonoticMapList_drawListBoxItem(entity me, int i, vector absSize, bool isSelected, bool isFocused)
 {
        // layout: Ping, Map name, Map name, NP, TP, MP
        string s;
@@ -197,8 +193,16 @@ void XonoticMapList_drawListBoxItem(entity me, float i, vector absSize, float is
 
        if(isSelected)
                draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_SELECTED, SKINALPHA_LISTBOX_SELECTED);
-       else if(included)
-               draw_Fill('0 0 0', '1 1 0', SKINCOLOR_MAPLIST_INCLUDEDBG, SKINALPHA_MAPLIST_INCLUDEDBG);
+       else
+       {
+               if(included)
+                       draw_Fill('0 0 0', '1 1 0', SKINCOLOR_MAPLIST_INCLUDEDBG, SKINALPHA_MAPLIST_INCLUDEDBG);
+               if(isFocused)
+               {
+                       me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
+                       draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
+               }
+       }
 
        if(draw_PictureSize(strcat("/maps/", MapInfo_Map_bspname)) == '0 0 0')
                draw_Picture(me.columnPreviewOrigin * eX, "nopreview_map", me.columnPreviewSize * eX + eY, '1 1 1', theAlpha);
@@ -239,11 +243,15 @@ void XonoticMapList_refilter(entity me)
        {
                j = MapInfo_FindName(argv(i));
                if(j >= 0)
-                       s = strcat(
-                               substring(s, 0, j),
-                               "1",
-                               substring(s, j+1, MapInfo_count - (j+1))
-                       );
+               {
+                       // double check that the two mapnames are "identical", not just share the same prefix
+                       if (strlen(MapInfo_BSPName_ByID(j)) == strlen(argv(i)))
+                               s = strcat(
+                                       substring(s, 0, j),
+                                       "1",
+                                       substring(s, j+1, MapInfo_count - (j+1))
+                               );
+               }
        }
        me.g_maplistCache = strzone(s);
        if(gt != me.lastGametype || f != me.lastFeatures)
@@ -267,7 +275,7 @@ void MapList_StringFilterBox_Change(entity box, entity me)
                me.stringFilter = strzone(box.text);
        else
                me.stringFilter = string_null;
-       
+
        me.refilter(me);
 }
 
@@ -297,14 +305,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);
 }
 
@@ -333,7 +340,7 @@ void MapList_LoadMap(entity btn, entity me)
        m = MapInfo_BSPName_ByID(i);
        if (!m)
        {
-               print(_("Huh? Can't play this (m is NULL). Refiltering so this won't happen again.\n"));
+               LOG_INFO(_("Huh? Can't play this (m is NULL). Refiltering so this won't happen again.\n"));
                me.refilter(me);
                return;
        }
@@ -346,7 +353,7 @@ void MapList_LoadMap(entity btn, entity me)
        }
        else
        {
-               print(_("Huh? Can't play this (invalid game type). Refiltering so this won't happen again.\n"));
+               LOG_INFO(_("Huh? Can't play this (invalid game type). Refiltering so this won't happen again.\n"));
                me.refilter(me);
                return;
        }