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

Update demo to try out timed demo

This commit is contained in:
tobspr
2022-06-17 09:35:55 +02:00
parent abd26182f5
commit d39ae528f0
41 changed files with 136 additions and 43 deletions

View File

@@ -0,0 +1,28 @@
#ingame_HUD_DemoTimer {
position: absolute;
@include S(top, 10px);
left: 50%;
text-align: center;
color: #fff;
transform: translateX(-50%);
color: rgb(248, 40, 106);
.timer {
@include Heading;
@include S(font-size, 40px);
}
&.expired .timer {
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: scale(1.05);
}
}
}
.description {
@include SuperSmallText;
@include S(margin-top, 10px);
text-transform: uppercase;
}
}

View File

@@ -50,6 +50,7 @@
@import "ingame_hud/entity_debugger";
@import "ingame_hud/tutorial_hints";
@import "ingame_hud/watermark";
@import "ingame_hud/demo_timer";
@import "ingame_hud/blueprint_placer";
@import "ingame_hud/waypoints";
@import "ingame_hud/interactive_tutorial";
@@ -119,6 +120,7 @@ ingame_HUD_StandaloneAdvantages,
ingame_HUD_UnlockNotification,
ingame_HUD_PuzzleCompleteNotification,
ingame_HUD_SettingsMenu,
ingame_HUD_DemoTimer,
ingame_HUD_ModalDialogs;
$zindex: 100;

View File

@@ -13,6 +13,7 @@ import { HUDBuildingPlacer } from "./parts/building_placer";
import { HUDColorBlindHelper } from "./parts/color_blind_helper";
import { HUDChangesDebugger } from "./parts/debug_changes";
import { HUDDebugInfo } from "./parts/debug_info";
import { HUDDemoTimer } from "./parts/demo_timer";
import { HUDEntityDebugger } from "./parts/entity_debugger";
import { HUDModalDialogs } from "./parts/modal_dialogs";
import { enumNotificationType } from "./parts/notifications";
@@ -85,6 +86,12 @@ export class GameHUD {
this.parts.betaOverlay = new HUDBetaOverlay(this.root);
}
if (this.root.app.restrictionMgr.getIsStandaloneMarketingActive()) {
if (["1", "2"].includes(this.root.app.gameAnalytics.abtVariant)) {
this.parts.demoTimer = new HUDDemoTimer(this.root);
}
}
const additionalParts = this.root.gameMode.additionalHudParts;
for (const [partId, part] of Object.entries(additionalParts)) {
this.parts[partId] = new part(this.root);

View File

@@ -0,0 +1,42 @@
import { makeDiv } from "../../../core/utils";
import { BaseHUDPart } from "../base_hud_part";
export class HUDDemoTimer extends BaseHUDPart {
createElements(parent) {
this.mainElement = makeDiv(parent, "ingame_HUD_DemoTimer", [], "");
this.timerElement = makeDiv(this.mainElement, null, ["timer"], "12:00");
this.descElement = makeDiv(this.mainElement, null, ["description"], "Until end of demo");
this.currentValue = "";
}
get totalTime() {
return this.root.app.gameAnalytics.abtVariant === "1" ? 15 : 30;
}
initialize() {}
update() {
const time = Math.max(0, this.totalTime * 60 - this.root.time.now());
let minutes = Math.floor(time / 60);
let seconds = Math.floor(time % 60);
let displayString = String(minutes).padStart(2, "0") + ":" + String(seconds).padStart(2, "0");
if (displayString !== this.currentValue) {
this.currentValue = displayString;
this.timerElement.innerText = displayString;
if (time === 0) {
this.mainElement.classList.add("expired");
}
}
if (time === 0) {
const advantages = this.root.hud.parts.standaloneAdvantages;
if (advantages && !advantages.visible) {
advantages.show(true);
}
}
}
}

View File

@@ -80,21 +80,30 @@ export class HUDStandaloneAdvantages extends BaseHUDPart {
}
}
show() {
show(final = false) {
this.lastShown = this.root.time.now();
this.visible = true;
this.final = final;
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever);
}
close() {
this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever);
this.update();
if (this.final) {
this.root.gameState.goBackToMenu();
} else {
this.visible = false;
this.root.app.inputMgr.makeSureDetached(this.inputReciever);
this.update();
}
}
update() {
if (!this.visible && this.root.time.now() - this.lastShown > this.showIntervalSeconds) {
this.show();
if (this.root.app.gameAnalytics.abtVariant === "0") {
// only show in original variant
if (!this.visible && this.root.time.now() - this.lastShown > this.showIntervalSeconds) {
this.show();
}
}
this.domAttach.update(this.visible);

View File

@@ -19,6 +19,9 @@ export class HUDSteamCapsule extends BaseHUDPart {
}
update() {
this.domAttach.update(this.root.time.now() > showCapsuleAfter);
if (this.root.app.gameAnalytics.abtVariant === "0") {
// only show in original variant
this.domAttach.update(this.root.time.now() > showCapsuleAfter);
}
}
}

View File

@@ -47,6 +47,9 @@ export class HUDWatermark extends BaseHUDPart {
* @param {import("../../../core/draw_utils").DrawParameters} parameters
*/
drawOverlays(parameters) {
if (this.root.app.gameAnalytics.abtVariant !== "0") {
return;
}
const w = this.root.gameWidth;
parameters.context.fillStyle = "rgba(20, 30, 40, 0.25)";

View File

@@ -18,7 +18,7 @@ const analyticsUrl = G_IS_DEV ? "http://localhost:8001" : "https://analytics.sha
// Be sure to increment the ID whenever it changes
const analyticsLocalFile = G_IS_STEAM_DEMO ? "shapez_token_steamdemo.bin" : "shapez_token_123.bin";
const CURRENT_ABT = "abt_mmat";
const CURRENT_ABT = "abt_dmtm";
const CURRENT_ABT_COUNT = 3;
export class ShapezGameAnalytics extends GameAnalyticsInterface {

View File

@@ -74,12 +74,11 @@ export class MainMenuState extends GameState {
!G_IS_STEAM_DEMO &&
/** @type { PlatformWrapperImplElectron}*/ (this.app.platformWrapper).dlcs.puzzle);
let abtVariant = this.app.gameAnalytics.abtVariant;
const bannerHtml = `
<h3>${T.demoBanners.title}</h3>
<p>${T.demoBanners.intro}</p>
${
abtVariant === "0"
G_IS_STEAM_DEMO
? `<span class="playtimeDisclaimer">${T.demoBanners.playtimeDisclaimer}</span>`
: ""
}
@@ -91,7 +90,7 @@ export class MainMenuState extends GameState {
}
</a>
${abtVariant === "2" ? `<div class="onlinePlayerCount"></div>` : ""}
${!G_IS_STEAM_DEMO ? `<div class="onlinePlayerCount"></div>` : ""}
`;