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_IS_RELEASE: "false",
|
||||
G_IS_STANDALONE: "true",
|
||||
G_IS_BROWSER: "false",
|
||||
G_HAVE_ASSERT: "true",
|
||||
};
|
||||
|
||||
|
||||
@ -18,8 +18,6 @@ const globalDefs = {
|
||||
"G_ALL_UI_IMAGES": JSON.stringify(getAllResourceImages()),
|
||||
|
||||
"G_IS_RELEASE": "true",
|
||||
"G_IS_STANDALONE": "true",
|
||||
"G_IS_BROWSER": "false",
|
||||
"G_HAVE_ASSERT": "false",
|
||||
};
|
||||
|
||||
|
||||
@ -5,16 +5,14 @@ import { GameState } from "./core/game_state";
|
||||
import { GLOBAL_APP, setGlobalApp } from "./core/globals";
|
||||
import { InputDistributor } from "./core/input_distributor";
|
||||
import { Loader } from "./core/loader";
|
||||
import { createLogger, logSection } from "./core/logging";
|
||||
import { createLogger } from "./core/logging";
|
||||
import { StateManager } from "./core/state_manager";
|
||||
import { TrackedState } from "./core/tracked_state";
|
||||
import { getPlatformName, waitNextFrame } from "./core/utils";
|
||||
import { Vector } from "./core/vector";
|
||||
import { NoAchievementProvider } from "./platform/browser/no_achievement_provider";
|
||||
import { SoundImplBrowser } from "./platform/browser/sound";
|
||||
import { PlatformWrapperImplBrowser } from "./platform/browser/wrapper";
|
||||
import { PlatformWrapperImplElectron } from "./platform/electron/wrapper";
|
||||
import { PlatformWrapperInterface } from "./platform/wrapper";
|
||||
import { ApplicationSettings } from "./profile/application_settings";
|
||||
import { SavegameManager } from "./savegame/savegame_manager";
|
||||
import { AboutState } from "./states/about";
|
||||
@ -92,16 +90,10 @@ export class Application {
|
||||
/** @type {StorageInterface} */
|
||||
this.storage = null;
|
||||
|
||||
/** @type {SoundInterface} */
|
||||
this.sound = null;
|
||||
this.platformWrapper = new PlatformWrapperImplElectron(this);
|
||||
|
||||
/** @type {PlatformWrapperInterface} */
|
||||
this.platformWrapper = null;
|
||||
|
||||
/** @type {AchievementProviderInterface} */
|
||||
this.achievementProvider = null;
|
||||
|
||||
this.initPlatformDependentInstances();
|
||||
this.sound = new SoundImplBrowser(this);
|
||||
this.achievementProvider = new NoAchievementProvider(this);
|
||||
|
||||
// Track if the window is focused (only relevant for browser)
|
||||
this.focused = true;
|
||||
@ -151,22 +143,6 @@ export class Application {
|
||||
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
|
||||
*/
|
||||
@ -312,18 +288,7 @@ export class Application {
|
||||
/**
|
||||
* Internal before-unload handler
|
||||
*/
|
||||
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?";
|
||||
}
|
||||
}
|
||||
}
|
||||
onBeforeUnload(event) {}
|
||||
|
||||
/**
|
||||
* Deinitializes the application
|
||||
|
||||
@ -30,10 +30,8 @@ const INGAME_ASSETS = {
|
||||
css: ["async-resources.css"],
|
||||
};
|
||||
|
||||
if (G_IS_STANDALONE) {
|
||||
MAIN_MENU_ASSETS.sounds = [...Array.from(Object.values(MUSIC)), ...Array.from(Object.values(SOUNDS))];
|
||||
INGAME_ASSETS.sounds = [];
|
||||
}
|
||||
MAIN_MENU_ASSETS.sounds = [...Array.from(Object.values(MUSIC)), ...Array.from(Object.values(SOUNDS))];
|
||||
INGAME_ASSETS.sounds = [];
|
||||
|
||||
const LOADER_TIMEOUT_PER_RESOURCE = 180000;
|
||||
|
||||
@ -170,7 +168,6 @@ export class BackgroundResourcesLoader {
|
||||
* Shows an error when a resource failed to load and allows to reload the game
|
||||
*/
|
||||
showLoaderError(dialogs, err) {
|
||||
if (G_IS_STANDALONE) {
|
||||
dialogs
|
||||
.showWarning(
|
||||
T.dialogs.resourceLoadFailed.title,
|
||||
@ -178,20 +175,6 @@ export class BackgroundResourcesLoader {
|
||||
["retry"]
|
||||
)
|
||||
.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) {
|
||||
|
||||
@ -21,8 +21,6 @@ export const BUILD_OPTIONS = {
|
||||
APP_ENVIRONMENT: G_APP_ENVIRONMENT,
|
||||
IS_DEV: G_IS_DEV,
|
||||
IS_RELEASE: G_IS_RELEASE,
|
||||
IS_BROWSER: G_IS_BROWSER,
|
||||
IS_STANDALONE: G_IS_STANDALONE,
|
||||
BUILD_TIME: G_BUILD_TIME,
|
||||
BUILD_COMMIT_HASH: G_BUILD_COMMIT_HASH,
|
||||
BUILD_VERSION: G_BUILD_VERSION,
|
||||
|
||||
@ -4,15 +4,10 @@ const bigNumberSuffixTranslationKeys = ["thousands", "millions", "billions", "tr
|
||||
|
||||
/**
|
||||
* Returns a platform name
|
||||
* @returns {"android" | "browser" | "ios" | "standalone" | "unknown"}
|
||||
* @returns {"standalone"}
|
||||
*/
|
||||
export function getPlatformName() {
|
||||
if (G_IS_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
|
||||
*/
|
||||
export function isSupportedBrowser() {
|
||||
// please note,
|
||||
// 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() {
|
||||
return !G_IS_STANDALONE && this.visible;
|
||||
return false;
|
||||
}
|
||||
|
||||
createElements(parent) {
|
||||
|
||||
7
src/js/globals.d.ts
vendored
7
src/js/globals.d.ts
vendored
@ -1,7 +1,10 @@
|
||||
// Globals defined by webpack
|
||||
|
||||
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(
|
||||
condition: boolean | object | string,
|
||||
...errorMessage: string[]
|
||||
@ -12,8 +15,6 @@ declare const abstract: void;
|
||||
declare const G_APP_ENVIRONMENT: string;
|
||||
declare const G_HAVE_ASSERT: boolean;
|
||||
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_VERSION: string;
|
||||
|
||||
@ -63,8 +63,4 @@ function bootApp() {
|
||||
app.boot();
|
||||
}
|
||||
|
||||
if (G_IS_STANDALONE) {
|
||||
window.addEventListener("load", bootApp);
|
||||
} else {
|
||||
bootApp();
|
||||
}
|
||||
window.addEventListener("load", bootApp);
|
||||
|
||||
@ -105,7 +105,7 @@ export class ModLoader {
|
||||
}
|
||||
|
||||
exposeExports() {
|
||||
if (G_IS_DEV || G_IS_STANDALONE) {
|
||||
if (G_IS_DEV) {
|
||||
let exports = {};
|
||||
const modules = import.meta.webpackContext("../", {
|
||||
recursive: true,
|
||||
@ -140,24 +140,14 @@ export class ModLoader {
|
||||
}
|
||||
|
||||
async initMods() {
|
||||
if (!G_IS_STANDALONE && !G_IS_DEV) {
|
||||
this.initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a storage for reading mod settings
|
||||
const storage = G_IS_STANDALONE
|
||||
? new StorageImplElectron(this.app)
|
||||
: new StorageImplBrowserIndexedDB(this.app);
|
||||
const storage = new StorageImplElectron(this.app);
|
||||
await storage.initialize();
|
||||
|
||||
LOG.log("hook:init", this.app, this.app.storage);
|
||||
this.exposeExports();
|
||||
|
||||
let mods = [];
|
||||
if (G_IS_STANDALONE) {
|
||||
mods = await ipcRenderer.invoke("get-mods");
|
||||
}
|
||||
let mods = await ipcRenderer.invoke("get-mods");
|
||||
if (G_IS_DEV && globalConfig.debug.externalModUrl) {
|
||||
const modURLs = Array.isArray(globalConfig.debug.externalModUrl)
|
||||
? globalConfig.debug.externalModUrl
|
||||
|
||||
@ -99,11 +99,6 @@ export class SteamAchievementProvider extends AchievementProviderInterface {
|
||||
|
||||
/** @returns {Promise<void>} */
|
||||
initialize() {
|
||||
if (!G_IS_STANDALONE) {
|
||||
logger.warn("Steam unavailable. Achievements won't sync.");
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return ipcRenderer.invoke("steam:is-initialized").then(initialized => {
|
||||
this.initialized = initialized;
|
||||
|
||||
|
||||
@ -33,16 +33,12 @@ export const SOUNDS = {
|
||||
export const MUSIC = {
|
||||
// The theme always depends on the standalone only, even if running the full
|
||||
// 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 {
|
||||
constructor(key, url) {
|
||||
|
||||
@ -189,7 +189,7 @@ function initializeSettings() {
|
||||
},
|
||||
/**
|
||||
* @param {Application} app
|
||||
*/ app => G_IS_STANDALONE
|
||||
*/ app => true
|
||||
),
|
||||
|
||||
new BoolSetting(
|
||||
@ -288,7 +288,7 @@ function initializeSettings() {
|
||||
class SettingsStorage {
|
||||
constructor() {
|
||||
this.uiScale = "regular";
|
||||
this.fullscreen = G_IS_STANDALONE;
|
||||
this.fullscreen = true;
|
||||
|
||||
this.soundVolume = 1.0;
|
||||
this.musicVolume = 1.0;
|
||||
|
||||
@ -13,7 +13,7 @@ export class ModsState extends TextualGameState {
|
||||
}
|
||||
|
||||
get modsSupported() {
|
||||
return G_IS_STANDALONE || G_IS_DEV;
|
||||
return true;
|
||||
}
|
||||
|
||||
internalGetFullHtml() {
|
||||
@ -23,15 +23,11 @@ export class ModsState extends TextualGameState {
|
||||
|
||||
<div class="actions">
|
||||
${
|
||||
this.modsSupported && MODS.mods.length > 0
|
||||
MODS.mods.length > 0
|
||||
? `<button class="styledButton browseMods">${T.mods.browseMods}</button>`
|
||||
: ""
|
||||
}
|
||||
${
|
||||
this.modsSupported
|
||||
? `<button class="styledButton openModsFolder">${T.mods.openFolder}</button>`
|
||||
: ""
|
||||
}
|
||||
<button class="styledButton openModsFolder">${T.mods.openFolder}</button>
|
||||
</div>
|
||||
|
||||
</div>`;
|
||||
@ -45,18 +41,6 @@ export class ModsState extends TextualGameState {
|
||||
}
|
||||
|
||||
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) {
|
||||
return `
|
||||
|
||||
@ -121,10 +105,6 @@ export class ModsState extends TextualGameState {
|
||||
}
|
||||
|
||||
openModsFolder() {
|
||||
if (!G_IS_STANDALONE) {
|
||||
this.dialogs.showWarning(T.global.error, T.mods.folderOnlyStandalone);
|
||||
return;
|
||||
}
|
||||
ipcRenderer.invoke("open-mods-folder");
|
||||
}
|
||||
|
||||
|
||||
@ -172,10 +172,6 @@ export class PreloadState extends GameState {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!G_IS_STANDALONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.app.storage
|
||||
.readFileAsync("lastversion.bin")
|
||||
.catch(err => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user