Files
OpenFrontIO/src/client/render/gl/debug/props/Toggle.ts
T
evanpelle 4cd22a9b5c rename render/ files to UpperCamelCase to match client convention
The render/ tree was the only place in the client still using kebab-case
filenames. Brings ~80 files in line with the rest of src/client/
(BuildPreviewController, TransformHandler, etc.). Directories kept as
they were (name-pass/, fx-pass/, passes/, utils/, debug/) since the
codebase already mixes those.

Two collisions surfaced and got resolved: render/types/ is a directory,
not a file, so its imports kept the lowercase form; and the sed pass
incidentally normalized core/pathfinding imports, which had to be
reverted since that file is actually lowercase on disk despite some
imports having referenced it as ./Types under macOS case-insensitive
resolution.
2026-05-17 21:21:05 -07:00

29 lines
736 B
TypeScript

import type GUI from "lil-gui";
import type { Controller } from "lil-gui";
import type { ConfigProp } from "../ConfigProp";
export function toggle<T extends Record<string, unknown>>(
target: T,
key: keyof T & string,
defaults: T,
label?: string,
): ConfigProp {
const defaultVal = defaults[key] as boolean;
let ctrl: Controller | undefined;
return {
draw(folder: GUI) {
ctrl = folder.add(target, key);
if (label) ctrl.name(label);
return ctrl;
},
isModified: () => (target[key] as boolean) !== defaultVal,
resetToDefault() {
(target as Record<string, unknown>)[key] = defaultVal;
ctrl?.updateDisplay();
},
updateDisplay() {
ctrl?.updateDisplay();
},
};
}