2020-05-09 14:45:23 +00:00
|
|
|
import { GameState } from "../core/game_state";
|
|
|
|
import { cachebust } from "../core/cachebust";
|
|
|
|
import { globalConfig } from "../core/config";
|
|
|
|
|
|
|
|
export class MainMenuState extends GameState {
|
|
|
|
constructor() {
|
|
|
|
super("MainMenuState");
|
|
|
|
}
|
|
|
|
|
|
|
|
getInnerHTML() {
|
|
|
|
return `
|
|
|
|
<div class="logo">
|
|
|
|
<img src="${cachebust("res/logo.png")}" alt="shapez.io Logo">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mainContainer">
|
|
|
|
<button class="playButton styledButton">Play</button>
|
|
|
|
</div>
|
2020-05-10 17:20:32 +00:00
|
|
|
|
|
|
|
<div class="footer">
|
|
|
|
|
|
|
|
<a href="https://github.com/tobspr/shapez.io" target="_blank">
|
|
|
|
<span class="thirdpartyLogo githubLogo"></span>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<a href="https://discord.gg/HN7EVzV" target="_blank">
|
|
|
|
<span class="thirdpartyLogo discordLogo"></span>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
2020-05-09 14:45:23 +00:00
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
onBackButton() {
|
|
|
|
this.app.platformWrapper.exitApp();
|
|
|
|
}
|
|
|
|
|
|
|
|
onEnter(payload) {
|
|
|
|
if (payload.loadError) {
|
|
|
|
alert("Error while loading game: " + payload.loadError);
|
|
|
|
}
|
|
|
|
|
|
|
|
const qs = this.htmlElement.querySelector.bind(this.htmlElement);
|
|
|
|
this.trackClicks(qs(".mainContainer .playButton"), this.onPlayButtonClicked);
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.fastGameEnter) {
|
|
|
|
this.onPlayButtonClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onPlayButtonClicked() {
|
|
|
|
const savegame = this.app.savegameMgr.createNewSavegame();
|
|
|
|
|
|
|
|
this.app.analytics.trackUiClick("startgame");
|
|
|
|
this.moveToState("InGameState", {
|
|
|
|
savegame,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onLeave() {
|
|
|
|
// this.dialogs.cleanup();
|
|
|
|
}
|
|
|
|
}
|