mirror of
https://github.com/luanslimadev/Wand-Enhancer.git
synced 2026-08-28 23:01:14 +00:00
a0b3968d33
Reorganize the panel around product capabilities and integrate the remote i18n feature from origin/master into the new structure. - Restructure src into capability features (app, trainer, library, remote-session, appearance, shared); move the bridge to bridge/src. - Add lingui-based UI localization and wrap remaining user-facing strings (Trans / msg macros); fix the 'END В·' mojibake. - Port WeMod cheat-metadata i18n: capture the access token from the snapshot's renderer in the bridge and fetch localized trainer_meta in remote-session.i18n; guarantee snapshot sync on token failure. - Wire vitest to the app's lingui/preact pipeline (mergeConfig).
40 lines
1.6 KiB
TypeScript
40 lines
1.6 KiB
TypeScript
import { type ReactElement } from 'react';
|
|
|
|
import type { CheatSchema } from '../../../protocol/messages';
|
|
import { ECheatType } from '../../../protocol/messages';
|
|
import { ActionButton } from './ActionButton';
|
|
import { IncrementalControl } from './IncrementalControl';
|
|
import { NumberControl } from './NumberControl';
|
|
import { ScalarControl } from './ScalarControl';
|
|
import { SelectionControl } from './SelectionControl';
|
|
import { SliderControl } from './SliderControl';
|
|
import { ToggleControl } from './ToggleControl';
|
|
import type { ControlInternalProps } from './shared';
|
|
|
|
type CheatControlProps = {
|
|
cheat: CheatSchema;
|
|
value: unknown;
|
|
pending: boolean;
|
|
disabled: boolean;
|
|
onChange: (nextValue: unknown) => void;
|
|
};
|
|
|
|
const CONTROL_BY_TYPE: Record<ECheatType, (props: ControlInternalProps) => ReactElement> = {
|
|
[ECheatType.Toggle]: (props) => <ToggleControl {...props} />,
|
|
[ECheatType.Slider]: (props) => <SliderControl {...props} />,
|
|
[ECheatType.Number]: (props) => <NumberControl {...props} />,
|
|
[ECheatType.Button]: (props) => <ActionButton {...props} />,
|
|
[ECheatType.Selection]: (props) => <SelectionControl {...props} />,
|
|
[ECheatType.Scalar]: (props) => <ScalarControl {...props} />,
|
|
[ECheatType.Incremental]: (props) => <IncrementalControl {...props} />,
|
|
};
|
|
|
|
export const CheatControl = ({ cheat, value, pending, disabled, onChange }: CheatControlProps) => {
|
|
const Renderer = CONTROL_BY_TYPE[cheat.type];
|
|
if (!Renderer) {
|
|
return <span className="text-[12px] text-red-200">Unsupported: {cheat.type}</span>;
|
|
}
|
|
|
|
return <Renderer cheat={cheat} disabled={disabled || pending} value={value} onChange={onChange} />;
|
|
};
|