Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
ScrollContainer *EditorAbout::_populate_list(const String &p_name, const List<String> &p_sections, const char **p_src[]) {

	ScrollContainer *sc = memnew(ScrollContainer);
	sc->set_name(p_name);
	sc->set_v_size_flags(Control::SIZE_EXPAND);

	VBoxContainer *vbc = memnew(VBoxContainer);
	vbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	sc->add_child(vbc);

	for (int i = 0; i < p_sections.size(); i++) {

		const char **names_ptr = p_src[i];
		if (*names_ptr) {

			Label *lbl = memnew(Label);
			lbl->set_text(p_sections[i]);
			vbc->add_child(lbl);

			ItemList *il = memnew(ItemList);
			il->set_max_columns(16);
			il->set_h_size_flags(Control::SIZE_EXPAND_FILL);
			il->set_same_column_width(true);
			il->set_auto_height(true);
			while (*names_ptr) {
				il->add_item(String::utf8(*names_ptr++), NULL, false);
			}
			vbc->add_child(il);
			if (il->get_item_count() == 2) {
				il->set_fixed_column_width(200 * EDSCALE);
			}

			HSeparator *hs = memnew(HSeparator);
			hs->set_modulate(Color(0, 0, 0, 0));
			vbc->add_child(hs);
		}
	}

	return sc;
}
Ejemplo n.º 3
0
ExportTemplateManager::ExportTemplateManager() {

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

	current_hb = memnew(HBoxContainer);
	main_vb->add_margin_child(TTR("Current Version:"), current_hb, false);

	installed_scroll = memnew(ScrollContainer);
	main_vb->add_margin_child(TTR("Installed Versions:"), installed_scroll, true);

	installed_vb = memnew(VBoxContainer);
	installed_scroll->add_child(installed_vb);
	installed_scroll->set_enable_v_scroll(true);
	installed_scroll->set_enable_h_scroll(false);
	installed_vb->set_h_size_flags(SIZE_EXPAND_FILL);

	get_cancel()->set_text(TTR("Close"));
	get_ok()->set_text(TTR("Install From File"));

	remove_confirm = memnew(ConfirmationDialog);
	remove_confirm->set_title(TTR("Remove Template"));
	add_child(remove_confirm);
	remove_confirm->connect("confirmed", this, "_uninstall_template_confirm");

	template_open = memnew(FileDialog);
	template_open->set_title(TTR("Select template file"));
	template_open->add_filter("*.tpz ; Godot Export Templates");
	template_open->set_access(FileDialog::ACCESS_FILESYSTEM);
	template_open->set_mode(FileDialog::MODE_OPEN_FILE);
	template_open->connect("file_selected", this, "_install_from_file", varray(true));
	add_child(template_open);

	set_title(TTR("Export Template Manager"));
	set_hide_on_ok(false);

	request_mirror = memnew(HTTPRequest);
	add_child(request_mirror);
	request_mirror->connect("request_completed", this, "_http_download_mirror_completed");

	download_templates = memnew(HTTPRequest);
	add_child(download_templates);
	download_templates->connect("request_completed", this, "_http_download_templates_completed");

	template_downloader = memnew(AcceptDialog);
	template_downloader->set_title(TTR("Download Templates"));
	template_downloader->get_ok()->set_text(TTR("Close"));
	template_downloader->set_exclusive(true);
	add_child(template_downloader);
	template_downloader->connect("popup_hide", this, "_window_template_downloader_closed");

	VBoxContainer *vbc = memnew(VBoxContainer);
	template_downloader->add_child(vbc);
	ScrollContainer *sc = memnew(ScrollContainer);
	sc->set_custom_minimum_size(Size2(400, 200) * EDSCALE);
	vbc->add_margin_child(TTR("Select mirror from list: (Shift+Click: Open in Browser)"), sc);
	template_list = memnew(VBoxContainer);
	sc->add_child(template_list);
	sc->set_enable_v_scroll(true);
	sc->set_enable_h_scroll(false);
	template_list_state = memnew(Label);
	vbc->add_child(template_list_state);
	template_download_progress = memnew(ProgressBar);
	vbc->add_child(template_download_progress);

	update_countdown = 0;
}