mirror of
https://github.com/photonstorm/phaser
synced 2024-12-02 17:41:06 +00:00
91 lines
2.1 KiB
JavaScript
91 lines
2.1 KiB
JavaScript
/**
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
* @copyright 2016 Photon Storm Ltd.
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
*/
|
|
|
|
var CONST = require('../const');
|
|
var CHECKSUM = require('../checksum');
|
|
|
|
var DebugHeader = function (game)
|
|
{
|
|
var config = game.config;
|
|
|
|
if (config.hideBanner)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
|
|
|
|
var ie = false;
|
|
|
|
if (!ie)
|
|
{
|
|
var c = '';
|
|
var args = [ c ];
|
|
|
|
if (Array.isArray(config.bannerBackgroundColor))
|
|
{
|
|
var lastColor;
|
|
|
|
config.bannerBackgroundColor.forEach(function (color)
|
|
{
|
|
c = c.concat('%c ');
|
|
|
|
args.push('background: ' + color);
|
|
|
|
lastColor = color;
|
|
|
|
});
|
|
|
|
// inject the text color
|
|
args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor;
|
|
}
|
|
else
|
|
{
|
|
c = c.concat('%c ');
|
|
|
|
args.push('color: ' + config.bannerTextColor + '; background: ' + config.bannerBackgroundColor);
|
|
}
|
|
|
|
// URL link background color (always white)
|
|
args.push('background: #fff');
|
|
|
|
if (config.gameTitle)
|
|
{
|
|
c = c.concat(config.gameTitle);
|
|
|
|
if (config.gameVersion)
|
|
{
|
|
c = c.concat(' v' + config.gameVersion);
|
|
}
|
|
|
|
if (!config.hidePhaser)
|
|
{
|
|
c = c.concat(' / ');
|
|
}
|
|
}
|
|
|
|
if (!config.hidePhaser)
|
|
{
|
|
c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ')');
|
|
}
|
|
|
|
c = c.concat(' %c ' + config.gameURL);
|
|
|
|
// Inject the new string back into the args array
|
|
args[0] = c;
|
|
|
|
console.log.apply(console, args);
|
|
}
|
|
else if (window['console'])
|
|
{
|
|
console.log('Phaser v' + CONST.VERSION + ' / http://phaser.io');
|
|
}
|
|
|
|
// Keep this during dev build only
|
|
console.log(CHECKSUM.build);
|
|
};
|
|
|
|
module.exports = DebugHeader;
|