summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/script_debugger_remote.cpp115
-rw-r--r--core/script_debugger_remote.h4
-rw-r--r--core/script_language.h29
-rw-r--r--core/undo_redo.cpp27
-rw-r--r--core/undo_redo.h11
5 files changed, 183 insertions, 3 deletions
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 33e9dc0fd9..15861ed4a1 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -127,7 +127,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
ERR_CONTINUE( cmd[0].get_type()!=Variant::STRING );
String command = cmd[0];
- cmd.remove(0);
+
if (command=="get_stack_dump") {
@@ -150,7 +150,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
} else if (command=="get_stack_frame_vars") {
-
+ cmd.remove(0);
ERR_CONTINUE( cmd.size()!=1 );
int lv = cmd[0];
@@ -243,6 +243,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) {
if (request_scene_tree)
request_scene_tree(request_scene_tree_ud);
+ } else {
+ _parse_live_edit(cmd);
}
@@ -301,6 +303,105 @@ void ScriptDebuggerRemote::line_poll() {
}
+bool ScriptDebuggerRemote::_parse_live_edit(const Array& cmd) {
+
+ String cmdstr = cmd[0];
+ if (!live_edit_funcs || !cmdstr.begins_with("live_"))
+ return false;
+
+
+ print_line(Variant(cmd).get_construct_string());
+ if (cmdstr=="live_set_root") {
+
+ if (!live_edit_funcs->root_func)
+ return true;
+ print_line("root: "+Variant(cmd).get_construct_string());
+ live_edit_funcs->root_func(live_edit_funcs->udata,cmd[1],cmd[2]);
+
+ } else if (cmdstr=="live_node_path") {
+
+ if (!live_edit_funcs->node_path_func)
+ return true;
+ print_line("path: "+Variant(cmd).get_construct_string());
+
+ live_edit_funcs->node_path_func(live_edit_funcs->udata,cmd[1],cmd[2]);
+
+ } else if (cmdstr=="live_res_path") {
+
+ if (!live_edit_funcs->res_path_func)
+ return true;
+ live_edit_funcs->res_path_func(live_edit_funcs->udata,cmd[1],cmd[2]);
+
+ } else if (cmdstr=="live_node_prop_res") {
+ if (!live_edit_funcs->node_set_res_func)
+ return true;
+
+ live_edit_funcs->node_set_res_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_node_prop") {
+
+ if (!live_edit_funcs->node_set_func)
+ return true;
+ live_edit_funcs->node_set_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_res_prop_res") {
+
+ if (!live_edit_funcs->res_set_res_func)
+ return true;
+ live_edit_funcs->res_set_res_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_res_prop") {
+
+ if (!live_edit_funcs->res_set_func)
+ return true;
+ live_edit_funcs->res_set_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_node_call") {
+
+ if (!live_edit_funcs->node_call_func)
+ return true;
+ live_edit_funcs->node_call_func(live_edit_funcs->udata,cmd[1],cmd[2], cmd[3],cmd[4],cmd[5],cmd[6],cmd[7]);
+
+ } else if (cmdstr=="live_res_call") {
+
+ if (!live_edit_funcs->res_call_func)
+ return true;
+ live_edit_funcs->res_call_func(live_edit_funcs->udata,cmd[1],cmd[2], cmd[3],cmd[4],cmd[5],cmd[6],cmd[7]);
+
+ } else if (cmdstr=="live_create_node") {
+
+ live_edit_funcs->tree_create_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_instance_node") {
+
+ live_edit_funcs->tree_instance_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_remove_node") {
+
+ live_edit_funcs->tree_remove_node_func(live_edit_funcs->udata,cmd[1]);
+
+ } else if (cmdstr=="live_remove_and_keep_node") {
+
+ live_edit_funcs->tree_remove_and_keep_node_func(live_edit_funcs->udata,cmd[1],cmd[2]);
+ } else if (cmdstr=="live_restore_node") {
+
+ live_edit_funcs->tree_restore_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else if (cmdstr=="live_duplicate_node") {
+
+ live_edit_funcs->tree_duplicate_node_func(live_edit_funcs->udata,cmd[1],cmd[2]);
+ } else if (cmdstr=="live_reparent_node") {
+
+ live_edit_funcs->tree_reparent_node_func(live_edit_funcs->udata,cmd[1],cmd[2],cmd[3]);
+
+ } else {
+
+ return false;
+ }
+
+ return true;
+}
+
void ScriptDebuggerRemote::_poll_events() {
while(packet_peer_stream->get_available_packet_count()>0) {
@@ -321,7 +422,7 @@ void ScriptDebuggerRemote::_poll_events() {
ERR_CONTINUE( cmd[0].get_type()!=Variant::STRING );
String command = cmd[0];
- cmd.remove(0);
+ //cmd.remove(0);
if (command=="break") {
@@ -331,6 +432,8 @@ void ScriptDebuggerRemote::_poll_events() {
if (request_scene_tree)
request_scene_tree(request_scene_tree_ud);
+ } else {
+ _parse_live_edit(cmd);
}
}
@@ -413,6 +516,11 @@ void ScriptDebuggerRemote::set_request_scene_tree_message_func(RequestSceneTreeM
request_scene_tree_ud=p_udata;
}
+void ScriptDebuggerRemote::set_live_edit_funcs(LiveEditFuncs *p_funcs) {
+
+ live_edit_funcs=p_funcs;
+}
+
ScriptDebuggerRemote::ScriptDebuggerRemote() {
tcp_client = StreamPeerTCP::create_ref();
@@ -429,6 +537,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
last_perf_time=0;
poll_every=0;
request_scene_tree=NULL;
+ live_edit_funcs=NULL;
}
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 89b9947c4b..748b77eccd 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -62,9 +62,12 @@ class ScriptDebuggerRemote : public ScriptDebugger {
uint32_t poll_every;
+ bool _parse_live_edit(const Array &p_command);
+
RequestSceneTreeMessageFunc request_scene_tree;
void *request_scene_tree_ud;
+ LiveEditFuncs *live_edit_funcs;
public:
@@ -79,6 +82,7 @@ public:
virtual void send_message(const String& p_message, const Array& p_args);
virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata);
+ virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs);
ScriptDebuggerRemote();
~ScriptDebuggerRemote();
diff --git a/core/script_language.h b/core/script_language.h
index 7104fe4547..8b0ed2c33b 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -238,6 +238,32 @@ public:
typedef void (*RequestSceneTreeMessageFunc)(void *);
+ struct LiveEditFuncs {
+
+ void *udata;
+ void (*node_path_func)(void *,const NodePath &p_path,int p_id);
+ void (*res_path_func)(void *,const String &p_path,int p_id);
+
+ void (*node_set_func)(void *,int p_id,const StringName& p_prop,const Variant& p_value);
+ void (*node_set_res_func)(void *,int p_id,const StringName& p_prop,const String& p_value);
+ void (*node_call_func)(void *,int p_id,const StringName& p_method,VARIANT_ARG_DECLARE);
+ void (*res_set_func)(void *,int p_id,const StringName& p_prop,const Variant& p_value);
+ void (*res_set_res_func)(void *,int p_id,const StringName& p_prop,const String& p_value);
+ void (*res_call_func)(void *,int p_id,const StringName& p_method,VARIANT_ARG_DECLARE);
+ void (*root_func)(void*, const NodePath& p_scene_path,const String& p_scene_from);
+
+ void (*tree_create_node_func)(void*,const NodePath& p_parent,const String& p_type,const String& p_name);
+ void (*tree_instance_node_func)(void*,const NodePath& p_parent,const String& p_path,const String& p_name);
+ void (*tree_remove_node_func)(void*,const NodePath& p_at);
+ void (*tree_remove_and_keep_node_func)(void*,const NodePath& p_at,ObjectID p_keep_id);
+ void (*tree_restore_node_func)(void*,ObjectID p_id,const NodePath& p_at,int p_at_pos);
+ void (*tree_duplicate_node_func)(void*,const NodePath& p_at,const String& p_new_name);
+ void (*tree_reparent_node_func)(void*,const NodePath& p_at,const NodePath& p_new_place,const String& p_new_name);
+
+ };
+
+
+
_FORCE_INLINE_ static ScriptDebugger * get_singleton() { return singleton; }
void set_lines_left(int p_left);
int get_lines_left() const;
@@ -252,10 +278,12 @@ public:
bool is_breakpoint_line(int p_line) const;
void clear_breakpoints();
+
virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true)=0;
virtual void idle_poll();
virtual void line_poll();
+
void set_break_language(ScriptLanguage *p_lang);
ScriptLanguage* get_break_language() const;
@@ -265,6 +293,7 @@ public:
virtual void request_quit() {}
virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata) {}
+ virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs) {}
ScriptDebugger();
virtual ~ScriptDebugger() {singleton=NULL;}
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index f565070216..85cc2bbc7f 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -244,7 +244,12 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
Resource* res = obj->cast_to<Resource>();
if (res)
res->set_edited(true);
+
#endif
+
+ if (method_callback) {
+ method_callback(method_callbck_ud,obj,op.name,VARIANT_ARGS_FROM_ARRAY(op.args));
+ }
} break;
case Operation::TYPE_PROPERTY: {
@@ -254,6 +259,9 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
if (res)
res->set_edited(true);
#endif
+ if (property_callback) {
+ property_callback(prop_callback_ud,obj,op.name,op.args[0]);
+ }
} break;
case Operation::TYPE_REFERENCE: {
//do nothing
@@ -325,6 +333,19 @@ void UndoRedo::set_commit_notify_callback(CommitNotifyCallback p_callback,void*
callback_ud=p_ud;
}
+void UndoRedo::set_method_notify_callback(MethodNotifyCallback p_method_callback,void* p_ud) {
+
+ method_callback=p_method_callback;
+ method_callbck_ud=p_ud;
+}
+
+void UndoRedo::set_property_notify_callback(PropertyNotifyCallback p_property_callback,void* p_ud){
+
+ property_callback=p_property_callback;
+ prop_callback_ud=p_ud;
+}
+
+
UndoRedo::UndoRedo() {
version=1;
@@ -334,6 +355,12 @@ UndoRedo::UndoRedo() {
merging=true;
callback=NULL;
callback_ud=NULL;
+
+ method_callbck_ud=NULL;
+ prop_callback_ud=NULL;
+ method_callback=NULL;
+ property_callback=NULL;
+
}
UndoRedo::~UndoRedo() {
diff --git a/core/undo_redo.h b/core/undo_redo.h
index a9187534c1..141a413c2a 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -45,6 +45,9 @@ public:
Variant _add_do_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
Variant _add_undo_method(const Variant** p_args, int p_argcount, Variant::CallError& r_error);
+ typedef void (*MethodNotifyCallback)(void *p_ud,Object*p_base,const StringName& p_name,VARIANT_ARG_DECLARE);
+ typedef void (*PropertyNotifyCallback)(void *p_ud,Object*p_base,const StringName& p_property,const Variant& p_value);
+
private:
struct Operation {
@@ -83,6 +86,11 @@ private:
CommitNotifyCallback callback;
void* callback_ud;
+ void* method_callbck_ud;
+ void* prop_callback_ud;
+
+ MethodNotifyCallback method_callback;
+ PropertyNotifyCallback property_callback;
protected:
@@ -113,6 +121,9 @@ public:
void set_commit_notify_callback(CommitNotifyCallback p_callback,void* p_ud);
+ void set_method_notify_callback(MethodNotifyCallback p_method_callback,void* p_ud);
+ void set_property_notify_callback(PropertyNotifyCallback p_property_callback,void* p_ud);
+
UndoRedo();
~UndoRedo();
};