Show list of demos in "Download demo" menu
This commit is contained in:
@@ -50,13 +50,6 @@ menuitem (_ [Start recording a demo]) recorddemo
|
||||
menuitem (_ [Stop recording a demo]) stopdemo
|
||||
menuitem (_ [Download demos from the server]) [ listdemos; showmenu [Download demo] ] // Lists the demos, then asks which would like to be downloaded.
|
||||
|
||||
newmenu [Download demo]
|
||||
menuinit [ dldemo = []; echo (gray) (_ [Choose the demo number you wish to download, as shown below in the console.]) ]
|
||||
menuitem (concatword (c 9) [ ] (_ [Download the latest demo...])) [ getdemo [] ]
|
||||
menuitem [] -1
|
||||
menuitemtextinput (_ [Demo number: ]) [] [ dldemo = $arg1 ]
|
||||
menuitem (concatword (c 2) [ ] "[" (_ Download) "]" [ ]) [ getdemo $dldemo ]
|
||||
|
||||
newmenu [Play demo] // If not in-game (recording/downloading demos isn't needed)
|
||||
menuinit [ echo (_ [To stop demo playback, type:]) (red)/stopdemo ]
|
||||
menudirlist demos dmo "demo $arg1"
|
||||
|
||||
@@ -1151,6 +1151,9 @@ void startmap(const char *name, bool reset, bool norespawn) // called just aft
|
||||
if(editmode) toggleedit(true);
|
||||
intermission = false;
|
||||
showscores(false);
|
||||
closemenu("Download demo"); // close and reset demo list, because it may be no longer accurate, since a new game has started
|
||||
extern void *downloaddemomenu;
|
||||
menureset(downloaddemomenu);
|
||||
needscoresreorder = true;
|
||||
minutesremaining = -1;
|
||||
lastgametimeupdate = 0;
|
||||
@@ -1628,7 +1631,6 @@ void setadmin(int *claim, char *password)
|
||||
|
||||
COMMAND(setadmin, "is");
|
||||
|
||||
struct mline { string name, cmd; };
|
||||
static vector<mline> mlines;
|
||||
|
||||
void *kickmenu = NULL, *banmenu = NULL, *forceteammenu = NULL, *giveadminmenu = NULL;
|
||||
|
||||
@@ -9,6 +9,9 @@ VARP(networkdebug, 0, 0, 1);
|
||||
extern bool watchingdemo;
|
||||
extern string clientpassword;
|
||||
|
||||
void *downloaddemomenu = NULL;
|
||||
static vector<mline> demo_mlines;
|
||||
|
||||
packetqueue pktlogger;
|
||||
|
||||
void neterr(const char *s)
|
||||
@@ -1334,11 +1337,27 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false)
|
||||
case SV_SENDDEMOLIST:
|
||||
{
|
||||
int demos = getint(p);
|
||||
if(!demos) conoutf(_("no demos available"));
|
||||
else loopi(demos)
|
||||
menureset(downloaddemomenu);
|
||||
demo_mlines.shrink(0);
|
||||
if(!demos)
|
||||
{
|
||||
getstring(text, p);
|
||||
conoutf("%d. %s", i+1, text);
|
||||
conoutf(_("no demos available"));
|
||||
mline &m = demo_mlines.add();
|
||||
copystring(m.name, "no demos available");
|
||||
menumanual(downloaddemomenu,m.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
demo_mlines.reserve(demos);
|
||||
loopi(demos)
|
||||
{
|
||||
getstring(text, p);
|
||||
conoutf("%d. %s", i+1, text);
|
||||
mline &m = demo_mlines.add();
|
||||
formatstring(m.name)("%d. %s", i+1, text);
|
||||
formatstring(m.cmd)("getdemo %d", i+1);
|
||||
menumanual(downloaddemomenu, m.name, m.cmd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-1
@@ -1154,7 +1154,7 @@ int main(int argc, char **argv)
|
||||
audiomgr.initsound();
|
||||
|
||||
initlog("cfg");
|
||||
extern void *scoremenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu;
|
||||
extern void *scoremenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu, *downloaddemomenu;
|
||||
scoremenu = addmenu("score", "columns", false, renderscores, NULL, false, true);
|
||||
servmenu = addmenu("server", NULL, true, refreshservers, serverskey);
|
||||
searchmenu = addmenu("search", NULL, true, refreshservers, serverskey);
|
||||
@@ -1165,6 +1165,7 @@ int main(int argc, char **argv)
|
||||
giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu);
|
||||
docmenu = addmenu("reference", NULL, true, renderdocmenu);
|
||||
applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu);
|
||||
downloaddemomenu = addmenu("Download demo", NULL, true);
|
||||
|
||||
exec("config/scontext.cfg");
|
||||
exec("config/locale.cfg");
|
||||
|
||||
@@ -180,6 +180,8 @@ struct gmenu
|
||||
void init();
|
||||
};
|
||||
|
||||
struct mline { string name, cmd; };
|
||||
|
||||
// serverbrowser
|
||||
extern void addserver(const char *servername, int serverport, int weight);
|
||||
extern char *getservername(int n);
|
||||
|
||||
Reference in New Issue
Block a user