Skip to content

Commit

Permalink
Add Live View panel
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Aug 29, 2019
1 parent 89e3dfe commit 3ed12e5
Show file tree
Hide file tree
Showing 11 changed files with 524 additions and 7 deletions.
26 changes: 26 additions & 0 deletions core/script_debugger_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "core/project_settings.h"
#include "scene/main/node.h"
#include "scene/resources/packed_scene.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_live_view.h"
#endif

void ScriptDebuggerRemote::_send_video_memory() {

Expand Down Expand Up @@ -279,6 +282,11 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
if (request_scene_tree)
request_scene_tree(request_scene_tree_ud);

} else if (command == "request_framebuffer") {
#ifdef TOOLS_ENABLED
if (live_view_helper)
live_view_helper->handle_request_framebuffer(cmd[1], cmd[2]);
#endif
} else if (command == "request_video_mem") {

_send_video_memory();
Expand Down Expand Up @@ -729,6 +737,11 @@ void ScriptDebuggerRemote::_poll_events() {

if (request_scene_tree)
request_scene_tree(request_scene_tree_ud);
} else if (command == "request_framebuffer") {
#ifdef TOOLS_ENABLED
if (live_view_helper)
live_view_helper->handle_request_framebuffer(cmd[1], cmd[2]);
#endif
} else if (command == "request_video_mem") {

_send_video_memory();
Expand Down Expand Up @@ -1056,6 +1069,16 @@ void ScriptDebuggerRemote::set_request_scene_tree_message_func(RequestSceneTreeM
request_scene_tree_ud = p_udata;
}

#ifdef TOOLS_ENABLED
LiveViewDebugHelper *ScriptDebuggerRemote::get_live_view_helper() {
return live_view_helper;
}

void ScriptDebuggerRemote::set_live_view_helper(LiveViewDebugHelper *p_live_view_helper) {
live_view_helper = p_live_view_helper;
}
#endif

void ScriptDebuggerRemote::set_live_edit_funcs(LiveEditFuncs *p_funcs) {

live_edit_funcs = p_funcs;
Expand Down Expand Up @@ -1129,6 +1152,9 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() :
locking(false),
poll_every(0),
request_scene_tree(NULL),
#ifdef TOOLS_ENABLED
live_view_helper(NULL),
#endif
live_edit_funcs(NULL) {

packet_peer_stream->set_stream_peer(tcp_client);
Expand Down
9 changes: 9 additions & 0 deletions core/script_debugger_remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class ScriptDebuggerRemote : public ScriptDebugger {
RequestSceneTreeMessageFunc request_scene_tree;
void *request_scene_tree_ud;

#ifdef TOOLS_ENABLED
LiveViewDebugHelper *live_view_helper;
#endif

void _set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value);

void _send_object_id(ObjectID p_id);
Expand Down Expand Up @@ -169,6 +173,11 @@ class ScriptDebuggerRemote : public ScriptDebugger {
virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata);
virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs);

#ifdef TOOLS_ENABLED
virtual LiveViewDebugHelper *get_live_view_helper();
virtual void set_live_view_helper(LiveViewDebugHelper *p_live_view_helper);
#endif

virtual bool is_profiling() const;
virtual void add_profiling_frame_data(const StringName &p_name, const Array &p_data);

Expand Down
9 changes: 9 additions & 0 deletions core/script_language.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "core/resource.h"

class ScriptLanguage;
#ifdef TOOLS_ENABLED
class LiveViewDebugHelper;
#endif

typedef void (*ScriptEditRequestFunction)(const String &p_path);

Expand Down Expand Up @@ -422,6 +425,7 @@ class ScriptDebugger {

public:
typedef void (*RequestSceneTreeMessageFunc)(void *);
typedef void (*RequestFramebufferMessageFunc)(void *);

struct LiveEditFuncs {

Expand Down Expand Up @@ -477,6 +481,11 @@ class ScriptDebugger {
virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata) {}
virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs) {}

#ifdef TOOLS_ENABLED
virtual LiveViewDebugHelper *get_live_view_helper() { return NULL; }
virtual void set_live_view_helper(LiveViewDebugHelper *p_live_view_helper) {}
#endif

virtual bool is_profiling() const = 0;
virtual void add_profiling_frame_data(const StringName &p_name, const Array &p_data) = 0;
virtual void profiling_start() = 0;
Expand Down
Loading

0 comments on commit 3ed12e5

Please sign in to comment.