mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-02-17 01:12:37 +01:00
Add base wired & saving
This commit is contained in:
parent
4b202678c0
commit
8977cccbd3
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -12,5 +12,6 @@
|
||||
"git.ignoreLimitWarning": true,
|
||||
"files.eol": "\n",
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true
|
||||
"files.trimFinalNewlines": true,
|
||||
"editor.wordWrap": "on"
|
||||
}
|
||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -2376,6 +2376,15 @@
|
||||
"redux": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@types/react-slider": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-slider/-/react-slider-1.3.0.tgz",
|
||||
"integrity": "sha512-Hr+P8wiqYAjeFTlf+NWPVGWW79npC8V7KkZdbPlMqo+iblcopPzE/z0m8503j2YmfxoKJKaPnrJe0a6spXacYQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/react": "*"
|
||||
}
|
||||
},
|
||||
"@types/react-transition-group": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.1.tgz",
|
||||
@ -15061,6 +15070,11 @@
|
||||
"workbox-webpack-plugin": "5.1.4"
|
||||
}
|
||||
},
|
||||
"react-slider": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react-slider/-/react-slider-1.3.1.tgz",
|
||||
"integrity": "sha512-bD8hHJJUgAHI8g1F6PY6432l+Dmcs2fqzUwDhd+0HWDdvfjwNoXRNC2cL9OWyGTjYlJM92A8nF/w1X4pyHfytQ=="
|
||||
},
|
||||
"react-transition-group": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.1.tgz",
|
||||
|
@ -22,6 +22,7 @@
|
||||
"react-google-recaptcha": "^2.1.0",
|
||||
"react-redux": "^7.2.3",
|
||||
"react-scripts": "4.0.3",
|
||||
"react-slider": "^1.3.1",
|
||||
"react-transition-group": "^4.4.1",
|
||||
"redux": "^4.0.5",
|
||||
"typescript": "^4.2.4",
|
||||
@ -58,6 +59,7 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-slider": "^1.3.0",
|
||||
"@types/react-transition-group": "^4.4.1"
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,4 @@ export * from './inventory';
|
||||
export * from './navigator';
|
||||
export * from './notification-center';
|
||||
export * from './room-widgets';
|
||||
export * from './wired';
|
||||
|
6
src/events/wired/WiredEvent.ts
Normal file
6
src/events/wired/WiredEvent.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { NitroEvent } from 'nitro-renderer';
|
||||
|
||||
export class WiredEvent extends NitroEvent
|
||||
{
|
||||
public static SAVE_WIRED: string = 'WE_SAVE_WIRED';
|
||||
}
|
1
src/events/wired/index.ts
Normal file
1
src/events/wired/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './WiredEvent';
|
@ -1,5 +1,6 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Condensed:wght@300;400;500&display=swap');
|
||||
@import '../node_modules/animate.css/animate.css';
|
||||
@import '../node_modules/rc-slider/assets/index.css';
|
||||
@import './assets/styles';
|
||||
|
||||
html,
|
||||
|
@ -1,6 +1,62 @@
|
||||
import { FC } from 'react';
|
||||
import { WiredFurniActionEvent, WiredFurniConditionEvent, WiredFurniTriggerEvent, WiredOpenEvent, WiredRewardResultMessageEvent, WiredSaveSuccessEvent, WiredValidationErrorEvent } from 'nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { CreateMessageHook } from '../../hooks/messages';
|
||||
import { useWiredContext } from './context/WiredContext';
|
||||
|
||||
export const WiredMessageHandler: FC<{}> = props =>
|
||||
{
|
||||
const { setTrigger = null } = useWiredContext();
|
||||
|
||||
const onWiredFurniActionEvent = useCallback((event: WiredFurniActionEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
setTrigger(parser.definition);
|
||||
}, [ setTrigger ]);
|
||||
|
||||
const onWiredFurniConditionEvent = useCallback((event: WiredFurniConditionEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
setTrigger(parser.definition);
|
||||
}, [ setTrigger ]);
|
||||
|
||||
const onWiredFurniTriggerEvent = useCallback((event: WiredFurniTriggerEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
setTrigger(parser.definition);
|
||||
}, [ setTrigger ]);
|
||||
|
||||
const onWiredOpenEvent = useCallback((event: WiredOpenEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
}, []);
|
||||
|
||||
const onWiredRewardResultMessageEvent = useCallback((event: WiredRewardResultMessageEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
}, []);
|
||||
|
||||
const onWiredSaveSuccessEvent = useCallback((event: WiredSaveSuccessEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
setTrigger(null);
|
||||
}, [ setTrigger ]);
|
||||
|
||||
const onWiredValidationErrorEvent = useCallback((event: WiredValidationErrorEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
}, []);
|
||||
|
||||
CreateMessageHook(WiredFurniActionEvent, onWiredFurniActionEvent);
|
||||
CreateMessageHook(WiredFurniConditionEvent, onWiredFurniConditionEvent);
|
||||
CreateMessageHook(WiredFurniTriggerEvent, onWiredFurniTriggerEvent);
|
||||
CreateMessageHook(WiredOpenEvent, onWiredOpenEvent);
|
||||
CreateMessageHook(WiredRewardResultMessageEvent, onWiredRewardResultMessageEvent);
|
||||
CreateMessageHook(WiredSaveSuccessEvent, onWiredSaveSuccessEvent);
|
||||
CreateMessageHook(WiredValidationErrorEvent, onWiredValidationErrorEvent);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
@ -1,81 +1,42 @@
|
||||
import { ConditionDefinition, Nitro, TriggerDefinition, WiredActionDefinition, WiredFurniActionEvent, WiredFurniConditionEvent, WiredFurniTriggerEvent } from 'nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { CreateMessageHook } from '../../hooks/messages';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../layout';
|
||||
import { LocalizeText } from '../../utils/LocalizeText';
|
||||
import { WiredActionBaseView } from './views/actions/base/WiredActionBaseView';
|
||||
import { WiredConditionBaseView } from './views/conditions/base/WiredConditionBaseView';
|
||||
import { WiredTriggerBaseView } from './views/triggers/base/WiredTriggerBaseView';
|
||||
import { Triggerable, UpdateActionMessageComposer, WiredActionDefinition } from 'nitro-renderer';
|
||||
import { FC, useCallback, useMemo, useState } from 'react';
|
||||
import { GetConnection } from '../../api';
|
||||
import { WiredEvent } from '../../events';
|
||||
import { useUiEvent } from '../../hooks/events';
|
||||
import { GetWiredLayout } from './common/GetWiredLayout';
|
||||
import { WiredContextProvider } from './context/WiredContext';
|
||||
import { WiredMessageHandler } from './WiredMessageHandler';
|
||||
import { WiredFurniSelectorViewProps } from './WiredView.types';
|
||||
|
||||
export const WiredView: FC<WiredFurniSelectorViewProps> = props =>
|
||||
{
|
||||
const [ wiredDefinition, setWiredDefinition ] = useState<TriggerDefinition | WiredActionDefinition | ConditionDefinition>(null);
|
||||
const [ name, setName ] = useState(null);
|
||||
const [ description, setDescription ] = useState(null);
|
||||
const [ trigger, setTrigger ] = useState<Triggerable>(null);
|
||||
const [ intParams, setIntParams ] = useState<number[]>(null);
|
||||
const [ stringParam, setStringParam ] = useState<string>(null);
|
||||
const [ furniIds, setFurniIds ] = useState<number[]>(null);
|
||||
const [ actionDelay, setActionDelay ] = useState<number>(null);
|
||||
|
||||
useEffect(() =>
|
||||
const wiredLayout = useMemo(() =>
|
||||
{
|
||||
if(!wiredDefinition) return;
|
||||
return GetWiredLayout(trigger);
|
||||
}, [ trigger ]);
|
||||
|
||||
const itemData = Nitro.instance.sessionDataManager.getFloorItemData(wiredDefinition.spriteId);
|
||||
|
||||
if(!itemData) return;
|
||||
|
||||
setName(itemData.name);
|
||||
setDescription(itemData.description);
|
||||
}, [ wiredDefinition ]);
|
||||
|
||||
const getWiredType = useCallback(() =>
|
||||
const onWiredEvent = useCallback((event: WiredEvent) =>
|
||||
{
|
||||
if(wiredDefinition instanceof TriggerDefinition)
|
||||
return 'trigger';
|
||||
else if(wiredDefinition instanceof ConditionDefinition)
|
||||
return 'condition';
|
||||
else
|
||||
return 'action';
|
||||
// check if owner & warn with confirm
|
||||
|
||||
if(trigger instanceof WiredActionDefinition)
|
||||
{
|
||||
GetConnection().send(new UpdateActionMessageComposer(trigger.id, intParams, stringParam, furniIds, actionDelay, trigger.stuffTypeSelectionCode));
|
||||
}
|
||||
}, [ trigger, intParams, stringParam, furniIds, actionDelay ]);
|
||||
|
||||
}, [ wiredDefinition ]);
|
||||
|
||||
const getTypeBase = useCallback(() =>
|
||||
{
|
||||
if(wiredDefinition instanceof TriggerDefinition)
|
||||
return <WiredTriggerBaseView />;
|
||||
else if(wiredDefinition instanceof ConditionDefinition)
|
||||
return <WiredConditionBaseView />;
|
||||
else
|
||||
return <WiredActionBaseView wiredDefinition={ wiredDefinition } />;
|
||||
|
||||
}, [ wiredDefinition ]);
|
||||
|
||||
const onWiredFurniEvent = useCallback((event: WiredFurniTriggerEvent | WiredFurniConditionEvent | WiredFurniActionEvent) =>
|
||||
{
|
||||
setWiredDefinition(event.getParser().definition);
|
||||
}, [ setWiredDefinition ]);
|
||||
|
||||
CreateMessageHook(WiredFurniTriggerEvent, onWiredFurniEvent);
|
||||
CreateMessageHook(WiredFurniConditionEvent, onWiredFurniEvent);
|
||||
CreateMessageHook(WiredFurniActionEvent, onWiredFurniEvent);
|
||||
|
||||
if(!wiredDefinition) return null;
|
||||
useUiEvent(WiredEvent.SAVE_WIRED, onWiredEvent);
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-wired" simple={ true }>
|
||||
<NitroCardHeaderView headerText={ LocalizeText('wiredfurni.title') } onCloseClick={ event => {} } />
|
||||
<NitroCardContentView className="text-black">
|
||||
<div className="d-flex align-items-center">
|
||||
<i className={ 'me-2 icon icon-wired-' + getWiredType()} />
|
||||
<div className="fw-bold">{ name }</div>
|
||||
</div>
|
||||
<div>{ description }</div>
|
||||
<div>
|
||||
{ getTypeBase() }
|
||||
</div>
|
||||
<div className="d-flex mt-2">
|
||||
<button className="btn btn-success me-2 w-100">{ LocalizeText('wiredfurni.ready') }</button>
|
||||
<button className="btn btn-secondary w-100">{ LocalizeText('cancel') }</button>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
<WiredContextProvider value={ { trigger, setTrigger, intParams, setIntParams, stringParam, setStringParam, furniIds, setFurniIds, actionDelay, setActionDelay }}>
|
||||
<WiredMessageHandler />
|
||||
{ wiredLayout }
|
||||
</WiredContextProvider>
|
||||
);
|
||||
};
|
||||
|
@ -7,3 +7,11 @@ export class WiredLayoutViewProps
|
||||
{
|
||||
wiredDefinition: TriggerDefinition | WiredActionDefinition | ConditionDefinition;
|
||||
}
|
||||
|
||||
export class WiredFurniType
|
||||
{
|
||||
public static _Str_5431: number = 0;
|
||||
public static _Str_4873: number = 1;
|
||||
public static _Str_4991: number = 2;
|
||||
public static _Str_5430: number = 3;
|
||||
}
|
||||
|
14
src/views/wired/common/GetWiredActionLayout.tsx
Normal file
14
src/views/wired/common/GetWiredActionLayout.tsx
Normal file
@ -0,0 +1,14 @@
|
||||
import { WiredActionBotChangeFigureView } from '../views/actions/bot-change-figure/WiredActionBotChangeFigureView';
|
||||
import { WiredActionBotFollowAvatarView } from '../views/actions/bot-follow-avatar/WiredActionBotFollowAvatarView';
|
||||
import { WiredActionLayout } from './WiredActionLayoutCode';
|
||||
|
||||
export function GetWiredActionLayout(code: number): JSX.Element
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case WiredActionLayout.BOT_CHANGE_FIGURE:
|
||||
return <WiredActionBotChangeFigureView />;
|
||||
case WiredActionLayout.BOT_FOLLOW_AVATAR:
|
||||
return <WiredActionBotFollowAvatarView />;
|
||||
}
|
||||
}
|
9
src/views/wired/common/GetWiredLayout.tsx
Normal file
9
src/views/wired/common/GetWiredLayout.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import { Triggerable, WiredActionDefinition } from 'nitro-renderer';
|
||||
import { GetWiredActionLayout } from './GetWiredActionLayout';
|
||||
|
||||
export function GetWiredLayout(trigger: Triggerable): JSX.Element
|
||||
{
|
||||
if(trigger instanceof WiredActionDefinition) return GetWiredActionLayout(trigger.code);
|
||||
|
||||
return null;
|
||||
}
|
8
src/views/wired/common/GetWiredTimeLocale.ts
Normal file
8
src/views/wired/common/GetWiredTimeLocale.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export function GetWiredTimeLocale(value: number): string
|
||||
{
|
||||
const time = Math.floor((value / 2));
|
||||
|
||||
if(!(value % 2)) return time.toString();
|
||||
|
||||
return (time + 0.5).toString();
|
||||
}
|
29
src/views/wired/common/WiredActionLayoutCode.ts
Normal file
29
src/views/wired/common/WiredActionLayoutCode.ts
Normal file
@ -0,0 +1,29 @@
|
||||
export class WiredActionLayout
|
||||
{
|
||||
public static TOGGLE_FURNI_STATE: number = 0;
|
||||
public static RESET: number = 1;
|
||||
public static SET_FURNI_STATE: number = 3;
|
||||
public static MOVE_FURNI: number = 4;
|
||||
public static GIVE_SCORE: number = 6;
|
||||
public static CHAT: number = 7;
|
||||
public static TELEPORT: number = 8;
|
||||
public static JOIN_TEAM: number = 9;
|
||||
public static LEAVE_TEAM: number = 10;
|
||||
public static CHASE: number = 11;
|
||||
public static FLEE: number = 12;
|
||||
public static MOVE_TO_DIRECTION: number = 13;
|
||||
public static GIVE_SCORE_TO_PREDEFINED_TEAM: number = 14;
|
||||
public static TOGGLE_TO_RANDOM_STATE: number = 15;
|
||||
public static MOVE_FURNI_TO: number = 16;
|
||||
public static GIVE_REWARD: number = 17;
|
||||
public static CALL_ANOTHER_STACK: number = 18;
|
||||
public static KICK_FROM_ROOM: number = 19;
|
||||
public static MUTE_USER: number = 20;
|
||||
public static BOT_TELEPORT: number = 21;
|
||||
public static BOT_MOVE: number = 22;
|
||||
public static BOT_TALK: number = 23;
|
||||
public static BOT_GIVE_HAND_ITEM: number = 24;
|
||||
public static BOT_FOLLOW_AVATAR: number = 25;
|
||||
public static BOT_CHANGE_FIGURE: number = 26;
|
||||
public static BOT_TALK_DIRECT_TO_AVTR: number = 27;
|
||||
}
|
22
src/views/wired/context/WiredContext.tsx
Normal file
22
src/views/wired/context/WiredContext.tsx
Normal file
@ -0,0 +1,22 @@
|
||||
import { createContext, FC, useContext } from 'react';
|
||||
import { IWiredContext, WiredContextProps } from './WiredContext.types';
|
||||
|
||||
const WiredContext = createContext<IWiredContext>({
|
||||
trigger: null,
|
||||
setTrigger: null,
|
||||
intParams: null,
|
||||
setIntParams: null,
|
||||
stringParam: null,
|
||||
setStringParam: null,
|
||||
furniIds: null,
|
||||
setFurniIds: null,
|
||||
actionDelay: null,
|
||||
setActionDelay: null
|
||||
});
|
||||
|
||||
export const WiredContextProvider: FC<WiredContextProps> = props =>
|
||||
{
|
||||
return <WiredContext.Provider value={ props.value }>{ props.children }</WiredContext.Provider>
|
||||
}
|
||||
|
||||
export const useWiredContext = () => useContext(WiredContext);
|
21
src/views/wired/context/WiredContext.types.ts
Normal file
21
src/views/wired/context/WiredContext.types.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Triggerable } from 'nitro-renderer';
|
||||
import { Dispatch, ProviderProps, SetStateAction } from 'react';
|
||||
|
||||
export interface IWiredContext
|
||||
{
|
||||
trigger: Triggerable;
|
||||
setTrigger: Dispatch<SetStateAction<Triggerable>>;
|
||||
intParams: number[],
|
||||
setIntParams: Dispatch<SetStateAction<number[]>>;
|
||||
stringParam: string;
|
||||
setStringParam: Dispatch<SetStateAction<string>>;
|
||||
furniIds: number[];
|
||||
setFurniIds: Dispatch<SetStateAction<number[]>>;
|
||||
actionDelay: number;
|
||||
setActionDelay: Dispatch<SetStateAction<number>>;
|
||||
}
|
||||
|
||||
export interface WiredContextProps extends ProviderProps<IWiredContext>
|
||||
{
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
export interface IWiredLayout
|
||||
{
|
||||
code: number;
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
export class WiredActionLayout
|
||||
{
|
||||
public static TOGGLE_FURNI_STATE: number = 0;
|
||||
public static RESET: number = 1;
|
||||
public static SET_FURNI_STATE: number = 3;
|
||||
public static MOVE_FURNI: number = 4;
|
||||
public static GIVE_SCORE: number = 6;
|
||||
public static CHAT: number = 7;
|
||||
public static TELEPORT: number = 8;
|
||||
public static JOIN_TEAM: number = 9;
|
||||
public static LEAVE_TEAM: number = 10;
|
||||
public static CHASE: number = 11;
|
||||
public static FLEE: number = 12;
|
||||
public static MOVE_TO_DIRECTION: number = 13;
|
||||
public static GIVE_SCORE_TO_PREDEFINED_TEAM: number = 14;
|
||||
public static TOGGLE_TO_RANDOM_STATE: number = 15;
|
||||
public static MOVE_FURNI_TO: number = 16;
|
||||
public static GIVE_REWARD: number = 17;
|
||||
public static CALL_ANOTHER_STACK: number = 18;
|
||||
public static KICK_FROM_ROOM: number = 19;
|
||||
public static MUTE_USER: number = 20;
|
||||
public static BOT_TELEPORT: number = 21;
|
||||
public static BOT_MOVE: number = 22;
|
||||
public static BOT_TALK: number = 23;
|
||||
public static BOT_GIVE_HAND_ITEM: number = 24;
|
||||
public static BOT_FOLLOW_AVATAR: number = 25;
|
||||
public static BOT_CHANGE_FIGURE: number = 26;
|
||||
public static BOT_TALK_DIRECT_TO_AVTR: number = 27;
|
||||
}
|
@ -1,26 +1,45 @@
|
||||
import { ConditionDefinition, TriggerDefinition, WiredActionDefinition } from 'nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { WiredActionLayout } from '../../../utils/WiredActionLayout';
|
||||
import { WiredActionToggleFurniStateView } from '../toggle-furni-state/WiredActionToggleFurniStateView';
|
||||
import { WiredActionDefinition } from 'nitro-renderer';
|
||||
import Slider from 'rc-slider';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { LocalizeText } from '../../../../../utils/LocalizeText';
|
||||
import { GetWiredTimeLocale } from '../../../common/GetWiredTimeLocale';
|
||||
import { useWiredContext } from '../../../context/WiredContext';
|
||||
import { WiredFurniType } from '../../../WiredView.types';
|
||||
import { WiredBaseView } from '../../base/WiredBaseView';
|
||||
import { WiredActionBaseViewProps } from './WiredActionBaseView.types';
|
||||
|
||||
export const WiredActionBaseView: FC<{ wiredDefinition: TriggerDefinition | WiredActionDefinition | ConditionDefinition }> = props =>
|
||||
export const WiredActionBaseView: FC<WiredActionBaseViewProps> = props =>
|
||||
{
|
||||
const { wiredDefinition = null } = props;
|
||||
const { requiresFurni = WiredFurniType._Str_5431, save = null, children = null } = props;
|
||||
const [ delay, setDelay ] = useState(-1);
|
||||
const { trigger = null, setActionDelay = null } = useWiredContext();
|
||||
|
||||
const getActionlayout = useCallback((code: number) =>
|
||||
useEffect(() =>
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
case WiredActionLayout.TOGGLE_FURNI_STATE:
|
||||
return <WiredActionToggleFurniStateView wiredDefinition={ wiredDefinition } />;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}, [ wiredDefinition ]);
|
||||
|
||||
setDelay((trigger as WiredActionDefinition).delayInPulses);
|
||||
}, [ trigger ]);
|
||||
|
||||
const onSave = useCallback(() =>
|
||||
{
|
||||
if(save) save();
|
||||
|
||||
setActionDelay(delay);
|
||||
}, [ delay, save, setActionDelay ]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{ wiredDefinition && getActionlayout(wiredDefinition.code) }
|
||||
</>
|
||||
<WiredBaseView wiredType="action" requiresFurni={ requiresFurni } save={ onSave }>
|
||||
{ children }
|
||||
<hr className="my-1 mb-2 bg-dark" />
|
||||
<div className="d-flex flex-column justify-content-center align-items-center">
|
||||
{ LocalizeText('wiredfurni.params.delay', [ 'seconds' ], [ GetWiredTimeLocale(delay) ]) }
|
||||
<Slider
|
||||
defaultValue={ delay }
|
||||
dots={ true }
|
||||
min={ 0 }
|
||||
max={ 20 }
|
||||
onChange={ event => setDelay(event) }
|
||||
/>
|
||||
</div>
|
||||
</WiredBaseView>
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
export interface WiredActionBaseViewProps
|
||||
{
|
||||
requiresFurni: number;
|
||||
save: () => void;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { GetSessionDataManager } from '../../../../../api';
|
||||
import { LocalizeText } from '../../../../../utils/LocalizeText';
|
||||
import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView';
|
||||
import { useWiredContext } from '../../../context/WiredContext';
|
||||
import { WiredFurniType } from '../../../WiredView.types';
|
||||
import { WiredActionBaseView } from '../base/WiredActionBaseView';
|
||||
|
||||
const DELIMETER: string = '\t';
|
||||
const DEFAULT_FIGURE: string = 'hd-180-1.ch-210-66.lg-270-82.sh-290-81';
|
||||
|
||||
export const WiredActionBotChangeFigureView: FC<{}> = props =>
|
||||
{
|
||||
const [ botName, setBotName ] = useState('');
|
||||
const [ figure, setFigure ] = useState('');
|
||||
const { trigger = null, setStringParam = null } = useWiredContext();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const data = trigger.stringData.split(DELIMETER);
|
||||
|
||||
console.log(data);
|
||||
|
||||
if(data.length > 0) setBotName(data[0]);
|
||||
if(data.length > 1) setFigure(data[1].length > 0 ? data[1] : DEFAULT_FIGURE);
|
||||
}, [ trigger ]);
|
||||
|
||||
const copyLooks = useCallback(() =>
|
||||
{
|
||||
setFigure(GetSessionDataManager().figure);
|
||||
}, []);
|
||||
|
||||
const save = useCallback(() =>
|
||||
{
|
||||
setStringParam((botName + DELIMETER + figure));
|
||||
}, [ botName, figure, setStringParam ]);
|
||||
|
||||
return (
|
||||
<WiredActionBaseView requiresFurni={ WiredFurniType._Str_5431 } save={ save }>
|
||||
<div className="form-group">
|
||||
<label>{ LocalizeText('wiredfurni.params.bot.name') }</label>
|
||||
<input type="text" className="form-control form-control-sm" maxLength={ 32 } value={ botName } onChange={ event => setBotName(event.target.value) } />
|
||||
</div>
|
||||
<div className="d-flex align-items-center justify-content-center">
|
||||
<AvatarImageView figure={ figure } direction={ 4 } />
|
||||
<button type="button" className="btn btn-primary" onClick={ copyLooks }>{ LocalizeText('wiredfurni.params.capture.figure') }</button>
|
||||
</div>
|
||||
</WiredActionBaseView>
|
||||
);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { useWiredContext } from '../../../context/WiredContext';
|
||||
import { WiredFurniType } from '../../../WiredView.types';
|
||||
import { WiredActionBaseView } from '../base/WiredActionBaseView';
|
||||
|
||||
export const WiredActionBotFollowAvatarView: FC<{}> = props =>
|
||||
{
|
||||
const [ botName, setBotName ] = useState('');
|
||||
const [ followMode, setFollowMode ] = useState(-1);
|
||||
const { trigger = null, setStringParam = null } = useWiredContext();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setBotName(trigger.stringData);
|
||||
setFollowMode((trigger.intData.length > 0) ? trigger.intData[0] : 0);
|
||||
}, [ trigger ]);
|
||||
|
||||
return (
|
||||
<WiredActionBaseView requiresFurni={ WiredFurniType._Str_5431 } save={ null }>
|
||||
BOT_CHANGE_FIGURE
|
||||
</WiredActionBaseView>
|
||||
);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
import { FC } from 'react';
|
||||
import { WiredLayoutViewProps } from '../../../WiredView.types';
|
||||
import { WiredFurniSelectorView } from '../../furni-selector/WiredFurniSelectorView';
|
||||
|
||||
export const WiredActionToggleFurniStateView: FC<WiredLayoutViewProps> = props =>
|
||||
{
|
||||
return (
|
||||
<>
|
||||
<WiredFurniSelectorView selectedItemsCount={ 0 } maximumItemsCount={ 0 } />
|
||||
</>
|
||||
);
|
||||
};
|
79
src/views/wired/views/base/WiredBaseView.tsx
Normal file
79
src/views/wired/views/base/WiredBaseView.tsx
Normal file
@ -0,0 +1,79 @@
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { GetSessionDataManager } from '../../../../api';
|
||||
import { WiredEvent } from '../../../../events';
|
||||
import { dispatchUiEvent } from '../../../../hooks/events';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../layout';
|
||||
import { LocalizeText } from '../../../../utils/LocalizeText';
|
||||
import { useWiredContext } from '../../context/WiredContext';
|
||||
import { WiredFurniType } from '../../WiredView.types';
|
||||
import { WiredBaseViewProps } from './WiredBaseView.types';
|
||||
|
||||
export const WiredBaseView: FC<WiredBaseViewProps> = props =>
|
||||
{
|
||||
const { wiredType = '', requiresFurni = WiredFurniType._Str_5431, save = null, children = null } = props;
|
||||
const [ wiredName, setWiredName ] = useState<string>(null);
|
||||
const [ wiredDescription, setWiredDescription ] = useState<string>(null);
|
||||
const { trigger = null, setTrigger = null, setIntParams = null, setStringParam = null, setFurniIds = null } = useWiredContext();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(!trigger) return;
|
||||
|
||||
const spriteId = (trigger.spriteId || -1);
|
||||
|
||||
const furniData = GetSessionDataManager().getFloorItemData(spriteId);
|
||||
|
||||
if(!furniData)
|
||||
{
|
||||
setWiredName(('NAME: ' + spriteId));
|
||||
setWiredDescription(('NAME: ' + spriteId));
|
||||
}
|
||||
else
|
||||
{
|
||||
setWiredName(furniData.name);
|
||||
setWiredDescription(furniData.description);
|
||||
}
|
||||
|
||||
setIntParams(trigger.intData);
|
||||
setStringParam(trigger.stringData);
|
||||
setFurniIds(trigger.selectedItems);
|
||||
}, [ trigger, setIntParams, setStringParam, setFurniIds ]);
|
||||
|
||||
const onSave = useCallback(() =>
|
||||
{
|
||||
if(save) save();
|
||||
|
||||
setTimeout(() => dispatchUiEvent(new WiredEvent(WiredEvent.SAVE_WIRED)), 1);
|
||||
}, [ save ]);
|
||||
|
||||
const close = useCallback(() =>
|
||||
{
|
||||
setTrigger(null);
|
||||
}, [ setTrigger ]);
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-wired" simple={ true }>
|
||||
<NitroCardHeaderView headerText={ LocalizeText('wiredfurni.title') } onCloseClick={ close } />
|
||||
<NitroCardContentView className="text-black">
|
||||
<div className="d-flex align-items-center">
|
||||
<i className={ `me-2 icon icon-wired-${ wiredType }` } />
|
||||
<div className="fw-bold">{ wiredName }</div>
|
||||
</div>
|
||||
<div>{ wiredDescription }</div>
|
||||
<hr className="my-1 mb-2 bg-dark" />
|
||||
<div>
|
||||
{ children }
|
||||
</div>
|
||||
{ (requiresFurni !== WiredFurniType._Str_5431) &&
|
||||
<div className="d-flex">
|
||||
{ LocalizeText('wiredfurni.pickfurnis.caption', [ 'count', 'limit' ], [ '0', '0' ]) }
|
||||
{ LocalizeText('wiredfurni.pickfurnis.desc') }
|
||||
</div> }
|
||||
<div className="d-flex mt-2">
|
||||
<button className="btn btn-success me-2 w-100" onClick={ onSave }>{ LocalizeText('wiredfurni.ready') }</button>
|
||||
<button className="btn btn-secondary w-100" onClick={ close }>{ LocalizeText('cancel') }</button>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
}
|
6
src/views/wired/views/base/WiredBaseView.types.ts
Normal file
6
src/views/wired/views/base/WiredBaseView.types.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface WiredBaseViewProps
|
||||
{
|
||||
wiredType: string;
|
||||
requiresFurni: number;
|
||||
save: () => void;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import { FC, useCallback, useState } from 'react';
|
||||
import { IWiredLayout } from '../../../utils/IWiredLayout';
|
||||
|
||||
export const WiredConditionBaseView: FC<{}> = props =>
|
||||
{
|
||||
const [ conditionLayouts, setConditionLayouts ] = useState<IWiredLayout[]>([]);
|
||||
|
||||
const RegisterActionLayout = useCallback((layout: IWiredLayout) =>
|
||||
{
|
||||
setConditionLayouts(layouts => [...layouts, layout]);
|
||||
}, [ setConditionLayouts ]);
|
||||
|
||||
return null;
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
import { FC, useCallback, useState } from 'react';
|
||||
import { IWiredLayout } from '../../../utils/IWiredLayout';
|
||||
|
||||
export const WiredTriggerBaseView: FC<{}> = props =>
|
||||
{
|
||||
const [ triggerLayouts, setTriggerLayouts ] = useState<IWiredLayout[]>([]);
|
||||
|
||||
const RegisterActionLayout = useCallback((layout: IWiredLayout) =>
|
||||
{
|
||||
setTriggerLayouts(layouts => [...layouts, layout]);
|
||||
}, [ setTriggerLayouts ]);
|
||||
|
||||
return null;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user