]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
add ctrl-f hotkey; fix variable name consistency
authorBuddyFriendGuy <bfggeneral@gmail.com>
Wed, 8 Apr 2015 00:06:15 +0000 (20:06 -0400)
committerBuddyFriendGuy <bfggeneral@gmail.com>
Wed, 8 Apr 2015 00:06:15 +0000 (20:06 -0400)
qcsrc/common/mapinfo.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc
qcsrc/menu/xonotic/maplist.qc

index b77b4f676208b10959031ff1a4b6234c2e9718ee..316847069a1f41161bfbc20ccd0a937b7e00611d 100644 (file)
@@ -187,7 +187,7 @@ float MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, i
 
        return 1;
 }
-float MapInfo_FilterGametypeAndString(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate, string fs)
+float MapInfo_FilterGametypeAndString(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate, string sf)
 {
        float i, j;
        string title;
@@ -207,14 +207,12 @@ float MapInfo_FilterGametypeAndString(int pGametype, int pFeatures, int pFlagsRe
                                return 0;
                        }
                // prepare for keyword filter
-               //localcmd(sprintf("say filterString in mapinfo filter: %s\n", fs));
                if (MapInfo_Map_title && strstrofs(MapInfo_Map_title, "<TITLE>", 0) == -1)
                        title = MapInfo_Map_title;
                else
                        title = MapInfo_Map_bspname;
-               localcmd(sprintf("say map title: %s\n", title));
                // keyword filter
-               if((strstrofs(strtolower(title), strtolower(fs), 0)) >= 0)
+               if((strstrofs(strtolower(title), strtolower(sf), 0)) >= 0)
                if((MapInfo_Map_supportedGametypes & pGametype) != 0)
                if((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures)
                if((MapInfo_Map_flags & pFlagsForbidden) == 0)
index 65858bbcf84208d0904d9e88d023ad096e8920b4..717c4ea0de13db5212fec7418bc058ae35694aaf 100644 (file)
@@ -153,8 +153,9 @@ void XonoticServerCreateTab_fill(entity me)
        me.gotoRC(me, me.rows - 3.7, 3.2);
                /* map string filter */
                me.TD(me, 1, 0.6, e = makeXonoticTextLabel(1, _("Filter:")));
-               me.TD(me, 1, 2.2, e = makeXonoticInputBox(0, string_null));
-                       e.onChange = MapList_Filter_Change;
+               me.mapListBox.stringFilterBox = makeXonoticMapListStringFilterBox(me, 0, string_null);
+               me.TD(me, 1, 2.2, e = me.mapListBox.stringFilterBox);
+                       e.onChange = MapList_StringFilter_Change;
                        e.onChangeEntity = me.mapListBox;
                        me.mapListBox.controlledTextbox = e;
 
index 7978e544357798bb9cfb3ad2c7f8b3a2de9938c2..a525b31d9f2aee1b57b4df2ad13a78c07f074a54 100644 (file)
@@ -31,7 +31,8 @@ CLASS(XonoticMapList) EXTENDS(XonoticListBox)
        METHOD(XonoticMapList, g_maplistCacheToggle, void(entity, float))
        METHOD(XonoticMapList, g_maplistCacheQuery, float(entity, float))
 
-       ATTRIB(XonoticMapList, filterString, string, string_null)
+       ATTRIB(XonoticMapList, stringFilter, string, string_null)
+       ATTRIB(XonoticMapList, stringFilterBox, entity, NULL)
 
        ATTRIB(XonoticMapList, startButton, entity, NULL)
 
@@ -45,7 +46,8 @@ CLASS(XonoticMapList) EXTENDS(XonoticListBox)
        ATTRIB(XonoticListBox, alphaBG, float, 0)
 ENDCLASS(XonoticMapList)
 entity makeXonoticMapList();
-void MapList_Filter_Change(entity box, entity me);
+entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar);
+void MapList_StringFilter_Change(entity box, entity me);
 void MapList_All(entity btn, entity me);
 void MapList_None(entity btn, entity me);
 void MapList_LoadMap(entity btn, entity me);
@@ -57,6 +59,11 @@ void XonoticMapList_destroy(entity me)
        MapInfo_Shutdown();
 }
 
