mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-04-19 16:51:53 +00:00
Merge branch 'overall-download-progress' into 'next'
Total download progress for server's addons See merge request STJr/SRB2!2556
This commit is contained in:
commit
0cfba0c3da
3 changed files with 39 additions and 6 deletions
|
@ -54,6 +54,8 @@ static boolean IsDownloadingFile(void)
|
|||
static void DrawConnectionStatusBox(void)
|
||||
{
|
||||
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-16-8, 32, 1);
|
||||
if (cl_mode != CL_DOWNLOADSAVEGAME && filedownload.current != -1)
|
||||
M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-46-8, 32, 1);
|
||||
|
||||
if (cl_mode == CL_CONFIRMCONNECT || IsDownloadingFile())
|
||||
return;
|
||||
|
@ -84,6 +86,33 @@ static void DrawFileProgress(fileneeded_t *file, int y)
|
|||
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, y, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024));
|
||||
}
|
||||
|
||||
static void DrawOverallProgress(int y)
|
||||
{
|
||||
UINT32 totalsize = filedownload.totalsize;
|
||||
INT32 downloadedfiles = filedownload.completednum;
|
||||
INT32 totalfiles = filedownload.remaining + filedownload.completednum;
|
||||
INT32 downloaded = filedownload.completedsize;
|
||||
if (fileneeded[filedownload.current].currentsize != fileneeded[filedownload.current].totalsize)
|
||||
downloaded = filedownload.completedsize + fileneeded[filedownload.current].currentsize;
|
||||
|
||||
INT32 dldlength = (INT32)((downloaded/(double)totalsize) * 256);
|
||||
if (dldlength > 256)
|
||||
dldlength = 256;
|
||||
V_DrawFill(BASEVIDWIDTH/2-128, y, 256, 8, 111);
|
||||
V_DrawFill(BASEVIDWIDTH/2-128, y, dldlength, 8, 96);
|
||||
|
||||
const char *progress_str;
|
||||
if (totalsize >= 1024*1024)
|
||||
progress_str = va(" %.2fMiB/%.2fMiB", (double)downloaded / (1024*1024), (double)totalsize / (1024*1024));
|
||||
else if (totalsize < 1024)
|
||||
progress_str = va(" %4uB/%4uB", downloaded, totalsize);
|
||||
else
|
||||
progress_str = va(" %.2fKiB/%.2fKiB", (double)downloaded / 1024, (double)totalsize / 1024);
|
||||
|
||||
V_DrawString(BASEVIDWIDTH/2-128, y, V_20TRANS|V_ALLOWLOWERCASE, progress_str);
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH/2+128, y, V_20TRANS|V_ALLOWLOWERCASE, va("%2u/%2u Files ", downloadedfiles+1, totalfiles));
|
||||
}
|
||||
|
||||
//
|
||||
// CL_DrawConnectionStatus
|
||||
//
|
||||
|
@ -224,7 +253,7 @@ static void CL_DrawConnectionStatus(void)
|
|||
const char *download_str = M_GetText("Downloading \"%s\"");
|
||||
#endif
|
||||
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-24, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-24, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
va(download_str, tempname));
|
||||
|
||||
// Rusty: actually lets do this instead
|
||||
|
@ -244,16 +273,18 @@ static void CL_DrawConnectionStatus(void)
|
|||
strlcpy(tempname, http_source, sizeof(tempname));
|
||||
}
|
||||
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
va(M_GetText("from %s"), tempname));
|
||||
}
|
||||
else
|
||||
{
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-46-16, V_ALLOWLOWERCASE|V_YELLOWMAP,
|
||||
M_GetText("from the server"));
|
||||
}
|
||||
DrawFileProgress(file, BASEVIDHEIGHT-46);
|
||||
|
||||
DrawFileProgress(file, BASEVIDHEIGHT-16);
|
||||
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-16-14, V_ALLOWLOWERCASE|V_YELLOWMAP, "Total Progress");
|
||||
DrawOverallProgress(BASEVIDHEIGHT-16);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -657,6 +688,7 @@ static void ShowDownloadConsentMessage(void)
|
|||
if (IsFileDownloadable(&fileneeded[i]))
|
||||
totalsize += fileneeded[i].totalsize;
|
||||
}
|
||||
filedownload.totalsize = totalsize;
|
||||
|
||||
const char *downloadsize = GetPrintableFileSize(totalsize);
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ typedef struct
|
|||
INT32 remaining;
|
||||
INT32 completednum;
|
||||
UINT32 completedsize;
|
||||
UINT64 totalsize;
|
||||
|
||||
boolean http_failed;
|
||||
boolean http_running;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define SPEED 5
|
||||
|
||||
#define NUM_BLOCKS_X 20
|
||||
#define NUM_BLOCKS_Y 10
|
||||
#define NUM_BLOCKS_Y 8
|
||||
#define BLOCK_SIZE 12
|
||||
#define BORDER_SIZE 12
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
#define LEFT_X ((BASEVIDWIDTH - MAP_WIDTH) / 2 - BORDER_SIZE)
|
||||
#define RIGHT_X (LEFT_X + MAP_WIDTH + BORDER_SIZE * 2 - 1)
|
||||
#define BOTTOM_Y (BASEVIDHEIGHT - 48)
|
||||
#define BOTTOM_Y (BASEVIDHEIGHT - 76)
|
||||
#define TOP_Y (BOTTOM_Y - MAP_HEIGHT - BORDER_SIZE * 2 + 1)
|
||||
|
||||
enum bonustype_s {
|
||||
|
|
Loading…
Reference in a new issue