1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Merge remote-tracking branch 'Dimava/fix/debug-settings' into GeoZ

This commit is contained in:
Exund 2020-09-07 20:01:00 +02:00
commit c61dd2f9c2
5 changed files with 275 additions and 251 deletions

View File

@ -1,136 +1,136 @@
import { queryParamOptions } from "./query_parameters"; import { queryParamOptions } from "./query_parameters";
export const IS_DEBUG = export const IS_DEBUG =
G_IS_DEV && G_IS_DEV &&
typeof window !== "undefined" && typeof window !== "undefined" &&
window.location.port === "3005" && window.location.port === "3005" &&
(window.location.host.indexOf("localhost:") >= 0 || window.location.host.indexOf("192.168.0.") >= 0) && (window.location.host.indexOf("localhost:") >= 0 || window.location.host.indexOf("192.168.0.") >= 0) &&
window.location.search.indexOf("nodebug") < 0; window.location.search.indexOf("nodebug") < 0;
export const IS_DEMO = queryParamOptions.fullVersion export const IS_DEMO = queryParamOptions.fullVersion
? false ? false
: (!G_IS_DEV && !G_IS_STANDALONE) || : (!G_IS_DEV && !G_IS_STANDALONE) ||
(typeof window !== "undefined" && window.location.search.indexOf("demo") >= 0); (typeof window !== "undefined" && window.location.search.indexOf("demo") >= 0);
export const SUPPORT_TOUCH = false; export const SUPPORT_TOUCH = false;
const smoothCanvas = true; const smoothCanvas = true;
export const THIRDPARTY_URLS = { export const THIRDPARTY_URLS = {
discord: "https://discord.gg/HN7EVzV", discord: "https://discord.gg/HN7EVzV",
github: "https://github.com/tobspr/shapez.io", github: "https://github.com/tobspr/shapez.io",
reddit: "https://www.reddit.com/r/shapezio", reddit: "https://www.reddit.com/r/shapezio",
standaloneStorePage: "https://store.steampowered.com/app/1318690/shapezio/", standaloneStorePage: "https://store.steampowered.com/app/1318690/shapezio/",
}; };
export const globalConfig = { export const globalConfig = {
// Size of a single tile in Pixels. // Size of a single tile in Pixels.
// NOTICE: Update webpack.production.config too! // NOTICE: Update webpack.production.config too!
tileSize: 32, tileSize: 32,
halfTileSize: 16, halfTileSize: 16,
// Which dpi the assets have // Which dpi the assets have
assetsDpi: 192 / 32, assetsDpi: 192 / 32,
assetsSharpness: 1.5, assetsSharpness: 1.5,
shapesSharpness: 1.4, shapesSharpness: 1.4,
// Production analytics // Production analytics
statisticsGraphDpi: 2.5, statisticsGraphDpi: 2.5,
statisticsGraphSlices: 100, statisticsGraphSlices: 100,
analyticsSliceDurationSeconds: G_IS_DEV ? 1 : 10, analyticsSliceDurationSeconds: G_IS_DEV ? 1 : 10,
minimumTickRate: 25, minimumTickRate: 25,
maximumTickRate: 500, maximumTickRate: 500,
// Map // Map
mapChunkSize: 16, mapChunkSize: 16,
mapChunkOverviewMinZoom: 0.9, mapChunkOverviewMinZoom: 0.9,
mapChunkWorldSize: null, // COMPUTED mapChunkWorldSize: null, // COMPUTED
// Belt speeds // Belt speeds
// NOTICE: Update webpack.production.config too! // NOTICE: Update webpack.production.config too!
beltSpeedItemsPerSecond: 2, beltSpeedItemsPerSecond: 2,
minerSpeedItemsPerSecond: 0, // COMPUTED minerSpeedItemsPerSecond: 0, // COMPUTED
defaultItemDiameter: 20, defaultItemDiameter: 20,
itemSpacingOnBelts: 0.63, itemSpacingOnBelts: 0.63,
wiresSpeedItemsPerSecond: 6, wiresSpeedItemsPerSecond: 6,
undergroundBeltMaxTilesByTier: [5, 9], undergroundBeltMaxTilesByTier: [5, 9],
readerAnalyzeIntervalSeconds: G_IS_DEV ? 3 : 10, readerAnalyzeIntervalSeconds: G_IS_DEV ? 3 : 10,
buildingSpeeds: { buildingSpeeds: {
cutter: 1 / 4, cutter: 1 / 4,
cutterQuad: 1 / 4, cutterQuad: 1 / 4,
rotater: 1 / 1, rotater: 1 / 1,
rotaterCCW: 1 / 1, rotaterCCW: 1 / 1,
rotaterFL: 1 / 1, rotaterFL: 1 / 1,
painter: 1 / 6, painter: 1 / 6,
painterDouble: 1 / 8, painterDouble: 1 / 8,
painterQuad: 1 / 8, painterQuad: 1 / 8,
mixer: 1 / 5, mixer: 1 / 5,
stacker: 1 / 6, stacker: 1 / 6,
}, },
// Zooming // Zooming
initialZoom: 1.9, initialZoom: 1.9,
minZoomLevel: 0.1, minZoomLevel: 0.1,
maxZoomLevel: 3, maxZoomLevel: 3,
// Global game speed // Global game speed
gameSpeed: 1, gameSpeed: 1,
warmupTimeSecondsFast: 0.1, warmupTimeSecondsFast: 0.1,
warmupTimeSecondsRegular: 1, warmupTimeSecondsRegular: 1,
smoothing: { smoothing: {
smoothMainCanvas: smoothCanvas && true, smoothMainCanvas: smoothCanvas && true,
quality: "low", // Low is CRUCIAL for mobile performance! quality: "low", // Low is CRUCIAL for mobile performance!
}, },
rendering: {}, rendering: {},
debug: require("./config.local").default, debug: G_IS_DEV ? require("./config.local").default : {},
// Secret vars // Secret vars
info: { info: {
// Binary file salt // Binary file salt
file: "Ec'])@^+*9zMevK3uMV4432x9%iK'=", file: "Ec'])@^+*9zMevK3uMV4432x9%iK'=",
// Savegame salt // Savegame salt
sgSalt: "}95Q3%8/.837Lqym_BJx%q7)pAHJbF", sgSalt: "}95Q3%8/.837Lqym_BJx%q7)pAHJbF",
// Analytics key // Analytics key
analyticsApiKey: "baf6a50f0cc7dfdec5a0e21c88a1c69a4b34bc4a", analyticsApiKey: "baf6a50f0cc7dfdec5a0e21c88a1c69a4b34bc4a",
}, },
}; };
export const IS_MOBILE = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); export const IS_MOBILE = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
// Automatic calculations // Automatic calculations
globalConfig.minerSpeedItemsPerSecond = globalConfig.beltSpeedItemsPerSecond / 5; globalConfig.minerSpeedItemsPerSecond = globalConfig.beltSpeedItemsPerSecond / 5;
globalConfig.mapChunkWorldSize = globalConfig.mapChunkSize * globalConfig.tileSize; globalConfig.mapChunkWorldSize = globalConfig.mapChunkSize * globalConfig.tileSize;
// Dynamic calculations // Dynamic calculations
if (globalConfig.debug.disableMapOverview) { if (globalConfig.debug.disableMapOverview) {
globalConfig.mapChunkOverviewMinZoom = 0; globalConfig.mapChunkOverviewMinZoom = 0;
} }
// Stuff for making the trailer // Stuff for making the trailer
if (G_IS_DEV && globalConfig.debug.renderForTrailer) { if (G_IS_DEV && globalConfig.debug.renderForTrailer) {
globalConfig.debug.framePausesBetweenTicks = 32; globalConfig.debug.framePausesBetweenTicks = 32;
// globalConfig.mapChunkOverviewMinZoom = 0.0; // globalConfig.mapChunkOverviewMinZoom = 0.0;
// globalConfig.debug.instantBelts = true; // globalConfig.debug.instantBelts = true;
// globalConfig.debug.instantProcessors = true; // globalConfig.debug.instantProcessors = true;
// globalConfig.debug.instantMiners = true; // globalConfig.debug.instantMiners = true;
globalConfig.debug.disableSavegameWrite = true; globalConfig.debug.disableSavegameWrite = true;
// globalConfig.beltSpeedItemsPerSecond *= 2; // globalConfig.beltSpeedItemsPerSecond *= 2;
} }
if (globalConfig.debug.fastGameEnter) { if (globalConfig.debug.fastGameEnter) {
globalConfig.debug.noArtificalDelays = true; globalConfig.debug.noArtificalDelays = true;
} }

