Beispiel #1
0
ImportDock::ImportDock() {

	imported = memnew(LineEdit);
	imported->set_editable(false);
	add_child(imported);
	HBoxContainer *hb = memnew(HBoxContainer);
	add_margin_child(TTR("Import As:"), hb);
	import_as = memnew(OptionButton);
	hb->add_child(import_as);
	import_as->set_h_size_flags(SIZE_EXPAND_FILL);
	preset = memnew(MenuButton);
	preset->set_text(TTR("Preset.."));
	preset->get_popup()->connect("index_pressed", this, "_preset_selected");
	hb->add_child(preset);

	import_opts = memnew(PropertyEditor);
	add_child(import_opts);
	import_opts->set_v_size_flags(SIZE_EXPAND_FILL);
	import_opts->hide_top_label();
	import_opts->set_hide_script(true);

	hb = memnew(HBoxContainer);
	add_child(hb);
	import = memnew(Button);
	import->set_text(TTR("Reimport"));
	import->connect("pressed", this, "_reimport");
	hb->add_spacer();
	hb->add_child(import);
	hb->add_spacer();

	params = memnew(ImportDockParameters);
	import_opts->edit(params);
}
Beispiel #2
0
	NewProjectDialog() {


		VBoxContainer *vb = memnew( VBoxContainer );
		add_child(vb);
		set_child_rect(vb);

		Label* l = memnew(Label);
		l->set_text("Project Path:");
		vb->add_child(l);
		pp=l;

		project_path = memnew( LineEdit );
		MarginContainer *mc = memnew( MarginContainer );
		vb->add_child(mc);
		HBoxContainer *pphb = memnew( HBoxContainer );
		mc->add_child(pphb);
		pphb->add_child(project_path);
		project_path->set_h_size_flags(SIZE_EXPAND_FILL);

		Button* browse = memnew( Button );
		pphb->add_child(browse);
		browse->set_text("Browse");
		browse->connect("pressed", this,"_browse_path");

		l = memnew(Label);
		l->set_text("Project Name:");
		l->set_pos(Point2(5,50));
		vb->add_child(l);
		pn=l;

		project_name = memnew( LineEdit );
		mc = memnew( MarginContainer );
		vb->add_child(mc);
		mc->add_child(project_name);
		project_name->set_text("New Game Project");


		l = memnew(Label);
		l->set_text("That's a BINGO!");
		vb->add_child(l);
		error=l;
		l->add_color_override("font_color",Color(1,0.4,0.3,0.8));
		l->set_align(Label::ALIGN_CENTER);

		get_ok()->set_text("Create");
		DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
		project_path->set_text(d->get_current_dir());
		memdelete(d);

		fdialog = memnew( FileDialog );
		add_child(fdialog);
		fdialog->set_access(FileDialog::ACCESS_FILESYSTEM);
		project_name->connect("text_changed", this,"_text_changed");
		project_path->connect("text_changed", this,"_path_text_changed");
		fdialog->connect("dir_selected", this,"_path_selected");
		fdialog->connect("file_selected", this,"_file_selected");
		set_hide_on_ok(false);
		import_mode=false;
	}
Beispiel #3
0
EditorLog::EditorLog() {

	VBoxContainer *vb = memnew( VBoxContainer);
	add_child(vb);
	vb->set_v_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *hb = memnew( HBoxContainer );
	vb->add_child(hb);
	title = memnew( Label );
	title->set_text(" Output:");
	title->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(title);


	button = memnew( ToolButton );
	button->set_text_align(Button::ALIGN_LEFT);
	button->connect("pressed",this,"_flip_request");
	button->set_focus_mode(FOCUS_NONE);
	button->set_clip_text(true);
	button->set_tooltip("Open/Close output panel.");

	//pd = memnew( PaneDrag );
	//hb->add_child(pd);
	//pd->connect("dragged",this,"_dragged");
	//pd->set_default_cursor_shape(Control::CURSOR_MOVE);

	tb = memnew( TextureButton );
	hb->add_child(tb);
	tb->connect("pressed",this,"_close_request");


	ec = memnew( EmptyControl);
	vb->add_child(ec);
	ec->set_minsize(Size2(0,100));
	ec->set_v_size_flags(SIZE_EXPAND_FILL);


	PanelContainer *pc = memnew( PanelContainer );
	pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
	ec->add_child(pc);
	pc->set_area_as_parent_rect();

	log = memnew( RichTextLabel );
	log->set_scroll_follow(true);
	pc->add_child(log);
	add_message(VERSION_FULL_NAME" (c) 2010-2014 www.fengei.com.");
	//log->add_text("Initialization Complete.\n"); //because it looks cool.
	add_style_override("panel",get_stylebox("panelf","Panel"));

	eh.errfunc=_error_handler;
	eh.userdata=this;
	add_error_handler(&eh);

	current=Thread::get_caller_ID();

	EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);

	hide();

}
SpriteEditor::SpriteEditor() {

	options = memnew(MenuButton);

	CanvasItemEditor::get_singleton()->add_control_to_menu_panel(options);

	options->set_text(TTR("Sprite"));
	options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_icon("Sprite", "EditorIcons"));

	options->get_popup()->add_item(TTR("Convert to Mesh2D"), MENU_OPTION_CONVERT_TO_MESH_2D);
	options->get_popup()->add_item(TTR("Convert to Polygon2D"), MENU_OPTION_CONVERT_TO_POLYGON_2D);
	options->get_popup()->add_item(TTR("Create CollisionPolygon2D Sibling"), MENU_OPTION_CREATE_COLLISION_POLY_2D);
	options->get_popup()->add_item(TTR("Create LightOccluder2D Sibling"), MENU_OPTION_CREATE_LIGHT_OCCLUDER_2D);
	options->set_switch_on_hover(true);

	options->get_popup()->connect("id_pressed", this, "_menu_option");

	err_dialog = memnew(AcceptDialog);
	add_child(err_dialog);

	debug_uv_dialog = memnew(ConfirmationDialog);
	debug_uv_dialog->get_ok()->set_text(TTR("Create Mesh2D"));
	debug_uv_dialog->set_title("Mesh 2D Preview");
	VBoxContainer *vb = memnew(VBoxContainer);
	debug_uv_dialog->add_child(vb);
	ScrollContainer *scroll = memnew(ScrollContainer);
	scroll->set_custom_minimum_size(Size2(800, 500) * EDSCALE);
	scroll->set_enable_h_scroll(true);
	scroll->set_enable_v_scroll(true);
	vb->add_margin_child(TTR("Preview:"), scroll, true);
	debug_uv = memnew(Control);
	debug_uv->connect("draw", this, "_debug_uv_draw");
	scroll->add_child(debug_uv);
	debug_uv_dialog->connect("confirmed", this, "_create_node");

	HBoxContainer *hb = memnew(HBoxContainer);
	hb->add_child(memnew(Label(TTR("Simplification: "))));
	simplification = memnew(SpinBox);
	simplification->set_min(0.01);
	simplification->set_max(10.00);
	simplification->set_step(0.01);
	simplification->set_value(2);
	hb->add_child(simplification);
	hb->add_spacer();
	hb->add_child(memnew(Label(TTR("Grow (Pixels): "))));
	island_merging = memnew(SpinBox);
	island_merging->set_min(0);
	island_merging->set_max(10);
	island_merging->set_step(1);
	island_merging->set_value(2);
	hb->add_child(island_merging);
	hb->add_spacer();
	update_preview = memnew(Button);
	update_preview->set_text(TTR("Update Preview"));
	update_preview->connect("pressed", this, "_update_mesh_data");
	hb->add_child(update_preview);
	vb->add_margin_child(TTR("Settings:"), hb);

	add_child(debug_uv_dialog);
}
	EditorMeshImportDialog(EditorMeshImportPlugin *p_plugin) {

		plugin=p_plugin;

		set_title(TTR("Single Mesh Import"));
		set_hide_on_ok(false);

		VBoxContainer *vbc = memnew( VBoxContainer );
		add_child(vbc);
		//set_child_rect(vbc);

		HBoxContainer *hbc = memnew( HBoxContainer );
		vbc->add_margin_child(TTR("Source Mesh(es):"),hbc);

		import_path = memnew( LineEdit );
		import_path->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(import_path);

		Button * import_choose = memnew( Button );
		import_choose->set_text(" .. ");
		hbc->add_child(import_choose);

		import_choose->connect("pressed", this,"_browse");

		hbc = memnew( HBoxContainer );
		vbc->add_margin_child(TTR("Target Path:"),hbc);

		save_path = memnew( LineEdit );
		save_path->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(save_path);

		Button * save_choose = memnew( Button );
		save_choose->set_text(" .. ");
		hbc->add_child(save_choose);

		save_choose->connect("pressed", this,"_browse_target");

		file_select = memnew( EditorFileDialog );
		file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
		file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES);
		file_select->add_filter("*.obj ; Wavefront OBJ");
		add_child(file_select);
		file_select->connect("files_selected", this,"_choose_files");

		save_select = memnew( EditorDirDialog );
		add_child(save_select);
		save_select->connect("dir_selected", this,"_choose_save_dir");

		get_ok()->connect("pressed", this,"_import");
		get_ok()->set_text(TTR("Import"));

		error_dialog = memnew( AcceptDialog );
		add_child(error_dialog);

		options = memnew( _EditorMeshImportOptions );

		option_editor = memnew( PropertyEditor );
		option_editor->hide_top_label();
		vbc->add_margin_child(TTR("Options:"),option_editor,true);
	}
