CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) {

	canvas_item_editor=NULL;
	editor=p_editor;
	undo_redo = editor->get_undo_redo();

	add_child( memnew( VSeparator ));
	button_create = memnew( ToolButton );
	add_child(button_create);
	button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
	button_create->set_toggle_mode(true);

	button_edit = memnew( ToolButton );
	add_child(button_edit);
	button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
	button_edit->set_toggle_mode(true);

	//add_constant_override("separation",0);

#if 0
	options = memnew( MenuButton );
	add_child(options);
	options->set_area_as_parent_rect();
	options->set_text("Polygon");
	//options->get_popup()->add_item("Parse BBCODE",PARSE_BBCODE);
	options->get_popup()->connect("item_pressed", this,"_menu_option");
#endif

	mode = MODE_EDIT;
	wip_active=false;

}
CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {

	node=NULL;
	canvas_item_editor=NULL;
	editor=p_editor;
	undo_redo = editor->get_undo_redo();

	add_child( memnew( VSeparator ));
	button_create = memnew( ToolButton );
	add_child(button_create);
	button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE));
	button_create->set_toggle_mode(true);
	button_create->set_tooltip(TTR("Create a new polygon from scratch."));

	button_edit = memnew( ToolButton );
	add_child(button_edit);
	button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT));
	button_edit->set_toggle_mode(true);
	button_edit->set_tooltip("Edit existing polygon:\nLMB: Move Point.\nCtrl+LMB: Split Segment.\nRMB: Erase Point.");

	//add_constant_override("separation",0);

#if 0
	options = memnew( MenuButton );
	add_child(options);
	options->set_area_as_parent_rect();
	options->set_text("Polygon");
	//options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE);
	options->get_popup()->connect("item_pressed", this,"_menu_option");
