MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / DownloadProgressBox

Method DownloadProgressBox

neo/framework/Session_menu.cpp:1433–1510  ·  view source on GitHub ↗

================= idSessionLocal::DownloadProgressBox ================= */

Source from the content-addressed store, hash-verified

1431=================
1432*/
1433void idSessionLocal::DownloadProgressBox( backgroundDownload_t *bgl, const char *title, int progress_start, int progress_end ) {
1434 int dlnow = 0, dltotal = 0;
1435 int startTime = Sys_Milliseconds();
1436 int lapsed;
1437 idStr sNow, sTotal, sBW, sETA, sMsg;
1438
1439 if ( !BoxDialogSanityCheck() ) {
1440 return;
1441 }
1442
1443 guiMsg->SetStateString( "visible_msgbox", "1" );
1444 guiMsg->SetStateString( "visible_waitbox", "0" );
1445
1446 guiMsg->SetStateString( "visible_entry", "0" );
1447 guiMsg->SetStateString( "visible_cdkey", "0" );
1448
1449 guiMsg->SetStateString( "mid", "Cancel" );
1450 guiMsg->SetStateString( "visible_mid", "1" );
1451 guiMsg->SetStateString( "visible_left", "0" );
1452 guiMsg->SetStateString( "visible_right", "0" );
1453
1454 guiMsg->SetStateString( "title", title );
1455 guiMsg->SetStateString( "message", "Connecting.." );
1456
1457 guiMsgRestore = guiActive;
1458 guiActive = guiMsg;
1459 msgRunning = true;
1460
1461 while ( 1 ) {
1462 while ( msgRunning ) {
1463 common->GUIFrame( true, false );
1464 if ( bgl->completed ) {
1465 guiActive = guiMsgRestore;
1466 guiMsgRestore = NULL;
1467 return;
1468 } else if ( bgl->url.dltotal != dltotal || bgl->url.dlnow != dlnow ) {
1469 dltotal = bgl->url.dltotal;
1470 dlnow = bgl->url.dlnow;
1471 lapsed = Sys_Milliseconds() - startTime;
1472 sNow.BestUnit( "%.2f", dlnow, MEASURE_SIZE );
1473 if ( lapsed > 2000 ) {
1474 sBW.BestUnit( "%.1f", ( 1000.0f * dlnow ) / lapsed, MEASURE_BANDWIDTH );
1475 } else {
1476 sBW = "-- KB/s";
1477 }
1478 if ( dltotal ) {
1479 sTotal.BestUnit( "%.2f", dltotal, MEASURE_SIZE );
1480 if ( lapsed < 2000 ) {
1481 sprintf( sMsg, "%s / %s", sNow.c_str(), sTotal.c_str() );
1482 } else {
1483 sprintf( sETA, "%.0f sec", ( (float)dltotal / (float)dlnow - 1.0f ) * lapsed / 1000 );
1484 sprintf( sMsg, "%s / %s ( %s - %s )", sNow.c_str(), sTotal.c_str(), sBW.c_str(), sETA.c_str() );
1485 }
1486 } else {
1487 if ( lapsed < 2000 ) {
1488 sMsg = sNow;
1489 } else {
1490 sprintf( sMsg, "%s - %s", sNow.c_str(), sBW.c_str() );

Callers 1

HandleDownloadsMethod · 0.80

Calls 7

Sys_MillisecondsFunction · 0.85
sprintfFunction · 0.85
vaFunction · 0.85
SetStateStringMethod · 0.80
BestUnitMethod · 0.80
GUIFrameMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected