mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-17 22:29:52 +08:00
impr(commandline): preview error sound on hover (@Bretis2019) (#5769)
* fix: play sound on error on hover in settings pop up menu * name --------- Co-authored-by: Miodec <jack@monkeytype.com>
This commit is contained in:
parent
2ae398cdaf
commit
38a8529808
2 changed files with 26 additions and 0 deletions
|
|
@ -17,6 +17,9 @@ const subgroup: MonkeyTypes.CommandsSubgroup = {
|
|||
id: "setPlaySoundOnError1",
|
||||
display: "damage",
|
||||
configValue: "1",
|
||||
hover: (): void => {
|
||||
void SoundController.previewError("1");
|
||||
},
|
||||
exec: (): void => {
|
||||
UpdateConfig.setPlaySoundOnError("1");
|
||||
void SoundController.playError();
|
||||
|
|
@ -26,6 +29,9 @@ const subgroup: MonkeyTypes.CommandsSubgroup = {
|
|||
id: "setPlaySoundOnError2",
|
||||
display: "triangle",
|
||||
configValue: "2",
|
||||
hover: (): void => {
|
||||
void SoundController.previewError("2");
|
||||
},
|
||||
exec: (): void => {
|
||||
UpdateConfig.setPlaySoundOnError("2");
|
||||
void SoundController.playError();
|
||||
|
|
@ -35,6 +41,9 @@ const subgroup: MonkeyTypes.CommandsSubgroup = {
|
|||
id: "setPlaySoundOnError3",
|
||||
display: "square",
|
||||
configValue: "3",
|
||||
hover: (): void => {
|
||||
void SoundController.previewError("3");
|
||||
},
|
||||
exec: (): void => {
|
||||
UpdateConfig.setPlaySoundOnError("3");
|
||||
void SoundController.playError();
|
||||
|
|
@ -44,6 +53,9 @@ const subgroup: MonkeyTypes.CommandsSubgroup = {
|
|||
id: "setPlaySoundOnError3",
|
||||
display: "punch miss",
|
||||
configValue: "4",
|
||||
hover: (): void => {
|
||||
void SoundController.previewError("4");
|
||||
},
|
||||
exec: (): void => {
|
||||
UpdateConfig.setPlaySoundOnError("4");
|
||||
void SoundController.playError();
|
||||
|
|
|
|||
|
|
@ -404,6 +404,20 @@ export async function previewClick(val: string): Promise<void> {
|
|||
safeClickSounds[val][0].sounds[0].play();
|
||||
}
|
||||
|
||||
export async function previewError(val: string): Promise<void> {
|
||||
if (errorSounds === null) await initErrorSound();
|
||||
|
||||
const safeErrorSounds = errorSounds as ErrorSounds;
|
||||
|
||||
const errorSoundIds = Object.keys(safeErrorSounds);
|
||||
if (!errorSoundIds.includes(val)) return;
|
||||
|
||||
//@ts-expect-error
|
||||
errorClickSounds[val][0].sounds[0].seek(0);
|
||||
//@ts-expect-error
|
||||
errorClickSounds[val][0].sounds[0].play();
|
||||
}
|
||||
|
||||
let currentCode = "KeyA";
|
||||
|
||||
$(document).on("keydown", (event) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue