forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugHeader.js
More file actions
122 lines (97 loc) · 2.89 KB
/
DebugHeader.js
File metadata and controls
122 lines (97 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var CONST = require('../const');
/**
* 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.
*
* @function Phaser.Boot.DebugHeader
* @since 3.0.0
*
* @param {Phaser.Game} game - The Phaser.Game instance which will output this debug header.
*/
var DebugHeader = function (game)
{
var config = game.config;
if (config.hideBanner)
{
return;
}
var renderType = 'WebGL';
if (config.renderType === CONST.CANVAS)
{
renderType = 'Canvas';
}
else if (config.renderType === CONST.HEADLESS)
{
renderType = 'Headless';
}
var audioConfig = 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';
}
if (!game.device.browser.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 + ' | ' + audioType + ')');
}
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 + ' / https://phaser.io');
}
};
module.exports = DebugHeader;