Skip to content

Commit

Permalink
VGD-680 - Made sure that construct 2 games can be properly mangled.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Hulsman committed Dec 11, 2017
1 parent e203e6d commit 18498bd
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 31 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Folders
node_modules/
.idea/

# Files

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Icon must ends with two \r.
Icon

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "1.0",
"description": "Google ads for Vooxe",
"author": "Vooxe",
"help url": "http://www.gamedistribution.com/Api/",
"help url": "https://github.com/GameDistribution/GD-Construct2/wiki",
"category": "Monetisation",
"type": "object", // appears in layout
"rotatable": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ cr.plugins_.vooxe = function(runtime)
this.type = type;
this.runtime = type.runtime;
window["vooxe"]={};
window["GD_OPTIONS"]={};
};

var instanceProto = pluginProto.Instance.prototype;
Expand All @@ -47,9 +48,9 @@ cr.plugins_.vooxe = function(runtime)
// called whenever an instance is created
instanceProto.onCreate = function()
{
if (!window["vooxe"])
if (!window["vooxe"] && !window["GD_OPTIONS"])
{
cr.logexport("[Construct 2] Vooxe Googleads plugin is required to show googleads ads with Cordova; other platforms are not supported");
cr.logexport("[Construct 2] Gamedistribution.com SDK is required to show googleads ads with Cordova; other platforms are not supported");
return;
}

Expand All @@ -69,40 +70,59 @@ cr.plugins_.vooxe = function(runtime)

this.vooxe["onError"] = function (data)
{
cr.logexport("Vooxe Googleads Plugin onError: "+data);
cr.logexport("Gamedistribution.com SDK onError: "+data);
self.isShowingBannerAd = true;
self.runtime.trigger(cr.plugins_.vooxe.prototype.cnds.onError, self);
};

this.vooxe["onResumeGame"] = function ()
{
cr.logexport("Vooxe Googleads Plugin: onResume");
cr.logexport("Gamedistribution.com SDK: onResume");
self.isShowingBannerAd = false;
self.runtime.trigger(cr.plugins_.vooxe.prototype.cnds.onResumeGame, self);
};

this.vooxe["onPauseGame"] = function ()
{
cr.logexport("Vooxe Googleads Plugin: onPauseGame");
cr.logexport("Gamedistribution.com SDK: onPauseGame");
self.isShowingBannerAd = true;
self.runtime.trigger(cr.plugins_.vooxe.prototype.cnds.onPauseGame, self);
};

// Init GdApi
this.vooxe["InitAds"] = function ()
{
var settings = {
gameId: self.properties[0],
userId: self.properties[1],
resumeGame: self.vooxe.onResumeGame,
pauseGame: self.vooxe.onPauseGame,
onInit: self.vooxe.onInit,
onError: self.vooxe.onError
};
(function(i,s,o,g,r,a,m){
i['GameDistribution']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};i[r].l=1*new Date();a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a, m);
})(window, document, 'script', '//html5.api.gamedistribution.com/libs/gd/api.js', 'gdApi');
gdApi(settings);
window["GD_OPTIONS"] = {
"gameId": self.properties[0],
"userId": self.properties[1],
"advertisementSettings": {
"autoplay": false
},
"onEvent": function(event) {
switch (event.name) {
case "SDK_GAME_START":
self.vooxe["onResumeGame"]();
break;
case "SDK_GAME_PAUSE":
self.vooxe["onPauseGame"]();
break;
case "SDK_READY":
self.vooxe["onInit"]();
break;
case "SDK_ERROR":
self.vooxe["onError"]();
break;
}
}
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = '//html5.api.gamedistribution.com/main.min.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'gamedistribution-jssdk'));
}

};
Expand Down Expand Up @@ -143,49 +163,49 @@ cr.plugins_.vooxe = function(runtime)
// Actions
function Acts() {};

Acts.prototype.ShowBanner = function (key)
Acts.prototype.ShowBanner = function ()
{
if (!isSupported) return;

if (typeof (gdApi.showBanner) === "undefined")
if (typeof (window["gdsdk"]["showBanner"]) === "undefined")
{
cr.logexport("Vooxe Googleads Plugin is not initiliazed or AdBlocker");
cr.logexport("Gamedistribution.com SDK is not loaded or an ad blocker is present.");
this.vooxe["onResumeGame"]();
return;
}
gdApi.showBanner("{_key:"+key+"}");
cr.logexport("ShowBanner Key: "+key);

window["gdsdk"]["showBanner"]();
cr.logexport("ShowBanner");

this.isShowingBannerAd = true;
};

Acts.prototype.PlayLog = function ()
{
if (!isSupported) return;
if (typeof (gdApi.play) === "undefined")

if (typeof (window["gdsdk"]["play"]) === "undefined")
{
cr.logexport("Vooxe Googleads Plugin is not initiliazed.");
this.vooxe["onResumeGame"]();
return;
}

gdApi.play();
window['gdsdk']["play"]();
};

Acts.prototype.CustomLog = function (key)
Acts.prototype.CustomLog = function ()
{
if (!isSupported) return;
if (typeof (gdApi.customLog) === "undefined")

if (typeof (window['gdsdk']["customLog"]) === "undefined")
{
cr.logexport("Vooxe Googleads Plugin is not initiliazed.");
this.vooxe["onResumeGame"]();
return;
}

gdApi.customLog(key)
window['gdsdk']["customLog"]();
};

Acts.prototype.InitAds = function ()
Expand Down

0 comments on commit 18498bd

Please sign in to comment.