|
|
|
import { cachebust } from "../core/cachebust";
|
|
|
|
import { A_B_TESTING_LINK_TYPE, globalConfig, THIRDPARTY_URLS } from "../core/config";
|
|
|
|
import { GameState } from "../core/game_state";
|
|
|
|
import { DialogWithForm } from "../core/modal_dialog_elements";
|
|
|
|
import { FormElementInput } from "../core/modal_dialog_forms";
|
|
|
|
import { ReadWriteProxy } from "../core/read_write_proxy";
|
|
|
|
import {
|
|
|
|
formatSecondsToTimeAgo,
|
|
|
|
generateFileDownload,
|
|
|
|
isSupportedBrowser,
|
|
|
|
makeButton,
|
|
|
|
makeButtonElement,
|
|
|
|
makeDiv,
|
|
|
|
removeAllChildren,
|
|
|
|
startFileChoose,
|
|
|
|
waitNextFrame,
|
|
|
|
} from "../core/utils";
|
|
|
|
import { HUDModalDialogs } from "../game/hud/parts/modal_dialogs";
|
|
|
|
import { getApplicationSettingById } from "../profile/application_settings";
|
|
|
|
import { T } from "../translations";
|
|
|
|
|
|
|
|
const trim = require("trim");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @typedef {import("../savegame/savegame_typedefs").SavegameMetadata} SavegameMetadata
|
|
|
|
* @typedef {import("../profile/setting_types").EnumSetting} EnumSetting
|
|
|
|
*/
|
|
|
|
|
|
|
|
export class MainMenuState extends GameState {
|
|
|
|
constructor() {
|
|
|
|
super("MainMenuState");
|
|
|
|
}
|
|
|
|
|
|
|
|
getInnerHTML() {
|
|
|
|
const bannerHtml = `
|
|
|
|
<h3>${T.demoBanners.title}</h3>
|
|
|
|
<p>${T.demoBanners.intro}</p>
|
|
|
|
<a href="#" class="steamLink ${A_B_TESTING_LINK_TYPE}" target="_blank">Get the shapez.io standalone!</a>
|
|
|
|
`;
|
|
|
|
|
|
|
|
const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive();
|
|
|
|
|
|
|
|
return `
|
|
|
|
<div class="topButtons">
|
|
|
|
${
|
|
|
|
G_CHINA_VERSION
|
|
|
|
? ""
|
|
|
|
: `<button class="languageChoose" data-languageicon="${this.app.settings.getLanguage()}"></button>`
|
|
|
|
}
|
|
|
|
|
|
|
|
<button class="settingsButton"></button>
|
|
|
|
${
|
|
|
|
G_IS_STANDALONE || G_IS_DEV
|
|
|
|
? `
|
|
|
|
<button class="exitAppButton"></button>
|
|
|
|
`
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<video autoplay muted loop class="fullscreenBackgroundVideo">
|
|
|
|
<source src="${cachebust("res/bg_render.webm")}" type="video/webm">
|
|
|
|
</video>
|
|
|
|
|
|
|
|
<div class="logo">
|
|
|
|
<img src="${cachebust(
|
|
|
|
G_CHINA_VERSION ? "res/logo_cn.png" : "res/logo.png"
|
|
|
|
)}" alt="shapez.io Logo">
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
<span class="updateLabel">v${G_BUILD_VERSION} - Puzzle DLC!</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mainWrapper ${showDemoBadges ? "demo" : "noDemo"}" data-columns="${
|
|
|
|
G_IS_STANDALONE ? 2 : showDemoBadges ? 2 : 1
|
|
|
|
}">
|
|
|
|
<div class="sideContainer">
|
|
|
|
${showDemoBadges ? `<div class="standaloneBanner">${bannerHtml}</div>` : ""}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="mainContainer">
|
|
|
|
${
|
|
|
|
isSupportedBrowser()
|
|
|
|
? ""
|
|
|
|
: `<div class="browserWarning">${T.mainMenu.browserWarning}</div>`
|
|
|
|
}
|
|
|
|
<div class="buttons"></div>
|
|
|
|
</div>
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
|
|
|
|
${
|
|
|
|
// @TODO: Only display if DLC is owned, otherwise show ad for store page
|
|
|
|
G_IS_STANDALONE && false
|
|
|
|
? `
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
<div class="puzzleContainer">
|
|
|
|
<img class="dlcLogo" src="${cachebust(
|
|
|
|
"res/puzzle_dlc_logo.png"
|
|
|
|
)}" alt="shapez.io Logo">
|
|
|
|
<button class="styledButton puzzleDlcPlayButton">Play</button>
|
|
|
|
</div>`
|
|
|
|
: ""
|
|
|
|
}
|
|
|
|
|
|
|
|
${
|
|
|
|
// @TODO: Only display if DLC is owned, otherwise show ad for store page
|
|
|
|
G_IS_STANDALONE && true
|
|
|
|
? `
|
|
|
|
<div class="puzzleContainer notOwned">
|
|
|
|
<img class="dlcLogo" src="${cachebust(
|
|
|
|
"res/puzzle_dlc_logo.png"
|
|
|
|
)}" alt="shapez.io Logo">
|
|
|
|
<p>${T.mainMenu.puzzleDlcText}</p>
|
|
|
|
<button class="styledButton puzzleDlcGetButton">${
|
|
|
|
T.mainMenu.puzzleDlcWishlist
|
|
|
|
}</button>
|
|
|
|
</div>`
|
|
|
|
: ""
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="footer ${G_CHINA_VERSION ? "china" : ""}">
|
|
|
|
|
|
|
|
${
|
|
|
|
G_CHINA_VERSION
|
|
|
|
? ""
|
|
|
|
: `
|
|
|
|
<a class="githubLink boxLink" target="_blank">
|
|
|
|
${T.mainMenu.openSourceHint}
|
|
|
|
<span class="thirdpartyLogo githubLogo"></span>
|
|
|
|
</a>`
|
|
|
|
}
|
|
|
|
|
|
|
|
<a class="discordLink boxLink" target="_blank">
|
|
|
|
${T.mainMenu.discordLink}
|
|
|
|
<span class="thirdpartyLogo discordLogo"></span>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<div class="sidelinks">
|
|
|
|
${G_CHINA_VERSION ? "" : `<a class="redditLink">${T.mainMenu.subreddit}</a>`}
|
|
|
|
|
|
|
|
${G_CHINA_VERSION ? "" : `<a class="changelog">${T.changelog.title}</a>`}
|
|
|
|
|
|
|
|
${G_CHINA_VERSION ? "" : `<a class="helpTranslate">${T.mainMenu.helpTranslate}</a>`}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="author">${T.mainMenu.madeBy.replace(
|
|
|
|
"<author-link>",
|
|
|
|
'<a class="producerLink" target="_blank">Tobias Springer</a>'
|
|
|
|
)}</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks the user to import a savegame
|
|
|
|
*/
|
|
|
|
requestImportSavegame() {
|
|
|
|
if (
|
|
|
|
this.app.savegameMgr.getSavegamesMetaData().length > 0 &&
|
|
|
|
!this.app.restrictionMgr.getHasUnlimitedSavegames()
|
|
|
|
) {
|
|
|
|
this.app.analytics.trackUiClick("importgame_slot_limit_show");
|
|
|
|
this.showSavegameSlotLimit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a 'fake' file-input to accept savegames
|
|
|
|
startFileChoose(".bin").then(file => {
|
|
|
|
if (file) {
|
|
|
|
const closeLoader = this.dialogs.showLoadingDialog();
|
|
|
|
waitNextFrame().then(() => {
|
|
|
|
this.app.analytics.trackUiClick("import_savegame");
|
|
|
|
const reader = new FileReader();
|
|
|
|
reader.addEventListener("load", event => {
|
|
|
|
const contents = event.target.result;
|
|
|
|
let realContent;
|
|
|
|
|
|
|
|
try {
|
|
|
|
realContent = ReadWriteProxy.deserializeObject(contents);
|
|
|
|
} catch (err) {
|
|
|
|
closeLoader();
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.importSavegameError.title,
|
|
|
|
T.dialogs.importSavegameError.text + "<br><br>" + err
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.app.savegameMgr.importSavegame(realContent).then(
|
|
|
|
() => {
|
|
|
|
closeLoader();
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.importSavegameSuccess.title,
|
|
|
|
T.dialogs.importSavegameSuccess.text
|
|
|
|
);
|
|
|
|
|
|
|
|
this.renderMainMenu();
|
|
|
|
this.renderSavegames();
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
closeLoader();
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.importSavegameError.title,
|
|
|
|
T.dialogs.importSavegameError.text + ":<br><br>" + err
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
reader.addEventListener("error", error => {
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.importSavegameError.title,
|
|
|
|
T.dialogs.importSavegameError.text + ":<br><br>" + error
|
|
|
|
);
|
|
|
|
});
|
|
|
|
reader.readAsText(file, "utf-8");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onBackButton() {
|
|
|
|
this.app.platformWrapper.exitApp();
|
|
|
|
}
|
|
|
|
|
|
|
|
onEnter(payload) {
|
|
|
|
this.dialogs = new HUDModalDialogs(null, this.app);
|
|
|
|
const dialogsElement = document.body.querySelector(".modalDialogParent");
|
|
|
|
this.dialogs.initializeToElement(dialogsElement);
|
|
|
|
|
|
|
|
if (payload.loadError) {
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.gameLoadFailure.title,
|
|
|
|
T.dialogs.gameLoadFailure.text + "<br><br>" + payload.loadError
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const qs = this.htmlElement.querySelector.bind(this.htmlElement);
|
|
|
|
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
if (G_IS_DEV && globalConfig.debug.testPuzzleMode) {
|
|
|
|
this.onPuzzleModeButtonClicked(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.fastGameEnter) {
|
|
|
|
const games = this.app.savegameMgr.getSavegamesMetaData();
|
|
|
|
if (games.length > 0 && globalConfig.debug.resumeGameOnFastEnter) {
|
|
|
|
this.resumeGame(games[0]);
|
|
|
|
} else {
|
|
|
|
this.onPlayButtonClicked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize video
|
|
|
|
this.videoElement = this.htmlElement.querySelector("video");
|
|
|
|
this.videoElement.playbackRate = 0.9;
|
|
|
|
this.videoElement.addEventListener("canplay", () => {
|
|
|
|
if (this.videoElement) {
|
|
|
|
this.videoElement.classList.add("loaded");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.trackClicks(qs(".settingsButton"), this.onSettingsButtonClicked);
|
|
|
|
|
|
|
|
if (!G_CHINA_VERSION) {
|
|
|
|
this.trackClicks(qs(".languageChoose"), this.onLanguageChooseClicked);
|
|
|
|
this.trackClicks(qs(".redditLink"), this.onRedditClicked);
|
|
|
|
this.trackClicks(qs(".changelog"), this.onChangelogClicked);
|
|
|
|
this.trackClicks(qs(".helpTranslate"), this.onTranslationHelpLinkClicked);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_IS_STANDALONE) {
|
|
|
|
this.trackClicks(qs(".exitAppButton"), this.onExitAppButtonClicked);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.renderMainMenu();
|
|
|
|
this.renderSavegames();
|
|
|
|
|
|
|
|
const steamLink = this.htmlElement.querySelector(".steamLink");
|
|
|
|
if (steamLink) {
|
|
|
|
this.trackClicks(steamLink, () => this.onSteamLinkClicked(), { preventClick: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
const discordLink = this.htmlElement.querySelector(".discordLink");
|
|
|
|
this.trackClicks(
|
|
|
|
discordLink,
|
|
|
|
() => {
|
|
|
|
this.app.analytics.trackUiClick("main_menu_link_discord");
|
|
|
|
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.discord);
|
|
|
|
},
|
|
|
|
{ preventClick: true }
|
|
|
|
);
|
|
|
|
|
|
|
|
const githubLink = this.htmlElement.querySelector(".githubLink");
|
|
|
|
if (githubLink) {
|
|
|
|
this.trackClicks(
|
|
|
|
githubLink,
|
|
|
|
() => {
|
|
|
|
this.app.analytics.trackUiClick("main_menu_link_github");
|
|
|
|
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.github);
|
|
|
|
},
|
|
|
|
{ preventClick: true }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const producerLink = this.htmlElement.querySelector(".producerLink");
|
|
|
|
this.trackClicks(producerLink, () => this.app.platformWrapper.openExternalLink("https://tobspr.io"), {
|
|
|
|
preventClick: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderMainMenu() {
|
|
|
|
const buttonContainer = this.htmlElement.querySelector(".mainContainer .buttons");
|
|
|
|
removeAllChildren(buttonContainer);
|
|
|
|
|
|
|
|
// Import button
|
|
|
|
const importButtonElement = makeButtonElement(
|
|
|
|
["importButton", "styledButton"],
|
|
|
|
T.mainMenu.importSavegame
|
|
|
|
);
|
|
|
|
this.trackClicks(importButtonElement, this.requestImportSavegame);
|
|
|
|
|
|
|
|
if (this.savedGames.length > 0) {
|
|
|
|
// Continue game
|
|
|
|
const continueButton = makeButton(
|
|
|
|
buttonContainer,
|
|
|
|
["continueButton", "styledButton"],
|
|
|
|
T.mainMenu.continue
|
|
|
|
);
|
|
|
|
this.trackClicks(continueButton, this.onContinueButtonClicked);
|
|
|
|
|
|
|
|
const outerDiv = makeDiv(buttonContainer, null, ["outer"], null);
|
|
|
|
outerDiv.appendChild(importButtonElement);
|
|
|
|
const newGameButton = makeButton(
|
|
|
|
this.htmlElement.querySelector(".mainContainer .outer"),
|
|
|
|
["newGameButton", "styledButton"],
|
|
|
|
T.mainMenu.newGame
|
|
|
|
);
|
|
|
|
this.trackClicks(newGameButton, this.onPlayButtonClicked);
|
|
|
|
} else {
|
|
|
|
// New game
|
|
|
|
const playBtn = makeButton(buttonContainer, ["playButton", "styledButton"], T.mainMenu.play);
|
|
|
|
this.trackClicks(playBtn, this.onPlayButtonClicked);
|
|
|
|
buttonContainer.appendChild(importButtonElement);
|
|
|
|
}
|
Puzzle DLC (#1172)
* Puzzle mode (#1135)
* Add mode button to main menu
* [WIP] Add mode menu. Add factory-based gameMode creation
* Add savefile migration, serialize, deserialize
* Add hidden HUD elements, zone, and zoom, boundary constraints
* Clean up lint issues
* Add building, HUD exclusion, building exclusion, and refactor
- [WIP] Add ConstantProducer building that combines ConstantSignal
and ItemProducer functionality. Currently using temp assets.
- Add pre-placement check to the zone
- Use Rectangles for zone and boundary
- Simplify zone drawing
- Account for exclusion in savegame data
- [WIP] Add puzzle play and edit buttons in puzzle mode menu
* [WIP] Add building, component, and systems for producing and
accepting user-specified items and checking goal criteria
* Add ingame puzzle mode UI elements
- Add minimal menus in puzzle mode for back, next navigation
- Add lower menu for changing zone dimenensions
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
* Performance optimizations (#1154)
* 1.3.1 preparations
* Minor fixes, update translations
* Fix achievements not working
* Lots of belt optimizations, ~15% performance boost
* Puzzle mode, part 1
* Puzzle mode, part 2
* Fix missing import
* Puzzle mode, part 3
* Fix typo
* Puzzle mode, part 4
* Puzzle Mode fixes: Correct zone restrictions and more (#1155)
* Hide Puzzle Editor Controls in regular game mode, fix typo
* Disallow shrinking zone if there are buildings
* Fix multi-tile buildings for shrinking
* Puzzle mode, Refactor hud
* Puzzle mode
* Fixed typo in latest puzzle commit (#1156)
* Allow completing puzzles
* Puzzle mode, almost done
* Bump version to 1.4.0
* Fixes
* [puzzle] Prevent pipette cheats (miners, emitters) (#1158)
* Puzzle mode, almost done
* Allow clearing belts with 'B'
* Multiple users for the puzzle dlc
* Bump api key
* Minor adjustments
* Update
* Minor fixes
* Fix throughput
* Fix belts
* Minor puzzle adjustments
* New difficulty
* Minor puzzle improvements
* Fix belt path
* Update translations
* Added a button to return to the menu after a puzzle is completed (#1170)
* added another button to return to the menu
* improved menu return
* fixed continue button to not go back to menu
* [Puzzle] Added ability to lock buildings in the puzzle editor! (#1164)
* initial test
* tried to get it to work
* added icon
* added test exclusion
* reverted css
* completed flow for building locking
* added lock option
* finalized look and changed locked building to same sprite
* removed unused art
* added clearing every goal acceptor on lock to prevent creating impossible puzzles
* heavily improved validation and prevented autocompletion
* validation only checks every 100 ticks to improve performance
* validation only checks every 100 ticks to improve performance
* removed clearing goal acceptors as it isn't needed because of validation
* Add soundtrack, puzzle dlc fixes
Co-authored-by: Greg Considine <gconsidine@users.noreply.github.com>
Co-authored-by: dengr1065 <dengr1065@gmail.com>
Co-authored-by: Sense101 <67970865+Sense101@users.noreply.github.com>
3 years ago
|
|
|
|
|
|
|
const puzzleModeButton = this.htmlElement.querySelector(".puzzleDlcPlayButton");
|
|
|
|
if (puzzleModeButton) {
|
|
|
|
this.trackClicks(puzzleModeButton, () => this.onPuzzleModeButtonClicked());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onPuzzleModeButtonClicked(force = false) {
|
|
|
|
const hasUnlockedBlueprints = this.app.savegameMgr.getSavegamesMetaData().some(s => s.level >= 12);
|
|
|
|
console.log(hasUnlockedBlueprints);
|
|
|
|
if (!force && !hasUnlockedBlueprints) {
|
|
|
|
const { ok } = this.dialogs.showWarning(
|
|
|
|
T.dialogs.puzzlePlayRegularRecommendation.title,
|
|
|
|
T.dialogs.puzzlePlayRegularRecommendation.desc,
|
|
|
|
["cancel:good", "ok:bad:timeout"]
|
|
|
|
);
|
|
|
|
ok.add(() => this.onPuzzleModeButtonClicked(true));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.moveToState("LoginState", {
|
|
|
|
nextStateId: "PuzzleMenuState",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onBackButtonClicked() {
|
|
|
|
this.renderMainMenu();
|
|
|
|
this.renderSavegames();
|
|
|
|
}
|
|
|
|
|
|
|
|
onSteamLinkClicked() {
|
|
|
|
this.app.analytics.trackUiClick("main_menu_steam_link_" + A_B_TESTING_LINK_TYPE);
|
|
|
|
this.app.platformWrapper.openExternalLink(
|
|
|
|
THIRDPARTY_URLS.standaloneStorePage + "?ref=mmsl2&prc=" + A_B_TESTING_LINK_TYPE
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
onExitAppButtonClicked() {
|
|
|
|
this.app.platformWrapper.exitApp();
|
|
|
|
}
|
|
|
|
|
|
|
|
onChangelogClicked() {
|
|
|
|
this.moveToState("ChangelogState");
|
|
|
|
}
|
|
|
|
|
|
|
|
onRedditClicked() {
|
|
|
|
this.app.analytics.trackUiClick("main_menu_reddit_link");
|
|
|
|
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.reddit);
|
|
|
|
}
|
|
|
|
|
|
|
|
onLanguageChooseClicked() {
|
|
|
|
this.app.analytics.trackUiClick("choose_language");
|
|
|
|
const setting = /** @type {EnumSetting} */ (getApplicationSettingById("language"));
|
|
|
|
|
|
|
|
const { optionSelected } = this.dialogs.showOptionChooser(T.settings.labels.language.title, {
|
|
|
|
active: this.app.settings.getLanguage(),
|
|
|
|
options: setting.options.map(option => ({
|
|
|
|
value: setting.valueGetter(option),
|
|
|
|
text: setting.textGetter(option),
|
|
|
|
desc: setting.descGetter(option),
|
|
|
|
iconPrefix: setting.iconPrefix,
|
|
|
|
})),
|
|
|
|
});
|
|
|
|
|
|
|
|
optionSelected.add(value => {
|
|
|
|
this.app.settings.updateLanguage(value).then(() => {
|
|
|
|
if (setting.restartRequired) {
|
|
|
|
if (this.app.platformWrapper.getSupportsRestart()) {
|
|
|
|
this.app.platformWrapper.performRestart();
|
|
|
|
} else {
|
|
|
|
this.dialogs.showInfo(
|
|
|
|
T.dialogs.restartRequired.title,
|
|
|
|
T.dialogs.restartRequired.text,
|
|
|
|
["ok:good"]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setting.changeCb) {
|
|
|
|
setting.changeCb(this.app, value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Update current icon
|
|
|
|
this.htmlElement.querySelector("button.languageChoose").setAttribute("data-languageIcon", value);
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
get savedGames() {
|
|
|
|
return this.app.savegameMgr.getSavegamesMetaData();
|
|
|
|
}
|
|
|
|
|
|
|
|
renderSavegames() {
|
|
|
|
const oldContainer = this.htmlElement.querySelector(".mainContainer .savegames");
|
|
|
|
if (oldContainer) {
|
|
|
|
oldContainer.remove();
|
|
|
|
}
|
|
|
|
const games = this.savedGames;
|
|
|
|
if (games.length > 0) {
|
|
|
|
const parent = makeDiv(this.htmlElement.querySelector(".mainContainer"), null, ["savegames"]);
|
|
|
|
|
|
|
|
for (let i = 0; i < games.length; ++i) {
|
|
|
|
const elem = makeDiv(parent, null, ["savegame"]);
|
|
|
|
|
|
|
|
makeDiv(
|
|
|
|
elem,
|
|
|
|
null,
|
|
|
|
["playtime"],
|
|
|
|
formatSecondsToTimeAgo((new Date().getTime() - games[i].lastUpdate) / 1000.0)
|
|
|
|
);
|
|
|
|
|
|
|
|
makeDiv(
|
|
|
|
elem,
|
|
|
|
null,
|
|
|
|
["level"],
|
|
|
|
games[i].level
|
|
|
|
? T.mainMenu.savegameLevel.replace("<x>", "" + games[i].level)
|
|
|
|
: T.mainMenu.savegameLevelUnknown
|
|
|
|
);
|
|
|
|
|
|
|
|
const name = makeDiv(
|
|
|
|
elem,
|
|
|
|
null,
|
|
|
|
["name"],
|
|
|
|
"<span>" + (games[i].name ? games[i].name : T.mainMenu.savegameUnnamed) + "</span>"
|
|
|
|
);
|
|
|
|
|
|
|
|
const deleteButton = document.createElement("button");
|
|
|
|
deleteButton.classList.add("styledButton", "deleteGame");
|
|
|
|
elem.appendChild(deleteButton);
|
|
|
|
|
|
|
|
const downloadButton = document.createElement("button");
|
|
|
|
downloadButton.classList.add("styledButton", "downloadGame");
|
|
|
|
elem.appendChild(downloadButton);
|
|
|
|
|
|
|
|
const renameButton = document.createElement("button");
|
|
|
|
renameButton.classList.add("styledButton", "renameGame");
|
|
|
|
name.appendChild(renameButton);
|
|
|
|
|
|
|
|
const resumeButton = document.createElement("button");
|
|
|
|
resumeButton.classList.add("styledButton", "resumeGame");
|
|
|
|
elem.appendChild(resumeButton);
|
|
|
|
|
|
|
|
this.trackClicks(deleteButton, () => this.deleteGame(games[i]));
|
|
|
|
this.trackClicks(downloadButton, () => this.downloadGame(games[i]));
|
|
|
|
this.trackClicks(resumeButton, () => this.resumeGame(games[i]));
|
|
|
|
this.trackClicks(renameButton, () => this.requestRenameSavegame(games[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {SavegameMetadata} game
|
|
|
|
*/
|
|
|
|
requestRenameSavegame(game) {
|
|
|
|
const regex = /^[a-zA-Z0-9_\- ]{1,20}$/;
|
|
|
|
|
|
|
|
const nameInput = new FormElementInput({
|
|
|
|
id: "nameInput",
|
|
|
|
label: null,
|
|
|
|
placeholder: "",
|
|
|
|
defaultValue: game.name || "",
|
|
|
|
validator: val => val.match(regex) && trim(val).length > 0,
|
|
|
|
});
|
|
|
|
const dialog = new DialogWithForm({
|
|
|
|
app: this.app,
|
|
|
|
title: T.dialogs.renameSavegame.title,
|
|
|
|
desc: T.dialogs.renameSavegame.desc,
|
|
|
|
formElements: [nameInput],
|
|
|
|
buttons: ["cancel:bad:escape", "ok:good:enter"],
|
|
|
|
});
|
|
|
|
this.dialogs.internalShowDialog(dialog);
|
|
|
|
|
|
|
|
// When confirmed, save the name
|
|
|
|
dialog.buttonSignals.ok.add(() => {
|
|
|
|
game.name = trim(nameInput.getValue());
|
|
|
|
this.app.savegameMgr.writeAsync();
|
|
|
|
this.renderSavegames();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {SavegameMetadata} game
|
|
|
|
*/
|
|
|
|
resumeGame(game) {
|
|
|
|
this.app.analytics.trackUiClick("resume_game");
|
|
|
|
|
|
|
|
this.app.adProvider.showVideoAd().then(() => {
|
|
|
|
this.app.analytics.trackUiClick("resume_game_adcomplete");
|
|
|
|
const savegame = this.app.savegameMgr.getSavegameById(game.internalId);
|
|
|
|
savegame
|
|
|
|
.readAsync()
|
|
|
|
.then(() => {
|
|
|
|
this.moveToState("InGameState", {
|
|
|
|
savegame,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.gameLoadFailure.title,
|
|
|
|
T.dialogs.gameLoadFailure.text + "<br><br>" + err
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {SavegameMetadata} game
|
|
|
|
*/
|
|
|
|
deleteGame(game) {
|
|
|
|
this.app.analytics.trackUiClick("delete_game");
|
|
|
|
|
|
|
|
const signals = this.dialogs.showWarning(
|
|
|
|
T.dialogs.confirmSavegameDelete.title,
|
|
|
|
T.dialogs.confirmSavegameDelete.text
|
|
|
|
.replace("<savegameName>", game.name || T.mainMenu.savegameUnnamed)
|
|
|
|
.replace("<savegameLevel>", String(game.level)),
|
|
|
|
["cancel:good", "delete:bad:timeout"]
|
|
|
|
);
|
|
|
|
|
|
|
|
signals.delete.add(() => {
|
|
|
|
this.app.savegameMgr.deleteSavegame(game).then(
|
|
|
|
() => {
|
|
|
|
this.renderSavegames();
|
|
|
|
if (this.savedGames.length <= 0) this.renderMainMenu();
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
this.dialogs.showWarning(
|
|
|
|
T.dialogs.savegameDeletionError.title,
|
|
|
|
T.dialogs.savegameDeletionError.text + "<br><br>" + err
|
|
|
|
);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {SavegameMetadata} game
|
|
|
|
*/
|
|
|
|
downloadGame(game) {
|
|
|
|
this.app.analytics.trackUiClick("download_game");
|
|
|
|
|
|
|
|
const savegame = this.app.savegameMgr.getSavegameById(game.internalId);
|
|
|
|
savegame.readAsync().then(() => {
|
|
|
|
const data = ReadWriteProxy.serializeObject(savegame.currentData);
|
|
|
|
const filename = (game.name || "unnamed") + ".bin";
|
|
|
|
generateFileDownload(filename, data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a hint that the slot limit has been reached
|
|
|
|
*/
|
|
|
|
showSavegameSlotLimit() {
|
|
|
|
const { getStandalone } = this.dialogs.showWarning(
|
|
|
|
T.dialogs.oneSavegameLimit.title,
|
|
|
|
T.dialogs.oneSavegameLimit.desc,
|
|
|
|
["cancel:bad", "getStandalone:good"]
|
|
|
|
);
|
|
|
|
getStandalone.add(() => {
|
|
|
|
this.app.analytics.trackUiClick("visit_steampage_from_slot_limit");
|
|
|
|
this.app.platformWrapper.openExternalLink(THIRDPARTY_URLS.standaloneStorePage + "?reF=ssll");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onSettingsButtonClicked() {
|
|
|
|
this.moveToState("SettingsState");
|
|
|
|
}
|
|
|
|
|
|
|
|
onTranslationHelpLinkClicked() {
|
|
|
|
this.app.analytics.trackUiClick("translation_help_link");
|
|
|
|
this.app.platformWrapper.openExternalLink(
|
|
|
|
"https://github.com/tobspr/shapez.io/blob/master/translations"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onPlayButtonClicked() {
|
|
|
|
if (
|
|
|
|
this.app.savegameMgr.getSavegamesMetaData().length > 0 &&
|
|
|
|
!this.app.restrictionMgr.getHasUnlimitedSavegames()
|
|
|
|
) {
|
|
|
|
this.app.analytics.trackUiClick("startgame_slot_limit_show");
|
|
|
|
this.showSavegameSlotLimit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.app.analytics.trackUiClick("startgame");
|
|
|
|
this.app.adProvider.showVideoAd().then(() => {
|
|
|
|
const savegame = this.app.savegameMgr.createNewSavegame();
|
|
|
|
|
|
|
|
this.moveToState("InGameState", {
|
|
|
|
savegame,
|
|
|
|
});
|
|
|
|
this.app.analytics.trackUiClick("startgame_adcomplete");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|