Make arg completion for 'load' nicer, including showing filetimes and previewpics (where available). Should make autosave's rotating filenames a little nicer to work with.
This commit is contained in:
parent
76cbc3c019
commit
907e8fa0b1
3 changed files with 102 additions and 58 deletions
|
@ -159,9 +159,7 @@ void Con_Destroy (console_t *con)
|
||||||
}
|
}
|
||||||
con->display = con->current = con->oldest = NULL;
|
con->display = con->current = con->oldest = NULL;
|
||||||
|
|
||||||
if (con->footerline)
|
Con_Footerf(con, false, "");
|
||||||
Z_Free(con->footerline);
|
|
||||||
con->footerline = NULL;
|
|
||||||
if (con->completionline)
|
if (con->completionline)
|
||||||
Z_Free(con->completionline);
|
Z_Free(con->completionline);
|
||||||
con->completionline = NULL;
|
con->completionline = NULL;
|
||||||
|
@ -331,13 +329,7 @@ void Con_SetActive (console_t *con)
|
||||||
con_current = con;
|
con_current = con;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (con->footerline)
|
Con_Footerf(con, false, "");
|
||||||
{
|
|
||||||
con->selstartline = NULL;
|
|
||||||
con->selendline = NULL;
|
|
||||||
Z_Free(con->footerline);
|
|
||||||
con->footerline = NULL;
|
|
||||||
}
|
|
||||||
con->buttonsdown = CB_NONE;
|
con->buttonsdown = CB_NONE;
|
||||||
}
|
}
|
||||||
/*for enumerating consoles*/
|
/*for enumerating consoles*/
|
||||||
|
@ -936,9 +928,10 @@ qboolean Con_InsertConChars (console_t *con, conline_t *line, int offset, concha
|
||||||
void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags)
|
void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags)
|
||||||
{
|
{
|
||||||
conchar_t expanded[4096];
|
conchar_t expanded[4096];
|
||||||
conchar_t *c;
|
conchar_t *c, *n;
|
||||||
conline_t *reuse;
|
conline_t *reuse;
|
||||||
int maxlines;
|
int maxlines;
|
||||||
|
unsigned flags, codepoint;
|
||||||
|
|
||||||
if (con->maxlines)
|
if (con->maxlines)
|
||||||
maxlines = con->maxlines;
|
maxlines = con->maxlines;
|
||||||
|
@ -950,14 +943,13 @@ void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags)
|
||||||
c = expanded;
|
c = expanded;
|
||||||
if (*c)
|
if (*c)
|
||||||
con->unseentext = true;
|
con->unseentext = true;
|
||||||
while (*c)
|
for (;*c; c=n)
|
||||||
{
|
{
|
||||||
switch (*c & (CON_CHARMASK|CON_HIDDEN)) //include hidden so we don't do \r or \n on hidden chars, allowing them to be embedded in links and stuff.
|
n = Font_Decode(c, &flags, &codepoint);
|
||||||
{
|
if (codepoint=='\r' && !(flags&CON_HIDDEN))
|
||||||
case '\r':
|
|
||||||
con->cr = true;
|
con->cr = true;
|
||||||
break;
|
else if (codepoint=='\n' && !(flags&CON_HIDDEN))
|
||||||
case '\n':
|
{
|
||||||
con->cr = false;
|
con->cr = false;
|
||||||
reuse = NULL;
|
reuse = NULL;
|
||||||
while (con->linecount >= maxlines)
|
while (con->linecount >= maxlines)
|
||||||
|
@ -1012,8 +1004,9 @@ void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags)
|
||||||
con->current->length = 0;
|
con->current->length = 0;
|
||||||
if (con->display == con->current->older && con->displayscroll==0)
|
if (con->display == con->current->older && con->displayscroll==0)
|
||||||
con->display = con->current;
|
con->display = con->current;
|
||||||
break;
|
}
|
||||||
default:
|
else
|
||||||
|
{
|
||||||
if (con->cr)
|
if (con->cr)
|
||||||
{
|
{
|
||||||
con->current->length = 0;
|
con->current->length = 0;
|
||||||
|
@ -1034,10 +1027,8 @@ void Con_PrintCon (console_t *con, const char *txt, unsigned int parseflags)
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: don't do this a char at a time
|
//FIXME: don't do this a char at a time
|
||||||
Con_InsertConChars(con, con->current, con->current->length, c, 1);
|
Con_InsertConChars(con, con->current, con->current->length, c, n-c);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
con->current->time = realtime;
|
con->current->time = realtime;
|
||||||
|
@ -1327,14 +1318,70 @@ void VARGS Con_ThrottlePrintf (float *timer, int developerlevel, const char *fmt
|
||||||
Con_Printf("%s", msg);
|
Con_Printf("%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Con_FooterMarked(console_t *con, qboolean append, conchar_t *marked, conchar_t *markedend)
|
||||||
|
{
|
||||||
|
int oldlen, newlen;
|
||||||
|
conline_t *newf = NULL, *l;
|
||||||
|
unsigned fl, cp;
|
||||||
|
conchar_t *nl, *n;
|
||||||
|
|
||||||
|
if (!append)
|
||||||
|
{
|
||||||
|
while(con->footerline)
|
||||||
|
{
|
||||||
|
l = con->footerline;
|
||||||
|
con->footerline = l->older;
|
||||||
|
if (con->selstartline == l)
|
||||||
|
con->selstartline = NULL;
|
||||||
|
if (con->selendline == l)
|
||||||
|
con->selendline = NULL;
|
||||||
|
Z_Free(l);
|
||||||
|
}
|
||||||
|
con->footerline = NULL;
|
||||||
|
}
|
||||||
|
for (append = true; marked < markedend; marked = n, append = false)
|
||||||
|
{
|
||||||
|
n = markedend;
|
||||||
|
for (nl = marked; nl < markedend; nl=n)
|
||||||
|
{
|
||||||
|
n = Font_Decode(nl, &fl, &cp);
|
||||||
|
if (cp == '\n' && !(fl&CONF_HIDDEN))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
newlen = nl - marked;
|
||||||
|
if (append && con->footerline)
|
||||||
|
oldlen = con->footerline->length;
|
||||||
|
else
|
||||||
|
oldlen = 0;
|
||||||
|
|
||||||
|
if (newlen || !append)
|
||||||
|
{
|
||||||
|
newf = Z_Malloc(sizeof(*newf) + (oldlen + newlen) * sizeof(conchar_t));
|
||||||
|
if (append && con->footerline)
|
||||||
|
{
|
||||||
|
memcpy(newf, con->footerline, sizeof(*con->footerline)+oldlen*sizeof(conchar_t));
|
||||||
|
Z_Free(con->footerline);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
newf->older = con->footerline;
|
||||||
|
if (newf->older)
|
||||||
|
newf->older->newer = newf;
|
||||||
|
|
||||||
|
memcpy((conchar_t*)(newf+1)+oldlen, marked, newlen*sizeof(conchar_t));
|
||||||
|
newf->length = oldlen + newlen;
|
||||||
|
con->footerline = newf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*description text at the bottom of the console*/
|
/*description text at the bottom of the console*/
|
||||||
void Con_Footerf(console_t *con, qboolean append, const char *fmt, ...)
|
void Con_Footerf(console_t *con, qboolean append, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
char msg[MAXPRINTMSG];
|
char msg[MAXPRINTMSG];
|
||||||
conchar_t marked[MAXPRINTMSG], *markedend;
|
conchar_t marked[MAXPRINTMSG], *markedend;
|
||||||
int oldlen, newlen;
|
|
||||||
conline_t *newf;
|
|
||||||
if (!con)
|
if (!con)
|
||||||
con = con_current;
|
con = con_current;
|
||||||
if (!con)
|
if (!con)
|
||||||
|
@ -1345,31 +1392,7 @@ void Con_Footerf(console_t *con, qboolean append, const char *fmt, ...)
|
||||||
va_end (argptr);
|
va_end (argptr);
|
||||||
markedend = COM_ParseFunString((COLOR_YELLOW << CON_FGSHIFT)|(con->backshader?CON_NONCLEARBG:0), msg, marked, sizeof(marked), false);
|
markedend = COM_ParseFunString((COLOR_YELLOW << CON_FGSHIFT)|(con->backshader?CON_NONCLEARBG:0), msg, marked, sizeof(marked), false);
|
||||||
|
|
||||||
newlen = markedend - marked;
|
Con_FooterMarked(con, append, marked, markedend);
|
||||||
if (append && con->footerline)
|
|
||||||
oldlen = con->footerline->length;
|
|
||||||
else
|
|
||||||
oldlen = 0;
|
|
||||||
|
|
||||||
if (!newlen && !oldlen)
|
|
||||||
newf = NULL;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newf = Z_Malloc(sizeof(*newf) + (oldlen + newlen) * sizeof(conchar_t));
|
|
||||||
if (con->footerline)
|
|
||||||
memcpy(newf, con->footerline, sizeof(*con->footerline)+oldlen*sizeof(conchar_t));
|
|
||||||
markedend = (void*)(newf+1);
|
|
||||||
markedend += oldlen;
|
|
||||||
memcpy(markedend, marked, newlen*sizeof(conchar_t));
|
|
||||||
newf->length = oldlen + newlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (con->selstartline == con->footerline)
|
|
||||||
con->selstartline = NULL;
|
|
||||||
if (con->selendline == con->footerline)
|
|
||||||
con->selendline = NULL;
|
|
||||||
Z_Free(con->footerline);
|
|
||||||
con->footerline = newf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -558,9 +558,9 @@ void CompleteCommand (qboolean force, int direction)
|
||||||
con_commandmatch = 1;
|
con_commandmatch = 1;
|
||||||
|
|
||||||
if (desc)
|
if (desc)
|
||||||
Con_Footerf(NULL, false, "%s: %s", cmd, localtext(desc));
|
Con_Footerf(con_current, false, "%s: %s", cmd, desc);
|
||||||
else
|
else
|
||||||
Con_Footerf(NULL, false, "");
|
Con_Footerf(con_current, false, "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1436,12 +1436,23 @@ static int QDECL CompleteSaveList (const char *name, qofs_t flags, time_t mtime,
|
||||||
struct xcommandargcompletioncb_s *ctx = parm;
|
struct xcommandargcompletioncb_s *ctx = parm;
|
||||||
char trimmed[256];
|
char trimmed[256];
|
||||||
size_t l;
|
size_t l;
|
||||||
Q_strncpyz(trimmed, name+6, sizeof(trimmed));
|
char timetext[128];
|
||||||
l = strlen(trimmed);
|
char desc[256];
|
||||||
if (l >= 9 && !Q_strcasecmp(trimmed+l-9, "/info.fsv"))
|
flocation_t loc;
|
||||||
|
if (FS_FLocateFile(name, FSLF_QUIET|FSLF_DONTREFERENCE, &loc) && loc.search->handle != spath)
|
||||||
|
; //found in some other gamedir. don't show the dupe.
|
||||||
|
else
|
||||||
{
|
{
|
||||||
trimmed[l-9] = 0;
|
Q_strncpyz(trimmed, name+6, sizeof(trimmed));
|
||||||
ctx->cb(trimmed, NULL, NULL, ctx);
|
l = strlen(trimmed);
|
||||||
|
if (l >= 9 && !Q_strcasecmp(trimmed+l-9, "/info.fsv"))
|
||||||
|
{
|
||||||
|
trimmed[l-9] = 0;
|
||||||
|
|
||||||
|
strftime(timetext, sizeof(timetext), "%a "S_COLOR_MAGENTA"%Y-%m-%d "S_COLOR_WHITE"%H:%M:%S", localtime(&mtime));
|
||||||
|
Q_snprintfz(desc, sizeof(desc), "Modified %s\n^[\\h\\64\\img\\saves/%s/screeny.tga^]", timetext, trimmed);
|
||||||
|
ctx->cb(trimmed, desc, NULL, ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1450,8 +1461,18 @@ static int QDECL CompleteSaveListLegacy (const char *name, qofs_t flags, time_t
|
||||||
{
|
{
|
||||||
struct xcommandargcompletioncb_s *ctx = parm;
|
struct xcommandargcompletioncb_s *ctx = parm;
|
||||||
char stripped[64];
|
char stripped[64];
|
||||||
COM_StripExtension(name, stripped, sizeof(stripped));
|
char timetext[128];
|
||||||
ctx->cb(stripped, NULL, NULL, ctx);
|
char desc[256];
|
||||||
|
flocation_t loc;
|
||||||
|
if (FS_FLocateFile(name, FSLF_QUIET|FSLF_DONTREFERENCE, &loc) && loc.search->handle != spath)
|
||||||
|
; //found in some other gamedir. don't show the dupe.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COM_StripExtension(name, stripped, sizeof(stripped));
|
||||||
|
strftime(timetext, sizeof(timetext), "%a "S_COLOR_MAGENTA"%Y-%m-%d "S_COLOR_WHITE"%H:%M:%S", localtime(&mtime));
|
||||||
|
Q_snprintfz(desc, sizeof(desc), "%s, Modified %s", name, timetext);
|
||||||
|
ctx->cb(stripped, desc, NULL, ctx);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue