mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
[HTML5] Export process writes sizes in template.
This allow the loading bar to be much more reliable, even in cases where realible stream loading status is not detectable (server-side compression, chunked encoding).
This commit is contained in:
parent
272e491f52
commit
cb1b89dac5
4 changed files with 47 additions and 26 deletions
|
|
@ -43,9 +43,9 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un
|
|||
}), { headers: response.headers });
|
||||
}
|
||||
|
||||
function loadFetch(file, tracker, raw) {
|
||||
function loadFetch(file, tracker, fileSize, raw) {
|
||||
tracker[file] = {
|
||||
total: 0,
|
||||
total: fileSize || 0,
|
||||
loaded: 0,
|
||||
done: false,
|
||||
};
|
||||
|
|
@ -117,16 +117,16 @@ const Preloader = /** @constructor */ function () { // eslint-disable-line no-un
|
|||
progressFunc = callback;
|
||||
};
|
||||
|
||||
this.loadPromise = function (file, raw = false) {
|
||||
return retry(loadFetch.bind(null, file, loadingFiles, raw), DOWNLOAD_ATTEMPTS_MAX);
|
||||
this.loadPromise = function (file, fileSize, raw = false) {
|
||||
return retry(loadFetch.bind(null, file, loadingFiles, fileSize, raw), DOWNLOAD_ATTEMPTS_MAX);
|
||||
};
|
||||
|
||||
this.preloadedFiles = [];
|
||||
this.preload = function (pathOrBuffer, destPath) {
|
||||
this.preload = function (pathOrBuffer, destPath, fileSize) {
|
||||
let buffer = null;
|
||||
if (typeof pathOrBuffer === 'string') {
|
||||
const me = this;
|
||||
return this.loadPromise(pathOrBuffer).then(function (buf) {
|
||||
return this.loadPromise(pathOrBuffer, fileSize).then(function (buf) {
|
||||
me.preloadedFiles.push({
|
||||
path: destPath || pathOrBuffer,
|
||||
buffer: buf,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue