mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Added continue button
This commit is contained in:
parent
64f772a594
commit
ef3d492b41
@ -244,6 +244,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
.continueButton {
|
||||
@include SuperHeading;
|
||||
@include S(min-width, 130px);
|
||||
@include S(padding, 15px, 20px);
|
||||
@include S(margin-top, 15px);
|
||||
letter-spacing: 0.3em !important;
|
||||
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
background-color: $colorGreenBright;
|
||||
transition: transform 0.12s ease-in-out;
|
||||
&:hover {
|
||||
transform: scale(1.02);
|
||||
}
|
||||
}
|
||||
|
||||
.importButton {
|
||||
@include S(margin-top, 15px);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { cachebust } from "../core/cachebust";
|
||||
import { globalConfig, IS_DEBUG, IS_DEMO, THIRDPARTY_URLS } from "../core/config";
|
||||
import {
|
||||
makeDiv,
|
||||
makeButton,
|
||||
formatSecondsToTimeAgo,
|
||||
generateFileDownload,
|
||||
waitNextFrame,
|
||||
@ -330,9 +331,17 @@ export class MainMenuState extends GameState {
|
||||
const oldContainer = this.htmlElement.querySelector(".mainContainer .savegames");
|
||||
if (oldContainer) {
|
||||
oldContainer.remove();
|
||||
this.htmlElement.querySelector(".mainContainer .continueButton").remove();
|
||||
}
|
||||
const games = this.app.savegameMgr.getSavegamesMetaData();
|
||||
if (games.length > 0) {
|
||||
const continueButton = makeButton(
|
||||
this.htmlElement.querySelector(".mainContainer"),
|
||||
["continueButton", "styledButton"],
|
||||
T.mainMenu.continue
|
||||
);
|
||||
this.trackClicks(continueButton, this.onContinueButtonClicked);
|
||||
|
||||
const parent = makeDiv(this.htmlElement.querySelector(".mainContainer"), null, ["savegames"]);
|
||||
|
||||
for (let i = 0; i < games.length; ++i) {
|
||||
@ -463,6 +472,24 @@ export class MainMenuState extends GameState {
|
||||
});
|
||||
}
|
||||
|
||||
onContinueButtonClicked() {
|
||||
let latestLastUpdate = 0;
|
||||
let latestInternalId;
|
||||
this.app.savegameMgr.currentData.savegames.forEach(saveGame => {
|
||||
if (saveGame.lastUpdate > latestLastUpdate) {
|
||||
latestLastUpdate = saveGame.lastUpdate;
|
||||
latestInternalId = saveGame.internalId;
|
||||
}
|
||||
});
|
||||
|
||||
const savegame = this.app.savegameMgr.getSavegameById(latestInternalId);
|
||||
savegame.readAsync().then(() => {
|
||||
this.moveToState("InGameState", {
|
||||
savegame,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
onLeave() {
|
||||
this.dialogs.cleanup();
|
||||
}
|
||||
|
@ -118,6 +118,7 @@ demoBanners:
|
||||
|
||||
mainMenu:
|
||||
play: Play
|
||||
continue: Continue
|
||||
changelog: Changelog
|
||||
importSavegame: Import
|
||||
openSourceHint: This game is open source!
|
||||
|
Loading…
Reference in New Issue
Block a user