Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify's don't occur when loading the mod #495 #529

Merged
merged 1 commit into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions CookieMonster.js
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,8 @@ CM.Disp.CreateWhiteScreen = function() {
* @param {string} config The setting in CM.Options that is checked before creating the flash
*/
CM.Disp.Flash = function(mode, config) {
if ((CM.Options[config] == 1 && mode == 3) || mode == 1) {
// The arguments check makes the sound not play upon initialization of the mod
if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) {
CM.Disp.WhiteScreen.style.opacity = '0.5';
if (mode == 3) {
CM.Disp.WhiteScreen.style.display = 'inline';
Expand All @@ -2203,7 +2204,8 @@ CM.Disp.Flash = function(mode, config) {
* @param {string} volConfig The setting in CM.Options that is checked to determine volume
*/
CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
if (CM.Options[sndConfig] == 1) {
// The arguments check makes the sound not play upon initialization of the mod
if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) {
var sound = new realAudio(url);
sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100);
sound.play();
Expand All @@ -2218,7 +2220,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
* @param {string} message The text of the to-be created notifications
*/
CM.Disp.Notification = function(notifyConfig, title, message) {
if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') {
// The arguments check makes the sound not play upon initialization of the mod
if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) {
var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'
notification = new Notification(title, {body: message, badge: CookieIcon});
}
Expand Down
9 changes: 6 additions & 3 deletions src/Disp.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@ CM.Disp.CreateWhiteScreen = function() {
* @param {string} config The setting in CM.Options that is checked before creating the flash
*/
CM.Disp.Flash = function(mode, config) {
if ((CM.Options[config] == 1 && mode == 3) || mode == 1) {
// The arguments check makes the sound not play upon initialization of the mod
if ((CM.Options[config] == 1 && mode == 3 && arguments.callee.caller.caller.caller.caller == null) || mode == 1) {
CM.Disp.WhiteScreen.style.opacity = '0.5';
if (mode == 3) {
CM.Disp.WhiteScreen.style.display = 'inline';
Expand All @@ -991,7 +992,8 @@ CM.Disp.Flash = function(mode, config) {
* @param {string} volConfig The setting in CM.Options that is checked to determine volume
*/
CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
if (CM.Options[sndConfig] == 1) {
// The arguments check makes the sound not play upon initialization of the mod
if (CM.Options[sndConfig] == 1 && arguments.callee.caller.caller.caller.caller == null) {
var sound = new realAudio(url);
sound.volume = (CM.Options[volConfig] / 100) * (Game.volume / 100);
sound.play();
Expand All @@ -1006,7 +1008,8 @@ CM.Disp.PlaySound = function(url, sndConfig, volConfig) {
* @param {string} message The text of the to-be created notifications
*/
CM.Disp.Notification = function(notifyConfig, title, message) {
if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden') {
// The arguments check makes the sound not play upon initialization of the mod
if (CM.Options[notifyConfig] == 1 && document.visibilityState == 'hidden' && arguments.callee.caller.caller.caller.caller == null) {
var CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'
notification = new Notification(title, {body: message, badge: CookieIcon});
}
Expand Down