Beispiel #6
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);
}
EditorPropertyRootMotion::EditorPropertyRootMotion() {

	HBoxContainer *hbc = memnew(HBoxContainer);
	add_child(hbc);
	assign = memnew(Button);
	assign->set_flat(true);
	assign->set_h_size_flags(SIZE_EXPAND_FILL);
	assign->set_clip_text(true);
	assign->connect("pressed", this, "_node_assign");
	hbc->add_child(assign);

	clear = memnew(Button);
	clear->set_flat(true);
	clear->connect("pressed", this, "_node_clear");
	hbc->add_child(clear);

	filter_dialog = memnew(ConfirmationDialog);
	add_child(filter_dialog);
	filter_dialog->set_title(TTR("Edit Filtered Tracks:"));
	filter_dialog->connect("confirmed", this, "_confirmed");

	filters = memnew(Tree);
	filter_dialog->add_child(filters);
	filters->set_v_size_flags(SIZE_EXPAND_FILL);
	filters->set_hide_root(true);
	filters->connect("item_activated", this, "_confirmed");
	//filters->connect("item_edited", this, "_filter_edited");
}
Beispiel #8
0
EditorAssetLibraryItem::EditorAssetLibraryItem() {

	Ref<StyleBoxEmpty> border;
	border.instance();
	/*border->set_default_margin(MARGIN_LEFT,5);
	border->set_default_margin(MARGIN_RIGHT,5);
	border->set_default_margin(MARGIN_BOTTOM,5);
	border->set_default_margin(MARGIN_TOP,5);*/
	add_style_override("panel",border);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);

	icon = memnew( TextureButton );
	icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
	icon->connect("pressed",this,"_asset_clicked");

	hb->add_child(icon);

	VBoxContainer *vb = memnew( VBoxContainer );

	hb->add_child(vb);
	vb->set_h_size_flags(SIZE_EXPAND_FILL);

	title = memnew( LinkButton );
	title->set_text("My Awesome Addon");
	title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_asset_clicked");
	vb->add_child(title);


	category = memnew( LinkButton );
	category->set_text("Editor Tools");
	category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_category_clicked");
	vb->add_child(category);

	author = memnew( LinkButton );
	author->set_text("Johny Tolengo");
	author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_author_clicked");
	vb->add_child(author);

	HBoxContainer *rating_hb = memnew( HBoxContainer );
	vb->add_child(rating_hb);

	for(int i=0;i<5;i++) {
		stars[i]=memnew(TextureFrame);
		rating_hb->add_child(stars[i]);
	}
	price = memnew( Label );
	price->set_text("Free");
	vb->add_child(price);

	set_custom_minimum_size(Size2(250,100));
	set_h_size_flags(SIZE_EXPAND_FILL);

	set_stop_mouse(false);
}
Variant SceneTreeEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
	if (!can_rename)
		return Variant(); //not editable tree

	Vector<Node *> selected;
	Vector<Ref<Texture> > icons;
	TreeItem *next = tree->get_next_selected(NULL);
	while (next) {

		NodePath np = next->get_metadata(0);

		Node *n = get_node(np);
		if (n) {
			// Only allow selection if not part of an instanced scene.
			if (!n->get_owner() || n->get_owner() == get_scene_node() || n->get_owner()->get_filename() == String()) {
				selected.push_back(n);
				icons.push_back(next->get_icon(0));
			}
		}
		next = tree->get_next_selected(next);
	}

	if (selected.empty())
		return Variant();

	VBoxContainer *vb = memnew(VBoxContainer);
	Array objs;
	int list_max = 10;
	float opacity_step = 1.0f / list_max;
	float opacity_item = 1.0f;
	for (int i = 0; i < selected.size(); i++) {

		if (i < list_max) {
			HBoxContainer *hb = memnew(HBoxContainer);
			TextureRect *tf = memnew(TextureRect);
			tf->set_texture(icons[i]);
			hb->add_child(tf);
			Label *label = memnew(Label(selected[i]->get_name()));
			hb->add_child(label);
			vb->add_child(hb);
			hb->set_modulate(Color(1, 1, 1, opacity_item));
			opacity_item -= opacity_step;
		}
		NodePath p = selected[i]->get_path();
		objs.push_back(p);
	}

	set_drag_preview(vb);
	Dictionary drag_data;
	drag_data["type"] = "nodes";
	drag_data["nodes"] = objs;

	tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM);
	emit_signal("nodes_dragged");

	return drag_data;
}
EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {

	VBoxContainer *vbox = memnew( VBoxContainer );
	add_child(vbox);
	set_child_rect(vbox);


	HBoxContainer *hbox = memnew( HBoxContainer);
	vbox->add_child(hbox);
	vbox->add_constant_override("separation",15);
	VBoxContainer *desc_vbox = memnew( VBoxContainer );
	hbox->add_child(desc_vbox);
	hbox->add_constant_override("separation",15);

	item = memnew( EditorAssetLibraryItem );

	desc_vbox->add_child(item);
	desc_vbox->set_custom_minimum_size(Size2(300,0));


	PanelContainer * desc_bg = memnew( PanelContainer );
	desc_vbox->add_child(desc_bg);
	desc_bg->set_v_size_flags(SIZE_EXPAND_FILL);

	description = memnew( RichTextLabel );
	description->connect("meta_clicked",this,"_link_click");
	//desc_vbox->add_child(description);
	desc_bg->add_child(description);
	desc_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));

	preview = memnew( TextureFrame );
	preview->set_custom_minimum_size(Size2(640,345));
	hbox->add_child(preview);

	PanelContainer * previews_bg = memnew( PanelContainer );
	vbox->add_child(previews_bg);
	previews_bg->set_custom_minimum_size(Size2(0,85));
	previews_bg->add_style_override("panel",get_stylebox("normal","TextEdit"));

	previews = memnew( ScrollContainer );
	previews_bg->add_child(previews);
	previews->set_enable_v_scroll(false);
	previews->set_enable_h_scroll(true);
	preview_hb = memnew( HBoxContainer );
	preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);

	previews->add_child(preview_hb);
	get_ok()->set_text("Install");
	get_cancel()->set_text("Close");



}
Beispiel #11
0
EditorLog::EditorLog() {

	VBoxContainer *vb = this;
	add_constant_override("separation",get_constant("separation","VBoxContainer"));

	HBoxContainer *hb = memnew( HBoxContainer );
	vb->add_child(hb);
	title = memnew( Label );
	title->set_text(" Output:");
	title->set_h_size_flags(SIZE_EXPAND_FILL);
	hb->add_child(title);

	//pd = memnew( PaneDrag );
	//hb->add_child(pd);
	//pd->connect("dragged",this,"_dragged");
	//pd->set_default_cursor_shape(Control::CURSOR_MOVE);

	clearbutton = memnew( Button );
	hb->add_child(clearbutton);
	clearbutton->set_text(TTR("Clear"));
	clearbutton->connect("pressed", this,"_clear_request");

	ec = memnew( Control);
	vb->add_child(ec);
	ec->set_custom_minimum_size(Size2(0,180));
	ec->set_v_size_flags(SIZE_EXPAND_FILL);


	PanelContainer *pc = memnew( PanelContainer );
	pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
	ec->add_child(pc);
	pc->set_area_as_parent_rect();

	log = memnew( RichTextLabel );
	log->set_scroll_follow(true);
	log->set_selection_enabled(true);
	log->set_focus_mode(FOCUS_CLICK);
	pc->add_child(log);
	add_message(VERSION_FULL_NAME" (c) 2008-2016 Juan Linietsky, Ariel Manzur.");
	//log->add_text("Initialization Complete.\n"); //because it looks cool.

	eh.errfunc=_error_handler;
	eh.userdata=this;
	add_error_handler(&eh);

	current=Thread::get_caller_ID();

	EditorNode::get_undo_redo()->set_commit_notify_callback(_undo_redo_cbk,this);


}
ResourcePreloaderEditor::ResourcePreloaderEditor() {

	//add_style_override("panel", get_stylebox("panel","Panel"));

	VBoxContainer *vbc = memnew( VBoxContainer );
	add_child(vbc);

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

	load = memnew( Button );
	load->set_tooltip("Load Resource");
	hbc->add_child(load);



	_delete = memnew( Button );
	hbc->add_child(_delete);

	paste = memnew( Button );
	paste->set_text("Paste");
	hbc->add_child(paste);

	file = memnew( FileDialog );
	add_child(file);


	tree = memnew( Tree );
	tree->set_columns(2);
	tree->set_column_min_width(0,3);
	tree->set_column_min_width(1,1);
	tree->set_column_expand(0,true);
	tree->set_column_expand(1,true);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);

	vbc->add_child(tree);

	dialog = memnew( AcceptDialog );
	add_child( dialog );

	load->connect("pressed", this,"_load_pressed");
	_delete->connect("pressed", this,"_delete_pressed");
	paste->connect("pressed", this,"_paste_pressed");
	file->connect("file_selected", this,"_file_load_request");
	//dialog->connect("confirmed", this,"_delete_confirm_pressed");
	tree->connect("item_edited", this,"_item_edited");
	loading_scene=false;

}
Beispiel #13
0
ItemListEditor::ItemListEditor() {

	selected_idx=-1;
	options = memnew( MenuButton );
	add_child(options);
	options->set_area_as_parent_rect();

	options->set_text("Items");
	options->get_popup()->add_item("Edit Items",MENU_EDIT_ITEMS);
	//options->get_popup()->add_item("Clear",MENU_CLEAR);

	options->get_popup()->connect("item_pressed", this,"_menu_option");

	dialog = memnew( AcceptDialog );
	add_child( dialog );



	HBoxContainer *hbc = memnew( HBoxContainer );

	dialog->add_child(hbc);
	dialog->set_child_rect(hbc);

	prop_editor = memnew( PropertyEditor );

	hbc->add_child(prop_editor);
	prop_editor->set_h_size_flags(SIZE_EXPAND_FILL);

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

	add_button = memnew( Button );
	//add_button->set_text("Add");
	add_button->connect("pressed",this,"_add_button");
	vbc->add_child(add_button);

	del_button = memnew( Button );
	//del_button->set_text("Del");
	del_button->connect("pressed",this,"_delete_button");
	vbc->add_child(del_button);

	dialog->set_title("Item List");
	prop_editor->hide_top_label();



}
Beispiel #14
0
EditorSubScene::EditorSubScene() {

	scene = NULL;
	is_root = false;

	set_title(TTR("Select Node(s) to Import"));
	set_hide_on_ok(false);

	VBoxContainer *vb = memnew(VBoxContainer);
	add_child(vb);
	//set_child_rect(vb);

	HBoxContainer *hb = memnew(HBoxContainer);
	path = memnew(LineEdit);
	path->connect("text_entered", this, "_path_changed");
	hb->add_child(path);
	path->set_h_size_flags(SIZE_EXPAND_FILL);
	Button *b = memnew(Button);
	b->set_text(" .. ");
	hb->add_child(b);
	b->connect("pressed", this, "_path_browse");
	vb->add_margin_child(TTR("Scene Path:"), hb);

	tree = memnew(Tree);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);
	vb->add_margin_child(TTR("Import From Node:"), tree, true);
	tree->set_select_mode(Tree::SELECT_MULTI);
	tree->connect("multi_selected", this, "_item_multi_selected");
	//tree->connect("nothing_selected", this, "_deselect_items");
	tree->connect("cell_selected", this, "_selected_changed");

	tree->connect("item_activated", this, "_ok", make_binds(), CONNECT_DEFERRED);

	file_dialog = memnew(EditorFileDialog);
	List<String> extensions;
	ResourceLoader::get_recognized_extensions_for_type("PackedScene", &extensions);

	for (List<String>::Element *E = extensions.front(); E; E = E->next()) {

		file_dialog->add_filter("*." + E->get());
	}

	file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
	add_child(file_dialog);
	file_dialog->connect("file_selected", this, "_path_selected");
}
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;


}
EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {

	VBoxContainer *vbox = memnew(VBoxContainer);
	add_child(vbox);

	HBoxContainer *hbox = memnew(HBoxContainer);
	vbox->add_child(hbox);
	vbox->add_constant_override("separation", 15 * EDSCALE);
	VBoxContainer *desc_vbox = memnew(VBoxContainer);
	hbox->add_child(desc_vbox);
	hbox->add_constant_override("separation", 15 * EDSCALE);

	item = memnew(EditorAssetLibraryItem);

	desc_vbox->add_child(item);
	desc_vbox->set_custom_minimum_size(Size2(300 * EDSCALE, 0));

	desc_bg = memnew(PanelContainer);
	desc_vbox->add_child(desc_bg);
	desc_bg->set_v_size_flags(SIZE_EXPAND_FILL);

	description = memnew(RichTextLabel);
	description->connect("meta_clicked", this, "_link_click");
	desc_bg->add_child(description);

	preview = memnew(TextureRect);
	preview->set_custom_minimum_size(Size2(640 * EDSCALE, 345 * EDSCALE));
	hbox->add_child(preview);

	previews_bg = memnew(PanelContainer);
	vbox->add_child(previews_bg);
	previews_bg->set_custom_minimum_size(Size2(0, 101 * EDSCALE));

	previews = memnew(ScrollContainer);
	previews_bg->add_child(previews);
	previews->set_enable_v_scroll(false);
	previews->set_enable_h_scroll(true);
	preview_hb = memnew(HBoxContainer);
	preview_hb->set_v_size_flags(SIZE_EXPAND_FILL);

	previews->add_child(preview_hb);
	get_ok()->set_text(TTR("Download"));
	get_cancel()->set_text(TTR("Close"));
}
ItemListEditor::ItemListEditor() {

	selected_idx=-1;

	add_child( memnew( VSeparator ) );

	toolbar_button = memnew( ToolButton );
	toolbar_button->set_text(TTR("Items"));
	add_child(toolbar_button);
	toolbar_button->connect("pressed",this,"_edit_items");

	dialog = memnew( AcceptDialog );
	dialog->set_title(TTR("Item List Editor"));
	add_child( dialog );

	VBoxContainer *vbc = memnew( VBoxContainer );
	dialog->add_child(vbc);
	dialog->set_child_rect(vbc);

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

	add_button = memnew( Button );
	add_button->set_text(TTR("Add"));
	hbc->add_child(add_button);
	add_button->connect("pressed",this,"_add_button");

	hbc->add_spacer();

	del_button = memnew( Button );
	del_button->set_text(TTR("Delete"));
	hbc->add_child(del_button);
	del_button->connect("pressed",this,"_delete_button");

	property_editor = memnew( PropertyEditor );
	property_editor->hide_top_label();
	property_editor->set_subsection_selectable(true);
	vbc->add_child(property_editor);
	property_editor->set_v_size_flags(SIZE_EXPAND_FILL);

	tree = property_editor->get_scene_tree();
}
Beispiel #18
0
Variant ProjectExportDialog::get_drag_data_fw(const Point2 &p_point, Control *p_from) {

	if (p_from == presets) {
		int pos = presets->get_item_at_position(p_point, true);

		if (pos >= 0) {
			Dictionary d;
			d["type"] = "export_preset";
			d["preset"] = pos;

			HBoxContainer *drag = memnew(HBoxContainer);
			TextureRect *tr = memnew(TextureRect);
			tr->set_texture(presets->get_item_icon(pos));
			drag->add_child(tr);
			Label *label = memnew(Label);
			label->set_text(presets->get_item_text(pos));
			drag->add_child(label);

			set_drag_preview(drag);

			return d;
		}
	} else if (p_from == patches) {

		TreeItem *item = patches->get_item_at_position(p_point);

		if (item && item->get_cell_mode(0) == TreeItem::CELL_MODE_CHECK) {

			int metadata = item->get_metadata(0);
			Dictionary d;
			d["type"] = "export_patch";
			d["patch"] = metadata;

			Label *label = memnew(Label);
			label->set_text(item->get_text(0));
			set_drag_preview(label);

			return d;
		}
	}

	return Variant();
}
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;
}
ResourcePreloaderEditor::ResourcePreloaderEditor() {

	//add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("panel","Panel"));

	VBoxContainer *vbc = memnew(VBoxContainer);
	add_child(vbc);

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

	load = memnew(Button);
	load->set_tooltip(TTR("Load Resource"));
	hbc->add_child(load);

	paste = memnew(Button);
	paste->set_text(TTR("Paste"));
	hbc->add_child(paste);

	file = memnew(EditorFileDialog);
	add_child(file);

	tree = memnew(Tree);
	tree->connect("button_pressed", this, "_cell_button_pressed");
	tree->set_columns(2);
	tree->set_column_min_width(0, 2);
	tree->set_column_min_width(1, 3);
	tree->set_column_expand(0, true);
	tree->set_column_expand(1, true);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);

	tree->set_drag_forwarding(this);
	vbc->add_child(tree);

	dialog = memnew(AcceptDialog);
	add_child(dialog);

	load->connect("pressed", this, "_load_pressed");
	paste->connect("pressed", this, "_paste_pressed");
	file->connect("files_selected", this, "_files_load_request");
	tree->connect("item_edited", this, "_item_edited");
	loading_scene = false;
}
DependencyEditor::DependencyEditor() {

	VBoxContainer *vb = memnew( VBoxContainer );
	vb->set_name(TTR("Dependencies"));
	add_child(vb);
	set_child_rect(vb);

	tree = memnew( Tree );
	tree->set_columns(2);
	tree->set_column_titles_visible(true);
	tree->set_column_title(0,"Resource");
	tree->set_column_title(1,"Path");
	tree->set_hide_root(true);
	tree->connect("button_pressed",this,"_load_pressed");

	HBoxContainer *hbc = memnew( HBoxContainer );
	Label *label = memnew( Label(TTR("Dependencies:")));
	hbc->add_child(label);
	hbc->add_spacer();
	fixdeps = memnew( Button(TTR("Fix Broken")));
	hbc->add_child(fixdeps);
	fixdeps->connect("pressed",this,"_fix_all");

	vb->add_child(hbc);

	MarginContainer *mc = memnew( MarginContainer );
	mc->set_v_size_flags(SIZE_EXPAND_FILL);

	mc->add_child(tree);
	vb->add_child(mc);

	set_title(TTR("Dependency Editor"));
	search = memnew( EditorFileDialog );
	search->connect("file_selected",this,"_searched");
	search->set_mode(EditorFileDialog::MODE_OPEN_FILE);
	search->set_title(TTR("Search Replacement Resource:"));
	add_child(search);

}
Beispiel #22
0
EditorSubScene::EditorSubScene() {

	set_title("Select Sub-Scene..");
	VBoxContainer *vb = memnew( VBoxContainer );
	add_child(vb);
	set_child_rect(vb);

	HBoxContainer *hb = memnew( HBoxContainer );
	path = memnew( LineEdit );
	path->connect("text_entered",this,"_path_changed");
	hb->add_child(path);
	path->set_h_size_flags(SIZE_EXPAND_FILL);
	Button *b = memnew( Button );
	b->set_text(" .. ");
	hb->add_child(b);
	b->connect("pressed",this,"_path_browse");
	vb->add_margin_child("Scene Path:",hb);
	tree = memnew( Tree );
	tree->set_v_size_flags(SIZE_EXPAND_FILL);
	vb->add_margin_child("Import From Node:",tree)->set_v_size_flags(SIZE_EXPAND_FILL);

	file_dialog = memnew( FileDialog );
	List<String> extensions;
	ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions);

	for(List<String>::Element *E = extensions.front();E;E=E->next() ) {

		file_dialog->add_filter("*."+E->get());
	}

	file_dialog->set_mode(FileDialog::MODE_OPEN_FILE);
	add_child(file_dialog);
	file_dialog->connect("file_selected",this,"_path_selected");

	scene=NULL;

	set_hide_on_ok(false);

}
Beispiel #23
0
ConnectionsDock::ConnectionsDock(EditorNode *p_editor) {

	editor=p_editor;
	set_name(TTR("Signals"));


	VBoxContainer *vbc = this;

	tree = memnew( Tree );
	tree->set_columns(1);
	tree->set_select_mode(Tree::SELECT_ROW);
	tree->set_hide_root(true);
	vbc->add_child(tree);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);

	connect_button = memnew( Button );
	connect_button->set_text("Connect");
	HBoxContainer *hb = memnew( HBoxContainer);
	vbc->add_child(hb);
	hb->add_spacer();
	hb->add_child(connect_button);
	connect_button->connect("pressed",this,"_connect_pressed");
	//add_child(tree);

	connect_dialog = memnew( ConnectDialog );
	connect_dialog->set_as_toplevel(true);
	add_child(connect_dialog);

	remove_confirm = memnew( ConfirmationDialog );
	remove_confirm->set_as_toplevel(true);
	add_child(remove_confirm);

	/*
	node_only->set_anchor( MARGIN_TOP, ANCHOR_END );
	node_only->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
	node_only->set_anchor( MARGIN_RIGHT, ANCHOR_END );

	node_only->set_begin( Point2( 20,51) );
	node_only->set_end( Point2( 10,44) );
	*/


	remove_confirm->connect("confirmed", this,"_remove_confirm");
	connect_dialog->connect("connected", this,"_connect");
	tree->connect("item_selected", this,"_something_selected");
	tree->connect("item_activated", this,"_something_activated");

	add_constant_override("separation",3*EDSCALE);
}
Beispiel #24
0
ColorPicker::ColorPicker() :
		BoxContainer(true) {

	updating = true;
	edit_alpha = true;
	text_is_constructor = false;
	raw_mode_enabled = false;
	deferred_mode_enabled = false;
	changing_color = false;
	screen = NULL;

	HBoxContainer *hb_smpl = memnew(HBoxContainer);
	btn_pick = memnew(ToolButton);
	btn_pick->connect("pressed", this, "_screen_pick_pressed");

	sample = memnew(TextureRect);
	sample->set_h_size_flags(SIZE_EXPAND_FILL);
	sample->connect("draw", this, "_sample_draw");

	hb_smpl->add_child(sample);
	hb_smpl->add_child(btn_pick);
	add_child(hb_smpl);

	HBoxContainer *hb_edit = memnew(HBoxContainer);
	hb_edit->set_v_size_flags(SIZE_EXPAND_FILL);

	uv_edit = memnew(Control);

	uv_edit->connect("gui_input", this, "_uv_input");
	uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
	uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
	uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
	uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height")));
	uv_edit->connect("draw", this, "_hsv_draw", make_binds(0, uv_edit));

	add_child(hb_edit);

	w_edit = memnew(Control);
	w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
	w_edit->set_h_size_flags(SIZE_FILL);
	w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
	w_edit->connect("gui_input", this, "_w_input");
	w_edit->connect("draw", this, "_hsv_draw", make_binds(1, w_edit));

	hb_edit->add_child(uv_edit);
	hb_edit->add_child(memnew(VSeparator));
	hb_edit->add_child(w_edit);

	VBoxContainer *vbl = memnew(VBoxContainer);
	add_child(vbl);

	add_child(memnew(HSeparator));

	VBoxContainer *vbr = memnew(VBoxContainer);
	add_child(vbr);
	vbr->set_h_size_flags(SIZE_EXPAND_FILL);
	const char *lt[4] = { "R", "G", "B", "A" };

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

		HBoxContainer *hbc = memnew(HBoxContainer);

		labels[i] = memnew(Label(lt[i]));
		labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0));
		labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
		hbc->add_child(labels[i]);

		scroll[i] = memnew(HSlider);
		scroll[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
		scroll[i]->set_focus_mode(FOCUS_NONE);
		hbc->add_child(scroll[i]);

		values[i] = memnew(SpinBox);
		scroll[i]->share(values[i]);
		hbc->add_child(values[i]);
		values[i]->get_line_edit()->connect("focus_entered", this, "_focus_enter");
		values[i]->get_line_edit()->connect("focus_exited", this, "_focus_exit");

		scroll[i]->set_min(0);
		scroll[i]->set_page(0);
		scroll[i]->set_h_size_flags(SIZE_EXPAND_FILL);

		scroll[i]->connect("value_changed", this, "_value_changed");

		vbr->add_child(hbc);
	}

	HBoxContainer *hhb = memnew(HBoxContainer);

	btn_mode = memnew(CheckButton);
	btn_mode->set_text(TTR("Raw Mode"));
	btn_mode->connect("toggled", this, "set_raw_mode");
	hhb->add_child(btn_mode);
	vbr->add_child(hhb);
	text_type = memnew(Button);
	text_type->set_flat(true);
	text_type->connect("pressed", this, "_text_type_toggled");
	hhb->add_child(text_type);

	c_text = memnew(LineEdit);
	hhb->add_child(c_text);
	c_text->connect("text_entered", this, "_html_entered");
	c_text->connect("focus_entered", this, "_focus_enter");
	c_text->connect("focus_exited", this, "_html_focus_exit");

	text_type->set_text("#");
	c_text->set_h_size_flags(SIZE_EXPAND_FILL);

	_update_controls();
	updating = false;

	set_pick_color(Color(1, 1, 1));

	HBoxContainer *bbc = memnew(HBoxContainer);
	add_child(bbc);

	preset = memnew(TextureRect);
	bbc->add_child(preset);
	preset->connect("gui_input", this, "_preset_input");
	preset->connect("draw", this, "_update_presets");

	bt_add_preset = memnew(Button);
	bt_add_preset->set_tooltip(TTR("Add current color as a preset"));
	bt_add_preset->connect("pressed", this, "_add_preset_pressed");
	bbc->add_child(bt_add_preset);
}
void ExportTemplateManager::_update_template_list() {

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

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

	DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
	Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir());

	d->list_dir_begin();
	Set<String> templates;

	if (err == OK) {

		bool isdir;
		String c = d->get_next(&isdir);
		while (c != String()) {
			if (isdir && !c.begins_with(".")) {
				templates.insert(c);
			}
			c = d->get_next(&isdir);
		}
	}
	d->list_dir_end();

	memdelete(d);

	String current_version = VERSION_FULL_CONFIG;

	Label *current = memnew(Label);
	current->set_h_size_flags(SIZE_EXPAND_FILL);
	current_hb->add_child(current);

	if (templates.has(current_version)) {
		current->add_color_override("font_color", get_color("success_color", "Editor"));
		Button *redownload = memnew(Button);
		redownload->set_text(TTR("Re-Download"));
		current_hb->add_child(redownload);
		redownload->connect("pressed", this, "_download_template", varray(current_version));

		Button *uninstall = memnew(Button);
		uninstall->set_text(TTR("Uninstall"));
		current_hb->add_child(uninstall);
		current->set_text(current_version + " " + TTR("(Installed)"));
		uninstall->connect("pressed", this, "_uninstall_template", varray(current_version));

	} else {
		current->add_color_override("font_color", get_color("error_color", "Editor"));
		Button *redownload = memnew(Button);
		redownload->set_text(TTR("Download"));
		redownload->connect("pressed", this, "_download_template", varray(current_version));
		current_hb->add_child(redownload);
		current->set_text(current_version + " " + TTR("(Missing)"));
	}

	for (Set<String>::Element *E = templates.back(); E; E = E->prev()) {

		HBoxContainer *hbc = memnew(HBoxContainer);
		Label *version = memnew(Label);
		version->set_modulate(get_color("disabled_font_color", "Editor"));
		String text = E->get();
		if (text == current_version) {
			text += " " + TTR("(Current)");
		}
		version->set_text(text);
		version->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(version);

		Button *uninstall = memnew(Button);

		uninstall->set_text(TTR("Uninstall"));
		hbc->add_child(uninstall);
		uninstall->connect("pressed", this, "_uninstall_template", varray(E->get()));

		installed_vb->add_child(hbc);
	}
}
SpriteFramesEditor::SpriteFramesEditor() {

	//add_style_override("panel", get_stylebox("panel","Panel"));

	split = memnew(HSplitContainer);
	add_child(split);

	VBoxContainer *vbc_animlist = memnew(VBoxContainer);
	split->add_child(vbc_animlist);
	vbc_animlist->set_custom_minimum_size(Size2(150, 0));
	//vbc_animlist->set_v_size_flags(SIZE_EXPAND_FILL);

	VBoxContainer *sub_vb = memnew(VBoxContainer);
	vbc_animlist->add_margin_child(TTR("Animations"), sub_vb, true);
	sub_vb->set_v_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *hbc_animlist = memnew(HBoxContainer);
	sub_vb->add_child(hbc_animlist);

	new_anim = memnew(Button);
	hbc_animlist->add_child(new_anim);
	new_anim->connect("pressed", this, "_animation_add");

	hbc_animlist->add_spacer();

	remove_anim = memnew(Button);
	hbc_animlist->add_child(remove_anim);
	remove_anim->connect("pressed", this, "_animation_remove");

	animations = memnew(Tree);
	sub_vb->add_child(animations);
	animations->set_v_size_flags(SIZE_EXPAND_FILL);
	animations->set_hide_root(true);
	animations->connect("cell_selected", this, "_animation_select");
	animations->connect("item_edited", this, "_animation_name_edited");
	animations->set_single_select_cell_editing_only_when_already_selected(true);

	anim_speed = memnew(SpinBox);
	vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
	anim_speed->set_min(0);
	anim_speed->set_max(100);
	anim_speed->set_step(0.01);
	anim_speed->connect("value_changed", this, "_animation_fps_changed");

	anim_loop = memnew(CheckButton);
	anim_loop->set_text(TTR("Loop"));
	vbc_animlist->add_child(anim_loop);
	anim_loop->connect("pressed", this, "_animation_loop_changed");

	VBoxContainer *vbc = memnew(VBoxContainer);
	split->add_child(vbc);
	vbc->set_h_size_flags(SIZE_EXPAND_FILL);

	sub_vb = memnew(VBoxContainer);
	vbc->add_margin_child(TTR("Animation Frames"), sub_vb, true);

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

	//animations = memnew( ItemList );

	load = memnew(Button);
	load->set_tooltip(TTR("Load Resource"));
	hbc->add_child(load);

	copy = memnew(Button);
	copy->set_text(TTR("Copy"));
	hbc->add_child(copy);

	paste = memnew(Button);
	paste->set_text(TTR("Paste"));
	hbc->add_child(paste);

	empty = memnew(Button);
	empty->set_text(TTR("Insert Empty (Before)"));
	hbc->add_child(empty);

	empty2 = memnew(Button);
	empty2->set_text(TTR("Insert Empty (After)"));
	hbc->add_child(empty2);

	move_up = memnew(Button);
	move_up->set_text(TTR("Up"));
	hbc->add_child(move_up);

	move_down = memnew(Button);
	move_down->set_text(TTR("Down"));
	hbc->add_child(move_down);

	_delete = memnew(Button);
	hbc->add_child(_delete);

	file = memnew(EditorFileDialog);
	add_child(file);

	tree = memnew(ItemList);
	tree->set_v_size_flags(SIZE_EXPAND_FILL);
	tree->set_icon_mode(ItemList::ICON_MODE_TOP);

	int thumbnail_size = 96;
	tree->set_max_columns(0);
	tree->set_icon_mode(ItemList::ICON_MODE_TOP);
	tree->set_fixed_column_width(thumbnail_size * 3 / 2);
	tree->set_max_text_lines(2);
	tree->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size));
	//tree->set_min_icon_size(Size2(thumbnail_size,thumbnail_size));
	tree->set_drag_forwarding(this);

	sub_vb->add_child(tree);

	dialog = memnew(AcceptDialog);
	add_child(dialog);

	load->connect("pressed", this, "_load_pressed");
	_delete->connect("pressed", this, "_delete_pressed");
	copy->connect("pressed", this, "_copy_pressed");
	paste->connect("pressed", this, "_paste_pressed");
	empty->connect("pressed", this, "_empty_pressed");
	empty2->connect("pressed", this, "_empty2_pressed");
	move_up->connect("pressed", this, "_up_pressed");
	move_down->connect("pressed", this, "_down_pressed");
	file->connect("files_selected", this, "_file_load_request");
	//dialog->connect("confirmed", this,"_delete_confirm_pressed");
	//tree->connect("item_selected", this,"_item_edited");
	loading_scene = false;
	sel = -1;

	updating = false;

	edited_anim = "default";
}
	EditorTranslationImportDialog(EditorTranslationImportPlugin *p_plugin) {

		plugin=p_plugin;


		set_title(TTR("Import Translation"));

		VBoxContainer *vbc = memnew( VBoxContainer );
		add_child(vbc);
		set_child_rect(vbc);



		VBoxContainer *csvb = memnew( VBoxContainer );

		HBoxContainer *hbc = memnew( HBoxContainer );
		csvb->add_child(hbc);
		vbc->add_margin_child(TTR("Source CSV:"),csvb);

		import_path = memnew( LineEdit );
		import_path->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(import_path);
		ignore_first = memnew( CheckButton );
		ignore_first->set_text(TTR("Ignore First Row"));
		csvb->add_child(ignore_first);

		Button * import_choose = memnew( Button );
		import_choose->set_text(" .. ");
		hbc->add_child(import_choose);

		import_choose->connect("pressed", this,"_browse");

		VBoxContainer *tcomp = memnew( VBoxContainer);
		hbc = memnew( HBoxContainer );
		tcomp->add_child(hbc);
		vbc->add_margin_child(TTR("Target Path:"),tcomp);

		save_path = memnew( LineEdit );
		save_path->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(save_path);

		Button * save_choose = memnew( Button );
		save_choose->set_text(" .. ");
		hbc->add_child(save_choose);

		save_choose->connect("pressed", this,"_browse_target");

		compress = memnew( CheckButton);
		compress->set_pressed(true);
		compress->set_text(TTR("Compress"));
		tcomp->add_child(compress);

		add_to_project = memnew( CheckButton);
		add_to_project->set_pressed(true);
		add_to_project->set_text(TTR("Add to Project (engine.cfg)"));
		tcomp->add_child(add_to_project);

		file_select = memnew(EditorFileDialog);
		file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
		add_child(file_select);
		file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE);
		file_select->connect("file_selected", this,"_choose_file");
		file_select->add_filter("*.csv ; Translation CSV");
		save_select = memnew(	EditorDirDialog );
		add_child(save_select);

	//	save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR);
		save_select->connect("dir_selected", this,"_choose_save_dir");

		get_ok()->connect("pressed", this,"_import");
		get_ok()->set_text(TTR("Import"));


		error_dialog = memnew ( ConfirmationDialog );
		add_child(error_dialog);
		error_dialog->get_ok()->set_text(TTR("Accept"));
	//	error_dialog->get_cancel()->hide();

		set_hide_on_ok(false);

		columns = memnew( Tree );
		vbc->add_margin_child(TTR("Import Languages:"),columns,true);
	}
