diff --git a/src/api/wired/WiredActionLayoutCode.ts b/src/api/wired/WiredActionLayoutCode.ts index 10b9842..14ecc94 100644 --- a/src/api/wired/WiredActionLayoutCode.ts +++ b/src/api/wired/WiredActionLayoutCode.ts @@ -29,4 +29,5 @@ export class WiredActionLayoutCode public static FURNI_AREA_SELECTOR: number = 28; public static FURNI_NEIGHBORHOOD_SELECTOR: number = 29; public static FURNI_BYTYPE_SELECTOR: number = 30; + public static USERS_AREA_SELECTOR: number = 31; } diff --git a/src/components/wired/views/actions/WiredActionLayoutView.tsx b/src/components/wired/views/actions/WiredActionLayoutView.tsx index 6b0a0a9..cbd1ad3 100644 --- a/src/components/wired/views/actions/WiredActionLayoutView.tsx +++ b/src/components/wired/views/actions/WiredActionLayoutView.tsx @@ -3,6 +3,7 @@ import { WiredActionBotChangeFigureView } from './WiredActionBotChangeFigureView import { WiredActionFurniAreaView } from '../selectors/WiredActionFurniAreaView'; import { WiredSelectorFurniNeighborhoodView } from '../selectors/WiredSelectorFurniNeighborhoodView'; import { WiredSelectorFurniByTypeView } from '../selectors/WiredSelectorFurniByTypeView'; +import { WiredSelectorUsersAreaView } from '../selectors/WiredSelectorUsersAreaView'; import { WiredActionBotFollowAvatarView } from './WiredActionBotFollowAvatarView'; import { WiredActionBotGiveHandItemView } from './WiredActionBotGiveHandItemView'; import { WiredActionBotMoveView } from './WiredActionBotMoveView'; @@ -88,6 +89,8 @@ export const WiredActionLayoutView = (code: number) => return ; case WiredActionLayoutCode.FURNI_BYTYPE_SELECTOR: return ; + case WiredActionLayoutCode.USERS_AREA_SELECTOR: + return ; } return null; diff --git a/src/components/wired/views/selectors/WiredActionFurniAreaView.tsx b/src/components/wired/views/selectors/WiredActionFurniAreaView.tsx index 4bbfc0c..9bc431b 100644 --- a/src/components/wired/views/selectors/WiredActionFurniAreaView.tsx +++ b/src/components/wired/views/selectors/WiredActionFurniAreaView.tsx @@ -78,6 +78,15 @@ export const WiredActionFurniAreaView: FC<{}> = props => setInvert(trigger.intData.length >= 6 && trigger.intData[5] === 1); }, [ trigger ]); + useEffect(() => + { + if(!trigger) return; + + GetRoomEngine().areaSelectionManager.setHighlightType( + invert ? RoomAreaSelectionManager.HIGHLIGHT_GREEN : RoomAreaSelectionManager.HIGHLIGHT_BRIGHTEN + ); + }, [ invert, trigger ]); + const hasArea = areaWidth > 0 && areaHeight > 0; const pickedLimit = trigger?.maximumItemSelectionCount ?? 20; @@ -97,11 +106,6 @@ export const WiredActionFurniAreaView: FC<{}> = props => { LocalizeText('wiredfurni.params.area_selection') } { LocalizeText('wiredfurni.params.area_selection.info') } - { hasArea && - - { LocalizeText('wiredfurni.params.area_selection.selected', [ 'x', 'y', 'w', 'h' ], [ rootX.toString(), rootY.toString(), areaWidth.toString(), areaHeight.toString() ]) } - } - { hasArea && { LocalizeText('wiredfurni.pickfurnis.caption', [ 'count', 'limit' ], [ pickedCount.toString(), pickedLimit.toString() ]) } @@ -111,7 +115,14 @@ export const WiredActionFurniAreaView: FC<{}> = props => - diff --git a/src/components/wired/views/selectors/WiredSelectorUsersAreaView.tsx b/src/components/wired/views/selectors/WiredSelectorUsersAreaView.tsx new file mode 100644 index 0000000..d507972 --- /dev/null +++ b/src/components/wired/views/selectors/WiredSelectorUsersAreaView.tsx @@ -0,0 +1,136 @@ +import { GetRoomEngine, RoomAreaSelectionManager } from '@nitrots/nitro-renderer'; +import { FC, useCallback, useEffect, useState } from 'react'; +import { LocalizeText } from '../../../../api'; +import { Button, Text } from '../../../../common'; +import { useWired } from '../../../../hooks'; +import { WiredActionBaseView } from '../actions/WiredActionBaseView'; + +export const WiredSelectorUsersAreaView: FC<{}> = props => +{ + const [ rootX, setRootX ] = useState(0); + const [ rootY, setRootY ] = useState(0); + const [ areaWidth, setAreaWidth ] = useState(0); + const [ areaHeight, setAreaHeight ] = useState(0); + const [ filterExisting, setFilterExisting ] = useState(false); + const [ invert, setInvert ] = useState(false); + const { trigger = null, setIntParams } = useWired(); + + const save = useCallback(() => + { + setIntParams([ rootX, rootY, areaWidth, areaHeight, filterExisting ? 1 : 0, invert ? 1 : 0 ]); + }, [ rootX, rootY, areaWidth, areaHeight, filterExisting, invert, setIntParams ]); + + useEffect(() => + { + if(!trigger) return; + + const callback = (x: number, y: number, w: number, h: number) => + { + setRootX(x); + setRootY(y); + setAreaWidth(w); + setAreaHeight(h); + }; + + const activated = GetRoomEngine().areaSelectionManager.activate(callback, RoomAreaSelectionManager.HIGHLIGHT_BRIGHTEN); + + if(activated) + { + if(trigger.intData.length >= 4 && trigger.intData[2] > 0 && trigger.intData[3] > 0) + { + GetRoomEngine().areaSelectionManager.setHighlight( + trigger.intData[0], + trigger.intData[1], + trigger.intData[2], + trigger.intData[3] + ); + } + } + + return () => + { + GetRoomEngine().areaSelectionManager.deactivate(); + }; + }, [ trigger ]); + + useEffect(() => + { + if(!trigger) return; + + if(trigger.intData.length >= 4) + { + setRootX(trigger.intData[0]); + setRootY(trigger.intData[1]); + setAreaWidth(trigger.intData[2]); + setAreaHeight(trigger.intData[3]); + } + else + { + setRootX(0); + setRootY(0); + setAreaWidth(0); + setAreaHeight(0); + } + + setFilterExisting(trigger.intData.length >= 5 && trigger.intData[4] === 1); + setInvert(trigger.intData.length >= 6 && trigger.intData[5] === 1); + }, [ trigger ]); + + useEffect(() => + { + if(!trigger) return; + + GetRoomEngine().areaSelectionManager.setHighlightType( + invert ? RoomAreaSelectionManager.HIGHLIGHT_GREEN : RoomAreaSelectionManager.HIGHLIGHT_BRIGHTEN + ); + }, [ invert, trigger ]); + + const hasArea = areaWidth > 0 && areaHeight > 0; + + return ( + +
+ { LocalizeText('wiredfurni.params.area_selection') } + { LocalizeText('wiredfurni.params.area_selection.info') } + +
+ + +
+ +
+ + { LocalizeText('wiredfurni.params.selector_options_selector') } + + + + +
+
+ ); +};