From: BuddyFriendGuy Date: Wed, 8 Apr 2015 00:06:15 +0000 (-0400) Subject: add ctrl-f hotkey; fix variable name consistency X-Git-Tag: xonotic-v0.8.1~23^2~17 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cd1eb81e90f409af874d1226e9ae5f09ca743923;p=xonotic%2Fxonotic-data.pk3dir.git add ctrl-f hotkey; fix variable name consistency --- diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc index b77b4f676..316847069 100644 --- a/qcsrc/common/mapinfo.qc +++ b/qcsrc/common/mapinfo.qc @@ -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, "", 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) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc index 65858bbcf..717c4ea0d 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_create.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_create.qc @@ -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; diff --git a/qcsrc/menu/xonotic/maplist.qc b/qcsrc/menu/xonotic/maplist.qc index 7978e5443..a525b31d9 100644 --- a/qcsrc/menu/xonotic/maplist.qc +++ b/qcsrc/menu/xonotic/maplist.qc @@ -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