#endif

	mode = MODE_EDIT;
	wip_active=false;

}
void AnimationTreeEditor::_update_path() {
	while (path_hb->get_child_count() > 1) {
		memdelete(path_hb->get_child(1));
	}

	Ref<ButtonGroup> group;
	group.instance();

	Button *b = memnew(Button);
	b->set_text("root");
	b->set_toggle_mode(true);
	b->set_button_group(group);
	b->set_pressed(true);
	b->set_focus_mode(FOCUS_NONE);
	b->connect("pressed", this, "_path_button_pressed", varray(-1));
	path_hb->add_child(b);
	for (int i = 0; i < button_path.size(); i++) {
		b = memnew(Button);
		b->set_text(button_path[i]);
		b->set_toggle_mode(true);
		b->set_button_group(group);
		path_hb->add_child(b);
		b->set_pressed(true);
		b->set_focus_mode(FOCUS_NONE);
		b->connect("pressed", this, "_path_button_pressed", varray(i));
	}
}
NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) {
	node = NULL;
	canvas_item_editor = NULL;
	editor = p_editor;
	undo_redo = editor->get_undo_redo();

	add_child(memnew(VSeparator));
	button_create = memnew(ToolButton);
	add_child(button_create);
	button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
	button_create->set_toggle_mode(true);
	button_create->set_tooltip(TTR("Create a new polygon from scratch."));

	button_edit = memnew(ToolButton);
	add_child(button_edit);
	button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
	button_edit->set_toggle_mode(true);
	button_edit->set_tooltip(TTR("Edit existing polygon:") + "\n" + TTR("LMB: Move Point.") + "\n" + TTR("Ctrl+LMB: Split Segment.") + "\n" + TTR("RMB: Erase Point."));
	create_nav = memnew(ConfirmationDialog);
	add_child(create_nav);
	create_nav->get_ok()->set_text(TTR("Create"));

	mode = MODE_EDIT;
	wip_active = false;
	edited_outline = -1;
}
Ejemplo n.º 5
0
MeshEditor::MeshEditor() {

	viewport = memnew( Viewport );
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_process_input(false);

	camera = memnew( Camera );
	camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
	camera->set_perspective(45,0.1,10);
	viewport->add_child(camera);

	light1 = memnew( DirectionalLight );
	light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
	viewport->add_child(light1);

	light2 = memnew( DirectionalLight );
	light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
	light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
	light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
	viewport->add_child(light2);

	mesh_instance = memnew( MeshInstance );
	viewport->add_child(mesh_instance);



	set_custom_minimum_size(Size2(1,150));

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_area_as_parent_rect(2);

	hb->add_spacer();

	VBoxContainer *vb_light = memnew( VBoxContainer );
	hb->add_child(vb_light);

	light_1_switch = memnew( TextureButton );
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));

	light_2_switch = memnew( TextureButton );
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));

	first_enter=true;

	rot_x=0;
	rot_y=0;


}
Ejemplo n.º 6
0
MeshEditor::MeshEditor() {

	viewport = memnew(Viewport);
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_disable_input(true);
	set_stretch(true);

	camera = memnew(Camera);
	camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
	camera->set_perspective(45, 0.1, 10);
	viewport->add_child(camera);

	light1 = memnew(DirectionalLight);
	light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
	viewport->add_child(light1);

	light2 = memnew(DirectionalLight);
	light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
	light2->set_color(Color(0.7, 0.7, 0.7));
	viewport->add_child(light2);

	rotation = memnew(Spatial);
	viewport->add_child(rotation);
	mesh_instance = memnew(MeshInstance);
	rotation->add_child(mesh_instance);

	set_custom_minimum_size(Size2(1, 150) * EDSCALE);

	HBoxContainer *hb = memnew(HBoxContainer);
	add_child(hb);
	hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);

	hb->add_spacer();

	VBoxContainer *vb_light = memnew(VBoxContainer);
	hb->add_child(vb_light);

	light_1_switch = memnew(TextureButton);
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));

	light_2_switch = memnew(TextureButton);
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));

	first_enter = true;

	rot_x = 0;
	rot_y = 0;
}
Ejemplo n.º 7
0
void GraphEdit::add_child_notify(Node *p_child) {

	top_layer->call_deferred("raise"); //top layer always on top!
	GraphNode *gn = p_child->cast_to<GraphNode>();
	if (gn) {
		gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
		gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
		_graph_node_moved(gn);
		gn->set_stop_mouse(false);
	}
}
Ejemplo n.º 8
0
Path2DEditor::Path2DEditor(EditorNode *p_editor) {

	canvas_item_editor = NULL;
	editor = p_editor;
	undo_redo = editor->get_undo_redo();

	mode = MODE_EDIT;
	action = ACTION_NONE;

	base_hb = memnew(HBoxContainer);
	CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb);

	sep = memnew(VSeparator);
	base_hb->add_child(sep);
	curve_edit = memnew(ToolButton);
	curve_edit->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveEdit", "EditorIcons"));
	curve_edit->set_toggle_mode(true);
	curve_edit->set_focus_mode(Control::FOCUS_NONE);
	curve_edit->set_tooltip(TTR("Select Points") + "\n" + TTR("Shift+Drag: Select Control Points") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Click: Add Point") + "\n" + TTR("Right Click: Delete Point"));
	curve_edit->connect("pressed", this, "_mode_selected", varray(MODE_EDIT));
	base_hb->add_child(curve_edit);
	curve_edit_curve = memnew(ToolButton);
	curve_edit_curve->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCurve", "EditorIcons"));
	curve_edit_curve->set_toggle_mode(true);
	curve_edit_curve->set_focus_mode(Control::FOCUS_NONE);
	curve_edit_curve->set_tooltip(TTR("Select Control Points (Shift+Drag)"));
	curve_edit_curve->connect("pressed", this, "_mode_selected", varray(MODE_EDIT_CURVE));
	base_hb->add_child(curve_edit_curve);
	curve_create = memnew(ToolButton);
	curve_create->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveCreate", "EditorIcons"));
	curve_create->set_toggle_mode(true);
	curve_create->set_focus_mode(Control::FOCUS_NONE);
	curve_create->set_tooltip(TTR("Add Point (in empty space)") + "\n" + TTR("Split Segment (in curve)"));
	curve_create->connect("pressed", this, "_mode_selected", varray(MODE_CREATE));
	base_hb->add_child(curve_create);
	curve_del = memnew(ToolButton);
	curve_del->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveDelete", "EditorIcons"));
	curve_del->set_toggle_mode(true);
	curve_del->set_focus_mode(Control::FOCUS_NONE);
	curve_del->set_tooltip(TTR("Delete Point"));
	curve_del->connect("pressed", this, "_mode_selected", varray(MODE_DELETE));
	base_hb->add_child(curve_del);
	curve_close = memnew(ToolButton);
	curve_close->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("CurveClose", "EditorIcons"));
	curve_close->set_focus_mode(Control::FOCUS_NONE);
	curve_close->set_tooltip(TTR("Close Curve"));
	curve_close->connect("pressed", this, "_mode_selected", varray(ACTION_CLOSE));
	base_hb->add_child(curve_close);
	base_hb->hide();

	curve_edit->set_pressed(true);
}
Ejemplo n.º 9
0
void GraphEdit::add_child_notify(Node *p_child) {

	Control::add_child_notify(p_child);

	top_layer->call_deferred("raise"); //top layer always on top!
	GraphNode *gn = Object::cast_to<GraphNode>(p_child);
	if (gn) {
		gn->set_scale(Vector2(zoom, zoom));
		gn->connect("offset_changed", this, "_graph_node_moved", varray(gn));
		gn->connect("raise_request", this, "_graph_node_raised", varray(gn));
		gn->connect("item_rect_changed", connections_layer, "update");
		_graph_node_moved(gn);
		gn->set_mouse_filter(MOUSE_FILTER_PASS);
	}
}
Ejemplo n.º 10
0
Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {

	node = NULL;
	editor = p_editor;
	undo_redo = editor->get_undo_redo();

	add_child(memnew(VSeparator));
	button_create = memnew(ToolButton);
	add_child(button_create);
	button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
	button_create->set_toggle_mode(true);

	button_edit = memnew(ToolButton);
	add_child(button_edit);
	button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
	button_edit->set_toggle_mode(true);

	mode = MODE_EDIT;
	wip_active = false;
	imgeom = memnew(ImmediateGeometry);
	imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));

	line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
	line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
	line_material->set_line_width(3.0);
	line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
	line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
	line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
	line_material->set_albedo(Color(1, 1, 1));

	handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial));
	handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
	handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true);
	handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
	handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
	handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
	Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons");
	handle_material->set_point_size(handle->get_width());
	handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle);

	pointsm = memnew(MeshInstance);
	imgeom->add_child(pointsm);
	m.instance();
	pointsm->set_mesh(m);
	pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));

	snap_ignore = false;
}
Ejemplo n.º 11
0
void Polygon2DEditor::edit(Node *p_collision_polygon) {

	if (!canvas_item_editor) {
		canvas_item_editor=CanvasItemEditor::get_singleton();
	}


	if (p_collision_polygon) {

		node=p_collision_polygon->cast_to<Polygon2D>();
		if (!canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
			canvas_item_editor->get_viewport_control()->connect("draw",this,"_canvas_draw");
		node->connect("exit_tree",this,"_node_removed",varray(),CONNECT_ONESHOT);
		wip.clear();
		wip_active=false;
		edited_point=-1;

	} else {

		if (node)
			node->disconnect("exit_tree",this,"_node_removed");

		node=NULL;

		if (canvas_item_editor->get_viewport_control()->is_connected("draw",this,"_canvas_draw"))
			canvas_item_editor->get_viewport_control()->disconnect("draw",this,"_canvas_draw");

	}

}
Ejemplo n.º 12
0
void EditorDirDialog::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {
		EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "reload");
		reload();

		if (!tree->is_connected("item_collapsed", this, "_item_collapsed")) {
			tree->connect("item_collapsed", this, "_item_collapsed", varray(), CONNECT_DEFERRED);
		}

		if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed", this, "reload")) {
			EditorFileSystem::get_singleton()->connect("filesystem_changed", this, "reload");
		}
	}

	if (p_what == NOTIFICATION_EXIT_TREE) {
		EditorFileSystem::get_singleton()->disconnect("filesystem_changed", this, "reload");
	}

	if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
		if (must_reload && is_visible_in_tree()) {
			reload();
		}
	}
}
Ejemplo n.º 13
0
void VisualScript::add_node(const StringName& p_func,int p_id, const Ref<VisualScriptNode>& p_node, const Point2 &p_pos) {

	ERR_FAIL_COND(!functions.has(p_func));


	for (Map<StringName,Function>::Element *E=functions.front();E;E=E->next()) {

		ERR_FAIL_COND(E->get().nodes.has(p_id)); //id can exist only one in script, even for different functions
	}

	Function &func = functions[p_func];


	if (p_node->cast_to<VisualScriptFunction>()) {
		//the function indeed
		ERR_EXPLAIN("A function node already has been set here.");
		ERR_FAIL_COND(func.function_id>=0);

		func.function_id=p_id;
	}

	Function::NodeData nd;
	nd.node=p_node;
	nd.pos=p_pos;

	Ref<VisualScriptNode> vsn = p_node;
	vsn->connect("ports_changed",this,"_node_ports_changed",varray(p_id));
	vsn->scripts_used.insert(this);



	func.nodes[p_id]=nd;
}
Ejemplo n.º 14
0
void EditorRunNative::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {

		for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {

			Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(i);
			if (eep.is_null())
				continue;
			Ref<ImageTexture> icon = eep->get_run_icon();
			if (!icon.is_null()) {
				Ref<Image> im = icon->get_data();
				im = im->duplicate();
				im->clear_mipmaps();
				if (!im->empty()) {

					im->resize(16 * EDSCALE, 16 * EDSCALE);
					Ref<ImageTexture> small_icon;
					small_icon.instance();
					small_icon->create_from_image(im, 0);
					MenuButton *mb = memnew(MenuButton);
					mb->get_popup()->connect("id_pressed", this, "_run_native", varray(i));
					//mb->connect("pressed", this, "_run_native", varray(-1, i));
					mb->set_icon(small_icon);
					add_child(mb);
					menus[i] = mb;
				}
			}
		}
	}

	if (p_what == NOTIFICATION_PROCESS) {

		bool changed = EditorExport::get_singleton()->poll_export_platforms() || first;

		if (changed) {

			for (Map<int, MenuButton *>::Element *E = menus.front(); E; E = E->next()) {

				Ref<EditorExportPlatform> eep = EditorExport::get_singleton()->get_export_platform(E->key());
				MenuButton *mb = E->get();
				int dc = eep->get_device_count();

				if (dc == 0) {
					mb->hide();
				} else {
					mb->get_popup()->clear();
					mb->show();
					mb->set_tooltip(TTR("Select device from the list"));
					for (int i = 0; i < dc; i++) {
						mb->get_popup()->add_icon_item(get_icon("Play", "EditorIcons"), eep->get_device_name(i));
						mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() - 1, eep->get_device_info(i).strip_edges());
					}
				}
			}

			first = false;
		}
	}
}
Ejemplo n.º 15
0
void ScrollBar::set_drag_slave(const NodePath &p_path) {

	if (is_inside_tree()) {

		if (drag_slave) {
			drag_slave->disconnect("gui_input", this, "_drag_slave_input");
			drag_slave->disconnect("tree_exited", this, "_drag_slave_exit");
		}
	}

	drag_slave = NULL;
	drag_slave_path = p_path;

	if (is_inside_tree()) {

		if (has_node(p_path)) {
			Node *n = get_node(p_path);
			drag_slave = n->cast_to<Control>();
		}

		if (drag_slave) {
			drag_slave->connect("gui_input", this, "_drag_slave_input");
			drag_slave->connect("tree_exited", this, "_drag_slave_exit", varray(), CONNECT_ONESHOT);
		}
	}
}
Ejemplo n.º 16
0
GroupsEditor::GroupsEditor() {

	node=NULL;

	VBoxContainer *vbc = this;

	HBoxContainer *hbc = memnew( HBoxContainer );
	vbc->add_child(hbc);

	group_name = memnew( LineEdit );
	group_name->set_h_size_flags(SIZE_EXPAND_FILL);
	hbc->add_child(group_name);
	group_name->connect("text_entered",this,"_add_group");

	add = memnew( Button );
	add->set_text(TTR("Add"));
	hbc->add_child(add);
	add->connect("pressed", this,"_add_group", varray(String()));

	tree = memnew( Tree );
	tree->set_hide_root(true);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);
	vbc->add_child(tree);
	tree->connect("button_pressed",this,"_remove_group");
	add_constant_override("separation",3*EDSCALE);
}
Ejemplo n.º 17
0
void SceneTreeEditor::_notification(int p_what) {

	if (p_what==NOTIFICATION_ENTER_TREE) {

		get_tree()->connect("tree_changed",this,"_tree_changed");
		get_tree()->connect("node_removed",this,"_node_removed");
		get_tree()->connect("node_configuration_warning_changed",this,"_warning_changed");

		instance_menu->set_item_icon(5,get_icon("Load","EditorIcons"));
		tree->connect("item_collapsed",this,"_cell_collapsed");
		inheritance_menu->set_item_icon(2,get_icon("Load","EditorIcons"));
		clear_inherit_confirm->connect("confirmed",this,"_subscene_option",varray(SCENE_MENU_CLEAR_INHERITANCE_CONFIRM));

		EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");


//		get_scene()->connect("tree_changed",this,"_tree_changed",Vector<Variant>(),CONNECT_DEFERRED);
//		get_scene()->connect("node_removed",this,"_node_removed",Vector<Variant>(),CONNECT_DEFERRED);
		_update_tree();
	}
	if (p_what==NOTIFICATION_EXIT_TREE) {

		get_tree()->disconnect("tree_changed",this,"_tree_changed");
		get_tree()->disconnect("node_removed",this,"_node_removed");
		tree->disconnect("item_collapsed",this,"_cell_collapsed");
		clear_inherit_confirm->disconnect("confirmed",this,"_subscene_option");
		get_tree()->disconnect("node_configuration_warning_changed",this,"_warning_changed");
		EditorSettings::get_singleton()->disconnect("settings_changed",this,"_editor_settings_changed");
	}

}
void ControlEditor::_add_control(Control *p_control,const EditInfo& p_info) {

	if (controls.has(p_control))
		return;

	controls.insert(p_control,p_info);
	p_control->call_deferred("connect","visibility_changed",this,"_visibility_changed",varray(p_control->get_instance_ID()));
}
Ejemplo n.º 19
0
MenuButton::MenuButton() {

	switch_on_hover = false;
	set_flat(true);
	set_toggle_mode(true);
	set_disable_shortcuts(false);
	set_enabled_focus_mode(FOCUS_NONE);
	set_process_unhandled_key_input(true);
	set_action_mode(ACTION_MODE_BUTTON_PRESS);

	popup = memnew(PopupMenu);
	popup->hide();
	add_child(popup);
	popup->set_pass_on_modal_close_click(false);
	popup->connect("about_to_show", this, "set_pressed", varray(true)); // For when switching from another MenuButton.
	popup->connect("popup_hide", this, "set_pressed", varray(false));
}
Ejemplo n.º 20
0
void ScenesDock::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			if (initialized)
				return;
			initialized=true;

			EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed");

			button_reload->set_icon( get_icon("Reload","EditorIcons"));
			button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
			button_fav_up->set_icon( get_icon("MoveUp","EditorIcons"));
			button_fav_down->set_icon( get_icon("MoveDown","EditorIcons"));
			button_instance->set_icon( get_icon("Add","EditorIcons"));
			button_open->set_icon( get_icon("Folder","EditorIcons"));
			button_back->set_icon( get_icon("Filesystem","EditorIcons"));
			display_mode->set_icon( get_icon("FileList","EditorIcons"));
			display_mode->connect("pressed",this,"_change_file_display");
			file_options->set_icon( get_icon("Tools","EditorIcons"));
			files->connect("item_activated",this,"_select_file");
			button_hist_next->connect("pressed",this,"_fw_history");
			button_hist_prev->connect("pressed",this,"_bw_history");

			button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
			button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
			file_options->get_popup()->connect("item_pressed",this,"_file_option");


			button_back->connect("pressed",this,"_go_to_tree",varray(),CONNECT_DEFERRED);
			current_path->connect("text_entered",this,"_go_to_dir");
			_update_tree(); //maybe it finished already

			if (EditorFileSystem::get_singleton()->is_scanning()) {
				_set_scannig_mode();
			}

		} break;
		case NOTIFICATION_PROCESS: {
			if (EditorFileSystem::get_singleton()->is_scanning()) {
				scanning_progress->set_val(EditorFileSystem::get_singleton()->get_scanning_progress()*100);
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

		} break;
		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {

			display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);

			_change_file_display();
		} break;
	}

}
Ejemplo n.º 21
0
void EditorAudioBuses::_request_drop_end() {

	if (!drop_end && bus_hb->get_child_count()) {
		drop_end = memnew(EditorAudioBusDrop);

		bus_hb->add_child(drop_end);
		drop_end->set_custom_minimum_size(Object::cast_to<Control>(bus_hb->get_child(0))->get_size());
		drop_end->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
	}
}
Ejemplo n.º 22
0
void EditorAudioBuses::_update_buses() {

	while (bus_hb->get_child_count() > 0) {
		memdelete(bus_hb->get_child(0));
	}

	drop_end = NULL;

	for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {

		bool is_master = i == 0 ? true : false;
		EditorAudioBus *audio_bus = memnew(EditorAudioBus(this, is_master));
		bus_hb->add_child(audio_bus);
		audio_bus->connect("delete_request", this, "_delete_bus", varray(audio_bus), CONNECT_DEFERRED);
		audio_bus->connect("duplicate_request", this, "_duplicate_bus", varray(), CONNECT_DEFERRED);
		audio_bus->connect("vol_reset_request", this, "_reset_bus_volume", varray(audio_bus), CONNECT_DEFERRED);
		audio_bus->connect("drop_end_request", this, "_request_drop_end");
		audio_bus->connect("dropped", this, "_drop_at_index", varray(), CONNECT_DEFERRED);
	}
}
Ejemplo n.º 23
0
void SpriteRegionEditor::edit(Node *p_sprite)
{
	if (p_sprite) {
		node=p_sprite->cast_to<Sprite>();
		node->connect("exit_tree",this,"_node_removed",varray(p_sprite),CONNECT_ONESHOT);
	} else {
		if (node)
			node->disconnect("exit_tree",this,"_node_removed");
		node=NULL;
	}

}
Ejemplo n.º 24
0
void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node) {
	ERR_FAIL_INDEX(p_point, blend_points_used);
	ERR_FAIL_COND(p_node.is_null());

	if (blend_points[p_point].node.is_valid()) {
		blend_points[p_point].node->disconnect("tree_changed", this, "_tree_changed");
	}

	blend_points[p_point].node = p_node;
	blend_points[p_point].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED);

	emit_signal("tree_changed");
}
Ejemplo n.º 25
0
void VisibilityEnabler2D::_find_nodes(Node* p_node) {


	bool add=false;
	Variant meta;

	if (enabler[ENABLER_FREEZE_BODIES]) {

		RigidBody2D *rb2d = p_node->cast_to<RigidBody2D>();
		if (rb2d && ((rb2d->get_mode()==RigidBody2D::MODE_CHARACTER || (rb2d->get_mode()==RigidBody2D::MODE_RIGID && !rb2d->is_able_to_sleep())))) {


			add=true;
			meta=rb2d->get_mode();
		}
	}

	if (enabler[ENABLER_PAUSE_ANIMATIONS]) {

		AnimationPlayer *ap = p_node->cast_to<AnimationPlayer>();
		if (ap) {
			add=true;
		}

	}

	if (enabler[ENABLER_PAUSE_PARTICLES]) {

		Particles2D *ps = p_node->cast_to<Particles2D>();
		if (ps) {
			add=true;
		}

	}

	if (add) {

		p_node->connect(SceneStringNames::get_singleton()->exit_tree,this,"_node_removed",varray(p_node),CONNECT_ONESHOT);
		nodes[p_node]=meta;
		_change_node_state(p_node,false);
	}

	for(int i=0;i<p_node->get_child_count();i++) {
		Node *c = p_node->get_child(i);
		if (c->get_filename()!=String())
			continue; //skip, instance

		_find_nodes(c);
	}

}
CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) {

	node = NULL;
	canvas_item_editor = NULL;
	editor = p_editor;
	undo_redo = editor->get_undo_redo();

	add_child(memnew(VSeparator));
	button_create = memnew(ToolButton);
	add_child(button_create);
	button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE));
	button_create->set_toggle_mode(true);
	button_create->set_tooltip(TTR("Create a new polygon from scratch."));

	button_edit = memnew(ToolButton);
	add_child(button_edit);
	button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT));
	button_edit->set_toggle_mode(true);
	button_edit->set_tooltip(TTR("Edit existing polygon:\nLMB: Move Point.\nCtrl+LMB: Split Segment.\nRMB: Erase Point."));

	mode = MODE_EDIT;
	wip_active = false;
}
Ejemplo n.º 27
0
void ExportTemplateManager::_http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data) {

	if (p_status != HTTPRequest::RESULT_SUCCESS || p_code != 200) {
		EditorNode::get_singleton()->show_warning("Error getting the list of mirrors.");
		return;
	}

	String mirror_str;
	{
		PoolByteArray::Read r = p_data.read();
		mirror_str.parse_utf8((const char *)r.ptr(), p_data.size());
	}

	template_list_state->hide();
	template_download_progress->hide();

	Variant r;
	String errs;
	int errline;
	Error err = JSON::parse(mirror_str, r, errs, errline);
	if (err != OK) {
		EditorNode::get_singleton()->show_warning("Error parsing JSON of mirror list. Please report this issue!");
		return;
	}

	bool mirrors_found = false;

	Dictionary d = r;
	print_line(r);
	if (d.has("mirrors")) {
		Array mirrors = d["mirrors"];
		for (int i = 0; i < mirrors.size(); i++) {
			Dictionary m = mirrors[i];
			ERR_CONTINUE(!m.has("url") || !m.has("name"));
			LinkButton *lb = memnew(LinkButton);
			lb->set_text(m["name"]);
			lb->connect("pressed", this, "_begin_template_download", varray(m["url"]));
			template_list->add_child(lb);
			mirrors_found = true;
		}
	}

	if (!mirrors_found) {
		EditorNode::get_singleton()->show_warning(TTR("No download links found for this version. Direct download is only available for official releases."));
		return;
	}
}
Ejemplo n.º 28
0
void ProjectManager::_on_project_created(const String& dir) {
	bool has_already=false;
	for (int i=0;i<scroll_childs->get_child_count();i++) {
		HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>();
		Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>();
		if (fpath->get_text()==dir) {
			has_already=true;
			break;
		}
	}
	if (has_already) {
		_update_scroll_pos(dir);
	} else {
		_load_recent_projects();
		scroll->connect("draw", this, "_update_scroll_pos", varray(dir), CONNECT_ONESHOT);
	}
}
Ejemplo n.º 29
0
void ParticleAttractor2D::_set_owner(Particles2D* p_owner) {

	if (owner==p_owner)
		return;

	if (owner) {
		owner->disconnect("exit_tree",this,"_owner_exited");
		owner->attractors.erase(this);
		owner=NULL;
	}
	owner=p_owner;

	if (owner) {

		owner->connect("exit_tree",this,"_owner_exited",varray(),CONNECT_ONESHOT);
		owner->attractors.insert(this);
	}
}
Ejemplo n.º 30
0
void EditorAssetLibraryItemDescription::add_preview(int p_id, bool p_video, const String &p_url) {

	Preview preview;
	preview.id = p_id;
	preview.video_link = p_url;
	preview.is_video = p_video;
	preview.button = memnew(Button);
	preview.button->set_flat(true);
	preview.button->set_icon(get_icon("ThumbnailWait", "EditorIcons"));
	preview.button->set_toggle_mode(true);
	preview.button->connect("pressed", this, "_preview_click", varray(p_id));
	preview_hb->add_child(preview.button);
	if (!p_video) {
		preview.image = get_icon("ThumbnailWait", "EditorIcons");
	}
	if (preview_images.size() == 0 && !p_video) {
		_preview_click(p_id);
	}
	preview_images.push_back(preview);
}