import { Atom } from "@rbxts/charm";
import Vide, { Case, For, Source, source, Switch } from "@rbxts/vide";
import { SettingDefinition, SettingRealType, SettingType } from "../../../../shared/typings/settings";
import { SettingsController } from "../../../controllers/settings";
import { Toggle } from "../global/toggle";
/**
* The settings menu as vide components.
* @param settingsController The settings Controller for fetching settings.
* @returns A Vide node with the settings menu.
*/
export function Settings(settingsController: SettingsController) {
const keys = source(settingsController.getSections());
const panel = source(keys()[0]);
return (
{(group) => }
settingsController.getSectionWithDef(panel())}>
{([def, atom]) => }
);
}
/**
* An entry in the settings menu.
* @param props Properties of the entry.
* @param props.definition Setting definition.
* @param props.atom Charm atom with the value of the setting.
* @returns A setting entry.
*/
export function SettingsEntry(props: {
/**
* The atom with the value of the setting.
*/
atom: Atom>;
/**
* The definition of the setting.
*/
definition: SettingDefinition;
}) {
return (
props.definition.type}>
{() => (
<>
} />
>
)}
);
}
/**
* A button for each setting section the settings menu.
* @param props Properties of the button.
* @param props.name The name of the entry.
* @param props.panelSource A vide source for the current panel.
* @returns The Settings group button.
*/
export function SettingsGroup(props: {
/**
* The name of the settings group.
*/
name: string;
/**
* A vide source with the name of the current panel.
*/
panelSource: Source;
}) {
return (
props.name === props.panelSource()
? Font.fromEnum(Enum.Font.SourceSansBold)
: Font.fromEnum(Enum.Font.SourceSans)
}
MouseButton1Click={() => {
props.panelSource(props.name);
}}
Size={UDim2.fromScale(1, 1)}
Text={props.name}
TextColor3={new Color3(1, 1, 1)}
TextScaled={true}
/>
);
}