mirror of
https://github.com/duckietm/Nitro-Cool-UI.git
synced 2025-06-21 22:36:58 +00:00
🆙 Set the WiredConditionFurniHasAvatarOnView to have a default to select only 1 Furni
This commit is contained in:
parent
5194bd357c
commit
381617c3bd
@ -11,11 +11,12 @@ export interface WiredBaseViewProps
|
|||||||
hasSpecialInput: boolean;
|
hasSpecialInput: boolean;
|
||||||
save: () => void;
|
save: () => void;
|
||||||
validate?: () => boolean;
|
validate?: () => boolean;
|
||||||
|
maxItemSelectionCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
|
export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
|
||||||
{
|
{
|
||||||
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false } = props;
|
const { wiredType = '', requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, validate = null, children = null, hasSpecialInput = false, maxItemSelectionCount = 5 } = props; // Default to 5
|
||||||
const [ wiredName, setWiredName ] = useState<string>(null);
|
const [ wiredName, setWiredName ] = useState<string>(null);
|
||||||
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
|
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
|
||||||
const [ needsSave, setNeedsSave ] = useState<boolean>(false);
|
const [ needsSave, setNeedsSave ] = useState<boolean>(false);
|
||||||
@ -83,7 +84,11 @@ export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
setAllowsFurni(requiresFurni);
|
setAllowsFurni(requiresFurni);
|
||||||
}, [ trigger, hasSpecialInput, requiresFurni, setIntParams, setStringParam, setFurniIds, setAllowsFurni ]);
|
|
||||||
|
// Set max item selection count
|
||||||
|
WiredSelectionVisualizer.setMaxItemSelectionCount(maxItemSelectionCount); // Use the passed value
|
||||||
|
|
||||||
|
}, [ trigger, hasSpecialInput, requiresFurni, setIntParams, setStringParam, setFurniIds, setAllowsFurni, maxItemSelectionCount ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCardView uniqueKey="nitro-wired" className="nitro-wired" theme="primary-slim">
|
<NitroCardView uniqueKey="nitro-wired" className="nitro-wired" theme="primary-slim">
|
||||||
@ -101,7 +106,7 @@ export const WiredBaseView: FC<PropsWithChildren<WiredBaseViewProps>> = props =>
|
|||||||
{ (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) &&
|
{ (requiresFurni > WiredFurniType.STUFF_SELECTION_OPTION_NONE) &&
|
||||||
<>
|
<>
|
||||||
<hr className="m-0 bg-dark" />
|
<hr className="m-0 bg-dark" />
|
||||||
<WiredFurniSelectorView />
|
<WiredFurniSelectorView maxItemSelectionCount={ maxItemSelectionCount } /> {/* Pass the count */}
|
||||||
</> }
|
</> }
|
||||||
<Flex alignItems="center" gap={ 1 }>
|
<Flex alignItems="center" gap={ 1 }>
|
||||||
<Button fullWidth variant="success" onClick={ onSave }>{ LocalizeText('wiredfurni.ready') }</Button>
|
<Button fullWidth variant="success" onClick={ onSave }>{ LocalizeText('wiredfurni.ready') }</Button>
|
||||||
|
@ -3,13 +3,22 @@ import { LocalizeText } from '../../../api';
|
|||||||
import { Column, Text } from '../../../common';
|
import { Column, Text } from '../../../common';
|
||||||
import { useWired } from '../../../hooks';
|
import { useWired } from '../../../hooks';
|
||||||
|
|
||||||
export const WiredFurniSelectorView: FC<{}> = props =>
|
export interface WiredFurniSelectorViewProps
|
||||||
{
|
{
|
||||||
|
maxItemSelectionCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WiredFurniSelectorView: FC<WiredFurniSelectorViewProps> = props =>
|
||||||
|
{
|
||||||
|
const { maxItemSelectionCount } = props;
|
||||||
const { trigger = null, furniIds = [] } = useWired();
|
const { trigger = null, furniIds = [] } = useWired();
|
||||||
|
|
||||||
|
// Enforce the selection limit
|
||||||
|
const selectionText = LocalizeText('wiredfurni.pickfurnis.caption', [ 'count', 'limit' ], [ furniIds.length.toString(), maxItemSelectionCount.toString() ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap={ 1 }>
|
<Column gap={ 1 }>
|
||||||
<Text bold>{ LocalizeText('wiredfurni.pickfurnis.caption', [ 'count', 'limit' ], [ furniIds.length.toString(), trigger.maximumItemSelectionCount.toString() ]) }</Text>
|
<Text bold>{ selectionText }</Text>
|
||||||
<Text small>{ LocalizeText('wiredfurni.pickfurnis.desc') }</Text>
|
<Text small>{ LocalizeText('wiredfurni.pickfurnis.desc') }</Text>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
@ -7,16 +7,17 @@ export interface WiredConditionBaseViewProps
|
|||||||
hasSpecialInput: boolean;
|
hasSpecialInput: boolean;
|
||||||
requiresFurni: number;
|
requiresFurni: number;
|
||||||
save: () => void;
|
save: () => void;
|
||||||
|
maxItemSelectionCount?: number; // Optional parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WiredConditionBaseView: FC<PropsWithChildren<WiredConditionBaseViewProps>> = props =>
|
export const WiredConditionBaseView: FC<PropsWithChildren<WiredConditionBaseViewProps>> = props =>
|
||||||
{
|
{
|
||||||
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, hasSpecialInput = false, children = null } = props;
|
const { requiresFurni = WiredFurniType.STUFF_SELECTION_OPTION_NONE, save = null, hasSpecialInput = false, children = null, maxItemSelectionCount = 5 } = props;
|
||||||
|
|
||||||
const onSave = () => (save && save());
|
const onSave = () => (save && save());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WiredBaseView wiredType="condition" requiresFurni={ requiresFurni } hasSpecialInput={ hasSpecialInput } save={ onSave }>
|
<WiredBaseView wiredType="condition" requiresFurni={ requiresFurni } hasSpecialInput={ hasSpecialInput } save={ onSave } maxItemSelectionCount={ maxItemSelectionCount }>
|
||||||
{ children }
|
{ children }
|
||||||
</WiredBaseView>
|
</WiredBaseView>
|
||||||
);
|
);
|
||||||
|
@ -4,5 +4,5 @@ import { WiredConditionBaseView } from './WiredConditionBaseView';
|
|||||||
|
|
||||||
export const WiredConditionFurniHasAvatarOnView: FC<{}> = props =>
|
export const WiredConditionFurniHasAvatarOnView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
return <WiredConditionBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } hasSpecialInput={ false } save={ null } />;
|
return <WiredConditionBaseView requiresFurni={ WiredFurniType.STUFF_SELECTION_OPTION_BY_ID } hasSpecialInput={ false } save={ null } maxItemSelectionCount={ 1 } />;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user