Skip to content

Commit a2e3473

Browse files
committed
Merge pull request godotengine#98378 from dalexeev/doc-clarify-engine-debugger
Clarify `EngineDebugger` and `EditorDebugger*` documentation
2 parents 6ad513b + be41e6f commit a2e3473

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

doc/classes/EditorDebuggerPlugin.xml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@
1515

1616
class ExampleEditorDebugger extends EditorDebuggerPlugin:
1717

18-
func _has_capture(prefix):
19-
# Return true if you wish to handle message with this prefix.
20-
return prefix == "my_plugin"
18+
func _has_capture(capture):
19+
# Return true if you wish to handle messages with the prefix "my_plugin:".
20+
return capture == "my_plugin"
2121

2222
func _capture(message, data, session_id):
2323
if message == "my_plugin:ping":
2424
get_session(session_id).send_message("my_plugin:echo", data)
25+
return true
26+
return false
2527

2628
func _setup_session(session_id):
2729
# Add a new tab in the debugger session UI containing a label.
2830
var label = Label.new()
29-
label.name = "Example plugin"
31+
label.name = "Example plugin" # Will be used as the tab title.
3032
label.text = "Example plugin"
3133
var session = get_session(session_id)
3234
# Listens to the session started and stopped signals.
@@ -43,6 +45,24 @@
4345
remove_debugger_plugin(debugger)
4446
[/gdscript]
4547
[/codeblocks]
48+
To connect on the running game side, use the [EngineDebugger] singleton:
49+
[codeblocks]
50+
[gdscript]
51+
extends Node
52+
53+
func _ready():
54+
EngineDebugger.register_message_capture("my_plugin", _capture)
55+
EngineDebugger.send_message("my_plugin:ping", ["test"])
56+
57+
func _capture(message, data):
58+
# Note that the "my_plugin:" prefix is not used here.
59+
if message == "echo":
60+
prints("Echo received:", data)
61+
return true
62+
return false
63+
[/gdscript]
64+
[/codeblocks]
65+
[b]Note:[/b] While the game is running, [method @GlobalScope.print] and similar functions [i]called in the editor[/i] do not print anything, the Output Log prints only game messages.
4666
</description>
4767
<tutorials>
4868
</tutorials>
@@ -68,7 +88,7 @@
6888
<param index="1" name="data" type="Array" />
6989
<param index="2" name="session_id" type="int" />
7090
<description>
71-
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]).
91+
Override this method to process incoming messages. The [param session_id] is the ID of the [EditorDebuggerSession] that received the [param message]. Use [method get_session] to retrieve the session. This method should return [code]true[/code] if the message is recognized.
7292
</description>
7393
</method>
7494
<method name="_goto_script_line" qualifiers="virtual">
@@ -90,7 +110,7 @@
90110
<return type="void" />
91111
<param index="0" name="session_id" type="int" />
92112
<description>
93-
Override this method to be notified whenever a new [EditorDebuggerSession] is created (the session may be inactive during this stage).
113+
Override this method to be notified whenever a new [EditorDebuggerSession] is created. Note that the session may be inactive during this stage.
94114
</description>
95115
</method>
96116
<method name="get_session">

doc/classes/EditorDebuggerSession.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<return type="void" />
1515
<param index="0" name="control" type="Control" />
1616
<description>
17-
Adds the given [param control] to the debug session UI in the debugger bottom panel.
17+
Adds the given [param control] to the debug session UI in the debugger bottom panel. The [param control]'s node name will be used as the tab title.
1818
</description>
1919
</method>
2020
<method name="is_active">

doc/classes/EngineDebugger.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@
113113
<param index="1" name="callable" type="Callable" />
114114
<description>
115115
Registers a message capture with given [param name]. If [param name] is "my_message" then messages starting with "my_message:" will be called with the given callable.
116-
Callable must accept a message string and a data array as argument. If the message and data are valid then callable must return [code]true[/code] otherwise [code]false[/code].
116+
The callable must accept a message string and a data array as argument. The callable should return [code]true[/code] if the message is recognized.
117+
[b]Note:[/b] The callable will receive the message with the prefix stripped, unlike [method EditorDebuggerPlugin._capture]. See the [EditorDebuggerPlugin] description for an example.
117118
</description>
118119
</method>
119120
<method name="register_profiler">

editor/debugger/script_editor_debugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
827827

828828
bool parsed = EditorDebuggerNode::get_singleton()->plugins_capture(this, p_msg, p_data);
829829
if (!parsed) {
830-
WARN_PRINT("unknown message " + p_msg);
830+
WARN_PRINT("Unknown message: " + p_msg);
831831
}
832832
}
833833
}

0 commit comments

Comments
 (0)