From c6512be476aaf8c519ff1d1c86e70d91db12c8a3 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 1 Mar 2022 03:23:20 -0500 Subject: [PATCH] Update avatar info widget --- .../AvatarInfoRentableBotChatView.tsx | 71 ++++++++++++++ .../AvatarInfoUseProductConfirmView.tsx | 76 ++++++++------- .../AvatarInfoUseProductView.tsx | 20 ++-- .../AvatarInfoWidgetAvatarView.tsx | 86 +++++++++-------- .../AvatarInfoWidgetDecorateView.tsx | 25 ++--- .../name => }/AvatarInfoWidgetNameView.tsx | 16 ++-- .../AvatarInfoWidgetOwnAvatarView.tsx | 68 +++++++------ .../AvatarInfoWidgetOwnPetView.tsx | 81 +++++++++------- .../pet => }/AvatarInfoWidgetPetView.tsx | 83 ++++++++-------- .../AvatarInfoWidgetRentableBotView.tsx | 95 ++++++++++--------- .../avatar-info/AvatarInfoWidgetView.tsx | 20 ++-- .../AvatarInfoWidgetAvatarView.types.ts | 7 -- .../AvatarInfoWidgetDecorateView.types.ts | 7 -- .../name/AvatarInfoWidgetNameView.types.ts | 7 -- .../AvatarInfoWidgetOwnAvatarView.types.ts | 8 -- .../AvatarInfoWidgetOwnPetView.types.ts | 7 -- .../pet/AvatarInfoWidgetPetView.types.ts | 7 -- .../AvatarInfoRentableBotChatView.tsx | 65 ------------- .../AvatarInfoRentableBotChatView.types.ts | 7 -- .../AvatarInfoWidgetRentableBotView.types.ts | 14 --- .../AvatarInfoUseProductConfirmView.types.ts | 7 -- .../AvatarInfoUseProductView.types.ts | 8 -- .../widgets/context-menu/ContextMenu.scss | 5 + .../context-menu/ContextMenuHeaderView.tsx | 18 ++++ .../context-menu/ContextMenuListItemView.tsx | 32 +++++++ .../context-menu/ContextMenuListView.tsx | 18 ++++ .../widgets/context-menu/ContextMenuView.tsx | 65 +++++++++---- .../context-menu/ContextMenuView.types.ts | 9 -- .../views/header/ContextMenuHeaderView.tsx | 13 --- .../header/ContextMenuHeaderView.types.ts | 5 - .../list-item/ContextMenuListItemView.tsx | 20 ---- .../ContextMenuListItemView.types.ts | 8 -- .../views/list/ContextMenuListView.tsx | 13 --- .../views/list/ContextMenuListView.types.ts | 4 - 34 files changed, 505 insertions(+), 490 deletions(-) create mode 100644 src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx rename src/views/room/widgets/avatar-info/{views/use-product-confirm => }/AvatarInfoUseProductConfirmView.tsx (73%) rename src/views/room/widgets/avatar-info/{views/use-product => }/AvatarInfoUseProductView.tsx (89%) rename src/views/room/widgets/avatar-info/{views/avatar => }/AvatarInfoWidgetAvatarView.tsx (89%) rename src/views/room/widgets/avatar-info/{views/decorate => }/AvatarInfoWidgetDecorateView.tsx (53%) rename src/views/room/widgets/avatar-info/{views/name => }/AvatarInfoWidgetNameView.tsx (58%) rename src/views/room/widgets/avatar-info/{views/own-avatar => }/AvatarInfoWidgetOwnAvatarView.tsx (87%) rename src/views/room/widgets/avatar-info/{views/own-pet => }/AvatarInfoWidgetOwnPetView.tsx (87%) rename src/views/room/widgets/avatar-info/{views/pet => }/AvatarInfoWidgetPetView.tsx (82%) rename src/views/room/widgets/avatar-info/{views/rentable-bot => }/AvatarInfoWidgetRentableBotView.tsx (68%) delete mode 100644 src/views/room/widgets/avatar-info/views/avatar/AvatarInfoWidgetAvatarView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/decorate/AvatarInfoWidgetDecorateView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/name/AvatarInfoWidgetNameView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/own-avatar/AvatarInfoWidgetOwnAvatarView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/own-pet/AvatarInfoWidgetOwnPetView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/pet/AvatarInfoWidgetPetView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.tsx delete mode 100644 src/views/room/widgets/avatar-info/views/rentable-bot-chat/AvatarInfoRentableBotChatView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/rentable-bot/AvatarInfoWidgetRentableBotView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/use-product-confirm/AvatarInfoUseProductConfirmView.types.ts delete mode 100644 src/views/room/widgets/avatar-info/views/use-product/AvatarInfoUseProductView.types.ts create mode 100644 src/views/room/widgets/context-menu/ContextMenuHeaderView.tsx create mode 100644 src/views/room/widgets/context-menu/ContextMenuListItemView.tsx create mode 100644 src/views/room/widgets/context-menu/ContextMenuListView.tsx delete mode 100644 src/views/room/widgets/context-menu/ContextMenuView.types.ts delete mode 100644 src/views/room/widgets/context-menu/views/header/ContextMenuHeaderView.tsx delete mode 100644 src/views/room/widgets/context-menu/views/header/ContextMenuHeaderView.types.ts delete mode 100644 src/views/room/widgets/context-menu/views/list-item/ContextMenuListItemView.tsx delete mode 100644 src/views/room/widgets/context-menu/views/list-item/ContextMenuListItemView.types.ts delete mode 100644 src/views/room/widgets/context-menu/views/list/ContextMenuListView.tsx delete mode 100644 src/views/room/widgets/context-menu/views/list/ContextMenuListView.types.ts diff --git a/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx new file mode 100644 index 00000000..60a34d1e --- /dev/null +++ b/src/views/room/widgets/avatar-info/AvatarInfoRentableBotChatView.tsx @@ -0,0 +1,71 @@ +import { BotSkillSaveComposer } from '@nitrots/nitro-renderer'; +import { FC, useMemo, useState } from 'react'; +import { GetRoomObjectBounds, GetRoomSession, LocalizeText, RoomWidgetUpdateRentableBotChatEvent } from '../../../../api'; +import { Base, Button, Column, Flex, Text } from '../../../../common'; +import { SendMessageHook } from '../../../../hooks'; +import { DraggableWindow, DraggableWindowPosition } from '../../../../layout'; +import { ContextMenuHeaderView } from '../context-menu/ContextMenuHeaderView'; +import { BotSkillsEnum } from './common/BotSkillsEnum'; + +interface AvatarInfoRentableBotChatViewProps +{ + chatEvent: RoomWidgetUpdateRentableBotChatEvent; + close(): void; +} + +export const AvatarInfoRentableBotChatView: FC = props => +{ + const { chatEvent = null, close = null } = props; + // eslint-disable-next-line no-template-curly-in-string + const [ newText, setNewText ] = useState(chatEvent.chat === '${bot.skill.chatter.configuration.text.placeholder}' ? '' : chatEvent.chat); + const [ automaticChat, setAutomaticChat ] = useState(chatEvent.automaticChat); + const [ mixSentences, setMixSentences ] = useState(chatEvent.mixSentences); + const [ chatDelay, setChatDelay ] = useState(chatEvent.chatDelay); + + const getObjectLocation = useMemo(() => GetRoomObjectBounds(GetRoomSession().roomId, chatEvent.objectId, chatEvent.category, 1), [ chatEvent ]); + + const formatChatString = (value: string) => value.replace(/;#;/g, ' ').replace(/\r\n|\r|\n/g, '\r'); + + const save = () => + { + const chatConfiguration = formatChatString(newText) + ';#;' + automaticChat + ';#;' + chatDelay + ';#;' + mixSentences; + + SendMessageHook(new BotSkillSaveComposer(chatEvent.botId, BotSkillsEnum.SETUP_CHAT, chatConfiguration)); + + close(); + } + + return ( + + + + { LocalizeText('bot.skill.chatter.configuration.title') } + + + + { LocalizeText('bot.skill.chatter.configuration.chat.text') } +