Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ function App() {
data: ''
},
hideCode: false,
stereoInLobby: true
stereoInLobby: true,
haunt: false,
globalVentsComm: false,
hearingDistance: 2.6,
});

useEffect(() => {
Expand Down
68 changes: 68 additions & 0 deletions src/renderer/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ const store = new Store<ISettings>({
stereoInLobby: {
type: 'boolean',
default: true
},
haunt: {
type: 'boolean',
default: false
},
globalVentsComm: {
type: 'boolean',
default: false
},
hearingDistance: {
type: 'number',
default: 2.6
}
}
});
Expand Down Expand Up @@ -118,6 +130,9 @@ export interface ISettings {
},
hideCode: boolean;
stereoInLobby: boolean;
haunt: boolean;
globalVentsComm: boolean;
hearingDistance: number;
}
export const settingsReducer = (state: ISettings, action: {
type: 'set' | 'setOne', action: [string, any] | ISettings
Expand All @@ -137,6 +152,36 @@ 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<HTMLInputElement>) {
setCurrentDistance(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 {
setDistanceValid(false);
}
}

return <input className={isValidNumber ? '' : 'input-error'} spellCheck={false} type="number"
min="0" max="255" step="0.1" value={currentDistance} onChange={onChange}/>
}

type URLInputProps = {
initialURL: string,
onValidURL: (url: string) => void
Expand Down Expand Up @@ -326,6 +371,29 @@ export default function Settings({ open, onClose }: SettingsProps) {
<input type="checkbox" checked={settings.stereoInLobby} style={{ color: '#fd79a8' }} readOnly />
<label>Stereo Audio in Lobbies</label>
</div>
<div className="form-control m" style={{ color: '#4166ff' }} onClick={() => setSettings({
type: 'setOne',
action: ['haunt', !settings.haunt]
})}>
<input type="checkbox" checked={settings.haunt} style={{ color: '#4166ff' }} readOnly />
<label>Allows haunt</label>
</div>
<div className="form-control m" style={{ color: '#e60000' }} onClick={() => setSettings({
type: 'setOne',
action: ['globalVentsComm', !settings.globalVentsComm]
})}>
<input type="checkbox" checked={settings.globalVentsComm} style={{ color: '#e60000' }} readOnly />
<label>Global vents comms</label>
</div>
<div className="form-control l m" style={{ color: '#3498db' }}>
<label>Hearing distance (A: {settings.hearingDistance.toString()})</label>
<EaringInput initialDistance={settings.hearingDistance.toString()} onValidDistance={(dist: number) => {
setSettings({
type: 'setOne',
action: ['hearingDistance', dist]
})
}} />
</div>
</div>
</div>
}
18 changes: 14 additions & 4 deletions src/renderer/Voice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ 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;
if (me.inVent && other.inVent) {
gain.gain.value = 1;
if (settings.globalVentsComm) {
panPos = [0, 0];
}
pan.positionX.setValueAtTime(panPos[0], audioContext.currentTime);
pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime);
return;
}
if (me.isDead && other.isDead) {
Expand All @@ -81,7 +86,11 @@ function calculateVoiceAudio(state: AmongUsState, settings: ISettings, me: Playe
pan.positionY.setValueAtTime(panPos[1], audioContext.currentTime);
return;
}
if (!me.isDead && other.isDead) {
if (other.inVent) {
gain.gain.value = 0;
return;
}
if ((!me.isDead && other.isDead) && (!settings.haunt)) {
gain.gain.value = 0;
return;
}
Expand Down Expand Up @@ -260,7 +269,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.hearingDistance * 2;
pan.rolloffFactor = 1;

source.connect(pan);
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down