|
|
@ -3,6 +3,8 @@ import { createLogger } from "../core/logging";
|
|
|
|
import { findNiceValue, waitNextFrame } from "../core/utils";
|
|
|
|
import { findNiceValue, waitNextFrame } from "../core/utils";
|
|
|
|
import { cachebust } from "../core/cachebust";
|
|
|
|
import { cachebust } from "../core/cachebust";
|
|
|
|
import { PlatformWrapperImplBrowser } from "../platform/browser/wrapper";
|
|
|
|
import { PlatformWrapperImplBrowser } from "../platform/browser/wrapper";
|
|
|
|
|
|
|
|
import { T } from "../translations";
|
|
|
|
|
|
|
|
import { HUDModalDialogs } from "../game/hud/parts/modal_dialogs";
|
|
|
|
|
|
|
|
|
|
|
|
const logger = createLogger("state/preload");
|
|
|
|
const logger = createLogger("state/preload");
|
|
|
|
|
|
|
|
|
|
|
@ -44,9 +46,9 @@ export class PreloadState extends GameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this.dialogs = new HUDModalDialogs(null, this.app);
|
|
|
|
this.dialogs = new HUDModalDialogs(null, this.app);
|
|
|
|
// const dialogsElement = document.body.querySelector(".modalDialogParent");
|
|
|
|
const dialogsElement = document.body.querySelector(".modalDialogParent");
|
|
|
|
// this.dialogs.initializeToElement(dialogsElement);
|
|
|
|
this.dialogs.initializeToElement(dialogsElement);
|
|
|
|
|
|
|
|
|
|
|
|
this.statusText = this.htmlElement.querySelector(".loadingStatus > .desc");
|
|
|
|
this.statusText = this.htmlElement.querySelector(".loadingStatus > .desc");
|
|
|
|
this.statusBar = this.htmlElement.querySelector(".loadingStatus > .bar > .inner");
|
|
|
|
this.statusBar = this.htmlElement.querySelector(".loadingStatus > .bar > .inner");
|
|
|
@ -64,6 +66,42 @@ export class PreloadState extends GameState {
|
|
|
|
startLoading() {
|
|
|
|
startLoading() {
|
|
|
|
this.setStatus("Booting")
|
|
|
|
this.setStatus("Booting")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.then(() => this.setStatus("Checking for updates"))
|
|
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
|
|
if (G_IS_STANDALONE || true) {
|
|
|
|
|
|
|
|
return Promise.race([
|
|
|
|
|
|
|
|
new Promise(resolve => setTimeout(resolve, 10000)),
|
|
|
|
|
|
|
|
fetch(
|
|
|
|
|
|
|
|
"https://itch.io/api/1/x/wharf/latest?target=tobspr/shapezio&channel_name=windows",
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cache: "no-cache",
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
.then(res => res.json())
|
|
|
|
|
|
|
|
.then(({ latest }) => {
|
|
|
|
|
|
|
|
if (latest !== G_BUILD_VERSION) {
|
|
|
|
|
|
|
|
const { ok, viewUpdate } = this.dialogs.showInfo(
|
|
|
|
|
|
|
|
T.dialogs.newUpdate.title,
|
|
|
|
|
|
|
|
T.dialogs.newUpdate.desc,
|
|
|
|
|
|
|
|
["ok:good", "viewUpdate:good"]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
|
|
ok.add(resolve);
|
|
|
|
|
|
|
|
viewUpdate.add(() => {
|
|
|
|
|
|
|
|
window.open("https://tobspr.itch.io/shapezio", "_blank");
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(err => {
|
|
|
|
|
|
|
|
logger.log("Failed to fetch version:", err);
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
.then(() => this.setStatus("Creating platform wrapper"))
|
|
|
|
.then(() => this.setStatus("Creating platform wrapper"))
|
|
|
|
.then(() => this.app.platformWrapper.initialize())
|
|
|
|
.then(() => this.app.platformWrapper.initialize())
|
|
|
|
|
|
|
|
|
|
|
|