From 2a8409ab5bc547b50cc394a749490ff9d8f8a16c Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 7 Dec 2020 19:51:19 +0100 Subject: [PATCH 01/17] Add haunt mode and earing distance (WIP) --- src/renderer/App.tsx | 4 +++- src/renderer/Settings.tsx | 30 ++++++++++++++++++++++++++++++ src/renderer/Voice.tsx | 5 +++-- yarn.lock | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index c572eee9..880f878f 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -39,7 +39,9 @@ function App() { data: '' }, hideCode: false, - stereoInLobby: true + stereoInLobby: true, + haunt: true, + earingDistance: 2.5, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 379ef587..a08f5fee 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -83,6 +83,14 @@ const store = new Store({ stereoInLobby: { type: 'boolean', default: true + }, + haunt: { + type: 'boolean', + default: true + }, + earingDistance: { + type: 'number', + default: 2.5 } } }); @@ -106,6 +114,8 @@ export interface ISettings { }, hideCode: boolean; stereoInLobby: boolean; + haunt: boolean; + earingDistance: number; } export const settingsReducer = (state: ISettings, action: { type: 'set' | 'setOne', action: [string, any] | ISettings @@ -314,6 +324,26 @@ export default function Settings({ open, onClose }: SettingsProps) { +
setSettings({ + type: 'setOne', + action: ['haunt', !settings.haunt] + })}> + + +
+
+ + ): void => { + let val: number = ev.target.valueAsNumber; + if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 10.0)) + val = 2.5; + setSettings({ + type: 'set', + action: ['earingDistance', val] + }); + }} /> +
} \ No newline at end of file diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 8c2a874e..091b5dd7 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -81,7 +81,7 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } - if (!me.isDead && other.isDead) { + if ((!me.isDead && other.isDead) && (!settings.haunt)) { gain.gain.value = 0; return; } @@ -260,7 +260,8 @@ export default function Voice() { pan.refDistance = 0.1; pan.panningModel = 'equalpower'; pan.distanceModel = 'linear'; - pan.maxDistance = 2.66 * 2; + // pan.maxDistance = 2.66 * 2; + pan.maxDistance = settings.earingDistance; pan.rolloffFactor = 1; source.connect(pan); diff --git a/yarn.lock b/yarn.lock index bbacc8a5..7e0f50f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1417,7 +1417,7 @@ ajv@^6.1.0, ajv@^6.10.1, ajv@^6.10.2, ajv@^6.12.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^6.12.2, ajv@^6.12.3, ajv@^6.9.1: +ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.6, ajv@^6.9.1: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== From 498507f608bfc4734815e23311b95f4918d66271 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 21:42:02 +0100 Subject: [PATCH 02/17] allow impostor to communicate while inVent earingDistance default value is now 3 instead of 2.5 --- src/renderer/App.tsx | 4 ++-- src/renderer/Settings.tsx | 8 ++++---- src/renderer/Voice.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 880f878f..8d141b0f 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -40,8 +40,8 @@ function App() { }, hideCode: false, stereoInLobby: true, - haunt: true, - earingDistance: 2.5, + haunt: false, + earingDistance: 3, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index a08f5fee..4bab188d 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -86,11 +86,11 @@ const store = new Store({ }, haunt: { type: 'boolean', - default: true + default: false }, earingDistance: { type: 'number', - default: 2.5 + default: 3 } } }); @@ -336,8 +336,8 @@ export default function Settings({ open, onClose }: SettingsProps) { ): void => { let val: number = ev.target.valueAsNumber; - if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 10.0)) - val = 2.5; + if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 100.0)) + val = 3; setSettings({ type: 'set', action: ['earingDistance', val] diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 091b5dd7..b90473e5 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -75,7 +75,7 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe gain.gain.value = 0; return; } - if (me.isDead && other.isDead) { + if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); From 8d18c13ac6507283b917cedc597986d3913b90f6 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 23:17:32 +0100 Subject: [PATCH 03/17] fix vents-talking --- src/renderer/Voice.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index b90473e5..f94808e3 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -71,16 +71,17 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe if (isNaN(panPos[1])) panPos[1] = 999; panPos[0] = Math.min(999, Math.max(-999, panPos[0])); panPos[1] = Math.min(999, Math.max(-999, panPos[1])); - if (other.inVent) { - gain.gain.value = 0; - return; - } + if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } + if (other.inVent) { + gain.gain.value = 0; + return; + } if ((!me.isDead && other.isDead) && (!settings.haunt)) { gain.gain.value = 0; return; From 516d4bcf5f3a81eb878ff542e8e2cb96e49880fb Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 23:56:46 +0100 Subject: [PATCH 04/17] comms in vents are on all around the map now --- src/renderer/Voice.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index f94808e3..c687b87f 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -71,8 +71,14 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe if (isNaN(panPos[1])) panPos[1] = 999; panPos[0] = Math.min(999, Math.max(-999, panPos[0])); panPos[1] = Math.min(999, Math.max(-999, panPos[1])); - - if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { + if (me.inVent && other.inVent) { + gain.gain.value = 1; + panPos = [0, 0]; + pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); + pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); + return; + } + if (me.isDead && other.isDead) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); From a2d52a85f86ee2a5b502cef96c66b59e7455f878 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Dec 2020 11:54:00 +0100 Subject: [PATCH 05/17] Add EaringInput to manage the in-game earing distance. --- src/renderer/Settings.tsx | 45 +++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 4bab188d..0bfb4645 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -135,6 +135,33 @@ interface MediaDevice { label: string; } +type EaringInputProps = { + initialDistance: string, + onValidDistance: (dist: number) => void +}; + +function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { + const [isValidNumber, setDistanceValid] = useState(true); + const [currentDistance, setCurrentDistance] = useState(initialDistance); + + useEffect(() => { + setCurrentDistance(initialDistance); + }, [initialDistance]); + + function onChange(event: React.ChangeEvent) { + setCurrentDistance(event.target.value); + + if (!isNaN(parseFloat(event.target.value))) { + setDistanceValid(true); + onValidDistance(parseFloat(event.target.value)); + } else { + setDistanceValid(false); + } + } + + return +} + type URLInputProps = { initialURL: string, onValidURL: (url: string) => void @@ -331,18 +358,14 @@ export default function Settings({ open, onClose }: SettingsProps) { -
+
- ): void => { - let val: number = ev.target.valueAsNumber; - if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 100.0)) - val = 3; - setSettings({ - type: 'set', - action: ['earingDistance', val] - }); - }} /> + { + setSettings({ + type: 'setOne', + action: ['earingDistance', dist] + }) + }} />
From aae9969d849037c838eaa11be37fa219d3a31bbf Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Tue, 8 Dec 2020 12:22:50 +0100 Subject: [PATCH 06/17] Add a setting option for global vents comm --- src/renderer/App.tsx | 1 + src/renderer/Settings.tsx | 12 ++++++++++++ src/renderer/Voice.tsx | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 8d141b0f..2267c67c 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -41,6 +41,7 @@ function App() { hideCode: false, stereoInLobby: true, haunt: false, + globalVentsComm: false, earingDistance: 3, }); diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 0bfb4645..aa5cd832 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -88,6 +88,10 @@ const store = new Store({ type: 'boolean', default: false }, + globalVentsComm: { + type: 'boolean', + default: false + }, earingDistance: { type: 'number', default: 3 @@ -115,6 +119,7 @@ export interface ISettings { hideCode: boolean; stereoInLobby: boolean; haunt: boolean; + globalVentsComm: boolean; earingDistance: number; } export const settingsReducer = (state: ISettings, action: { @@ -358,6 +363,13 @@ export default function Settings({ open, onClose }: SettingsProps) { +
setSettings({ + type: 'setOne', + action: ['globalVent', !settings.globalVentsComm] + })}> + + +
{ diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index c687b87f..77291600 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -73,7 +73,9 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe panPos[1] = Math.min(999, Math.max(-999, panPos[1])); if (me.inVent && other.inVent) { gain.gain.value = 1; - panPos = [0, 0]; + if (settings.globalVentsComm) { + panPos = [0, 0]; + } pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; From 707f1a8737b61f38bbd6afebbd691e370a54a11e Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Dec 2020 12:27:16 +0100 Subject: [PATCH 07/17] Fix earing distance --- src/renderer/Settings.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 0bfb4645..2ab77b72 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -151,7 +151,9 @@ function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { function onChange(event: React.ChangeEvent) { setCurrentDistance(event.target.value); - if (!isNaN(parseFloat(event.target.value))) { + if (!isNaN(parseFloat(event.target.value)) + && parseFloat(event.target.value) >= 0 + && parseFloat(event.target.value) <= 255) { setDistanceValid(true); onValidDistance(parseFloat(event.target.value)); } else { @@ -159,7 +161,8 @@ function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { } } - return + return } type URLInputProps = { @@ -359,7 +362,7 @@ export default function Settings({ open, onClose }: SettingsProps) {
- + { setSettings({ type: 'setOne', From 0f268bb4dcaed4f6f1e5148838c504d9d71d1b9d Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Tue, 8 Dec 2020 12:45:18 +0100 Subject: [PATCH 08/17] fix the setting globalVentsComm in menu --- src/renderer/Settings.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 3cdf6d84..09fc767c 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -366,12 +366,12 @@ export default function Settings({ open, onClose }: SettingsProps) {
-
setSettings({ +
setSettings({ type: 'setOne', - action: ['globalVent', !settings.globalVentsComm] + action: ['globalVentsComm', !settings.globalVentsComm] })}> - - + +
From edbf6a5034790f0249ae6d74bead2b7bd062b38c Mon Sep 17 00:00:00 2001 From: Tom Date: Mon, 7 Dec 2020 19:51:19 +0100 Subject: [PATCH 09/17] Add haunt mode and earing distance (WIP) --- src/renderer/App.tsx | 4 +++- src/renderer/Settings.tsx | 30 ++++++++++++++++++++++++++++++ src/renderer/Voice.tsx | 5 +++-- yarn.lock | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index ace43b85..2f0f3984 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -39,7 +39,9 @@ function App() { data: '' }, hideCode: false, - stereoInLobby: true + stereoInLobby: true, + haunt: true, + earingDistance: 2.5, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 47580ad4..03b10d73 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -89,6 +89,14 @@ const store = new Store({ stereoInLobby: { type: 'boolean', default: true + }, + haunt: { + type: 'boolean', + default: true + }, + earingDistance: { + type: 'number', + default: 2.5 } } }); @@ -118,6 +126,8 @@ export interface ISettings { }, hideCode: boolean; stereoInLobby: boolean; + haunt: boolean; + earingDistance: number; } export const settingsReducer = (state: ISettings, action: { type: 'set' | 'setOne', action: [string, any] | ISettings @@ -326,6 +336,26 @@ export default function Settings({ open, onClose }: SettingsProps) {
+
setSettings({ + type: 'setOne', + action: ['haunt', !settings.haunt] + })}> + + +
+
+ + ): void => { + let val: number = ev.target.valueAsNumber; + if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 10.0)) + val = 2.5; + setSettings({ + type: 'set', + action: ['earingDistance', val] + }); + }} /> +
} \ No newline at end of file diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 8c2a874e..091b5dd7 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -81,7 +81,7 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } - if (!me.isDead && other.isDead) { + if ((!me.isDead && other.isDead) && (!settings.haunt)) { gain.gain.value = 0; return; } @@ -260,7 +260,8 @@ export default function Voice() { pan.refDistance = 0.1; pan.panningModel = 'equalpower'; pan.distanceModel = 'linear'; - pan.maxDistance = 2.66 * 2; + // pan.maxDistance = 2.66 * 2; + pan.maxDistance = settings.earingDistance; pan.rolloffFactor = 1; source.connect(pan); diff --git a/yarn.lock b/yarn.lock index bbacc8a5..7e0f50f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1417,7 +1417,7 @@ ajv@^6.1.0, ajv@^6.10.1, ajv@^6.10.2, ajv@^6.12.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^6.12.2, ajv@^6.12.3, ajv@^6.9.1: +ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.6, ajv@^6.9.1: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== From 9de667d56ed0790d5d87d666aa95c589b9a562e9 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 21:42:02 +0100 Subject: [PATCH 10/17] allow impostor to communicate while inVent earingDistance default value is now 3 instead of 2.5 --- src/renderer/App.tsx | 4 ++-- src/renderer/Settings.tsx | 8 ++++---- src/renderer/Voice.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 2f0f3984..0b97a1b6 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -40,8 +40,8 @@ function App() { }, hideCode: false, stereoInLobby: true, - haunt: true, - earingDistance: 2.5, + haunt: false, + earingDistance: 3, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 03b10d73..ff2ac428 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -92,11 +92,11 @@ const store = new Store({ }, haunt: { type: 'boolean', - default: true + default: false }, earingDistance: { type: 'number', - default: 2.5 + default: 3 } } }); @@ -348,8 +348,8 @@ export default function Settings({ open, onClose }: SettingsProps) { ): void => { let val: number = ev.target.valueAsNumber; - if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 10.0)) - val = 2.5; + if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 100.0)) + val = 3; setSettings({ type: 'set', action: ['earingDistance', val] diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 091b5dd7..b90473e5 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -75,7 +75,7 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe gain.gain.value = 0; return; } - if (me.isDead && other.isDead) { + if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); From 70dc86ad742f93988c9f1ac7cadb9088801fe975 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 23:17:32 +0100 Subject: [PATCH 11/17] fix vents-talking --- src/renderer/Voice.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index b90473e5..f94808e3 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -71,16 +71,17 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe if (isNaN(panPos[1])) panPos[1] = 999; panPos[0] = Math.min(999, Math.max(-999, panPos[0])); panPos[1] = Math.min(999, Math.max(-999, panPos[1])); - if (other.inVent) { - gain.gain.value = 0; - return; - } + if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; } + if (other.inVent) { + gain.gain.value = 0; + return; + } if ((!me.isDead && other.isDead) && (!settings.haunt)) { gain.gain.value = 0; return; From c047f2ef82be8e17157cb6bb8ed57e56c2b7f21e Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Dec 2020 11:54:00 +0100 Subject: [PATCH 12/17] Add EaringInput to manage the in-game earing distance. --- src/renderer/Settings.tsx | 45 +++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index ff2ac428..2540c993 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -147,6 +147,33 @@ interface MediaDevice { label: string; } +type EaringInputProps = { + initialDistance: string, + onValidDistance: (dist: number) => void +}; + +function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { + const [isValidNumber, setDistanceValid] = useState(true); + const [currentDistance, setCurrentDistance] = useState(initialDistance); + + useEffect(() => { + setCurrentDistance(initialDistance); + }, [initialDistance]); + + function onChange(event: React.ChangeEvent) { + setCurrentDistance(event.target.value); + + if (!isNaN(parseFloat(event.target.value))) { + setDistanceValid(true); + onValidDistance(parseFloat(event.target.value)); + } else { + setDistanceValid(false); + } + } + + return +} + type URLInputProps = { initialURL: string, onValidURL: (url: string) => void @@ -343,18 +370,14 @@ export default function Settings({ open, onClose }: SettingsProps) { -
+
- ): void => { - let val: number = ev.target.valueAsNumber; - if (!(ev.target.valueAsNumber >= 0.0 && ev.target.valueAsNumber <= 100.0)) - val = 3; - setSettings({ - type: 'set', - action: ['earingDistance', val] - }); - }} /> + { + setSettings({ + type: 'setOne', + action: ['earingDistance', dist] + }) + }} />
From 3322eb3f8fd59628eee5642774e957c5c35d0557 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Mon, 7 Dec 2020 23:56:46 +0100 Subject: [PATCH 13/17] comms in vents are on all around the map now --- src/renderer/Voice.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index f94808e3..c687b87f 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -71,8 +71,14 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe if (isNaN(panPos[1])) panPos[1] = 999; panPos[0] = Math.min(999, Math.max(-999, panPos[0])); panPos[1] = Math.min(999, Math.max(-999, panPos[1])); - - if ((me.isDead && other.isDead) || (me.inVent && other.inVent)) { + if (me.inVent && other.inVent) { + gain.gain.value = 1; + panPos = [0, 0]; + pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); + pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); + return; + } + if (me.isDead && other.isDead) { gain.gain.value = 1; pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); From a0a340436ad3a3744af22c6ccca57ae4d61cc7a0 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Dec 2020 12:27:16 +0100 Subject: [PATCH 14/17] Fix earing distance --- src/renderer/Settings.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 2540c993..ac6302fd 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -163,7 +163,9 @@ function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { function onChange(event: React.ChangeEvent) { setCurrentDistance(event.target.value); - if (!isNaN(parseFloat(event.target.value))) { + if (!isNaN(parseFloat(event.target.value)) + && parseFloat(event.target.value) >= 0 + && parseFloat(event.target.value) <= 255) { setDistanceValid(true); onValidDistance(parseFloat(event.target.value)); } else { @@ -171,7 +173,8 @@ function EaringInput({ initialDistance, onValidDistance }: EaringInputProps) { } } - return + return } type URLInputProps = { @@ -371,7 +374,7 @@ export default function Settings({ open, onClose }: SettingsProps) {
- + { setSettings({ type: 'setOne', From 28ff6f5cf601b33273a1431adc9c0af2570a4c8f Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Tue, 8 Dec 2020 12:22:50 +0100 Subject: [PATCH 15/17] Add a setting option for global vents comm --- src/renderer/App.tsx | 1 + src/renderer/Settings.tsx | 12 ++++++++++++ src/renderer/Voice.tsx | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index 0b97a1b6..a920abfd 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -41,6 +41,7 @@ function App() { hideCode: false, stereoInLobby: true, haunt: false, + globalVentsComm: false, earingDistance: 3, }); diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index ac6302fd..635b270d 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -94,6 +94,10 @@ const store = new Store({ type: 'boolean', default: false }, + globalVentsComm: { + type: 'boolean', + default: false + }, earingDistance: { type: 'number', default: 3 @@ -127,6 +131,7 @@ export interface ISettings { hideCode: boolean; stereoInLobby: boolean; haunt: boolean; + globalVentsComm: boolean; earingDistance: number; } export const settingsReducer = (state: ISettings, action: { @@ -373,6 +378,13 @@ export default function Settings({ open, onClose }: SettingsProps) {
+
setSettings({ + type: 'setOne', + action: ['globalVent', !settings.globalVentsComm] + })}> + + +
{ diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index c687b87f..77291600 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -73,7 +73,9 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe panPos[1] = Math.min(999, Math.max(-999, panPos[1])); if (me.inVent && other.inVent) { gain.gain.value = 1; - panPos = [0, 0]; + if (settings.globalVentsComm) { + panPos = [0, 0]; + } pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime); pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime); return; From 91e62854331061b2ecad5d6730ab4598b35ea8a5 Mon Sep 17 00:00:00 2001 From: Charlly PIERRE Date: Tue, 8 Dec 2020 12:45:18 +0100 Subject: [PATCH 16/17] fix the setting globalVentsComm in menu --- src/renderer/Settings.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index 635b270d..d2d9e1cc 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -378,12 +378,12 @@ export default function Settings({ open, onClose }: SettingsProps) {
-
setSettings({ +
setSettings({ type: 'setOne', - action: ['globalVent', !settings.globalVentsComm] + action: ['globalVentsComm', !settings.globalVentsComm] })}> - - + +
From ce34caeb0eb49d2259e400859defcd96d0f59cc2 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Dec 2020 14:44:32 +0100 Subject: [PATCH 17/17] Correct typo in name (earing -> hearing) --- src/renderer/App.tsx | 2 +- src/renderer/Settings.tsx | 12 ++++++------ src/renderer/Voice.tsx | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index a920abfd..26b85b26 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -42,7 +42,7 @@ function App() { stereoInLobby: true, haunt: false, globalVentsComm: false, - earingDistance: 3, + hearingDistance: 2.6, }); useEffect(() => { diff --git a/src/renderer/Settings.tsx b/src/renderer/Settings.tsx index d2d9e1cc..84923133 100644 --- a/src/renderer/Settings.tsx +++ b/src/renderer/Settings.tsx @@ -98,9 +98,9 @@ const store = new Store({ type: 'boolean', default: false }, - earingDistance: { + hearingDistance: { type: 'number', - default: 3 + default: 2.6 } } }); @@ -132,7 +132,7 @@ export interface ISettings { stereoInLobby: boolean; haunt: boolean; globalVentsComm: boolean; - earingDistance: number; + hearingDistance: number; } export const settingsReducer = (state: ISettings, action: { type: 'set' | 'setOne', action: [string, any] | ISettings @@ -386,11 +386,11 @@ export default function Settings({ open, onClose }: SettingsProps) {
- - { + + { setSettings({ type: 'setOne', - action: ['earingDistance', dist] + action: ['hearingDistance', dist] }) }} />
diff --git a/src/renderer/Voice.tsx b/src/renderer/Voice.tsx index 77291600..7844d5b0 100644 --- a/src/renderer/Voice.tsx +++ b/src/renderer/Voice.tsx @@ -270,7 +270,7 @@ export default function Voice() { pan.panningModel = 'equalpower'; pan.distanceModel = 'linear'; // pan.maxDistance = 2.66 * 2; - pan.maxDistance = settings.earingDistance; + pan.maxDistance = settings.hearingDistance * 2; pan.rolloffFactor = 1; source.connect(pan);