blob: 10da1edd5680b4d1ad5acc449cf72fc62e4f0d06 (
plain)
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
|
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorDebuggerPlugin" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A base class to implement debugger plugins.
</brief_description>
<description>
[EditorDebuggerPlugin] provides functions related to the editor side of the debugger.
To interact with the debugger, an instance of this class must be added to the editor via [method EditorPlugin.add_debugger_plugin].
Once added, the [method _setup_session] callback will be called for every [EditorDebuggerSession] available to the plugin, and when new ones are created (the sessions may be inactive during this stage).
You can retrieve the available [EditorDebuggerSession]s via [method get_sessions] or get a specific one via [method get_session].
[codeblocks]
[gdscript]
@tool
extends EditorPlugin
class ExampleEditorDebugger extends EditorDebuggerPlugin:
func _has_capture(prefix):
# Return true if you wish to handle message with this prefix.
return prefix == "my_plugin"
func _capture(message, data, session_id):
if message == "my_plugin:ping":
get_session(session_id).send_message("my_plugin:echo", data)
func _setup_session(session_id):
# Add a new tab in the debugger session UI containing a label.
var label = Label.new()
label.name = "Example plugin"
label.text = "Example plugin"
var session = get_session(session_id)
# Listens to the session started and stopped signals.
session.started.connect(func (): print("Session started"))
session.stopped.connect(func (): print("Session stopped"))
session.add_session_tab(label)
var debugger = ExampleEditorDebugger.new()
func _enter_tree():
add_debugger_plugin(debugger)
func _exit_tree():
remove_debugger_plugin(debugger)
[/gdscript]
[/codeblocks]
</description>
<tutorials>
</tutorials>
<methods>
<method name="_capture" qualifiers="virtual">
<return type="bool" />
<param index="0" name="message" type="String" />
<param index="1" name="data" type="Array" />
<param index="2" name="session_id" type="int" />
<description>
Override this method to process incoming messages. The [param session_id] is the ID of the [EditorDebuggerSession] that received the message (which you can retrieve via [method get_session]).
</description>
</method>
<method name="_has_capture" qualifiers="virtual const">
<return type="bool" />
<param index="0" name="capture" type="String" />
<description>
Override this method to enable receiving messages from the debugger. If [param capture] is "my_message" then messages starting with "my_message:" will be passes to the [method _capture] method.
</description>
</method>
<method name="_setup_session" qualifiers="virtual">
<return type="void" />
<param index="0" name="session_id" type="int" />
<description>
Override this method to be notified whenever a new [EditorDebuggerSession] is created (the session may be inactive during this stage).
</description>
</method>
<method name="get_session">
<return type="EditorDebuggerSession" />
<param index="0" name="id" type="int" />
<description>
Returns the [EditorDebuggerSession] with the given [param id].
</description>
</method>
<method name="get_sessions">
<return type="Array" />
<description>
Returns an array of [EditorDebuggerSession] currently available to this debugger plugin.
Note: Not sessions in the array may be inactive, check their state via [method EditorDebuggerSession.is_active]
</description>
</method>
</methods>
</class>
|