View File

@ -1,114 +1,114 @@
export default { export default {
// You can set any debug options here! // You can set any debug options here!
/* dev:start */ /* dev:start */
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Quickly enters the game and skips the main menu - good for fast iterating _fastGameEnter: "Quickly enters the game and skips the main menu - good for fast iterating",
// fastGameEnter: true, fastGameEnter: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Skips any delays like transitions between states and such _noArtificialDelays: "Skips any delays like transitions between states and such",
// noArtificialDelays: true, noArtificialDelays: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables writing of savegames, useful for testing the same savegame over and over _disableSavegameWrite: "Disables writing of savegames, useful for testing the same savegame over and over",
// disableSavegameWrite: true, disableSavegameWrite: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Shows bounds of all entities _showEntityBounds: "Shows bounds of all entities",
// showEntityBounds: true, showEntityBounds: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Shows arrows for every ejector / acceptor _showAcceptorEjectors: "Shows arrows for every ejector / acceptor",
// showAcceptorEjectors: true, showAcceptorEjectors: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables the music (Overrides any setting, can cause weird behaviour) _disableMusic: "Disables the music (Overrides any setting, can cause weird behaviour)",
// disableMusic: true, disableMusic: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Do not render static map entities (=most buildings) _doNotRenderStatics: "Do not render static map entities (=most buildings)",
// doNotRenderStatics: true, doNotRenderStatics: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Allow to zoom freely without limits _disableZoomLimits: "Allow to zoom freely without limits",
// disableZoomLimits: true, disableZoomLimits: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Shows a border arround every chunk _showChunkBorders: "Shows a border arround every chunk",
// showChunkBorders: true, showChunkBorders: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// All rewards can be unlocked by passing just 1 of any shape _rewardsInstant: "All rewards can be unlocked by passing just 1 of any shape",
// rewardsInstant: true, rewardsInstant: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Unlocks all buildings _allBuildingsUnlocked: "Unlocks all buildings",
// allBuildingsUnlocked: true, allBuildingsUnlocked: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables cost of blueprints _blueprintsNoCost: "Disables cost of blueprints",
// blueprintsNoCost: true, blueprintsNoCost: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables cost of upgrades _upgradesNoCost: "Disables cost of upgrades",
// upgradesNoCost: true, upgradesNoCost: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables the dialog when completing a level _disableUnlockDialog: "Disables the dialog when completing a level",
// disableUnlockDialog: true, disableUnlockDialog: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables the simulation - This effectively pauses the game. _disableLogicTicks: "Disables the simulation - This effectively pauses the game.",
// disableLogicTicks: true, disableLogicTicks: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Test the rendering if everything is clipped out properly _testClipping: "Test the rendering if everything is clipped out properly",
// testClipping: true, testClipping: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Allows to render slower, useful for recording at half speed to avoid stuttering // Allows to render slower, useful for recording at half speed to avoid stuttering
// framePausesBetweenTicks: 250, // framePausesBetweenTicks: 250,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Replace all translations with emojis to see which texts are translateable _testTranslations: "Replace all translations with emojis to see which texts are translateable",
// testTranslations: true, testTranslations: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Enables an inspector which shows information about the entity below the curosr _enableEntityInspector: "Enables an inspector which shows information about the entity below the curosr",
// enableEntityInspector: true, enableEntityInspector: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Enables ads in the local build (normally they are deactivated there) _testAds: "Enables ads in the local build (normally they are deactivated there)",
// testAds: true, testAds: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables the automatic switch to an overview when zooming out _disableMapOverview: "Disables the automatic switch to an overview when zooming out",
// disableMapOverview: true, disableMapOverview: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables the notification when there are new entries in the changelog since last played _disableUpgradeNotification: "Disables the notification when there are new entries in the changelog since last played",
// disableUpgradeNotification: true, disableUpgradeNotification: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Makes belts almost infinitely fast _instantBelts: "Makes belts almost infinitely fast",
// instantBelts: true, instantBelts: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Makes item processors almost infinitely fast _instantProcessors: "Makes item processors almost infinitely fast",
// instantProcessors: true, instantProcessors: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Makes miners almost infinitely fast _instantMiners: "Makes miners almost infinitely fast",
// instantMiners: true, instantMiners: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// When using fastGameEnter, controls whether a new game is started or the last one is resumed _resumeGameOnFastEnter: "When using fastGameEnter, controls whether a new game is started or the last one is resumed",
// resumeGameOnFastEnter: true, resumeGameOnFastEnter: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Special option used to render the trailer _renderForTrailer: "Special option used to render the trailer",
// renderForTrailer: true, renderForTrailer: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Whether to render changes _renderChanges: "Whether to render changes",
// renderChanges: true, renderChanges: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Whether to render belt paths _renderBeltPaths: "Whether to render belt paths",
// renderBeltPaths: true, renderBeltPaths: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Whether to check belt paths _checkBeltPaths: "Whether to check belt paths",
// checkBeltPaths: true, checkBeltPaths: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Whether to items / s instead of items / m in stats _detailedStatistics: "Whether to items / s instead of items / m in stats",
// detailedStatistics: true, detailedStatistics: false,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Shows detailed information about which atlas is used // Shows detailed information about which atlas is used
// showAtlasInfo: true, // showAtlasInfo: true,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Renders the rotation of all wires // Renders the rotation of all wires
// renderWireRotations: true, // renderWireRotations: true,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Renders information about wire networks // Renders information about wire networks
// renderWireNetworkInfos: true, // renderWireNetworkInfos: true,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Disables ejector animations and processing // Disables ejector animations and processing
// disableEjectorProcessing: true, // disableEjectorProcessing: true,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
// Allows manual ticking // Allows manual ticking
// manualTickOnly: true, // manualTickOnly: true,
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
/* dev:end */ /* dev:end */
}; };

