mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Improve loading screen
This commit is contained in:
@@ -234,6 +234,14 @@ export class GameState {
|
||||
return MUSIC.menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should return whether to clear the whole body content before entering the state.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
getRemovePreviousContent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
//// INTERNAL ////
|
||||
|
||||
@@ -81,11 +81,16 @@ export class StateManager {
|
||||
this.currentState.internalRegisterCallback(this, this.app);
|
||||
|
||||
// Clean up old elements
|
||||
removeAllChildren(document.body);
|
||||
if (this.currentState.getRemovePreviousContent()) {
|
||||
removeAllChildren(document.body);
|
||||
}
|
||||
|
||||
document.body.className = "gameState " + (this.currentState.getHasFadeIn() ? "" : "arrived");
|
||||
document.body.id = "state_" + key;
|
||||
document.body.innerHTML = this.currentState.internalGetFullHtml();
|
||||
|
||||
if (this.currentState.getRemovePreviousContent()) {
|
||||
document.body.innerHTML = this.currentState.internalGetFullHtml();
|
||||
}
|
||||
|
||||
const dialogParent = document.createElement("div");
|
||||
dialogParent.classList.add("modalDialogParent");
|
||||
|
||||
@@ -35,26 +35,17 @@ export class PreloadState extends GameState {
|
||||
return false;
|
||||
}
|
||||
|
||||
getRemovePreviousContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
onEnter() {
|
||||
this.htmlElement.classList.add("prefab_LoadingState");
|
||||
|
||||
const elementsToRemove = ["#loadingPreload", "#fontPreload"];
|
||||
for (let i = 0; i < elementsToRemove.length; ++i) {
|
||||
const elem = document.querySelector(elementsToRemove[i]);
|
||||
if (elem) {
|
||||
elem.remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.dialogs = new HUDModalDialogs(null, this.app);
|
||||
const dialogsElement = document.body.querySelector(".modalDialogParent");
|
||||
this.dialogs.initializeToElement(dialogsElement);
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
this.statusText = this.htmlElement.querySelector(".loadingStatus > .desc");
|
||||
|
||||
/** @type {HTMLElement} */
|
||||
this.hintsText = this.htmlElement.querySelector(".prefab_GameHint");
|
||||
this.hintsText = this.htmlElement.querySelector("#preload_ll_text");
|
||||
this.lastHintShown = -1000;
|
||||
this.nextHintDuration = 0;
|
||||
|
||||
@@ -286,11 +277,12 @@ export class PreloadState extends GameState {
|
||||
*/
|
||||
setStatus(text) {
|
||||
logger.log("✅ " + text);
|
||||
|
||||
if (G_CHINA_VERSION || G_WEGAME_VERSION) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
this.currentStatus = text;
|
||||
this.statusText.innerText = text;
|
||||
// this.statusText.innerText = text;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user