Quasar Posted March 16, 2006 I've added a console command (and corresponding item on the menus) which allows you to enter a term and then search for occurances of it within the other menus. The next result is returned each time until all matches have been exhausted. The search then gets reset so you can start over if you wish. I pasted the code just to make this post longer and to piss off people who hate code ^_^ I figured some of you like Joel might be interested to see what was involved in adding such a potentially useful feature. CONSOLE_COMMAND(mn_search, 0) { int i = 0; menu_t *curMenu; boolean pastLast; // if lastMatch is set, set pastLast to false so that we'll seek // forward until we pass the last item that was matched pastLast = !lastMatch; if(!mn_searchstr || !mn_searchstr[0]) { MN_ErrorMsg("invalid search string"); return; } M_Strlwr(mn_searchstr); // run through every menu in the search list... while((curMenu = mn_search_menus[i++])) { menu_t *curPage = curMenu; // run through every page of the menu while(curPage) { int j = 0; menuitem_t *item; // run through items while((item = &(curPage->menuitems[j++]))) { char *desc; if(item->type == it_end) break; if(!item->description) continue; // keep seeking until we pass the last item found if(item == lastMatch) { pastLast = true; continue; } if(!pastLast) continue; desc = M_Strlwr(strdup(item->description)); // found a match if(strstr(desc, mn_searchstr)) { // go to it lastMatch = item; MN_StartMenu(curPage); MN_ErrorMsg("found: %s", desc); if(!is_a_gap(item)) curPage->selected = j - 1; free(desc); return; } free(desc); } curPage = curPage->nextpage; } } if(lastMatch) // if doing a valid search, reset it now { lastMatch = NULL; MN_ErrorMsg("reached end of search"); } else MN_ErrorMsg("no match found for '%s'", mn_searchstr); } 0 Share this post Link to post
SoM Posted March 16, 2006 Quasar said:I pasted the code just to make this post longer and to piss off people who hate code ^_^ haha! Nice :) 0 Share this post Link to post
Anders Posted March 16, 2006 you know you need to redesign your menus when: 1) You need a search function to find stuff in them. 0 Share this post Link to post
Murdoch Posted March 19, 2006 Well that was a useful contribution. Have you actually seen the menus anders? 0 Share this post Link to post
Quasar Posted March 20, 2006 The menus have already BEEN redesigned; in fact they are now 99.9% finished. The search function is there for two reasons: 1) I NEVER want to hear "I can't find so-and-so in the menus" again in my life, no matter what. 2) To ease the transition now that many things have been moved around to more logical places. 0 Share this post Link to post