-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathJsExtension.js
More file actions
164 lines (157 loc) · 5.73 KB
/
Copy pathJsExtension.js
File metadata and controls
164 lines (157 loc) · 5.73 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//@ts-check
/// <reference path="../JsExtensionTypes.d.ts" />
/**
* This is a declaration of an extension for GDevelop 5.
*
* ℹ️ Changes in this file are watched and automatically imported if the editor
* is running. You can also manually run `node import-GDJS-Runtime.js` (in newIDE/app/scripts).
*
* The file must be named "JsExtension.js", otherwise GDevelop won't load it.
* ⚠️ If you make a change and the extension is not loaded, open the developer console
* and search for any errors.
*
* More information on https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md
*/
/** @type {ExtensionModule} */
module.exports = {
createExtension: function (_, gd) {
const extension = new gd.PlatformExtension();
extension
.setExtensionInformation(
'DebuggerTools',
_('Debugger Tools'),
_(
'Allow to interact with the editor debugger from the game (notably: enable 2D debug draw, log a message in the debugger console).'
),
'Arthur Pacaud (arthuro555), Aurélien Vivet (Bouh)',
'MIT'
)
.setShortDescription(
'Enable 2D debug draw, log messages to debugger console, pause execution.'
)
.setCategory('Advanced');
extension
.addInstructionOrExpressionGroupMetadata(_('Debugger Tools'))
.setIcon('res/actions/bug32.png');
extension
.addAction(
'Pause',
_('Pause game execution'),
_(
'This pauses the game, useful for inspecting the game state through the debugger. ' +
'Note that events will be still executed until the end before the game is paused.'
),
_('Pause game execution'),
'',
'res/actions/bug32.png',
'res/actions/bug32.png'
)
.addCodeOnlyParameter('currentScene', '')
.getCodeExtraInformation()
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
.setFunctionName('gdjs.evtTools.debuggerTools.pause');
extension
.addAction(
'EnableDebugDraw',
_('Draw collisions hitboxes and points'),
_(
'This activates the display of rectangles and information on screen showing the objects bounding boxes (blue), the hitboxes (red) and some points of objects.'
),
_(
'Enable debugging view of bounding boxes/collision masks: _PARAM1_ (include invisible objects: _PARAM2_, point names: _PARAM3_, custom points: _PARAM4_)'
),
'',
'res/actions/planicon24.png',
'res/actions/planicon.png'
)
.addCodeOnlyParameter('currentScene', '')
.addParameter('yesorno', _('Enable debug draw'), '', true)
.setDefaultValue('yes')
.addParameter(
'yesorno',
_('Show collisions for hidden objects'),
'',
true
)
.setDefaultValue('no')
.addParameter('yesorno', _('Show points names'), '', true)
.setDefaultValue('yes')
.addParameter('yesorno', _('Show custom points'), '', true)
.setDefaultValue('yes')
.getCodeExtraInformation()
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
.setFunctionName('gdjs.evtTools.debuggerTools.enableDebugDraw');
extension
.addAction(
'EnableDebugDraw3D',
_('Draw 3D collision shapes'),
_(
'This activates the display of wireframe meshes showing the 3D collision shapes of objects using the 3D physics engine (box, sphere, capsule, cylinder).'
),
_(
'Enable 3D debug draw of collision shapes: _PARAM1_ (color: _PARAM2_, depth test: _PARAM3_)'
),
'',
'res/actions/planicon24.png',
'res/actions/planicon.png'
)
.addCodeOnlyParameter('currentScene', '')
.addParameter('yesorno', _('Enable 3D debug draw'), '', true)
.setDefaultValue('yes')
.addParameter('color', _('Wireframe color'), '', true)
.setDefaultValue('"0;255;0"')
.addParameter(
'yesorno',
_('Apply depth test (hide shapes behind geometry)'),
'',
true
)
.setDefaultValue('yes')
.getCodeExtraInformation()
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
.setFunctionName('gdjs.evtTools.debuggerTools.enableDebugDraw3D');
extension
.addAction(
'ToggleDebugDraw3D',
_('Toggle 3D collision shapes drawing'),
_(
'Toggles the display of wireframe meshes showing the 3D collision shapes of objects using the 3D physics engine. The last used color and depth test settings are reused.'
),
_('Toggle 3D debug draw of collision shapes'),
'',
'res/actions/planicon24.png',
'res/actions/planicon.png'
)
.addCodeOnlyParameter('currentScene', '')
.getCodeExtraInformation()
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
.setFunctionName('gdjs.evtTools.debuggerTools.toggleDebugDraw3D');
extension
.addAction(
'ConsoleLog',
_('Log a message to the console'),
_("Logs a message to the debugger's console."),
_(
'Log message _PARAM0_ of type _PARAM1_ to the console in group _PARAM2_'
),
'',
'res/actions/bug32.png',
'res/actions/bug32.png'
)
.addParameter('string', 'Message to log', '', false)
.addParameter(
'stringWithSelector',
'Message type',
'["info", "warning", "error"]',
true
)
.addParameter('string', 'Group of messages', '', true)
.getCodeExtraInformation()
.setIncludeFile('Extensions/DebuggerTools/debuggertools.js')
.setFunctionName('gdjs.evtTools.debuggerTools.log');
return extension;
},
runExtensionSanityTests: function (gd, extension) {
return [];
},
};