mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 18:21:51 +00:00
Remove all references of "G_IS_STANDALONE"
This commit is contained in:
parent
60b2727b42
commit
6662cb2694
@ -17,8 +17,6 @@ const globalDefs = {
|
|||||||
G_ALL_UI_IMAGES: JSON.stringify(getAllResourceImages()),
|
G_ALL_UI_IMAGES: JSON.stringify(getAllResourceImages()),
|
||||||
|
|
||||||
G_IS_RELEASE: "false",
|
G_IS_RELEASE: "false",
|
||||||
G_IS_STANDALONE: "true",
|
|
||||||
G_IS_BROWSER: "false",
|
|
||||||
G_HAVE_ASSERT: "true",
|
G_HAVE_ASSERT: "true",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -18,8 +18,6 @@ const globalDefs = {
|
|||||||
"G_ALL_UI_IMAGES": JSON.stringify(getAllResourceImages()),
|
"G_ALL_UI_IMAGES": JSON.stringify(getAllResourceImages()),
|
||||||
|
|
||||||
"G_IS_RELEASE": "true",
|
"G_IS_RELEASE": "true",
|
||||||
"G_IS_STANDALONE": "true",
|
|
||||||
"G_IS_BROWSER": "false",
|
|
||||||
"G_HAVE_ASSERT": "false",
|
"G_HAVE_ASSERT": "false",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -5,16 +5,14 @@ import { GameState } from "./core/game_state";
|
|||||||
import { GLOBAL_APP, setGlobalApp } from "./core/globals";
|
import { GLOBAL_APP, setGlobalApp } from "./core/globals";
|
||||||
import { InputDistributor } from "./core/input_distributor";
|
import { InputDistributor } from "./core/input_distributor";
|
||||||
import { Loader } from "./core/loader";
|
import { Loader } from "./core/loader";
|
||||||
import { createLogger, logSection } from "./core/logging";
|
import { createLogger } from "./core/logging";
|
||||||
import { StateManager } from "./core/state_manager";
|
import { StateManager } from "./core/state_manager";
|
||||||
import { TrackedState } from "./core/tracked_state";
|
import { TrackedState } from "./core/tracked_state";
|
||||||
import { getPlatformName, waitNextFrame } from "./core/utils";
|
import { getPlatformName, waitNextFrame } from "./core/utils";
|
||||||
import { Vector } from "./core/vector";
|
import { Vector } from "./core/vector";
|
||||||
import { NoAchievementProvider } from "./platform/browser/no_achievement_provider";
|
import { NoAchievementProvider } from "./platform/browser/no_achievement_provider";
|
||||||
import { SoundImplBrowser } from "./platform/browser/sound";
|
import { SoundImplBrowser } from "./platform/browser/sound";
|
||||||
import { PlatformWrapperImplBrowser } from "./platform/browser/wrapper";
|
|
||||||
import { PlatformWrapperImplElectron } from "./platform/electron/wrapper";
|
import { PlatformWrapperImplElectron } from "./platform/electron/wrapper";
|
||||||
import { PlatformWrapperInterface } from "./platform/wrapper";
|
|
||||||
import { ApplicationSettings } from "./profile/application_settings";
|
import { ApplicationSettings } from "./profile/application_settings";
|
||||||
import { SavegameManager } from "./savegame/savegame_manager";
|
import { SavegameManager } from "./savegame/savegame_manager";
|
||||||
import { AboutState } from "./states/about";
|
import { AboutState } from "./states/about";
|
||||||
@ -92,16 +90,10 @@ export class Application {
|
|||||||
/** @type {StorageInterface} */
|
/** @type {StorageInterface} */
|
||||||
this.storage = null;
|
this.storage = null;
|
||||||
|
|
||||||
/** @type {SoundInterface} */
|
this.platformWrapper = new PlatformWrapperImplElectron(this);
|
||||||
this.sound = null;
|
|
||||||
|
|
||||||
/** @type {PlatformWrapperInterface} */
|
this.sound = new SoundImplBrowser(this);
|
||||||
this.platformWrapper = null;
|
this.achievementProvider = new NoAchievementProvider(this);
|
||||||
|
|
||||||
/** @type {AchievementProviderInterface} */
|
|
||||||
this.achievementProvider = null;
|
|
||||||
|
|
||||||
this.initPlatformDependentInstances();
|
|
||||||
|
|
||||||
// Track if the window is focused (only relevant for browser)
|
// Track if the window is focused (only relevant for browser)
|
||||||
this.focused = true;
|
this.focused = true;
|
||||||
@ -151,22 +143,6 @@ export class Application {
|
|||||||
MOD_SIGNALS.appBooted.dispatch();
|
MOD_SIGNALS.appBooted.dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes all platform instances
|
|
||||||
*/
|
|
||||||
initPlatformDependentInstances() {
|
|
||||||
logger.log("Creating platform dependent instances (standalone=", G_IS_STANDALONE, ")");
|
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
|
||||||
this.platformWrapper = new PlatformWrapperImplElectron(this);
|
|
||||||
} else {
|
|
||||||
this.platformWrapper = new PlatformWrapperImplBrowser(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sound = new SoundImplBrowser(this);
|
|
||||||
this.achievementProvider = new NoAchievementProvider(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all game states
|
* Registers all game states
|
||||||
*/
|
*/
|
||||||
@ -312,18 +288,7 @@ export class Application {
|
|||||||
/**
|
/**
|
||||||
* Internal before-unload handler
|
* Internal before-unload handler
|
||||||
*/
|
*/
|
||||||
onBeforeUnload(event) {
|
onBeforeUnload(event) {}
|
||||||
logSection("BEFORE UNLOAD HANDLER", "#f77");
|
|
||||||
const currentState = this.stateMgr.getCurrentState();
|
|
||||||
|
|
||||||
if (!G_IS_DEV && currentState && currentState.getHasUnloadConfirmation()) {
|
|
||||||
if (!G_IS_STANDALONE) {
|
|
||||||
// Need to show a "Are you sure you want to exit"
|
|
||||||
event.preventDefault();
|
|
||||||
event.returnValue = "Are you sure you want to exit?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deinitializes the application
|
* Deinitializes the application
|
||||||
|
|||||||
@ -30,10 +30,8 @@ const INGAME_ASSETS = {
|
|||||||
css: ["async-resources.css"],
|
css: ["async-resources.css"],
|
||||||
};
|
};
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
MAIN_MENU_ASSETS.sounds = [...Array.from(Object.values(MUSIC)), ...Array.from(Object.values(SOUNDS))];
|
||||||
MAIN_MENU_ASSETS.sounds = [...Array.from(Object.values(MUSIC)), ...Array.from(Object.values(SOUNDS))];
|
INGAME_ASSETS.sounds = [];
|
||||||
INGAME_ASSETS.sounds = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const LOADER_TIMEOUT_PER_RESOURCE = 180000;
|
const LOADER_TIMEOUT_PER_RESOURCE = 180000;
|
||||||
|
|
||||||
@ -170,28 +168,13 @@ export class BackgroundResourcesLoader {
|
|||||||
* Shows an error when a resource failed to load and allows to reload the game
|
* Shows an error when a resource failed to load and allows to reload the game
|
||||||
*/
|
*/
|
||||||
showLoaderError(dialogs, err) {
|
showLoaderError(dialogs, err) {
|
||||||
if (G_IS_STANDALONE) {
|
dialogs
|
||||||
dialogs
|
.showWarning(
|
||||||
.showWarning(
|
T.dialogs.resourceLoadFailed.title,
|
||||||
T.dialogs.resourceLoadFailed.title,
|
T.dialogs.resourceLoadFailed.descSteamDemo + "<br>" + err,
|
||||||
T.dialogs.resourceLoadFailed.descSteamDemo + "<br>" + err,
|
["retry"]
|
||||||
["retry"]
|
)
|
||||||
)
|
.retry.add(() => window.location.reload());
|
||||||
.retry.add(() => window.location.reload());
|
|
||||||
} else {
|
|
||||||
dialogs
|
|
||||||
.showWarning(
|
|
||||||
T.dialogs.resourceLoadFailed.title,
|
|
||||||
T.dialogs.resourceLoadFailed.descWeb.replace(
|
|
||||||
"<demoOnSteamLinkText>",
|
|
||||||
`<a href="https://get.shapez.io/resource_timeout" target="_blank">${T.dialogs.resourceLoadFailed.demoLinkText}</a>`
|
|
||||||
) +
|
|
||||||
"<br>" +
|
|
||||||
err,
|
|
||||||
["retry"]
|
|
||||||
)
|
|
||||||
.retry.add(() => window.location.reload());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadWithProgress(src, progressHandler) {
|
preloadWithProgress(src, progressHandler) {
|
||||||
|
|||||||
@ -21,8 +21,6 @@ export const BUILD_OPTIONS = {
|
|||||||
APP_ENVIRONMENT: G_APP_ENVIRONMENT,
|
APP_ENVIRONMENT: G_APP_ENVIRONMENT,
|
||||||
IS_DEV: G_IS_DEV,
|
IS_DEV: G_IS_DEV,
|
||||||
IS_RELEASE: G_IS_RELEASE,
|
IS_RELEASE: G_IS_RELEASE,
|
||||||
IS_BROWSER: G_IS_BROWSER,
|
|
||||||
IS_STANDALONE: G_IS_STANDALONE,
|
|
||||||
BUILD_TIME: G_BUILD_TIME,
|
BUILD_TIME: G_BUILD_TIME,
|
||||||
BUILD_COMMIT_HASH: G_BUILD_COMMIT_HASH,
|
BUILD_COMMIT_HASH: G_BUILD_COMMIT_HASH,
|
||||||
BUILD_VERSION: G_BUILD_VERSION,
|
BUILD_VERSION: G_BUILD_VERSION,
|
||||||
|
|||||||
@ -4,15 +4,10 @@ const bigNumberSuffixTranslationKeys = ["thousands", "millions", "billions", "tr
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a platform name
|
* Returns a platform name
|
||||||
* @returns {"android" | "browser" | "ios" | "standalone" | "unknown"}
|
* @returns {"standalone"}
|
||||||
*/
|
*/
|
||||||
export function getPlatformName() {
|
export function getPlatformName() {
|
||||||
if (G_IS_STANDALONE) {
|
return "standalone";
|
||||||
return "standalone";
|
|
||||||
} else if (G_IS_BROWSER) {
|
|
||||||
return "browser";
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -421,41 +416,7 @@ export function removeAllChildren(elem) {
|
|||||||
* Returns if the game supports this browser
|
* Returns if the game supports this browser
|
||||||
*/
|
*/
|
||||||
export function isSupportedBrowser() {
|
export function isSupportedBrowser() {
|
||||||
// please note,
|
return true;
|
||||||
// that IE11 now returns undefined again for window.chrome
|
|
||||||
// and new Opera 30 outputs true for window.chrome
|
|
||||||
// but needs to check if window.opr is not undefined
|
|
||||||
// and new IE Edge outputs to true now for window.chrome
|
|
||||||
// and if not iOS Chrome check
|
|
||||||
// so use the below updated condition
|
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ts-ignore
|
|
||||||
var isChromium = window.chrome;
|
|
||||||
var winNav = window.navigator;
|
|
||||||
var vendorName = winNav.vendor;
|
|
||||||
// @ts-ignore
|
|
||||||
var isIEedge = winNav.userAgent.indexOf("Edge") > -1;
|
|
||||||
var isIOSChrome = winNav.userAgent.match("CriOS");
|
|
||||||
|
|
||||||
if (isIOSChrome) {
|
|
||||||
// is Google Chrome on IOS
|
|
||||||
return false;
|
|
||||||
} else if (
|
|
||||||
isChromium !== null &&
|
|
||||||
typeof isChromium !== "undefined" &&
|
|
||||||
vendorName === "Google Inc." &&
|
|
||||||
isIEedge === false
|
|
||||||
) {
|
|
||||||
// is Google Chrome
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
// not Google Chrome
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export class HUDUnlockNotification extends BaseHUDPart {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shouldPauseGame() {
|
shouldPauseGame() {
|
||||||
return !G_IS_STANDALONE && this.visible;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
createElements(parent) {
|
createElements(parent) {
|
||||||
|
|||||||
167
src/js/globals.d.ts
vendored
167
src/js/globals.d.ts
vendored
@ -1,10 +1,13 @@
|
|||||||
// Globals defined by webpack
|
// Globals defined by webpack
|
||||||
|
|
||||||
declare const G_IS_DEV: boolean;
|
declare const G_IS_DEV: boolean;
|
||||||
declare function assert(condition: boolean | object | string, ...errorMessage: string[]): asserts condition;
|
declare function assert(
|
||||||
|
condition: boolean | object | string,
|
||||||
|
...errorMessage: string[]
|
||||||
|
): asserts condition;
|
||||||
declare function assertAlways(
|
declare function assertAlways(
|
||||||
condition: boolean | object | string,
|
condition: boolean | object | string,
|
||||||
...errorMessage: string[]
|
...errorMessage: string[]
|
||||||
): asserts condition;
|
): asserts condition;
|
||||||
|
|
||||||
declare const abstract: void;
|
declare const abstract: void;
|
||||||
@ -12,8 +15,6 @@ declare const abstract: void;
|
|||||||
declare const G_APP_ENVIRONMENT: string;
|
declare const G_APP_ENVIRONMENT: string;
|
||||||
declare const G_HAVE_ASSERT: boolean;
|
declare const G_HAVE_ASSERT: boolean;
|
||||||
declare const G_BUILD_TIME: number;
|
declare const G_BUILD_TIME: number;
|
||||||
declare const G_IS_STANDALONE: boolean;
|
|
||||||
declare const G_IS_BROWSER: boolean;
|
|
||||||
|
|
||||||
declare const G_BUILD_COMMIT_HASH: string;
|
declare const G_BUILD_COMMIT_HASH: string;
|
||||||
declare const G_BUILD_VERSION: string;
|
declare const G_BUILD_VERSION: string;
|
||||||
@ -26,146 +27,146 @@ declare const ipcRenderer: any;
|
|||||||
|
|
||||||
// Polyfills
|
// Polyfills
|
||||||
declare interface String {
|
declare interface String {
|
||||||
replaceAll(search: string, replacement: string): string;
|
replaceAll(search: string, replacement: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface CanvasRenderingContext2D {
|
declare interface CanvasRenderingContext2D {
|
||||||
beginRoundedRect(x: number, y: number, w: number, h: number, r: number): void;
|
beginRoundedRect(x: number, y: number, w: number, h: number, r: number): void;
|
||||||
beginCircle(x: number, y: number, r: number): void;
|
beginCircle(x: number, y: number, r: number): void;
|
||||||
|
|
||||||
msImageSmoothingEnabled: boolean;
|
msImageSmoothingEnabled: boolean;
|
||||||
mozImageSmoothingEnabled: boolean;
|
mozImageSmoothingEnabled: boolean;
|
||||||
webkitImageSmoothingEnabled: boolean;
|
webkitImageSmoothingEnabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just for compatibility with the shared code
|
// Just for compatibility with the shared code
|
||||||
declare interface Logger {
|
declare interface Logger {
|
||||||
log(...args);
|
log(...args);
|
||||||
warn(...args);
|
warn(...args);
|
||||||
info(...args);
|
info(...args);
|
||||||
error(...args);
|
error(...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface MobileAccessibility {
|
declare interface MobileAccessibility {
|
||||||
usePreferredTextZoom(boolean);
|
usePreferredTextZoom(boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface Window {
|
declare interface Window {
|
||||||
// Debugging
|
// Debugging
|
||||||
activeClickDetectors: Array<any>;
|
activeClickDetectors: Array<any>;
|
||||||
|
|
||||||
// Mods
|
// Mods
|
||||||
$shapez_registerMod: any;
|
$shapez_registerMod: any;
|
||||||
anyModLoaded: any;
|
anyModLoaded: any;
|
||||||
|
|
||||||
shapez: any;
|
shapez: any;
|
||||||
|
|
||||||
APP_ERROR_OCCURED?: boolean;
|
APP_ERROR_OCCURED?: boolean;
|
||||||
|
|
||||||
webkitRequestAnimationFrame();
|
webkitRequestAnimationFrame();
|
||||||
|
|
||||||
assert(condition: boolean, failureMessage: string);
|
assert(condition: boolean, failureMessage: string);
|
||||||
|
|
||||||
coreThreadLoadedCb();
|
coreThreadLoadedCb();
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface Navigator {
|
declare interface Navigator {
|
||||||
app: any;
|
app: any;
|
||||||
device: any;
|
device: any;
|
||||||
splashscreen: any;
|
splashscreen: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Webpack
|
// Webpack
|
||||||
declare interface WebpackContext {
|
declare interface WebpackContext {
|
||||||
keys(): Array<string>;
|
keys(): Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface NodeRequire {
|
declare interface NodeRequire {
|
||||||
context(src: string, flag: boolean, regexp: RegExp): WebpackContext;
|
context(src: string, flag: boolean, regexp: RegExp): WebpackContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface Object {
|
declare interface Object {
|
||||||
entries(obj: object): Array<[string, any]>;
|
entries(obj: object): Array<[string, any]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface Math {
|
declare interface Math {
|
||||||
radians(number): number;
|
radians(number): number;
|
||||||
degrees(number): number;
|
degrees(number): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type Class<T = unknown> = new (...args: any[]) => T;
|
declare type Class<T = unknown> = new (...args: any[]) => T;
|
||||||
|
|
||||||
declare interface String {
|
declare interface String {
|
||||||
padStart(size: number, fill?: string): string;
|
padStart(size: number, fill?: string): string;
|
||||||
padEnd(size: number, fill: string): string;
|
padEnd(size: number, fill: string): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface SignalTemplate0 {
|
declare interface SignalTemplate0 {
|
||||||
add(receiver: () => string | void, scope: null | any);
|
add(receiver: () => string | void, scope: null | any);
|
||||||
dispatch(): string | void;
|
dispatch(): string | void;
|
||||||
remove(receiver: () => string | void);
|
remove(receiver: () => string | void);
|
||||||
removeAll();
|
removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class TypedTrackedState<T> {
|
declare class TypedTrackedState<T> {
|
||||||
constructor(callbackMethod?: (value: T) => void, callbackScope?: any);
|
constructor(callbackMethod?: (value: T) => void, callbackScope?: any);
|
||||||
|
|
||||||
set(value: T, changeHandler?: (value: T) => void, changeScope?: any): void;
|
set(value: T, changeHandler?: (value: T) => void, changeScope?: any): void;
|
||||||
|
|
||||||
setSilent(value: any): void;
|
setSilent(value: any): void;
|
||||||
get(): T;
|
get(): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare type Layer = "regular" | "wires";
|
declare type Layer = "regular" | "wires";
|
||||||
declare type ItemType = "shape" | "color" | "boolean";
|
declare type ItemType = "shape" | "color" | "boolean";
|
||||||
|
|
||||||
declare module "worker-loader?inline=true&fallback=false!*" {
|
declare module "worker-loader?inline=true&fallback=false!*" {
|
||||||
class WebpackWorker extends Worker {
|
class WebpackWorker extends Worker {
|
||||||
constructor();
|
constructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
export default WebpackWorker;
|
export default WebpackWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSX type support - https://www.typescriptlang.org/docs/handbook/jsx.html
|
// JSX type support - https://www.typescriptlang.org/docs/handbook/jsx.html
|
||||||
// modified from https://stackoverflow.com/a/68238924
|
// modified from https://stackoverflow.com/a/68238924
|
||||||
declare namespace JSX {
|
declare namespace JSX {
|
||||||
/**
|
/**
|
||||||
* The return type of a JSX expression.
|
* The return type of a JSX expression.
|
||||||
*
|
*
|
||||||
* In reality, Fragments can return arbitrary values, but we ignore this for convenience.
|
* In reality, Fragments can return arbitrary values, but we ignore this for convenience.
|
||||||
*/
|
*/
|
||||||
type Element = HTMLElement;
|
type Element = HTMLElement;
|
||||||
/**
|
/**
|
||||||
* Key-value list of intrinsic element names and their allowed properties.
|
* Key-value list of intrinsic element names and their allowed properties.
|
||||||
*
|
*
|
||||||
* Because children are treated as a property, the Node type cannot be excluded from the index signature.
|
* Because children are treated as a property, the Node type cannot be excluded from the index signature.
|
||||||
*/
|
*/
|
||||||
type IntrinsicElements = {
|
type IntrinsicElements = {
|
||||||
[K in keyof HTMLElementTagNameMap]: {
|
[K in keyof HTMLElementTagNameMap]: {
|
||||||
children?: Node | Node[];
|
children?: Node | Node[];
|
||||||
[k: string]: Node | Node[] | string | number | boolean;
|
[k: string]: Node | Node[] | string | number | boolean;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
/**
|
};
|
||||||
* The property of the attributes object storing the children.
|
/**
|
||||||
*/
|
* The property of the attributes object storing the children.
|
||||||
type ElementChildrenAttribute = { children: unknown };
|
*/
|
||||||
|
type ElementChildrenAttribute = { children: unknown };
|
||||||
|
|
||||||
// The following do not have special meaning to TypeScript.
|
// The following do not have special meaning to TypeScript.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An attributes object.
|
* An attributes object.
|
||||||
*/
|
*/
|
||||||
type Props = { [k: string]: unknown };
|
type Props = { [k: string]: unknown };
|
||||||
/**
|
/**
|
||||||
* A functional component requiring attributes to match `T`.
|
* A functional component requiring attributes to match `T`.
|
||||||
*/
|
*/
|
||||||
type Component<T extends Props> = {
|
type Component<T extends Props> = {
|
||||||
(props: T): Element;
|
(props: T): Element;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* A child of a JSX element.
|
* A child of a JSX element.
|
||||||
*/
|
*/
|
||||||
type Node = Element | string | boolean | null | undefined;
|
type Node = Element | string | boolean | null | undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,8 +63,4 @@ function bootApp() {
|
|||||||
app.boot();
|
app.boot();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
window.addEventListener("load", bootApp);
|
||||||
window.addEventListener("load", bootApp);
|
|
||||||
} else {
|
|
||||||
bootApp();
|
|
||||||
}
|
|
||||||
|
|||||||
@ -105,7 +105,7 @@ export class ModLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exposeExports() {
|
exposeExports() {
|
||||||
if (G_IS_DEV || G_IS_STANDALONE) {
|
if (G_IS_DEV) {
|
||||||
let exports = {};
|
let exports = {};
|
||||||
const modules = import.meta.webpackContext("../", {
|
const modules = import.meta.webpackContext("../", {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@ -140,24 +140,14 @@ export class ModLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initMods() {
|
async initMods() {
|
||||||
if (!G_IS_STANDALONE && !G_IS_DEV) {
|
|
||||||
this.initialized = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a storage for reading mod settings
|
// Create a storage for reading mod settings
|
||||||
const storage = G_IS_STANDALONE
|
const storage = new StorageImplElectron(this.app);
|
||||||
? new StorageImplElectron(this.app)
|
|
||||||
: new StorageImplBrowserIndexedDB(this.app);
|
|
||||||
await storage.initialize();
|
await storage.initialize();
|
||||||
|
|
||||||
LOG.log("hook:init", this.app, this.app.storage);
|
LOG.log("hook:init", this.app, this.app.storage);
|
||||||
this.exposeExports();
|
this.exposeExports();
|
||||||
|
|
||||||
let mods = [];
|
let mods = await ipcRenderer.invoke("get-mods");
|
||||||
if (G_IS_STANDALONE) {
|
|
||||||
mods = await ipcRenderer.invoke("get-mods");
|
|
||||||
}
|
|
||||||
if (G_IS_DEV && globalConfig.debug.externalModUrl) {
|
if (G_IS_DEV && globalConfig.debug.externalModUrl) {
|
||||||
const modURLs = Array.isArray(globalConfig.debug.externalModUrl)
|
const modURLs = Array.isArray(globalConfig.debug.externalModUrl)
|
||||||
? globalConfig.debug.externalModUrl
|
? globalConfig.debug.externalModUrl
|
||||||
|
|||||||
@ -99,11 +99,6 @@ export class SteamAchievementProvider extends AchievementProviderInterface {
|
|||||||
|
|
||||||
/** @returns {Promise<void>} */
|
/** @returns {Promise<void>} */
|
||||||
initialize() {
|
initialize() {
|
||||||
if (!G_IS_STANDALONE) {
|
|
||||||
logger.warn("Steam unavailable. Achievements won't sync.");
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ipcRenderer.invoke("steam:is-initialized").then(initialized => {
|
return ipcRenderer.invoke("steam:is-initialized").then(initialized => {
|
||||||
this.initialized = initialized;
|
this.initialized = initialized;
|
||||||
|
|
||||||
|
|||||||
@ -33,16 +33,12 @@ export const SOUNDS = {
|
|||||||
export const MUSIC = {
|
export const MUSIC = {
|
||||||
// The theme always depends on the standalone only, even if running the full
|
// The theme always depends on the standalone only, even if running the full
|
||||||
// version in the browser
|
// version in the browser
|
||||||
theme: G_IS_STANDALONE ? "theme-full" : "theme-short",
|
theme: "theme-full",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
MUSIC.menu = "menu";
|
||||||
MUSIC.menu = "menu";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (G_IS_STANDALONE) {
|
MUSIC.puzzle = "puzzle-full";
|
||||||
MUSIC.puzzle = "puzzle-full";
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SoundInstanceInterface {
|
export class SoundInstanceInterface {
|
||||||
constructor(key, url) {
|
constructor(key, url) {
|
||||||
|
|||||||
@ -189,7 +189,7 @@ function initializeSettings() {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @param {Application} app
|
* @param {Application} app
|
||||||
*/ app => G_IS_STANDALONE
|
*/ app => true
|
||||||
),
|
),
|
||||||
|
|
||||||
new BoolSetting(
|
new BoolSetting(
|
||||||
@ -288,7 +288,7 @@ function initializeSettings() {
|
|||||||
class SettingsStorage {
|
class SettingsStorage {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.uiScale = "regular";
|
this.uiScale = "regular";
|
||||||
this.fullscreen = G_IS_STANDALONE;
|
this.fullscreen = true;
|
||||||
|
|
||||||
this.soundVolume = 1.0;
|
this.soundVolume = 1.0;
|
||||||
this.musicVolume = 1.0;
|
this.musicVolume = 1.0;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export class ModsState extends TextualGameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get modsSupported() {
|
get modsSupported() {
|
||||||
return G_IS_STANDALONE || G_IS_DEV;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internalGetFullHtml() {
|
internalGetFullHtml() {
|
||||||
@ -23,15 +23,11 @@ export class ModsState extends TextualGameState {
|
|||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
${
|
${
|
||||||
this.modsSupported && MODS.mods.length > 0
|
MODS.mods.length > 0
|
||||||
? `<button class="styledButton browseMods">${T.mods.browseMods}</button>`
|
? `<button class="styledButton browseMods">${T.mods.browseMods}</button>`
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
${
|
<button class="styledButton openModsFolder">${T.mods.openFolder}</button>
|
||||||
this.modsSupported
|
|
||||||
? `<button class="styledButton openModsFolder">${T.mods.openFolder}</button>`
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>`;
|
</div>`;
|
||||||
@ -45,18 +41,6 @@ export class ModsState extends TextualGameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getMainContentHTML() {
|
getMainContentHTML() {
|
||||||
if (!this.modsSupported) {
|
|
||||||
return `
|
|
||||||
<div class="noModSupport">
|
|
||||||
|
|
||||||
<p>${T.mods.noModSupport}</p>
|
|
||||||
<br>
|
|
||||||
<button class="styledButton browseMods">${T.mods.browseMods}</button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MODS.mods.length === 0) {
|
if (MODS.mods.length === 0) {
|
||||||
return `
|
return `
|
||||||
|
|
||||||
@ -121,10 +105,6 @@ export class ModsState extends TextualGameState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openModsFolder() {
|
openModsFolder() {
|
||||||
if (!G_IS_STANDALONE) {
|
|
||||||
this.dialogs.showWarning(T.global.error, T.mods.folderOnlyStandalone);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ipcRenderer.invoke("open-mods-folder");
|
ipcRenderer.invoke("open-mods-folder");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -172,10 +172,6 @@ export class PreloadState extends GameState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!G_IS_STANDALONE) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.app.storage
|
return this.app.storage
|
||||||
.readFileAsync("lastversion.bin")
|
.readFileAsync("lastversion.bin")
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user