1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Authorize via steam for the puzzle api

This commit is contained in:
tobspr
2021-05-23 17:34:13 +02:00
parent ec4d198df3
commit 329cefb3c9
5 changed files with 93 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ import {
waitNextFrame,
} from "../core/utils";
import { HUDModalDialogs } from "../game/hud/parts/modal_dialogs";
import { PlatformWrapperImplElectron } from "../platform/electron/wrapper";
import { getApplicationSettingById } from "../profile/application_settings";
import { T } from "../translations";
@@ -40,6 +41,11 @@ export class MainMenuState extends GameState {
const showDemoBadges = this.app.restrictionMgr.getIsStandaloneMarketingActive();
const puzzleDlc =
G_IS_STANDALONE &&
/** @type { PlatformWrapperImplElectron
}*/ (this.app.platformWrapper).dlcs.puzzle;
return `
<div class="topButtons">
${
@@ -86,8 +92,7 @@ export class MainMenuState extends GameState {
</div>
${
// @TODO: Only display if DLC is owned, otherwise show ad for store page
G_IS_STANDALONE && false
G_IS_STANDALONE && puzzleDlc
? `
<div class="puzzleContainer">
<img class="dlcLogo" src="${cachebust(
@@ -99,8 +104,7 @@ export class MainMenuState extends GameState {
}
${
// @TODO: Only display if DLC is owned, otherwise show ad for store page
G_IS_STANDALONE && true
G_IS_STANDALONE && !puzzleDlc
? `
<div class="puzzleContainer notOwned">
<img class="dlcLogo" src="${cachebust(
@@ -304,6 +308,16 @@ export class MainMenuState extends GameState {
this.trackClicks(producerLink, () => this.app.platformWrapper.openExternalLink("https://tobspr.io"), {
preventClick: true,
});
const puzzleModeButton = qs(".puzzleDlcPlayButton");
if (puzzleModeButton) {
this.trackClicks(puzzleModeButton, () => this.onPuzzleModeButtonClicked());
}
const puzzleWishlistButton = qs(".puzzleDlcGetButton");
if (puzzleWishlistButton) {
this.trackClicks(puzzleWishlistButton, () => this.onPuzzleWishlistButtonClicked());
}
}
renderMainMenu() {
@@ -340,11 +354,6 @@ export class MainMenuState extends GameState {
this.trackClicks(playBtn, this.onPlayButtonClicked);
buttonContainer.appendChild(importButtonElement);
}
const puzzleModeButton = this.htmlElement.querySelector(".puzzleDlcPlayButton");
if (puzzleModeButton) {
this.trackClicks(puzzleModeButton, () => this.onPuzzleModeButtonClicked());
}
}
onPuzzleModeButtonClicked(force = false) {
@@ -365,6 +374,12 @@ export class MainMenuState extends GameState {
});
}
onPuzzleWishlistButtonClicked() {
this.app.platformWrapper.openExternalLink(
THIRDPARTY_URLS.puzzleDlcStorePage + "?ref=mmsl2&prc=" + A_B_TESTING_LINK_TYPE
);
}
onBackButtonClicked() {
this.renderMainMenu();
this.renderSavegames();