mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Merge branch '@update/inventory' into @update/friends
This commit is contained in:
commit
86d8ba31f5
@ -3,8 +3,8 @@
|
||||
"version": "2.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "cross-env BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
|
||||
"build": "cross-env GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
|
||||
"start": "cross-env SKIP_PREFLIGHT_CHECK=true BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
|
||||
"build": "cross-env SKIP_PREFLIGHT_CHECK=true GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
|
||||
"build:prod": "npx browserslist@latest --update-db && yarn build",
|
||||
"test": "craco test",
|
||||
"eject": "react-scripts eject"
|
||||
@ -14,7 +14,7 @@
|
||||
"@fortawesome/fontawesome-svg-core": "^6.1.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.1.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.17",
|
||||
"@nitrots/nitro-renderer": "^1.1.20",
|
||||
"@nitrots/nitro-renderer": "^1.1.21",
|
||||
"animate.css": "^4.1.1",
|
||||
"classnames": "^2.3.1",
|
||||
"cross-env": "^7.0.3",
|
||||
|
@ -1,28 +1,26 @@
|
||||
import { LocalizeText, NotificationUtilities } from '..';
|
||||
import { TradingNotificationType } from './TradingNotificationType';
|
||||
|
||||
export const TradingNotificationMessage = (type: number) =>
|
||||
export const TradingNotificationMessage = (type: number, otherUsername: string = '') =>
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case TradingNotificationType.ALERT_SCAM:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.other_not_offering'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
return;
|
||||
case TradingNotificationType.ALERT_OTHER_CANCELLED:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
return;
|
||||
case TradingNotificationType.ALERT_ALREADY_OPEN:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.already_open'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
return;
|
||||
case TradingNotificationType.ALERT_OTHER_DISABLED:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.others_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
case TradingNotificationType.HOTEL_TRADING_DISABLED:
|
||||
case TradingNotificationType.YOU_NOT_ALLOWED:
|
||||
case TradingNotificationType.THEY_NOT_ALLOWED:
|
||||
case TradingNotificationType.ROOM_DISABLED:
|
||||
case TradingNotificationType.YOU_OPEN:
|
||||
case TradingNotificationType.THEY_OPEN:
|
||||
NotificationUtilities.simpleAlert(LocalizeText(`inventory.trading.openfail.${ type }`, [ 'otherusername' ], [ otherUsername ]), null, null, null, LocalizeText('inventory.trading.openfail.title'));
|
||||
return;
|
||||
case TradingNotificationType.ERROR_WHILE_COMMIT:
|
||||
NotificationUtilities.simpleAlert(`${ LocalizeText('inventory.trading.notification.caption') }, ${ LocalizeText('inventory.trading.notification.commiterror.info') }`, null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
return;
|
||||
case TradingNotificationType.YOU_NOT_ALLOWED:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.own_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
case TradingNotificationType.THEY_CANCELLED:
|
||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
export class TradingNotificationType
|
||||
{
|
||||
public static ALERT_SCAM: number = 0;
|
||||
public static ALERT_OTHER_CANCELLED: number = 1;
|
||||
public static ALERT_ALREADY_OPEN: number = 2;
|
||||
public static ALERT_OTHER_DISABLED: number = 3;
|
||||
public static ERROR_WHILE_COMMIT: number = 4;
|
||||
public static YOU_NOT_ALLOWED: number = 5;
|
||||
public static HOTEL_TRADING_DISABLED = 1;
|
||||
public static YOU_NOT_ALLOWED: number = 2;
|
||||
public static THEY_NOT_ALLOWED: number = 4;
|
||||
public static ROOM_DISABLED: number = 6;
|
||||
public static YOU_OPEN: number = 7;
|
||||
public static THEY_OPEN: number = 8;
|
||||
public static ERROR_WHILE_COMMIT: number = 9;
|
||||
public static THEY_CANCELLED: number = 10;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ interface InventoryFurnitureViewProps
|
||||
export const InventoryFurnitureView: FC<InventoryFurnitureViewProps> = props =>
|
||||
{
|
||||
const { roomSession = null, roomPreviewer = null } = props;
|
||||
const { groupItems = [], selectedItem = null, selectItem = null } = useInventoryFurni();
|
||||
const [ filteredGroupItems, setFilteredGroupItems ] = useState<GroupItem[]>(groupItems);
|
||||
const [ filteredGroupItems, setFilteredGroupItems ] = useState<GroupItem[]>([]);
|
||||
const { groupItems = [], selectedItem = null, selectItem = null, activate = null, deactivate = null } = useInventoryFurni();
|
||||
const { getCount = null, resetCategory = null } = useInventoryUnseenTracker();
|
||||
|
||||
useEffect(() =>
|
||||
@ -86,6 +86,13 @@ export const InventoryFurnitureView: FC<InventoryFurnitureViewProps> = props =>
|
||||
}
|
||||
}, [ groupItems, getCount, resetCategory ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const id = activate();
|
||||
|
||||
return () => deactivate(id);
|
||||
}, [ activate, deactivate ]);
|
||||
|
||||
if(!groupItems || !groupItems.length) return <InventoryCategoryEmptyView title={ LocalizeText('inventory.empty.title') } desc={ LocalizeText('inventory.empty.desc') } />;
|
||||
|
||||
const InventoryFurnitureItemView: FC<{ groupItem: GroupItem }> = props =>
|
||||
|
@ -94,7 +94,7 @@ export const UserSettingsView: FC<{}> = props =>
|
||||
|
||||
if(doUpdate) setUserSettings(clone);
|
||||
DispatchMainEvent(clone)
|
||||
}, [userSettings]);
|
||||
}, [ userSettings ]);
|
||||
|
||||
const saveRangeSlider = useCallback((type: string) =>
|
||||
{
|
||||
@ -104,14 +104,14 @@ export const UserSettingsView: FC<{}> = props =>
|
||||
SendMessageComposer(new UserSettingsSoundComposer(Math.round(userSettings.volumeSystem), Math.round(userSettings.volumeFurni), Math.round(userSettings.volumeTrax)));
|
||||
break;
|
||||
}
|
||||
}, [userSettings]);
|
||||
}, [ userSettings ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(!userSettings) return;
|
||||
|
||||
DispatchUiEvent(userSettings);
|
||||
}, [userSettings]);
|
||||
}, [ userSettings ]);
|
||||
|
||||
if(!isVisible) return null;
|
||||
|
||||
|
@ -258,17 +258,10 @@ export const useInventoryFurni = () =>
|
||||
const { setIsVisible, ...rest } = useBetween(useInventoryFurniState);
|
||||
const { isVisible = false, activate = null, deactivate = null } = useSharedVisibility();
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const id = activate();
|
||||
|
||||
return () => deactivate(id);
|
||||
}, [ activate, deactivate ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
setIsVisible(isVisible);
|
||||
}, [ isVisible, setIsVisible ]);
|
||||
|
||||
return { ...rest };
|
||||
return { activate, deactivate, ...rest };
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOpenFailedParser, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useBetween } from 'use-between';
|
||||
import { useInventoryFurni } from '.';
|
||||
import { BatchUpdates, UseMessageEventHook } from '..';
|
||||
@ -13,7 +13,7 @@ const useInventoryTradeState = () =>
|
||||
const [ ownUser, setOwnUser ] = useState<TradeUserData>(null);
|
||||
const [ otherUser, setOtherUser ] = useState<TradeUserData>(null);
|
||||
const [ tradeState, setTradeState ] = useState(TradeState.TRADING_STATE_READY);
|
||||
const { groupItems = [], setGroupItems = null } = useInventoryFurni();
|
||||
const { groupItems = [], setGroupItems = null, activate = null, deactivate = null } = useInventoryFurni();
|
||||
const isTrading = (tradeState >= TradeState.TRADING_STATE_RUNNING);
|
||||
|
||||
const progressTrade = () =>
|
||||
@ -126,7 +126,7 @@ const useInventoryTradeState = () =>
|
||||
{
|
||||
if(ownUser && (parser.userID !== ownUser.userId))
|
||||
{
|
||||
TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_CANCELLED);
|
||||
TradingNotificationMessage(TradingNotificationType.THEY_CANCELLED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,9 +294,7 @@ const useInventoryTradeState = () =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if((parser.reason !== TradingOpenFailedParser.REASON_YOU_ARE_ALREADY_TRADING && (parser.reason !== TradingOpenFailedParser.REASON_OTHER_USER_ALREADY_TRADING))) return;
|
||||
|
||||
TradingNotificationMessage(TradingNotificationType.ALERT_ALREADY_OPEN);
|
||||
TradingNotificationMessage(parser.reason, parser.otherUserName);
|
||||
}, []);
|
||||
|
||||
UseMessageEventHook(TradingOpenFailedEvent, onTradingOpenFailedEvent);
|
||||
@ -305,7 +303,7 @@ const useInventoryTradeState = () =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_DISABLED);
|
||||
TradingNotificationMessage(TradingNotificationType.THEY_NOT_ALLOWED);
|
||||
}, []);
|
||||
|
||||
UseMessageEventHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent);
|
||||
@ -319,6 +317,15 @@ const useInventoryTradeState = () =>
|
||||
|
||||
UseMessageEventHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(tradeState === TradeState.TRADING_STATE_READY) return;
|
||||
|
||||
const id = activate();
|
||||
|
||||
return () => deactivate(id);
|
||||
}, [ tradeState, activate, deactivate ]);
|
||||
|
||||
return { ownUser, otherUser, tradeState, setTradeState, isTrading, groupItems, progressTrade, removeItem, stopTrading };
|
||||
}
|
||||
|
||||
|
@ -1426,10 +1426,10 @@
|
||||
"@jridgewell/resolve-uri" "^3.0.3"
|
||||
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||
|
||||
"@nitrots/nitro-renderer@^1.1.20":
|
||||
version "1.1.20"
|
||||
resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.20.tgz#13fd468028542f777d2c1c7902f2247769ffd98d"
|
||||
integrity sha512-DVwM4M0Iofsgd94dVPoNmzPbt7YzVG5liupULIe+WHo2vhR8fEyq3E+cdQleXtr/MBODGXTHBrU0yL67YDpIRQ==
|
||||
"@nitrots/nitro-renderer@^1.1.21":
|
||||
version "1.1.21"
|
||||
resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.21.tgz#8d527d63510fb4c3003e7d48347cdd50b67bb5b1"
|
||||
integrity sha512-futoNgDy+wD1il7gEnKly/VlRdESJZrPkG9m+jDy3bswdpRZ0RAph1XYNpNzkSchpxXib2yuKMME6ePPct/l1A==
|
||||
dependencies:
|
||||
"@pixi/canvas-renderer" "^6.3.0"
|
||||
"@pixi/extract" "^6.3.0"
|
||||
|
Loading…
Reference in New Issue
Block a user