2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2023-01-02 17:36:27 +00:00
|
|
|
* @copyright 2013-2023 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-25 00:48:48 +00:00
|
|
|
var CONST = require('../const');
|
2016-11-22 03:11:33 +00:00
|
|
|
|
2017-10-04 22:48:16 +00:00
|
|
|
/**
|
2018-01-25 00:48:48 +00:00
|
|
|
* Called automatically by Phaser.Game and responsible for creating the console.log debug header.
|
|
|
|
*
|
|
|
|
* You can customize or disable the header via the Game Config object.
|
2017-10-04 22:48:16 +00:00
|
|
|
*
|
2019-01-15 16:17:04 +00:00
|
|
|
* @function Phaser.Core.DebugHeader
|
2017-10-04 22:48:16 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-01-25 00:48:48 +00:00
|
|
|
* @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header.
|
2017-10-04 22:48:16 +00:00
|
|
|
*/
|
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;
|
|
|
|
}
|
|
|
|
|
2018-02-28 21:57:32 +00:00
|
|
|
var renderType = 'WebGL';
|
|
|
|
|
|
|
|
if (config.renderType === CONST.CANVAS)
|
|
|
|
{
|
|
|
|
renderType = 'Canvas';
|
|
|
|
}
|
|
|
|
else if (config.renderType === CONST.HEADLESS)
|
|
|
|
{
|
|
|
|
renderType = 'Headless';
|
|
|
|
}
|
2016-11-24 01:35:02 +00:00
|
|
|
|
2018-01-19 11:06:41 +00:00
|
|
|
var audioConfig = config.audio;
|
2018-01-25 17:03:35 +00:00
|
|
|
var deviceAudio = game.device.audio;
|
2018-01-08 17:07:17 +00:00
|
|
|
|
|
|
|
var audioType;
|
|
|
|
|
2020-09-10 16:22:44 +00:00
|
|
|
if (deviceAudio.webAudio && !audioConfig.disableWebAudio)
|
2018-01-08 17:07:17 +00:00
|
|
|
{
|
|
|
|
audioType = 'Web Audio';
|
|
|
|
}
|
2020-09-10 16:22:44 +00:00
|
|
|
else if (audioConfig.noAudio || (!deviceAudio.webAudio && !deviceAudio.audioData))
|
2018-01-08 17:07:17 +00:00
|
|
|
{
|
|
|
|
audioType = 'No Audio';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
audioType = 'HTML5 Audio';
|
|
|
|
}
|
|
|
|
|
2018-01-25 17:03:35 +00:00
|
|
|
if (!game.device.browser.ie)
|
2016-11-22 03:11:33 +00:00
|
|
|
{
|
2016-11-24 15:40:05 +00:00
|
|
|
var c = '';
|
2017-06-30 14:47:51 +00:00
|
|
|
var args = [ c ];
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
if (Array.isArray(config.bannerBackgroundColor))
|
|
|
|
{
|
|
|
|
var lastColor;
|
|
|
|
|
2017-06-30 14:47:51 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2021-01-14 06:33:05 +00:00
|
|
|
// URL link background color (always transparent to support different browser themes)
|
|
|
|
args.push('background: transparent');
|
2016-11-24 15:40:05 +00:00
|
|
|
|
|
|
|
if (config.gameTitle)
|
|
|
|
{
|
|
|
|
c = c.concat(config.gameTitle);
|
|
|
|
|
|
|
|
if (config.gameVersion)
|
|
|
|
{
|
|
|
|
c = c.concat(' v' + config.gameVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config.hidePhaser)
|
|
|
|
{
|
|
|
|
c = c.concat(' / ');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-20 13:14:09 +00:00
|
|
|
var fb = (typeof PLUGIN_FBINSTANT) ? '-FB' : '';
|
|
|
|
|
2016-11-24 15:40:05 +00:00
|
|
|
if (!config.hidePhaser)
|
|
|
|
{
|
2018-09-20 13:14:09 +00:00
|
|
|
c = c.concat('Phaser v' + CONST.VERSION + fb + ' (' + 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'])
|
|
|
|
{
|
2018-01-28 02:52:35 +00:00
|
|
|
console.log('Phaser v' + CONST.VERSION + ' / https://phaser.io');
|
2016-11-22 03:11:33 +00:00
|
|
|
}
|
2016-11-22 03:32:41 +00:00
|
|
|
};
|
2016-11-22 03:11:33 +00:00
|
|
|
|
|
|
|
module.exports = DebugHeader;
|