Files
nissefolk/src/config.ts
tekki mariani c7ebf49bf2 overlay opacity: global setting + settings screen (Issue #16)
- Add UI_SETTINGS_KEY to config.ts for separate localStorage entry
- Add uiOpacity field (default 0.8, range 0.4–1.0, 10 % steps) to UIScene
- loadUISettings / saveUISettings persist opacity independently of game save
- Replace all hardcoded panel BG alphas with this.uiOpacity:
  build menu, villager panel, context menu, ESC menu, confirm dialog,
  nisse info panel
- Debug panel (F3) background synced via updateDebugPanelBackground()
- Replace Settings toast with real Settings overlay:
  title, opacity − / value / + buttons, Close button
- ESC key priority stack now includes settingsVisible
- repositionUI closes settings panel on window resize

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 09:36:42 +00:00

60 lines
2.0 KiB
TypeScript

import type { CropKind, ItemId, BuildingType } from './types'
export const TILE_SIZE = 32
export const CHUNK_SIZE = 16
export const WORLD_CHUNKS = 32
export const WORLD_TILES = WORLD_CHUNKS * CHUNK_SIZE
export const WORLD_PX = WORLD_TILES * TILE_SIZE
export const PLAYER_SPEED = 180
export const INTERACTION_RANGE = 60
export const CAMERA_LERP = 0.09
export const TREE_HEALTH = 3
export const ROCK_HEALTH = 5
export const BUILDING_COSTS: Record<BuildingType, Record<string, number>> = {
floor: { wood: 2 },
wall: { wood: 3, stone: 1 },
chest: { wood: 5, stone: 2 },
bed: { wood: 6 },
stockpile_zone:{ wood: 0 },
}
export interface CropConfig {
stages: number
stageTimeMs: number
rewards: Partial<Record<ItemId, number>>
}
export const CROP_CONFIGS: Record<CropKind, CropConfig> = {
wheat: { stages: 3, stageTimeMs: 20_000, rewards: { wheat: 3, wheat_seed: 2 } },
carrot: { stages: 3, stageTimeMs: 25_000, rewards: { carrot: 4, carrot_seed: 1 } },
}
// Villager config
export const VILLAGER_SPEED = 75 // px/s — slow and visible
export const VILLAGER_SPAWN_INTERVAL = 8_000 // ms between spawn checks
export const VILLAGER_WORK_TIMES: Record<string, number> = {
chop: 3000,
mine: 5000,
farm: 1200,
}
export const VILLAGER_NAMES = [
'Aldric','Brix','Cora','Dwyn','Edna','Finn','Greta',
'Holt','Iris','Jorn','Kira','Lars','Mira','Nox',
'Orla','Pike','Quinn','Rook','Sera','Tull','Uma','Vex',
]
export const SAVE_KEY = 'tg_save_v5'
export const AUTOSAVE_INTERVAL = 30_000
/** localStorage key for UI settings (opacity etc.) — separate from the game save. */
export const UI_SETTINGS_KEY = 'tg_ui_settings'
/** Milliseconds for one tree-seedling stage to advance (two stages = full tree). */
export const TREE_SEEDLING_STAGE_MS = 60_000 // 1 min per stage → 2 min total
/** Milliseconds before a bare DARK_GRASS tile (after tree felling) reverts to GRASS. */
export const TILE_RECOVERY_MS = 300_000 // 5 minutes