add constants

This commit is contained in:
dank074 2021-11-25 23:16:00 -06:00
parent 02e3e04fe7
commit caf6fe4b18
7 changed files with 21 additions and 14 deletions

View File

@ -5,3 +5,10 @@ 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';

View File

@ -1,7 +1,7 @@
import { NitroRectangle } from '@nitrots/nitro-renderer';
import { FC, useCallback, useRef } from 'react';
import { GetRoomEngine, LocalizeText } from '../../api';
import { PlaySound } from '../../api/utils/PlaySound';
import { CAMERA_SHUTTER, PlaySound } from '../../api/utils/PlaySound';
import { DraggableWindow } from '../draggable-window';
import { NitroLayoutMiniCameraViewProps } from './NitroLayoutMiniCameraView.types';
@ -21,7 +21,7 @@ export const NitroLayoutMiniCameraView: FC<NitroLayoutMiniCameraViewProps> = pro
const takePicture = useCallback(() =>
{
PlaySound('camera_shutter');
PlaySound(CAMERA_SHUTTER);
textureReceiver(GetRoomEngine().createTextureFromRoom(roomId, 1, getCameraBounds()));
}, [ roomId, getCameraBounds, textureReceiver ]);

View File

@ -1,7 +1,7 @@
import { NitroRectangle, TextureUtils } from '@nitrots/nitro-renderer';
import { FC, useCallback, useRef } from 'react';
import { GetRoomEngine, GetRoomSession, LocalizeText } from '../../../../api';
import { PlaySound } from '../../../../api/utils/PlaySound';
import { CAMERA_SHUTTER, PlaySound } from '../../../../api/utils/PlaySound';
import { DraggableWindow } from '../../../../layout';
import { CameraPicture } from '../../common/CameraPicture';
import { useCameraWidgetContext } from '../../context/CameraWidgetContext';
@ -45,7 +45,7 @@ export const CameraWidgetCaptureView: FC<CameraWidgetCaptureViewProps> = props =
clone.pop();
}
PlaySound('camera_shutter');
PlaySound(CAMERA_SHUTTER);
clone.push(new CameraPicture(texture, TextureUtils.generateImageUrl(texture)));
setCameraRoll(clone);

View File

@ -1,7 +1,7 @@
import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, ILinkEventTracker, INodeData, RoomPreviewer } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useReducer, useState } from 'react';
import { AddEventLinkTracker, GetRoomEngine, LocalizeText, RemoveLinkEventTracker } from '../../api';
import { PlaySound } from '../../api/utils/PlaySound';
import { CREDITS, PlaySound } from '../../api/utils/PlaySound';
import { CatalogEvent } from '../../events';
import { useUiEvent } from '../../hooks/events/ui/ui-event';
import { SendMessageHook } from '../../hooks/messages/message-event';
@ -49,7 +49,7 @@ export const CatalogView: FC<CatalogViewProps> = props =>
setIsVisible(value => !value);
return;
case CatalogEvent.PURCHASE_SUCCESS:
PlaySound('credits');
PlaySound(CREDITS);
return;
}

View File

@ -1,7 +1,7 @@
import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, SendMessageComposer } from '@nitrots/nitro-renderer';
import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { AddEventLinkTracker, GetUserProfile, LocalizeText, RemoveLinkEventTracker } from '../../../../api';
import { PlaySound } from '../../../../api/utils/PlaySound';
import { MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound } from '../../../../api/utils/PlaySound';
import { FriendsMessengerIconEvent } from '../../../../events';
import { BatchUpdates, CreateMessageHook, dispatchUiEvent, SendMessageHook } from '../../../../hooks';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutButton, NitroLayoutButtonGroup, NitroLayoutFlex, NitroLayoutFlexColumn } from '../../../../layout';
@ -115,7 +115,7 @@ export const FriendsMessengerView: FC<{}> = props =>
SendMessageHook(new SendMessageComposer(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(MESSENGER_NEW_THREAD);
thread.addMessage(0, messageText, 0, null, MessengerThreadChat.CHAT);
@ -230,7 +230,7 @@ export const FriendsMessengerView: FC<{}> = props =>
}
}
if(isUnread) PlaySound('messenger_message_received');
if(isUnread) PlaySound(MESSENGER_MESSAGE_RECEIVED);
dispatchUiEvent(new FriendsMessengerIconEvent(FriendsMessengerIconEvent.UPDATE_ICON, isUnread ? FriendsMessengerIconEvent.UNREAD_ICON : FriendsMessengerIconEvent.SHOW_ICON));
}, [ visibleThreads, updateValue ]);

View File

@ -1,6 +1,6 @@
import { CfhSanctionMessageEvent, CfhTopicsInitEvent, IssueDeletedMessageEvent, IssueInfoMessageEvent, IssuePickFailedMessageEvent, ModeratorActionResultMessageEvent, ModeratorInitMessageEvent, ModeratorToolPreferencesEvent, RoomEngineEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react';
import { PlaySound } from '../../api/utils/PlaySound';
import { MODTOOLS_NEW_TICKET, PlaySound } from '../../api/utils/PlaySound';
import { NotificationAlertEvent } from '../../events';
import { ModToolsEvent } from '../../events/mod-tools/ModToolsEvent';
import { ModToolsOpenRoomChatlogEvent } from '../../events/mod-tools/ModToolsOpenRoomChatlogEvent';
@ -58,7 +58,7 @@ export const ModToolsMessageHandler: FC<{}> = props =>
else
{
newTickets.push(parser.issueData);
PlaySound('modtools_new_ticket');
PlaySound(MODTOOLS_NEW_TICKET);
}
dispatchModToolsState({

View File

@ -1,6 +1,6 @@
import { ActivityPointNotificationMessageEvent, UserCreditsEvent, UserCurrencyEvent, UserSubscriptionEvent, UserSubscriptionParser } from '@nitrots/nitro-renderer';
import { FC, useCallback } from 'react';
import { PlaySound } from '../../api/utils/PlaySound';
import { CREDITS, DUCKETS, PlaySound } from '../../api/utils/PlaySound';
import { CreateMessageHook } from '../../hooks/messages/message-event';
import { usePurseContext } from './context/PurseContext';
import { PurseMessageHandlerProps } from './PurseMessageHandler.types';
@ -13,7 +13,7 @@ export const PurseMessageHandler: FC<PurseMessageHandlerProps> = props =>
{
const parser = event.getParser();
if(purse.credits && purse.credits !== parseFloat(parser.credits)) PlaySound('credits');
if(purse.credits && purse.credits !== parseFloat(parser.credits)) PlaySound(CREDITS);
purse.credits = parseFloat(parser.credits);
@ -35,7 +35,7 @@ export const PurseMessageHandler: FC<PurseMessageHandlerProps> = props =>
purse.activityPoints.set(parser.type, parser.amount);
if(parser.type === 0) PlaySound('duckets');
if(parser.type === 0) PlaySound(DUCKETS);
purse.notify();
}, [ purse ]);