Test button for sounds and new Audio() code #630
This commit is contained in:
@@ -8,7 +8,6 @@ module.exports = {
|
|||||||
l: 'readonly',
|
l: 'readonly',
|
||||||
b64_to_utf8: 'readonly',
|
b64_to_utf8: 'readonly',
|
||||||
utf8_to_b64: 'readonly',
|
utf8_to_b64: 'readonly',
|
||||||
realAudio: 'readonly',
|
|
||||||
BeautifyAll: 'readonly',
|
BeautifyAll: 'readonly',
|
||||||
},
|
},
|
||||||
extends: ['airbnb-base', 'plugin:prettier/recommended'],
|
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 ConfigDefault from '../../Data/SettingsDefault';
|
||||||
import RefreshScale from '../HelperFunctions/RefreshScale';
|
import RefreshScale from '../HelperFunctions/RefreshScale';
|
||||||
import UpdateColors from '../HelperFunctions/UpdateColors';
|
import UpdateColors from '../HelperFunctions/UpdateColors';
|
||||||
|
import PlaySound from '../Notifications/Sound';
|
||||||
import { Colors } from '../VariablesAndData';
|
import { Colors } from '../VariablesAndData';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,6 +111,18 @@ function CreatePrefOption(config) {
|
|||||||
};
|
};
|
||||||
volume.appendChild(slider);
|
volume.appendChild(slider);
|
||||||
div.appendChild(volume);
|
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;
|
return div;
|
||||||
}
|
}
|
||||||
if (Config[config].type === 'url') {
|
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 {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} 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 {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
|
// 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
|
// eslint-disable-next-line new-cap
|
||||||
const sound = new realAudio(url);
|
const sound = new Audio(url);
|
||||||
if (CMOptions.GeneralSound)
|
if (CMOptions.GeneralSound)
|
||||||
sound.volume = (CMOptions[volConfig] / 100) * (Game.volume / 100);
|
sound.volume = (CMOptions[volConfig] / 100) * (Game.volume / 100);
|
||||||
else sound.volume = CMOptions[volConfig] / 100;
|
else sound.volume = CMOptions[volConfig] / 100;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default function CheckGardenTick() {
|
|||||||
) {
|
) {
|
||||||
if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) {
|
if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) {
|
||||||
Flash(3, 'GardFlash');
|
Flash(3, 'GardFlash');
|
||||||
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume');
|
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume', false);
|
||||||
}
|
}
|
||||||
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
|
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default function CheckGoldenCookie() {
|
|||||||
if (LastGoldenCookieState) {
|
if (LastGoldenCookieState) {
|
||||||
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
|
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
|
||||||
Flash(3, 'GCFlash');
|
Flash(3, 'GCFlash');
|
||||||
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume');
|
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume', false);
|
||||||
CreateNotification(
|
CreateNotification(
|
||||||
'GCNotification',
|
'GCNotification',
|
||||||
'Golden Cookie Spawned',
|
'Golden Cookie Spawned',
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default function CheckMagicMeter() {
|
|||||||
else if (!LastMagicBarFull) {
|
else if (!LastMagicBarFull) {
|
||||||
LastMagicBarFull = true;
|
LastMagicBarFull = true;
|
||||||
Flash(3, 'MagicFlash');
|
Flash(3, 'MagicFlash');
|
||||||
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume');
|
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume', false);
|
||||||
CreateNotification(
|
CreateNotification(
|
||||||
'MagicNotification',
|
'MagicNotification',
|
||||||
'Magic Meter full',
|
'Magic Meter full',
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export default function CheckSeasonPopup() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
Flash(3, 'SeaFlash');
|
Flash(3, 'SeaFlash');
|
||||||
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume');
|
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume', false);
|
||||||
CreateNotification(
|
CreateNotification(
|
||||||
'SeaNotification',
|
'SeaNotification',
|
||||||
'Reindeer sighted!',
|
'Reindeer sighted!',
|
||||||
|
|||||||
@@ -17,7 +17,12 @@ export default function CheckTickerFortune() {
|
|||||||
Game.TickerEffect && Game.TickerEffect.type === 'fortune';
|
Game.TickerEffect && Game.TickerEffect.type === 'fortune';
|
||||||
if (LastTickerFortuneState) {
|
if (LastTickerFortuneState) {
|
||||||
Flash(3, 'FortuneFlash');
|
Flash(3, 'FortuneFlash');
|
||||||
PlaySound(CMOptions.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
|
PlaySound(
|
||||||
|
CMOptions.FortuneSoundURL,
|
||||||
|
'FortuneSound',
|
||||||
|
'FortuneVolume',
|
||||||
|
false,
|
||||||
|
);
|
||||||
CreateNotification(
|
CreateNotification(
|
||||||
'FortuneNotification',
|
'FortuneNotification',
|
||||||
'Fortune Cookie found',
|
'Fortune Cookie found',
|
||||||
|
|||||||
@@ -32,12 +32,14 @@ export default function CheckWrinklerCount() {
|
|||||||
CMOptions.WrinklerMaxSoundURL,
|
CMOptions.WrinklerMaxSoundURL,
|
||||||
'WrinklerMaxSound',
|
'WrinklerMaxSound',
|
||||||
'WrinklerMaxVolume',
|
'WrinklerMaxVolume',
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
PlaySound(
|
PlaySound(
|
||||||
CMOptions.WrinklerSoundURL,
|
CMOptions.WrinklerSoundURL,
|
||||||
'WrinklerSound',
|
'WrinklerSound',
|
||||||
'WrinklerVolume',
|
'WrinklerVolume',
|
||||||
|
false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user