summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-05-22 19:28:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-05-22 19:29:06 -0300
commitb2a4908e9cc802a838a67f92dd66a17d3894c619 (patch)
treec1980369034a13728295f53f1f737b9fa7d174f5 /core
parentec7c36aa3eccaa1bb26c119041fd6c9459396a1c (diff)
Real-Time Remote Inspector support
Diffstat (limited to 'core')
-rw-r--r--core/object.cpp2
-rw-r--r--core/object.h1
-rw-r--r--core/script_debugger_remote.cpp99
-rw-r--r--core/script_debugger_remote.h3
4 files changed, 104 insertions, 1 deletions
diff --git a/core/object.cpp b/core/object.cpp
index 7f4db7c8b5..3cfc0329bc 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1396,7 +1396,7 @@ Error Object::connect(const StringName& p_signal, Object *p_to_object, const Str
signal_is_valid=true;
if (!signal_is_valid) {
- ERR_EXPLAIN("Attempt to connect nonexistent signal '"+p_signal+"' to method '"+p_to_method+"'");
+ ERR_EXPLAIN("In Object of type '"+String(get_type())+"': Attempt to connect nonexistent signal '"+p_signal+"' to method '"+p_to_object->get_type()+"."+p_to_method+"'");
ERR_FAIL_COND_V(!signal_is_valid,ERR_INVALID_PARAMETER);
}
signal_map[p_signal]=Signal();
diff --git a/core/object.h b/core/object.h
index c34440100f..3945d1d0ba 100644
--- a/core/object.h
+++ b/core/object.h
@@ -67,6 +67,7 @@ enum PropertyHint {
PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
+ PROPERTY_HINT_OBJECT_ID,
PROPERTY_HINT_MAX,
};
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 10e1b65cf3..011b1f78a0 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -283,6 +283,14 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
} else if (command=="request_video_mem") {
_send_video_memory();
+ } else if (command=="inspect_object") {
+
+ ObjectID id = cmd[1];
+ _send_object_id(id);
+ } else if (command=="set_object_property") {
+
+ _set_object_property(cmd[1],cmd[2],cmd[3]);
+
} else if (command=="breakpoint") {
bool set = cmd[3];
@@ -539,6 +547,89 @@ bool ScriptDebuggerRemote::_parse_live_edit(const Array& cmd) {
return true;
}
+
+void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
+
+ Object* obj = ObjectDB::get_instance(p_id);
+ if (!obj)
+ return;
+
+ List<PropertyInfo> pinfo;
+ obj->get_property_list(&pinfo,true);
+
+ int props_to_send=0;
+ for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+
+ if (E->get().usage&(PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CATEGORY)) {
+ props_to_send++;
+ }
+ }
+
+ packet_peer_stream->put_var("message:inspect_object");
+ packet_peer_stream->put_var(props_to_send*5+4);
+ packet_peer_stream->put_var(p_id);
+ packet_peer_stream->put_var(obj->get_type());
+ if (obj->is_type("Resource") || obj->is_type("Node"))
+ packet_peer_stream->put_var(obj->call("get_path"));
+ else
+ packet_peer_stream->put_var("");
+
+ packet_peer_stream->put_var(props_to_send);
+
+ for (List<PropertyInfo>::Element *E=pinfo.front();E;E=E->next()) {
+
+ if (E->get().usage&(PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CATEGORY)) {
+
+ if (E->get().usage&PROPERTY_USAGE_CATEGORY) {
+ packet_peer_stream->put_var("*"+E->get().name);
+ } else {
+ packet_peer_stream->put_var(E->get().name);
+ }
+
+ Variant var = obj->get(E->get().name);
+
+ if (E->get().type==Variant::OBJECT || var.get_type()==Variant::OBJECT) {
+
+ ObjectID id2;
+ Object *obj=var;
+ if (obj) {
+ id2=obj->get_instance_ID();
+ } else {
+ id2=0;
+ }
+
+ packet_peer_stream->put_var(Variant::INT); //hint string
+ packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_ID); //hint
+ packet_peer_stream->put_var(E->get().hint_string); //hint string
+ packet_peer_stream->put_var(id2); //value
+ } else {
+ packet_peer_stream->put_var(E->get().type);
+ packet_peer_stream->put_var(E->get().hint);
+ packet_peer_stream->put_var(E->get().hint_string);
+ //only send information that can be sent..
+ if (var.get_type()==Variant::IMAGE) {
+ var=Image();
+ }
+ if (var.get_type()>=Variant::DICTIONARY) {
+ var=Array(); //send none for now, may be to big
+ }
+ packet_peer_stream->put_var(var);
+ }
+
+ }
+ }
+
+}
+
+void ScriptDebuggerRemote::_set_object_property(ObjectID p_id, const String& p_property, const Variant& p_value) {
+
+ Object* obj = ObjectDB::get_instance(p_id);
+ if (!obj)
+ return;
+
+ obj->set(p_property,p_value);
+}
+
void ScriptDebuggerRemote::_poll_events() {
//this si called from ::idle_poll, happens only when running the game,
@@ -575,6 +666,14 @@ void ScriptDebuggerRemote::_poll_events() {
} else if (command=="request_video_mem") {
_send_video_memory();
+ } else if (command=="inspect_object") {
+
+ ObjectID id = cmd[1];
+ _send_object_id(id);
+ } else if (command=="set_object_property") {
+
+ _set_object_property(cmd[1],cmd[2],cmd[3]);
+
} else if (command=="start_profiling") {
for(int i=0;i<ScriptServer::get_language_count();i++) {
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index a19b4ed2bd..8fdab47013 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -111,6 +111,9 @@ class ScriptDebuggerRemote : public ScriptDebugger {
RequestSceneTreeMessageFunc request_scene_tree;
void *request_scene_tree_ud;
+ void _set_object_property(ObjectID p_id, const String& p_property, const Variant& p_value);
+
+ void _send_object_id(ObjectID p_id);
void _send_video_memory();
LiveEditFuncs *live_edit_funcs;