diff --git a/src/app/(frontend)/account/actions.ts b/src/app/(frontend)/account/actions.ts index abc0c32b..8819cbc2 100644 --- a/src/app/(frontend)/account/actions.ts +++ b/src/app/(frontend)/account/actions.ts @@ -211,6 +211,7 @@ export async function updatePreferences(input: { discordMutedTypes: string[]; xpDisplayMini: boolean; conversationTypewriter: "default" | "on" | "off"; + conversationTypewriterSound: boolean; conversationVoice: boolean; }): Promise { try { @@ -250,6 +251,7 @@ export async function updatePreferences(input: { }, dialogue: { typewriter: input.conversationTypewriter, + typewriterSound: input.conversationTypewriterSound, voice: input.conversationVoice, }, discord: { diff --git a/src/app/(frontend)/account/page.tsx b/src/app/(frontend)/account/page.tsx index 58aa48ee..0d64cf72 100644 --- a/src/app/(frontend)/account/page.tsx +++ b/src/app/(frontend)/account/page.tsx @@ -182,6 +182,9 @@ export default async function AccountPage() { showCallsign={fullUser.preferences?.display?.showCallsign ?? false} showVersionOverlay={fullUser.preferences?.display?.showVersionOverlay ?? true} conversationTypewriter={fullUser.preferences?.dialogue?.typewriter ?? "default"} + conversationTypewriterSound={ + fullUser.preferences?.dialogue?.typewriterSound !== false + } conversationVoice={fullUser.preferences?.dialogue?.voice !== false} showBackgroundTexture={fullUser.preferences?.display?.showBackgroundTexture ?? true} leadOrActual={fullUser.preferences?.display?.leadOrActual ?? "lead"} diff --git a/src/app/(frontend)/personnel/contacts/[id]/page.tsx b/src/app/(frontend)/personnel/contacts/[id]/page.tsx index 984c2192..9b77b7b3 100644 --- a/src/app/(frontend)/personnel/contacts/[id]/page.tsx +++ b/src/app/(frontend)/personnel/contacts/[id]/page.tsx @@ -188,6 +188,11 @@ export default async function NpcContactPage({ params }: NpcContactPageProps) { const voiceEnabled = dialogue ? (isPayloadUser(user) ? user.preferences?.dialogue?.voice : undefined) !== false : false; + // The typing sound has its own switch; it is silent anyway on lines that carry + // a recorded clip, so the two preferences do not have to agree. + const typewriterSoundEnabled = dialogue + ? (isPayloadUser(user) ? user.preferences?.dialogue?.typewriterSound : undefined) !== false + : false; return (
@@ -200,6 +205,7 @@ export default async function NpcContactPage({ params }: NpcContactPageProps) { dialogue={dialogue} initialSeenNodeIds={seenNodeIds} typewriter={typewriterEnabled} + typewriterSound={typewriterSoundEnabled} voice={voiceEnabled} /> } diff --git a/src/collections/users/Users.ts b/src/collections/users/Users.ts index cfa25b65..df2f4de9 100644 --- a/src/collections/users/Users.ts +++ b/src/collections/users/Users.ts @@ -342,6 +342,16 @@ export const Users: CollectionConfig = { "NPC dialogue lines type out letter by letter. Click a line to finish it immediately. Reduced-motion devices always show lines instantly.", }, }, + { + name: "typewriterSound", + label: "Typing sound in conversations", + type: "checkbox", + defaultValue: true, + admin: { + description: + "A soft key tick under lines that type out. Silent on lines with a recorded voice, and muted by the speaker button in a conversation header.", + }, + }, { name: "voice", label: "Play voice clips in conversations", diff --git a/src/components/command-palette/CommandPalette.tsx b/src/components/command-palette/CommandPalette.tsx index d32719e2..866bfa3c 100644 --- a/src/components/command-palette/CommandPalette.tsx +++ b/src/components/command-palette/CommandPalette.tsx @@ -118,6 +118,7 @@ export function CommandPalette({ discordMutedTypes: preferences?.discord?.mutedTypes ?? [], xpDisplayMini: preferences?.display?.xpDisplayMini ?? false, conversationTypewriter: preferences?.dialogue?.typewriter ?? "default", + conversationTypewriterSound: preferences?.dialogue?.typewriterSound !== false, conversationVoice: preferences?.dialogue?.voice !== false, }); if (result.success) { @@ -140,6 +141,7 @@ export function CommandPalette({ discordMutedTypes: preferences?.discord?.mutedTypes ?? [], xpDisplayMini: preferences?.display?.xpDisplayMini ?? false, conversationTypewriter: preferences?.dialogue?.typewriter ?? "default", + conversationTypewriterSound: preferences?.dialogue?.typewriterSound !== false, conversationVoice: preferences?.dialogue?.voice !== false, }); if (result.success) { @@ -162,6 +164,7 @@ export function CommandPalette({ discordMutedTypes: preferences?.discord?.mutedTypes ?? [], xpDisplayMini: !(preferences?.display?.xpDisplayMini ?? false), conversationTypewriter: preferences?.dialogue?.typewriter ?? "default", + conversationTypewriterSound: preferences?.dialogue?.typewriterSound !== false, conversationVoice: preferences?.dialogue?.voice !== false, }); if (result.success) { diff --git a/src/components/frontend/account/PreferencesForm.tsx b/src/components/frontend/account/PreferencesForm.tsx index d61aff80..d1ab80dd 100644 --- a/src/components/frontend/account/PreferencesForm.tsx +++ b/src/components/frontend/account/PreferencesForm.tsx @@ -24,6 +24,8 @@ interface PreferencesFormProps { readonly xpDisplayMini: boolean; /** Stored choice for the NPC conversation typing animation. */ readonly conversationTypewriter: "default" | "on" | "off"; + /** Whether the typing sound plays under lines that type out. */ + readonly conversationTypewriterSound: boolean; /** Whether recorded voice clips play in conversations. */ readonly conversationVoice: boolean; } @@ -39,6 +41,7 @@ export function PreferencesForm({ discordMutedTypes: initialDiscordMutedTypes, xpDisplayMini: initialXPDisplayMini, conversationTypewriter: initialConversationTypewriter, + conversationTypewriterSound: initialConversationTypewriterSound, conversationVoice: initialConversationVoice, }: PreferencesFormProps) { const router = useRouter(); @@ -57,6 +60,9 @@ export function PreferencesForm({ "default" | "on" | "off" >(initialConversationTypewriter); const [conversationVoice, setConversationVoice] = useState(initialConversationVoice); + const [conversationTypewriterSound, setConversationTypewriterSound] = useState( + initialConversationTypewriterSound, + ); const [error, setError] = useState(null); const [success, setSuccess] = useState(null); const [loading, setLoading] = useState(false); @@ -91,6 +97,7 @@ export function PreferencesForm({ discordMutedTypes, xpDisplayMini, conversationTypewriter, + conversationTypewriterSound, conversationVoice, }); @@ -248,6 +255,26 @@ export function PreferencesForm({
+ +