mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
time download better--not from beginning of p3d file
This commit is contained in:
parent
8de216ed0c
commit
211116b6cc
@ -417,9 +417,9 @@ set_p3d_url(const string &p3d_url) {
|
|||||||
// Mark the time we started downloading, so we'll know when to reveal
|
// Mark the time we started downloading, so we'll know when to reveal
|
||||||
// the progress bar, and we can predict the total download time.
|
// the progress bar, and we can predict the total download time.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
_start_dl_instance_tick = GetTickCount();
|
_start_dl_tick = GetTickCount();
|
||||||
#else
|
#else
|
||||||
gettimeofday(&_start_dl_instance_timeval, NULL);
|
gettimeofday(&_start_dl_timeval, NULL);
|
||||||
#endif
|
#endif
|
||||||
_show_dl_instance_progress = false;
|
_show_dl_instance_progress = false;
|
||||||
|
|
||||||
@ -459,9 +459,9 @@ make_p3d_stream(const string &p3d_url) {
|
|||||||
// Mark the time we started downloading, so we'll know when to reveal
|
// Mark the time we started downloading, so we'll know when to reveal
|
||||||
// the progress bar.
|
// the progress bar.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
_start_dl_instance_tick = GetTickCount();
|
_start_dl_tick = GetTickCount();
|
||||||
#else
|
#else
|
||||||
gettimeofday(&_start_dl_instance_timeval, NULL);
|
gettimeofday(&_start_dl_timeval, NULL);
|
||||||
#endif
|
#endif
|
||||||
_show_dl_instance_progress = false;
|
_show_dl_instance_progress = false;
|
||||||
|
|
||||||
@ -2758,6 +2758,14 @@ ready_to_install() {
|
|||||||
_download_package_index = 0;
|
_download_package_index = 0;
|
||||||
_total_downloaded = 0;
|
_total_downloaded = 0;
|
||||||
|
|
||||||
|
// Record the time we started the package download, so we can
|
||||||
|
// report downlaodElapsedTime and predict downloadRemainingTime.
|
||||||
|
#ifdef _WIN32
|
||||||
|
_start_dl_tick = GetTickCount();
|
||||||
|
#else
|
||||||
|
gettimeofday(&_start_dl_timeval, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
nout << "Beginning install of " << _downloading_packages.size()
|
nout << "Beginning install of " << _downloading_packages.size()
|
||||||
<< " packages, total " << _total_download_size
|
<< " packages, total " << _total_download_size
|
||||||
<< " bytes required.\n";
|
<< " bytes required.\n";
|
||||||
@ -2914,12 +2922,12 @@ report_instance_progress(double progress, bool is_progress_known,
|
|||||||
// instance file might be already in the browser cache).
|
// instance file might be already in the browser cache).
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int now = GetTickCount();
|
int now = GetTickCount();
|
||||||
double elapsed = (double)(now - _start_dl_instance_tick) * 0.001;
|
double elapsed = (double)(now - _start_dl_tick) * 0.001;
|
||||||
#else
|
#else
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
double elapsed = (double)(now.tv_sec - _start_dl_instance_timeval.tv_sec) +
|
double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) +
|
||||||
(double)(now.tv_usec - _start_dl_instance_timeval.tv_usec) / 1000000.0;
|
(double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Put up the progress bar after 2 seconds have elapsed, if we've
|
// Put up the progress bar after 2 seconds have elapsed, if we've
|
||||||
@ -2984,12 +2992,12 @@ report_package_progress(P3DPackage *package, double progress) {
|
|||||||
// Get the floating-point elapsed time.
|
// Get the floating-point elapsed time.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int now = GetTickCount();
|
int now = GetTickCount();
|
||||||
double elapsed = (double)(now - _start_dl_instance_tick) * 0.001;
|
double elapsed = (double)(now - _start_dl_tick) * 0.001;
|
||||||
#else
|
#else
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
double elapsed = (double)(now.tv_sec - _start_dl_instance_timeval.tv_sec) +
|
double elapsed = (double)(now.tv_sec - _start_dl_timeval.tv_sec) +
|
||||||
(double)(now.tv_usec - _start_dl_instance_timeval.tv_usec) / 1000000.0;
|
(double)(now.tv_usec - _start_dl_timeval.tv_usec) / 1000000.0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int ielapsed = (int)elapsed;
|
int ielapsed = (int)elapsed;
|
||||||
|
@ -329,13 +329,17 @@ private:
|
|||||||
bool _instance_window_attached;
|
bool _instance_window_attached;
|
||||||
bool _stuff_to_download;
|
bool _stuff_to_download;
|
||||||
|
|
||||||
// Members for deciding whether and when to display the progress bar
|
// Keep track of when the download was started, for reporting
|
||||||
// for downloading the initial instance data.
|
// purposes. These members are used both for the instance download,
|
||||||
|
// and for the later package download.
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int _start_dl_instance_tick;
|
int _start_dl_tick;
|
||||||
#else
|
#else
|
||||||
struct timeval _start_dl_instance_timeval;
|
struct timeval _start_dl_timeval;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This is set false initially, but true if the instance download
|
||||||
|
// continues for more than a couple of seconds.
|
||||||
bool _show_dl_instance_progress;
|
bool _show_dl_instance_progress;
|
||||||
|
|
||||||
typedef vector<P3DPackage *> Packages;
|
typedef vector<P3DPackage *> Packages;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user