+entity makeXonoticMapListStringFilterBox(entity me, float doEditColorCodes, string theCvar)
+{
+       me.mapListBox.stringFilterBox = makeXonoticInputBox(doEditColorCodes, theCvar);
+       return me.mapListBox.stringFilterBox;
+}
 entity makeXonoticMapList()
 {
        entity me;
@@ -65,6 +72,12 @@ entity makeXonoticMapList()
        return me;
 }
 
+entity MapList_Set_String_Filter_Box(entity me, entity e)
+{
+       me.stringFilterBox = e;
+       return e;
+}
+
 void XonoticMapList_configureXonoticMapList(entity me)
 {
        me.configureXonoticListBox(me);
@@ -76,6 +89,7 @@ void XonoticMapList_loadCvars(entity me)
        me.refilter(me);
 }
 
+
 float XonoticMapList_g_maplistCacheQuery(entity me, float i)
 {
        return stof(substring(me.g_maplistCache, i, 1));
@@ -206,8 +220,8 @@ void XonoticMapList_refilter(entity me)
        gt = MapInfo_CurrentGametype();
        f = MapInfo_CurrentFeatures();
        // TODO consider consolidating the two functions
-       if (me.filterString)
-               MapInfo_FilterGametypeAndString(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0, me.filterString);
+       if (me.stringFilter)
+               MapInfo_FilterGametypeAndString(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0, me.stringFilter);
        else
                MapInfo_FilterGametype(gt, f, MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
        me.nItems = MapInfo_count;
@@ -223,7 +237,6 @@ void XonoticMapList_refilter(entity me)
        for(i = 0; i < n; ++i)
        {
                j = MapInfo_FindName(argv(i));
-               //localcmd(sprintf("say %s\n", argv(i)));
                if(j >= 0)
                        s = strcat(
                                substring(s, 0, j),
@@ -232,7 +245,6 @@ void XonoticMapList_refilter(entity me)
                        );
        }
        me.g_maplistCache = strzone(s);
-       //localcmd(sprintf("say maplistcache %s\n", me.g_maplistCache));
        if(gt != me.lastGametype || f != me.lastFeatures)
        {
                me.lastGametype = gt;
@@ -245,14 +257,14 @@ void XonoticMapList_refilterCallback(entity me, entity cb)
 {
        me.refilter(me);
 }
-void MapList_Filter_Change(entity box, entity me)
+void MapList_StringFilter_Change(entity box, entity me)
 {
-       if(me.filterString)
-               strunzone(me.filterString);
+       if(me.stringFilter)
+               strunzone(me.stringFilter);
        if(box.text != "")
-               me.filterString = strzone(box.text);
+               me.stringFilter = strzone(box.text);
        else
-               me.filterString = string_null;
+               me.stringFilter = string_null;
        
        me.refilter(me);
 }
@@ -261,8 +273,8 @@ void MapList_All(entity btn, entity me)
 {
        float i;
        string s;
-       if (me.filterString)
-               MapInfo_FilterGametypeAndString(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0, me.filterString);
+       if (me.stringFilter)
+               MapInfo_FilterGametypeAndString(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0, me.stringFilter);
        else
                MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, 0, MapInfo_ForbiddenFlags(), 0); // all
        s = "";
@@ -382,9 +394,12 @@ float XonoticMapList_keyDown(entity me, float scan, float ascii, float shift)
                if(MapInfo_FindName_firstResult >= 0)
                        me.setSelected(me, MapInfo_FindName_firstResult);
        }
+       else if(scan == 102 && ascii == 6 && shift == 2) // ctrl-f ("F"ind)
+       {
+               me.parent.setFocus(me.parent, me.stringFilterBox);
+       }
        else
                return SUPER(XonoticMapList).keyDown(me, scan, ascii, shift);
        return 1;
 }
-
 #endif