void VisualShaderEditor::_update_graph() {

	if (updating)
		return;

	if (visual_shader.is_null())
		return;

	graph->set_scroll_ofs(visual_shader->get_graph_offset() * EDSCALE);

	VisualShader::Type type = VisualShader::Type(edit_type->get_selected());
	graph->clear_connections();
	//erase all nodes
	for (int i = 0; i < graph->get_child_count(); i++) {

		if (Object::cast_to<GraphNode>(graph->get_child(i))) {
			memdelete(graph->get_child(i));
			i--;
		}
	}

	static const Color type_color[3] = {
		Color::html("#61daf4"),
		Color::html("#d67dee"),
		Color::html("#f6a86e")
	};

	List<VisualShader::Connection> connections;
	visual_shader->get_node_connections(type, &connections);

	Ref<StyleBoxEmpty> label_style = make_empty_stylebox(2, 1, 2, 1);

	Vector<int> nodes = visual_shader->get_node_list(type);

	for (int n_i = 0; n_i < nodes.size(); n_i++) {

		Vector2 position = visual_shader->get_node_position(type, nodes[n_i]);
		Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, nodes[n_i]);

		GraphNode *node = memnew(GraphNode);
		graph->add_child(node);

		/*if (!vsnode->is_connected("changed", this, "_node_changed")) {
			vsnode->connect("changed", this, "_node_changed", varray(vsnode->get_instance_id()), CONNECT_DEFERRED);
		}*/

		node->set_offset(position);

		node->set_title(vsnode->get_caption());
		node->set_name(itos(nodes[n_i]));

		if (nodes[n_i] >= 2) {
			node->set_show_close_button(true);
			node->connect("close_request", this, "_delete_request", varray(nodes[n_i]), CONNECT_DEFERRED);
		}

		node->connect("dragged", this, "_node_dragged", varray(nodes[n_i]));

		Control *custom_editor = NULL;
		int port_offset = 0;

		Ref<VisualShaderNodeUniform> uniform = vsnode;
		if (uniform.is_valid()) {
			LineEdit *uniform_name = memnew(LineEdit);
			uniform_name->set_text(uniform->get_uniform_name());
			node->add_child(uniform_name);
			uniform_name->connect("text_entered", this, "_line_edit_changed", varray(uniform_name, nodes[n_i]));
			uniform_name->connect("focus_exited", this, "_line_edit_focus_out", varray(uniform_name, nodes[n_i]));

			if (vsnode->get_input_port_count() == 0 && vsnode->get_output_port_count() == 1 && vsnode->get_output_port_name(0) == "") {
				//shortcut
				VisualShaderNode::PortType port_right = vsnode->get_output_port_type(0);
				node->set_slot(0, false, VisualShaderNode::PORT_TYPE_SCALAR, Color(), true, port_right, type_color[port_right]);
				continue;
			}
			port_offset++;
		}

		for (int i = 0; i < plugins.size(); i++) {
			custom_editor = plugins.write[i]->create_editor(vsnode);
			if (custom_editor) {
				break;
			}
		}

		if (custom_editor && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == "")) {
			//will be embedded in first port
		} else if (custom_editor) {
			port_offset++;
			node->add_child(custom_editor);
			custom_editor = NULL;
		}

		for (int i = 0; i < MAX(vsnode->get_input_port_count(), vsnode->get_output_port_count()); i++) {

			if (vsnode->is_port_separator(i)) {
				node->add_child(memnew(HSeparator));
				port_offset++;
			}

			bool valid_left = i < vsnode->get_input_port_count();
			VisualShaderNode::PortType port_left = VisualShaderNode::PORT_TYPE_SCALAR;
			bool port_left_used = false;
			String name_left;
			if (valid_left) {
				name_left = vsnode->get_input_port_name(i);
				port_left = vsnode->get_input_port_type(i);
				for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {
					if (E->get().to_node == nodes[n_i] && E->get().to_port == i) {
						port_left_used = true;
					}
				}
			}

			bool valid_right = i < vsnode->get_output_port_count();
			VisualShaderNode::PortType port_right = VisualShaderNode::PORT_TYPE_SCALAR;
			String name_right;
			if (valid_right) {
				name_right = vsnode->get_output_port_name(i);
				port_right = vsnode->get_output_port_type(i);
			}

			HBoxContainer *hb = memnew(HBoxContainer);

			Variant default_value;

			if (valid_left && !port_left_used) {
				default_value = vsnode->get_input_port_default_value(i);
			}

			if (default_value.get_type() != Variant::NIL) { // only a label
				Button *button = memnew(Button);
				hb->add_child(button);
				button->connect("pressed", this, "_edit_port_default_input", varray(button, nodes[n_i], i));

				switch (default_value.get_type()) {

					case Variant::COLOR: {
						button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
						button->connect("draw", this, "_draw_color_over_button", varray(button, default_value));
					} break;
					case Variant::INT:
					case Variant::REAL: {
						button->set_text(String::num(default_value, 4));
					} break;
					case Variant::VECTOR3: {
						Vector3 v = default_value;
						button->set_text(String::num(v.x, 3) + "," + String::num(v.y, 3) + "," + String::num(v.z, 3));
					} break;
					default: {}
				}
			}

			if (i == 0 && custom_editor) {

				hb->add_child(custom_editor);
				custom_editor->set_h_size_flags(SIZE_EXPAND_FILL);
			} else {

				if (valid_left) {

					Label *label = memnew(Label);
					label->set_text(name_left);
					label->add_style_override("normal", label_style); //more compact
					hb->add_child(label);
				}

				hb->add_spacer();

				if (valid_right) {

					Label *label = memnew(Label);
					label->set_text(name_right);
					label->set_align(Label::ALIGN_RIGHT);
					label->add_style_override("normal", label_style); //more compact
					hb->add_child(label);
				}
			}

			if (valid_right && edit_type->get_selected() == VisualShader::TYPE_FRAGMENT) {
				TextureButton *preview = memnew(TextureButton);
				preview->set_toggle_mode(true);
				preview->set_normal_texture(get_icon("GuiVisibilityHidden", "EditorIcons"));
				preview->set_pressed_texture(get_icon("GuiVisibilityVisible", "EditorIcons"));
				preview->set_v_size_flags(SIZE_SHRINK_CENTER);

				if (vsnode->get_output_port_for_preview() == i) {
					preview->set_pressed(true);
				}

				preview->connect("pressed", this, "_preview_select_port", varray(nodes[n_i], i), CONNECT_DEFERRED);
				hb->add_child(preview);
			}

			node->add_child(hb);

			node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]);

			if (EditorSettings::get_singleton()->get("interface/theme/use_graph_node_headers")) {
				Ref<StyleBoxFlat> sb = node->get_stylebox("frame", "GraphNode");
				Color c = sb->get_border_color(MARGIN_TOP);
				Color mono_color = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0) : Color(0.0, 0.0, 0.0);
				mono_color.a = 0.85;
				c = mono_color;

				node->add_color_override("title_color", c);
				c.a = 0.7;
				node->add_color_override("close_color", c);
			}
		}

		if (vsnode->get_output_port_for_preview() >= 0) {
			VisualShaderNodePortPreview *port_preview = memnew(VisualShaderNodePortPreview);
			port_preview->setup(visual_shader, type, nodes[n_i], vsnode->get_output_port_for_preview());
			port_preview->set_h_size_flags(SIZE_SHRINK_CENTER);
			node->add_child(port_preview);
		}

		String error = vsnode->get_warning(visual_shader->get_mode(), type);
		if (error != String()) {
			Label *error_label = memnew(Label);
			error_label->add_color_override("font_color", get_color("error_color", "Editor"));
			error_label->set_text(error);
			node->add_child(error_label);
		}
	}

	for (List<VisualShader::Connection>::Element *E = connections.front(); E; E = E->next()) {

		int from = E->get().from_node;
		int from_idx = E->get().from_port;
		int to = E->get().to_node;
		int to_idx = E->get().to_port;

		graph->connect_node(itos(from), from_idx, itos(to), to_idx);
	}
}
Beispiel #29
0
ResourcesDock::ResourcesDock(EditorNode *p_editor) {

	editor=p_editor;

	VBoxContainer *vbc = this;

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


	Button *b;
	b = memnew( ToolButton );
	b->set_tooltip(TTR("Create New Resource"));
	b->connect("pressed",this,"_tool_selected",make_binds(TOOL_NEW));
	hbc->add_child( b );
	button_new=b;

	b = memnew( ToolButton );
	b->set_tooltip(TTR("Open Resource"));
	b->connect("pressed",this,"_tool_selected",make_binds(TOOL_OPEN));
	hbc->add_child( b );
	button_open=b;

	MenuButton *mb = memnew( MenuButton );
	mb->set_tooltip(TTR("Save Resource"));
	mb->get_popup()->add_item(TTR("Save Resource"),TOOL_SAVE);
	mb->get_popup()->add_item(TTR("Save Resource As.."),TOOL_SAVE_AS);
	mb->get_popup()->connect("item_pressed",this,"_tool_selected" );
	hbc->add_child( mb );
	button_save=mb;

	hbc->add_spacer();

	mb = memnew( MenuButton );
	mb->set_tooltip(TTR("Resource Tools"));
	mb->get_popup()->add_item(TTR("Make Local"),TOOL_MAKE_LOCAL);
	mb->get_popup()->add_item(TTR("Copy"),TOOL_COPY);
	mb->get_popup()->add_item(TTR("Paste"),TOOL_PASTE);
	mb->get_popup()->connect("item_pressed",this,"_tool_selected" );
	hbc->add_child( mb );
	button_tools=mb;

	resources = memnew( Tree );
	vbc->add_child(resources);
	resources->set_v_size_flags(SIZE_EXPAND_FILL);
	resources->create_item(); //root
	resources->set_hide_root(true);
	resources->connect("cell_selected",this,"_resource_selected");
	resources->connect("button_pressed",this,"_delete");

	create_dialog = memnew( CreateDialog );
	add_child(create_dialog);
	create_dialog->set_base_type("Resource");
	create_dialog->connect("create",this,"_create");
	accept = memnew (AcceptDialog);
	add_child(accept);

	file = memnew( EditorFileDialog );
	add_child(file);
	file->connect("file_selected",this,"_file_action");


	block_add=false;
}
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
	editor=p_editor;
	singleton=this;

	updating=false;

	set_focus_mode(FOCUS_ALL);

	player=NULL;
	add_style_override("panel", get_stylebox("panel","Panel"));


	Label * l;

	/*l= memnew( Label );
	l->set_text("Animation Player:");
	add_child(l);*/

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);


	add_anim = memnew( ToolButton );
	add_anim->set_tooltip("Create new animation in player.");

	hb->add_child(add_anim);


	load_anim = memnew( ToolButton );
	load_anim->set_tooltip("Load an animation from disk.");
	hb->add_child(load_anim);

	save_anim = memnew(MenuButton);
	save_anim->set_tooltip("Save the current animation");
	save_anim->get_popup()->add_item("Save", ANIM_SAVE);
	save_anim->get_popup()->add_item("Save As..", ANIM_SAVE_AS);
	save_anim->set_focus_mode(Control::FOCUS_NONE);
	hb->add_child(save_anim);

	accept = memnew(AcceptDialog);
	add_child(accept);
	accept->connect("confirmed", this, "_menu_confirm_current");

	duplicate_anim = memnew( ToolButton );
	hb->add_child(duplicate_anim);
	duplicate_anim->set_tooltip("Duplicate Animation");

	rename_anim = memnew( ToolButton );
	hb->add_child(rename_anim);
	rename_anim->set_tooltip("Rename Animation");

	remove_anim = memnew( ToolButton );

	hb->add_child(remove_anim);
	remove_anim->set_tooltip("Remove Animation");


	animation = memnew( OptionButton );
	hb->add_child(animation);
	animation->set_h_size_flags(SIZE_EXPAND_FILL);
	animation->set_tooltip("Display list of animations in player.");

	autoplay = memnew( ToolButton );
	hb->add_child(autoplay);
	autoplay->set_tooltip("Autoplay On Load");



	blend_anim = memnew( ToolButton );
	hb->add_child(blend_anim);
	blend_anim->set_tooltip("Edit Target Blend Times");

	tool_anim = memnew( MenuButton);
	//tool_anim->set_flat(false);
	tool_anim->set_tooltip("Animation Tools");
	tool_anim->get_popup()->add_item("Copy Animation",TOOL_COPY_ANIM);
	tool_anim->get_popup()->add_item("Paste Animation",TOOL_PASTE_ANIM);
	//tool_anim->get_popup()->add_separator();
	//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
	hb->add_child(tool_anim);


	edit_anim = memnew( ToolButton );
	edit_anim->set_toggle_mode(true);
	hb->add_child(edit_anim);
	edit_anim->set_tooltip("Open animation editor.\nProperty editor will displays all editable keys too.");


	hb = memnew (HBoxContainer);
	add_child(hb);

	play_bw_from = memnew( ToolButton );
	play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)");
	hb->add_child(play_bw_from);

	play_bw = memnew( ToolButton );
	play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)");
	hb->add_child(play_bw);

	stop = memnew( ToolButton );
	stop->set_toggle_mode(true);
	hb->add_child(stop);
	stop->set_tooltip("Stop animation playback. (S)");

	play = memnew( ToolButton );
	play->set_tooltip("Play selected animation from start. (Shift+D)");
	hb->add_child(play);


	play_from = memnew( ToolButton );
	play_from->set_tooltip("Play selected animation from current pos. (D)");
	hb->add_child(play_from);



	//pause = memnew( Button );
	//pause->set_toggle_mode(true);
	//hb->add_child(pause);

	seek = memnew( HSlider );
	seek->set_val(0);
	seek->set_step(0.01);
	hb->add_child(seek);
	seek->set_h_size_flags(SIZE_EXPAND_FILL);
	seek->set_stretch_ratio(8);
	seek->set_tooltip("Seek animation (when stopped).");

	frame = memnew( SpinBox );
	hb->add_child(frame);
	frame->set_h_size_flags(SIZE_EXPAND_FILL);
	frame->set_stretch_ratio(2);
	frame->set_tooltip("Animation position (in seconds).");
	seek->share(frame);



	scale = memnew( LineEdit );
	hb->add_child(scale);
	scale->set_h_size_flags(SIZE_EXPAND_FILL);
	scale->set_stretch_ratio(1);
	scale->set_tooltip("Scale animation playback globally for the node.");
	scale->hide();

	resource_edit_anim= memnew( Button );
	hb->add_child(resource_edit_anim);
	resource_edit_anim->hide();


	file = memnew(EditorFileDialog);
	add_child(file);

	name_dialog = memnew( ConfirmationDialog );
	name_dialog->set_title("Create New Animation");
	name_dialog->set_hide_on_ok(false);
	add_child(name_dialog);
	name = memnew( LineEdit );
	name_dialog->add_child(name);
	name->set_pos(Point2(18,30));
	name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10);
	name_dialog->register_text_enter(name);


	l = memnew( Label );
	l->set_text("Animation Name:");
	l->set_pos( Point2(10,10) );

	name_dialog->add_child(l);
	name_title=l;

	error_dialog = memnew( ConfirmationDialog );
	error_dialog->get_ok()->set_text("Close");
	//error_dialog->get_cancel()->set_text("Close");
	error_dialog->set_text("Error!");
	add_child(error_dialog);

	name_dialog->connect("confirmed", this,"_animation_name_edited");
	
	blend_editor.dialog = memnew( AcceptDialog );
	add_child(blend_editor.dialog);
	blend_editor.dialog->get_ok()->set_text("Close");
	blend_editor.dialog->set_hide_on_ok(true);
	VBoxContainer *blend_vb = memnew( VBoxContainer);
	blend_editor.dialog->add_child(blend_vb);
	blend_editor.dialog->set_child_rect(blend_vb);
	blend_editor.tree = memnew( Tree );
	blend_editor.tree->set_columns(2);
	blend_vb->add_margin_child("Blend Times: ",blend_editor.tree,true);
	blend_editor.next = memnew( LineEdit );
	blend_vb->add_margin_child("Next (Auto Queue):",blend_editor.next);
	blend_editor.dialog->set_title("Cross-Animation Blend Times");
	updating_blends=false;

	blend_editor.tree->connect("item_edited",this,"_blend_edited");
	

	autoplay->connect("pressed", this,"_autoplay_pressed");
	autoplay->set_toggle_mode(true);
	play->connect("pressed", this,"_play_pressed");
	play_from->connect("pressed", this,"_play_from_pressed");
	play_bw->connect("pressed", this,"_play_bw_pressed");
	play_bw_from->connect("pressed", this,"_play_bw_from_pressed");
	stop->connect("pressed", this,"_stop_pressed");
	//pause->connect("pressed", this,"_pause_pressed");
	add_anim->connect("pressed", this,"_animation_new");
	rename_anim->connect("pressed", this,"_animation_rename");
	load_anim->connect("pressed", this,"_animation_load");
	duplicate_anim->connect("pressed", this,"_animation_duplicate");
	//frame->connect("text_entered", this,"_seek_frame_changed");
	edit_anim->connect("pressed", this,"_animation_edit");
	blend_anim->connect("pressed", this,"_animation_blend");
	remove_anim->connect("pressed", this,"_animation_remove");
	animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true);
	resource_edit_anim->connect("pressed", this,"_animation_resource_edit");
	file->connect("file_selected", this,"_dialog_action");
	 seek->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
	 scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true);
	 editor->get_animation_editor()->connect("timeline_changed",this,"_animation_key_editor_seek");
	 editor->get_animation_editor()->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");

	 HBoxContainer *ahb = editor->get_animation_panel_hb();
	 nodename = memnew( Label );
	 ahb->add_child(nodename);
	 nodename->set_h_size_flags(SIZE_EXPAND_FILL);
	 nodename->set_opacity(0.5);
	 pin = memnew( TextureButton );
	 pin->set_toggle_mode(true);
	 ahb->add_child(pin);

	renaming=false;
	last_active=false;

	set_process_unhandled_key_input(true);
}