From e8316e3837873b859b8cc3b43401e70bd2edfb2c Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 6 Mar 2022 22:15:49 -0500 Subject: [PATCH] Update SoundNames --- src/api/utils/PlaySound.ts | 7 ------- src/api/utils/SoundNames.ts | 9 +++++++++ src/api/utils/index.ts | 1 + src/common/layout/LayoutMiniCameraView.tsx | 6 +++--- .../camera/views/capture/CameraWidgetCaptureView.tsx | 4 ++-- src/components/catalog/CatalogView.tsx | 4 ++-- src/components/mod-tools/ModToolsMessageHandler.tsx | 4 ++-- src/components/purse/PurseView.tsx | 6 +++--- .../friends/views/messenger/FriendsMessengerView.tsx | 6 +++--- 9 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 src/api/utils/SoundNames.ts diff --git a/src/api/utils/PlaySound.ts b/src/api/utils/PlaySound.ts index d07ceb7c..2c4bc026 100644 --- a/src/api/utils/PlaySound.ts +++ b/src/api/utils/PlaySound.ts @@ -5,10 +5,3 @@ export function PlaySound(sampleCode: string): void { DispatchMainEvent(new NitroSoundEvent(NitroSoundEvent.PLAY_SOUND, sampleCode)); } - -export const CAMERA_SHUTTER = 'camera_shutter'; -export const CREDITS = 'credits'; -export const DUCKETS = 'duckets'; -export const MESSENGER_NEW_THREAD = 'messenger_new_thread'; -export const MESSENGER_MESSAGE_RECEIVED = 'messenger_message_received'; -export const MODTOOLS_NEW_TICKET = 'modtools_new_ticket'; diff --git a/src/api/utils/SoundNames.ts b/src/api/utils/SoundNames.ts new file mode 100644 index 00000000..4459651b --- /dev/null +++ b/src/api/utils/SoundNames.ts @@ -0,0 +1,9 @@ +export class SoundNames +{ + public static CAMERA_SHUTTER = 'camera_shutter'; + public static CREDITS = 'credits'; + public static DUCKETS = 'duckets'; + public static MESSENGER_NEW_THREAD = 'messenger_new_thread'; + public static MESSENGER_MESSAGE_RECEIVED = 'messenger_message_received'; + public static MODTOOLS_NEW_TICKET = 'modtools_new_ticket'; +} diff --git a/src/api/utils/index.ts b/src/api/utils/index.ts index 39c45b00..427b5a25 100644 --- a/src/api/utils/index.ts +++ b/src/api/utils/index.ts @@ -6,3 +6,4 @@ export * from './LocalizeShortNumber'; export * from './LocalizeText'; export * from './PlaySound'; export * from './Randomizer'; +export * from './SoundNames'; diff --git a/src/common/layout/LayoutMiniCameraView.tsx b/src/common/layout/LayoutMiniCameraView.tsx index 0f7dfb0c..0a8fb07b 100644 --- a/src/common/layout/LayoutMiniCameraView.tsx +++ b/src/common/layout/LayoutMiniCameraView.tsx @@ -1,7 +1,7 @@ import { NitroRectangle, NitroRenderTexture } from '@nitrots/nitro-renderer'; import { FC, useCallback, useRef } from 'react'; -import { GetRoomEngine, LocalizeText } from '../../api'; -import { CAMERA_SHUTTER, PlaySound } from '../../api/utils/PlaySound'; +import { GetRoomEngine, LocalizeText, SoundNames } from '../../api'; +import { PlaySound } from '../../api/utils/PlaySound'; import { DraggableWindow } from '../draggable-window'; interface LayoutMiniCameraViewProps @@ -27,7 +27,7 @@ export const LayoutMiniCameraView: FC = props => const takePicture = useCallback(() => { - PlaySound(CAMERA_SHUTTER); + PlaySound(SoundNames.CAMERA_SHUTTER); textureReceiver(GetRoomEngine().createTextureFromRoom(roomId, 1, getCameraBounds())); }, [ roomId, getCameraBounds, textureReceiver ]); diff --git a/src/components/camera/views/capture/CameraWidgetCaptureView.tsx b/src/components/camera/views/capture/CameraWidgetCaptureView.tsx index 80590d82..4a4fb03b 100644 --- a/src/components/camera/views/capture/CameraWidgetCaptureView.tsx +++ b/src/components/camera/views/capture/CameraWidgetCaptureView.tsx @@ -1,7 +1,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { NitroRectangle, TextureUtils } from '@nitrots/nitro-renderer'; import { FC, useCallback, useRef } from 'react'; -import { CAMERA_SHUTTER, GetRoomEngine, GetRoomSession, LocalizeText, PlaySound } from '../../../../api'; +import { GetRoomEngine, GetRoomSession, LocalizeText, PlaySound, SoundNames } from '../../../../api'; import { Column, DraggableWindow, Flex } from '../../../../common'; import { NotificationUtilities } from '../../../../views/notification-center/common/NotificationUtilities'; import { useCameraWidgetContext } from '../../CameraWidgetContext'; @@ -52,7 +52,7 @@ export const CameraWidgetCaptureView: FC = props = clone.pop(); } - PlaySound(CAMERA_SHUTTER); + PlaySound(SoundNames.CAMERA_SHUTTER); clone.push(new CameraPicture(texture, TextureUtils.generateImageUrl(texture))); setCameraRoll(clone); diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index 36a5979a..115d2892 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -1,6 +1,6 @@ import { FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, GetMarketplaceConfigurationMessageComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { AddEventLinkTracker, CREDITS, GetRoomEngine, LocalizeText, PlaySound, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; +import { AddEventLinkTracker, GetRoomEngine, LocalizeText, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../api'; import { Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { CatalogPurchasedEvent } from '../../events'; import { BatchUpdates, UseUiEvent } from '../../hooks'; @@ -268,7 +268,7 @@ export const CatalogView: FC<{}> = props => const onCatalogPurchasedEvent = useCallback((event: CatalogPurchasedEvent) => { - PlaySound(CREDITS); + PlaySound(SoundNames.CREDITS); }, []); UseUiEvent(CatalogPurchasedEvent.PURCHASE_SUCCESS, onCatalogPurchasedEvent); diff --git a/src/components/mod-tools/ModToolsMessageHandler.tsx b/src/components/mod-tools/ModToolsMessageHandler.tsx index f68f7df8..e2b11619 100644 --- a/src/components/mod-tools/ModToolsMessageHandler.tsx +++ b/src/components/mod-tools/ModToolsMessageHandler.tsx @@ -1,6 +1,6 @@ import { CfhSanctionMessageEvent, CfhTopicsInitEvent, IssueDeletedMessageEvent, IssueInfoMessageEvent, IssuePickFailedMessageEvent, ModeratorActionResultMessageEvent, ModeratorInitMessageEvent, ModeratorToolPreferencesEvent, RoomEngineEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { MODTOOLS_NEW_TICKET, PlaySound } from '../../api'; +import { PlaySound, SoundNames } from '../../api'; import { ModToolsEvent, ModToolsOpenRoomChatlogEvent, ModToolsOpenRoomInfoEvent, ModToolsOpenUserChatlogEvent, ModToolsOpenUserInfoEvent } from '../../events'; import { UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { NotificationAlertType } from '../../views/notification-center/common/NotificationAlertType'; @@ -54,7 +54,7 @@ export const ModToolsMessageHandler: FC<{}> = props => else { newTickets.push(parser.issueData); - PlaySound(MODTOOLS_NEW_TICKET); + PlaySound(SoundNames.MODTOOLS_NEW_TICKET); } dispatchModToolsState({ diff --git a/src/components/purse/PurseView.tsx b/src/components/purse/PurseView.tsx index f664f23e..a21f04c9 100644 --- a/src/components/purse/PurseView.tsx +++ b/src/components/purse/PurseView.tsx @@ -1,6 +1,6 @@ import { ActivityPointNotificationMessageEvent, FriendlyTime, HabboClubLevelEnum, UserCreditsEvent, UserCurrencyComposer, UserCurrencyEvent, UserSubscriptionComposer, UserSubscriptionEvent, UserSubscriptionParser } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { CreateLinkEvent, CREDITS, DUCKETS, GetConfiguration, LocalizeText, PlaySound, SendMessageComposer } from '../../api'; +import { CreateLinkEvent, GetConfiguration, LocalizeText, PlaySound, SendMessageComposer, SoundNames } from '../../api'; import { Column, Flex, Grid, LayoutCurrencyIcon, Text } from '../../common'; import { HcCenterEvent, UserSettingsUIEvent } from '../../events'; import { DispatchUiEvent, UseMessageEventHook } from '../../hooks'; @@ -75,7 +75,7 @@ export const PurseView: FC<{}> = props => newValue.credits = parseFloat(parser.credits); - if(prevValue.credits !== newValue.credits) PlaySound(CREDITS); + if(prevValue.credits !== newValue.credits) PlaySound(SoundNames.CREDITS); return newValue; }); @@ -111,7 +111,7 @@ export const PurseView: FC<{}> = props => newValue.activityPoints.set(parser.type, parser.amount); - if(parser.type === 0) PlaySound(DUCKETS) + if(parser.type === 0) PlaySound(SoundNames.DUCKETS) return newValue; }); diff --git a/src/views/friends/views/messenger/FriendsMessengerView.tsx b/src/views/friends/views/messenger/FriendsMessengerView.tsx index 1f4368b5..fa42040b 100644 --- a/src/views/friends/views/messenger/FriendsMessengerView.tsx +++ b/src/views/friends/views/messenger/FriendsMessengerView.tsx @@ -1,6 +1,6 @@ import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer as SendMessageComposerPacket } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound, RemoveLinkEventTracker, SendMessageComposer } from '../../../../api'; +import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../../../api'; import { Base, Button, ButtonGroup, Column, Flex, Grid, LayoutAvatarImageView, LayoutBadgeImageView, LayoutItemCountView, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { FriendsMessengerIconEvent } from '../../../../events'; import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; @@ -127,7 +127,7 @@ export const FriendsMessengerView: FC<{}> = props => SendMessageComposer(new SendMessageComposerPacket(thread.participant.id, messageText)); - if(messageThreads.length === 1 && thread.groups.length === 1) PlaySound(MESSENGER_NEW_THREAD); + if(messageThreads.length === 1 && thread.groups.length === 1) PlaySound(SoundNames.MESSENGER_NEW_THREAD); thread.addMessage(GetSessionDataManager().userId, messageText, 0, null, MessengerThreadChat.CHAT); @@ -242,7 +242,7 @@ export const FriendsMessengerView: FC<{}> = props => } } - if(isUnread) PlaySound(MESSENGER_MESSAGE_RECEIVED); + if(isUnread) PlaySound(SoundNames.MESSENGER_MESSAGE_RECEIVED); DispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, isUnread ? FriendsMessengerIconEvent.UNREAD_ICON : FriendsMessengerIconEvent.SHOW_ICON)); }, [visibleThreads, updateValue]);