phaser/src/boot/DebugHeader.js

112 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-11-22 03:32:41 +00:00
var CONST = require('../const');
var CHECKSUM = require('../checksum');
2016-11-22 03:11:33 +00:00
2017-10-04 22:48:16 +00:00
/**
* [description]
*
* @function Phaser.Boot.DebugHeader
* @since 3.0.0
*
* @param {Phaser.Game} game - [description]
*/
2016-11-24 15:40:05 +00:00
var DebugHeader = function (game)
2016-11-22 03:11:33 +00:00
{
2016-11-24 15:40:05 +00:00
var config = game.config;
if (config.hideBanner)
{
return;
}
var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL';
var audioConfig = game.config.audio;
var deviceAudio = game.device.Audio;
var audioType;
if(deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio))
{
audioType = 'Web Audio';
}
else if((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData))
{
audioType = 'No Audio';
}
else
{
audioType = 'HTML5 Audio';
}
var ie = false;
2016-11-22 03:11:33 +00:00
2016-11-22 03:32:41 +00:00
if (!ie)
2016-11-22 03:11:33 +00:00
{
2016-11-24 15:40:05 +00:00
var c = '';
var args = [ c ];
2016-11-24 15:40:05 +00:00
if (Array.isArray(config.bannerBackgroundColor))
{
var lastColor;
config.bannerBackgroundColor.forEach(function (color)
{
2016-11-24 15:40:05 +00:00
c = c.concat('%c ');
args.push('background: ' + color);
lastColor = color;
});
// inject the text color
args[args.length - 1] = 'color: ' + config.bannerTextColor + '; background: ' + lastColor;
}
else
{
2016-11-24 16:41:50 +00:00
c = c.concat('%c ');
2016-11-24 15:40:05 +00:00
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 + ' | ' + audioType + ')');
2016-11-24 15:40:05 +00:00
}
c = c.concat(' %c ' + config.gameURL);
// Inject the new string back into the args array
args[0] = c;
2016-11-22 03:11:33 +00:00
console.log.apply(console, args);
}
else if (window['console'])
{
2016-11-22 03:32:41 +00:00
console.log('Phaser v' + CONST.VERSION + ' / http://phaser.io');
2016-11-22 03:11:33 +00:00
}
// Keep this during dev build only
console.log(CHECKSUM.build);
2016-11-22 03:32:41 +00:00
};
2016-11-22 03:11:33 +00:00
module.exports = DebugHeader;