// Which rotor dial to draw. // // Two compasses ship: the current one (night map, square scale, mouse pointer, // target marker) and the original small light-map dial. Neither is more correct // than the other — one operator reads the big map at a glance, another wants the // compact dial that was there before — so it is a preference, not a migration. // // A UI preference rather than a settings-database key: it decides what a widget // looks like, nothing is transmitted from it, and it belongs to the screen it is // read on. It is portable all the same (see lib/uiPref), so a copied folder // keeps the dial its owner chose. import { writeUiPref } from '@/lib/uiPref'; export const KEY_ROTOR_STYLE = 'opslog.rotorStyle'; export type RotorStyle = 'modern' | 'classic'; export function rotorStyle(): RotorStyle { try { return localStorage.getItem(KEY_ROTOR_STYLE) === 'classic' ? 'classic' : 'modern'; } catch { return 'modern'; } } // Same shape as the distance unit: the compasses are rendered from two call // sites, and a preference changed in Settings has to reach both without either // of them polling for it. const listeners = new Set<() => void>(); export function setRotorStyle(style: RotorStyle): void { writeUiPref(KEY_ROTOR_STYLE, style); listeners.forEach((l) => l()); } export function subscribeRotorStyle(fn: () => void): () => void { listeners.add(fn); return () => { listeners.delete(fn); }; }