From a907b85514041b0f5881420962e7ef6ca1c1b2fa Mon Sep 17 00:00:00 2001 From: Bill Date: Tue, 6 Jul 2021 22:25:36 -0400 Subject: [PATCH] Trading --- src/assets/styles/scrollbars.scss | 26 +-- src/layout/card/NitroCardView.scss | 1 + src/layout/card/grid/NitroCardGridView.scss | 26 +++ src/layout/card/grid/NitroCardGridView.tsx | 15 ++ .../card/grid/NitroCardGridView.types.ts | 4 + .../card/grid/item/NitroCardGridItemView.scss | 47 ++++ .../card/grid/item/NitroCardGridItemView.tsx | 24 ++ .../grid/item/NitroCardGridItemView.types.ts | 10 + src/views/inventory/InventoryView.tsx | 61 ++--- src/views/inventory/InventoryView.types.ts | 8 +- .../reducers/InventoryFurnitureReducer.tsx | 1 - src/views/inventory/views/InventoryViews.scss | 2 - .../views/badge/InventoryBadgeView.scss | 6 +- .../InventoryActiveBadgeResultsView.scss | 2 - .../InventoryActiveBadgeResultsView.tsx | 5 +- .../badge/item/InventoryBadgeItemView.tsx | 9 +- .../results/InventoryBadgeResultsView.scss | 9 - .../results/InventoryBadgeResultsView.tsx | 17 +- .../inventory/views/bot/InventoryBotView.scss | 2 - .../views/bot/item/InventoryBotItemView.scss | 25 --- .../views/bot/item/InventoryBotItemView.tsx | 9 +- .../bot/results/InventoryBotResultsView.scss | 5 - .../bot/results/InventoryBotResultsView.tsx | 13 +- .../furniture/InventoryFurnitureView.scss | 4 - .../furniture/InventoryFurnitureView.tsx | 117 +--------- .../item/InventoryFurnitureItemView.scss | 25 --- .../item/InventoryFurnitureItemView.tsx | 17 +- .../InventoryFurnitureResultsView.scss | 2 - .../results/InventoryFurnitureResultsView.tsx | 17 +- .../InventoryFurnitureResultsView.types.ts | 1 + .../search/InventoryFurnitureSearchView.scss | 0 .../search/InventoryFurnitureSearchView.tsx | 2 +- .../inventory/views/pet/InventoryPetView.scss | 2 - .../views/pet/item/InventoryPetItemView.scss | 17 -- .../views/pet/item/InventoryPetItemView.tsx | 9 +- .../pet/results/InventoryPetResultsView.scss | 5 - .../pet/results/InventoryPetResultsView.tsx | 13 +- .../views/trade/InventoryTradeView.tsx | 211 ++++++++++++++++-- .../views/trade/InventoryTradeView.types.ts | 1 - .../trade/item/InventoryTradeItemView.tsx | 37 --- .../item/InventoryTradeItemView.types.ts | 6 - 41 files changed, 426 insertions(+), 387 deletions(-) create mode 100644 src/layout/card/grid/NitroCardGridView.scss create mode 100644 src/layout/card/grid/NitroCardGridView.tsx create mode 100644 src/layout/card/grid/NitroCardGridView.types.ts create mode 100644 src/layout/card/grid/item/NitroCardGridItemView.scss create mode 100644 src/layout/card/grid/item/NitroCardGridItemView.tsx create mode 100644 src/layout/card/grid/item/NitroCardGridItemView.types.ts delete mode 100644 src/views/inventory/views/badge/active-results/InventoryActiveBadgeResultsView.scss delete mode 100644 src/views/inventory/views/badge/results/InventoryBadgeResultsView.scss delete mode 100644 src/views/inventory/views/bot/InventoryBotView.scss delete mode 100644 src/views/inventory/views/bot/item/InventoryBotItemView.scss delete mode 100644 src/views/inventory/views/bot/results/InventoryBotResultsView.scss delete mode 100644 src/views/inventory/views/furniture/item/InventoryFurnitureItemView.scss delete mode 100644 src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss delete mode 100644 src/views/inventory/views/furniture/search/InventoryFurnitureSearchView.scss delete mode 100644 src/views/inventory/views/pet/InventoryPetView.scss delete mode 100644 src/views/inventory/views/pet/item/InventoryPetItemView.scss delete mode 100644 src/views/inventory/views/pet/results/InventoryPetResultsView.scss delete mode 100644 src/views/inventory/views/trade/item/InventoryTradeItemView.tsx delete mode 100644 src/views/inventory/views/trade/item/InventoryTradeItemView.types.ts 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/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/inventory/InventoryView.tsx b/src/views/inventory/InventoryView.tsx index 04f65231..a0905bc4 100644 --- a/src/views/inventory/InventoryView.tsx +++ b/src/views/inventory/InventoryView.tsx @@ -103,18 +103,23 @@ export const InventoryView: FC = props => } }, []); + useEffect(() => + { + if(!furnitureState.tradeData) return; + + setIsVisible(true); + }, [ furnitureState.tradeData ]); + useEffect(() => { if(!isVisible) { if(furnitureState.tradeData) { - setIsVisible(true); - - if(currentTab !== InventoryTabs.FURNITURE) setCurrentTab(InventoryTabs.FURNITURE); + // cancel the trade } } - }, [ furnitureState.tradeData, isVisible, currentTab ]); + }, [ furnitureState.tradeData, isVisible ]); return ( @@ -122,27 +127,33 @@ export const InventoryView: FC = props => { isVisible && setIsVisible(false) } /> - - { tabs.map((name, index) => - { - return ( - setCurrentTab(name) }> - { LocalizeText(name) } - - ); - }) } - - - { (currentTab === InventoryTabs.FURNITURE ) && - } - { (currentTab === InventoryTabs.BOTS ) && - } - { (currentTab === InventoryTabs.PETS ) && - } - { (currentTab === InventoryTabs.BADGES ) && - } - { furnitureState.tradeData && } - + { !furnitureState.tradeData && + <> + + { tabs.map((name, index) => + { + return ( + setCurrentTab(name) }> + { LocalizeText(name) } + + ); + }) } + + + { (currentTab === InventoryTabs.FURNITURE ) && + } + { (currentTab === InventoryTabs.BOTS ) && + } + { (currentTab === InventoryTabs.PETS ) && + } + { (currentTab === InventoryTabs.BADGES ) && + } + + } + { furnitureState.tradeData && + + + } } ); diff --git a/src/views/inventory/InventoryView.types.ts b/src/views/inventory/InventoryView.types.ts index ea815348..ee6e9307 100644 --- a/src/views/inventory/InventoryView.types.ts +++ b/src/views/inventory/InventoryView.types.ts @@ -3,8 +3,8 @@ export interface InventoryViewProps export class InventoryTabs { - public static readonly FURNITURE: string = 'inventory.furni'; - public static readonly BOTS: string = 'inventory.bots'; - public static readonly PETS: string = 'inventory.furni.tab.pets'; - public static readonly BADGES: string = 'inventory.badges'; + public static readonly FURNITURE: string = 'inventory.furni'; + public static readonly BOTS: string = 'inventory.bots'; + public static readonly PETS: string = 'inventory.furni.tab.pets'; + public static readonly BADGES: string = 'inventory.badges'; } diff --git a/src/views/inventory/reducers/InventoryFurnitureReducer.tsx b/src/views/inventory/reducers/InventoryFurnitureReducer.tsx index 51b380c6..cb4dbb1e 100644 --- a/src/views/inventory/reducers/InventoryFurnitureReducer.tsx +++ b/src/views/inventory/reducers/InventoryFurnitureReducer.tsx @@ -261,7 +261,6 @@ export const InventoryFurnitureReducer: Reducer + { badges && (badges.length > 0) && badges.map(code => { return }) } - + ); } diff --git a/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx b/src/views/inventory/views/badge/item/InventoryBadgeItemView.tsx index 1b9248b8..fc221a7d 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 89cb22ac..99f0693e 100644 --- a/src/views/inventory/views/furniture/InventoryFurnitureView.tsx +++ b/src/views/inventory/views/furniture/InventoryFurnitureView.tsx @@ -1,129 +1,26 @@ -import { FurnitureListComposer, IObjectData, RoomObjectVariable, TradingListAddItemComposer, TradingListAddItemsComposer, Vector3d } from 'nitro-renderer'; -import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { GetConnection, GetRoomEngine } from '../../../../api'; -import { SendMessageHook } from '../../../../hooks/messages/message-event'; +import { FurnitureListComposer, RoomObjectVariable, Vector3d } from 'nitro-renderer'; +import { FC, useEffect, useState } from 'react'; +import { GetRoomEngine } 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'; import { FurniCategory } from '../../common/FurniCategory'; import { attemptItemPlacement } from '../../common/FurnitureUtilities'; 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 { InventoryFurnitureViewProps } from './InventoryFurnitureView.types'; import { InventoryFurnitureResultsView } from './results/InventoryFurnitureResultsView'; import { InventoryFurnitureSearchView } from './search/InventoryFurnitureSearchView'; -const MAX_ITEMS_TO_TRADE: number = 3; - export const InventoryFurnitureView: FC = props => { const { roomSession = null, roomPreviewer = null } = props; const { furnitureState = null, dispatchFurnitureState = null } = useInventoryContext(); - const { needsFurniUpdate = false, groupItem = null, groupItems = [], tradeData = null } = furnitureState; + const { needsFurniUpdate = false, groupItem = null, groupItems = [] } = furnitureState; const [ filteredGroupItems, setFilteredGroupItems ] = useState(groupItems); - const isTrading = useMemo(() => - { - if(!tradeData) return false; - - return (tradeData.state >= TradeState.TRADING_STATE_RUNNING); - }, [ tradeData ]); - - 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 || !isTrading) 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 tradedIds: number[] = []; - - if(isTrading) - { - const ownItemCount = tradeData.ownUser.items.length; - - if((ownItemCount + itemIds.length) <= 1500) - { - if(!coreItem.isGroupable && (itemIds.length)) - { - GetConnection().send(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)) - { - tradedIds.push(itemId); - } - } - - if(tradedIds.length) - { - if(tradedIds.length === 1) - { - GetConnection().send(new TradingListAddItemComposer(tradedIds.pop())); - } - else - { - GetConnection().send(new TradingListAddItemsComposer(...tradedIds)); - } - } - } - } - else - { - //this._notificationService.alert('${trading.items.too_many_items.desc}', '${trading.items.too_many_items.title}'); - } - } - }, [ canTradeItem, groupItem, isTrading, tradeData ]); - useEffect(() => { if(needsFurniUpdate) @@ -233,10 +130,8 @@ export const InventoryFurnitureView: FC = props => { groupItem &&

{ groupItem.name }

- { !!roomSession && !isTrading && + { !!roomSession && } - { isTrading && - }
} 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 5079f367..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'; @@ -37,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 9df3889c..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 - }) } -
-
+ + { groupItems && (groupItems.length > 0) && groupItems.map((item, index) => + { + 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 index 88fe8f7f..212ca779 100644 --- a/src/views/inventory/views/trade/InventoryTradeView.tsx +++ b/src/views/inventory/views/trade/InventoryTradeView.tsx @@ -1,36 +1,203 @@ -import { FC } from 'react'; +import { FurnitureListComposer, IObjectData, TradingListAddItemComposer, TradingListAddItemsComposer, TradingListItemRemoveComposer } from 'nitro-renderer'; +import { FC, useCallback, useEffect, 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 { _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'; -import { InventoryTradeItemView } from './item/InventoryTradeItemView'; -const MAX_ITEMS_COUNT: number = 9; +const MAX_ITEMS_TO_TRADE: number = 9; export const InventoryTradeView: FC = props => { - const { isInFurnitureView = false } = props; - const { furnitureState = null } = useInventoryContext(); - const { tradeData = null } = furnitureState; + const { furnitureState = null, dispatchFurnitureState = null } = useInventoryContext(); + const { needsFurniUpdate = false, groupItems = [], tradeData = null } = furnitureState; + const [ groupItem, setGroupItem ] = useState(null); + const [ selectedGroupItem, setSelectedGroupItem ] = useState(null); + const [ filteredGroupItems, setFilteredGroupItems ] = useState(null); + + const close = useCallback(() => + { + + }, []); + + 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()); + } + else + { + setFilteredGroupItems(groupItems); + } + + }, [ needsFurniUpdate, groupItems, dispatchFurnitureState ]); return ( -
-
-
{ LocalizeText('inventory.trading.you') }
-
- { Array.from(Array(MAX_ITEMS_COUNT), (e, i) => - { - return ; - }) } -
+
+
+ + + { filteredGroupItems && (filteredGroupItems.length > 0) && filteredGroupItems.map((item, index) => + { + const count = item.getUnlockedCount(); + + return ( + (count && setGroupItem(item)) }> + { ((count > 0) && (groupItem === item)) && + } + + ); + }) } +
-
+
+
{ LocalizeText('inventory.trading.you') }
+ + { Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) => + { + const item = (tradeData.ownUser.items.getWithIndex(i) || null); + + if(!item) return ; + + return ( + setSelectedGroupItem(item) }> + { (item === selectedGroupItem) && + } + + ); + }) } + +
+
{ tradeData.otherUser.userName }
-
- { Array.from(Array(MAX_ITEMS_COUNT), (e, i) => - { - return ; - }) } -
+ + { Array.from(Array(MAX_ITEMS_TO_TRADE), (e, i) => + { + const item = (tradeData.otherUser.items.getWithIndex(i) || null); + + if(!item) return ; + + return setSelectedGroupItem(item) } />; + }) } + +
+
+ plz
); diff --git a/src/views/inventory/views/trade/InventoryTradeView.types.ts b/src/views/inventory/views/trade/InventoryTradeView.types.ts index aa863e89..ee344ff2 100644 --- a/src/views/inventory/views/trade/InventoryTradeView.types.ts +++ b/src/views/inventory/views/trade/InventoryTradeView.types.ts @@ -1,4 +1,3 @@ export interface InventoryTradeViewProps { - isInFurnitureView: boolean; } diff --git a/src/views/inventory/views/trade/item/InventoryTradeItemView.tsx b/src/views/inventory/views/trade/item/InventoryTradeItemView.tsx deleted file mode 100644 index 75627b04..00000000 --- a/src/views/inventory/views/trade/item/InventoryTradeItemView.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import { FC, useCallback } from 'react'; -import { LimitedEditionStyledNumberView } from '../../../../shared/limited-edition/styled-number/LimitedEditionStyledNumberView'; -import { InventoryTradeItemViewProps } from './InventoryTradeItemView.types'; - -export const InventoryTradeItemView: FC = props => -{ - const { groupItem = null } = props; - - const onClick = useCallback(() => - { - - }, []); - - if(!groupItem) - { - return ( -
-
-
- ); - } - - const imageUrl = `url(${ groupItem.iconUrl })`; - - return ( -
-
- { groupItem.getUnlockedCount() > 1 && - { groupItem.getUnlockedCount() } } - { groupItem.stuffData.isUnique && -
- -
} -
-
- ); -} diff --git a/src/views/inventory/views/trade/item/InventoryTradeItemView.types.ts b/src/views/inventory/views/trade/item/InventoryTradeItemView.types.ts deleted file mode 100644 index 29740d21..00000000 --- a/src/views/inventory/views/trade/item/InventoryTradeItemView.types.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { GroupItem } from '../../../common/GroupItem'; - -export interface InventoryTradeItemViewProps -{ - groupItem: GroupItem; -}