Test button for sounds and new Audio() code #630
This commit is contained in:
@@ -8,7 +8,6 @@ module.exports = {
|
||||
l: 'readonly',
|
||||
b64_to_utf8: 'readonly',
|
||||
utf8_to_b64: 'readonly',
|
||||
realAudio: 'readonly',
|
||||
BeautifyAll: 'readonly',
|
||||
},
|
||||
extends: ['airbnb-base', 'plugin:prettier/recommended'],
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js
vendored
2
dist/CookieMonster.js
vendored
File diff suppressed because one or more lines are too long
2
dist/CookieMonster.js.map
vendored
2
dist/CookieMonster.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -20,6 +20,7 @@ import Config from '../../Data/SettingsData';
|
||||
import ConfigDefault from '../../Data/SettingsDefault';
|
||||
import RefreshScale from '../HelperFunctions/RefreshScale';
|
||||
import UpdateColors from '../HelperFunctions/UpdateColors';
|
||||
import PlaySound from '../Notifications/Sound';
|
||||
import { Colors } from '../VariablesAndData';
|
||||
|
||||
/**
|
||||
@@ -110,6 +111,18 @@ function CreatePrefOption(config) {
|
||||
};
|
||||
volume.appendChild(slider);
|
||||
div.appendChild(volume);
|
||||
const a = document.createElement('a');
|
||||
a.className = 'option';
|
||||
a.onclick = function () {
|
||||
PlaySound(
|
||||
CMOptions[config.replace('Volume', 'SoundURL')],
|
||||
config.replace('Volume', 'Sound'),
|
||||
config,
|
||||
true,
|
||||
);
|
||||
};
|
||||
a.textContent = 'Test sound';
|
||||
div.appendChild(a);
|
||||
return div;
|
||||
}
|
||||
if (Config[config].type === 'url') {
|
||||
|
||||
@@ -7,12 +7,13 @@ import { isInitializing } from '../../InitSaveLoad/Variables';
|
||||
* @param {variable} url A variable that gives the url for the sound (e.g., CM.Options.GCSoundURL)
|
||||
* @param {string} sndConfig The setting in CM.Options that is checked before creating the sound
|
||||
* @param {string} volConfig The setting in CM.Options that is checked to determine volume
|
||||
* @param {bool} forced Whether the sound should play regardless of settings, used to test the sound
|
||||
*/
|
||||
export default function PlaySound(url, sndConfig, volConfig) {
|
||||
export default function PlaySound(url, sndConfig, volConfig, forced) {
|
||||
// The arguments check makes the sound not play upon initialization of the mod
|
||||
if (CMOptions[sndConfig] === 1 && isInitializing === false) {
|
||||
if ((CMOptions[sndConfig] === 1 || forced) && isInitializing === false) {
|
||||
// eslint-disable-next-line new-cap
|
||||
const sound = new realAudio(url);
|
||||
const sound = new Audio(url);
|
||||
if (CMOptions.GeneralSound)
|
||||
sound.volume = (CMOptions[volConfig] / 100) * (Game.volume / 100);
|
||||
else sound.volume = CMOptions[volConfig] / 100;
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function CheckGardenTick() {
|
||||
) {
|
||||
if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) {
|
||||
Flash(3, 'GardFlash');
|
||||
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume');
|
||||
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume', false);
|
||||
}
|
||||
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export default function CheckGoldenCookie() {
|
||||
if (LastGoldenCookieState) {
|
||||
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
|
||||
Flash(3, 'GCFlash');
|
||||
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume');
|
||||
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume', false);
|
||||
CreateNotification(
|
||||
'GCNotification',
|
||||
'Golden Cookie Spawned',
|
||||
|
||||
@@ -18,7 +18,7 @@ export default function CheckMagicMeter() {
|
||||
else if (!LastMagicBarFull) {
|
||||
LastMagicBarFull = true;
|
||||
Flash(3, 'MagicFlash');
|
||||
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume');
|
||||
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume', false);
|
||||
CreateNotification(
|
||||
'MagicNotification',
|
||||
'Magic Meter full',
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function CheckSeasonPopup() {
|
||||
}
|
||||
});
|
||||
Flash(3, 'SeaFlash');
|
||||
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume');
|
||||
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume', false);
|
||||
CreateNotification(
|
||||
'SeaNotification',
|
||||
'Reindeer sighted!',
|
||||
|
||||
@@ -17,7 +17,12 @@ export default function CheckTickerFortune() {
|
||||
Game.TickerEffect && Game.TickerEffect.type === 'fortune';
|
||||
if (LastTickerFortuneState) {
|
||||
Flash(3, 'FortuneFlash');
|
||||
PlaySound(CMOptions.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
|
||||
PlaySound(
|
||||
CMOptions.FortuneSoundURL,
|
||||
'FortuneSound',
|
||||
'FortuneVolume',
|
||||
false,
|
||||
);
|
||||
CreateNotification(
|
||||
'FortuneNotification',
|
||||
'Fortune Cookie found',
|
||||
|
||||
@@ -32,12 +32,14 @@ export default function CheckWrinklerCount() {
|
||||
CMOptions.WrinklerMaxSoundURL,
|
||||
'WrinklerMaxSound',
|
||||
'WrinklerMaxVolume',
|
||||
false,
|
||||
);
|
||||
} else {
|
||||
PlaySound(
|
||||
CMOptions.WrinklerSoundURL,
|
||||
'WrinklerSound',
|
||||
'WrinklerVolume',
|
||||
false,
|
||||
);
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user