All checks were successful
Build / build (push) Successful in 1m20s
Major refactoring of the UI layer to use Svelte components: - Replace inline HTML with modular Svelte components - Add authentication system with UserProfile component - Implement navigation store for view management - Create comprehensive settings and controls screens - Add level editor with JSON validation - Implement progression tracking system - Update level configurations and base station model 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { writable, get } from 'svelte/store';
|
|
import type { ControllerMapping } from '../ship/input/controllerMapping';
|
|
import { ControllerMappingConfig } from '../ship/input/controllerMapping';
|
|
|
|
const STORAGE_KEY = 'space-game-controller-mapping';
|
|
|
|
function createControllerMappingStore() {
|
|
const config = ControllerMappingConfig.getInstance();
|
|
const initial = config.getMapping();
|
|
|
|
const { subscribe, set, update } = writable<ControllerMapping>(initial);
|
|
|
|
return {
|
|
subscribe,
|
|
update,
|
|
set: (value: ControllerMapping) => {
|
|
set(value);
|
|
config.setMapping(value);
|
|
},
|
|
save: () => {
|
|
const mapping = get(controllerMappingStore);
|
|
config.setMapping(mapping);
|
|
config.save();
|
|
console.log('[ControllerMapping Store] Saved');
|
|
},
|
|
reset: () => {
|
|
config.resetToDefault();
|
|
config.save();
|
|
set(config.getMapping());
|
|
console.log('[ControllerMapping Store] Reset to defaults');
|
|
},
|
|
validate: () => {
|
|
return config.validate();
|
|
},
|
|
};
|
|
}
|
|
|
|
export const controllerMappingStore = createControllerMappingStore();
|