diff --git a/src/css/states/main_menu.scss b/src/css/states/main_menu.scss index ff6ee607..a6ba4473 100644 --- a/src/css/states/main_menu.scss +++ b/src/css/states/main_menu.scss @@ -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); } diff --git a/src/js/states/main_menu.js b/src/js/states/main_menu.js index 101bbcd6..3f137b5c 100644 --- a/src/js/states/main_menu.js +++ b/src/js/states/main_menu.js @@ -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(); } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index ab054e32..0a6470b2 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -118,6 +118,7 @@ demoBanners: mainMenu: play: Play + continue: Continue changelog: Changelog importSavegame: Import openSourceHint: This game is open source!