View File

@ -10,6 +10,7 @@ import { THEMES, THEME, applyGameTheme } from "../game/theme";
import { IS_DEMO } from "../core/config"; import { IS_DEMO } from "../core/config";
import { T } from "../translations"; import { T } from "../translations";
import { LANGUAGES } from "../languages"; import { LANGUAGES } from "../languages";
import { globalConfig, IS_DEBUG } from "../core/config";
const logger = createLogger("application_settings"); const logger = createLogger("application_settings");
@ -21,6 +22,7 @@ export const enumCategories = {
userInterface: "userInterface", userInterface: "userInterface",
performance: "performance", performance: "performance",
advanced: "advanced", advanced: "advanced",
debug: "debug",
}; };
export const uiScales = [ export const uiScales = [
@ -293,6 +295,21 @@ export const allApplicationSettings = [
new BoolSetting("lowQualityTextures", enumCategories.performance, (app, value) => {}), new BoolSetting("lowQualityTextures", enumCategories.performance, (app, value) => {}),
]; ];
if (IS_DEBUG) {
for (let k in globalConfig.debug) {
if (k.startsWith('_')) continue;
const setting = new BoolSetting(`debug_${ k }`, enumCategories.debug, (app, value) => {
globalConfig.debug[k] = value;
});
setting.validate = () => true;
T.settings.labels[`debug_${ k }`] = {
title: k.replace(/(?!^)([A-Z])/g, " $1"),
description: globalConfig.debug[`_${ k }`],
};
allApplicationSettings.push(setting);
}
}
export function getApplicationSettingById(id) { export function getApplicationSettingById(id) {
return allApplicationSettings.find(setting => setting.id === id); return allApplicationSettings.find(setting => setting.id === id);
} }
@ -374,7 +391,9 @@ export class ApplicationSettings extends ReadWriteProxy {
* @param {string} key * @param {string} key
*/ */
getSetting(key) { getSetting(key) {
assert(this.getAllSettings().hasOwnProperty(key), "Setting not known: " + key); if (!key.startsWith('debug_')) {
assert(this.getAllSettings().hasOwnProperty(key), "Setting not known: " + key);
}
return this.getAllSettings()[key]; return this.getAllSettings()[key];
} }

View File

@ -185,6 +185,10 @@ export class BoolSetting extends BaseSetting {
} }
getHtml() { getHtml() {
if (!T.settings.labels[this.id].description) {
let a = T;
let b = a;
}
return ` return `
<div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}"> <div class="setting cardbox ${this.enabled ? "enabled" : "disabled"}">
${this.enabled ? "" : `<span class="standaloneOnlyHint">${T.demo.settingNotAvailable}</span>`} ${this.enabled ? "" : `<span class="standaloneOnlyHint">${T.demo.settingNotAvailable}</span>`}

View File

@ -721,6 +721,7 @@ settings:
userInterface: User Interface userInterface: User Interface
advanced: Advanced advanced: Advanced
performance: Performance performance: Performance
debug: Debug
versionBadges: versionBadges:
dev: Development dev: Development