mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-12-03 18:26:28 +01:00
Update inventory
This commit is contained in:
parent
72d5ef1a1f
commit
969d9f0c4e
@ -1,10 +1,11 @@
|
||||
import { AdvancedMap, BadgePointLimitsEvent, BadgeReceivedEvent, BadgesEvent, BotAddedToInventoryEvent, BotInventoryMessageEvent, BotRemovedFromInventoryEvent, FurnitureListAddOrUpdateEvent, FurnitureListEvent, FurnitureListInvalidateEvent, FurnitureListItemParser, FurnitureListRemovedEvent, FurniturePostItPlacedEvent, PetAddedToInventoryEvent, PetData, PetInventoryEvent, PetRemovedFromInventory, RequestBadgesComposer, TradingAcceptEvent, TradingCloseEvent, TradingCompletedEvent, TradingConfirmationEvent, TradingListItemEvent, TradingNotOpenEvent, TradingOpenEvent, TradingOpenFailedEvent, TradingOtherNotAllowedEvent, TradingYouAreNotAllowedEvent, UnseenItemsEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { GetLocalization, GetRoomSession, GetSessionDataManager } from '../../api';
|
||||
import { GetLocalization, GetRoomSession, GetSessionDataManager, LocalizeText } from '../../api';
|
||||
import { InventoryBadgesUpdatedEvent } from '../../events';
|
||||
import { InventoryBadgesRequestEvent } from '../../events/inventory/InventoryBadgesRequestEvent';
|
||||
import { dispatchUiEvent, useUiEvent } from '../../hooks';
|
||||
import { CreateMessageHook, SendMessageHook } from '../../hooks/messages/message-event';
|
||||
import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities';
|
||||
import { mergeFurniFragments } from './common/FurnitureUtilities';
|
||||
import { mergePetFragments } from './common/PetUtilities';
|
||||
import { TradeState } from './common/TradeState';
|
||||
@ -292,6 +293,8 @@ export const InventoryMessageHandler: FC<{}> = props =>
|
||||
const parser = event.getParser();
|
||||
|
||||
console.log(parser);
|
||||
|
||||
NotificationUtilities.simpleAlert(LocalizeText(`inventory.trading.openfail.${ parser.reason }`, [ 'otherusername' ], [ parser.otherUserName ]), null, null, null, LocalizeText('inventory.trading.openfail.title'));
|
||||
}, []);
|
||||
|
||||
const onTradingOtherNotAllowedEvent = useCallback((event: TradingOtherNotAllowedEvent) =>
|
||||
|
@ -7,4 +7,10 @@
|
||||
width: 129px;
|
||||
height: 181px;
|
||||
}
|
||||
|
||||
.trade-button {
|
||||
min-height: 0;
|
||||
font-size: 8px;
|
||||
padding: 1px 2px;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { MouseEventType } from '@nitrots/nitro-renderer';
|
||||
import { FC, MouseEvent, useCallback } from 'react';
|
||||
import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView';
|
||||
import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem';
|
||||
import { BadgeImageView } from '../../../../views/shared/badge-image/BadgeImageView';
|
||||
import { useInventoryContext } from '../../context/InventoryContext';
|
||||
import { InventoryBadgeActions } from '../../reducers/InventoryBadgeReducer';
|
||||
@ -28,8 +28,8 @@ export const InventoryBadgeItemView: FC<InventoryBadgeItemViewProps> = props =>
|
||||
}, [ badgeCode, dispatchBadgeState ]);
|
||||
|
||||
return (
|
||||
<NitroCardGridItemView itemActive={ (badgeState.badge === badgeCode) } onMouseDown={ onMouseEvent }>
|
||||
<LayoutGridItem itemActive={ (badgeState.badge === badgeCode) } onMouseDown={ onMouseEvent }>
|
||||
<BadgeImageView badgeCode={ badgeCode } />
|
||||
</NitroCardGridItemView>
|
||||
</LayoutGridItem>
|
||||
);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { MouseEventType } from '@nitrots/nitro-renderer';
|
||||
import { FC, MouseEvent, useCallback, useEffect, useState } from 'react';
|
||||
import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView';
|
||||
import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem';
|
||||
import { AvatarImageView } from '../../../../views/shared/avatar-image/AvatarImageView';
|
||||
import { BotItem } from '../../common/BotItem';
|
||||
import { attemptBotPlacement } from '../../common/BotUtilities';
|
||||
@ -50,8 +50,8 @@ export const InventoryBotItemView: FC<InventoryBotItemViewProps> = props =>
|
||||
}, [ isActive, botItem ]);
|
||||
|
||||
return (
|
||||
<NitroCardGridItemView itemActive={ isActive } itemUnseen={ botItem.isUnseen } onMouseDown={ onMouseEvent } onMouseUp={ onMouseEvent } onMouseOut={ onMouseEvent }>
|
||||
<LayoutGridItem itemActive={ isActive } itemUnseen={ botItem.isUnseen } onMouseDown={ onMouseEvent } onMouseUp={ onMouseEvent } onMouseOut={ onMouseEvent }>
|
||||
<AvatarImageView figure={ botItem.botData.figure } direction={ 3 } headOnly={ true } />
|
||||
</NitroCardGridItemView>
|
||||
</LayoutGridItem>
|
||||
);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ export const InventoryCategoryEmptyView: FC<InventoryCategoryEmptyViewProps> = p
|
||||
<div className="empty-image" />
|
||||
</Column>
|
||||
<Column justifyContent="center" size={ 7 } overflow="hidden">
|
||||
<Text fontWeight="bold" fontSize={ 5 } truncate>{ title }</Text>
|
||||
<Text fontWeight="bold" fontSize={ 5 } overflow="unset" truncate>{ title }</Text>
|
||||
<Text overflow="auto">{ desc }</Text>
|
||||
</Column>
|
||||
{ children }
|
||||
|
@ -14,8 +14,8 @@ export interface InventoryFurnitureItemViewProps
|
||||
export const InventoryFurnitureItemView: FC<InventoryFurnitureItemViewProps> = props =>
|
||||
{
|
||||
const { groupItem } = props;
|
||||
const { furnitureState, dispatchFurnitureState } = useInventoryContext();
|
||||
const [ isMouseDown, setMouseDown ] = useState(false);
|
||||
const { furnitureState, dispatchFurnitureState } = useInventoryContext();
|
||||
const isActive = (furnitureState.groupItem === groupItem);
|
||||
|
||||
const onMouseEvent = useCallback((event: MouseEvent) =>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { MouseEventType } from '@nitrots/nitro-renderer';
|
||||
import { FC, MouseEvent, useCallback, useEffect, useState } from 'react';
|
||||
import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView';
|
||||
import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem';
|
||||
import { PetImageView } from '../../../../views/shared/pet-image/PetImageView';
|
||||
import { PetItem } from '../../common/PetItem';
|
||||
import { attemptPetPlacement } from '../../common/PetUtilities';
|
||||
@ -15,8 +15,8 @@ export interface InventoryPetItemViewProps
|
||||
export const InventoryPetItemView: FC<InventoryPetItemViewProps> = props =>
|
||||
{
|
||||
const { petItem } = props;
|
||||
const { petState = null, dispatchPetState = null } = useInventoryContext();
|
||||
const [ isMouseDown, setMouseDown ] = useState(false);
|
||||
const { petState = null, dispatchPetState = null } = useInventoryContext();
|
||||
const isActive = (petState.petItem === petItem);
|
||||
|
||||
const onMouseEvent = useCallback((event: MouseEvent) =>
|
||||
@ -50,8 +50,8 @@ export const InventoryPetItemView: FC<InventoryPetItemViewProps> = props =>
|
||||
}, [ isActive, petItem ]);
|
||||
|
||||
return (
|
||||
<NitroCardGridItemView itemActive={ isActive } itemUnseen={ petItem.isUnseen } onMouseDown={ onMouseEvent } onMouseUp={ onMouseEvent } onMouseOut={ onMouseEvent }>
|
||||
<PetImageView figure={ petItem.petData.figureString } direction={ 3 } headOnly={ true } />
|
||||
</NitroCardGridItemView>
|
||||
<LayoutGridItem itemActive={ isActive } itemUnseen={ petItem.isUnseen } onMouseDown={ onMouseEvent } onMouseUp={ onMouseEvent } onMouseOut={ onMouseEvent }>
|
||||
<PetImageView figure={ petItem.petData.figureData.figuredata } scale={ 0.5 } />
|
||||
</LayoutGridItem>
|
||||
);
|
||||
}
|
||||
|
@ -7,9 +7,10 @@ import { Button } from '../../../../common/Button';
|
||||
import { Column } from '../../../../common/Column';
|
||||
import { Flex } from '../../../../common/Flex';
|
||||
import { Grid } from '../../../../common/Grid';
|
||||
import { LayoutGridItem } from '../../../../common/layout/LayoutGridItem';
|
||||
import { Text } from '../../../../common/Text';
|
||||
import { SendMessageHook } from '../../../../hooks/messages';
|
||||
import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView';
|
||||
import { NotificationUtilities } from '../../../../views/notification-center/common/NotificationUtilities';
|
||||
import { FurniCategory } from '../../common/FurniCategory';
|
||||
import { GroupItem } from '../../common/GroupItem';
|
||||
import { IFurnitureItem } from '../../common/IFurnitureItem';
|
||||
@ -156,7 +157,7 @@ export const InventoryTradeView: FC<InventoryTradeViewProps> = props =>
|
||||
case TradeState.TRADING_STATE_RUNNING:
|
||||
if(!tradeData.otherUser.itemCount && !tradeData.ownUser.accepts)
|
||||
{
|
||||
//this._notificationService.alert('${inventory.trading.warning.other_not_offering}');
|
||||
NotificationUtilities.simpleAlert(LocalizeText('${inventory.trading.warning.other_not_offering}'), null, null, null);
|
||||
}
|
||||
|
||||
if(tradeData.ownUser.accepts)
|
||||
@ -246,24 +247,26 @@ export const InventoryTradeView: FC<InventoryTradeViewProps> = props =>
|
||||
<Grid>
|
||||
<Column size={ 4 } overflow="hidden">
|
||||
<InventoryFurnitureSearchView groupItems={ groupItems } setGroupItems={ setFilteredGroupItems } />
|
||||
<Grid grow fullHeight columnCount={ 3 } overflow="auto">
|
||||
{ filteredGroupItems && (filteredGroupItems.length > 0) && filteredGroupItems.map((item, index) =>
|
||||
{
|
||||
const count = item.getUnlockedCount();
|
||||
<Flex column fullHeight justifyContent="between" overflow="hidden" gap={ 2 }>
|
||||
<Grid grow columnCount={ 3 } overflow="auto">
|
||||
{ filteredGroupItems && (filteredGroupItems.length > 0) && filteredGroupItems.map((item, index) =>
|
||||
{
|
||||
const count = item.getUnlockedCount();
|
||||
|
||||
return (
|
||||
<NitroCardGridItemView key={ index } className={ !count ? 'opacity-0-5 ' : '' } itemImage={ item.iconUrl } itemCount={ count } itemActive={ (groupItem === item) } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => (count && setGroupItem(item)) }>
|
||||
{ ((count > 0) && (groupItem === item)) &&
|
||||
<Button variant="success" size="sm" className="trade-button" onClick={ event => attemptItemOffer(1) }>
|
||||
<FontAwesomeIcon icon="chevron-right" />
|
||||
</Button> }
|
||||
</NitroCardGridItemView>
|
||||
);
|
||||
}) }
|
||||
</Grid>
|
||||
<Base fullWidth className="badge bg-muted">
|
||||
{ groupItem ? groupItem.name : LocalizeText('catalog_selectproduct') }
|
||||
</Base>
|
||||
return (
|
||||
<LayoutGridItem key={ index } className={ !count ? 'opacity-0-5 ' : '' } itemImage={ item.iconUrl } itemCount={ count } itemActive={ (groupItem === item) } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => (count && setGroupItem(item)) }>
|
||||
{ ((count > 0) && (groupItem === item)) &&
|
||||
<Button position="absolute" variant="success" size="sm" className="trade-button bottom-1 end-1" onClick={ event => attemptItemOffer(1) }>
|
||||
<FontAwesomeIcon icon="chevron-right" />
|
||||
</Button> }
|
||||
</LayoutGridItem>
|
||||
);
|
||||
}) }
|
||||
</Grid>
|
||||
<Base fullWidth className="badge bg-muted">
|
||||
{ groupItem ? groupItem.name : LocalizeText('catalog_selectproduct') }
|
||||
</Base>
|
||||
</Flex>
|
||||
</Column>
|
||||
<Column size={ 8 } overflow="hidden">
|
||||
<Grid overflow="hidden">
|
||||
@ -277,15 +280,15 @@ export const InventoryTradeView: FC<InventoryTradeViewProps> = props =>
|
||||
{
|
||||
const item = (tradeData.ownUser.items.getWithIndex(i) || null);
|
||||
|
||||
if(!item) return <NitroCardGridItemView key={ i } />;
|
||||
if(!item) return <LayoutGridItem key={ i } />;
|
||||
|
||||
return (
|
||||
<NitroCardGridItemView key={ i } itemActive={ (ownGroupItem === item) } itemImage={ item.iconUrl } itemCount={ item.getTotalCount() } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => setOwnGroupItem(item) }>
|
||||
<LayoutGridItem key={ i } itemActive={ (ownGroupItem === item) } itemImage={ item.iconUrl } itemCount={ item.getTotalCount() } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => setOwnGroupItem(item) }>
|
||||
{ (ownGroupItem === item) &&
|
||||
<Button variant="danger" size="sm" className="trade-button left" onClick={ event => removeItem(item) }>
|
||||
<Button position="absolute" variant="danger" size="sm" className="trade-button bottom-1 start-1" onClick={ event => removeItem(item) }>
|
||||
<FontAwesomeIcon icon="chevron-left" />
|
||||
</Button> }
|
||||
</NitroCardGridItemView>
|
||||
</LayoutGridItem>
|
||||
);
|
||||
}) }
|
||||
</Grid>
|
||||
@ -303,9 +306,9 @@ export const InventoryTradeView: FC<InventoryTradeViewProps> = props =>
|
||||
{
|
||||
const item = (tradeData.otherUser.items.getWithIndex(i) || null);
|
||||
|
||||
if(!item) return <NitroCardGridItemView key={ i } />;
|
||||
if(!item) return <LayoutGridItem key={ i } />;
|
||||
|
||||
return <NitroCardGridItemView key={ i } itemActive={ (otherGroupItem === item) } itemImage={ item.iconUrl } itemCount={ item.getTotalCount() } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => setOtherGroupItem(item) } />;
|
||||
return <LayoutGridItem key={ i } itemActive={ (otherGroupItem === item) } itemImage={ item.iconUrl } itemCount={ item.getTotalCount() } itemUniqueNumber={ item.stuffData.uniqueNumber } onClick={ event => setOtherGroupItem(item) } />;
|
||||
}) }
|
||||
</Grid>
|
||||
<Base fullWidth className="badge bg-muted w-100">
|
||||
|
Loading…
Reference in New Issue
Block a user