diff --git a/index.html b/index.html index 954b22d..d34bcff 100644 --- a/index.html +++ b/index.html @@ -20,6 +20,7 @@
📝 Level Editor + âš™ī¸ Settings
Loading...
@@ -259,6 +260,118 @@
+ +
+
+ ← Back to Game + +

âš™ī¸ Game Settings

+

Configure graphics quality and physics settings

+ +
+ +
+

🎨 Graphics Quality

+

+ Higher quality settings may impact performance on lower-end devices. +

+ +
+ + +
Controls planet rendering quality and detail
+
+ +
+ + +
Controls asteroid rendering quality and detail
+
+ +
+ + +
Controls sun rendering quality
+
+
+ + +
+

âš›ī¸ Physics

+

+ Disabling physics can significantly improve performance but will prevent gameplay. +

+ +
+ +
+ Required for collisions, shooting, and asteroid movement. Disabling this will prevent gameplay but may help with debugging or viewing the scene. +
+
+
+ + +
+

â„šī¸ Quality Level Guide

+
+

Wireframe: Minimal rendering, shows mesh structure only. Best for debugging or very low-end devices.

+

Simple Material: Basic solid colors without textures. Good performance with basic visuals.

+

Full Texture: Standard textures with procedural generation. Recommended for most users.

+

PBR Texture: Physically-based rendering with enhanced materials. Best visual quality but higher GPU usage.

+
+
+ + +
+

💾 Storage Info

+
+

Settings are automatically saved to your browser's local storage and will persist between sessions.

+

+ âš ī¸ Note: Changes will take effect when you start a new level. Restart the current level to see changes. +

+
+
+
+ +
+ + +
+ +
+
+
+ diff --git a/public/styles.css b/public/styles.css index ed4289a..ad510af 100644 --- a/public/styles.css +++ b/public/styles.css @@ -115,11 +115,10 @@ body { box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4); } -.editor-link { +.editor-link, +.settings-link { position: absolute; top: 20px; - right: 20px; - background: rgba(76, 175, 80, 0.8); color: white; padding: 10px 20px; border-radius: 5px; @@ -129,13 +128,29 @@ body { z-index: 2000; } +.editor-link { + right: 180px; + background: rgba(76, 175, 80, 0.8); +} + .editor-link:hover { background: rgba(76, 175, 80, 1); transform: scale(1.05); } +.settings-link { + right: 20px; + background: rgba(33, 150, 243, 0.8); +} + +.settings-link:hover { + background: rgba(33, 150, 243, 1); + transform: scale(1.05); +} + /* Editor View Styles */ -[data-view="editor"] { +[data-view="editor"], +[data-view="settings"] { background: linear-gradient(135deg, #0a0618, #1a1033, #0f0c29); min-height: 100vh; padding: 15px; @@ -165,7 +180,8 @@ body { text-shadow: 0 1px 3px rgba(0,0,0,0.8); } -.editor-grid { +.editor-grid, +.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 15px; diff --git a/src/main.ts b/src/main.ts index d6c9c2c..50b3dbc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -229,6 +229,17 @@ router.on('/editor', () => { } }); +router.on('/settings', () => { + showView('settings'); + // Dynamically import and initialize settings + if (!(window as any).__settingsInitialized) { + import('./settingsScreen').then((module) => { + module.initializeSettingsScreen(); + (window as any).__settingsInitialized = true; + }); + } +}); + // Generate default levels if localStorage is empty generateDefaultLevels(); diff --git a/src/settingsScreen.ts b/src/settingsScreen.ts new file mode 100644 index 0000000..b21d2a1 --- /dev/null +++ b/src/settingsScreen.ts @@ -0,0 +1,78 @@ +import { GameConfig, TextureLevel } from "./gameConfig"; + +/** + * Initialize the settings screen + */ +export function initializeSettingsScreen(): void { + const config = GameConfig.getInstance(); + + // Get form elements + const planetTextureSelect = document.getElementById('planetTextureLevel') as HTMLSelectElement; + const asteroidTextureSelect = document.getElementById('asteroidTextureLevel') as HTMLSelectElement; + const sunTextureSelect = document.getElementById('sunTextureLevel') as HTMLSelectElement; + const physicsEnabledCheckbox = document.getElementById('physicsEnabled') as HTMLInputElement; + + const saveBtn = document.getElementById('saveSettingsBtn'); + const resetBtn = document.getElementById('resetSettingsBtn'); + const messageDiv = document.getElementById('settingsMessage'); + + // Load current settings + loadSettings(); + + // Save button handler + saveBtn?.addEventListener('click', () => { + saveSettings(); + showMessage('Settings saved successfully!', 'success'); + }); + + // Reset button handler + resetBtn?.addEventListener('click', () => { + if (confirm('Are you sure you want to reset all settings to defaults?')) { + config.reset(); + loadSettings(); + showMessage('Settings reset to defaults', 'info'); + } + }); + + /** + * Load current settings into form + */ + function loadSettings(): void { + if (planetTextureSelect) planetTextureSelect.value = config.planetTextureLevel; + if (asteroidTextureSelect) asteroidTextureSelect.value = config.asteroidTextureLevel; + if (sunTextureSelect) sunTextureSelect.value = config.sunTextureLevel; + if (physicsEnabledCheckbox) physicsEnabledCheckbox.checked = config.physicsEnabled; + } + + /** + * Save form settings to GameConfig + */ + function saveSettings(): void { + config.planetTextureLevel = planetTextureSelect.value as TextureLevel; + config.asteroidTextureLevel = asteroidTextureSelect.value as TextureLevel; + config.sunTextureLevel = sunTextureSelect.value as TextureLevel; + config.physicsEnabled = physicsEnabledCheckbox.checked; + config.save(); + } + + /** + * Show a temporary message + */ + function showMessage(message: string, type: 'success' | 'info' | 'warning'): void { + if (!messageDiv) return; + + const colors = { + success: '#4CAF50', + info: '#2196F3', + warning: '#FF9800' + }; + + messageDiv.textContent = message; + messageDiv.style.color = colors[type]; + messageDiv.style.opacity = '1'; + + setTimeout(() => { + messageDiv.style.opacity = '0'; + }, 3000); + } +}