Add searching for map and demo in menu
Searching is by map/demo names and descriptions (also custom descriptions, in case of demo). DOCREF menudirlist
This commit is contained in:
@@ -58,6 +58,15 @@ menuitem "\f2Confirm" [ if (checkalias tmp_rewind) [rewind $tmp_rewind; delalias
|
||||
menuitem "" -1
|
||||
menuitem "Cancel" [ delalias tmp_setmr; delalias tmp_rewind ]
|
||||
|
||||
searchdemo = ""
|
||||
|
||||
newmenu [search specific demo]
|
||||
menudirlist demos dmo "demo $arg1" 0 searchdemo
|
||||
|
||||
newmenu [search demo]
|
||||
menuitemtextinput "Part of demo name or description: " "result $searchdemo" [ searchdemo = $arg1 ]
|
||||
menuitem "\f2\t\t Search demo" [ showmenu [search specific demo] ]
|
||||
|
||||
// in-game menu that opens when pressing escape while watching a demo.
|
||||
newmenu [Watching demo]
|
||||
menuitem "Stop watching demo" stopdemo
|
||||
@@ -66,6 +75,7 @@ menuitem "Rewind demo..." [ showmenu rewind ]
|
||||
menuitemtextinput "Custom description: " [ getalias (concatword "demodesc_" $curdemofile) ] [ alias (concatword "demodesc_" $curdemofile) $arg1 ] [] 50
|
||||
menuitem "" -1
|
||||
menuitem "Watch other demo" [ stopdemo; closecurmenu; showmenu [Play demo] ]
|
||||
menuitem "Search demo..." [ showmenu [search demo] ]
|
||||
menuitem "" -1
|
||||
menuitem "\f4Main menu..." [ closecurmenu; showmenu main ]
|
||||
menuitem "\f3Quit AssaultCube" savequit
|
||||
|
||||
+16
-1
@@ -84,7 +84,22 @@ menuitem "Bot Team One Shot, One Kill" [ tmp_mode = 21; tmp_isbotteammode = 1; s
|
||||
menuitem "Bot Survival" [ load_survival ; showmenu [Survival Mode] ]
|
||||
menuitem "" -1
|
||||
menuitem "Bot settings..." [ showmenu [Bot settings] ]
|
||||
menuitem "Empty Map" emptymap
|
||||
menuitem "" -1
|
||||
menuitem "Empty map" emptymap
|
||||
menuitem "Search map..." [ showmenu [search map] ]
|
||||
|
||||
searchmap = ""
|
||||
|
||||
newmenu [search official map]
|
||||
menudirlist "packages/maps/official" cgz [map $arg1] 0 searchmap
|
||||
|
||||
newmenu [search custom map]
|
||||
menudirlist "packages/maps" cgz [map $arg1] 0 searchmap
|
||||
|
||||
newmenu [search map]
|
||||
menuitemtextinput "Part of map name or description: " "result $searchmap" [ searchmap = $arg1 ]
|
||||
menuitem "\f2\t\tSearch in official maps" [ showmenu [search official map] ]
|
||||
menuitem "\f2\t\tSearch in custom maps" [ showmenu [search custom map] ]
|
||||
|
||||
const showmenu_enemies [ if ($tmp_isbotteammode) [ showmenu [team enemies] ] [ showmenu enemies ] ]
|
||||
|
||||
|
||||
+41
-14
@@ -1005,7 +1005,7 @@ void menumdl(char *mdl, char *anim, int *rotspeed, int *scale)
|
||||
}
|
||||
COMMAND(menumdl, "ssii");
|
||||
|
||||
void menudirlist(char *dir, char *ext, char *action, int *image)
|
||||
void menudirlist(char *dir, char *ext, char *action, int *image, char *searchfile)
|
||||
{
|
||||
if(!lastmenu) return;
|
||||
if(!action || !action[0]) return;
|
||||
@@ -1016,8 +1016,9 @@ void menudirlist(char *dir, char *ext, char *action, int *image)
|
||||
d->ext = ext[0] ? newstring(ext): NULL;
|
||||
d->action = action[0] ? newstring(action) : NULL;
|
||||
d->image = *image!=0;
|
||||
d->searchfile = searchfile[0] ? newstring(searchfile) : NULL;
|
||||
}
|
||||
COMMAND(menudirlist, "sssi");
|
||||
COMMAND(menudirlist, "sssis");
|
||||
|
||||
void chmenumdl(char *menu, char *mdl, char *anim, int *rotspeed, int *scale)
|
||||
{
|
||||
@@ -1275,12 +1276,32 @@ void gmenu::init()
|
||||
const char *customsortorder = getalias(sortorderalias);
|
||||
if(customsortorder) sortorderindex = getlistindex(customsortorder, menufilesortorders, true, 0);
|
||||
files.sort(menufilesortcmp[sortorderindex]);
|
||||
|
||||
string searchfileuc;
|
||||
if(dirlist->searchfile)
|
||||
{
|
||||
const char *searchfilealias = getalias(dirlist->searchfile);
|
||||
copystring(searchfileuc, searchfilealias ? searchfilealias : dirlist->searchfile);
|
||||
strtoupper(searchfileuc);
|
||||
}
|
||||
|
||||
loopv(files)
|
||||
{
|
||||
char *f = files[i];
|
||||
if(!f || !f[0]) continue;
|
||||
char *d = getfiledesc(dirlist->dir, f, dirlist->ext);
|
||||
defformatstring(jpgname)("%s/preview/%s.jpg", dirlist->dir, f);
|
||||
bool filefound = false;
|
||||
if(dirlist->searchfile)
|
||||
{
|
||||
string fuc, duc;
|
||||
copystring(fuc, f);
|
||||
strtoupper(fuc);
|
||||
copystring(duc, d);
|
||||
strtoupper(duc);
|
||||
if(strstr(fuc, searchfileuc) || strstr(duc, searchfileuc)) filefound = true;
|
||||
}
|
||||
|
||||
if(dirlist->image)
|
||||
{
|
||||
string fullname = "";
|
||||
@@ -1293,23 +1314,29 @@ void gmenu::init()
|
||||
}
|
||||
items.add(new mitemimage (this, newstring(fullname), f, newstring(dirlist->action), NULL, NULL, d));
|
||||
}
|
||||
else if(!strcmp(dirlist->ext, "cgz") /*&& (fileexists(jpgname, "r") || findfile(jpgname, "r") != jpgname)*/)
|
||||
else if(!strcmp(dirlist->ext, "cgz"))
|
||||
{
|
||||
//items.add(new mitemimage(this, newstring(jpgname), f, newstring(dirlist->action), NULL, NULL, d));
|
||||
int diroffset = 0;
|
||||
if(dirlist->dir[0])
|
||||
if(!dirlist->searchfile || filefound)
|
||||
{
|
||||
unsigned int ddsl = strlen("packages/");
|
||||
if(strlen(dirlist->dir)>ddsl)
|
||||
int diroffset = 0;
|
||||
if(dirlist->dir[0])
|
||||
{
|
||||
string prefix;
|
||||
copystring(prefix, dirlist->dir, ddsl+1);
|
||||
if(!strcmp(prefix,"packages/")) diroffset = ddsl;
|
||||
unsigned int ddsl = strlen("packages/");
|
||||
if(strlen(dirlist->dir)>ddsl)
|
||||
{
|
||||
string prefix;
|
||||
copystring(prefix, dirlist->dir, ddsl+1);
|
||||
if(!strcmp(prefix,"packages/")) diroffset = ddsl;
|
||||
}
|
||||
}
|
||||
defformatstring(fullname)("%s%s%s", dirlist->dir[0]?dirlist->dir+diroffset:"", dirlist->dir[0]?"/":"", f);
|
||||
defformatstring(title)("%s", f);
|
||||
items.add(new mitemmapload(this, newstring(fullname), newstring(title), newstring(dirlist->action), NULL, NULL, NULL));
|
||||
}
|
||||
defformatstring(fullname)("%s%s%s", dirlist->dir[0]?dirlist->dir+diroffset:"", dirlist->dir[0]?"/":"", f);
|
||||
defformatstring(title)("%s", f);
|
||||
items.add(new mitemmapload(this, newstring(fullname), newstring(title), newstring(dirlist->action), NULL, NULL, NULL));
|
||||
}
|
||||
else if(!strcmp(dirlist->ext, "dmo"))
|
||||
{
|
||||
if(!dirlist->searchfile || filefound) items.add(new mitemtext(this, f, newstring(dirlist->action), NULL, NULL, d));
|
||||
}
|
||||
else items.add(new mitemtext(this, f, newstring(dirlist->action), NULL, NULL, d));
|
||||
}
|
||||
|
||||
+2
-1
@@ -138,13 +138,14 @@ struct mitem
|
||||
|
||||
struct mdirlist
|
||||
{
|
||||
char *dir, *ext, *action;
|
||||
char *dir, *ext, *action, *searchfile;
|
||||
bool image;
|
||||
~mdirlist()
|
||||
{
|
||||
DELETEA(dir);
|
||||
DELETEA(ext);
|
||||
DELETEA(action);
|
||||
DELETEA(searchfile);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user