mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-21 01:41:10 +00:00
Minor cleanup to download draw function. More to do, this is just a good
checkpoint before I make changes that may not work.
This commit is contained in:
parent
1094e146da
commit
c7d74c6743
1 changed files with 33 additions and 39 deletions
|
@ -586,48 +586,42 @@ Con_DrawDownload (int lines)
|
|||
char *text;
|
||||
char dlbar[1024];
|
||||
|
||||
// draw the download bar
|
||||
// figure out width
|
||||
if (cls.download) {
|
||||
if ((text = strrchr (cls.downloadname, '/')))
|
||||
text++;
|
||||
else
|
||||
text = cls.downloadname;
|
||||
if (!cls.download)
|
||||
return;
|
||||
|
||||
x = con_linewidth - ((con_linewidth * 7) / 40);
|
||||
y = x - strlen (text) - 8;
|
||||
i = con_linewidth / 3;
|
||||
if (strlen (text) > i) {
|
||||
y = x - i - 11;
|
||||
strncpy (dlbar, text, i);
|
||||
dlbar[i] = 0;
|
||||
strncat (dlbar, "...", sizeof (dlbar) - strlen (dlbar));
|
||||
} else
|
||||
strncpy (dlbar, text, sizeof (dlbar));
|
||||
strncat (dlbar, ": ", sizeof (dlbar) - strlen (dlbar));
|
||||
i = strlen (dlbar);
|
||||
dlbar[i++] = '\x80';
|
||||
// where's the dot go?
|
||||
if (cls.downloadpercent == 0)
|
||||
n = 0;
|
||||
else
|
||||
n = y * cls.downloadpercent / 100;
|
||||
text = COM_SkipPath(cls.downloadname);
|
||||
|
||||
for (j = 0; j < y; j++)
|
||||
if (j == n)
|
||||
dlbar[i++] = '\x83';
|
||||
else
|
||||
dlbar[i++] = '\x81';
|
||||
dlbar[i++] = '\x82';
|
||||
x = con_linewidth - ((con_linewidth * 7) / 40);
|
||||
y = x - strlen (text) - 8;
|
||||
i = con_linewidth / 3;
|
||||
if (strlen (text) > i) {
|
||||
y = x - i - 11;
|
||||
strncpy (dlbar, text, i);
|
||||
dlbar[i] = 0;
|
||||
strncat (dlbar, "...", sizeof (dlbar) - strlen (dlbar));
|
||||
} else
|
||||
strncpy (dlbar, text, sizeof (dlbar));
|
||||
strncat (dlbar, ": ", sizeof (dlbar) - strlen (dlbar));
|
||||
i = strlen (dlbar);
|
||||
dlbar[i++] = '\x80';
|
||||
// where's the dot go?
|
||||
if (cls.downloadpercent == 0)
|
||||
n = 0;
|
||||
else
|
||||
n = y * cls.downloadpercent / 100;
|
||||
for (j = 0; j < y; j++)
|
||||
if (j == n)
|
||||
dlbar[i++] = '\x83';
|
||||
else
|
||||
dlbar[i++] = '\x81';
|
||||
dlbar[i++] = '\x82';
|
||||
dlbar[i] = 0;
|
||||
|
||||
snprintf (dlbar + strlen (dlbar), sizeof (dlbar) - strlen (dlbar),
|
||||
" %02d%%", cls.downloadpercent);
|
||||
|
||||
// draw it
|
||||
y = lines - 22 + 8;
|
||||
for (i = 0; i < strlen (dlbar); i++)
|
||||
Draw_Character8 ((i + 1) << 3, y, dlbar[i]);
|
||||
}
|
||||
snprintf (dlbar + strlen (dlbar), sizeof (dlbar) - strlen (dlbar),
|
||||
" %02d%%", cls.downloadpercent);
|
||||
// draw it
|
||||
y = lines - 22 + 8;
|
||||
for (i = 0; i < strlen (dlbar); i++)
|
||||
Draw_Character8 ((i + 1) << 3, y, dlbar[i]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue