diff --git a/src/assets/styles/scrollbars.scss b/src/assets/styles/scrollbars.scss index e9eee6a5..a011c8fa 100644 --- a/src/assets/styles/scrollbars.scss +++ b/src/assets/styles/scrollbars.scss @@ -1,25 +1,21 @@ ::-webkit-scrollbar { - width: 7px; - height: 5px; + width: 0.5rem; } ::-webkit-scrollbar-track { - border-radius: $border-radius; - background: rgba($black,.1); - box-shadow:inset 0 0 1px 1px rgba($black,.1); - padding-top:3px; + background-clip: padding-box; + border-right: 0.25rem solid rgba($black, .1); } ::-webkit-scrollbar-thumb { - border-radius: $border-radius; - background: rgba($primary,.4); - width: 4px; -} + background-clip: padding-box; + border-right: 0.25rem solid rgba($primary, .4); -::-webkit-scrollbar-thumb:hover { - background: rgba($primary,.8); -} + &:hover { + border-right: 0.25rem solid rgba($primary, .8); + } -::-webkit-scrollbar-thumb:active { - background: $secondary; + &:active { + border-right: 0.25rem solid $secondary; + } } diff --git a/src/assets/styles/utils.scss b/src/assets/styles/utils.scss index 69ce07fc..c2a43bac 100644 --- a/src/assets/styles/utils.scss +++ b/src/assets/styles/utils.scss @@ -14,6 +14,10 @@ transform: scale(2) translateZ(0); } +.opacity-0-5 { + opacity: 0.5; +} + .text-shadow { text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); } diff --git a/src/events/friend-list/FriendEnteredRoomEvent.ts b/src/events/friend-list/FriendEnteredRoomEvent.ts new file mode 100644 index 00000000..5a7755eb --- /dev/null +++ b/src/events/friend-list/FriendEnteredRoomEvent.ts @@ -0,0 +1,11 @@ +import { RoomWidgetObjectNameEvent } from '../../views/room/events'; + +export class FriendEnteredRoomEvent extends RoomWidgetObjectNameEvent +{ + public static ENTERED: string = 'FERE_ENTERED'; + + constructor(roomIndex: number, category: number, id: number, name: string, userType: number) + { + super(FriendEnteredRoomEvent.ENTERED, roomIndex, category, id, name, userType); + } +} diff --git a/src/events/friend-list/index.ts b/src/events/friend-list/index.ts index 413293c4..4789fde9 100644 --- a/src/events/friend-list/index.ts +++ b/src/events/friend-list/index.ts @@ -1 +1,2 @@ +export * from './FriendEnteredRoomEvent'; export * from './FriendListEvent'; diff --git a/src/events/inventory/InventoryTradeRequestEvent.ts b/src/events/inventory/InventoryTradeRequestEvent.ts new file mode 100644 index 00000000..8cc0ee9f --- /dev/null +++ b/src/events/inventory/InventoryTradeRequestEvent.ts @@ -0,0 +1,27 @@ +import { InventoryEvent } from './InventoryEvent'; + +export class InventoryTradeRequestEvent extends InventoryEvent +{ + public static REQUEST_TRADE: string = 'ITSE_REQUEST_TRADE'; + + private _objectId: number; + private _username: string; + + constructor(objectId: number, username: string) + { + super(InventoryTradeRequestEvent.REQUEST_TRADE); + + this._objectId = objectId; + this._username = username; + } + + public get objectId(): number + { + return this._objectId; + } + + public get username(): string + { + return this._username; + } +} diff --git a/src/events/inventory/InventoryTradeStartEvent.ts b/src/events/inventory/InventoryTradeStartEvent.ts new file mode 100644 index 00000000..1724979d --- /dev/null +++ b/src/events/inventory/InventoryTradeStartEvent.ts @@ -0,0 +1,28 @@ +import { TradeUserData } from '../../views/inventory/common/TradeUserData'; +import { InventoryEvent } from './InventoryEvent'; + +export class InventoryTradeStartEvent extends InventoryEvent +{ + public static START_TRADE: string = 'ITSE_START_TRADE'; + + private _ownUserTradeData: TradeUserData; + private _otherUserTradeData: TradeUserData; + + constructor(ownUserTradeData: TradeUserData, otherUserTradeData: TradeUserData) + { + super(InventoryTradeStartEvent.START_TRADE); + + this._ownUserTradeData = ownUserTradeData; + this._otherUserTradeData = otherUserTradeData; + } + + public get ownUserTradeData(): TradeUserData + { + return this._ownUserTradeData; + } + + public get otherUserTradeData(): TradeUserData + { + return this._otherUserTradeData; + } +} diff --git a/src/events/inventory/index.ts b/src/events/inventory/index.ts index 6b5cf8e6..e795837f 100644 --- a/src/events/inventory/index.ts +++ b/src/events/inventory/index.ts @@ -1 +1,3 @@ export * from './InventoryEvent'; +export * from './InventoryTradeRequestEvent'; +export * from './InventoryTradeStartEvent'; diff --git a/src/layout/card/NitroCardView.scss b/src/layout/card/NitroCardView.scss index de37a762..44285071 100644 --- a/src/layout/card/NitroCardView.scss +++ b/src/layout/card/NitroCardView.scss @@ -6,6 +6,7 @@ $nitro-card-tabs-height: 33px; @import './accordion/NitroCardAccordionView'; @import './content/NitroCardContentView'; + @import './grid/NitroCardGridView'; @import './header/NitroCardHeaderView'; @import './tabs/NitroCardTabsView'; } diff --git a/src/layout/card/grid/NitroCardGridView.scss b/src/layout/card/grid/NitroCardGridView.scss new file mode 100644 index 00000000..44a1ee42 --- /dev/null +++ b/src/layout/card/grid/NitroCardGridView.scss @@ -0,0 +1,26 @@ +.nitro-card-grid { + + .row-cols-3 { + + .col { + padding-right: 0.25rem; + + &:nth-child(3n+3) { + padding-right: 0; + } + } + } + + .row-cols-5 { + + .col { + padding-right: 0.25rem; + + &:nth-child(5n+5) { + padding-right: 0; + } + } + } + + @import './item/NitroCardGridItemView.scss'; +} diff --git a/src/layout/card/grid/NitroCardGridView.tsx b/src/layout/card/grid/NitroCardGridView.tsx new file mode 100644 index 00000000..25b9fe47 --- /dev/null +++ b/src/layout/card/grid/NitroCardGridView.tsx @@ -0,0 +1,15 @@ +import { FC } from 'react'; +import { NitroCardGridViewProps } from './NitroCardGridView.types'; + +export const NitroCardGridView: FC = props => +{ + const { columns = 5, children = null } = props; + + return ( +
+
+ { children } +
+
+ ); +} diff --git a/src/layout/card/grid/NitroCardGridView.types.ts b/src/layout/card/grid/NitroCardGridView.types.ts new file mode 100644 index 00000000..b24763d1 --- /dev/null +++ b/src/layout/card/grid/NitroCardGridView.types.ts @@ -0,0 +1,4 @@ +export interface NitroCardGridViewProps +{ + columns?: number; +} diff --git a/src/layout/card/grid/item/NitroCardGridItemView.scss b/src/layout/card/grid/item/NitroCardGridItemView.scss new file mode 100644 index 00000000..988d0535 --- /dev/null +++ b/src/layout/card/grid/item/NitroCardGridItemView.scss @@ -0,0 +1,47 @@ +.grid-item-container { + height: 48px; + max-height: 48px; + + .grid-item { + width: 100%; + height: 100%; + border-color: $grid-border-color !important; + background-color: $grid-bg-color !important; + background-position: center; + background-repeat: no-repeat; + overflow: hidden; + + &.active { + border-color: $grid-active-border-color !important; + background-color: $grid-active-bg-color !important; + } + + .badge { + top: 2px; + right: 2px; + font-size: 8px; + } + + .avatar-image { + width: 100% !important; + height: 100% !important; + background-position: center; + background-repeat: no-repeat; + background-position-y: -32px !important; + } + + .trade-button { + position: absolute; + bottom: 2px; + right: 2px; + font-size: 5px; + padding: 3px; + min-height: unset; + + &.left { + right: unset; + left: 2px; + } + } + } +} diff --git a/src/layout/card/grid/item/NitroCardGridItemView.tsx b/src/layout/card/grid/item/NitroCardGridItemView.tsx new file mode 100644 index 00000000..904c4fea --- /dev/null +++ b/src/layout/card/grid/item/NitroCardGridItemView.tsx @@ -0,0 +1,24 @@ +import { FC } from 'react'; +import { LimitedEditionStyledNumberView } from '../../../../views/shared/limited-edition/styled-number/LimitedEditionStyledNumberView'; +import { NitroCardGridItemViewProps } from './NitroCardGridItemView.types'; + +export const NitroCardGridItemView: FC = props => +{ + const { itemActive = false, itemCount = 1, itemUnique = false, itemUniqueNumber = 0, itemImage = null, className = '', style = {}, children = null, ...rest } = props; + + const imageUrl = `url(${ itemImage })`; + + return ( +
+
+ { (itemCount > 1) && + { itemCount } } + { itemUnique && +
+ +
} + { children } +
+
+ ); +} diff --git a/src/layout/card/grid/item/NitroCardGridItemView.types.ts b/src/layout/card/grid/item/NitroCardGridItemView.types.ts new file mode 100644 index 00000000..20bda705 --- /dev/null +++ b/src/layout/card/grid/item/NitroCardGridItemView.types.ts @@ -0,0 +1,10 @@ +import { DetailsHTMLAttributes } from 'react'; + +export interface NitroCardGridItemViewProps extends DetailsHTMLAttributes +{ + itemImage?: string; + itemActive?: boolean; + itemCount?: number; + itemUnique?: boolean; + itemUniqueNumber?: number; +} diff --git a/src/views/catalog/views/navigation/item/CatalogNavigationItemView.tsx b/src/views/catalog/views/navigation/item/CatalogNavigationItemView.tsx index d1cdea58..4fcabb6b 100644 --- a/src/views/catalog/views/navigation/item/CatalogNavigationItemView.tsx +++ b/src/views/catalog/views/navigation/item/CatalogNavigationItemView.tsx @@ -44,7 +44,7 @@ export const CatalogNavigationItemView: FC = pro }, [ page, setActiveChild ]); return ( -
+
{ page.localization }
diff --git a/src/views/catalog/views/page/CatalogPageView.tsx b/src/views/catalog/views/page/CatalogPageView.tsx index 3b127509..f87b48fa 100644 --- a/src/views/catalog/views/page/CatalogPageView.tsx +++ b/src/views/catalog/views/page/CatalogPageView.tsx @@ -87,12 +87,10 @@ export const CatalogPageView: FC = props => return; } - // const windowData = Nitro.instance.sessionDataManager.getWallItemDataByName('ads_twi_windw'); + const windowData = GetSessionDataManager().getWallItemDataByName('noob_window_double'); + + if(windowData) roomPreviewer.addWallItemIntoRoom(windowData.id, new Vector3d(90, 0, 0), windowData.customParams); - // if(windowData) - // { - // this._roomPreviewer.addWallItemIntoRoom(windowData.id, new Vector3d(90), windowData.customParams) - // } return; } } diff --git a/src/views/catalog/views/page/layout/spaces-new/CatalogLayoutSpacesView.tsx b/src/views/catalog/views/page/layout/spaces-new/CatalogLayoutSpacesView.tsx index 5b56f6a3..54ca82e5 100644 --- a/src/views/catalog/views/page/layout/spaces-new/CatalogLayoutSpacesView.tsx +++ b/src/views/catalog/views/page/layout/spaces-new/CatalogLayoutSpacesView.tsx @@ -70,14 +70,12 @@ export const CatalogLayoutSpacesView: FC = props = return (
-
-
-
- { groupNames.map((name, index) => - { - return - })} -
+
+
+ { groupNames.map((name, index) => + { + return + })}
diff --git a/src/views/friend-list/FriendListView.tsx b/src/views/friend-list/FriendListView.tsx index defd406c..a620c0ea 100644 --- a/src/views/friend-list/FriendListView.tsx +++ b/src/views/friend-list/FriendListView.tsx @@ -1,8 +1,10 @@ -import { MessengerInitComposer } from 'nitro-renderer'; +import { MessengerInitComposer, RoomEngineObjectEvent, RoomObjectCategory } from 'nitro-renderer'; import React, { FC, useCallback, useEffect, useReducer, useState } from 'react'; import { createPortal } from 'react-dom'; -import { FriendListEvent } from '../../events'; -import { useUiEvent } from '../../hooks/events/ui/ui-event'; +import { GetRoomSession } from '../../api'; +import { FriendEnteredRoomEvent, FriendListEvent } from '../../events'; +import { useRoomEngineEvent } from '../../hooks/events'; +import { dispatchUiEvent, useUiEvent } from '../../hooks/events/ui/ui-event'; import { SendMessageHook } from '../../hooks/messages/message-event'; import { NitroCardAccordionItemView, NitroCardAccordionView, NitroCardHeaderView, NitroCardView } from '../../layout'; import { LocalizeText } from '../../utils/LocalizeText'; @@ -48,6 +50,30 @@ export const FriendListView: FC = props => SendMessageHook(new MessengerInitComposer()); }, []); + const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) => + { + const roomSession = GetRoomSession(); + + if(!roomSession) return; + + if(event.category !== RoomObjectCategory.UNIT) return; + + const userData = roomSession.userDataManager.getUserDataByIndex(event.objectId); + + if(!userData) return; + + const friend = friendListState.friends.find(friend => + { + return (friend.id === userData.webID); + }); + + if(!friend) return; + + dispatchUiEvent(new FriendEnteredRoomEvent(userData.roomIndex, RoomObjectCategory.UNIT, userData.webID, userData.name, userData.type)); + }, [ friendListState.friends ]); + + useRoomEngineEvent(RoomEngineObjectEvent.ADDED, onRoomEngineObjectEvent); + return ( diff --git a/src/views/friend-list/views/friend-bar/FriendBarView.tsx b/src/views/friend-list/views/friend-bar/FriendBarView.tsx index b1836e64..3931c4f4 100644 --- a/src/views/friend-list/views/friend-bar/FriendBarView.tsx +++ b/src/views/friend-list/views/friend-bar/FriendBarView.tsx @@ -36,7 +36,7 @@ export const FriendBarView: FC = props => { Array.from(Array(maxDisplayCount), (e, i) => { - return ; + return ; }) }
+ ); } diff --git a/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx b/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx index 1b9248b8..61b15095 100644 --- a/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx +++ b/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx @@ -1,5 +1,6 @@ import { MouseEventType } from 'nitro-renderer'; import { FC, MouseEvent, useCallback } from 'react'; +import { NitroCardGridItemView } from '../../../../../layout/card/grid/item/NitroCardGridItemView'; import { BadgeImageView } from '../../../../shared/badge-image/BadgeImageView'; import { useInventoryContext } from '../../../context/InventoryContext'; import { InventoryBadgeActions } from '../../../reducers/InventoryBadgeReducer'; @@ -24,10 +25,8 @@ export const InventoryBadgeItemView: FC = props => }, [ badge, dispatchBadgeState ]); return ( -
-
- -
-
+ + + ); } diff --git a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.scss b/src/views/inventory/views/badge/results/InventoryBadgeResultsView.scss deleted file mode 100644 index e9a6e5ee..00000000 --- a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.scss +++ /dev/null @@ -1,9 +0,0 @@ -.badge-item-container { - height: 139px; - max-height: 139px; - overflow-y: auto; -} - -.inventory-badge-overflow { - height:calc(100% - 86px) -} diff --git a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx b/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx index 66215373..5473e2b0 100644 --- a/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx +++ b/src/views/inventory/views/badge/results/InventoryBadgeResultsView.tsx @@ -1,4 +1,5 @@ import { FC } from 'react'; +import { NitroCardGridView } from '../../../../../layout/card/grid/NitroCardGridView'; import { InventoryBadgeItemView } from '../item/InventoryBadgeItemView'; import { InventoryBadgeResultsViewProps } from './InventoryBadgeResultsView.types'; @@ -7,15 +8,13 @@ export const InventoryBadgeResultsView: FC = pro const { badges = [], activeBadges = [] } = props; return ( -
-
+ { badges && (badges.length > 0) && badges.map(code => - { - if(activeBadges.indexOf(code) >= 0) return null; - - return - }) } -
-
+ { + if(activeBadges.indexOf(code) >= 0) return null; + + return + }) } + ); } diff --git a/src/views/inventory/views/bot/InventoryBotView.scss b/src/views/inventory/views/bot/InventoryBotView.scss deleted file mode 100644 index d82c5a47..00000000 --- a/src/views/inventory/views/bot/InventoryBotView.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import './item/InventoryBotItemView'; -@import './results/InventoryBotResultsView'; diff --git a/src/views/inventory/views/bot/item/InventoryBotItemView.scss b/src/views/inventory/views/bot/item/InventoryBotItemView.scss deleted file mode 100644 index 5de8916d..00000000 --- a/src/views/inventory/views/bot/item/InventoryBotItemView.scss +++ /dev/null @@ -1,25 +0,0 @@ -.inventory-bot-item-container { - height: 48px; - max-height: 48px; - - .inventory-bot-item { - width: 100%; - height: 100%; - border-color: $grid-border-color !important; - background-color: $grid-bg-color; - overflow: hidden; - - &.active { - border-color: $grid-active-border-color !important; - background-color: $grid-active-bg-color; - } - - .avatar-image { - width: 100% !important; - height: 100% !important; - background-position: center; - background-repeat: no-repeat; - background-position-y: -32px !important; - } - } -} diff --git a/src/views/inventory/views/bot/item/InventoryBotItemView.tsx b/src/views/inventory/views/bot/item/InventoryBotItemView.tsx index a08151cf..404deaf2 100644 --- a/src/views/inventory/views/bot/item/InventoryBotItemView.tsx +++ b/src/views/inventory/views/bot/item/InventoryBotItemView.tsx @@ -1,5 +1,6 @@ import { MouseEventType } from 'nitro-renderer'; import { FC, MouseEvent, useCallback, useState } from 'react'; +import { NitroCardGridItemView } from '../../../../../layout/card/grid/item/NitroCardGridItemView'; import { AvatarImageView } from '../../../../shared/avatar-image/AvatarImageView'; import { attemptBotPlacement } from '../../../common/BotUtilities'; import { useInventoryContext } from '../../../context/InventoryContext'; @@ -37,10 +38,8 @@ export const InventoryBotItemView: FC = props => }, [ isActive, isMouseDown, botItem, dispatchBotState ]); return ( -
-
- -
-
+ + + ); } diff --git a/src/views/inventory/views/bot/results/InventoryBotResultsView.scss b/src/views/inventory/views/bot/results/InventoryBotResultsView.scss deleted file mode 100644 index 097c92d8..00000000 --- a/src/views/inventory/views/bot/results/InventoryBotResultsView.scss +++ /dev/null @@ -1,5 +0,0 @@ -.bot-item-container { - height: 220px; - max-height: 220px; - overflow-y: auto; -} diff --git a/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx b/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx index 477c7bb4..fc2763ce 100644 --- a/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx +++ b/src/views/inventory/views/bot/results/InventoryBotResultsView.tsx @@ -1,4 +1,5 @@ import { FC } from 'react'; +import { NitroCardGridView } from '../../../../../layout/card/grid/NitroCardGridView'; import { InventoryBotItemView } from '../item/InventoryBotItemView'; import { InventoryBotResultsViewProps } from './InventoryBotResultsView.types'; @@ -7,13 +8,11 @@ export const InventoryBotResultsView: FC = props = const { botItems = [] } = props; return ( -
-
+ { botItems && (botItems.length > 0) && botItems.map(item => - { - return - }) } -
-
+ { + return + }) } + ); } diff --git a/src/views/inventory/views/furniture/InventoryFurnitureView.scss b/src/views/inventory/views/furniture/InventoryFurnitureView.scss index 19515f7a..f56fa741 100644 --- a/src/views/inventory/views/furniture/InventoryFurnitureView.scss +++ b/src/views/inventory/views/furniture/InventoryFurnitureView.scss @@ -3,7 +3,3 @@ top: 5px; right: 15px; } - -@import './item/InventoryFurnitureItemView'; -@import './results/InventoryFurnitureResultsView'; -@import './search/InventoryFurnitureSearchView'; diff --git a/src/views/inventory/views/furniture/InventoryFurnitureView.tsx b/src/views/inventory/views/furniture/InventoryFurnitureView.tsx index 644af8a1..be45bc0b 100644 --- a/src/views/inventory/views/furniture/InventoryFurnitureView.tsx +++ b/src/views/inventory/views/furniture/InventoryFurnitureView.tsx @@ -1,7 +1,7 @@ import { FurnitureListComposer, RoomObjectVariable, Vector3d } from 'nitro-renderer'; import { FC, useEffect, useState } from 'react'; -import { GetRoomEngine } from '../../../../api'; -import { SendMessageHook } from '../../../../hooks/messages/message-event'; +import { GetRoomEngine, GetSessionDataManager } from '../../../../api'; +import { SendMessageHook } from '../../../../hooks/messages'; import { LocalizeText } from '../../../../utils/LocalizeText'; import { LimitedEditionCompactPlateView } from '../../../shared/limited-edition/compact-plate/LimitedEditionCompactPlateView'; import { RoomPreviewerView } from '../../../shared/room-previewer/RoomPreviewerView'; @@ -80,9 +80,9 @@ export const InventoryFurnitureView: FC = props => if(furnitureItem.category === FurniCategory._Str_3432) { - // insert a window if the type is landscape - //_local_19 = this._model.controller._Str_18225("ads_twi_windw", ProductTypeEnum.WALL); - //this._roomPreviewer._Str_12087(_local_19.id, new Vector3d(90, 0, 0), _local_19._Str_4558); + const data = GetSessionDataManager().getWallItemDataByName('noob_window_double'); + + if(data) roomPreviewer.addWallItemIntoRoom(data.id, new Vector3d(90, 0, 0), data.customParams); } } else @@ -123,14 +123,16 @@ export const InventoryFurnitureView: FC = props =>
- { groupItem && groupItem.stuffData.isUnique && + { groupItem &&groupItem.stuffData.isUnique &&
} - { groupItem &&
-

{ groupItem.name }

- { !!roomSession && } -
} + { groupItem && +
+

{ groupItem.name }

+ { !!roomSession && + } +
}
); diff --git a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.scss b/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.scss deleted file mode 100644 index 824e17ce..00000000 --- a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.scss +++ /dev/null @@ -1,25 +0,0 @@ -.inventory-furniture-item-container { - height: 48px; - max-height: 48px; - - .inventory-furniture-item { - width: 100%; - height: 100%; - border-color: $grid-border-color !important; - background-color: $grid-bg-color !important; - background-position: center; - background-repeat: no-repeat; - overflow: hidden; - - &.active { - border-color: $grid-active-border-color !important; - background-color: $grid-active-bg-color !important; - } - - .badge { - top: 2px; - right: 2px; - font-size: 8px; - } - } -} diff --git a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx b/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx index 97d174c6..657ea66c 100644 --- a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx +++ b/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx @@ -1,6 +1,6 @@ import { MouseEventType } from 'nitro-renderer'; import { FC, MouseEvent, useCallback, useState } from 'react'; -import { LimitedEditionStyledNumberView } from '../../../../shared/limited-edition/styled-number/LimitedEditionStyledNumberView'; +import { NitroCardGridItemView } from '../../../../../layout/card/grid/item/NitroCardGridItemView'; import { attemptItemPlacement } from '../../../common/FurnitureUtilities'; import { useInventoryContext } from '../../../context/InventoryContext'; import { InventoryFurnitureActions } from '../../../reducers/InventoryFurnitureReducer'; @@ -10,6 +10,7 @@ export const InventoryFurnitureItemView: FC = p { const { groupItem } = props; const { furnitureState, dispatchFurnitureState } = useInventoryContext(); + const { tradeData = null } = furnitureState; const [ isMouseDown, setMouseDown ] = useState(false); const isActive = (furnitureState.groupItem === groupItem); @@ -36,18 +37,7 @@ export const InventoryFurnitureItemView: FC = p } }, [ isActive, isMouseDown, groupItem, dispatchFurnitureState ]); - const imageUrl = `url(${ groupItem.iconUrl })`; + const count = groupItem.getUnlockedCount(); - return ( -
-
- {groupItem.getUnlockedCount() > 1 && - {groupItem.getUnlockedCount()} } - { groupItem.stuffData.isUnique && -
- -
} -
-
- ); + return ; } diff --git a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss deleted file mode 100644 index 2d4f3402..00000000 --- a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss +++ /dev/null @@ -1,2 +0,0 @@ -.furni-item-container { -} diff --git a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx index 4b3ae59b..0464eb55 100644 --- a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx +++ b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx @@ -1,19 +1,18 @@ import { FC } from 'react'; +import { NitroCardGridView } from '../../../../../layout/card/grid/NitroCardGridView'; import { InventoryFurnitureItemView } from '../item/InventoryFurnitureItemView'; import { InventoryFurnitureResultsViewProps } from './InventoryFurnitureResultsView.types'; export const InventoryFurnitureResultsView: FC = props => { - const { groupItems = [] } = props; + const { groupItems = [], columns = 5 } = props; return ( -
-
+ { groupItems && (groupItems.length > 0) && groupItems.map((item, index) => - { - return - }) } -
-
+ { + return + }) } + ); } diff --git a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.types.ts b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.types.ts index a0bc56bd..9ee28fe5 100644 --- a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.types.ts +++ b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.types.ts @@ -3,4 +3,5 @@ import { GroupItem } from '../../../common/GroupItem'; export interface InventoryFurnitureResultsViewProps { groupItems: GroupItem[]; + columns?: number; } diff --git a/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.scss b/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.tsx b/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.tsx index e8d4f05c..841999b2 100644 --- a/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.tsx +++ b/src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.tsx @@ -15,7 +15,7 @@ export const InventoryFurnitureSearchView: FC { const comparison = searchValue.toLocaleLowerCase(); - filteredGroupItems = filteredGroupItems.filter(item => + filteredGroupItems = groupItems.filter(item => { if(comparison && comparison.length) { diff --git a/src/views/inventory/views/pet/InventoryPetView.scss b/src/views/inventory/views/pet/InventoryPetView.scss deleted file mode 100644 index 7afd161a..00000000 --- a/src/views/inventory/views/pet/InventoryPetView.scss +++ /dev/null @@ -1,2 +0,0 @@ -@import './item/InventoryPetItemView'; -@import './results/InventoryPetResultsView'; diff --git a/src/views/inventory/views/pet/item/InventoryPetItemView.scss b/src/views/inventory/views/pet/item/InventoryPetItemView.scss deleted file mode 100644 index 17156c99..00000000 --- a/src/views/inventory/views/pet/item/InventoryPetItemView.scss +++ /dev/null @@ -1,17 +0,0 @@ -.inventory-pet-item-container { - height: 48px; - max-height: 48px; - - .inventory-pet-item { - width: 100%; - height: 100%; - border-color: $grid-border-color !important; - background-color: $grid-bg-color; - overflow: hidden; - - &.active { - border-color: $grid-active-border-color!important; - background-color: $grid-active-bg-color; - } - } -} diff --git a/src/views/inventory/views/pet/item/InventoryPetItemView.tsx b/src/views/inventory/views/pet/item/InventoryPetItemView.tsx index cd99c6bc..d9a56dda 100644 --- a/src/views/inventory/views/pet/item/InventoryPetItemView.tsx +++ b/src/views/inventory/views/pet/item/InventoryPetItemView.tsx @@ -1,5 +1,6 @@ import { MouseEventType } from 'nitro-renderer'; import { FC, MouseEvent, useCallback, useState } from 'react'; +import { NitroCardGridItemView } from '../../../../../layout/card/grid/item/NitroCardGridItemView'; import { PetImageView } from '../../../../shared/pet-image/PetImageView'; import { attemptPetPlacement } from '../../../common/PetUtilities'; import { useInventoryContext } from '../../../context/InventoryContext'; @@ -37,10 +38,8 @@ export const InventoryPetItemView: FC = props => }, [ isActive, isMouseDown, petItem, dispatchPetState ]); return ( -
-
- -
-
+ + + ); } diff --git a/src/views/inventory/views/pet/results/InventoryPetResultsView.scss b/src/views/inventory/views/pet/results/InventoryPetResultsView.scss deleted file mode 100644 index f5a48826..00000000 --- a/src/views/inventory/views/pet/results/InventoryPetResultsView.scss +++ /dev/null @@ -1,5 +0,0 @@ -.pet-item-container { - height: 220px; - max-height: 220px; - overflow-y: auto; -} diff --git a/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx b/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx index 21e99114..fb7fae4f 100644 --- a/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx +++ b/src/views/inventory/views/pet/results/InventoryPetResultsView.tsx @@ -1,4 +1,5 @@ import { FC } from 'react'; +import { NitroCardGridView } from '../../../../../layout/card/grid/NitroCardGridView'; import { InventoryPetItemView } from '../item/InventoryPetItemView'; import { InventoryPetResultsViewProps } from './InventoryPetResultsView.types'; @@ -7,13 +8,11 @@ export const InventoryPetResultsView: FC = props = const { petItems = [] } = props; return ( -
-
+ { petItems && (petItems.length > 0) && petItems.map(item => - { - return - }) } -
-
+ { + return + }) } + ); } diff --git a/src/views/inventory/views/trade/InventoryTradeView.tsx b/src/views/inventory/views/trade/InventoryTradeView.tsx new file mode 100644 index 00000000..d7c6ad83 --- /dev/null +++ b/src/views/inventory/views/trade/InventoryTradeView.tsx @@ -0,0 +1,290 @@ +import { FurnitureListComposer, IObjectData, TradingAcceptComposer, TradingConfirmationComposer, TradingListAddItemComposer, TradingListAddItemsComposer, TradingListItemRemoveComposer, TradingUnacceptComposer } from 'nitro-renderer'; +import { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { SendMessageHook } from '../../../../hooks/messages'; +import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; +import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; +import { LocalizeText } from '../../../../utils/LocalizeText'; +import { FurniCategory } from '../../common/FurniCategory'; +import { GroupItem } from '../../common/GroupItem'; +import { IFurnitureItem } from '../../common/IFurnitureItem'; +import { TradeState } from '../../common/TradeState'; +import { _Str_16998 } from '../../common/TradingUtilities'; +import { useInventoryContext } from '../../context/InventoryContext'; +import { InventoryFurnitureActions } from '../../reducers/InventoryFurnitureReducer'; +import { InventoryFurnitureSearchView } from '../furniture/search/InventoryFurnitureSearchView'; +import { InventoryTradeViewProps } from './InventoryTradeView.types'; + +const MAX_ITEMS_TO_TRADE: number = 9; + +export const InventoryTradeView: FC = props => +{ + const { cancelTrade = null } = props; + const [ groupItem, setGroupItem ] = useState(null); + const [ ownGroupItem, setOwnGroupItem ] = useState(null); + const [ otherGroupItem, setOtherGroupItem ] = useState(null); + const [ filteredGroupItems, setFilteredGroupItems ] = useState(null); + const [ countdownTick, setCountdownTick ] = useState(3); + const { furnitureState = null, dispatchFurnitureState = null } = useInventoryContext(); + const { needsFurniUpdate = false, groupItems = [], tradeData = null } = furnitureState; + + const canTradeItem = useCallback((isWallItem: boolean, spriteId: number, category: number, groupable: boolean, stuffData: IObjectData) => + { + if(!tradeData || !tradeData.ownUser || tradeData.ownUser.accepts || !tradeData.ownUser.items) return false; + + if(tradeData.ownUser.items.length < MAX_ITEMS_TO_TRADE) return true; + + if(!groupable) return false; + + let type = spriteId.toString(); + + if(category === FurniCategory._Str_5186) + { + type = ((type + 'poster') + stuffData.getLegacyString()); + } + else + { + if(category === FurniCategory._Str_12454) + { + type = _Str_16998(spriteId, stuffData); + } + else + { + type = (((isWallItem) ? 'I' : 'S') + type); + } + } + + return !!tradeData.ownUser.items.getValue(type); + }, [ tradeData ]); + + const attemptItemOffer = useCallback((count: number) => + { + if(!tradeData || !groupItem) return; + + const tradeItems = groupItem.getTradeItems(count); + + if(!tradeItems || !tradeItems.length) return; + + let coreItem: IFurnitureItem = null; + const itemIds: number[] = []; + + for(const item of tradeItems) + { + itemIds.push(item.id); + + if(!coreItem) coreItem = item; + } + + const ownItemCount = tradeData.ownUser.items.length; + + if((ownItemCount + itemIds.length) <= 1500) + { + if(!coreItem.isGroupable && (itemIds.length)) + { + SendMessageHook(new TradingListAddItemComposer(itemIds.pop())); + } + else + { + const tradeIds: number[] = []; + + for(const itemId of itemIds) + { + if(canTradeItem(coreItem.isWallItem, coreItem.type, coreItem.category, coreItem.isGroupable, coreItem.stuffData)) + { + tradeIds.push(itemId); + } + } + + if(tradeIds.length) + { + if(tradeIds.length === 1) + { + SendMessageHook(new TradingListAddItemComposer(tradeIds.pop())); + } + else + { + SendMessageHook(new TradingListAddItemsComposer(...tradeIds)); + } + } + } + } + else + { + //this._notificationService.alert('${trading.items.too_many_items.desc}', '${trading.items.too_many_items.title}'); + } + }, [ groupItem, tradeData, canTradeItem ]); + + const removeItem = useCallback((group: GroupItem) => + { + const item = group.getLastItem(); + + if(!item) return; + + SendMessageHook(new TradingListItemRemoveComposer(item.id)); + }, []); + + useEffect(() => + { + if(needsFurniUpdate) + { + dispatchFurnitureState({ + type: InventoryFurnitureActions.SET_NEEDS_UPDATE, + payload: { + flag: false + } + }); + + SendMessageHook(new FurnitureListComposer()); + } + + }, [ needsFurniUpdate, groupItems, dispatchFurnitureState ]); + + const progressTrade = useCallback(() => + { + switch(tradeData.state) + { + case TradeState.TRADING_STATE_RUNNING: + if(!tradeData.otherUser.itemCount && !tradeData.ownUser.accepts) + { + //this._notificationService.alert('${inventory.trading.warning.other_not_offering}'); + } + + if(tradeData.ownUser.accepts) + { + SendMessageHook(new TradingUnacceptComposer()); + } + else + { + SendMessageHook(new TradingAcceptComposer()); + } + return; + case TradeState.TRADING_STATE_CONFIRMING: + SendMessageHook(new TradingConfirmationComposer()); + + dispatchFurnitureState({ + type: InventoryFurnitureActions.SET_TRADE_STATE, + payload: { + tradeState: TradeState.TRADING_STATE_CONFIRMED + } + }); + return; + } + }, [ tradeData, dispatchFurnitureState ]); + + const getTradeButton = useMemo(() => + { + if(!tradeData) return null; + + switch(tradeData.state) + { + case TradeState.TRADING_STATE_READY: + return ; + case TradeState.TRADING_STATE_RUNNING: + return ; + case TradeState.TRADING_STATE_COUNTDOWN: + return ; + case TradeState.TRADING_STATE_CONFIRMING: + return ; + case TradeState.TRADING_STATE_CONFIRMED: + return ; + } + }, [ tradeData, countdownTick, progressTrade ]); + + useEffect(() => + { + if(!tradeData || (tradeData.state !== TradeState.TRADING_STATE_COUNTDOWN)) return; + + setCountdownTick(3); + + const interval = setInterval(() => + { + setCountdownTick(prevValue => + { + const newValue = (prevValue - 1); + + if(newValue === -1) + { + dispatchFurnitureState({ + type: InventoryFurnitureActions.SET_TRADE_STATE, + payload: { + tradeState: TradeState.TRADING_STATE_CONFIRMING + } + }); + + clearInterval(interval); + } + + return newValue; + }); + }, 1000); + + return () => + { + clearInterval(interval); + } + }, [ tradeData, dispatchFurnitureState ]); + + return ( +
+
+ + + { filteredGroupItems && (filteredGroupItems.length > 0) && filteredGroupItems.map((item, index) => + { + const count = item.getUnlockedCount(); + + return ( + (count && setGroupItem(item)) }> + { ((count > 0) && (groupItem === item)) && + } + + ); + }) } + +
{ groupItem ? groupItem.name : LocalizeText('catalog_selectproduct') }
+
+
+
+ { LocalizeText('inventory.trading.you') } { LocalizeText('inventory.trading.areoffering') }: + + { Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) => + { + const item = (tradeData.ownUser.items.getWithIndex(i) || null); + + if(!item) return ; + + return ( + setOwnGroupItem(item) }> + { (ownGroupItem === item) && + } + + ); + }) } +
{ ownGroupItem ? ownGroupItem.name : LocalizeText('catalog_selectproduct') }
+
+
+
+ { tradeData.otherUser.userName } { LocalizeText('inventory.trading.isoffering') }: + + { Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) => + { + const item = (tradeData.otherUser.items.getWithIndex(i) || null); + + if(!item) return ; + + return setOtherGroupItem(item) } />; + }) } +
{ otherGroupItem ? otherGroupItem.name : LocalizeText('catalog_selectproduct') }
+
+
+
+ + { getTradeButton } +
+
+
+ ); +} diff --git a/src/views/inventory/views/trade/InventoryTradeView.types.ts b/src/views/inventory/views/trade/InventoryTradeView.types.ts new file mode 100644 index 00000000..c71fe143 --- /dev/null +++ b/src/views/inventory/views/trade/InventoryTradeView.types.ts @@ -0,0 +1,4 @@ +export interface InventoryTradeViewProps +{ + cancelTrade: () => void; +} diff --git a/src/views/purse/PurseView.tsx b/src/views/purse/PurseView.tsx index 15932d13..8ab722ca 100644 --- a/src/views/purse/PurseView.tsx +++ b/src/views/purse/PurseView.tsx @@ -37,11 +37,11 @@ export const PurseView: FC = props =>
- { currencies && currencies.map((currency, index) => + { currencies && currencies.map(currency => { if(displayedCurrencies.indexOf(currency.type) === -1) return null; - return ; + return ; }) }
diff --git a/src/views/room/events/RoomWidgetObjectNameEvent.ts b/src/views/room/events/RoomWidgetObjectNameEvent.ts index 2a3773e4..87fbe42f 100644 --- a/src/views/room/events/RoomWidgetObjectNameEvent.ts +++ b/src/views/room/events/RoomWidgetObjectNameEvent.ts @@ -10,9 +10,9 @@ export class RoomWidgetObjectNameEvent extends RoomWidgetUpdateEvent private _name: string; private _userType: number; - constructor(roomIndex: number, category: number, id: number, name: string, userType: number) + constructor(type: string, roomIndex: number, category: number, id: number, name: string, userType: number) { - super(RoomWidgetObjectNameEvent.TYPE); + super(type); this._roomIndex = roomIndex; this._category = category; diff --git a/src/views/room/handlers/RoomWidgetInfostandHandler.ts b/src/views/room/handlers/RoomWidgetInfostandHandler.ts index 868911a7..287c980c 100644 --- a/src/views/room/handlers/RoomWidgetInfostandHandler.ts +++ b/src/views/room/handlers/RoomWidgetInfostandHandler.ts @@ -1,6 +1,6 @@ import { IFurnitureData, Nitro, NitroEvent, ObjectDataFactory, PetFigureData, PetType, RoomAdsUpdateComposer, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectOperationType, RoomObjectType, RoomObjectVariable, RoomSessionPetInfoUpdateEvent, RoomSessionUserBadgesEvent, RoomTradingLevelEnum, RoomUnitDropHandItemComposer, RoomUnitGiveHandItemComposer, RoomUnitGiveHandItemPetComposer, RoomUserData, RoomWidgetEnumItemExtradataParameter, SecurityLevel, Vector3d } from 'nitro-renderer'; import { GetConnection, GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture } from '../../../api'; -import { WiredSelectObjectEvent } from '../../../events'; +import { InventoryTradeRequestEvent, WiredSelectObjectEvent } from '../../../events'; import { dispatchUiEvent } from '../../../hooks/events'; import { LocalizeText } from '../../../utils/LocalizeText'; import { RoomWidgetObjectNameEvent, RoomWidgetUpdateChatInputContentEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../events'; @@ -114,7 +114,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler this.container.roomSession.sendTakeRightsMessage((message as RoomWidgetUserActionMessage).userId); break; case RoomWidgetUserActionMessage.START_TRADING: - //if(userData) this._widget.inventoryTrading.startTrade(userData.roomIndex, userData.name); + dispatchUiEvent(new InventoryTradeRequestEvent(userData.roomIndex, userData.name)); break; // case RoomWidgetUserActionMessage.RWUAM_OPEN_HOME_PAGE: // this._container.sessionDataManager._Str_21275((message as RoomWidgetUserActionMessage).userId, _local_3.name); @@ -286,7 +286,7 @@ export class RoomWidgetInfostandHandler extends RoomWidgetHandler } } - if(name) this.container.eventDispatcher.dispatchEvent(new RoomWidgetObjectNameEvent(message.id, message.category, id, name, userType)); + if(name) this.container.eventDispatcher.dispatchEvent(new RoomWidgetObjectNameEvent(RoomWidgetObjectNameEvent.TYPE, message.id, message.category, id, name, userType)); return null; } diff --git a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx index 7d06c1e3..1514df9e 100644 --- a/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx +++ b/src/views/room/widgets/avatar-info/AvatarInfoWidgetView.tsx @@ -1,6 +1,8 @@ import { RoomEnterEffect, RoomObjectCategory } from 'nitro-renderer'; import { FC, useCallback, useMemo, useState } from 'react'; import { GetRoomSession, GetSessionDataManager } from '../../../../api'; +import { FriendEnteredRoomEvent } from '../../../../events'; +import { useUiEvent } from '../../../../hooks/events'; import { CreateEventDispatcherHook } from '../../../../hooks/events/event-dispatcher.base'; import { useRoomContext } from '../../context/RoomContext'; import { RoomWidgetObjectNameEvent, RoomWidgetRoomEngineUpdateEvent, RoomWidgetRoomObjectUpdateEvent, RoomWidgetUpdateDanceStatusEvent, RoomWidgetUpdateInfostandEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent, RoomWidgetUpdateRentableBotChatEvent } from '../../events'; @@ -19,12 +21,35 @@ export const AvatarInfoWidgetView: FC = props => { const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); const [ name, setName ] = useState(null); + const [ nameBubbles, setNameBubbles ] = useState([]); const [ infoStandEvent, setInfoStandEvent ] = useState(null); const [ isGameMode, setGameMode ] = useState(false); const [ isDancing, setIsDancing ] = useState(false); const [ isDecorating, setIsDecorating ] = useState(GetRoomSession().isDecorating); const [ rentableBotChatEvent, setRentableBotChatEvent ] = useState(null); + const removeNameBubble = useCallback((index: number) => + { + setNameBubbles(prevValue => + { + const newValue = [ ...prevValue ]; + + newValue.splice(index, 1); + + return newValue; + }); + }, []); + + const clearInfoStandEvent = useCallback(() => + { + setInfoStandEvent(null); + }, []); + + const clearName = useCallback(() => + { + setName(null); + }, []); + const onRoomWidgetRoomEngineUpdateEvent = useCallback((event: RoomWidgetRoomEngineUpdateEvent) => { switch(event.type) @@ -50,6 +75,16 @@ export const AvatarInfoWidgetView: FC = props => if(event.id === name.id) setName(null); } + if(event.category === RoomObjectCategory.UNIT) + { + const nameBubbleIndex = nameBubbles.findIndex(bubble => + { + return (bubble.roomIndex === event.id); + }); + + if(nameBubbleIndex > -1) removeNameBubble(nameBubbleIndex); + } + if(infoStandEvent) { if(infoStandEvent instanceof RoomWidgetUpdateInfostandFurniEvent) @@ -67,7 +102,7 @@ export const AvatarInfoWidgetView: FC = props => if(infoStandEvent.roomIndex === event.id) setInfoStandEvent(null); } } - }, [ name, infoStandEvent ]); + }, [ name, infoStandEvent, nameBubbles, removeNameBubble ]); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_REMOVED, eventDispatcher, onRoomObjectRemoved); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onRoomObjectRemoved); @@ -104,8 +139,6 @@ export const AvatarInfoWidgetView: FC = props => { if(!infoStandEvent) return; - console.log('tru') - setInfoStandEvent(null); }, [ infoStandEvent ]); @@ -142,26 +175,6 @@ export const AvatarInfoWidgetView: FC = props => CreateEventDispatcherHook(RoomWidgetUpdateDanceStatusEvent.UPDATE_DANCE, eventDispatcher, onRoomWidgetUpdateDanceStatusEvent); - const onRoomWidgetRoomObjectUpdateEvent = useCallback((event: RoomWidgetRoomObjectUpdateEvent) => - { - switch(event.type) - { - case RoomWidgetRoomObjectUpdateEvent.USER_ADDED: { - // bubble if friend - - return; - } - case RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED: { - // set if waiting for pet - - return; - } - } - }, []); - - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.USER_ADDED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); - CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.OBJECT_SELECTED, eventDispatcher, onRoomWidgetRoomObjectUpdateEvent); - const onRoomWidgetUpdateRentableBotChatEvent = useCallback((event: RoomWidgetUpdateRentableBotChatEvent) => { setRentableBotChatEvent(event); @@ -169,6 +182,16 @@ export const AvatarInfoWidgetView: FC = props => CreateEventDispatcherHook(RoomWidgetUpdateRentableBotChatEvent.UPDATE_CHAT, eventDispatcher, onRoomWidgetUpdateRentableBotChatEvent); + const onFriendEnteredRoomEvent = useCallback((event: FriendEnteredRoomEvent) => + { + setNameBubbles(prevValue => + { + return [ ...prevValue, event ]; + }) + }, []); + + useUiEvent(FriendEnteredRoomEvent.ENTERED, onFriendEnteredRoomEvent); + const decorateView = useMemo(() => { GetRoomSession().isDecorating = isDecorating; @@ -182,23 +205,23 @@ export const AvatarInfoWidgetView: FC = props => return ; }, [ isDecorating ]); - const clearInfoStandEvent = useCallback(() => - { - setInfoStandEvent(null); - }, []); - - const clearName = useCallback(() => - { - setName(null); - }, []); - const currentView = useMemo(() => { if(isGameMode) return null; if(decorateView) return decorateView; - if(name) return ; + if(name) + { + const nameBubbleIndex = nameBubbles.findIndex(bubble => + { + return (bubble.roomIndex === name.roomIndex); + }); + + if(nameBubbleIndex > -1) removeNameBubble(nameBubbleIndex); + + return ; + } if(infoStandEvent) { @@ -210,7 +233,12 @@ export const AvatarInfoWidgetView: FC = props => if(event.isSpectatorMode) return null; - // if existing name bubble remove it + const nameBubbleIndex = nameBubbles.findIndex(bubble => + { + return (bubble.roomIndex === event.roomIndex); + }); + + if(nameBubbleIndex > -1) removeNameBubble(nameBubbleIndex); if(event.isOwnUser) { @@ -241,11 +269,15 @@ export const AvatarInfoWidgetView: FC = props => } return null; - }, [ isGameMode, decorateView, name, isDancing, infoStandEvent, clearName, clearInfoStandEvent ]); + }, [ isGameMode, decorateView, name, nameBubbles, isDancing, infoStandEvent, clearName, clearInfoStandEvent, removeNameBubble ]); return ( <> { currentView } + { (nameBubbles.length > 0) && nameBubbles.map((name, index) => + { + return removeNameBubble(index) } />; + }) } { rentableBotChatEvent && } ) diff --git a/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx b/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx index 5a6d5355..2649b842 100644 --- a/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx +++ b/src/views/room/widgets/chat/message/ChatWidgetMessageView.tsx @@ -97,13 +97,12 @@ export const ChatWidgetMessageView: FC = props =>
- { chat.text } - { + { chat.text } + {/* { messageParts && messageParts.map((part, index) => { return { part.text } - }) - } + }) */}