Fix ad provider

This commit is contained in:
tobspr 2021-08-26 14:47:28 +02:00
parent f61f25934f
commit 4546ca63c1
3 changed files with 14 additions and 23 deletions

View File

@ -91,26 +91,6 @@ export class GameState {
}
}
/**
*
* @param {string} nextStateId
* @param {object=} nextStatePayload
*/
watchAdAndMoveToState(nextStateId, nextStatePayload = {}) {
if (this.app.adProvider.getCanShowVideoAd() && this.app.isRenderable()) {
this.moveToState(
"WatchAdState",
{
nextStateId,
nextStatePayload,
},
true
);
} else {
this.moveToState(nextStateId, nextStatePayload);
}
}
/**
* Tracks clicks on a given element and calls the given callback *on this state*.
* If you want to call another function wrap it inside a lambda.

View File

@ -95,6 +95,10 @@ export class GamedistributionAdProvider extends AdProviderInterface {
document.body.classList.add("externalAdOpen");
logger.log("Set sound volume to 0");
this.app.sound.setMusicVolume(0);
this.app.sound.setSoundVolume(0);
return new Promise(resolve => {
// So, wait for the remove call but also remove after N seconds
this.videoAdResolveFunction = () => {
@ -119,6 +123,11 @@ export class GamedistributionAdProvider extends AdProviderInterface {
})
.then(() => {
document.body.classList.remove("externalAdOpen");
logger.log("Restored sound volume");
this.app.sound.setMusicVolume(this.app.settings.getSetting("musicVolume"));
this.app.sound.setSoundVolume(this.app.settings.getSetting("soundVolume"));
});
}
}

View File

@ -81,9 +81,11 @@ export class PreloadState extends GameState {
} catch (ex) {
logger.error("Failed to read/write local storage:", ex);
return new Promise(() => {
alert(`Your brower does not support thirdparty cookies or you have disabled it in your security settings.\n\n
In Chrome this setting is called "Block third-party cookies and site data".\n\n
Please allow third party cookies and then reload the page.`);
alert(
"Your brower does not support thirdparty cookies or you have disabled it in your security settings.\n\n" +
"In Chrome this setting is called 'Block third-party cookies and site data'.\n\n" +
"Please allow third party cookies and then reload the page."
);
// Never return
});
}