mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Do not allow saving in the demo version
This commit is contained in:
@@ -12,7 +12,7 @@ import { HUDKeybindingOverlay } from "./parts/keybinding_overlay";
|
||||
import { HUDUnlockNotification } from "./parts/unlock_notification";
|
||||
import { HUDGameMenu } from "./parts/game_menu";
|
||||
import { HUDShop } from "./parts/shop";
|
||||
import { IS_MOBILE, globalConfig } from "../../core/config";
|
||||
import { IS_MOBILE, globalConfig, IS_DEMO } from "../../core/config";
|
||||
import { HUDMassSelector } from "./parts/mass_selector";
|
||||
import { HUDVignetteOverlay } from "./parts/vignette_overlay";
|
||||
import { HUDStatistics } from "./parts/statistics";
|
||||
@@ -25,6 +25,7 @@ import { HUDDebugInfo } from "./parts/debug_info";
|
||||
import { HUDEntityDebugger } from "./parts/entity_debugger";
|
||||
import { KEYMAPPINGS } from "../key_action_mapper";
|
||||
import { HUDWatermark } from "./parts/watermark";
|
||||
import { HUDModalDialogs } from "./parts/modal_dialogs";
|
||||
|
||||
export class GameHUD {
|
||||
/**
|
||||
@@ -62,6 +63,8 @@ export class GameHUD {
|
||||
|
||||
// betaOverlay: new HUDBetaOverlay(this.root),
|
||||
debugInfo: new HUDDebugInfo(this.root),
|
||||
|
||||
dialogs: new HUDModalDialogs(this.root),
|
||||
};
|
||||
|
||||
this.signals = {
|
||||
@@ -78,7 +81,7 @@ export class GameHUD {
|
||||
this.parts.entityDebugger = new HUDEntityDebugger(this.root);
|
||||
}
|
||||
|
||||
if (!G_IS_STANDALONE && G_IS_RELEASE) {
|
||||
if (IS_DEMO) {
|
||||
this.parts.watermark = new HUDWatermark(this.root);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import { SOUNDS } from "../../../platform/sound";
|
||||
import { enumNotificationType } from "./notifications";
|
||||
import { T } from "../../../translations";
|
||||
import { KEYMAPPINGS } from "../../key_action_mapper";
|
||||
import { IS_DEMO } from "../../../core/config";
|
||||
|
||||
export class HUDGameMenu extends BaseHUDPart {
|
||||
initialize() {}
|
||||
@@ -117,6 +118,13 @@ export class HUDGameMenu extends BaseHUDPart {
|
||||
}
|
||||
|
||||
startSave() {
|
||||
if (IS_DEMO) {
|
||||
this.root.hud.parts.dialogs.showFeatureRestrictionInfo(
|
||||
null,
|
||||
T.dialogs.saveNotPossibleInDemo.desc
|
||||
);
|
||||
}
|
||||
|
||||
this.root.gameState.doSave();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import { DynamicDomAttach } from "../dynamic_dom_attach";
|
||||
import { BaseHUDPart } from "../base_hud_part";
|
||||
import { Dialog, DialogLoading, DialogOptionChooser } from "../../../core/modal_dialog_elements";
|
||||
import { makeDiv } from "../../../core/utils";
|
||||
import { T } from "../../../translations";
|
||||
import { THIRDPARTY_URLS } from "../../../core/config";
|
||||
|
||||
export class HUDModalDialogs extends BaseHUDPart {
|
||||
constructor(root, app) {
|
||||
@@ -14,7 +16,7 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
super(root);
|
||||
|
||||
/** @type {Application} */
|
||||
this.app = app;
|
||||
this.app = root ? root.app : app;
|
||||
|
||||
this.dialogParent = null;
|
||||
this.dialogStack = [];
|
||||
@@ -22,7 +24,7 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
|
||||
// For use inside of the game, implementation of base hud part
|
||||
initialize() {
|
||||
this.dialogParent = document.getElementById("rg_HUD_ModalDialogs");
|
||||
this.dialogParent = document.getElementById("ingame_HUD_ModalDialogs");
|
||||
this.domWatcher = new DynamicDomAttach(this.root, this.dialogParent);
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
}
|
||||
|
||||
createElements(parent) {
|
||||
return makeDiv(parent, "rg_HUD_ModalDialogs");
|
||||
return makeDiv(parent, "ingame_HUD_ModalDialogs");
|
||||
}
|
||||
|
||||
// For use outside of the game
|
||||
@@ -46,6 +48,11 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
|
||||
// Methods
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
* @param {Array<string>} buttons
|
||||
*/
|
||||
showInfo(title, text, buttons = ["ok:good"]) {
|
||||
const dialog = new Dialog({
|
||||
app: this.app,
|
||||
@@ -63,6 +70,11 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
return dialog.buttonSignals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} title
|
||||
* @param {string} text
|
||||
* @param {Array<string>} buttons
|
||||
*/
|
||||
showWarning(title, text, buttons = ["ok:good"]) {
|
||||
const dialog = new Dialog({
|
||||
app: this.app,
|
||||
@@ -80,6 +92,38 @@ export class HUDModalDialogs extends BaseHUDPart {
|
||||
return dialog.buttonSignals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} feature
|
||||
* @param {string} textPrefab
|
||||
*/
|
||||
showFeatureRestrictionInfo(feature, textPrefab = T.dialogs.featureRestriction.desc) {
|
||||
const dialog = new Dialog({
|
||||
app: this.app,
|
||||
title: T.dialogs.featureRestriction.title,
|
||||
contentHTML: textPrefab.replace("<feature>", feature),
|
||||
buttons: ["cancel:bad", "getStandalone:good"],
|
||||
type: "warning",
|
||||
});
|
||||
this.internalShowDialog(dialog);
|
||||
|
||||
if (this.app) {
|
||||
this.app.sound.playUiSound(SOUNDS.dialogOk);
|
||||
}
|
||||
|
||||
this.app.analytics.trackUiClick("demo_dialog_show");
|
||||
|
||||
dialog.buttonSignals.cancel.add(() => {
|
||||
this.app.analytics.trackUiClick("demo_dialog_cancel");
|
||||
});
|
||||
|
||||
dialog.buttonSignals.getStandalone.add(() => {
|
||||
this.app.analytics.trackUiClick("demo_dialog_click");
|
||||
window.open(THIRDPARTY_URLS.standaloneStorePage);
|
||||
});
|
||||
|
||||
return dialog.buttonSignals;
|
||||
}
|
||||
|
||||
showOptionChooser(title, options) {
|
||||
const dialog = new DialogOptionChooser({
|
||||
app: this.app,
|
||||
|
||||
@@ -14,13 +14,9 @@ export class HUDWatermark extends BaseHUDPart {
|
||||
const w = this.root.gameWidth;
|
||||
|
||||
parameters.context.fillStyle = "#f77";
|
||||
parameters.context.font = "50px GameFont";
|
||||
parameters.context.font = "bold " + this.root.app.getEffectiveUiScale() * 15 + "px GameFont";
|
||||
parameters.context.textAlign = "center";
|
||||
parameters.context.fillText("DEMO VERSION", w / 2, 100);
|
||||
|
||||
parameters.context.fillStyle = "#aaaca9";
|
||||
parameters.context.font = "20px GameFont";
|
||||
parameters.context.fillText("Get shapez.io on steam for the full experience!", w / 2, 140);
|
||||
parameters.context.fillText("DEMO VERSION", w / 2, 50);
|
||||
|
||||
parameters.context.textAlign = "left";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user