A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: add extensible settings dialog with registry pattern
esengine0c16c20587f1
diff --git a/editor/src/Editor.ts b/editor/src/Editor.tsindex 2c87f077c..9f2d8c20e 100644--- a/editor/src/Editor.ts+++ b/editor/src/Editor.ts@@ -55,6 +55,16 @@ import { showToast, showSuccessToast, showErrorToast } from './ui/Toast';import { showContextMenu } from './ui/ContextMenu';import { showConfirmDialog, showInputDialog } from './ui/dialog';import { getEditorStore } from './store';+import {+ registerBuiltinSettings,+ lockBuiltinSettings,+ clearExtensionSettings,+ showSettingsDialog,+ registerSettingsSection,+ registerSettingsItem,+ getSettingsValue,+ setSettingsValue,+} from './settings';// =============================================================================// Types@@ -95,6 +105,7 @@ export class Editor {registerBuiltinSchemas();initBoundsProviders();registerBuiltinGizmos();+ registerBuiltinSettings();registerBuiltinPanels({projectPath: this.projectPath_ ?? undefined,@@ -107,6 +118,7 @@ export class Editor {lockBuiltinPropertyEditors();lockBuiltinComponentSchemas();lockBuiltinBoundsProviders();+ lockBuiltinSettings();this.setupLayout();@@ -303,6 +315,10 @@ export class Editor {document.body.appendChild(overlay);}+ showSettings(): void {+ showSettingsDialog();+ }+// =========================================================================// Script Operations// =========================================================================@@ -396,6 +412,10 @@ export class Editor {registerDrawCallback,unregisterDrawCallback,clearDrawCallbacks,+ registerSettingsSection,+ registerSettingsItem,+ getSettingsValue,+ setSettingsValue,};setEditorAPI(this.baseAPI_);}@@ -446,6 +466,7 @@ export class Editor {clearExtensionPropertyEditors();clearExtensionComponentSchemas();clearExtensionBoundsProviders();+ clearExtensionSettings();}private applyExtensionUI(): void {diff --git a/editor/src/index.ts b/editor/src/index.tsindex a06a52b2a..87036cd99 100644--- a/editor/src/index.ts+++ b/editor/src/index.ts@@ -331,6 +331,24 @@ export {type ExtensionLoaderOptions,} from './extension';+// =============================================================================+// Settings+// =============================================================================++export {+ type SettingsItemType,+ type SettingsSectionDescriptor,+ type SettingsItemDescriptor,+ registerSettingsSection,+ registerSettingsItem,+ getSettingsValue,+ setSettingsValue,+ onSettingsChange,+ getAllSections,+ getSectionItems,+ showSettingsDialog,+} from './settings';+// =============================================================================// SDK Re-exports// =============================================================================diff --git a/editor/src/menus/builtinMenus.ts b/editor/src/menus/builtinMenus.tsindex f5fe8309b..947775f16 100644--- a/editor/src/menus/builtinMenus.ts+++ b/editor/src/menus/builtinMenus.ts@@ -60,6 +60,11 @@ export function registerBuiltinMenus(editor: Editor): void {enabled: () => editor.store.selectedEntity !== null,action: () => editor.duplicateSelected(),});+ registerMenuItem({+ id: 'edit.preferences', menu: 'edit', label: 'Preferences...',+ shortcut: 'Ctrl+,', order: 10, separator: true,+ action: () => editor.showSettings(),+ });registerMenuItem({id: 'view.hierarchy', menu: 'view', label: 'Hierarchy', order: 0,diff --git a/editor/src/panels/SceneViewPanel.ts b/editor/src/panels/SceneViewPanel.tsindex 43deb6fb2..356c6777d 100644--- a/editor/src/panels/SceneViewPanel.ts+++ b/editor/src/panels/SceneViewPanel.ts@@ -15,40 +15,7 @@ import { quatToEuler, eulerToQuat } from '../math/Transform';import { getEntityBounds } from '../bounds';import { GizmoManager, getAllGizmos } from '../gizmos';import type { GizmoContext } from '../gizmos';--// =============================================================================-// Types-// =============================================================================--interface GizmoSettings {- showGrid: boolean;- gridColor: string;- gridOpacity: number;- showGizmos: boolean;- showSelectionBox: boolean;-}--const DEFAULT_GIZMO_SETTINGS: GizmoSettings = {- showGrid: true,- gridColor: '#333333',- gridOpacity: 1.0,- showGizmos: true,- showSelectionBox: true,-};--const GIZMO_SETTINGS_KEY = 'esengine_gizmo_settings';--function loadGizmoSettings(): GizmoSettings {- try {- const raw = localStorage.getItem(GIZMO_SETTINGS_KEY);- if (raw) return { ...DEFAULT_GIZMO_SETTINGS, ...JSON.parse(raw) };- } catch { /* ignore */ }- return { ...DEFAULT_GIZMO_SETTINGS };-}--function saveGizmoSettings(settings: GizmoSettings): void {- localStorage.setItem(GIZMO_SETTINGS_KEY, JSON.stringify(settings));-}+import { getSettingsValue, setSettingsValue, onSettingsChange } from '../settings/SettingsRegistry';// =============================================================================// SceneViewPanel@@ -96,9 +63,9 @@ export class SceneViewPanel {private metadataCache_: Map<string, SliceBorder | null> = new Map();private loadingTextures_: Set<string> = new Set();- private gizmoSettings_: GizmoSettings = loadGizmoSettings();private settingsDropdown_: HTMLElement | null = null;private settingsDropdownClickHandler_: ((e: MouseEvent) => void) | null = null;+ private unsubscribeSettings_: (() => void) | null = null;private getEntityBoundsWithSpine(entityData: import('../types/SceneTypes').EntityData): { width: number; height: number; offsetX?: number; offsetY?: number } {const hasSpine = entityData.components.some(c => c.type === 'SpineAnimation');@@ -140,28 +107,28 @@ export class SceneViewPanel {<div class="es-gizmo-settings-dropdown" style="display: none;"><div class="es-settings-row"><label class="es-settings-checkbox">- <input type="checkbox" data-setting="showGrid" ${this.gizmoSettings_.showGrid ? 'checked' : ''}>+ <input type="checkbox" data-setting="scene.showGrid" ${getSettingsValue<boolean>('scene.showGrid') ? 'checked' : ''}><span>Show Grid</span></label></div><div class="es-settings-row"><label class="es-settings-label">Grid Color</label>- <input type="color" data-setting="gridColor" value="${this.gizmoSettings_.gridColor}" class="es-color-input">+ <input type="color" data-setting="scene.gridColor" value="${getSettingsValue<string>('scene.gridColor')}" class="es-color-input"></div><div class="es-settings-row"><label class="es-settings-label">Grid Opacity</label>- <input type="range" data-setting="gridOpacity" min="0" max="1" step="0.1" value="${this.gizmoSettings_.gridOpacity}" class="es-slider-input">+ <input type="range" data-setting="scene.gridOpacity" min="0" max="1" step="0.1" value="${getSettingsValue<number>('scene.gridOpacity')}" class="es-slider-input"></div><div class="es-settings-divider"></div><div class="es-settings-row"><label class="es-settings-checkbox">- <input type="checkbox" data-setting="showGizmos" ${this.gizmoSettings_.showGizmos ? 'checked' : ''}>+ <input type="checkbox" data-setting="scene.showGizmos" ${getSettingsValue<boolean>('scene.showGizmos') ? 'checked' : ''}><span>Show Gizmos</span></label></div><div class="es-settings-row"><label class="es-settings-checkbox">- <input type="checkbox" data-setting="showSelectionBox" ${this.gizmoSettings_.showSelectionBox ? 'checked' : ''}>+ <input type="checkbox" data-setting="scene.showSelectionBox" ${getSettingsValue<boolean>('scene.showSelectionBox') ? 'checked' : ''}><span>Show Selection Box</span></label></div>@@ -224,6 +191,10 @@ export class SceneViewPanel {document.removeEventListener('click', this.settingsDropdownClickHandler_);this.settingsDropdownClickHandler_ = null;}+ if (this.unsubscribeSettings_) {+ this.unsubscribeSettings_();+ this.unsubscribeSettings_ = null;+ }if (this.sceneRenderer_) {this.sceneRenderer_.dispose();this.sceneRenderer_ = null;@@ -465,28 +436,39 @@ export class SceneViewPanel {document.addEventListener('click', this.settingsDropdownClickHandler_);this.settingsDropdown_.querySelectorAll('input').forEach(input => {- const setting = input.dataset.setting as keyof GizmoSettings;- if (!setting) return;+ const settingId = input.dataset.setting;+ if (!settingId) return;input.addEventListener('change', () => {if (input.type === 'checkbox') {- (this.gizmoSettings_ as any)[setting] = input.checked;+ setSettingsValue(settingId, input.checked);} else if (input.type === 'range') {- (this.gizmoSettings_ as any)[setting] = parseFloat(input.value);+ setSettingsValue(settingId, parseFloat(input.value));} else if (input.type === 'color') {- (this.gizmoSettings_ as any)[setting] = input.value;+ setSettingsValue(settingId, input.value);}- saveGizmoSettings(this.gizmoSettings_);this.requestRender();});if (input.type === 'range') {input.addEventListener('input', () => {- (this.gizmoSettings_ as any)[setting] = parseFloat(input.value);+ setSettingsValue(settingId, parseFloat(input.value));this.requestRender();});}});++ this.unsubscribeSettings_ = onSettingsChange((id, value) => {+ if (!id.startsWith('scene.')) return;+ const input = this.settingsDropdown_?.querySelector(`[data-setting="${id}"]`) as HTMLInputElement | null;+ if (!input) return;+ if (input.type === 'checkbox') {+ input.checked = value as boolean;+ } else {+ input.value = String(value);+ }+ this.requestRender();+ });}private updateGizmoContext(): void {@@ -778,13 +760,13 @@ export class SceneViewPanel {const selectedEntity = this.store_.selectedEntity;if (selectedEntity !== null && this.store_.isEntityVisible(selectedEntity as number)) {- if (this.gizmoSettings_.showSelectionBox) {+ if (getSettingsValue<boolean>('scene.showSelectionBox')) {this.drawSelectionBox(ctx);}this.drawCameraFrustum(ctx);- if (this.gizmoManager_.getActiveId() !== 'select' && this.gizmoSettings_.showGizmos) {+ if (this.gizmoManager_.getActiveId() !== 'select' && getSettingsValue<boolean>('scene.showGizmos')) {this.gizmoManager_.setContext(this.createGizmoContext(ctx));this.gizmoManager_.draw();}@@ -918,7 +900,7 @@ export class SceneViewPanel {if (selectedEntity !== null && this.store_.isEntityVisible(selectedEntity as number)) {this.drawCameraFrustum(ctx);- if (this.gizmoManager_.getActiveId() !== 'select' && this.gizmoSettings_.showGizmos) {+ if (this.gizmoManager_.getActiveId() !== 'select' && getSettingsValue<boolean>('scene.showGizmos')) {this.gizmoManager_.setContext(this.createGizmoContext(ctx));this.gizmoManager_.draw();}@@ -928,7 +910,7 @@ export class SceneViewPanel {}private drawGrid(ctx: CanvasRenderingContext2D, w: number, h: number): void {- if (!this.gizmoSettings_.showGrid) return;+ if (!getSettingsValue<boolean>('scene.showGrid')) return;const gridSize = 50;const halfW = w / 2 / this.zoom_;@@ -939,8 +921,8 @@ export class SceneViewPanel {const startY = Math.floor((-halfH - this.panY_) / gridSize) * gridSize;const endY = Math.ceil((halfH - this.panY_) / gridSize) * gridSize;- ctx.globalAlpha = this.gizmoSettings_.gridOpacity;- ctx.strokeStyle = this.gizmoSettings_.gridColor;+ ctx.globalAlpha = getSettingsValue<number>('scene.gridOpacity');+ ctx.strokeStyle = getSettingsValue<string>('scene.gridColor');ctx.lineWidth = 1 / this.zoom_;for (let x = startX; x <= endX; x += gridSize) {@@ -959,7 +941,7 @@ export class SceneViewPanel {ctx.stroke();}- ctx.strokeStyle = this.lightenColor(this.gizmoSettings_.gridColor, 30);+ ctx.strokeStyle = this.lightenColor(getSettingsValue<string>('scene.gridColor'), 30);ctx.lineWidth = 2 / this.zoom_;ctx.beginPath();ctx.moveTo(startX, 0);diff --git a/editor/src/settings/SettingsDialog.ts b/editor/src/settings/SettingsDialog.tsnew file mode 100644index 000000000..1e98993b7--- /dev/null+++ b/editor/src/settings/SettingsDialog.ts@@ -0,0 +1,223 @@+import { Dialog } from '../ui/dialog/Dialog';+import {+ getAllSections,+ getSectionItems,+ getSettingsValue,+ setSettingsValue,+ onSettingsChange,+ type SettingsItemDescriptor,+} from './SettingsRegistry';++export function showSettingsDialog(): void {+ const sections = getAllSections();+ if (sections.length === 0) return;++ const body = document.createElement('div');+ body.className = 'es-settings-dialog-body';++ const nav = document.createElement('div');+ nav.className = 'es-settings-nav';++ const content = document.createElement('div');+ content.className = 'es-settings-content';++ body.appendChild(nav);+ body.appendChild(content);++ let activeSectionId = sections[0].id;+ const inputElements = new Map<string, HTMLInputElement | HTMLSelectElement>();++ function buildNav(): void {+ nav.innerHTML = '';+ for (const section of sections) {+ const btn = document.createElement('button');+ btn.className = 'es-settings-nav-item';+ if (section.id === activeSectionId) {+ btn.classList.add('es-active');+ }+ btn.textContent = section.title;+ btn.addEventListener('click', () => {+ activeSectionId = section.id;+ buildNav();+ buildContent();+ });+ nav.appendChild(btn);+ }+ }++ function buildContent(): void {+ content.innerHTML = '';+ const items = getSectionItems(activeSectionId);+ const section = sections.find(s => s.id === activeSectionId);++ if (section) {+ const heading = document.createElement('h3');+ heading.className = 'es-settings-section-title';+ heading.textContent = section.title;+ content.appendChild(heading);+ }++ for (const item of items) {+ const row = document.createElement('div');+ row.className = 'es-settings-item';+ content.appendChild(row);+ renderItem(row, item);+ }+ }++ function renderItem(container: HTMLElement, item: SettingsItemDescriptor): void {+ const value = getSettingsValue(item.id);++ switch (item.type) {+ case 'boolean': {+ const label = document.createElement('label');+ label.className = 'es-settings-checkbox-row';+ const input = document.createElement('input');+ input.type = 'checkbox';+ input.checked = value as boolean;+ input.addEventListener('change', () => {+ setSettingsValue(item.id, input.checked);+ });+ const span = document.createElement('span');+ span.textContent = item.label;+ label.appendChild(input);+ label.appendChild(span);+ container.appendChild(label);+ inputElements.set(item.id, input);+ break;+ }+ case 'number': {+ const label = document.createElement('label');+ label.className = 'es-settings-label';+ label.textContent = item.label;+ container.appendChild(label);+ const input = document.createElement('input');+ input.type = 'number';+ input.className = 'es-settings-input';+ input.value = String(value ?? '');+ if (item.min !== undefined) input.min = String(item.min);+ if (item.max !== undefined) input.max = String(item.max);+ if (item.step !== undefined) input.step = String(item.step);+ input.addEventListener('change', () => {+ setSettingsValue(item.id, parseFloat(input.value));+ });+ container.appendChild(input);+ inputElements.set(item.id, input);+ break;+ }+ case 'string': {+ const label = document.createElement('label');+ label.className = 'es-settings-label';+ label.textContent = item.label;+ container.appendChild(label);+ const input = document.createElement('input');+ input.type = 'text';+ input.className = 'es-settings-input';+ input.value = (value as string) ?? '';+ input.addEventListener('change', () => {+ setSettingsValue(item.id, input.value);+ });+ container.appendChild(input);+ inputElements.set(item.id, input);+ break;+ }+ case 'color': {+ const row = document.createElement('div');+ row.className = 'es-settings-color-row';+ const label = document.createElement('label');+ label.className = 'es-settings-label';+ label.textContent = item.label;+ row.appendChild(label);+ const input = document.createElement('input');+ input.type = 'color';+ input.className = 'es-color-input';+ input.value = (value as string) ?? '#000000';+ input.addEventListener('input', () => {+ setSettingsValue(item.id, input.value);+ });+ row.appendChild(input);+ container.appendChild(row);+ inputElements.set(item.id, input);+ break;+ }+ case 'select': {+ const label = document.createElement('label');+ label.className = 'es-settings-label';+ label.textContent = item.label;+ container.appendChild(label);+ const select = document.createElement('select');+ select.className = 'es-settings-select';+ for (const opt of item.options ?? []) {+ const option = document.createElement('option');+ option.value = opt.value;+ option.textContent = opt.label;+ if (opt.value === value) option.selected = true;+ select.appendChild(option);+ }+ select.addEventListener('change', () => {+ setSettingsValue(item.id, select.value);+ });+ container.appendChild(select);+ inputElements.set(item.id, select);+ break;+ }+ case 'range': {+ const row = document.createElement('div');+ row.className = 'es-settings-range-row';+ const label = document.createElement('label');+ label.className = 'es-settings-label';+ label.textContent = item.label;+ row.appendChild(label);+ const valueDisplay = document.createElement('span');+ valueDisplay.className = 'es-settings-range-value';+ valueDisplay.textContent = String(value ?? 0);+ row.appendChild(valueDisplay);+ container.appendChild(row);+ const input = document.createElement('input');+ input.type = 'range';+ input.className = 'es-slider-input';+ input.value = String(value ?? 0);+ if (item.min !== undefined) input.min = String(item.min);+ if (item.max !== undefined) input.max = String(item.max);+ if (item.step !== undefined) input.step = String(item.step);+ input.addEventListener('input', () => {+ const val = parseFloat(input.value);+ valueDisplay.textContent = String(val);+ setSettingsValue(item.id, val);+ });+ container.appendChild(input);+ inputElements.set(item.id, input);+ break;+ }+ }+ }++ buildNav();+ buildContent();++ const unsubscribe = onSettingsChange((id, value) => {+ const el = inputElements.get(id);+ if (!el) return;+ if (el instanceof HTMLSelectElement) {+ el.value = String(value);+ } else if (el.type === 'checkbox') {+ (el as HTMLInputElement).checked = value as boolean;+ } else {+ el.value = String(value);+ }+ });++ const dialog = new Dialog({+ title: 'Preferences',+ content: body,+ width: 640,+ showCloseButton: true,+ closeOnOverlay: true,+ closeOnEscape: true,+ className: 'es-settings-dialog',+ });++ dialog.open().then(() => {+ unsubscribe();+ });+}diff --git a/editor/src/settings/SettingsRegistry.ts b/editor/src/settings/SettingsRegistry.tsnew file mode 100644index 000000000..ad4d4ecfd--- /dev/null+++ b/editor/src/settings/SettingsRegistry.ts@@ -0,0 +1,148 @@+export type SettingsItemType = 'boolean' | 'number' | 'string' | 'color' | 'select' | 'range';++export interface SettingsSectionDescriptor {+ id: string;+ title: string;+ icon?: string;+ order?: number;+}++export interface SettingsItemDescriptor {+ id: string;+ section: string;+ label: string;+ type: SettingsItemType;+ defaultValue: unknown;+ order?: number;+ options?: { label: string; value: string }[];+ min?: number;+ max?: number;+ step?: number;+ onChange?: (value: unknown) => void;+}++type SettingsChangeListener = (id: string, value: unknown) => void;++const STORAGE_KEY = 'esengine_settings';++const sections_ = new Map<string, SettingsSectionDescriptor>();+const items_ = new Map<string, SettingsItemDescriptor>();+const values_ = new Map<string, unknown>();+const listeners_: SettingsChangeListener[] = [];+let builtinSectionIds_: Set<string> | null = null;+let builtinItemIds_: Set<string> | null = null;++const LEGACY_GIZMO_KEY = 'esengine_gizmo_settings';++const LEGACY_KEY_MAP: Record<string, string> = {+ showGrid: 'scene.showGrid',+ gridColor: 'scene.gridColor',+ gridOpacity: 'scene.gridOpacity',+ showGizmos: 'scene.showGizmos',+ showSelectionBox: 'scene.showSelectionBox',+};++function migrateLegacySettings(): void {+ try {+ const raw = localStorage.getItem(LEGACY_GIZMO_KEY);+ if (!raw) return;+ const data = JSON.parse(raw) as Record<string, unknown>;+ for (const [oldKey, newKey] of Object.entries(LEGACY_KEY_MAP)) {+ if (oldKey in data && !values_.has(newKey)) {+ values_.set(newKey, data[oldKey]);+ }+ }+ localStorage.removeItem(LEGACY_GIZMO_KEY);+ saveToStorage();+ } catch { /* ignore */ }+}++function loadFromStorage(): void {+ try {+ const raw = localStorage.getItem(STORAGE_KEY);+ if (raw) {+ const data = JSON.parse(raw) as Record<string, unknown>;+ for (const [key, value] of Object.entries(data)) {+ values_.set(key, value);+ }+ }+ } catch { /* ignore */ }+}++function saveToStorage(): void {+ try {+ const data: Record<string, unknown> = {};+ for (const [key, value] of values_) {+ data[key] = value;+ }+ localStorage.setItem(STORAGE_KEY, JSON.stringify(data));+ } catch { /* ignore */ }+}++loadFromStorage();+migrateLegacySettings();++export function registerSettingsSection(descriptor: SettingsSectionDescriptor): void {+ sections_.set(descriptor.id, descriptor);+}++export function registerSettingsItem(descriptor: SettingsItemDescriptor): void {+ items_.set(descriptor.id, descriptor);+ if (!values_.has(descriptor.id)) {+ values_.set(descriptor.id, descriptor.defaultValue);+ }+}++export function getSettingsValue<T = unknown>(id: string): T {+ if (values_.has(id)) return values_.get(id) as T;+ const item = items_.get(id);+ return (item?.defaultValue ?? undefined) as T;+}++export function setSettingsValue(id: string, value: unknown): void {+ const prev = values_.get(id);+ if (prev === value) return;++ values_.set(id, value);+ saveToStorage();++ const item = items_.get(id);+ item?.onChange?.(value);++ for (const listener of listeners_) {+ listener(id, value);+ }+}++export function onSettingsChange(listener: SettingsChangeListener): () => void {+ listeners_.push(listener);+ return () => {+ const idx = listeners_.indexOf(listener);+ if (idx >= 0) listeners_.splice(idx, 1);+ };+}++export function getAllSections(): SettingsSectionDescriptor[] {+ return [...sections_.values()].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));+}++export function getSectionItems(sectionId: string): SettingsItemDescriptor[] {+ return [...items_.values()]+ .filter(item => item.section === sectionId)+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));+}++export function lockBuiltinSettings(): void {+ builtinSectionIds_ = new Set(sections_.keys());+ builtinItemIds_ = new Set(items_.keys());+}++export function clearExtensionSettings(): void {+ if (!builtinSectionIds_ || !builtinItemIds_) return;+ for (const id of sections_.keys()) {+ if (!builtinSectionIds_.has(id)) sections_.delete(id);+ }+ for (const id of items_.keys()) {+ if (!builtinItemIds_.has(id)) items_.delete(id);+ }+}diff --git a/editor/src/settings/builtinSettings.ts b/editor/src/settings/builtinSettings.tsnew file mode 100644index 000000000..d862d0a51--- /dev/null+++ b/editor/src/settings/builtinSettings.ts@@ -0,0 +1,75 @@+import { registerSettingsSection, registerSettingsItem } from './SettingsRegistry';++export function registerBuiltinSettings(): void {+ registerSettingsSection({+ id: 'general',+ title: 'General',+ order: 0,+ });++ registerSettingsSection({+ id: 'scene-view',+ title: 'Scene View',+ order: 1,+ });++ registerSettingsItem({+ id: 'general.language',+ section: 'general',+ label: 'Language',+ type: 'select',+ defaultValue: 'en',+ order: 0,+ options: [+ { label: 'English', value: 'en' },+ ],+ });++ registerSettingsItem({+ id: 'scene.showGrid',+ section: 'scene-view',+ label: 'Show Grid',+ type: 'boolean',+ defaultValue: true,+ order: 0,+ });++ registerSettingsItem({+ id: 'scene.gridColor',+ section: 'scene-view',+ label: 'Grid Color',+ type: 'color',+ defaultValue: '#333333',+ order: 1,+ });++ registerSettingsItem({+ id: 'scene.gridOpacity',+ section: 'scene-view',+ label: 'Grid Opacity',+ type: 'range',+ defaultValue: 1.0,+ min: 0,+ max: 1,+ step: 0.1,+ order: 2,+ });++ registerSettingsItem({+ id: 'scene.showGizmos',+ section: 'scene-view',+ label: 'Show Gizmos',+ type: 'boolean',+ defaultValue: true,+ order: 3,+ });++ registerSettingsItem({+ id: 'scene.showSelectionBox',+ section: 'scene-view',+ label: 'Show Selection Box',+ type: 'boolean',+ defaultValue: true,+ order: 4,+ });+}diff --git a/editor/src/settings/index.ts b/editor/src/settings/index.tsnew file mode 100644index 000000000..4f7c9f158--- /dev/null+++ b/editor/src/settings/index.ts@@ -0,0 +1,17 @@+export {+ type SettingsItemType,+ type SettingsSectionDescriptor,+ type SettingsItemDescriptor,+ registerSettingsSection,+ registerSettingsItem,+ getSettingsValue,+ setSettingsValue,+ onSettingsChange,+ getAllSections,+ getSectionItems,+ lockBuiltinSettings,+ clearExtensionSettings,+} from './SettingsRegistry';++export { showSettingsDialog } from './SettingsDialog';+export { registerBuiltinSettings } from './builtinSettings';diff --git a/editor/src/styles/editor.css b/editor/src/styles/editor.cssindex 292cf3a84..37806198a 100644--- a/editor/src/styles/editor.css+++ b/editor/src/styles/editor.css@@ -2383,6 +2383,156 @@ svg {border-color: #e53935;}+/* =============================================================================+ * Settings Dialog+ * ============================================================================= */++.es-settings-dialog {+ max-width: 640px !important;+}++.es-settings-dialog .es-dialog-body {+ padding: 0;+}++.es-settings-dialog-body {+ display: flex;+ min-height: 400px;+}++.es-settings-nav {+ width: 180px;+ min-width: 180px;+ background: var(--es-bg-primary);+ border-right: 1px solid var(--es-border);+ padding: 8px 0;+ overflow-y: auto;+}++.es-settings-nav-item {+ display: block;+ width: 100%;+ padding: 8px 16px;+ background: transparent;+ border: none;+ color: var(--es-text-secondary);+ font-size: 13px;+ text-align: left;+ cursor: pointer;+ transition: all 0.15s;+}++.es-settings-nav-item:hover {+ color: var(--es-text-primary);+ background: var(--es-bg-hover);+}++.es-settings-nav-item.es-active {+ color: var(--es-text-primary);+ background: var(--es-bg-tertiary);+ border-left: 2px solid #d19a66;+ padding-left: 14px;+}++.es-settings-content {+ flex: 1;+ padding: 20px;+ overflow-y: auto;+}++.es-settings-section-title {+ margin: 0 0 16px;+ font-size: 15px;+ font-weight: 500;+ color: var(--es-text-primary);+}++.es-settings-item {+ margin-bottom: 14px;+}++.es-settings-item:last-child {+ margin-bottom: 0;+}++.es-settings-label {+ display: block;+ margin-bottom: 6px;+ font-size: 13px;+ color: var(--es-text-secondary);+}++.es-settings-checkbox-row {+ display: flex;+ align-items: center;+ gap: 8px;+ cursor: pointer;+ font-size: 13px;+ color: var(--es-text-primary);+}++.es-settings-checkbox-row input[type="checkbox"] {+ margin: 0;+}++.es-settings-input {+ width: 100%;+ padding: 6px 10px;+ background: var(--es-bg-primary);+ border: 1px solid var(--es-border);+ color: var(--es-text-primary);+ font-size: 13px;+ box-sizing: border-box;+}++.es-settings-input:focus {+ outline: none;+ border-color: var(--es-accent);+}++.es-settings-select {+ width: 100%;+ padding: 6px 10px;+ background: var(--es-bg-primary);+ border: 1px solid var(--es-border);+ color: var(--es-text-primary);+ font-size: 13px;+ box-sizing: border-box;+}++.es-settings-select:focus {+ outline: none;+ border-color: var(--es-accent);+}++.es-settings-color-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+}++.es-settings-color-row .es-color-input {+ width: 60px;+ height: 28px;+ padding: 2px;+ border: 1px solid var(--es-border);+ background: var(--es-bg-primary);+ cursor: pointer;+}++.es-settings-range-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+}++.es-settings-range-value {+ font-size: 12px;+ color: var(--es-text-secondary);+ min-width: 32px;+ text-align: right;+}+/* =============================================================================* Add Component Popup* ============================================================================= */