From d54ea63f8b362860b8bb540114b923e3f8d36d31 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 15:28:36 -0500 Subject: [PATCH 01/17] Update chat widget --- src/assets/styles/utils.scss | 17 + .../{message => }/ChatWidgetMessageView.tsx | 25 +- .../room/widgets/chat/ChatWidgetView.scss | 905 ++++++++++++++++- .../room/widgets/chat/ChatWidgetView.tsx | 17 +- .../{utils => common}/ChatBubbleMessage.ts | 0 .../chat/message/ChatWidgetMessageView.scss | 921 ------------------ .../message/ChatWidgetMessageView.types.ts | 8 - .../widgets/chat/utils/ChatWidgetUtilities.ts | 32 - 8 files changed, 936 insertions(+), 989 deletions(-) rename src/views/room/widgets/chat/{message => }/ChatWidgetMessageView.tsx (78%) rename src/views/room/widgets/chat/{utils => common}/ChatBubbleMessage.ts (100%) delete mode 100644 src/views/room/widgets/chat/message/ChatWidgetMessageView.scss delete mode 100644 src/views/room/widgets/chat/message/ChatWidgetMessageView.types.ts delete mode 100644 src/views/room/widgets/chat/utils/ChatWidgetUtilities.ts diff --git a/src/assets/styles/utils.scss b/src/assets/styles/utils.scss index 029f054e..8db17555 100644 --- a/src/assets/styles/utils.scss +++ b/src/assets/styles/utils.scss @@ -97,3 +97,20 @@ ul { background-color: $table-striped-bg; } } + +@keyframes bounceIn { + 0% { + opacity: 0; + transform: scale(.3); + } + 50% { + opacity: 1; + transform: scale(1.1); + } + 70% { + transform: scale(.9); + } + 100% { + transform: scale(1); + } +} diff --git a/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx b/src/views/room/widgets/chat/ChatWidgetMessageView.tsx similarity index 78% rename from src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx rename to src/views/room/widgets/chat/ChatWidgetMessageView.tsx index 6ea5eea4..190d7629 100644 --- a/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx +++ b/src/views/room/widgets/chat/ChatWidgetMessageView.tsx @@ -1,20 +1,20 @@ -import { FC, MouseEvent, useCallback, useEffect, useRef, useState } from 'react'; -import { useRoomContext } from '../../../context/RoomContext'; -import { ChatWidgetMessageViewProps } from './ChatWidgetMessageView.types'; +import { FC, MouseEvent, useEffect, useRef, useState } from 'react'; +import { ChatBubbleMessage } from './common/ChatBubbleMessage'; + +interface ChatWidgetMessageViewProps +{ + chat: ChatBubbleMessage; + makeRoom: (chat: ChatBubbleMessage) => void; + onChatClicked: (chat: ChatBubbleMessage) => void; +} export const ChatWidgetMessageView: FC = props => { const { chat = null, makeRoom = null, onChatClicked = null } = props; const [ isVisible, setIsVisible ] = useState(false); - const { widgetHandler = null } = useRoomContext(); const elementRef = useRef(); - const onMouseDown = useCallback((event: MouseEvent) => - { - if(event.shiftKey) return; - - onChatClicked(chat); - }, [ chat, onChatClicked ]); + const onMouseDown = (event: MouseEvent) => ((event.shiftKey) && onChatClicked(chat)); useEffect(() => { @@ -54,10 +54,7 @@ export const ChatWidgetMessageView: FC = props => } }, [ elementRef, chat, makeRoom ]); - useEffect(() => - { - setIsVisible(chat.visible); - }, [ chat.visible ]); + useEffect(() => setIsVisible(chat.visible), [ chat.visible ]); return (
diff --git a/src/views/room/widgets/chat/ChatWidgetView.scss b/src/views/room/widgets/chat/ChatWidgetView.scss index 53904e1d..d2b8c923 100644 --- a/src/views/room/widgets/chat/ChatWidgetView.scss +++ b/src/views/room/widgets/chat/ChatWidgetView.scss @@ -13,4 +13,907 @@ pointer-events: none; } -@import './message/ChatWidgetMessageView'; +.chat-mention { + padding: 1px 5px; + font-weight: bold; + background: rgba(0, 0, 0, .2); + cursor: pointer; + border-radius: 100px; + + &:hover { + color: blue; + } +} + +.bubble-container { + position: absolute; + width: fit-content; + transition: top 0.2s ease 0s; + user-select: none; + pointer-events: all; + + // -webkit-animation-duration: 0.2s; + // animation-duration: 0.2s; + // -webkit-animation-fill-mode: both; + // animation-fill-mode: both; + // -webkit-animation-name: bounceIn; + // animation-name: bounceIn; + + &:hover, + &:active { + pointer-events: none; + } + + .user-container-bg { + position: absolute; + top: -1px; + left: 1px; + width: 30px; + height: calc(100% - 0.5px); + border-radius: 7px; + z-index: 1; + } + + .chat-bubble { + position: relative; + z-index: 1; + word-break: break-word; + max-width: 350px; + min-height: 25px; + font-size: 15px; + + border-image-slice: 17 6 6 29 fill; + border-image-width: 17px 6px 6px 29px; + border-image-outset: 2px 0px 0px 0px; + border-image-repeat: repeat repeat; + + .pointer { + position: absolute; + left: 50%; + transform: translateX(-50%); + + width: 9px; + height: 6px; + bottom: -5px; + } + + &.type-0 { // normal + .message { + font-weight: 400; + } + } + + &.type-1 { // whisper + .message { + font-weight: 400; + font-style: italic; + color: #595959; + } + } + + &.type-2 { // shout + .message { + font-weight: 700; + } + } + + &.bubble-0 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_0_transparent.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); + bottom: -5px; + } + } + + &.bubble-1 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_1.png'); + + border-image-slice: 18 6 6 29 fill; + border-image-width: 18px 6px 6px 29px; + border-image-outset: 3px 0px 0px 0px; + + .user-container { + display: none; + } + + .username { + display: none; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); + } + } + + &.bubble-2, &.bubble-31 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_2.png'); + + .user-container { + display: none; + } + + .username { + color: rgba($white, 1); + } + + .message { + color: rgba($white, 1) !important; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_2_31_pointer.png'); + height: 7px; + } + } + + &.bubble-3 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_3.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_3_pointer.png'); + } + } + + &.bubble-4 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_4.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_4_pointer.png'); + } + } + + &.bubble-5 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_5.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_5_pointer.png'); + } + } + + &.bubble-6 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_6.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_6_pointer.png'); + } + } + + &.bubble-7 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_7.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_7_pointer.png'); + } + } + + &.bubble-8 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_8.png'); + + border-image-slice: 20 6 6 27 fill; + border-image-width: 20px 6px 6px 27px; + border-image-outset: 5px 0px 0px 0px; + + .chat-content { + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_8_pointer.png'); + } + } + + &.bubble-9 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_9.png'); + + border-image-slice: 17 18 12 19 fill; + border-image-width: 17px 18px 12px 19px; + border-image-outset: 7px 7px 0px 9px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_9_pointer.png'); + width: 7px; + height: 10px; + bottom: -6px; + } + } + + &.bubble-10 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_10.png'); + + border-image-slice: 29 18 8 37 fill; + border-image-width: 29px 18px 8px 37px; + border-image-outset: 12px 7px 1px 5px; + + .chat-content { + margin-left: 24px; + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_10_pointer.png'); + width: 7px; + height: 8px; + bottom: -3px; + } + } + + &.bubble-11 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_11.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_11_pointer.png'); + } + } + + &.bubble-12 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_12.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_12_pointer.png'); + } + } + + &.bubble-13 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_13.png'); + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_13_pointer.png'); + } + } + + &.bubble-14 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_14.png'); + + .chat-content { + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_14_pointer.png'); + } + } + + &.bubble-15 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_15.png'); + + .chat-content { + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_15_pointer.png'); + } + } + + &.bubble-16 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_16.png'); + + border-image-slice: 13 6 10 31 fill; + border-image-width: 13px 6px 10px 31px; + border-image-outset: 6px 0px 0px 0px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_16_pointer.png'); + height: 8px; + } + } + + &.bubble-17 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_17.png'); + + border-image-slice: 24 6 8 35 fill; + border-image-width: 24px 6px 8px 35px; + border-image-outset: 9px 0px 2px 5px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_17_pointer.png'); + } + } + + &.bubble-18 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_18.png'); + + border-image-slice: 7 16 8 16 fill; + border-image-width: 7px 16px 8px 16px; + border-image-outset: 3px 10px 2px 11px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_18_pointer.png'); + height: 8px; + } + } + + &.bubble-19 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_19.png'); + + border-image-slice: 17 6 9 19 fill; + border-image-width: 17px 6px 9px 19px; + border-image-outset: 5px 0px 0px 8px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_19_20_pointer.png'); + } + } + + &.bubble-20 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_20.png'); + + border-image-slice: 18 6 8 19 fill; + border-image-width: 18px 6px 8px 19px; + border-image-outset: 5px 0px 0px 8px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_19_20_pointer.png'); + } + } + + &.bubble-21 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_21.png'); + + border-image-slice: 20 6 12 24 fill; + border-image-width: 20px 6px 12px 24px; + border-image-outset: 13px 2px 1px 3px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_21_pointer.png'); + bottom: -4px; + } + } + + &.bubble-22 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_22.png'); + + border-image-slice: 18 19 11 33 fill; + border-image-width: 18px 19px 11px 33px; + border-image-outset: 7px 1px 1px 5px; + + .chat-content { + margin-left: 20px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_22_pointer.png'); + } + } + + &.bubble-23 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_23.png'); + + border-image-slice: 16 6 7 32 fill; + border-image-width: 16px 6px 7px 32px; + border-image-outset: 5px 0px 0px 3px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_23_37_pointer.png'); + } + } + + &.bubble-24 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_24.png'); + + border-image-slice: 23 8 6 40 fill; + border-image-width: 23px 8px 6px 40px; + border-image-outset: 6px 0px 0px 6px; + + .chat-content { + margin-left: 30px; + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_24_pointer.png'); + bottom: -4px; + } + } + + &.bubble-25 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_25.png'); + + border-image-slice: 10 13 8 28 fill; + border-image-width: 10px 13px 8px 28px; + border-image-outset: 6px 3px 2px 0px; + + .chat-content { + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_25_pointer.png'); + height: 9px; + bottom: -7px; + } + } + + &.bubble-26 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_26.png'); + + border-image-slice: 16 9 8 29 fill; + border-image-width: 16px 9px 8px 29px; + border-image-outset: 2px 2px 2px 0px; + + .chat-content { + color: #c59432; + text-shadow: 1px 1px rgba(0, 0, 0, .3); + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_26_pointer.png'); + height: 10px; + bottom: -6px; + } + } + + &.bubble-27 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_27.png'); + + border-image-slice: 25 6 5 36 fill; + border-image-width: 25px 6px 5px 36px; + border-image-outset: 8px 0px 0px 5px; + + .chat-content { + margin-left: 30px; + color: #fff; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_27_pointer.png'); + } + } + + &.bubble-28 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_28.png'); + + border-image-slice: 16 7 7 27 fill; + border-image-width: 16px 7px 7px 27px; + border-image-outset: 3px 0px 0px 0px; + + .chat-content { + margin-left: 25px; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_28_pointer.png'); + } + } + + &.bubble-29 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_29.png'); + + border-image-slice: 10 7 15 31 fill; + border-image-width: 10px 7px 15px 31px; + border-image-outset: 2px 0px 0px 1px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_29_pointer.png'); + bottom: -4px; + } + } + + &.bubble-30 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_30.png'); + + .user-container { + display: none; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_30_pointer.png'); + height: 7px; + } + } + + &.bubble-32 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_32.png'); + + border-image-slice: 15 7 7 30 fill; + border-image-width: 15px 7px 7px 30px; + border-image-outset: 2px 0px 0px 0px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_32_pointer.png'); + } + } + + &.bubble-33 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); + + border-image-slice: 7 6 6 39 fill; + border-image-width: 7px 6px 6px 39px; + border-image-outset: 2px 0px 0px 0px; + + .user-container { + display: none; + } + + .chat-content { + margin-left: 35px; + } + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 9px; + top: 2px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_33_extra.png'); + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); + } + } + + &.bubble-34 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); + + border-image-slice: 7 6 6 39 fill; + border-image-width: 7px 6px 6px 39px; + border-image-outset: 2px 0px 0px 0px; + + &.type-1 { + + .message { + font-style: unset; + color: inherit; + } + } + + .user-container { + display: none; + } + + .username { + display: none; + } + + .chat-content { + margin-left: 35px; + } + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 9px; + top: 2px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_34_extra.png'); + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); + } + } + + &.bubble-35 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_35.png'); + + border-image-slice: 19 6 5 29 fill; + border-image-width: 19px 6px 5px 29px; + border-image-outset: 4px 0px 0px 0px; + + .user-container { + display: none; + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_35_pointer.png'); + } + } + + &.bubble-36 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_36.png'); + + border-image-slice: 17 7 5 30 fill; + border-image-width: 17px 7px 5px 30px; + border-image-outset: 2px 0px 0px 0px; + + .user-container { + display: none; + } + + &::before { + content: ' '; + position: absolute; + width: 13px; + height: 18px; + left: 5px; + top: 2px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_36_extra.png'); + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_36_pointer.png'); + } + } + + &.bubble-37 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_37.png'); + + border-image-slice: 16 6 7 32 fill; + border-image-width: 16px 6px 7px 32px; + border-image-outset: 5px 0px 0px 3px; + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_23_37_pointer.png'); + } + } + + &.bubble-38 { + border-image-source: url('../../../../assets/images/chat/chatbubbles/bubble_38.png'); + + border-image-slice: 17 7 5 30 fill; + border-image-width: 17px 7px 5px 30px; + border-image-outset: 2px 0px 0px 0px; + + .user-container { + display: none; + } + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 3px; + top: 2px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_38_extra.png'); + } + + .pointer { + background: url('../../../../assets/images/chat/chatbubbles/bubble_38_pointer.png'); + } + } + + .user-container { + z-index: 3; + display: flex; + align-items: center; + justify-content: center; + height: 100%; + max-height: 24px; + overflow: hidden; + + .user-image { + position: absolute; + top: -48px; + left: -32.5px; + width: 90px; + height: 130px; + background-repeat: no-repeat; + background-position: center; + transform: scale(0.5); + overflow: hidden; + image-rendering: -webkit-optimize-contrast; + } + } + + .chat-content { + padding: 5px 6px 5px 4px; + margin-left: 27px; + line-height: 1; + color: $black; + min-height: 25px; + } + } +} + +.chat-bubble-icon { + background-repeat: no-repeat; + background-position: center; + + &.bubble-0 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_0.png'); + } + + &.bubble-1 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_1.png'); + height: 25px; + } + + &.bubble-2, &.bubble-31 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_2.png'); + } + + &.bubble-3 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_3.png'); + } + + &.bubble-4 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_4.png'); + } + + &.bubble-5 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_5.png'); + } + + &.bubble-6 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_6.png'); + } + + &.bubble-7 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_7.png'); + } + + &.bubble-8 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_8.png'); + } + + &.bubble-9 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_9.png'); + } + + &.bubble-10 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_10.png'); + } + + &.bubble-11 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_11.png'); + } + + &.bubble-12 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_12.png'); + } + + &.bubble-13 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_13.png'); + } + + &.bubble-14 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_14.png'); + } + + &.bubble-15 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_15.png'); + } + + &.bubble-16 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_16.png'); + } + + &.bubble-17 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_17.png'); + } + + &.bubble-18 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_18.png'); + } + + &.bubble-19 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_19.png'); + } + + &.bubble-20 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_20.png'); + } + + &.bubble-21 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_21.png'); + } + + &.bubble-22 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_22.png'); + } + + &.bubble-23 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_23.png'); + } + + &.bubble-24 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_24.png'); + } + + &.bubble-25 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_25.png'); + } + + &.bubble-26 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_26.png'); + } + + &.bubble-27 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_27.png'); + } + + &.bubble-28 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_28.png'); + } + + &.bubble-29 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_29.png'); + } + + &.bubble-30 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_30.png'); + } + + &.bubble-32 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_32.png'); + } + + &.bubble-33 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 11px; + top: 10px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_33_extra.png'); + } + } + + &.bubble-34 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 11px; + top: 10px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_34_extra.png'); + } + } + + &.bubble-35 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_35.png'); + } + + &.bubble-36 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_36.png'); + + &::before { + content: ' '; + position: absolute; + width: 13px; + height: 18px; + left: 13px; + top: 10px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_36_extra.png'); + } + } + + &.bubble-37 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_35.png'); + } + + &.bubble-38 { + background-image: url('../../../../assets/images/chat/chatbubbles/bubble_38.png'); + + &::before { + content: ' '; + position: absolute; + width: 19px; + height: 19px; + left: 11px; + top: 10px; + background: url('../../../../assets/images/chat/chatbubbles/bubble_38_extra.png'); + } + } +} diff --git a/src/views/room/widgets/chat/ChatWidgetView.tsx b/src/views/room/widgets/chat/ChatWidgetView.tsx index 6dab7b50..9181ffa3 100644 --- a/src/views/room/widgets/chat/ChatWidgetView.tsx +++ b/src/views/room/widgets/chat/ChatWidgetView.tsx @@ -3,8 +3,8 @@ import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api'; import { CreateEventDispatcherHook, useRoomEngineEvent } from '../../../../hooks/events'; import { useRoomContext } from '../../context/RoomContext'; -import { ChatWidgetMessageView } from './message/ChatWidgetMessageView'; -import { ChatBubbleMessage } from './utils/ChatBubbleMessage'; +import { ChatWidgetMessageView } from './ChatWidgetMessageView'; +import { ChatBubbleMessage } from './common/ChatBubbleMessage'; export const ChatWidgetView: FC<{}> = props => { @@ -54,13 +54,7 @@ export const ChatWidgetView: FC<{}> = props => } }, [ chatMessages, moveChatUp, removeHiddenChats ]); - const addChat = useCallback((chat: ChatBubbleMessage) => - { - setChatMessages(prevValue => - { - return [ ...prevValue, chat ]; - }); - }, []); + const addChat = useCallback((chat: ChatBubbleMessage) => setChatMessages(prevValue => [ ...prevValue, chat ]), []); const onRoomWidgetUpdateChatEvent = useCallback((event: RoomWidgetUpdateChatEvent) => { @@ -115,10 +109,7 @@ export const ChatWidgetView: FC<{}> = props => return (
- { chatMessages.map(chat => - { - return - })} + { chatMessages.map(chat => ) }
); } diff --git a/src/views/room/widgets/chat/utils/ChatBubbleMessage.ts b/src/views/room/widgets/chat/common/ChatBubbleMessage.ts similarity index 100% rename from src/views/room/widgets/chat/utils/ChatBubbleMessage.ts rename to src/views/room/widgets/chat/common/ChatBubbleMessage.ts diff --git a/src/views/room/widgets/chat/message/ChatWidgetMessageView.scss b/src/views/room/widgets/chat/message/ChatWidgetMessageView.scss deleted file mode 100644 index 9337ed85..00000000 --- a/src/views/room/widgets/chat/message/ChatWidgetMessageView.scss +++ /dev/null @@ -1,921 +0,0 @@ -@keyframes bounceIn { - 0% { - opacity: 0; - transform: scale(.3); - } - 50% { - opacity: 1; - transform: scale(1.1); - } - 70% { - transform: scale(.9); - } - 100% { - transform: scale(1); - } -} - -.chat-mention { - padding: 1px 5px; - font-weight: bold; - background: rgba(0, 0, 0, .2); - cursor: pointer; - border-radius: 100px; - - &:hover { - color: blue; - } -} - -.bubble-container { - position: absolute; - width: fit-content; - transition: top 0.2s ease 0s; - user-select: none; - pointer-events: all; - - // -webkit-animation-duration: 0.2s; - // animation-duration: 0.2s; - // -webkit-animation-fill-mode: both; - // animation-fill-mode: both; - // -webkit-animation-name: bounceIn; - // animation-name: bounceIn; - - &:hover, - &:active { - pointer-events: none; - } - - .user-container-bg { - position: absolute; - top: -1px; - left: 1px; - width: 30px; - height: calc(100% - 0.5px); - border-radius: 7px; - z-index: 1; - } - - .chat-bubble { - position: relative; - z-index: 1; - word-break: break-word; - max-width: 350px; - min-height: 25px; - font-size: 15px; - - border-image-slice: 17 6 6 29 fill; - border-image-width: 17px 6px 6px 29px; - border-image-outset: 2px 0px 0px 0px; - border-image-repeat: repeat repeat; - - .pointer { - position: absolute; - left: 50%; - transform: translateX(-50%); - - width: 9px; - height: 6px; - bottom: -5px; - } - - &.type-0 { // normal - .message { - font-weight: 400; - } - } - - &.type-1 { // whisper - .message { - font-weight: 400; - font-style: italic; - color: #595959; - } - } - - &.type-2 { // shout - .message { - font-weight: 700; - } - } - - &.bubble-0 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_0_transparent.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); - bottom: -5px; - } - } - - &.bubble-1 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_1.png'); - - border-image-slice: 18 6 6 29 fill; - border-image-width: 18px 6px 6px 29px; - border-image-outset: 3px 0px 0px 0px; - - .user-container { - display: none; - } - - .username { - display: none; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); - } - } - - &.bubble-2, &.bubble-31 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_2.png'); - - .user-container { - display: none; - } - - .username { - color: rgba($white, 1); - } - - .message { - color: rgba($white, 1) !important; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_2_31_pointer.png'); - height: 7px; - } - } - - &.bubble-3 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_3.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_3_pointer.png'); - } - } - - &.bubble-4 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_4.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_4_pointer.png'); - } - } - - &.bubble-5 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_5.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_5_pointer.png'); - } - } - - &.bubble-6 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_6.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_6_pointer.png'); - } - } - - &.bubble-7 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_7.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_7_pointer.png'); - } - } - - &.bubble-8 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_8.png'); - - border-image-slice: 20 6 6 27 fill; - border-image-width: 20px 6px 6px 27px; - border-image-outset: 5px 0px 0px 0px; - - .chat-content { - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_8_pointer.png'); - } - } - - &.bubble-9 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_9.png'); - - border-image-slice: 17 18 12 19 fill; - border-image-width: 17px 18px 12px 19px; - border-image-outset: 7px 7px 0px 9px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_9_pointer.png'); - width: 7px; - height: 10px; - bottom: -6px; - } - } - - &.bubble-10 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_10.png'); - - border-image-slice: 29 18 8 37 fill; - border-image-width: 29px 18px 8px 37px; - border-image-outset: 12px 7px 1px 5px; - - .chat-content { - margin-left: 24px; - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_10_pointer.png'); - width: 7px; - height: 8px; - bottom: -3px; - } - } - - &.bubble-11 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_11.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_11_pointer.png'); - } - } - - &.bubble-12 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_12.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_12_pointer.png'); - } - } - - &.bubble-13 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_13.png'); - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_13_pointer.png'); - } - } - - &.bubble-14 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_14.png'); - - .chat-content { - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_14_pointer.png'); - } - } - - &.bubble-15 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_15.png'); - - .chat-content { - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_15_pointer.png'); - } - } - - &.bubble-16 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_16.png'); - - border-image-slice: 13 6 10 31 fill; - border-image-width: 13px 6px 10px 31px; - border-image-outset: 6px 0px 0px 0px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_16_pointer.png'); - height: 8px; - } - } - - &.bubble-17 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_17.png'); - - border-image-slice: 24 6 8 35 fill; - border-image-width: 24px 6px 8px 35px; - border-image-outset: 9px 0px 2px 5px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_17_pointer.png'); - } - } - - &.bubble-18 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_18.png'); - - border-image-slice: 7 16 8 16 fill; - border-image-width: 7px 16px 8px 16px; - border-image-outset: 3px 10px 2px 11px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_18_pointer.png'); - height: 8px; - } - } - - &.bubble-19 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_19.png'); - - border-image-slice: 17 6 9 19 fill; - border-image-width: 17px 6px 9px 19px; - border-image-outset: 5px 0px 0px 8px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_19_20_pointer.png'); - } - } - - &.bubble-20 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_20.png'); - - border-image-slice: 18 6 8 19 fill; - border-image-width: 18px 6px 8px 19px; - border-image-outset: 5px 0px 0px 8px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_19_20_pointer.png'); - } - } - - &.bubble-21 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_21.png'); - - border-image-slice: 20 6 12 24 fill; - border-image-width: 20px 6px 12px 24px; - border-image-outset: 13px 2px 1px 3px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_21_pointer.png'); - bottom: -4px; - } - } - - &.bubble-22 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_22.png'); - - border-image-slice: 18 19 11 33 fill; - border-image-width: 18px 19px 11px 33px; - border-image-outset: 7px 1px 1px 5px; - - .chat-content { - margin-left: 20px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_22_pointer.png'); - } - } - - &.bubble-23 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_23.png'); - - border-image-slice: 16 6 7 32 fill; - border-image-width: 16px 6px 7px 32px; - border-image-outset: 5px 0px 0px 3px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_23_37_pointer.png'); - } - } - - &.bubble-24 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_24.png'); - - border-image-slice: 23 8 6 40 fill; - border-image-width: 23px 8px 6px 40px; - border-image-outset: 6px 0px 0px 6px; - - .chat-content { - margin-left: 30px; - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_24_pointer.png'); - bottom: -4px; - } - } - - &.bubble-25 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_25.png'); - - border-image-slice: 10 13 8 28 fill; - border-image-width: 10px 13px 8px 28px; - border-image-outset: 6px 3px 2px 0px; - - .chat-content { - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_25_pointer.png'); - height: 9px; - bottom: -7px; - } - } - - &.bubble-26 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_26.png'); - - border-image-slice: 16 9 8 29 fill; - border-image-width: 16px 9px 8px 29px; - border-image-outset: 2px 2px 2px 0px; - - .chat-content { - color: #c59432; - text-shadow: 1px 1px rgba(0, 0, 0, .3); - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_26_pointer.png'); - height: 10px; - bottom: -6px; - } - } - - &.bubble-27 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_27.png'); - - border-image-slice: 25 6 5 36 fill; - border-image-width: 25px 6px 5px 36px; - border-image-outset: 8px 0px 0px 5px; - - .chat-content { - margin-left: 30px; - color: #fff; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_27_pointer.png'); - } - } - - &.bubble-28 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_28.png'); - - border-image-slice: 16 7 7 27 fill; - border-image-width: 16px 7px 7px 27px; - border-image-outset: 3px 0px 0px 0px; - - .chat-content { - margin-left: 25px; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_28_pointer.png'); - } - } - - &.bubble-29 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_29.png'); - - border-image-slice: 10 7 15 31 fill; - border-image-width: 10px 7px 15px 31px; - border-image-outset: 2px 0px 0px 1px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_29_pointer.png'); - bottom: -4px; - } - } - - &.bubble-30 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_30.png'); - - .user-container { - display: none; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_30_pointer.png'); - height: 7px; - } - } - - &.bubble-32 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_32.png'); - - border-image-slice: 15 7 7 30 fill; - border-image-width: 15px 7px 7px 30px; - border-image-outset: 2px 0px 0px 0px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_32_pointer.png'); - } - } - - &.bubble-33 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); - - border-image-slice: 7 6 6 39 fill; - border-image-width: 7px 6px 6px 39px; - border-image-outset: 2px 0px 0px 0px; - - .user-container { - display: none; - } - - .chat-content { - margin-left: 35px; - } - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 9px; - top: 2px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_33_extra.png'); - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); - } - } - - &.bubble-34 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); - - border-image-slice: 7 6 6 39 fill; - border-image-width: 7px 6px 6px 39px; - border-image-outset: 2px 0px 0px 0px; - - &.type-1 { - - .message { - font-style: unset; - color: inherit; - } - } - - .user-container { - display: none; - } - - .username { - display: none; - } - - .chat-content { - margin-left: 35px; - } - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 9px; - top: 2px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_34_extra.png'); - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_0_1_33_34_pointer.png'); - } - } - - &.bubble-35 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_35.png'); - - border-image-slice: 19 6 5 29 fill; - border-image-width: 19px 6px 5px 29px; - border-image-outset: 4px 0px 0px 0px; - - .user-container { - display: none; - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_35_pointer.png'); - } - } - - &.bubble-36 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_36.png'); - - border-image-slice: 17 7 5 30 fill; - border-image-width: 17px 7px 5px 30px; - border-image-outset: 2px 0px 0px 0px; - - .user-container { - display: none; - } - - &::before { - content: ' '; - position: absolute; - width: 13px; - height: 18px; - left: 5px; - top: 2px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_36_extra.png'); - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_36_pointer.png'); - } - } - - &.bubble-37 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_37.png'); - - border-image-slice: 16 6 7 32 fill; - border-image-width: 16px 6px 7px 32px; - border-image-outset: 5px 0px 0px 3px; - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_23_37_pointer.png'); - } - } - - &.bubble-38 { - border-image-source: url('../../../../../assets/images/chat/chatbubbles/bubble_38.png'); - - border-image-slice: 17 7 5 30 fill; - border-image-width: 17px 7px 5px 30px; - border-image-outset: 2px 0px 0px 0px; - - .user-container { - display: none; - } - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 3px; - top: 2px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_38_extra.png'); - } - - .pointer { - background: url('../../../../../assets/images/chat/chatbubbles/bubble_38_pointer.png'); - } - } - - .user-container { - z-index: 3; - display: flex; - align-items: center; - justify-content: center; - height: 100%; - max-height: 24px; - overflow: hidden; - - .user-image { - position: absolute; - top: -48px; - left: -32.5px; - width: 90px; - height: 130px; - background-repeat: no-repeat; - background-position: center; - transform: scale(0.5); - overflow: hidden; - image-rendering: -webkit-optimize-contrast; - } - } - - .chat-content { - padding: 5px 6px 5px 4px; - margin-left: 27px; - line-height: 1; - color: $black; - min-height: 25px; - } - } -} - -.chat-bubble-icon { - background-repeat: no-repeat; - background-position: center; - - &.bubble-0 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_0.png'); - } - - &.bubble-1 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_1.png'); - height: 25px; - } - - &.bubble-2, &.bubble-31 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_2.png'); - } - - &.bubble-3 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_3.png'); - } - - &.bubble-4 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_4.png'); - } - - &.bubble-5 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_5.png'); - } - - &.bubble-6 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_6.png'); - } - - &.bubble-7 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_7.png'); - } - - &.bubble-8 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_8.png'); - } - - &.bubble-9 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_9.png'); - } - - &.bubble-10 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_10.png'); - } - - &.bubble-11 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_11.png'); - } - - &.bubble-12 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_12.png'); - } - - &.bubble-13 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_13.png'); - } - - &.bubble-14 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_14.png'); - } - - &.bubble-15 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_15.png'); - } - - &.bubble-16 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_16.png'); - } - - &.bubble-17 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_17.png'); - } - - &.bubble-18 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_18.png'); - } - - &.bubble-19 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_19.png'); - } - - &.bubble-20 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_20.png'); - } - - &.bubble-21 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_21.png'); - } - - &.bubble-22 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_22.png'); - } - - &.bubble-23 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_23.png'); - } - - &.bubble-24 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_24.png'); - } - - &.bubble-25 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_25.png'); - } - - &.bubble-26 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_26.png'); - } - - &.bubble-27 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_27.png'); - } - - &.bubble-28 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_28.png'); - } - - &.bubble-29 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_29.png'); - } - - &.bubble-30 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_30.png'); - } - - &.bubble-32 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_32.png'); - } - - &.bubble-33 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 11px; - top: 10px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_33_extra.png'); - } - } - - &.bubble-34 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_33_34.png'); - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 11px; - top: 10px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_34_extra.png'); - } - } - - &.bubble-35 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_35.png'); - } - - &.bubble-36 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_36.png'); - - &::before { - content: ' '; - position: absolute; - width: 13px; - height: 18px; - left: 13px; - top: 10px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_36_extra.png'); - } - } - - &.bubble-37 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_35.png'); - } - - &.bubble-38 { - background-image: url('../../../../../assets/images/chat/chatbubbles/bubble_38.png'); - - &::before { - content: ' '; - position: absolute; - width: 19px; - height: 19px; - left: 11px; - top: 10px; - background: url('../../../../../assets/images/chat/chatbubbles/bubble_38_extra.png'); - } - } -} diff --git a/src/views/room/widgets/chat/message/ChatWidgetMessageView.types.ts b/src/views/room/widgets/chat/message/ChatWidgetMessageView.types.ts deleted file mode 100644 index 330b2886..00000000 --- a/src/views/room/widgets/chat/message/ChatWidgetMessageView.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { ChatBubbleMessage } from '../utils/ChatBubbleMessage'; - -export interface ChatWidgetMessageViewProps -{ - chat: ChatBubbleMessage; - makeRoom: (chat: ChatBubbleMessage) => void; - onChatClicked: (chat: ChatBubbleMessage) => void; -} diff --git a/src/views/room/widgets/chat/utils/ChatWidgetUtilities.ts b/src/views/room/widgets/chat/utils/ChatWidgetUtilities.ts deleted file mode 100644 index 220b6bae..00000000 --- a/src/views/room/widgets/chat/utils/ChatWidgetUtilities.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { INitroPoint, IVector3D, NitroPoint } from '@nitrots/nitro-renderer'; -import { GetRoomEngine } from '../../../../../api'; - -export function GetBubbleLocation(roomId: number, userLocation: IVector3D, canvasId = 1): INitroPoint -{ - const geometry = GetRoomEngine().getRoomInstanceGeometry(roomId, canvasId); - const scale = GetRoomEngine().getRoomInstanceRenderingCanvasScale(roomId, canvasId); - - let x = ((document.body.offsetWidth * scale) / 2); - let y = ((document.body.offsetHeight * scale) / 2); - - if(geometry && userLocation) - { - const screenPoint = geometry.getScreenPoint(userLocation); - - if(screenPoint) - { - x = (x + (screenPoint.x * scale)); - y = (y + (screenPoint.y * scale)); - - const offsetPoint = GetRoomEngine().getRoomInstanceRenderingCanvasOffset(roomId, canvasId); - - if(offsetPoint) - { - x = (x + offsetPoint.x); - y = (y + offsetPoint.y); - } - } - } - - return new NitroPoint(x, y); -} From da810998c5b6f5c3a78f867575596d60fae14874 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 19:31:26 -0500 Subject: [PATCH 02/17] Update chooser widget --- src/App.scss | 3 + .../widgets/choosers/ChooserWidgetView.scss | 16 +----- .../widgets/choosers/ChooserWidgetView.tsx | 56 ++++++++++--------- .../choosers/ChooserWidgetView.type.ts | 9 --- .../choosers/FurniChooserWidgetView.tsx | 20 ++++--- .../choosers/UserChooserWidgetView.tsx | 16 ++++-- 6 files changed, 58 insertions(+), 62 deletions(-) delete mode 100644 src/views/room/widgets/choosers/ChooserWidgetView.type.ts diff --git a/src/App.scss b/src/App.scss index 547c02c4..30fce560 100644 --- a/src/App.scss +++ b/src/App.scss @@ -71,6 +71,9 @@ $room-info-width: 325px; $nitro-mod-tools-width: 175px; +$nitro-chooser-width: 200px; +$nitro-chooser-height: 200px; + .nitro-app { width: 100%; height: 100%; diff --git a/src/views/room/widgets/choosers/ChooserWidgetView.scss b/src/views/room/widgets/choosers/ChooserWidgetView.scss index 5365dd13..026e95b1 100644 --- a/src/views/room/widgets/choosers/ChooserWidgetView.scss +++ b/src/views/room/widgets/choosers/ChooserWidgetView.scss @@ -1,16 +1,4 @@ .nitro-chooser-widget { - - - .chooser-container { - min-height: 150px; - - .list-item { - color: black; - overflow: hidden; - - &.selected { - background-color: cadetblue; - } - } - } + width: $nitro-chooser-width; + height: $nitro-chooser-height; } diff --git a/src/views/room/widgets/choosers/ChooserWidgetView.tsx b/src/views/room/widgets/choosers/ChooserWidgetView.tsx index 492b5164..2a11519f 100644 --- a/src/views/room/widgets/choosers/ChooserWidgetView.tsx +++ b/src/views/room/widgets/choosers/ChooserWidgetView.tsx @@ -2,16 +2,24 @@ import { FC, useCallback, useMemo, useState } from 'react'; import { AutoSizer, List, ListRowProps, ListRowRenderer } from 'react-virtualized'; import { RoomObjectItem, RoomWidgetRoomObjectMessage } from '../../../../api'; import { LocalizeText } from '../../../../api/utils'; +import { Column, Flex, Text } from '../../../../common'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../layout'; import { useRoomContext } from '../../context/RoomContext'; -import { ChooserWidgetViewProps } from './ChooserWidgetView.type'; + +interface ChooserWidgetViewProps +{ + title: string; + items: RoomObjectItem[]; + displayItemId: boolean; + onCloseClick: () => void; +} export const ChooserWidgetView: FC = props => { const { title = null, items = null, displayItemId = false, onCloseClick = null } = props; const [ selectedItem, setSelectedItem ] = useState(null); const [ searchValue, setSearchValue ] = useState(''); - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const { widgetHandler = null } = useRoomContext(); const filteredItems = useMemo(() => { @@ -21,15 +29,13 @@ export const ChooserWidgetView: FC = props => const value = searchValue.toLocaleLowerCase(); - return items.filter(item => - { - return item.name.toLocaleLowerCase().includes(value); - }); + return items.filter(item => item.name.toLocaleLowerCase().includes(value)); }, [ items, searchValue ]); const onItemClick = useCallback((item: RoomObjectItem) => { setSelectedItem(item); + widgetHandler.processWidgetMessage(new RoomWidgetRoomObjectMessage(RoomWidgetRoomObjectMessage.SELECT_OBJECT, item.id, item.category)); }, [ widgetHandler, setSelectedItem]); @@ -38,34 +44,30 @@ export const ChooserWidgetView: FC = props => const item = filteredItems[props.index]; return ( -
onItemClick(item) }> - { item.name } { displayItemId && (' - ' + item.id) } -
+ onItemClick(item) }> + { item.name } { displayItemId && (' - ' + item.id) } + ); } return ( - -
-
- setSearchValue(event.target.value)} /> -
-
-
- - {({ height, width }) => - { - return () - }} + + setSearchValue(event.target.value)} /> + + + { ({ width, height }) => + { + return () + } } -
+
); diff --git a/src/views/room/widgets/choosers/ChooserWidgetView.type.ts b/src/views/room/widgets/choosers/ChooserWidgetView.type.ts deleted file mode 100644 index 89c9a169..00000000 --- a/src/views/room/widgets/choosers/ChooserWidgetView.type.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { RoomObjectItem } from '../../../../api'; - -export interface ChooserWidgetViewProps -{ - title: string; - items: RoomObjectItem[]; - displayItemId: boolean; - onCloseClick: () => void; -} diff --git a/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx b/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx index 68a2971f..99198b1d 100644 --- a/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx +++ b/src/views/room/widgets/choosers/FurniChooserWidgetView.tsx @@ -1,6 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetRequestWidgetMessage, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../../../hooks'; +import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChooserWidgetView } from './ChooserWidgetView'; @@ -20,13 +20,16 @@ export const FurniChooserWidgetView: FC<{}> = props => if(prevValue) clearTimeout(prevValue); return setTimeout(() => widgetHandler.processWidgetMessage(new RoomWidgetRequestWidgetMessage(RoomWidgetRequestWidgetMessage.FURNI_CHOOSER)), 100); - }) + }); }, [ isVisible, widgetHandler ]); const onRoomWidgetChooserContentEvent = useCallback((event: RoomWidgetChooserContentEvent) => { - setItems(event.items); - setIsVisible(true); + BatchUpdates(() => + { + setItems(event.items); + setIsVisible(true); + }); }, []); CreateEventDispatcherHook(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); @@ -49,11 +52,14 @@ export const FurniChooserWidgetView: FC<{}> = props => const close = useCallback(() => { - setIsVisible(false); - setItems(null); + BatchUpdates(() => + { + setIsVisible(false); + setItems(null); + }); }, []); - if(!isVisible) return null; + if(!items) return null; return ; } diff --git a/src/views/room/widgets/choosers/UserChooserWidgetView.tsx b/src/views/room/widgets/choosers/UserChooserWidgetView.tsx index b9ab2460..18dcbefd 100644 --- a/src/views/room/widgets/choosers/UserChooserWidgetView.tsx +++ b/src/views/room/widgets/choosers/UserChooserWidgetView.tsx @@ -1,6 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetRequestWidgetMessage, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../../../hooks'; +import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { ChooserWidgetView } from './ChooserWidgetView'; @@ -25,8 +25,11 @@ export const UserChooserWidgetView: FC<{}> = props => const onRoomWidgetChooserContentEvent = useCallback((event: RoomWidgetChooserContentEvent) => { - setItems(event.items); - setIsVisible(true); + BatchUpdates(() => + { + setItems(event.items); + setIsVisible(true); + }); }, []); CreateEventDispatcherHook(RoomWidgetChooserContentEvent.USER_CHOOSER_CONTENT, eventDispatcher, onRoomWidgetChooserContentEvent); @@ -49,8 +52,11 @@ export const UserChooserWidgetView: FC<{}> = props => const close = useCallback(() => { - setIsVisible(false); - setItems(null); + BatchUpdates(() => + { + setIsVisible(false); + setItems(null); + }); }, []); if(!isVisible) return null; From de682dac3af1f0638e649edb88f2a127dc3d7064 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 19:40:53 -0500 Subject: [PATCH 03/17] Update doorbell widget --- src/views/room/widgets/RoomWidgets.scss | 1 - .../doorbell/DoorbellWidgetItemView.tsx | 29 +++++++++++++++++++ .../widgets/doorbell/DoorbellWidgetView.scss | 22 -------------- .../widgets/doorbell/DoorbellWidgetView.tsx | 25 ++++++++-------- .../doorbell-item/DoorbellWidgetItemView.tsx | 21 -------------- .../DoorbellWidgetItemView.types.ts | 6 ---- 6 files changed, 41 insertions(+), 63 deletions(-) create mode 100644 src/views/room/widgets/doorbell/DoorbellWidgetItemView.tsx delete mode 100644 src/views/room/widgets/doorbell/DoorbellWidgetView.scss delete mode 100644 src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.tsx delete mode 100644 src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.types.ts diff --git a/src/views/room/widgets/RoomWidgets.scss b/src/views/room/widgets/RoomWidgets.scss index 46b5281c..a2f114d6 100644 --- a/src/views/room/widgets/RoomWidgets.scss +++ b/src/views/room/widgets/RoomWidgets.scss @@ -3,7 +3,6 @@ @import './chat-input/ChatInputView'; @import './choosers/ChooserWidgetView'; @import './context-menu/ContextMenu'; -@import './doorbell/DoorbellWidgetView'; @import './friend-request/FriendRequestDialogView'; @import './furniture/FurnitureWidgets'; @import './infostand/InfoStandWidgetView'; diff --git a/src/views/room/widgets/doorbell/DoorbellWidgetItemView.tsx b/src/views/room/widgets/doorbell/DoorbellWidgetItemView.tsx new file mode 100644 index 00000000..810cae5d --- /dev/null +++ b/src/views/room/widgets/doorbell/DoorbellWidgetItemView.tsx @@ -0,0 +1,29 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FC } from 'react'; +import { Button, ButtonGroup, Flex, Text } from '../../../../common'; + +interface DoorbellWidgetItemViewProps +{ + userName: string; + accept: () => void; + deny: () => void; +} + +export const DoorbellWidgetItemView: FC = props => +{ + const { userName = '', accept = null, deny = null } = props; + + return ( + + { userName } + + + + + + ); +} diff --git a/src/views/room/widgets/doorbell/DoorbellWidgetView.scss b/src/views/room/widgets/doorbell/DoorbellWidgetView.scss deleted file mode 100644 index 125a5e69..00000000 --- a/src/views/room/widgets/doorbell/DoorbellWidgetView.scss +++ /dev/null @@ -1,22 +0,0 @@ -.nitro-widget-doorbell { - width: 250px; - - .content-area { - min-height: 143px; - height: 143px; - } - - .doorbell-user-list { - - .list-item { - background: $grid-active-bg-color; - } - - .col:nth-child(even) { - - .list-item { - background: $white !important; - } - } - } -} diff --git a/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx b/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx index 8e8b86c5..a42ed47c 100644 --- a/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx +++ b/src/views/room/widgets/doorbell/DoorbellWidgetView.tsx @@ -1,9 +1,10 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomWidgetDoorbellEvent, RoomWidgetLetUserInMessage } from '../../../../api'; -import { CreateEventDispatcherHook } from '../../../../hooks'; +import { Column } from '../../../../common'; +import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../layout'; import { useRoomContext } from '../../context/RoomContext'; -import { DoorbellWidgetItemView } from './doorbell-item/DoorbellWidgetItemView'; +import { DoorbellWidgetItemView } from './DoorbellWidgetItemView'; export const DoorbellWidgetView: FC<{}> = props => { @@ -15,10 +16,11 @@ export const DoorbellWidgetView: FC<{}> = props => { if(users.indexOf(userName) >= 0) return; - const newUsers = [ ...users, userName ]; - - setUsers(newUsers); - setIsVisible(true); + BatchUpdates(() => + { + setUsers([ ...users, userName ]); + setIsVisible(true); + }); }, [ users ]); const removeUser = useCallback((userName: string) => @@ -66,13 +68,10 @@ export const DoorbellWidgetView: FC<{}> = props => return ( setIsVisible(false) } /> - -
- { (users.length > 0) && users.map(userName => - { - return answer(userName, true) } deny={ () => answer(userName, false) } />; - }) } -
+ + + { users && (users.length > 0) && users.map(userName => answer(userName, true) } deny={ () => answer(userName, false) } />) } +
); diff --git a/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.tsx b/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.tsx deleted file mode 100644 index dcd90189..00000000 --- a/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { FC } from 'react'; -import { DoorbellWidgetItemViewProps } from './DoorbellWidgetItemView.types'; - -export const DoorbellWidgetItemView: FC = props => -{ - const { userName = '', accept = null, deny = null } = props; - - return ( -
- { userName } -
- - -
-
- ); -} diff --git a/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.types.ts b/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.types.ts deleted file mode 100644 index a0ba4caa..00000000 --- a/src/views/room/widgets/doorbell/doorbell-item/DoorbellWidgetItemView.types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface DoorbellWidgetItemViewProps -{ - userName: string; - accept: () => void; - deny: () => void; -} From 7bf528d4be18e441462c0edd0303822f38e7e7d6 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 19:52:37 -0500 Subject: [PATCH 04/17] Update dimmer widget --- .../furniture/dimmer/FurnitureDimmerView.scss | 6 +- .../furniture/dimmer/FurnitureDimmerView.tsx | 61 ++++++++----------- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss index 7ec95775..a83b0fe6 100644 --- a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss @@ -1,10 +1,10 @@ -.nitro-dimmer { - width: 300px; +.nitro-room-widget-dimmer { + width: 275px; .dimmer-banner { width: 56px; height: 79px; - background: url(../../../../../assets/images/room-widgets/dimmer-widget/dimmer_banner.png) center no-repeat; + background: url('../../../../../assets/images/room-widgets/dimmer-widget/dimmer_banner.png') center no-repeat; } .color-swatch { diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx index ad1e5dee..7e02396a 100644 --- a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx +++ b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.tsx @@ -3,11 +3,7 @@ import classNames from 'classnames'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import ReactSlider from 'react-slider'; import { ColorUtils, GetConfiguration, LocalizeText, RoomWidgetDimmerChangeStateMessage, RoomWidgetDimmerPreviewMessage, RoomWidgetDimmerSavePresetMessage, RoomWidgetUpdateDimmerEvent, RoomWidgetUpdateDimmerStateEvent } from '../../../../../api'; -import { Button } from '../../../../../common/Button'; -import { Column } from '../../../../../common/Column'; -import { Flex } from '../../../../../common/Flex'; -import { Grid } from '../../../../../common/Grid'; -import { Text } from '../../../../../common/Text'; +import { Base, Button, Column, Flex, Grid, Text } from '../../../../../common'; import { BatchUpdates, CreateEventDispatcherHook } from '../../../../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../../layout'; import { useRoomContext } from '../../../context/RoomContext'; @@ -31,7 +27,6 @@ export const FurnitureDimmerView: FC<{}> = props => const [ selectedEffectId, setSelectedEffectId ] = useState(0); const [ selectedColor, setSelectedColor ] = useState(0); const [ selectedBrightness, setSelectedBrightness ] = useState(0); - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const onNitroEvent = useCallback((event: NitroEvent) => @@ -45,9 +40,12 @@ export const FurnitureDimmerView: FC<{}> = props => for(const preset of widgetEvent.presets) presets.push(new DimmerFurnitureWidgetPresetItem(preset.id, preset.type, preset.color, preset.brightness)); - setPresets(presets); - setSelectedPresetId(widgetEvent.selectedPresetId); - setIsVisible(true); + BatchUpdates(() => + { + setPresets(presets); + setSelectedPresetId(widgetEvent.selectedPresetId); + setIsVisible(true); + }); return; } case RoomWidgetUpdateDimmerEvent.HIDE: { @@ -86,10 +84,13 @@ export const FurnitureDimmerView: FC<{}> = props => if(!preset) return; - setSelectedPresetId(preset.id); - setSelectedEffectId(preset.type); - setSelectedColor(preset.color); - setSelectedBrightness(preset.light); + BatchUpdates(() => + { + setSelectedPresetId(preset.id); + setSelectedEffectId(preset.type); + setSelectedColor(preset.color); + setSelectedBrightness(preset.light); + }); }, [ presets ]); const close = useCallback(() => @@ -133,36 +134,28 @@ export const FurnitureDimmerView: FC<{}> = props => return ~~((((value - MIN_BRIGHTNESS) * (100 - 0)) / (MAX_BRIGHTNESS - MIN_BRIGHTNESS)) + 0); }, []); - const isFreeColorMode = useMemo(() => - { - return GetConfiguration('widget.dimmer.colorwheel', false); - }, []); + const isFreeColorMode = useMemo(() => GetConfiguration('widget.dimmer.colorwheel', false), []); useEffect(() => { if((dimmerState === 0) && (lastDimmerState === 0)) return; - console.log('ye') - widgetHandler.processWidgetMessage(new RoomWidgetDimmerPreviewMessage(selectedColor, selectedBrightness, (selectedEffectId === 2))); }, [ widgetHandler, dimmerState, lastDimmerState, selectedColor, selectedBrightness, selectedEffectId ]); if(!isVisible) return null; return ( - + { (dimmerState === 1) && - { presets.map(preset => - { - return selectPresetId(preset.id) }>{ LocalizeText(`widget.dimmer.tab.${preset.id}`) } - }) } + { presets.map(preset => selectPresetId(preset.id) }>{ LocalizeText(`widget.dimmer.tab.${preset.id}`) }) } } { (dimmerState === 0) && -
+ { LocalizeText('widget.dimmer.info.off') }
} @@ -173,7 +166,7 @@ export const FurnitureDimmerView: FC<{}> = props => { isFreeColorMode && setSelectedColor(ColorUtils.convertFromHex(event.target.value)) } /> } { !isFreeColorMode && - + { AVAILABLE_COLORS.map((color, index) => { return ( @@ -193,18 +186,14 @@ export const FurnitureDimmerView: FC<{}> = props => thumbClassName={ 'thumb percent' } renderThumb={ (props, state) =>
{ scaledBrightness(state.valueNow) }
} /> - + setSelectedEffectId(event.target.checked ? 2 : 1) } /> - + { LocalizeText('widget.dimmer.type.checkbox') } + + + + -
- setSelectedEffectId(event.target.checked ? 2 : 1) } /> - -
-
- - -
}
From 66bb329b74ca2cfa5a4dcbed5d3c4ffed1628167 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 19:56:16 -0500 Subject: [PATCH 05/17] Update background color widget --- .../FurnitureBackgroundColorView.tsx | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx index 1442a942..576ac22b 100644 --- a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx +++ b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx @@ -2,11 +2,8 @@ import { ApplyTonerComposer, RoomControllerLevel, RoomEngineObjectEvent, RoomEng import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { GetRoomEngine, GetSessionDataManager, LocalizeText, RoomWidgetUpdateBackgroundColorPreviewEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; -import { Button } from '../../../../../common/Button'; -import { Column } from '../../../../../common/Column'; -import { FormGroup } from '../../../../../common/FormGroup'; -import { Text } from '../../../../../common/Text'; -import { SendMessageHook } from '../../../../../hooks'; +import { Button, Column, Text } from '../../../../../common'; +import { BatchUpdates, SendMessageHook } from '../../../../../hooks'; import { CreateEventDispatcherHook, useRoomEngineEvent } from '../../../../../hooks/events'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; import { useRoomContext } from '../../../context/RoomContext'; @@ -44,11 +41,14 @@ export const FurnitureBackgroundColorView: FC<{}> = props => const roomObject = GetRoomEngine().getRoomObject(event.roomId, event.objectId, event.category); const model = roomObject.model; - - setObjectId(roomObject.id); - setHue(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_HUE))); - setSaturation(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_SATURATION))); - setLightness(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_LIGHTNESS))); + + BatchUpdates(() => + { + setObjectId(roomObject.id); + setHue(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_HUE))); + setSaturation(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_SATURATION))); + setLightness(parseInt(model.getValue(RoomObjectVariable.FURNITURE_ROOM_BACKGROUND_COLOR_LIGHTNESS))); + }); return; } @@ -89,10 +89,10 @@ export const FurnitureBackgroundColorView: FC<{}> = props => return ( - - - - { LocalizeText('widget.backgroundcolor.hue') } + + + + { LocalizeText('widget.backgroundcolor.hue') } = props => onChange={ event => setHue(event) } thumbClassName={ 'thumb degree' } renderThumb={ (props, state) =>
{ state.valueNow }
} /> -
- - { LocalizeText('widget.backgroundcolor.saturation') } +
+ + { LocalizeText('widget.backgroundcolor.saturation') } = props => onChange={ event => setSaturation(event) } thumbClassName={ 'thumb percent' } renderThumb={ (props, state) =>
{ state.valueNow }
} /> - - - { LocalizeText('widget.backgroundcolor.lightness') } +
+ + { LocalizeText('widget.backgroundcolor.lightness') } = props => onChange={ event => setLightness(event) } thumbClassName={ 'thumb percent' } renderThumb={ (props, state) =>
{ state.valueNow }
} /> - +
- - - From d40cb0897391c9c2fd51092d89c6e3fe67769df8 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 21:52:27 -0500 Subject: [PATCH 06/17] Update context menus --- .../context-menu/FurnitureContextMenuView.tsx | 100 +++++++++++------- .../views/EffectBoxConfirmView.tsx | 41 +++++++ .../MonsterPlantSeedConfirmView.tsx | 58 +++++----- .../PurchasableClothingConfirmView.tsx | 60 ++++++----- .../views/effect-box/EffectBoxConfirmView.tsx | 37 ------- .../effect-box/EffectBoxConfirmView.types.ts | 5 - .../MonsterPlantSeedConfirmView.types.ts | 5 - .../PurchasableClothingConfirmView.types.ts | 5 - 8 files changed, 165 insertions(+), 146 deletions(-) create mode 100644 src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx rename src/views/room/widgets/furniture/context-menu/views/{monsterplant-seed => }/MonsterPlantSeedConfirmView.tsx (50%) rename src/views/room/widgets/furniture/context-menu/views/{purchaseable-clothing => }/PurchasableClothingConfirmView.tsx (59%) delete mode 100644 src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.tsx delete mode 100644 src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.types.ts delete mode 100644 src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.types.ts delete mode 100644 src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.types.ts diff --git a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx index a66d6bda..c8b836fd 100644 --- a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx +++ b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx @@ -3,15 +3,15 @@ import { GroupFurniContextMenuInfoMessageEvent } from '@nitrots/nitro-renderer/s import { FC, useCallback, useState } from 'react'; import { GetGroupInformation, GetRoomEngine, IsOwnerOfFurniture, LocalizeText, RoomWidgetFurniActionMessage, TryVisitRoom } from '../../../../../api'; import { TryJoinGroup } from '../../../../../api/groups/TryJoinGroup'; -import { CreateMessageHook } from '../../../../../hooks'; +import { BatchUpdates, CreateMessageHook } from '../../../../../hooks'; import { useRoomEngineEvent } from '../../../../../hooks/events'; import { useRoomContext } from '../../../context/RoomContext'; import { ContextMenuView } from '../../context-menu/ContextMenuView'; import { ContextMenuHeaderView } from '../../context-menu/views/header/ContextMenuHeaderView'; import { ContextMenuListItemView } from '../../context-menu/views/list-item/ContextMenuListItemView'; -import { EffectBoxConfirmView } from './views/effect-box/EffectBoxConfirmView'; -import { MonsterPlantSeedConfirmView } from './views/monsterplant-seed/MonsterPlantSeedConfirmView'; -import { PurchasableClothingConfirmView } from './views/purchaseable-clothing/PurchasableClothingConfirmView'; +import { EffectBoxConfirmView } from './views/EffectBoxConfirmView'; +import { MonsterPlantSeedConfirmView } from './views/MonsterPlantSeedConfirmView'; +import { PurchasableClothingConfirmView } from './views/PurchasableClothingConfirmView'; const MONSTERPLANT_SEED_CONFIRMATION: string = 'MONSTERPLANT_SEED_CONFIRMATION'; const PURCHASABLE_CLOTHING_CONFIRMATION: string = 'PURCHASABLE_CLOTHING_CONFIRMATION'; @@ -26,22 +26,24 @@ export const FurnitureContextMenuView: FC<{}> = props => const [ confirmingObjectId, setConfirmingObjectId ] = useState(-1); const [ groupData, setGroupData ] = useState(null); const [ isGroupMember, setIsGroupMember ] = useState(false); - const { roomSession = null, widgetHandler = null } = useRoomContext(); const close = useCallback(() => { - setObjectId(-1); - setGroupData(null); - setIsGroupMember(false); - setMode(null); + BatchUpdates(() => + { + setObjectId(-1); + setGroupData(null); + setIsGroupMember(false); + setMode(null); + }); }, []); - const closeConfirm = useCallback(() => + const closeConfirm = () => { setConfirmMode(null); setConfirmingObjectId(-1); - }, []); + } const onRoomEngineTriggerWidgetEvent = useCallback((event: RoomEngineTriggerWidgetEvent) => { @@ -54,47 +56,60 @@ export const FurnitureContextMenuView: FC<{}> = props => case RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG: if(!IsOwnerOfFurniture(object)) return; - setConfirmingObjectId(object.id); - setConfirmMode(MONSTERPLANT_SEED_CONFIRMATION); + BatchUpdates(() => + { + setConfirmingObjectId(object.id); + setConfirmMode(MONSTERPLANT_SEED_CONFIRMATION); + }); close(); return; case RoomEngineTriggerWidgetEvent.REQUEST_EFFECTBOX_OPEN_DIALOG: if(!IsOwnerOfFurniture(object)) return; - - setConfirmingObjectId(object.id); - setConfirmMode(EFFECTBOX_OPEN); + + BatchUpdates(() => + { + setConfirmingObjectId(object.id); + setConfirmMode(EFFECTBOX_OPEN); + }); close(); return; case RoomEngineTriggerWidgetEvent.REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG: if(!IsOwnerOfFurniture(object)) return; - setConfirmingObjectId(object.id); - setConfirmMode(PURCHASABLE_CLOTHING_CONFIRMATION); + BatchUpdates(() => + { + setConfirmingObjectId(object.id); + setConfirmMode(PURCHASABLE_CLOTHING_CONFIRMATION); + }); close(); return; case RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU: - setObjectId(object.id); - switch(event.contextMenu) + BatchUpdates(() => { - case ContextMenuEnum.FRIEND_FURNITURE: - setMode(ContextMenuEnum.FRIEND_FURNITURE); - return; - case ContextMenuEnum.MONSTERPLANT_SEED: - if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.MONSTERPLANT_SEED); - return; - case ContextMenuEnum.MYSTERY_BOX: - return; - case ContextMenuEnum.RANDOM_TELEPORT: - setMode(ContextMenuEnum.RANDOM_TELEPORT); - return; - case ContextMenuEnum.PURCHASABLE_CLOTHING: - if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.PURCHASABLE_CLOTHING); - return; - } + setObjectId(object.id); + + switch(event.contextMenu) + { + case ContextMenuEnum.FRIEND_FURNITURE: + setMode(ContextMenuEnum.FRIEND_FURNITURE); + return; + case ContextMenuEnum.MONSTERPLANT_SEED: + if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.MONSTERPLANT_SEED); + return; + case ContextMenuEnum.MYSTERY_BOX: + return; + case ContextMenuEnum.RANDOM_TELEPORT: + setMode(ContextMenuEnum.RANDOM_TELEPORT); + return; + case ContextMenuEnum.PURCHASABLE_CLOTHING: + if(IsOwnerOfFurniture(object)) setMode(ContextMenuEnum.PURCHASABLE_CLOTHING); + return; + } + }); return; case RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU: @@ -113,15 +128,18 @@ export const FurnitureContextMenuView: FC<{}> = props => { const parser = event.getParser(); - setObjectId(parser.objectId); - setGroupData(parser); - setIsGroupMember(parser.userIsMember); - setMode(GROUP_FURNITURE); + BatchUpdates(() => + { + setObjectId(parser.objectId); + setGroupData(parser); + setIsGroupMember(parser.userIsMember); + setMode(GROUP_FURNITURE); + }); }, []); CreateMessageHook(GroupFurniContextMenuInfoMessageEvent, onGroupFurniContextMenuInfoMessageEvent); - const processAction = useCallback((name: string) => + const processAction = (name: string) => { if(name) { @@ -152,7 +170,7 @@ export const FurnitureContextMenuView: FC<{}> = props => } close(); - }, [ roomSession, widgetHandler, objectId, groupData, close ]); + } return ( <> diff --git a/src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx new file mode 100644 index 00000000..0732c592 --- /dev/null +++ b/src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx @@ -0,0 +1,41 @@ +import { FC } from 'react'; +import { LocalizeText } from '../../../../../../api'; +import { Button, Column, Flex, Text } from '../../../../../../common'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; +import { useRoomContext } from '../../../../context/RoomContext'; + +interface EffectBoxConfirmViewProps +{ + objectId: number; + close: () => void; +} + +export const EffectBoxConfirmView: FC = props => +{ + const { objectId = -1, close = null } = props; + const { roomSession = null } = useRoomContext(); + + const useProduct = () => + { + roomSession.useMultistateItem(objectId); + + close(); + } + + return ( + + + + + + { LocalizeText('effectbox.header.description') } + + + + + + + + + ); +} diff --git a/src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx similarity index 50% rename from src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.tsx rename to src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx index 4d1836c0..f6bc99eb 100644 --- a/src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.tsx +++ b/src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx @@ -1,10 +1,16 @@ import { IFurnitureData, RoomObjectCategory } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useState } from 'react'; -import { GetFurnitureDataForRoomObject, LocalizeText, RoomWidgetUseProductMessage } from '../../../../../../../api'; -import { FurniCategory } from '../../../../../../../components/inventory/common/FurniCategory'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../../layout'; -import { useRoomContext } from '../../../../../context/RoomContext'; -import { MonsterPlantSeedConfirmViewProps } from './MonsterPlantSeedConfirmView.types'; +import { FC, useEffect, useState } from 'react'; +import { GetFurnitureDataForRoomObject, LocalizeText, RoomWidgetUseProductMessage } from '../../../../../../api'; +import { Base, Button, Column, Flex, Text } from '../../../../../../common'; +import { FurniCategory } from '../../../../../../components/inventory/common/FurniCategory'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; +import { useRoomContext } from '../../../../context/RoomContext'; + +interface MonsterPlantSeedConfirmViewProps +{ + objectId: number; + close: () => void; +} const MODE_DEFAULT: number = -1; const MODE_MONSTERPLANT_SEED: number = 0; @@ -16,12 +22,12 @@ export const MonsterPlantSeedConfirmView: FC = const [ mode, setMode ] = useState(MODE_DEFAULT); const { roomSession = null, widgetHandler = null } = useRoomContext(); - const useProduct = useCallback(() => + const useProduct = () => { widgetHandler.processWidgetMessage(new RoomWidgetUseProductMessage(RoomWidgetUseProductMessage.MONSTERPLANT_SEED, objectId)); close(); - }, [ widgetHandler, objectId, close ]); + } useEffect(() => { @@ -57,24 +63,24 @@ export const MonsterPlantSeedConfirmView: FC = return ( - -
-
-
-
-
-
-
-
-
{ LocalizeText('useproduct.widget.text.plant_seed', [ 'productName' ], [ furniData.name ] ) }
-
{ LocalizeText('useproduct.widget.info.plant_seed') }
-
-
- - -
-
-
+ + + + + + + + + + { LocalizeText('useproduct.widget.text.plant_seed', [ 'productName' ], [ furniData.name ] ) } + { LocalizeText('useproduct.widget.info.plant_seed') } + + + + + + + ); diff --git a/src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx similarity index 59% rename from src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.tsx rename to src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx index 01cf94c2..fb673709 100644 --- a/src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.tsx +++ b/src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx @@ -1,12 +1,18 @@ import { RedeemItemClothingComposer, RoomObjectCategory, UserFigureComposer } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useEffect, useState } from 'react'; -import { GetAvatarRenderManager, GetConnection, GetFurnitureDataForRoomObject, GetSessionDataManager, LocalizeText } from '../../../../../../../api'; -import { FigureData } from '../../../../../../../components/avatar-editor/common/FigureData'; -import { FurniCategory } from '../../../../../../../components/inventory/common/FurniCategory'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../../layout'; -import { AvatarImageView } from '../../../../../../shared/avatar-image/AvatarImageView'; -import { useRoomContext } from '../../../../../context/RoomContext'; -import { PurchasableClothingConfirmViewProps } from './PurchasableClothingConfirmView.types'; +import { FC, useEffect, useState } from 'react'; +import { GetAvatarRenderManager, GetConnection, GetFurnitureDataForRoomObject, GetSessionDataManager, LocalizeText } from '../../../../../../api'; +import { Base, Button, Column, Flex, Text } from '../../../../../../common'; +import { FigureData } from '../../../../../../components/avatar-editor/common/FigureData'; +import { FurniCategory } from '../../../../../../components/inventory/common/FurniCategory'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; +import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; +import { useRoomContext } from '../../../../context/RoomContext'; + +interface PurchasableClothingConfirmViewProps +{ + objectId: number; + close: () => void; +} const MODE_DEFAULT: number = -1; const MODE_PURCHASABLE_CLOTHING: number = 0; @@ -19,13 +25,13 @@ export const PurchasableClothingConfirmView: FC(null); const { roomSession = null } = useRoomContext(); - const useProduct = useCallback(() => + const useProduct = () => { GetConnection().send(new RedeemItemClothingComposer(objectId)); GetConnection().send(new UserFigureComposer(gender, newFigure)); close(); - }, [ objectId, gender, newFigure, close ]); + } useEffect(() => { @@ -78,24 +84,24 @@ export const PurchasableClothingConfirmView: FC - -
-
-
+ + + + -
-
-
-
-
{ LocalizeText('useproduct.widget.text.bind_clothing') }
-
{ LocalizeText('useproduct.widget.info.bind_clothing') }
-
-
- - -
-
-
+ + + + + { LocalizeText('useproduct.widget.text.bind_clothing') } + { LocalizeText('useproduct.widget.info.bind_clothing') } + + + + + + +
); diff --git a/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.tsx deleted file mode 100644 index 09063d38..00000000 --- a/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../../../../../api'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../../layout'; -import { useRoomContext } from '../../../../../context/RoomContext'; -import { EffectBoxConfirmViewProps } from './EffectBoxConfirmView.types'; - -export const EffectBoxConfirmView: FC = props => -{ - const { objectId = -1, close = null } = props; - const { roomSession = null, widgetHandler = null } = useRoomContext(); - - const useProduct = useCallback(() => - { - roomSession.useMultistateItem(objectId); - - close(); - }, [ roomSession, objectId, close ]); - - return ( - - - -
-
-
-
{ LocalizeText('effectbox.header.description') }
-
-
- - -
-
-
-
-
- ); -} diff --git a/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.types.ts b/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.types.ts deleted file mode 100644 index 1a8655d9..00000000 --- a/src/views/room/widgets/furniture/context-menu/views/effect-box/EffectBoxConfirmView.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface EffectBoxConfirmViewProps -{ - objectId: number; - close: () => void; -} diff --git a/src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.types.ts b/src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.types.ts deleted file mode 100644 index 75fded04..00000000 --- a/src/views/room/widgets/furniture/context-menu/views/monsterplant-seed/MonsterPlantSeedConfirmView.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface MonsterPlantSeedConfirmViewProps -{ - objectId: number; - close: () => void; -} diff --git a/src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.types.ts b/src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.types.ts deleted file mode 100644 index f6f04211..00000000 --- a/src/views/room/widgets/furniture/context-menu/views/purchaseable-clothing/PurchasableClothingConfirmView.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface PurchasableClothingConfirmViewProps -{ - objectId: number; - close: () => void; -} From 34bfd96c4f5be26a5a4e35374aacfba1380368f8 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 25 Feb 2022 22:38:49 -0500 Subject: [PATCH 07/17] More widget updates --- .../widgets/furniture/FurnitureWidgets.scss | 52 ++++++++++- .../FurnitureBackgroundColorView.tsx | 2 +- .../FurnitureBadgeDisplayView.tsx | 2 +- .../{views => }/EffectBoxConfirmView.tsx | 8 +- .../context-menu/FurnitureContextMenuView.tsx | 6 +- .../MonsterPlantSeedConfirmView.tsx | 10 +- .../PurchasableClothingConfirmView.tsx | 14 +-- .../FurnitureCustomStackHeightView.scss | 4 - .../FurnitureCustomStackHeightView.tsx | 58 ++++++------ .../furniture/dimmer/FurnitureDimmerView.scss | 19 ---- .../FurnitureExchangeCreditView.scss | 10 -- .../FurnitureExchangeCreditView.tsx | 33 ++++--- .../FurnitureExternalImageView.scss | 7 -- .../FurnitureExternalImageView.tsx | 34 ++++--- .../FurnitureGiftOpeningView.scss | 3 - .../gift-opening/FurnitureGiftOpeningView.tsx | 91 ++++++++++--------- 16 files changed, 176 insertions(+), 177 deletions(-) rename src/views/room/widgets/furniture/context-menu/{views => }/EffectBoxConfirmView.tsx (85%) rename src/views/room/widgets/furniture/context-menu/{views => }/MonsterPlantSeedConfirmView.tsx (92%) rename src/views/room/widgets/furniture/context-menu/{views => }/PurchasableClothingConfirmView.tsx (90%) delete mode 100644 src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.scss delete mode 100644 src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss delete mode 100644 src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.scss delete mode 100644 src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.scss delete mode 100644 src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss diff --git a/src/views/room/widgets/furniture/FurnitureWidgets.scss b/src/views/room/widgets/furniture/FurnitureWidgets.scss index 55ebd35f..390c4e14 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgets.scss +++ b/src/views/room/widgets/furniture/FurnitureWidgets.scss @@ -2,15 +2,57 @@ pointer-events: none; } -@import './custom-stack-height/FurnitureCustomStackHeightView'; +.nitro-widget-custom-stack-height { + width: $nitro-widget-custom-stack-height-width; + height: $nitro-widget-custom-stack-height-height; +} + +.nitro-room-widget-dimmer { + width: 275px; + + .dimmer-banner { + width: 56px; + height: 79px; + background: url('../../../../assets/images/room-widgets/dimmer-widget/dimmer_banner.png') center no-repeat; + } + + .color-swatch { + height: 30px; + border: 2px solid $white; + box-shadow: inset 3px 3px rgba(0, 0, 0, .2); + + &.active { + box-shadow: none; + } + } +} + +.nitro-widget-exchange-credit { + width: $nitro-widget-exchange-credit-width; + height: $nitro-widget-exchange-credit-height; + + .exchange-image { + background-image: url('../../../../assets/images/room-widgets/exchange-credit/exchange-credit-image.png'); + width: 103px; + height: 103px; + } +} + +.nitro-external-image-widget { + + .picture-preview { + width: 320px; + height: 320px; + } +} + +.nitro-gift-opening { + +} -@import './dimmer/FurnitureDimmerView'; -@import './exchange-credit/FurnitureExchangeCreditView'; -@import './external-image/FurnitureExternalImageView'; @import './friend-furni/FurnitureFriendFurniView'; @import './manipulation-menu/FurnitureManipulationMenuView'; @import './mannequin/FurnitureMannequinView'; @import './stickie/FurnitureStickieView'; @import './high-score/FurnitureHighScoreView'; -@import './gift-opening/FurnitureGiftOpeningView'; @import './youtube-tv/FurnitureYoutubeDisplayView'; diff --git a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx index 576ac22b..d76b971a 100644 --- a/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx +++ b/src/views/room/widgets/furniture/background-color/FurnitureBackgroundColorView.tsx @@ -89,7 +89,7 @@ export const FurnitureBackgroundColorView: FC<{}> = props => return ( - + { LocalizeText('widget.backgroundcolor.hue') } diff --git a/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx b/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx index 9615bce6..f2398acd 100644 --- a/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx +++ b/src/views/room/widgets/furniture/badge-display/FurnitureBadgeDisplayView.tsx @@ -9,8 +9,8 @@ import { FurnitureTrophyData } from '../trophy/FurnitureTrophyData'; export const FurnitureBadgeDisplayView: FC<{}> = props => { - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ trophyData, setTrophyData ] = useState(null); + const { widgetHandler = null } = useRoomContext(); const onNitroEvent = useCallback((event: NitroEvent) => { diff --git a/src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/EffectBoxConfirmView.tsx similarity index 85% rename from src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx rename to src/views/room/widgets/furniture/context-menu/EffectBoxConfirmView.tsx index 0732c592..ed12a5e4 100644 --- a/src/views/room/widgets/furniture/context-menu/views/EffectBoxConfirmView.tsx +++ b/src/views/room/widgets/furniture/context-menu/EffectBoxConfirmView.tsx @@ -1,8 +1,8 @@ import { FC } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { Button, Column, Flex, Text } from '../../../../../../common'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; -import { useRoomContext } from '../../../../context/RoomContext'; +import { LocalizeText } from '../../../../../api'; +import { Button, Column, Flex, Text } from '../../../../../common'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; +import { useRoomContext } from '../../../context/RoomContext'; interface EffectBoxConfirmViewProps { diff --git a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx index c8b836fd..e018d0ce 100644 --- a/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx +++ b/src/views/room/widgets/furniture/context-menu/FurnitureContextMenuView.tsx @@ -9,9 +9,9 @@ import { useRoomContext } from '../../../context/RoomContext'; import { ContextMenuView } from '../../context-menu/ContextMenuView'; import { ContextMenuHeaderView } from '../../context-menu/views/header/ContextMenuHeaderView'; import { ContextMenuListItemView } from '../../context-menu/views/list-item/ContextMenuListItemView'; -import { EffectBoxConfirmView } from './views/EffectBoxConfirmView'; -import { MonsterPlantSeedConfirmView } from './views/MonsterPlantSeedConfirmView'; -import { PurchasableClothingConfirmView } from './views/PurchasableClothingConfirmView'; +import { EffectBoxConfirmView } from './EffectBoxConfirmView'; +import { MonsterPlantSeedConfirmView } from './MonsterPlantSeedConfirmView'; +import { PurchasableClothingConfirmView } from './PurchasableClothingConfirmView'; const MONSTERPLANT_SEED_CONFIRMATION: string = 'MONSTERPLANT_SEED_CONFIRMATION'; const PURCHASABLE_CLOTHING_CONFIRMATION: string = 'PURCHASABLE_CLOTHING_CONFIRMATION'; diff --git a/src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/MonsterPlantSeedConfirmView.tsx similarity index 92% rename from src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx rename to src/views/room/widgets/furniture/context-menu/MonsterPlantSeedConfirmView.tsx index f6bc99eb..0744f514 100644 --- a/src/views/room/widgets/furniture/context-menu/views/MonsterPlantSeedConfirmView.tsx +++ b/src/views/room/widgets/furniture/context-menu/MonsterPlantSeedConfirmView.tsx @@ -1,10 +1,10 @@ import { IFurnitureData, RoomObjectCategory } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { GetFurnitureDataForRoomObject, LocalizeText, RoomWidgetUseProductMessage } from '../../../../../../api'; -import { Base, Button, Column, Flex, Text } from '../../../../../../common'; -import { FurniCategory } from '../../../../../../components/inventory/common/FurniCategory'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; -import { useRoomContext } from '../../../../context/RoomContext'; +import { GetFurnitureDataForRoomObject, LocalizeText, RoomWidgetUseProductMessage } from '../../../../../api'; +import { Base, Button, Column, Flex, Text } from '../../../../../common'; +import { FurniCategory } from '../../../../../components/inventory/common/FurniCategory'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; +import { useRoomContext } from '../../../context/RoomContext'; interface MonsterPlantSeedConfirmViewProps { diff --git a/src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx b/src/views/room/widgets/furniture/context-menu/PurchasableClothingConfirmView.tsx similarity index 90% rename from src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx rename to src/views/room/widgets/furniture/context-menu/PurchasableClothingConfirmView.tsx index fb673709..aa122d03 100644 --- a/src/views/room/widgets/furniture/context-menu/views/PurchasableClothingConfirmView.tsx +++ b/src/views/room/widgets/furniture/context-menu/PurchasableClothingConfirmView.tsx @@ -1,12 +1,12 @@ import { RedeemItemClothingComposer, RoomObjectCategory, UserFigureComposer } from '@nitrots/nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { GetAvatarRenderManager, GetConnection, GetFurnitureDataForRoomObject, GetSessionDataManager, LocalizeText } from '../../../../../../api'; -import { Base, Button, Column, Flex, Text } from '../../../../../../common'; -import { FigureData } from '../../../../../../components/avatar-editor/common/FigureData'; -import { FurniCategory } from '../../../../../../components/inventory/common/FurniCategory'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../../layout'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { useRoomContext } from '../../../../context/RoomContext'; +import { GetAvatarRenderManager, GetConnection, GetFurnitureDataForRoomObject, GetSessionDataManager, LocalizeText } from '../../../../../api'; +import { Base, Button, Column, Flex, Text } from '../../../../../common'; +import { FigureData } from '../../../../../components/avatar-editor/common/FigureData'; +import { FurniCategory } from '../../../../../components/inventory/common/FurniCategory'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; +import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; +import { useRoomContext } from '../../../context/RoomContext'; interface PurchasableClothingConfirmViewProps { diff --git a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.scss b/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.scss deleted file mode 100644 index 755c73d1..00000000 --- a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.scss +++ /dev/null @@ -1,4 +0,0 @@ -.nitro-widget-custom-stack-height { - width: $nitro-widget-custom-stack-height-width; - height: $nitro-widget-custom-stack-height-height; -} diff --git a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx b/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx index 0b7c7ee1..0b864967 100644 --- a/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx +++ b/src/views/room/widgets/furniture/custom-stack-height/FurnitureCustomStackHeightView.tsx @@ -2,10 +2,10 @@ import { FurnitureStackHeightComposer, FurnitureStackHeightEvent } from '@nitrot import { FC, useCallback, useEffect, useState } from 'react'; import ReactSlider from 'react-slider'; import { LocalizeText, RoomWidgetUpdateCustomStackHeightEvent } from '../../../../../api'; +import { Button, Column, Flex, Text } from '../../../../../common'; import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../../hooks'; import { CreateEventDispatcherHook } from '../../../../../hooks/events'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutButton, NitroLayoutFlex, NitroLayoutFlexColumn, NitroLayoutGrid, NitroLayoutGridColumn } from '../../../../../layout'; -import { NitroLayoutBase } from '../../../../../layout/base'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; import { useRoomContext } from '../../../context/RoomContext'; const MAX_HEIGHT: number = 40; @@ -17,14 +17,14 @@ export const FurnitureCustomStackHeightView: FC<{}> = props => const [ pendingHeight, setPendingHeight ] = useState(-1); const { eventDispatcher = null } = useRoomContext(); - const close = useCallback(() => + const close = () => { BatchUpdates(() => { setObjectId(-1); setHeight(0); }); - }, []); + } const updateHeight = useCallback((height: number, fromServer: boolean = false) => { @@ -83,35 +83,29 @@ export const FurnitureCustomStackHeightView: FC<{}> = props => if(objectId === -1) return null; return ( - + - - - - - { LocalizeText('widget.custom.stack.height.text') } - - - - updateHeight(event) } - renderThumb={ (props, state) =>
{ state.valueNow }
} /> - updateHeight(parseFloat(event.target.value)) } /> -
- sendUpdate(-100) }> - { LocalizeText('furniture.above.stack') } - - sendUpdate(0) }> - { LocalizeText('furniture.floor.level') } - -
-
-
+ + { LocalizeText('widget.custom.stack.height.text') } + + updateHeight(event) } + renderThumb={ (props, state) =>
{ state.valueNow }
} /> + updateHeight(parseFloat(event.target.value)) } /> +
+ + + +
); diff --git a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss b/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss deleted file mode 100644 index a83b0fe6..00000000 --- a/src/views/room/widgets/furniture/dimmer/FurnitureDimmerView.scss +++ /dev/null @@ -1,19 +0,0 @@ -.nitro-room-widget-dimmer { - width: 275px; - - .dimmer-banner { - width: 56px; - height: 79px; - background: url('../../../../../assets/images/room-widgets/dimmer-widget/dimmer_banner.png') center no-repeat; - } - - .color-swatch { - height: 30px; - border: 2px solid $white; - box-shadow: inset 3px 3px rgba(0, 0, 0, .2); - - &.active { - box-shadow: none; - } - } -} diff --git a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.scss b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.scss deleted file mode 100644 index 4c286c5e..00000000 --- a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.scss +++ /dev/null @@ -1,10 +0,0 @@ -.nitro-widget-exchange-credit { - width: $nitro-widget-exchange-credit-width; - height: $nitro-widget-exchange-credit-height; - - .exchange-image { - background-image: url('../../../../../assets/images/room-widgets/exchange-credit/exchange-credit-image.png'); - width: 103px; - height: 103px; - } -} diff --git a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx index 81d7ed79..1c9295d9 100644 --- a/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx +++ b/src/views/room/widgets/furniture/exchange-credit/FurnitureExchangeCreditView.tsx @@ -1,10 +1,6 @@ import { FC, useCallback, useState } from 'react'; import { LocalizeText, RoomWidgetCreditFurniRedeemMessage, RoomWidgetUpdateCreditFurniEvent } from '../../../../../api'; -import { Base } from '../../../../../common/Base'; -import { Button } from '../../../../../common/Button'; -import { Column } from '../../../../../common/Column'; -import { Grid } from '../../../../../common/Grid'; -import { Text } from '../../../../../common/Text'; +import { Base, Button, Column, Flex, Text } from '../../../../../common'; import { BatchUpdates } from '../../../../../hooks'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; @@ -18,39 +14,42 @@ export const FurnitureExchangeCreditView: FC<{}> = props => const onRoomWidgetUpdateCreditFurniEvent = useCallback((event: RoomWidgetUpdateCreditFurniEvent) => { - setObjectId(event.objectId); - setValue(event.value); + BatchUpdates(() => + { + setObjectId(event.objectId); + setValue(event.value); + }); }, []); CreateEventDispatcherHook(RoomWidgetUpdateCreditFurniEvent.CREDIT_FURNI_UPDATE, eventDispatcher, onRoomWidgetUpdateCreditFurniEvent); - const close = useCallback(() => + const close = () => { BatchUpdates(() => { setObjectId(-1); setValue(0); }); - }, []); + } - const redeem = useCallback(() => + const redeem = () => { widgetHandler.processWidgetMessage(new RoomWidgetCreditFurniRedeemMessage(RoomWidgetCreditFurniRedeemMessage.REDEEM, objectId)); close(); - }, [ widgetHandler, objectId, close ]); + } if(objectId === -1) return null; return ( - + - - - + + + - + { LocalizeText('creditfurni.description', [ 'credits' ], [ value.toString() ]) } { LocalizeText('creditfurni.prompt') } @@ -59,7 +58,7 @@ export const FurnitureExchangeCreditView: FC<{}> = props => { LocalizeText('catalog.redeem.dialog.button.exchange') } - + ); diff --git a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.scss b/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.scss deleted file mode 100644 index 4e39e9d0..00000000 --- a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.scss +++ /dev/null @@ -1,7 +0,0 @@ -.nitro-external-image-widget { - - .picture-preview { - width: 320px; - height: 320px; - } -} diff --git a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx b/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx index 0729d563..7b6f576b 100644 --- a/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx +++ b/src/views/room/widgets/furniture/external-image/FurnitureExternalImageView.tsx @@ -1,6 +1,7 @@ import { FC, useCallback, useState } from 'react'; import { IPhotoData, LocalizeText, RoomWidgetUpdateExternalImageEvent } from '../../../../../api'; -import { CreateEventDispatcherHook } from '../../../../../hooks'; +import { Flex, Text } from '../../../../../common'; +import { BatchUpdates, CreateEventDispatcherHook } from '../../../../../hooks'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; import { useRoomContext } from '../../../context/RoomContext'; @@ -10,19 +11,23 @@ export const FurnitureExternalImageView: FC<{}> = props => const [ photoData, setPhotoData ] = useState(null); const { eventDispatcher = null } = useRoomContext(); - const close = useCallback(() => + const close = () => { setObjectId(-1); setPhotoData(null) - }, []); + } const onRoomWidgetUpdateExternalImageEvent = useCallback((event: RoomWidgetUpdateExternalImageEvent) => { switch(event.type) { case RoomWidgetUpdateExternalImageEvent.UPDATE_EXTERNAL_IMAGE: { - setObjectId(event.objectId); - setPhotoData(event.photoData); + + BatchUpdates(() => + { + setObjectId(event.objectId); + setPhotoData(event.photoData); + }); } } }, []); @@ -35,17 +40,16 @@ export const FurnitureExternalImageView: FC<{}> = props => -
+ { !photoData.w && -
- { LocalizeText('camera.loading') } -
} -
- { photoData.m &&
{ photoData.m }
}
-
- { (photoData.n || '') } - { new Date(photoData.t * 1000).toLocaleDateString() } -
+ { LocalizeText('camera.loading') } } + + { photoData.m && photoData.m.length && + { photoData.m } } + + { (photoData.n || '') } + { new Date(photoData.t * 1000).toLocaleDateString() } +
); diff --git a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss deleted file mode 100644 index 9719609c..00000000 --- a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.scss +++ /dev/null @@ -1,3 +0,0 @@ -.nitro-gift-opening { - min-width: 340px; -} diff --git a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx index 3ded35e9..c76b9112 100644 --- a/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx +++ b/src/views/room/widgets/furniture/gift-opening/FurnitureGiftOpeningView.tsx @@ -1,11 +1,11 @@ import { RoomObjectCategory, RoomObjectOperationType } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useMemo, useState } from 'react'; +import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { CreateLinkEvent, GetRoomEngine, GetSessionDataManager, LocalizeText, RoomWidgetPresentOpenMessage, RoomWidgetUpdatePresentDataEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../../api'; +import { Button, Column, Flex, Text } from '../../../../../common'; import { ProductTypeEnum } from '../../../../../components/catalog/common/ProductTypeEnum'; import { BatchUpdates } from '../../../../../hooks'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; -import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutButton, NitroLayoutFlex, NitroLayoutFlexColumn, NitroLayoutGiftCardView, NitroLayoutGrid, NitroLayoutGridColumn } from '../../../../../layout'; -import { NitroLayoutBase } from '../../../../../layout/base'; +import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutGiftCardView } from '../../../../../layout'; import { useRoomContext } from '../../../context/RoomContext'; const FLOOR: string = 'floor'; @@ -33,6 +33,11 @@ export const FurnitureGiftOpeningView: FC<{}> = props => const [ openRequested, setOpenRequested ] = useState(false); const { roomSession = null, eventDispatcher = null, widgetHandler = null } = useRoomContext(); + useEffect(() => + { + console.log(imageUrl); + }, [ imageUrl ]); + const clearGift = useCallback(() => { if(!openRequested) setObjectId(-1); @@ -48,6 +53,7 @@ export const FurnitureGiftOpeningView: FC<{}> = props => const onRoomWidgetUpdatePresentDataEvent = useCallback((event: RoomWidgetUpdatePresentDataEvent) => { + console.log(event.imageUrl, event.type); switch(event.type) { case RoomWidgetUpdatePresentDataEvent.PACKAGEINFO: { @@ -111,6 +117,7 @@ export const FurnitureGiftOpeningView: FC<{}> = props => setPlacedItemId(event.placedItemId); setPlacedItemType(event.placedItemType); setPlacedInRoom(event.placedInRoom); + setImageUrl(event.imageUrl); }); return; } @@ -215,47 +222,43 @@ export const FurnitureGiftOpeningView: FC<{}> = props => return ( - - - { (placedItemId === -1) && - - - - - - { senderName && - handleAction(ACTION_GIVE_GIFT) }> - { LocalizeText('widget.furni.present.give_gift', [ 'name' ], [ senderName ]) } - } - handleAction(ACTION_OPEN) }> - { LocalizeText('widget.furni.present.open_gift') } - - - } - { (placedItemId > -1) && - - - - - { LocalizeText(productName, [ 'product' ], [ text ]) } - - - - - handleAction(ACTION_INVENTORY) }> - { LocalizeText('widget.furni.present.put_in_inventory') } - - handleAction(ACTION_PLACE) }> - { LocalizeText(placedInRoom ? 'widget.furni.present.keep_in_room' : 'widget.furni.present.place_in_room') } - - - { (senderName && senderName.length) && - handleAction(ACTION_GIVE_GIFT) }> - { LocalizeText('widget.furni.present.give_gift', [ 'name' ], [ senderName ]) } - } - - } - + + { (placedItemId === -1) && + + + + + + { senderName && + } + + + } + { (placedItemId > -1) && + + + + { LocalizeText(productName, [ 'product' ], [ text ]) } + + + + + + + { (senderName && senderName.length) && + } + + } ); From 06bc3f238e324de6a1e6732ca55327fcc578d902 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 26 Feb 2022 00:23:11 -0500 Subject: [PATCH 08/17] More widget updates --- src/views/room/widgets/RoomWidgets.scss | 99 +++++++++++++- .../avatar-info/AvatarInfoWidgetView.scss | 10 -- .../widgets/furniture/FurnitureWidgets.scss | 14 +- .../FurnitureMannequinPreviewView.tsx | 23 ++++ .../mannequin/FurnitureMannequinView.scss | 9 -- .../mannequin/FurnitureMannequinView.tsx | 62 +++++---- .../preview/FurnitureMannequinPreviewView.tsx | 17 --- .../FurnitureMannequinPreviewView.types.ts | 5 - .../object-location/ObjectLocationView.scss | 2 - .../object-location/ObjectLocationView.tsx | 18 +-- .../ObjectLocationView.types.ts | 8 -- .../room-tools/RoomToolsWidgetView.scss | 55 -------- .../room-tools/RoomToolsWidgetView.tsx | 45 ++++--- .../user-location/UserLocationView.tsx | 7 +- .../user-location/UserLocationView.types.ts | 6 - .../word-quiz/WordQuizQuestionView.tsx | 44 ++++++ .../widgets/word-quiz/WordQuizVoteView.tsx | 24 ++++ .../widgets/word-quiz/WordQuizWidgetView.scss | 39 ------ .../widgets/word-quiz/WordQuizWidgetView.tsx | 126 +++++++++--------- .../word-quiz/views/question/QuestionView.tsx | 24 ---- .../views/question/QuestionView.types.ts | 9 -- .../widgets/word-quiz/views/vote/VoteView.tsx | 16 --- .../word-quiz/views/vote/VoteView.types.ts | 5 - 23 files changed, 346 insertions(+), 321 deletions(-) create mode 100644 src/views/room/widgets/furniture/mannequin/FurnitureMannequinPreviewView.tsx delete mode 100644 src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.scss delete mode 100644 src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.tsx delete mode 100644 src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.types.ts delete mode 100644 src/views/room/widgets/object-location/ObjectLocationView.scss delete mode 100644 src/views/room/widgets/object-location/ObjectLocationView.types.ts delete mode 100644 src/views/room/widgets/room-tools/RoomToolsWidgetView.scss delete mode 100644 src/views/room/widgets/user-location/UserLocationView.types.ts create mode 100644 src/views/room/widgets/word-quiz/WordQuizQuestionView.tsx create mode 100644 src/views/room/widgets/word-quiz/WordQuizVoteView.tsx delete mode 100644 src/views/room/widgets/word-quiz/WordQuizWidgetView.scss delete mode 100644 src/views/room/widgets/word-quiz/views/question/QuestionView.tsx delete mode 100644 src/views/room/widgets/word-quiz/views/question/QuestionView.types.ts delete mode 100644 src/views/room/widgets/word-quiz/views/vote/VoteView.tsx delete mode 100644 src/views/room/widgets/word-quiz/views/vote/VoteView.types.ts diff --git a/src/views/room/widgets/RoomWidgets.scss b/src/views/room/widgets/RoomWidgets.scss index a2f114d6..03b34a57 100644 --- a/src/views/room/widgets/RoomWidgets.scss +++ b/src/views/room/widgets/RoomWidgets.scss @@ -1,3 +1,99 @@ +.nitro-room-tools-container { + position: absolute; + bottom: $toolbar-height + 65px; + left: 0; + + .nitro-room-tools { + background: rgba($dark,.95); + box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); + border-top-right-radius: $border-radius; + border-bottom-right-radius: $border-radius; + transition: all .2s ease; + z-index: 2; + + .list-group-item { + background: transparent; + padding: 3px 0px; + color: $white; + border-color: rgba($black, 0.3); + cursor: pointer; + + &:hover { + text-decoration: underline; + } + + &:first-child { + padding-top: 8px; + } + + &:last-child { + border-bottom: none; + padding-bottom: 8px; + } + + .tools-item { + .icon { + width: 22px; + background-repeat: no-repeat; + background-position: center; + } + + &:hover { + text-decoration: underline; + } + } + } + } + + .nitro-room-tools-info { + background: rgba($dark,.95); + box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); + transition: all .2s ease; + pointer-events: none; + max-width: 250px; + } +} + +.wordquiz-question { + position: absolute; + top: 10px; + left: 50%; + transform: translateX(-50%); + font-size: large; + background: rgba($dark, 0.95); + box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); + border-radius: $border-radius; + transition: all 0.2s ease; + + .question { + max-width: 300px; + } +} + +.word-quiz-dislike { + background: url("../../../assets/images/room-widgets/wordquiz-widget/thumbs-down.png"); + width: 31px; + height: 34px; +} + +.word-quiz-like { + background: url("../../../assets/images/room-widgets/wordquiz-widget/thumbs-up.png"); + width: 31px; + height: 34px; +} + +.word-quiz-dislike-sm { + background: url("../../../assets/images/room-widgets/wordquiz-widget/thumbs-down-small.png"); + width: 22px; + height: 22px; +} + +.word-quiz-like-sm { + background: url("../../../assets/images/room-widgets/wordquiz-widget/thumbs-up-small.png"); + height: 22px; + width: 22px; +} + @import './avatar-info/AvatarInfoWidgetView'; @import './chat/ChatWidgetView'; @import './chat-input/ChatInputView'; @@ -6,6 +102,3 @@ @import './friend-request/FriendRequestDialogView'; @import './furniture/FurnitureWidgets'; @import './infostand/InfoStandWidgetView'; -@import './object-location/ObjectLocationView'; -@import './room-tools/RoomToolsWidgetView'; -@import './word-quiz/WordQuizWidgetView'; diff --git a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.scss b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.scss index df009b29..737bf54c 100644 --- a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.scss +++ b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.scss @@ -20,14 +20,4 @@ background: url('../../../../assets/images/room-widgets/furni-context-menu/monsterplant-preview.png') no-repeat center; } } - - .mannequin-preview { - display: flex; - justify-content: center; - align-items: center; - width: 83px; - height: 130px; - background-image: url('../../../../assets/images/room-widgets/mannequin-widget/mannequin-spritesheet.png'); - overflow: hidden; - } } diff --git a/src/views/room/widgets/furniture/FurnitureWidgets.scss b/src/views/room/widgets/furniture/FurnitureWidgets.scss index 390c4e14..425d02fa 100644 --- a/src/views/room/widgets/furniture/FurnitureWidgets.scss +++ b/src/views/room/widgets/furniture/FurnitureWidgets.scss @@ -50,9 +50,21 @@ } +.nitro-mannequin { +} + +.mannequin-preview { + display: flex; + justify-content: center; + align-items: center; + width: 83px; + height: 130px; + background-image: url('../../../../assets/images/room-widgets/mannequin-widget/mannequin-spritesheet.png'); + overflow: hidden; +} + @import './friend-furni/FurnitureFriendFurniView'; @import './manipulation-menu/FurnitureManipulationMenuView'; -@import './mannequin/FurnitureMannequinView'; @import './stickie/FurnitureStickieView'; @import './high-score/FurnitureHighScoreView'; @import './youtube-tv/FurnitureYoutubeDisplayView'; diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinPreviewView.tsx b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinPreviewView.tsx new file mode 100644 index 00000000..a0f6dba2 --- /dev/null +++ b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinPreviewView.tsx @@ -0,0 +1,23 @@ +import { FC } from 'react'; +import { Base } from '../../../../../common'; +import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; +import { CurrencyIcon } from '../../../../shared/currency-icon/CurrencyIcon'; + +interface FurnitureMannequinPreviewViewProps +{ + figure: string; + clubLevel: number; +} + +export const FurnitureMannequinPreviewView: FC = props => +{ + const { figure = null, clubLevel = 0 } = props; + + return ( + + + { (clubLevel > 0) && + } + + ); +} diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.scss b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.scss deleted file mode 100644 index cc16ce4c..00000000 --- a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.scss +++ /dev/null @@ -1,9 +0,0 @@ -.nitro-mannequin { - width: 350px; - - .mannequin-preview { - width: 83px; - height: 130px; - background-image: url('../../../../../assets/images/room-widgets/mannequin-widget/mannequin-spritesheet.png'); - } -} diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx index da7848c2..c7591e33 100644 --- a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx +++ b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx @@ -1,16 +1,17 @@ import { AvatarFigurePartType, FurnitureMannequinSaveLookComposer, FurnitureMannequinSaveNameComposer, FurnitureMultiStateComposer, HabboClubLevelEnum, IAvatarFigureContainer, RoomControllerLevel } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useState } from 'react'; import { GetAvatarRenderManager, GetSessionDataManager, LocalizeText, RoomWidgetUpdateMannequinEvent } from '../../../../../api'; +import { Base } from '../../../../../common'; import { Button } from '../../../../../common/Button'; import { Column } from '../../../../../common/Column'; import { Flex } from '../../../../../common/Flex'; -import { Grid } from '../../../../../common/Grid'; import { Text } from '../../../../../common/Text'; import { BatchUpdates, SendMessageHook } from '../../../../../hooks'; import { CreateEventDispatcherHook } from '../../../../../hooks/events/event-dispatcher.base'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; +import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; +import { CurrencyIcon } from '../../../../shared/currency-icon/CurrencyIcon'; import { useRoomContext } from '../../../context/RoomContext'; -import { FurnitureMannequinPreviewView } from './views/preview/FurnitureMannequinPreviewView'; const MODE_NONE: number = -1; const MODE_CONTROLLER: number = 0; @@ -143,8 +144,11 @@ export const FurnitureMannequinView: FC<{}> = props => transformAsMannequinFigure(figureContainer); - setRenderedFigure(figureContainer.getFigureString()); - setRenderedClubLevel(clubLevel); + BatchUpdates(() => + { + setRenderedFigure(figureContainer.getFigureString()); + setRenderedClubLevel(clubLevel); + }); break; } case MODE_UPDATE: { @@ -152,16 +156,22 @@ export const FurnitureMannequinView: FC<{}> = props => transformAsMannequinFigure(figureContainer); - setRenderedFigure(figureContainer.getFigureString()); - setRenderedClubLevel(GetAvatarRenderManager().getFigureClubLevel(figureContainer, GetSessionDataManager().gender, MANNEQUIN_CLOTHING_PART_TYPES)); + BatchUpdates(() => + { + setRenderedFigure(figureContainer.getFigureString()); + setRenderedClubLevel(GetAvatarRenderManager().getFigureClubLevel(figureContainer, GetSessionDataManager().gender, MANNEQUIN_CLOTHING_PART_TYPES)); + }); break; } case MODE_PEER: case MODE_NO_CLUB: { const figureContainer = getMergedFigureContainer(GetSessionDataManager().figure, figure); - setRenderedFigure(figureContainer.getFigureString()); - setRenderedClubLevel(clubLevel); + BatchUpdates(() => + { + setRenderedFigure(figureContainer.getFigureString()); + setRenderedClubLevel(clubLevel); + }); break; } } @@ -170,18 +180,22 @@ export const FurnitureMannequinView: FC<{}> = props => if(mode === MODE_NONE) return null; return ( - + setMode(MODE_NONE) } /> - - - - + + + + + + { (clubLevel > 0) && + } + - + { (mode === MODE_CONTROLLER) && <> setName(event.target.value) } onKeyDown={ event => handleKeyDown(event) } /> - + @@ -192,9 +206,9 @@ export const FurnitureMannequinView: FC<{}> = props => } { (mode === MODE_UPDATE) && <> - - { name } - { LocalizeText('mannequin.widget.savetext') } + + { name } + { LocalizeText('mannequin.widget.savetext') } setMode(MODE_CONTROLLER) }> @@ -207,18 +221,20 @@ export const FurnitureMannequinView: FC<{}> = props => } { (mode === MODE_PEER) && <> - - { name } + + { name } { LocalizeText('mannequin.widget.weartext') } } - { (mode === MODE_NO_CLUB) && { LocalizeText('mannequin.widget.clubnotification') } } - { (mode === MODE_WRONG_GENDER) && { LocalizeText('mannequin.widget.wronggender') } } + { (mode === MODE_NO_CLUB) && + { LocalizeText('mannequin.widget.clubnotification') } } + { (mode === MODE_WRONG_GENDER) && + { LocalizeText('mannequin.widget.wronggender') } } - + ); diff --git a/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.tsx b/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.tsx deleted file mode 100644 index 194700df..00000000 --- a/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { FC } from 'react'; -import { NitroLayoutBase } from '../../../../../../../layout/base'; -import { AvatarImageView } from '../../../../../../shared/avatar-image/AvatarImageView'; -import { CurrencyIcon } from '../../../../../../shared/currency-icon/CurrencyIcon'; -import { FurnitureMannequinPreviewViewProps } from './FurnitureMannequinPreviewView.types'; - -export const FurnitureMannequinPreviewView: FC = props => -{ - const { figure = null, clubLevel = 0 } = props; - - return ( - - - { (clubLevel > 0) && } - - ); -} diff --git a/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.types.ts b/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.types.ts deleted file mode 100644 index 1a5ee3fe..00000000 --- a/src/views/room/widgets/furniture/mannequin/views/preview/FurnitureMannequinPreviewView.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface FurnitureMannequinPreviewViewProps -{ - figure: string; - clubLevel: number; -} diff --git a/src/views/room/widgets/object-location/ObjectLocationView.scss b/src/views/room/widgets/object-location/ObjectLocationView.scss deleted file mode 100644 index ab82f870..00000000 --- a/src/views/room/widgets/object-location/ObjectLocationView.scss +++ /dev/null @@ -1,2 +0,0 @@ -.object-location { -} diff --git a/src/views/room/widgets/object-location/ObjectLocationView.tsx b/src/views/room/widgets/object-location/ObjectLocationView.tsx index c7df0d2a..d28d2a4e 100644 --- a/src/views/room/widgets/object-location/ObjectLocationView.tsx +++ b/src/views/room/widgets/object-location/ObjectLocationView.tsx @@ -1,11 +1,17 @@ import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { GetNitroInstance, GetRoomEngine, GetRoomSession } from '../../../../api'; -import { NitroLayoutBase } from '../../../../layout/base'; -import { ObjectLocationViewProps } from './ObjectLocationView.types'; +import { Base, BaseProps } from '../../../../common'; + +interface ObjectLocationViewProps extends BaseProps +{ + objectId: number; + category: number; + noFollow?: boolean; +} export const ObjectLocationView: FC = props => { - const { objectId = -1, category = -1, noFollow = false, children = null, ...rest } = props; + const { objectId = -1, category = -1, noFollow = false, position = 'absolute', ...rest } = props; const [ pos, setPos ] = useState<{ x: number, y: number }>({ x: -1, y: -1 }); const elementRef = useRef(); @@ -50,9 +56,5 @@ export const ObjectLocationView: FC = props => } }, [ updatePosition, noFollow ]); - return ( - -1 ? 'visible' : 'invisible') } style={ { left: pos.x, top: pos.y } } { ...rest }> - { children } - - ); + return -1 } className="object-location" style={ { left: pos.x, top: pos.y } } { ...rest } />; } diff --git a/src/views/room/widgets/object-location/ObjectLocationView.types.ts b/src/views/room/widgets/object-location/ObjectLocationView.types.ts deleted file mode 100644 index 0da23b4b..00000000 --- a/src/views/room/widgets/object-location/ObjectLocationView.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { NitroLayoutBaseProps } from '../../../../layout/base'; - -export interface ObjectLocationViewProps extends NitroLayoutBaseProps -{ - objectId: number; - category: number; - noFollow?: boolean; -} diff --git a/src/views/room/widgets/room-tools/RoomToolsWidgetView.scss b/src/views/room/widgets/room-tools/RoomToolsWidgetView.scss deleted file mode 100644 index fe081425..00000000 --- a/src/views/room/widgets/room-tools/RoomToolsWidgetView.scss +++ /dev/null @@ -1,55 +0,0 @@ -.nitro-room-tools-container { - position: absolute; - bottom: $toolbar-height + 65px; - left: 0; - - .nitro-room-tools { - background: rgba($dark,.95); - box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); - border-top-right-radius: $border-radius; - border-bottom-right-radius: $border-radius; - transition: all .2s ease; - - .list-group-item { - background: transparent; - padding: 3px 0px; - color: $white; - border-color: rgba($black, 0.3); - cursor: pointer; - - &:hover { - text-decoration: underline; - } - - &:first-child { - padding-top: 8px; - } - - &:last-child { - border-bottom: none; - padding-bottom: 8px; - } - - .tools-item { - .icon { - width: 22px; - background-repeat: no-repeat; - background-position: center; - } - - &:hover { - text-decoration: underline; - } - } - } - } - - .nitro-room-tools-info { - margin-left: 10px; - background: rgba($dark,.95); - box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); - transition: all .2s ease; - pointer-events: none; - max-width: 250px; - } -} diff --git a/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx b/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx index 6bf17ef8..19ca05c0 100644 --- a/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx +++ b/src/views/room/widgets/room-tools/RoomToolsWidgetView.tsx @@ -4,8 +4,10 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { CreateLinkEvent, LocalizeText, RoomWidgetZoomToggleMessage } from '../../../../api'; import { Base, Column, Flex, Text } from '../../../../common'; import { NavigatorEvent } from '../../../../events'; +import { BatchUpdates } from '../../../../hooks'; import { dispatchUiEvent } from '../../../../hooks/events'; import { CreateMessageHook, SendMessageHook } from '../../../../hooks/messages'; +import { TransitionAnimation, TransitionAnimationTypes } from '../../../../layout'; import { useRoomContext } from '../../context/RoomContext'; export const RoomToolsWidgetView: FC<{}> = props => @@ -13,14 +15,13 @@ export const RoomToolsWidgetView: FC<{}> = props => const [ isZoomedIn, setIsZoomedIn ] = useState(false); const [ isLiked, setIsLiked ] = useState(false); const { widgetHandler = null } = useRoomContext(); - const [ roomName, setRoomName ] = useState(null); const [ roomOwner, setRoomOwner ] = useState(null); const [ roomTags, setRoomTags ] = useState(null); const [ roomInfoDisplay, setRoomInfoDisplay ] = useState(false); const [ isOpen, setIsOpen ] = useState(false); - const handleToolClick = useCallback((action: string) => + const handleToolClick = (action: string) => { switch(action) { @@ -44,17 +45,18 @@ export const RoomToolsWidgetView: FC<{}> = props => dispatchUiEvent(new NavigatorEvent(NavigatorEvent.TOGGLE_ROOM_LINK)); return; } - }, [ isZoomedIn, isLiked, widgetHandler ]); + } const onGetGuestRoomResultEvent = useCallback((event: GetGuestRoomResultEvent) => { const parser = event.getParser(); - if(roomName !== parser.data.roomName) setRoomName(parser.data.roomName); - - if(roomOwner !== parser.data.ownerName) setRoomOwner(parser.data.ownerName); - - if(roomTags !== parser.data.tags) setRoomTags(parser.data.tags); + BatchUpdates(() => + { + if(roomName !== parser.data.roomName) setRoomName(parser.data.roomName); + if(roomOwner !== parser.data.ownerName) setRoomOwner(parser.data.ownerName); + if(roomTags !== parser.data.tags) setRoomTags(parser.data.tags); + }); }, [ roomName, roomOwner, roomTags ]); CreateMessageHook(GetGuestRoomResultEvent, onGetGuestRoomResultEvent); @@ -69,26 +71,29 @@ export const RoomToolsWidgetView: FC<{}> = props => }, [ roomName, roomOwner, roomTags ]); return ( - + handleToolClick('settings') } /> handleToolClick('zoom') } className={ 'icon ' + classNames({ 'icon-zoom-less': !isZoomedIn, 'icon-zoom-more': isZoomedIn }) } /> handleToolClick('chat_history') } className="icon icon-chat-history" /> { !isLiked && handleToolClick('like_room') } className="icon icon-like-room" /> } - { isOpen && - - - - { roomName } - { roomOwner } + + + + + + { roomName } + { roomOwner } + + { roomTags && roomTags.length > 0 && + + { roomTags.map((tag: string) => #{ tag }) } + } - { roomTags && roomTags.length > 0 && -
- { roomTags.map((tag: string) =>
#{ tag }
) } -
}
-
} + +
); } diff --git a/src/views/room/widgets/user-location/UserLocationView.tsx b/src/views/room/widgets/user-location/UserLocationView.tsx index c8dd2364..61c1cb49 100644 --- a/src/views/room/widgets/user-location/UserLocationView.tsx +++ b/src/views/room/widgets/user-location/UserLocationView.tsx @@ -1,8 +1,13 @@ import { RoomObjectCategory } from '@nitrots/nitro-renderer'; import { FC } from 'react'; +import { BaseProps } from '../../../../common'; import { useRoomContext } from '../../context/RoomContext'; import { ObjectLocationView } from '../object-location/ObjectLocationView'; -import { UserLocationViewProps } from './UserLocationView.types'; + +interface UserLocationViewProps extends BaseProps +{ + userId: number; +} export const UserLocationView: FC = props => { diff --git a/src/views/room/widgets/user-location/UserLocationView.types.ts b/src/views/room/widgets/user-location/UserLocationView.types.ts deleted file mode 100644 index d5951e2b..00000000 --- a/src/views/room/widgets/user-location/UserLocationView.types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { NitroLayoutBaseProps } from '../../../../layout/base'; - -export interface UserLocationViewProps extends NitroLayoutBaseProps -{ - userId: number; -} diff --git a/src/views/room/widgets/word-quiz/WordQuizQuestionView.tsx b/src/views/room/widgets/word-quiz/WordQuizQuestionView.tsx new file mode 100644 index 00000000..83421ea1 --- /dev/null +++ b/src/views/room/widgets/word-quiz/WordQuizQuestionView.tsx @@ -0,0 +1,44 @@ +import { FC } from 'react'; +import { Base, Column, Flex, Text } from '../../../../common'; +import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE } from './common/VoteValue'; + +interface WordQuizQuestionViewProps +{ + question: string; + canVote: boolean; + vote(value: string): void; + noVotes: number; + yesVotes: number; +} + +export const WordQuizQuestionView: FC = props => +{ + const { question = null, canVote = null, vote = null, noVotes = null, yesVotes = null } = props; + + return ( + + { !canVote && + + + { noVotes } + + { question } + + { yesVotes } + + } + { canVote && + + { question } + + vote(VALUE_KEY_DISLIKE) }> + + + vote(VALUE_KEY_LIKE) }> + + + + } + + ); +} diff --git a/src/views/room/widgets/word-quiz/WordQuizVoteView.tsx b/src/views/room/widgets/word-quiz/WordQuizVoteView.tsx new file mode 100644 index 00000000..5511b284 --- /dev/null +++ b/src/views/room/widgets/word-quiz/WordQuizVoteView.tsx @@ -0,0 +1,24 @@ +import { RoomObjectCategory } from '@nitrots/nitro-renderer/src'; +import { FC } from 'react'; +import { Base, BaseProps, Flex } from '../../../../common'; +import { ObjectLocationView } from '../object-location/ObjectLocationView'; +import { VALUE_KEY_DISLIKE } from './common/VoteValue'; + +interface WordQuizVoteViewProps extends BaseProps +{ + userIndex: number; + vote: string; +} + +export const WordQuizVoteView: FC = props => +{ + const { userIndex = null, vote = null, ...rest } = props; + + return ( + + + + + + ); +} diff --git a/src/views/room/widgets/word-quiz/WordQuizWidgetView.scss b/src/views/room/widgets/word-quiz/WordQuizWidgetView.scss deleted file mode 100644 index 5889d925..00000000 --- a/src/views/room/widgets/word-quiz/WordQuizWidgetView.scss +++ /dev/null @@ -1,39 +0,0 @@ -.wordquiz-question { - position: absolute; - top: 10px; - left: 50%; - transform: translateX(-50%); - font-size: large; - background: rgba($dark, 0.9); - //box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4); - border-radius: $border-radius; - transition: all 0.2s ease; - - .question { - max-width: 300px; - } -} - -.word-quiz-dislike { - background: url("../../../../assets/images/room-widgets/wordquiz-widget/thumbs-down.png"); - width: 31px; - height: 34px; -} - -.word-quiz-like { - background: url("../../../../assets/images/room-widgets/wordquiz-widget/thumbs-up.png"); - width: 31px; - height: 34px; -} - -.word-quiz-dislike-sm { - background: url("../../../../assets/images/room-widgets/wordquiz-widget/thumbs-down-small.png"); - width: 22px; - height: 22px; -} - -.word-quiz-like-sm { - background: url("../../../../assets/images/room-widgets/wordquiz-widget/thumbs-up-small.png"); - height: 22px; - width: 22px; -} diff --git a/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx b/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx index 271853e4..b6b7475e 100644 --- a/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx +++ b/src/views/room/widgets/word-quiz/WordQuizWidgetView.tsx @@ -5,21 +5,21 @@ import { RoomWidgetPollMessage } from '../../../../api/nitro/room/widgets/messag import { BatchUpdates, CreateEventDispatcherHook } from '../../../../hooks'; import { useRoomContext } from '../../context/RoomContext'; import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE, VoteValue } from './common/VoteValue'; -import { QuestionView } from './views/question/QuestionView'; -import { VoteView } from './views/vote/VoteView'; +import { WordQuizQuestionView } from './WordQuizQuestionView'; +import { WordQuizVoteView } from './WordQuizVoteView'; const DEFAULT_DISPLAY_DELAY = 4000; const SIGN_FADE_DELAY = 3; export const WordQuizWidgetView: FC<{}> = props => { + const [ pollId, setPollId ] = useState(-1); + const [ question, setQuestion ] = useState(null); + const [ answerSent, setAnswerSent ] = useState(false); + const [ questionClearTimeout, setQuestionClearTimeout ] = useState(null); + const [ answerCounts, setAnswerCounts ] = useState>(new Map()); + const [ userAnswers, setUserAnswers ] = useState>(new Map()); const { eventDispatcher = null, widgetHandler = null, roomSession = null } = useRoomContext(); - const [pollId, setPollId] = useState(-1); - const [question, setQuestion] = useState(null); - const [answerSent, setAnswerSent] = useState(false); - const [questionClearTimeout, setQuestionClearTimeout] = useState(null); - const [answerCounts, setAnswerCounts] = useState>(new Map()); - const [userAnswers, setUserAnswers] = useState>(new Map()); const clearQuestion = useCallback(() => { @@ -39,33 +39,47 @@ export const WordQuizWidgetView: FC<{}> = props => setAnswerSent(false); setAnswerCounts(new Map()); setUserAnswers(new Map()); - if(questionClearTimeout) clearTimeout(questionClearTimeout); - }); - if(event.duration > 0) - { - const delay = event.duration < 1000 ? DEFAULT_DISPLAY_DELAY : event.duration; setQuestionClearTimeout(prevValue => - { - if(prevValue) clearTimeout(prevValue); + { + if(prevValue) clearTimeout(prevValue); - return setTimeout((clearQuestion as TimerHandler), delay); - }) - } + if(event.duration > 0) + { + const delay = event.duration < 1000 ? DEFAULT_DISPLAY_DELAY : event.duration; + + return setTimeout(() => clearQuestion(), delay) as unknown as number; + } + + return null; + }); + }); break; - case RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED: + case RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED: { const userData = roomSession.userDataManager.getUserData(event.userId); + if(!userData) return; - setAnswerCounts(event.answerCounts); - - if(!userAnswers.has(userData.roomIndex)) + BatchUpdates(() => { - const answersCopy = new Map(userAnswers); - answersCopy.set(userData.roomIndex, { value: event.value, secondsLeft: SIGN_FADE_DELAY }); - setUserAnswers(answersCopy); - } + setAnswerCounts(event.answerCounts); + + setUserAnswers(prevValue => + { + if(!prevValue.has(userData.roomIndex)) + { + const newValue = new Map(userAnswers); + + newValue.set(userData.roomIndex, { value: event.value, secondsLeft: SIGN_FADE_DELAY }); + + return newValue; + } + + return prevValue; + }); + }); break; + } case RoomWidgetWordQuizUpdateEvent.QUESTION_FINISHED: if(question && question.id === event.questionId) { @@ -73,18 +87,20 @@ export const WordQuizWidgetView: FC<{}> = props => { setAnswerCounts(event.answerCounts); setAnswerSent(true); + setQuestionClearTimeout(prevValue => { if(prevValue) clearTimeout(prevValue); - return setTimeout((clearQuestion as TimerHandler), DEFAULT_DISPLAY_DELAY); + return setTimeout(() => clearQuestion(), DEFAULT_DISPLAY_DELAY) as unknown as number; }); - }) + }); } + setUserAnswers(new Map()); break; } - }, [clearQuestion, question, questionClearTimeout, roomSession.userDataManager, userAnswers]); + }, [ question, roomSession.userDataManager, userAnswers, clearQuestion ]); CreateEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.NEW_QUESTION, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); CreateEventDispatcherHook(RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED, eventDispatcher, onRoomWidgetWordQuizUpdateEvent); @@ -95,49 +111,44 @@ export const WordQuizWidgetView: FC<{}> = props => if(answerSent || !question) return; const updateMessage = new RoomWidgetPollMessage(RoomWidgetPollMessage.ANSWER, pollId); + updateMessage.questionId = question.id; updateMessage.answers = [vote]; - widgetHandler.processWidgetMessage(updateMessage); - setAnswerSent(true); - }, [answerSent, pollId, question, widgetHandler]); + widgetHandler.processWidgetMessage(updateMessage); + + setAnswerSent(true); + }, [ answerSent, pollId, question, widgetHandler ]); const checkSignFade = useCallback(() => { - setUserAnswers(prev => + setUserAnswers(prevValue => { const keysToRemove: number[] = []; - prev.forEach((value, key) => + + prevValue.forEach((value, key) => { value.secondsLeft--; - if(value.secondsLeft <= 0) - { - keysToRemove.push(key); - } + if(value.secondsLeft <= 0) keysToRemove.push(key); }); - if(keysToRemove.length === 0) return prev; + if(keysToRemove.length === 0) return prevValue; + + const copy = new Map(prevValue); - const copy = new Map(prev); keysToRemove.forEach(key => copy.delete(key)); - return copy; - }) + return copy; + }); }, []); useEffect(() => { - const interval = setInterval(() => - { - checkSignFade(); - }, 1000) + const interval = setInterval(() => checkSignFade(), 1000); - return () => - { - clearInterval(interval); - } - }, [checkSignFade]); + return () => clearInterval(interval); + }, [ checkSignFade ]); useEffect(() => { @@ -154,15 +165,10 @@ export const WordQuizWidgetView: FC<{}> = props => return ( <> - {question && - - } - {userAnswers && - Array.from(userAnswers.entries()).map(([key, value], index) => - { - return - }) - } + { question && + } + { userAnswers && + Array.from(userAnswers.entries()).map(([key, value], index) => ) } ); } diff --git a/src/views/room/widgets/word-quiz/views/question/QuestionView.tsx b/src/views/room/widgets/word-quiz/views/question/QuestionView.tsx deleted file mode 100644 index 2d2b5d17..00000000 --- a/src/views/room/widgets/word-quiz/views/question/QuestionView.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FC } from 'react'; -import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE } from '../../common/VoteValue'; -import { QuestionViewProps } from './QuestionView.types'; - -export const QuestionView:FC = props => -{ - const { question = null, canVote = null, vote = null, noVotes = null, yesVotes = null } = props; - - return ( -
-
- { !canVote && } -
{question}
- { !canVote && } -
- {canVote && -
- - -
- } -
- ) -} diff --git a/src/views/room/widgets/word-quiz/views/question/QuestionView.types.ts b/src/views/room/widgets/word-quiz/views/question/QuestionView.types.ts deleted file mode 100644 index fde51dba..00000000 --- a/src/views/room/widgets/word-quiz/views/question/QuestionView.types.ts +++ /dev/null @@ -1,9 +0,0 @@ - -export interface QuestionViewProps -{ - question: string; - canVote: boolean; - vote(value: string): void; - noVotes: number; - yesVotes: number; -} diff --git a/src/views/room/widgets/word-quiz/views/vote/VoteView.tsx b/src/views/room/widgets/word-quiz/views/vote/VoteView.tsx deleted file mode 100644 index bee02143..00000000 --- a/src/views/room/widgets/word-quiz/views/vote/VoteView.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { RoomObjectCategory } from '@nitrots/nitro-renderer/src'; -import { FC } from 'react'; -import { ObjectLocationView } from '../../../object-location/ObjectLocationView'; -import { VALUE_KEY_DISLIKE } from '../../common/VoteValue'; -import { VoteViewProps } from './VoteView.types'; - -export const VoteView:FC = props => -{ - const { userIndex = null , vote = null } = props; - - return ( - - - - ) -} diff --git a/src/views/room/widgets/word-quiz/views/vote/VoteView.types.ts b/src/views/room/widgets/word-quiz/views/vote/VoteView.types.ts deleted file mode 100644 index 17062cc6..00000000 --- a/src/views/room/widgets/word-quiz/views/vote/VoteView.types.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface VoteViewProps -{ - userIndex: number; - vote: string; -} From c7d3022ccb63fb1c1eec789f4fbbe5e1bd3c6c63 Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 27 Feb 2022 20:58:28 -0500 Subject: [PATCH 09/17] Fix catalog offers --- src/components/catalog/common/FurnitureOffer.ts | 13 ++++++++++++- src/components/catalog/common/IPurchasableOffer.ts | 2 ++ src/components/catalog/common/Offer.ts | 10 ++++++++++ .../page/widgets/CatalogItemGridWidgetView.tsx | 9 +++++---- .../page/widgets/CatalogPurchaseWidgetView.tsx | 12 ++++++------ 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/components/catalog/common/FurnitureOffer.ts b/src/components/catalog/common/FurnitureOffer.ts index 85d3216a..9197ae9f 100644 --- a/src/components/catalog/common/FurnitureOffer.ts +++ b/src/components/catalog/common/FurnitureOffer.ts @@ -1,5 +1,6 @@ -import { IFurnitureData } from '@nitrots/nitro-renderer'; +import { GetProductOfferComposer, IFurnitureData } from '@nitrots/nitro-renderer'; import { GetProductDataForLocalization } from '../../../api'; +import { SendMessageHook } from '../../../hooks'; import { ICatalogPage } from './ICatalogPage'; import { IProduct } from './IProduct'; import { IPurchasableOffer } from './IPurchasableOffer'; @@ -18,6 +19,11 @@ export class FurnitureOffer implements IPurchasableOffer this._product = (new Product(this._furniData.type, this._furniData.id, this._furniData.customParams, 1, GetProductDataForLocalization(this._furniData.className), this._furniData) as IProduct); } + public activate(): void + { + SendMessageHook(new GetProductOfferComposer((this._furniData.rentOfferId > -1) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId)); + } + public get offerId(): number { return (this.isRentOffer) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId; @@ -107,4 +113,9 @@ export class FurnitureOffer implements IPurchasableOffer { return this._furniData.description; } + + public get isLazy(): boolean + { + return true; + } } diff --git a/src/components/catalog/common/IPurchasableOffer.ts b/src/components/catalog/common/IPurchasableOffer.ts index cc2693f7..b1828651 100644 --- a/src/components/catalog/common/IPurchasableOffer.ts +++ b/src/components/catalog/common/IPurchasableOffer.ts @@ -3,6 +3,7 @@ import { IProduct } from './IProduct'; export interface IPurchasableOffer { + activate(): void; clubLevel: number; page: ICatalogPage; offerId: number; @@ -19,5 +20,6 @@ export interface IPurchasableOffer badgeCode: string; localizationName: string; localizationDescription: string; + isLazy: boolean; products: IProduct[]; } diff --git a/src/components/catalog/common/Offer.ts b/src/components/catalog/common/Offer.ts index 16e30a0c..b39ed48f 100644 --- a/src/components/catalog/common/Offer.ts +++ b/src/components/catalog/common/Offer.ts @@ -59,6 +59,11 @@ export class Offer implements IPurchasableOffer } } + public activate(): void + { + + } + public get clubLevel(): number { return this._clubLevel; @@ -160,6 +165,11 @@ export class Offer implements IPurchasableOffer return LocalizeText(this._localizationId); } + public get isLazy(): boolean + { + return false; + } + public get products(): IProduct[] { return this._products; diff --git a/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx index e41ff311..dbb20b17 100644 --- a/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogItemGridWidgetView.tsx @@ -21,6 +21,10 @@ export const CatalogItemGridWidgetView: FC = pro const selectOffer = (offer: IPurchasableOffer) => { + offer.activate(); + + if(offer.isLazy) return; + setCurrentOffer(offer); if(offer.product && (offer.product.productType === ProductTypeEnum.WALL)) @@ -31,10 +35,7 @@ export const CatalogItemGridWidgetView: FC = pro return ( - { currentPage.offers && (currentPage.offers.length > 0) && currentPage.offers.map((offer, index) => - { - return selectOffer(offer) } />; - }) } + { currentPage.offers && (currentPage.offers.length > 0) && currentPage.offers.map((offer, index) => selectOffer(offer) } />) } { children } ); diff --git a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx index 9b05d88f..d9df7e86 100644 --- a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx @@ -106,15 +106,15 @@ export const CatalogPurchaseWidgetView: FC = pro let pageId = currentOffer.page.pageId; - if(pageId === -1) - { - const nodes = getNodesByOfferId(currentOffer.offerId); + // if(pageId === -1) + // { + // const nodes = getNodesByOfferId(currentOffer.offerId); - if(nodes) pageId = nodes[0].pageId; - } + // if(nodes) pageId = nodes[0].pageId; + // } SendMessageHook(new PurchaseFromCatalogComposer(pageId, currentOffer.offerId, extraData, quantity)); - }, [ currentOffer, purchaseCallback, extraData, quantity, getNodesByOfferId ]); + }, [ currentOffer, purchaseCallback, extraData, quantity ]); useEffect(() => { From 86d1d8ceba6c47a585af36e9fc96ede6f038e60a Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 1 Mar 2022 00:09:02 -0500 Subject: [PATCH 10/17] Update infostand --- .../infostand/InfoStandWidgetBotView.tsx | 57 +++++ .../furni => }/InfoStandWidgetFurniView.tsx | 237 ++++++++++-------- .../infostand/InfoStandWidgetPetView.tsx | 85 +++++++ .../InfoStandWidgetRentableBotView.tsx | 89 +++++++ .../InfoStandWidgetUserRelationshipsView.tsx | 47 ++++ .../infostand/InfoStandWidgetUserView.tsx | 177 +++++++++++++ .../infostand/InfoStandWidgetView.scss | 2 +- .../widgets/infostand/InfoStandWidgetView.tsx | 15 +- .../views/base/InfoStandBaseView.tsx | 20 -- .../views/base/InfoStandBaseView.types.ts | 7 - .../views/bot/InfoStandWidgetBotView.tsx | 44 ---- .../views/bot/InfoStandWidgetBotView.types.ts | 7 - .../furni/InfoStandWidgetFurniView.types.ts | 7 - .../views/pet/InfoStandWidgetPetView.tsx | 55 ---- .../views/pet/InfoStandWidgetPetView.types.ts | 7 - .../InfoStandWidgetRentableBotView.tsx | 70 ------ .../InfoStandWidgetRentableBotView.types.ts | 7 - .../views/user/InfoStandWidgetUserView.tsx | 159 ------------ .../user/InfoStandWidgetUserView.types.ts | 7 - 19 files changed, 601 insertions(+), 498 deletions(-) create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx rename src/views/room/widgets/infostand/{views/furni => }/InfoStandWidgetFurniView.tsx (53%) create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx create mode 100644 src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx delete mode 100644 src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx delete mode 100644 src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx delete mode 100644 src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx delete mode 100644 src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx delete mode 100644 src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts delete mode 100644 src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx delete mode 100644 src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts diff --git a/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx new file mode 100644 index 00000000..dac8f179 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetBotView.tsx @@ -0,0 +1,57 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FC } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandUserEvent } from '../../../../api'; +import { Column, Flex, Text } from '../../../../common'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; + +interface InfoStandWidgetBotViewProps +{ + botData: RoomWidgetUpdateInfostandUserEvent; + close: () => void; +} + +export const InfoStandWidgetBotView: FC = props => +{ + const { botData = null, close = null } = props; + + if(!botData) return null; + + return ( + + + + + { botData.name } + + +
+
+ + + + + + + { (botData.badges.length > 0) && botData.badges.map(result => + { + return ; + }) } + + +
+
+ + { botData.motto } + + { (botData.carryItem > 0) && + +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + botData.carryItem) ]) } + +
} +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx similarity index 53% rename from src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx rename to src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx index d848327d..eae29e55 100644 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetFurniView.tsx @@ -1,14 +1,20 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { CrackableDataType, GroupInformationComposer, GroupInformationEvent, RoomControllerLevel, RoomObjectCategory, RoomObjectVariable, RoomWidgetEnumItemExtradataParameter, RoomWidgetFurniInfoUsagePolicyEnum, SetObjectDataMessageComposer, StringDataType } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage } from '../../../../../../api'; -import { CreateMessageHook, SendMessageHook } from '../../../../../../hooks'; -import { UserProfileIconView } from '../../../../../../layout'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { LimitedEditionCompactPlateView } from '../../../../../shared/limited-edition/LimitedEditionCompactPlateView'; -import { RarityLevelView } from '../../../../../shared/rarity-level/RarityLevelView'; -import { useRoomContext } from '../../../../context/RoomContext'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetFurniViewProps } from './InfoStandWidgetFurniView.types'; +import { CreateLinkEvent, GetGroupInformation, GetRoomEngine, LocalizeText, RoomWidgetFurniActionMessage, RoomWidgetUpdateInfostandFurniEvent } from '../../../../api'; +import { Button, Column, Flex, Text } from '../../../../common'; +import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { UserProfileIconView } from '../../../../layout'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { LimitedEditionCompactPlateView } from '../../../shared/limited-edition/LimitedEditionCompactPlateView'; +import { RarityLevelView } from '../../../shared/rarity-level/RarityLevelView'; +import { useRoomContext } from '../../context/RoomContext'; + +interface InfoStandWidgetFurniViewProps +{ + furniData: RoomWidgetUpdateInfostandFurniEvent; + close: () => void; +} const PICKUP_MODE_NONE: number = 0; const PICKUP_MODE_EJECT: number = 1; @@ -117,19 +123,22 @@ export const InfoStandWidgetFurniView: FC = props if(furniData.isStickie) pickupMode = PICKUP_MODE_NONE; - setPickupMode(pickupMode); - setCanMove(canMove); - setCanRotate(canRotate); - setCanUse(canUse); - setFurniKeys(furniKeyss); - setFurniValues(furniValuess); - setCustomKeys(customKeyss); - setCustomValues(customValuess); - setIsCrackable(isCrackable); - setCrackableHits(crackableHits); - setCrackableTarget(crackableTarget); - setGodMode(godMode); - setGroupName(null); + BatchUpdates(() => + { + setPickupMode(pickupMode); + setCanMove(canMove); + setCanRotate(canRotate); + setCanUse(canUse); + setFurniKeys(furniKeyss); + setFurniValues(furniValuess); + setCustomKeys(customKeyss); + setCustomValues(customValuess); + setIsCrackable(isCrackable); + setCrackableHits(crackableHits); + setCrackableTarget(crackableTarget); + setGodMode(godMode); + setGroupName(null); + }); if(furniData.groupId) SendMessageHook(new GroupInformationComposer(furniData.groupId, false)); }, [ roomSession, furniData ]); @@ -247,97 +256,125 @@ export const InfoStandWidgetFurniView: FC = props if(!furniData) return null; return ( - <> - -
- { furniData.stuffData.isUnique && -
- -
} - { (furniData.stuffData.rarityLevel > -1) && -
- -
} - { furniData.image && furniData.image.src.length && - } -
-
-
{ furniData.description }
-
-
- -
{ LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) }
-
- { (furniData.purchaseOfferId > 0) && } - { isCrackable && - <> -
-
{ LocalizeText('infostand.crackable_furni.hits_remaining', [ 'hits', 'target' ], [ crackableHits.toString(), crackableTarget.toString() ]) }
- } - { furniData.groupId > 0 && - <> -
-
GetGroupInformation(furniData.groupId) }> - -
{ groupName }
-
- } - { godMode && - <> -
-
ID: { furniData.id }
- { (furniKeys.length > 0) && + + + + + + { furniData.name } + + +
+
+ + + { furniData.stuffData.isUnique && +
+ +
} + { (furniData.stuffData.rarityLevel > -1) && +
+ +
} + { furniData.image && furniData.image.src.length && + } +
+
+
+ + { furniData.description } +
+
+ + + + + { LocalizeText('furni.owner', [ 'name' ], [ furniData.ownerName ]) } + + + { (furniData.purchaseOfferId > 0) && + + processButtonAction('buy_one') }> + { LocalizeText('infostand.button.buy') } + + } + + + { isCrackable && + <> +
+ { LocalizeText('infostand.crackable_furni.hits_remaining', [ 'hits', 'target' ], [ crackableHits.toString(), crackableTarget.toString() ]) } + } + { furniData.groupId > 0 && + <> +
+ GetGroupInformation(furniData.groupId) }> + + { groupName } + + } + { godMode && + <> +
+ ID: { furniData.id } + { (furniKeys.length > 0) && + <> +
+ + { furniKeys.map((key, index) => + { + return ( + + { key } + onFurniSettingChange(index, event.target.value) }/> + ); + }) } + + } + } + { (customKeys.length > 0) && <>
- { furniKeys.map((key, index) => - { - return ( -
-
{ key }
- onFurniSettingChange(index, event.target.value) }/> -
); - }) } + + { customKeys.map((key, index) => + { + return ( + + { key } + onCustomVariableChange(index, event.target.value) }/> + ); + }) } + } - } - { (customKeys.length > 0) && - <> -
- { customKeys.map((key, index) => - { - return ( -
-
{ key }
- onCustomVariableChange(index, event.target.value) }/> -
); - }) } - } -
-
+ + + + { canMove && - } + } { canRotate && - } + } { canUse && - } + } { (pickupMode !== PICKUP_MODE_NONE) && - } + } { ((furniKeys.length > 0 && furniValues.length > 0) && (furniKeys.length === furniValues.length)) && - } + } { ((customKeys.length > 0 && customValues.length > 0) && (customKeys.length === customValues.length)) && - } -
- + } +
+
); } diff --git a/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx new file mode 100644 index 00000000..1b6f14d1 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetPetView.tsx @@ -0,0 +1,85 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { FC } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandPetEvent } from '../../../../api'; +import { Base, Column, Flex, Text } from '../../../../common'; +import { UserProfileIconView } from '../../../../layout'; +import { PetImageView } from '../../../shared/pet-image/PetImageView'; + +interface InfoStandWidgetPetViewProps +{ + petData: RoomWidgetUpdateInfostandPetEvent; + close: () => void; +} + +export const InfoStandWidgetPetView: FC = props => +{ + const { petData = null, close = null } = props; + + if(!petData) return null; + + return ( + + + + + { petData.name } + + + { LocalizeText(`pet.breed.${ petData.petType }.${ petData.petBreed }`) } +
+
+ + + + + + + { LocalizeText('pet.level', [ 'level', 'maxlevel' ], [ petData.level.toString(), petData.maximumLevel.toString() ]) } + + { LocalizeText('infostand.pet.text.happiness') } + + + { petData.happyness + '/' + petData.maximumHappyness } + + + + + + { LocalizeText('infostand.pet.text.experience') } + + + { petData.experience + '/' + petData.levelExperienceGoal } + + + + + + { LocalizeText('infostand.pet.text.energy') } + + + { petData.energy + '/' + petData.maximumEnergy } + + + + + + +
+
+ + { LocalizeText('infostand.text.petrespect', [ 'count' ], [ petData.respect.toString() ]) } + { LocalizeText('pet.age', [ 'age' ], [ petData.age.toString() ]) } +
+
+ + + + + { LocalizeText('infostand.text.petowner', [ 'name' ], [ petData.ownerName ]) } + + + +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx new file mode 100644 index 00000000..d3847d31 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetRentableBotView.tsx @@ -0,0 +1,89 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { BotRemoveComposer } from '@nitrots/nitro-renderer'; +import { FC, useMemo } from 'react'; +import { LocalizeText, RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../api'; +import { Button, Column, Flex, Text } from '../../../../common'; +import { SendMessageHook } from '../../../../hooks'; +import { UserProfileIconView } from '../../../../layout'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { BotSkillsEnum } from '../avatar-info/common/BotSkillsEnum'; + +interface InfoStandWidgetRentableBotViewProps +{ + rentableBotData: RoomWidgetUpdateInfostandRentableBotEvent; + close: () => void; +} + +export const InfoStandWidgetRentableBotView: FC = props => +{ + const { rentableBotData = null, close = null } = props; + + const canPickup = useMemo(() => + { + if(rentableBotData.botSkills.indexOf(BotSkillsEnum.NO_PICK_UP) >= 0) return false; + + if(!rentableBotData.amIOwner && !rentableBotData.amIAnyRoomController) return false; + + return true; + }, [ rentableBotData ]); + + const pickupBot = () => SendMessageHook(new BotRemoveComposer(rentableBotData.webID)); + + if(!rentableBotData) return; + + return ( + + + + + + { rentableBotData.name } + + +
+
+ + + + + + + { (rentableBotData.badges.length > 0) && rentableBotData.badges.map(result => + { + return ; + }) } + + +
+
+ + + { rentableBotData.motto } + +
+
+ + + + + { LocalizeText('infostand.text.botowner', [ 'name' ], [ rentableBotData.ownerName ]) } + + + { (rentableBotData.carryItem > 0) && + <> +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + rentableBotData.carryItem) ]) } + + } +
+
+
+ { canPickup && + + + } +
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx new file mode 100644 index 00000000..dea72734 --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetUserRelationshipsView.tsx @@ -0,0 +1,47 @@ +import { RelationshipStatusEnum, RelationshipStatusInfoMessageParser } from '@nitrots/nitro-renderer'; +import { FC } from 'react'; +import { GetUserProfile, LocalizeText } from '../../../../api'; +import { Flex, Text } from '../../../../common'; + +interface InfoStandWidgetUserRelationshipsViewProps +{ + relationships: RelationshipStatusInfoMessageParser; +} + +interface InfoStandWidgetUserRelationshipsRelationshipViewProps +{ + type: number; +} + +export const InfoStandWidgetUserRelationshipsView: FC = props => +{ + const { relationships = null } = props; + + const RelationshipComponent = ({ type }: InfoStandWidgetUserRelationshipsRelationshipViewProps) => + { + const relationshipInfo = (relationships && relationships.relationshipStatusMap.hasKey(type)) ? relationships.relationshipStatusMap.getValue(type) : null; + + if(!relationshipInfo || !relationshipInfo.friendCount) return null; + + const relationshipName = RelationshipStatusEnum.RELATIONSHIP_NAMES[type].toLocaleLowerCase(); + + return ( + + + + GetUserProfile(relationshipInfo.randomFriendId) }>{ relationshipInfo.randomFriendName } + { (relationshipInfo.friendCount > 1) && + { ' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationshipInfo.friendCount - 1).toString() ]) } } + + + ); + } + + return ( + <> + + + + + ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx new file mode 100644 index 00000000..f2faaaae --- /dev/null +++ b/src/views/room/widgets/infostand/InfoStandWidgetUserView.tsx @@ -0,0 +1,177 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionUserBadgesEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; +import { FC, FocusEvent, KeyboardEvent, useCallback, useEffect, useState } from 'react'; +import { GetConfiguration, GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent } from '../../../../api'; +import { Column, Text } from '../../../../common'; +import { Base } from '../../../../common/Base'; +import { Flex } from '../../../../common/Flex'; +import { BatchUpdates, CreateMessageHook, SendMessageHook } from '../../../../hooks'; +import { CreateEventDispatcherHook } from '../../../../hooks/events'; +import { UserProfileIconView } from '../../../../layout'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; +import { useRoomContext } from '../../context/RoomContext'; +import { InfoStandWidgetUserRelationshipsView } from './InfoStandWidgetUserRelationshipsView'; + +interface InfoStandWidgetUserViewProps +{ + userData: RoomWidgetUpdateInfostandUserEvent; + close: () => void; +} + +export const InfoStandWidgetUserView: FC = props => +{ + const { userData = null, close = null } = props; + const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); + const [ badges, setBadges ] = useState([]); + const [ motto, setMotto ] = useState(null); + const [ isEditingMotto, setIsEditingMotto ] = useState(false); + const [ userRelationships, setUserRelationships ] = useState(null); + + const maxBadgeCount = GetConfiguration('user.badges.max.slots', 5); + + const saveMotto = (motto: string) => + { + if(motto.length > 38) return; + + widgetHandler.processWidgetMessage(new RoomWidgetChangeMottoMessage(motto)); + + setIsEditingMotto(false); + } + + const onMottoBlur = (event: FocusEvent) => saveMotto(event.target.value); + + const onMottoKeyDown = (event: KeyboardEvent) => + { + event.stopPropagation(); + + switch(event.key) + { + case 'Enter': + saveMotto((event.target as HTMLInputElement).value); + return; + } + } + + const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => + { + if(!userData || (userData.webID !== event.userId)) return; + + setBadges(event.badges); + }, [ userData ]); + + CreateEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); + + const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => + { + const parser = event.getParser(); + + if(!userData || (userData.webID !== parser.userId)) return; + + setUserRelationships(parser); + }, [ userData ]); + + CreateMessageHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); + + useEffect(() => + { + BatchUpdates(() => + { + setBadges(userData.badges); + setIsEditingMotto(false); + setMotto(userData.motto); + }); + + SendMessageHook(new UserRelationshipsComposer(userData.webID)); + + return () => + { + setBadges([]); + setUserRelationships(null); + } + }, [ userData ]); + + if(!userData) return null; + + return ( + + + + + + + { userData.name } + + + +
+
+ + + + + + + + + { badges[0] && } + + 0) } className="badge-image" onClick={ event => GetGroupInformation(userData.groupId) }> + { userData.groupId > 0 && + } + + + + + { badges[1] && } + + + { badges[2] && } + + + + + { badges[3] && } + + + { badges[4] && } + + + + +
+
+ + + { (userData.type !== RoomWidgetUpdateInfostandUserEvent.OWN_USER) && + { motto } } + { userData.type === RoomWidgetUpdateInfostandUserEvent.OWN_USER && + + + { !isEditingMotto && + setIsEditingMotto(true) }>{ motto } } + { isEditingMotto && + setMotto(event.target.value) } onBlur={ onMottoBlur } onKeyDown={ onMottoKeyDown } autoFocus={ true } /> } + } + +
+
+ + + { LocalizeText('infostand.text.achievement_score') + ' ' + userData.achievementScore } + + { (userData.carryItem > 0) && + <> +
+ + { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + userData.carryItem) ]) } + + } +
+ + + +
+
+ ); +} diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.scss b/src/views/room/widgets/infostand/InfoStandWidgetView.scss index 53ad09d5..2e57c0c0 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.scss +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.scss @@ -4,6 +4,7 @@ bottom: $toolbar-height + 10px; pointer-events: none; z-index: $infostand-zindex; + color: $white; .nitro-infostand { position: relative; @@ -28,7 +29,6 @@ width: 100%; max-width: 68px; border-radius: $border-radius; - margin-right: 5px; &.pet { max-width: 75px; diff --git a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx index 4f240121..ef76d03d 100644 --- a/src/views/room/widgets/infostand/InfoStandWidgetView.tsx +++ b/src/views/room/widgets/infostand/InfoStandWidgetView.tsx @@ -1,12 +1,13 @@ import { FC, useCallback, useState } from 'react'; import { RoomWidgetRoomObjectMessage, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; +import { Column } from '../../../../common'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; import { useRoomContext } from '../../context/RoomContext'; -import { InfoStandWidgetBotView } from './views/bot/InfoStandWidgetBotView'; -import { InfoStandWidgetFurniView } from './views/furni/InfoStandWidgetFurniView'; -import { InfoStandWidgetPetView } from './views/pet/InfoStandWidgetPetView'; -import { InfoStandWidgetRentableBotView } from './views/rentable-bot/InfoStandWidgetRentableBotView'; -import { InfoStandWidgetUserView } from './views/user/InfoStandWidgetUserView'; +import { InfoStandWidgetBotView } from './InfoStandWidgetBotView'; +import { InfoStandWidgetFurniView } from './InfoStandWidgetFurniView'; +import { InfoStandWidgetPetView } from './InfoStandWidgetPetView'; +import { InfoStandWidgetRentableBotView } from './InfoStandWidgetRentableBotView'; +import { InfoStandWidgetUserView } from './InfoStandWidgetUserView'; export const InfoStandWidgetView: FC<{}> = props => { @@ -116,8 +117,8 @@ export const InfoStandWidgetView: FC<{}> = props => if(!infoStandEvent) return null; return ( -
+ { getInfostandView() } -
+
); } diff --git a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx b/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx deleted file mode 100644 index 19569bd0..00000000 --- a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { FC } from 'react'; -import { InfoStandBaseViewProps } from './InfoStandBaseView.types'; - -export const InfoStandBaseView: FC = props => -{ - const { headerText = null, onCloseClick = null, children = null } = props; - - return ( -
-
-
-
{ headerText }
- -
-
- { children } -
-
- ); -} diff --git a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts b/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts deleted file mode 100644 index bb775875..00000000 --- a/src/views/room/widgets/infostand/views/base/InfoStandBaseView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { MouseEvent, ReactNode } from 'react'; - -export interface InfoStandBaseViewProps -{ - headerText: ReactNode; - onCloseClick: (event: MouseEvent) => void; -} diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx deleted file mode 100644 index 682f801c..00000000 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { FC, useCallback } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetBotViewProps } from './InfoStandWidgetBotView.types'; - -export const InfoStandWidgetBotView: FC = props => -{ - const { botData = null, close = null } = props; - - const processButtonAction = useCallback((action: string) => - { - if(!action || (action === '')) return; - - }, []); - - if(!botData) return null; - - return ( - -
-
- -
-
- { (botData.badges.length > 0) && botData.badges.map(result => - { - return ; - }) } -
-
-
-
{ botData.motto }
- { (botData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + botData.carryItem) ]) } -
- } -
- ); -} diff --git a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts b/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts deleted file mode 100644 index 6691eec4..00000000 --- a/src/views/room/widgets/infostand/views/bot/InfoStandWidgetBotView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; - -export interface InfoStandWidgetBotViewProps -{ - botData: RoomWidgetUpdateInfostandUserEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts b/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts deleted file mode 100644 index c4a77f9c..00000000 --- a/src/views/room/widgets/infostand/views/furni/InfoStandWidgetFurniView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandFurniEvent } from '../../../../../../api'; - -export interface InfoStandWidgetFurniViewProps -{ - furniData: RoomWidgetUpdateInfostandFurniEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx b/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx deleted file mode 100644 index a2482ced..00000000 --- a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { FC } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { UserProfileIconView } from '../../../../../../layout'; -import { PetImageView } from '../../../../../shared/pet-image/PetImageView'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetPetViewProps } from './InfoStandWidgetPetView.types'; - -export const InfoStandWidgetPetView: FC = props => -{ - const { petData = null, close = null } = props; - - if(!petData) return null; - - return ( - { petData.name }
{ LocalizeText('pet.breed.' + petData.petType + '.' + petData.petBreed) } } onCloseClick={ close }> -
-
- -
-
-
{ LocalizeText('pet.level', ['level', 'maxlevel'], [petData.level.toString(), petData.maximumLevel.toString()]) }
-
-
{ LocalizeText('infostand.pet.text.happiness') }
-
-
{ petData.happyness + '/' + petData.maximumHappyness }
-
-
-
-
-
{ LocalizeText('infostand.pet.text.experience') }
-
-
{ petData.experience + '/' + petData.levelExperienceGoal }
-
-
-
-
-
{ LocalizeText('infostand.pet.text.energy') }
-
-
{ petData.energy + '/' + petData.maximumEnergy }
-
-
-
-
-
-
-
{ LocalizeText('infostand.text.petrespect', ['count'], [petData.respect.toString()]) }
-
{ LocalizeText('pet.age', ['age'], [petData.age.toString()]) }
-
-
- -
{ LocalizeText('infostand.text.petowner', ['name'], [petData.ownerName]) }
-
- - ); -} diff --git a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts b/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts deleted file mode 100644 index 46d61195..00000000 --- a/src/views/room/widgets/infostand/views/pet/InfoStandWidgetPetView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandPetEvent } from '../../../../../../api'; - -export interface InfoStandWidgetPetViewProps -{ - petData: RoomWidgetUpdateInfostandPetEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx deleted file mode 100644 index e4214850..00000000 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { BotRemoveComposer } from '@nitrots/nitro-renderer'; -import { FC, useCallback, useMemo } from 'react'; -import { LocalizeText } from '../../../../../../api'; -import { SendMessageHook } from '../../../../../../hooks'; -import { UserProfileIconView } from '../../../../../../layout'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { BotSkillsEnum } from '../../../avatar-info/common/BotSkillsEnum'; -import { InfoStandBaseView } from '../base/InfoStandBaseView'; -import { InfoStandWidgetRentableBotViewProps } from './InfoStandWidgetRentableBotView.types'; - -export const InfoStandWidgetRentableBotView: FC = props => -{ - const { rentableBotData = null, close = null } = props; - - const canPickup = useMemo(() => - { - if(rentableBotData.botSkills.indexOf(BotSkillsEnum.NO_PICK_UP) >= 0) return false; - - if(!rentableBotData.amIOwner && !rentableBotData.amIAnyRoomController) return false; - - return true; - }, [ rentableBotData ]); - - const pickupBot = useCallback(() => - { - SendMessageHook(new BotRemoveComposer(rentableBotData.webID)); - }, [ rentableBotData ]); - - if(!rentableBotData) return; - - return ( - <> - -
-
- -
-
- { (rentableBotData.badges.length > 0) && rentableBotData.badges.map(result => - { - return ; - }) } -
-
-
-
{ rentableBotData.motto }
-
-
- -
{ LocalizeText('infostand.text.botowner', [ 'name' ], [ rentableBotData.ownerName ]) }
-
- { (rentableBotData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + rentableBotData.carryItem) ]) } -
- } -
- { canPickup && -
- -
} - - ); -} diff --git a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts b/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts deleted file mode 100644 index d3480bd1..00000000 --- a/src/views/room/widgets/infostand/views/rentable-bot/InfoStandWidgetRentableBotView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandRentableBotEvent } from '../../../../../../api'; - -export interface InfoStandWidgetRentableBotViewProps -{ - rentableBotData: RoomWidgetUpdateInfostandRentableBotEvent; - close: () => void; -} diff --git a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx deleted file mode 100644 index 44e90e40..00000000 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.tsx +++ /dev/null @@ -1,159 +0,0 @@ -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomSessionUserBadgesEvent, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; -import classNames from 'classnames'; -import { FC, FocusEvent, KeyboardEvent, useCallback, useEffect, useState } from 'react'; -import { GetGroupInformation, LocalizeText, RoomWidgetChangeMottoMessage, RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; -import { Base } from '../../../../../../common/Base'; -import { Flex } from '../../../../../../common/Flex'; -import { RelationshipsContainerView } from '../../../../../../components/user-profile/views/RelationshipsContainerView'; -import { CreateMessageHook, SendMessageHook } from '../../../../../../hooks'; -import { CreateEventDispatcherHook } from '../../../../../../hooks/events'; -import { UserProfileIconView } from '../../../../../../layout'; -import { AvatarImageView } from '../../../../../shared/avatar-image/AvatarImageView'; -import { BadgeImageView } from '../../../../../shared/badge-image/BadgeImageView'; -import { useRoomContext } from '../../../../context/RoomContext'; -import { InfoStandWidgetUserViewProps } from './InfoStandWidgetUserView.types'; - -export const InfoStandWidgetUserView: FC = props => -{ - const { userData = null, close = null } = props; - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); - const [ badges, setBadges ] = useState([]); - const [ motto, setMotto ] = useState(null); - const [ isEditingMotto, setIsEditingMotto ] = useState(false); - const [ userRelationships, setUserRelationships ] = useState(null); - - const saveMotto = useCallback((motto: string) => - { - if(motto.length > 38) return; - - widgetHandler.processWidgetMessage(new RoomWidgetChangeMottoMessage(motto)); - - setIsEditingMotto(false); - }, [ widgetHandler ]); - - const onMottoBlur = useCallback((event: FocusEvent) => - { - saveMotto(event.target.value); - }, [ saveMotto ]); - - const onMottoKeyDown = useCallback((event: KeyboardEvent) => - { - event.stopPropagation(); - - switch(event.key) - { - case 'Enter': - saveMotto((event.target as HTMLInputElement).value); - return; - } - }, [ saveMotto ]); - - const onRoomSessionUserBadgesEvent = useCallback((event: RoomSessionUserBadgesEvent) => - { - if(!userData || (userData.webID !== event.userId)) return; - - setBadges(event.badges); - }, [ userData ]); - - CreateEventDispatcherHook(RoomSessionUserBadgesEvent.RSUBE_BADGES, eventDispatcher, onRoomSessionUserBadgesEvent); - - const onUserRelationshipsEvent = useCallback((event: RelationshipStatusInfoEvent) => - { - const parser = event.getParser(); - - if(userData && userData.webID === parser.userId) - setUserRelationships(parser); - }, [userData]); - - CreateMessageHook(RelationshipStatusInfoEvent, onUserRelationshipsEvent); - - useEffect(() => - { - setBadges(userData.badges); - setIsEditingMotto(false); - setMotto(userData.motto); - SendMessageHook(new UserRelationshipsComposer(userData.webID)); - - return () => - { - setBadges([]); - setUserRelationships(null); - } - }, [ userData ]); - - if(!userData) return null; - - return ( - -
- - - - { userData.name } - - - -
- -
- -
-
- -
- { badges[0] && } -
-
0 }) } onClick={ () => GetGroupInformation(userData.groupId) }> - { userData.groupId > 0 && } -
-
- -
- { badges[1] && } -
-
- { badges[2] && } -
-
- -
- { badges[3] && } -
-
- { badges[4] && } -
-
-
-
-
-
- { (userData.type !== RoomWidgetUpdateInfostandUserEvent.OWN_USER) && -
{ motto }
} - { userData.type === RoomWidgetUpdateInfostandUserEvent.OWN_USER && - - - - { !isEditingMotto && -
setIsEditingMotto(true) }>{ motto }
} - { isEditingMotto && - setMotto(event.target.value) } onBlur={ onMottoBlur } onKeyDown={ onMottoKeyDown } autoFocus={ true } /> } - -
} -
-
-
- { LocalizeText('infostand.text.achievement_score') + ' ' + userData.achievementScore } -
- { (userData.carryItem > 0) && - <> -
-
- { LocalizeText('infostand.text.handitem', [ 'item' ], [ LocalizeText('handitem' + userData.carryItem) ]) } -
- - } - -
-
); -} diff --git a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts b/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts deleted file mode 100644 index df69165b..00000000 --- a/src/views/room/widgets/infostand/views/user/InfoStandWidgetUserView.types.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { RoomWidgetUpdateInfostandUserEvent } from '../../../../../../api'; - -export interface InfoStandWidgetUserViewProps -{ - userData: RoomWidgetUpdateInfostandUserEvent; - close: () => void; -} From 02556310b1c8d59cc18f6c8a3ce96acc863d6ca9 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 1 Mar 2022 00:50:24 -0500 Subject: [PATCH 11/17] Update chat style selector --- .../ChatInputStyleSelectorView.tsx | 53 +++++++++++-------- .../widgets/chat-input/ChatInputView.scss | 31 +++-------- .../room/widgets/chat-input/ChatInputView.tsx | 2 +- .../ChatInputStyleSelectorView.types.ts | 6 --- 4 files changed, 38 insertions(+), 54 deletions(-) rename src/views/room/widgets/chat-input/{style-selector => }/ChatInputStyleSelectorView.tsx (56%) delete mode 100644 src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.types.ts diff --git a/src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.tsx b/src/views/room/widgets/chat-input/ChatInputStyleSelectorView.tsx similarity index 56% rename from src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.tsx rename to src/views/room/widgets/chat-input/ChatInputStyleSelectorView.tsx index 04bcb68f..828f762a 100644 --- a/src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.tsx +++ b/src/views/room/widgets/chat-input/ChatInputStyleSelectorView.tsx @@ -1,8 +1,15 @@ -import { FC, MouseEvent, useCallback, useEffect, useState } from 'react'; +import { FC, MouseEvent, useEffect, useState } from 'react'; import { Overlay, Popover } from 'react-bootstrap'; -import { BatchUpdates } from '../../../../../hooks'; -import { NitroCardContentView, NitroCardGridItemView, NitroCardGridView } from '../../../../../layout'; -import { ChatInputStyleSelectorViewProps } from './ChatInputStyleSelectorView.types'; +import { Base, Flex, Grid } from '../../../../common'; +import { BatchUpdates } from '../../../../hooks'; +import { NitroCardContentView } from '../../../../layout'; + +interface ChatInputStyleSelectorViewProps +{ + chatStyleId: number; + chatStyleIds: number[]; + selectChatStyleId: (styleId: number) => void; +} export const ChatInputStyleSelectorView: FC = props => { @@ -10,13 +17,6 @@ export const ChatInputStyleSelectorView: FC = p const [ target, setTarget ] = useState<(EventTarget & HTMLElement)>(null); const [ selectorVisible, setSelectorVisible ] = useState(false); - useEffect(() => - { - if(selectorVisible) return; - - setTarget(null); - }, [ selectorVisible ]); - const selectStyle = (styleId: number) => { BatchUpdates(() => @@ -26,7 +26,7 @@ export const ChatInputStyleSelectorView: FC = p }); } - const toggleSelector = useCallback((event: MouseEvent) => + const toggleSelector = (event: MouseEvent) => { BatchUpdates(() => { @@ -41,26 +41,33 @@ export const ChatInputStyleSelectorView: FC = p if(visible) setTarget((event.target as (EventTarget & HTMLElement))); }) - }, []); + } + + useEffect(() => + { + if(selectorVisible) return; + + setTarget(null); + }, [ selectorVisible ]); return ( <> - + - - - + + + { chatStyleIds && (chatStyleIds.length > 0) && chatStyleIds.map((styleId) => { return ( - selectStyle(styleId) }> -
-
 
-
-
+ selectStyle(styleId) }> + +   + + ); }) } -
+
diff --git a/src/views/room/widgets/chat-input/ChatInputView.scss b/src/views/room/widgets/chat-input/ChatInputView.scss index 734dbcd2..f650fa62 100644 --- a/src/views/room/widgets/chat-input/ChatInputView.scss +++ b/src/views/room/widgets/chat-input/ChatInputView.scss @@ -4,11 +4,12 @@ align-items: center; position: relative; height: 40px; - border-radius: $border-radius; + border-radius: 8px; border: 2px solid rgb(0, 0, 0); background: #EDEDED; padding-right: 10px; width: 100%; + overflow: hidden; @include media-breakpoint-down(sm) { display: flex; @@ -21,9 +22,8 @@ &:before { content: ""; position: absolute; - width: 98%; + width: 100%; height: 5px; - border-radius: $border-radius; top: 1px; left: 0; right: 0; @@ -65,15 +65,6 @@ } } -.nitro-chat-style-selector-button { - position: absolute; - display: flex; - justify-content: center; - align-items: center; - height: 100%; - right: 7px; -} - .nitro-chat-style-selector-container { width: $chat-input-style-selector-widget-width; max-height: $chat-input-style-selector-widget-height; @@ -82,20 +73,12 @@ max-height: $chat-input-style-selector-widget-height !important; } - .grid-item { - font-size: $font-size-sm; - height: 30px !important; - border-color: unset !important; - border: 0 !important; - padding: 1px 3px; - - &:not(.active) { - background-color: unset !important; - } + .bubble-parent-container { + height: 30px; .bubble-container { - visibility: visible; - width: 75%; + position: relative; + width: 50px; } } } diff --git a/src/views/room/widgets/chat-input/ChatInputView.tsx b/src/views/room/widgets/chat-input/ChatInputView.tsx index ca2b54d7..ed1391cc 100644 --- a/src/views/room/widgets/chat-input/ChatInputView.tsx +++ b/src/views/room/widgets/chat-input/ChatInputView.tsx @@ -4,7 +4,7 @@ import { createPortal } from 'react-dom'; import { GetConfiguration, GetSessionDataManager, LocalizeText, RoomWidgetChatMessage, RoomWidgetChatTypingMessage, RoomWidgetUpdateChatInputContentEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRoomObjectEvent } from '../../../../api'; import { CreateEventDispatcherHook } from '../../../../hooks/events'; import { useRoomContext } from '../../context/RoomContext'; -import { ChatInputStyleSelectorView } from './style-selector/ChatInputStyleSelectorView'; +import { ChatInputStyleSelectorView } from './ChatInputStyleSelectorView'; export const ChatInputView: FC<{}> = props => { diff --git a/src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.types.ts b/src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.types.ts deleted file mode 100644 index 9df829be..00000000 --- a/src/views/room/widgets/chat-input/style-selector/ChatInputStyleSelectorView.types.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ChatInputStyleSelectorViewProps -{ - chatStyleId: number; - chatStyleIds: number[]; - selectChatStyleId: (styleId: number) => void; -} From c6512be476aaf8c519ff1d1c86e70d91db12c8a3 Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 1 Mar 2022 03:23:20 -0500 Subject: [PATCH 12/17] 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') } +