You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 19:41:11 +00:00
Merge pull request #12930 from vnen/gdscrit-output-print
Make tool scripts print on the editor Output panel
This commit is contained in:
@@ -82,7 +82,25 @@ void print_line(String p_string) {
|
|||||||
PrintHandlerList *l = print_handler_list;
|
PrintHandlerList *l = print_handler_list;
|
||||||
while (l) {
|
while (l) {
|
||||||
|
|
||||||
l->printfunc(l->userdata, p_string);
|
l->printfunc(l->userdata, p_string, false);
|
||||||
|
l = l->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
_global_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_error(String p_string) {
|
||||||
|
|
||||||
|
if (!_print_error_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data());
|
||||||
|
|
||||||
|
_global_lock();
|
||||||
|
PrintHandlerList *l = print_handler_list;
|
||||||
|
while (l) {
|
||||||
|
|
||||||
|
l->printfunc(l->userdata, p_string, true);
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
extern void (*_print_func)(String);
|
extern void (*_print_func)(String);
|
||||||
|
|
||||||
typedef void (*PrintHandlerFunc)(void *, const String &p_string);
|
typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error);
|
||||||
|
|
||||||
struct PrintHandlerList {
|
struct PrintHandlerList {
|
||||||
|
|
||||||
@@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler);
|
|||||||
extern bool _print_line_enabled;
|
extern bool _print_line_enabled;
|
||||||
extern bool _print_error_enabled;
|
extern bool _print_error_enabled;
|
||||||
extern void print_line(String p_string);
|
extern void print_line(String p_string);
|
||||||
|
extern void print_error(String p_string);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
|
|||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) {
|
void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) {
|
||||||
|
|
||||||
ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this;
|
ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this;
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
|
|||||||
uint64_t msec_count;
|
uint64_t msec_count;
|
||||||
|
|
||||||
bool locking; //hack to avoid a deadloop
|
bool locking; //hack to avoid a deadloop
|
||||||
static void _print_handler(void *p_this, const String &p_string);
|
static void _print_handler(void *p_this, const String &p_string, bool p_error);
|
||||||
|
|
||||||
PrintHandlerList phl;
|
PrintHandlerList phl;
|
||||||
|
|
||||||
|
|||||||
@@ -4552,6 +4552,11 @@ static Node *_resource_get_edited_scene() {
|
|||||||
return EditorNode::get_singleton()->get_edited_scene();
|
return EditorNode::get_singleton()->get_edited_scene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) {
|
||||||
|
EditorNode *en = (EditorNode *)p_this;
|
||||||
|
en->log->add_message(p_string, p_error);
|
||||||
|
}
|
||||||
|
|
||||||
EditorNode::EditorNode() {
|
EditorNode::EditorNode() {
|
||||||
|
|
||||||
Resource::_get_local_scene_func = _resource_get_edited_scene;
|
Resource::_get_local_scene_func = _resource_get_edited_scene;
|
||||||
@@ -5652,6 +5657,10 @@ EditorNode::EditorNode() {
|
|||||||
_dim_timer->connect("timeout", this, "_dim_timeout");
|
_dim_timer->connect("timeout", this, "_dim_timeout");
|
||||||
add_child(_dim_timer);
|
add_child(_dim_timer);
|
||||||
|
|
||||||
|
print_handler.printfunc = _print_handler;
|
||||||
|
print_handler.userdata = this;
|
||||||
|
add_print_handler(&print_handler);
|
||||||
|
|
||||||
ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1);
|
ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1);
|
||||||
ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2);
|
ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2);
|
||||||
ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3
|
ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3
|
||||||
@@ -5663,6 +5672,7 @@ EditorNode::EditorNode() {
|
|||||||
|
|
||||||
EditorNode::~EditorNode() {
|
EditorNode::~EditorNode() {
|
||||||
|
|
||||||
|
remove_print_handler(&print_handler);
|
||||||
memdelete(EditorHelp::get_doc_data());
|
memdelete(EditorHelp::get_doc_data());
|
||||||
memdelete(editor_selection);
|
memdelete(editor_selection);
|
||||||
memdelete(editor_plugins_over);
|
memdelete(editor_plugins_over);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#ifndef EDITOR_NODE_H
|
#ifndef EDITOR_NODE_H
|
||||||
#define EDITOR_NODE_H
|
#define EDITOR_NODE_H
|
||||||
|
|
||||||
|
#include "core/print_string.h"
|
||||||
#include "editor/connections_dialog.h"
|
#include "editor/connections_dialog.h"
|
||||||
#include "editor/create_dialog.h"
|
#include "editor/create_dialog.h"
|
||||||
#include "editor/editor_about.h"
|
#include "editor/editor_about.h"
|
||||||
@@ -610,6 +611,9 @@ private:
|
|||||||
|
|
||||||
Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
|
Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
|
||||||
|
|
||||||
|
PrintHandlerList print_handler;
|
||||||
|
static void _print_handler(void *p_this, const String &p_string, bool p_error);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_
|
|||||||
}
|
}
|
||||||
|
|
||||||
//str+="\n";
|
//str+="\n";
|
||||||
OS::get_singleton()->printerr("%s\n", str.utf8().get_data());
|
print_error(str);
|
||||||
r_ret = Variant();
|
r_ret = Variant();
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|||||||
@@ -1109,7 +1109,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
|
|||||||
String str = *p_inputs[0];
|
String str = *p_inputs[0];
|
||||||
|
|
||||||
//str+="\n";
|
//str+="\n";
|
||||||
OS::get_singleton()->printerr("%s\n", str.utf8().get_data());
|
print_error(str);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
|
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
|
||||||
|
|||||||
Reference in New Issue
Block a user