All checks were successful
Build / build (push) Successful in 1m16s
- Create debugLog wrapper function in src/debug.ts - Add debug checkbox to settings screen UI - Replace all console.log statements with debugLog calls (153 replacements) - Add debug flag to GameConfig with localStorage persistence - Fix GameConfig to properly load and reset debug setting - Preserve console.error and console.warn calls unchanged - Add Developer section to settings screen with debug toggle - Enable/disable all debug logging via settings UI checkbox Debug logging can now be controlled from Settings > Developer section, reducing console noise in production while maintaining full debugging capability during development. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
91 lines
2.8 KiB
TypeScript
91 lines
2.8 KiB
TypeScript
/**
|
|
* Texture detail levels for game objects
|
|
*/
|
|
export enum TextureLevel {
|
|
WIREFRAME = 'WIREFRAME',
|
|
SIMPLE_MATERIAL = 'SIMPLE_MATERIAL',
|
|
FULL_TEXTURE = 'FULL_TEXTURE',
|
|
PBR_TEXTURE = 'PBR_TEXTURE'
|
|
}
|
|
|
|
/**
|
|
* Global game configuration settings
|
|
* Singleton class for managing game-wide settings
|
|
*/
|
|
export class GameConfig {
|
|
private static _instance: GameConfig;
|
|
|
|
// Texture detail settings
|
|
public planetTextureLevel: TextureLevel = TextureLevel.FULL_TEXTURE;
|
|
public asteroidTextureLevel: TextureLevel = TextureLevel.FULL_TEXTURE;
|
|
public sunTextureLevel: TextureLevel = TextureLevel.FULL_TEXTURE;
|
|
public debug: boolean = false;
|
|
// Physics settings
|
|
public physicsEnabled: boolean = true;
|
|
|
|
/**
|
|
* Private constructor for singleton pattern
|
|
*/
|
|
private constructor() {
|
|
// Load settings from localStorage if available
|
|
this.loadFromStorage();
|
|
}
|
|
|
|
/**
|
|
* Get the singleton instance
|
|
*/
|
|
public static getInstance(): GameConfig {
|
|
if (!GameConfig._instance) {
|
|
GameConfig._instance = new GameConfig();
|
|
}
|
|
return GameConfig._instance;
|
|
}
|
|
|
|
/**
|
|
* Save current configuration to localStorage
|
|
*/
|
|
public save(): void {
|
|
const config = {
|
|
planetTextureLevel: this.planetTextureLevel,
|
|
asteroidTextureLevel: this.asteroidTextureLevel,
|
|
sunTextureLevel: this.sunTextureLevel,
|
|
physicsEnabled: this.physicsEnabled,
|
|
debug: this.debug
|
|
};
|
|
localStorage.setItem('game-config', JSON.stringify(config));
|
|
}
|
|
|
|
/**
|
|
* Load configuration from localStorage
|
|
*/
|
|
private loadFromStorage(): void {
|
|
try {
|
|
const stored = localStorage.getItem('game-config');
|
|
if (stored) {
|
|
const config = JSON.parse(stored);
|
|
this.planetTextureLevel = config.planetTextureLevel ?? TextureLevel.FULL_TEXTURE;
|
|
this.asteroidTextureLevel = config.asteroidTextureLevel ?? TextureLevel.FULL_TEXTURE;
|
|
this.sunTextureLevel = config.sunTextureLevel ?? TextureLevel.FULL_TEXTURE;
|
|
this.physicsEnabled = config.physicsEnabled ?? true;
|
|
this.debug = config.debug ?? false;
|
|
} else {
|
|
this.save();
|
|
}
|
|
} catch (error) {
|
|
console.warn('Failed to load game config from localStorage:', error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reset to default settings
|
|
*/
|
|
public reset(): void {
|
|
this.planetTextureLevel = TextureLevel.FULL_TEXTURE;
|
|
this.asteroidTextureLevel = TextureLevel.FULL_TEXTURE;
|
|
this.sunTextureLevel = TextureLevel.FULL_TEXTURE;
|
|
this.physicsEnabled = true;
|
|
this.debug = false;
|
|
this.save();
|
|
}
|
|
}
|