Skip to content

Commit

Permalink
Updated SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanny McNie committed Nov 14, 2012
1 parent c0927fa commit 00b0f69
Show file tree
Hide file tree
Showing 38 changed files with 700 additions and 331 deletions.
226 changes: 226 additions & 0 deletions scripts/BrowserDetect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
(function(scope) {

/**
* BrowserDetect derived from http://www.quirksmode.org/js/detect.html
*/
var s = {};

// Public properties:

s.browser = null;
s.version = null;
s.os = null;

s.isIE = function () {
return s.browser == 'Explorer';
};

s.isVista = function() {
return navigator.userAgent.indexOf('Windows NT 6.0') != -1;
};

s.isXP = function() {
return navigator.userAgent.indexOf('Windows NT 5') != -1;
};

s.isWindows = function() {
return s.os == "Windows";
};

s.isWP8 = function () {
return navigator.userAgent.indexOf('Windows Phone 8') != -1;
};

s.isWP7 = function () {
return navigator.userAgent.indexOf('Windows Phone 7') != -1;
};

s.isAndroid = function() {
return navigator.userAgent.indexOf('Android') != -1;
};

s.isIE9 = function () {
return this.isIE() && this.getInternetExplorerVersion() == 9;
};

s.isMac = function() {
return s.os == "Mac" || s.isIOS();
};

s.isIOS = function() {
return s.os == "iPhone/iPod" || s.os == "iPad";
};

s.isIOSRetina = function () {
return s.isIOS() && window.devicePixelRatio > 1;
};

s.isMobileSafari = function() {
return s.isSafari() && s.isIOS();
};

s.isSafari = function() {
return s.browser == "Safari";
};

s.isChrome = function() {
return s.browser == "Chrome";
};

s.isFirefox = function() {
return s.browser == "Firefox" || s.browser == "Mozilla";
};

s.isOpera = function () {
return s.browser == "Opera";
};

s.getInternetExplorerVersion = function()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}

// Protected properties:

s._dataBrowser = [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera",
versionSearch: "Version"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
];

s._dataOS = [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.userAgent,
subString: "iPad",
identity: "iPad"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
];

s._versionSearchString = null;

// Public methods:

s.init = function () {
s.browser = s._searchString(s._dataBrowser) || "An unknown browser";
s.version = s._searchVersion(navigator.userAgent) || s._searchVersion(navigator.appVersion) || "An unknown version";
s.os = s._searchString(s._dataOS) || "An unknown OS";
};

// Protected methods:

s._searchString = function (data) {
for (var i = 0, l = data.length; i < l; i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;

s._versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1) { return data[i].identity; }
} else if (dataProp) {
return data[i].identity;
}
}
};

s._searchVersion = function (dataString) {
var index = dataString.indexOf(s._versionSearchString);
if (index == -1) { return; }
return parseFloat(dataString.substring(index + s._versionSearchString.length + 1));
};

scope.BrowserDetect = s;

s.init(); // Auto init class.

}(window.AtariSite!=null?window.AtariSite:window));
2 changes: 1 addition & 1 deletion scripts/libs/atari/Atari.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
* Copyright (c) (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
Expand Down
2 changes: 1 addition & 1 deletion scripts/libs/atari/Fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
Expand Down
13 changes: 7 additions & 6 deletions scripts/libs/atari/GameBootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
Expand Down Expand Up @@ -109,10 +109,10 @@
*/
s.initialize = function() {
// Selectively set the plugins
/*createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
if (AtariSite.BrowserDetect.isSafari()) {
createjs.FlashPlugin.BASE_PATH = window.BASE_PATH + "scripts/soundjs/";
if (createjs.PreloadJS.BrowserDetect.isIOS) {
createjs.SoundJS.registerPlugin(createjs.FlashPlugin);
}*/
}
}

/**
Expand Down Expand Up @@ -143,8 +143,9 @@

var manifest = s.manifest = this.owner.currentGameManifest;
s.canvas = canvas;
canvas.width = manifest.width;
canvas.height = manifest.height;
// LM: DEPRECATED FOR NOW
//canvas.width = manifest.width;
//canvas.height = manifest.height;

// Append base to each path
var assets = [];
Expand Down
47 changes: 35 additions & 12 deletions scripts/libs/atari/GameMediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Developed by gskinner.com in partnership with Atari
* Visit http://atari.com/arcade/developers for documentation, updates and examples.
*
* ©Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
* Copyright (c) Atari Interactive, Inc. All Rights Reserved. Atari and the Atari logo are trademarks owned by Atari Interactive, Inc.
*
* Distributed under the terms of the MIT license.
* http://www.opensource.org/licenses/mit-license.html
Expand Down Expand Up @@ -51,6 +51,7 @@
s.RESTART_GAME = "restartGame";
s.DESTROY_GAME = "destroyGame";
s.REDUCE_FRAMERATE = "reduceFrameRate";
s.REMOVE_PLAYER = "removePlayer";

/**
* Defines the constant for a notify-level error, which can usually be ignored.
Expand Down Expand Up @@ -243,6 +244,11 @@
}
},

toggleVisibility: function(visible) {
// Consider throttling Tick...
GameLibs.GamePad.reset();
},

/**
* Register the game instance with the GameMediator. This ensures that all the game has all the
* required methods and event handlers defined, and adds handlers for events. Note that the
Expand Down Expand Up @@ -305,34 +311,42 @@
this.shell = shell;
this.multiPlayerGame = mpg;

// Scale the canvas to fit the GameInfo.
var canvas = this.stage.canvas;
var gameInfo = this.shell.gameInfo;

// Set the Canvas size
canvas.width = gameInfo.width;
canvas.height = gameInfo.height;

// On hi-resolution platforms, we need to counter-scale.
canvas.style.width = gameInfo.width * gameInfo.scaleFactor + "px";
canvas.style.height = gameInfo.height * gameInfo.scaleFactor + "px";

// Initialize the game itself.
if (true || Atari.developerMode) {
this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
} else {
try {
this.gameInstance.initialize(this.currentAssets, this.stage, this.shell.gameInfo);
} catch (error) {
this.showError(error, "Unable to initialize game.");
}
}
this.gameInstance.initialize(this.currentAssets, this.stage, gameInfo);
},

/**
* Start the game. This sets up the tick, and calls startGame on the game instance.
* @method startGame
*/
startGame: function() {
var gameInfo = this.shell.gameInfo;

var fps = this.shell.currentGameManifest.fps;
if (fps == null || isNaN(fps)) { fps = 30; }
createjs.Ticker.setFPS(fps);

this.targetFPS = fps;
this.targetMS = 1000 / fps;

//Ticker.useRAF = true;
if (gameInfo.platform != GameLibs.GameInfo.PLATFORM_IPHONE) {
createjs.Ticker.useRAF = true;
}
createjs.Ticker.addListener(this, false);

Atari.trace("[GameMediator] Staring game. Total players: " + this.shell.gameInfo.players.length);
Atari.trace("[GameMediator] Staring game. Total players: " + gameInfo.players.length);
this.gameInstance.startGame();

},
Expand All @@ -356,6 +370,9 @@
* @param {String} message A verbose message for the logs.
*/
logError: function(error, message) {
if(Atari.developerMode){
throw(error);
}
Atari.trace(error);
},

Expand Down Expand Up @@ -585,6 +602,12 @@
}
break;

case s.REMOVE_PLAYER:
if(game.removePlayer){
game.removePlayer(args);
}
break;

case s.CONTINUE_GAME:
createjs.Ticker.addListener(this, false);
if (dev) {
Expand Down
Loading

0 comments on commit 00b0f69

Please sign in to comment.