mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:20:43 +00:00
4cd22a9b5c
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.
29 lines
736 B
TypeScript
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();
|
|
},
|
|
};
|
|
}
|