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

View File

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

View File

@ -10,6 +10,7 @@ import { THEMES, THEME, applyGameTheme } from "../game/theme";
import { IS_DEMO } from "../core/config";
import { T } from "../translations";
import { LANGUAGES } from "../languages";
import { globalConfig, IS_DEBUG } from "../core/config";
const logger = createLogger("application_settings");
@ -21,6 +22,7 @@ export const enumCategories = {
userInterface: "userInterface",
performance: "performance",
advanced: "advanced",
debug: "debug",
};
export const uiScales = [
@ -293,6 +295,21 @@ export const allApplicationSettings = [
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) {
return allApplicationSettings.find(setting => setting.id === id);
}
@ -374,7 +391,9 @@ export class ApplicationSettings extends ReadWriteProxy {
* @param {string} 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];
}

View File

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

View File

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