Ejemplo n.º 1
0
void ScriptEditorDebugger::_live_edit_set() {

	if (!connection.is_valid())
		return;

	TreeItem* ti = inspect_scene_tree->get_selected();
	if (!ti)
		return;
	String path;

	while(ti) {
		String lp=ti->get_text(0);
		path="/"+lp+path;
		ti=ti->get_parent();

	}

	NodePath np = path;

	editor->get_editor_data().set_edited_scene_live_edit_root(np);

	update_live_edit_root();


}
Ejemplo n.º 2
0
void ScriptEditorDebugger::_live_edit_clear() {

	NodePath np = NodePath("/root");
	editor->get_editor_data().set_edited_scene_live_edit_root(np);

	update_live_edit_root();

}
Ejemplo n.º 3
0
void ScriptEditorDebugger::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			inspector->edit(variables);

			step->set_icon( get_icon("DebugStep","EditorIcons"));
			next->set_icon( get_icon("DebugNext","EditorIcons"));
			back->set_icon( get_icon("Back","EditorIcons"));
			forward->set_icon( get_icon("Forward","EditorIcons"));
			dobreak->set_icon( get_icon("Pause","EditorIcons"));
			docontinue->set_icon( get_icon("DebugContinue","EditorIcons"));
			//scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
			le_set->connect("pressed",this,"_live_edit_set");
			le_clear->connect("pressed",this,"_live_edit_clear");
			error_list->connect("item_selected",this,"_error_selected");
			error_stack->connect("item_selected",this,"_error_stack_selected");
			vmem_refresh->set_icon( get_icon("Reload","EditorIcons"));

		} break;
		case NOTIFICATION_PROCESS: {

			if (connection.is_valid()) {
				inspect_scene_tree_timeout-=get_process_delta_time();
				if (inspect_scene_tree_timeout<0) {
					inspect_scene_tree_timeout=EditorSettings::get_singleton()->get("debugger/scene_tree_refresh_interval");
					if (inspect_scene_tree->is_visible()) {
						_scene_tree_request();

						if (inspected_object_id!=0) {
							//take the chance and re-inspect selected object
							Array msg;
							msg.push_back("inspect_object");
							msg.push_back(inspected_object_id);
							ppeer->put_var(msg);
						}
					}
				}

				inspect_edited_object_timeout-=get_process_delta_time();
				if (inspect_edited_object_timeout<0) {
					inspect_edited_object_timeout=EditorSettings::get_singleton()->get("debugger/remote_inspect_refresh_interval");
					if (inspect_scene_tree->is_visible() && inspected_object_id) {
						//take the chance and re-inspect selected object
						Array msg;
						msg.push_back("inspect_object");
						msg.push_back(inspected_object_id);
						ppeer->put_var(msg);
					}
				}
			}

			if (error_count!=last_error_count) {

				if (error_count==0) {
					error_split->set_name(TTR("Errors"));
					debugger_button->set_text(TTR("Debugger"));
					debugger_button->set_icon(Ref<Texture>());
					tabs->set_tab_icon(error_split->get_index(),Ref<Texture>());
				} else {
					error_split->set_name(TTR("Errors")+" ("+itos(error_count)+")");
					debugger_button->set_text(TTR("Debugger")+" ("+itos(error_count)+")");
					debugger_button->set_icon(get_icon("Error","EditorIcons"));
					tabs->set_tab_icon(error_split->get_index(),get_icon("Error","EditorIcons"));
				}
				last_error_count=error_count;
			}

			if (connection.is_null()) {

				if (server->is_connection_available()) {

					connection = server->take_connection();
					if (connection.is_null())
						break;

					EditorNode::get_log()->add_message("** Debug Process Started **");
					log_forced_visible=false;

					ppeer->set_stream_peer(connection);

					//EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
					//emit_signal("show_debugger",true);

					dobreak->set_disabled(false);
					tabs->set_current_tab(0);

					reason->set_text(TTR("Child Process Connected"));
					reason->set_tooltip(TTR("Child Process Connected"));
					profiler->clear();

					inspect_scene_tree->clear();
					le_set->set_disabled(true);
					le_clear->set_disabled(false);
					error_list->clear();
					error_stack->clear();
					error_count=0;
					profiler_signature.clear();
					//live_edit_root->set_text("/root");

					EditorNode::get_singleton()->get_pause_button()->set_pressed(false);
					EditorNode::get_singleton()->get_pause_button()->set_disabled(false);

					update_live_edit_root();
					if (profiler->is_profiling()) {
						_profiler_activate(true);
					}


				} else {

					break;
				}
			};

			if (!connection->is_connected()) {
				stop();
				editor->notify_child_process_exited(); //somehow, exited
				break;
			};

			if (ppeer->get_available_packet_count() <= 0) {
				break;
			};

			while(ppeer->get_available_packet_count() > 0) {

				if (pending_in_queue) {

					int todo = MIN( ppeer->get_available_packet_count(), pending_in_queue );

					for(int i=0;i<todo;i++) {

						Variant cmd;
						Error ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}

						message.push_back(cmd);
						pending_in_queue--;
					}


					if (pending_in_queue==0) {
						_parse_message(message_type,message);
						message.clear();

					}


				} else {

					if (ppeer->get_available_packet_count()>=2) {


						Variant cmd;
						Error ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}
						if (cmd.get_type()!=Variant::STRING) {
							stop();
							ERR_FAIL_COND(cmd.get_type()!=Variant::STRING);
						}

						message_type=cmd;
						//print_line("GOT: "+message_type);

						ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}
						if (cmd.get_type()!=Variant::INT) {
							stop();
							ERR_FAIL_COND(cmd.get_type()!=Variant::INT);
						}

						pending_in_queue=cmd;

						if (pending_in_queue==0) {
							_parse_message(message_type,Array());
							message.clear();
						}

					} else {


						break;
					}

				}
			}



		} break;
	}

}
Ejemplo n.º 4
0
void ScriptEditorDebugger::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			step->set_icon( get_icon("DebugStep","EditorIcons"));
			next->set_icon( get_icon("DebugNext","EditorIcons"));
			back->set_icon( get_icon("Back","EditorIcons"));
			forward->set_icon( get_icon("Forward","EditorIcons"));
			dobreak->set_icon( get_icon("Pause","EditorIcons"));
			docontinue->set_icon( get_icon("DebugContinue","EditorIcons"));
			tb->set_normal_texture( get_icon("Close","EditorIcons"));
			tb->set_hover_texture( get_icon("CloseHover","EditorIcons"));
			tb->set_pressed_texture( get_icon("Close","EditorIcons"));
			scene_tree_refresh->set_icon( get_icon("Reload","EditorIcons"));
			le_set->connect("pressed",this,"_live_edit_set");
			le_clear->connect("pressed",this,"_live_edit_clear");
			error_list->connect("item_selected",this,"_error_selected");
			error_stack->connect("item_selected",this,"_error_stack_selected");
			vmem_refresh->set_icon( get_icon("Reload","EditorIcons"));

		} break;
		case NOTIFICATION_PROCESS: {

			if (error_count!=last_error_count) {

				if (error_count==0) {
					error_split->set_name("Errors");
				} else {
					error_split->set_name("Errors ("+itos(error_count)+")");
				}
				last_error_count=error_count;
			}
			if (connection.is_null()) {

				if (server->is_connection_available()) {

					connection = server->take_connection();
					if (connection.is_null())
						break;

					EditorNode::get_log()->add_message("** Debug Process Started **");
					log_forced_visible=false;

					ppeer->set_stream_peer(connection);


					show();
					dobreak->set_disabled(false);
					tabs->set_current_tab(0);

					emit_signal("show_debugger",true);
					reason->set_text("Child Process Connected");
					reason->set_tooltip("Child Process Connected");
					scene_tree->clear();
					le_set->set_disabled(true);
					le_clear->set_disabled(false);
					error_list->clear();
					error_stack->clear();
					error_count=0;
					//live_edit_root->set_text("/root");

					update_live_edit_root();

				} else {

					break;
				}
			};

			if (!connection->is_connected()) {
				stop();
				editor->notify_child_process_exited(); //somehow, exited
				break;
			};

			if (ppeer->get_available_packet_count() <= 0) {
				break;
			};

			while(ppeer->get_available_packet_count() > 0) {

				if (pending_in_queue) {

					int todo = MIN( ppeer->get_available_packet_count(), pending_in_queue );

					for(int i=0;i<todo;i++) {

						Variant cmd;
						Error ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}

						message.push_back(cmd);
						pending_in_queue--;
					}


					if (pending_in_queue==0) {
						_parse_message(message_type,message);
						message.clear();

					}


				} else {

					if (ppeer->get_available_packet_count()>=2) {


						Variant cmd;
						Error ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}
						if (cmd.get_type()!=Variant::STRING) {
							stop();
							ERR_FAIL_COND(cmd.get_type()!=Variant::STRING);
						}

						message_type=cmd;

						ret = ppeer->get_var(cmd);
						if (ret!=OK) {
							stop();
							ERR_FAIL_COND(ret!=OK);
						}
						if (cmd.get_type()!=Variant::INT) {
							stop();
							ERR_FAIL_COND(cmd.get_type()!=Variant::INT);
						}

						pending_in_queue=cmd;

						if (pending_in_queue==0) {
							_parse_message(message_type,Array());
							message.clear();
						}

					} else {


						break;
					}

				}
			}



		} break;
	}

}