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");



}
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"));
}
Beispiel #3
0
HBoxContainer* EditorAddonLibrary::_make_pages(int p_page,int p_max_page,int p_page_len,int p_total_items,int p_current_items) {

	HBoxContainer * hbc = memnew( HBoxContainer );

	//do the mario
	int from = p_page-5;
	if (from<0)
		from=0;
	int to = from+10;
	if (to>p_max_page)
		to=p_max_page;

	Color gray = Color(0.65,0.65,0.65);

	hbc->add_spacer();
	hbc->add_constant_override("separation",10);

	LinkButton *first = memnew( LinkButton );
	first->set_text("first");
	first->add_color_override("font_color", gray );
	first->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	first->connect("pressed",this,"_search",varray(0));
	hbc->add_child(first);

	if (p_page>0) {
		LinkButton *prev = memnew( LinkButton );
		prev->set_text("prev");
		prev->add_color_override("font_color", gray );
		prev->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
		prev->connect("pressed",this,"_search",varray(p_page-1));
		hbc->add_child(prev);
	}

	for(int i=from;i<=to;i++) {

		if (i==p_page) {

			Label *current = memnew(Label);
			current->set_text(itos(i));
			hbc->add_child(current);
		} else {

			LinkButton *current = memnew( LinkButton );
			current->add_color_override("font_color", gray );
			current->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
			current->set_text(itos(i));
			current->connect("pressed",this,"_search",varray(i));

			hbc->add_child(current);

		}
	}

	if (p_page<p_max_page) {
		LinkButton *next = memnew( LinkButton );
		next->set_text("next");
		next->add_color_override("font_color", gray );
		next->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
		next->connect("pressed",this,"_search",varray(p_page+1));

		hbc->add_child(next);
	}
	LinkButton *last = memnew( LinkButton );
	last->set_text("last");
	last->add_color_override("font_color", gray );
	last->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	hbc->add_child(last);
	last->connect("pressed",this,"_search",varray(p_max_page));

	Label *totals = memnew( Label );
	totals->set_text("( "+itos(from*p_page_len)+" - "+itos(from*p_page_len+p_current_items-1)+" / "+itos(p_total_items)+" )");
	hbc->add_child(totals);

	hbc->add_spacer();

	return hbc;
}
Beispiel #4
0
EditorAbout::EditorAbout() {

	set_title(TTR("Thanks from the Godot community!"));
	get_ok()->set_text(TTR("Thanks!"));
	set_hide_on_ok(true);
	set_resizable(true);

	VBoxContainer *vbc = memnew(VBoxContainer);
	HBoxContainer *hbc = memnew(HBoxContainer);
	hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	hbc->set_alignment(BoxContainer::ALIGN_CENTER);
	hbc->add_constant_override("separation", 30 * EDSCALE);
	add_child(vbc);
	vbc->add_child(hbc);

	_logo = memnew(TextureRect);
	hbc->add_child(_logo);

	String hash = String(VERSION_HASH);
	if (hash.length() != 0)
		hash = "." + hash.left(7);

	Label *about_text = memnew(Label);
	about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
	about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") +
						 TTR("Godot Engine contributors") + "\n");
	hbc->add_child(about_text);

	TabContainer *tc = memnew(TabContainer);
	tc->set_custom_minimum_size(Size2(630, 240) * EDSCALE);
	tc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	vbc->add_child(tc);

	// Authors

	List<String> dev_sections;
	dev_sections.push_back(TTR("Project Founders"));
	dev_sections.push_back(TTR("Lead Developer"));
	dev_sections.push_back(TTR("Project Manager"));
	dev_sections.push_back(TTR("Developers"));
	const char **dev_src[] = { dev_founders, dev_lead, dev_manager, dev_names };
	tc->add_child(_populate_list(TTR("Authors"), dev_sections, dev_src));

	// Donors

	List<String> donor_sections;
	donor_sections.push_back(TTR("Platinum Sponsors"));
	donor_sections.push_back(TTR("Gold Sponsors"));
	donor_sections.push_back(TTR("Mini Sponsors"));
	donor_sections.push_back(TTR("Gold Donors"));
	donor_sections.push_back(TTR("Silver Donors"));
	donor_sections.push_back(TTR("Bronze Donors"));
	const char **donor_src[] = { donor_s_plat, donor_s_gold, donor_s_mini, donor_gold, donor_silver, donor_bronze };
	tc->add_child(_populate_list(TTR("Donors"), donor_sections, donor_src));

	// License

	TextEdit *license = memnew(TextEdit);
	license->set_name(TTR("License"));
	license->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	license->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	license->set_wrap(true);
	license->set_readonly(true);
	license->set_text(String::utf8(about_license));
	tc->add_child(license);

	// Thirdparty License

	VBoxContainer *license_thirdparty = memnew(VBoxContainer);
	license_thirdparty->set_name(TTR("Thirdparty License"));
	license_thirdparty->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tc->add_child(license_thirdparty);

	Label *tpl_label = memnew(Label);
	tpl_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_label->set_autowrap(true);
	tpl_label->set_text(TTR("Godot Engine relies on a number of thirdparty free and open source libraries, all compatible with the terms of its MIT license. The following is an exhaustive list of all such thirdparty components with their respective copyright statements and license terms."));
	license_thirdparty->add_child(tpl_label);

	HSplitContainer *tpl_hbc = memnew(HSplitContainer);
	tpl_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_hbc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	tpl_hbc->set_split_offset(240 * EDSCALE);
	license_thirdparty->add_child(tpl_hbc);

	_tpl_tree = memnew(Tree);
	_tpl_tree->set_hide_root(true);
	TreeItem *root = _tpl_tree->create_item();
	TreeItem *tpl_ti_all = _tpl_tree->create_item(root);
	tpl_ti_all->set_text(0, TTR("All Components"));
	TreeItem *tpl_ti_tp = _tpl_tree->create_item(root);
	tpl_ti_tp->set_text(0, TTR("Components"));
	tpl_ti_tp->set_selectable(0, false);
	TreeItem *tpl_ti_lc = _tpl_tree->create_item(root);
	tpl_ti_lc->set_text(0, TTR("Licenses"));
	tpl_ti_lc->set_selectable(0, false);
	int read_idx = 0;
	String long_text = "";
	for (int i = 0; i < THIRDPARTY_COUNT; i++) {

		TreeItem *ti = _tpl_tree->create_item(tpl_ti_tp);
		String thirdparty = String(about_thirdparty[i]);
		ti->set_text(0, thirdparty);
		String text = thirdparty + "\n";
		long_text += "- " + thirdparty + "\n\n";
		for (int j = 0; j < about_tp_copyright_count[i]; j++) {

			text += "\n    Files:\n        " + String(about_tp_file[read_idx]).replace("\n", "\n        ") + "\n";
			String copyright = String::utf8("    \u00A9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n    \u00A9 "));
			text += copyright;
			long_text += copyright;
			String license = "\n    License: " + String(about_tp_license[read_idx]) + "\n";
			text += license;
			long_text += license + "\n";
			read_idx++;
		}
		ti->set_metadata(0, text);
	}
	for (int i = 0; i < LICENSE_COUNT; i++) {

		TreeItem *ti = _tpl_tree->create_item(tpl_ti_lc);
		String licensename = String(about_license_name[i]);
		ti->set_text(0, licensename);
		long_text += "- " + licensename + "\n\n";
		String licensebody = String(about_license_body[i]);
		ti->set_metadata(0, licensebody);
		long_text += "    " + licensebody.replace("\n", "\n    ") + "\n\n";
	}
	tpl_ti_all->set_metadata(0, long_text);
	tpl_hbc->add_child(_tpl_tree);

	_tpl_text = memnew(TextEdit);
	_tpl_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	_tpl_text->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	_tpl_text->set_wrap(true);
	_tpl_text->set_readonly(true);
	tpl_hbc->add_child(_tpl_text);

	_tpl_tree->connect("item_selected", this, "_license_tree_selected");
	tpl_ti_all->select(0);
	_tpl_text->set_text(tpl_ti_all->get_metadata(0));
}
Beispiel #5
0
void ProjectManager::_load_recent_projects() {

	ProjectListFilter::FilterOption filter_option = project_filter->get_filter_option();
	String search_term = project_filter->get_search_term();

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

	Map<String, String> selected_list_copy = selected_list;

	List<PropertyInfo> properties;
	EditorSettings::get_singleton()->get_property_list(&properties);

	Color font_color = gui_base->get_color("font_color","Tree");

	List<ProjectItem> projects;
	List<ProjectItem> favorite_projects;

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

		String _name = E->get().name;
		if (!_name.begins_with("projects/") && !_name.begins_with("favorite_projects/"))
			continue;

		String path = EditorSettings::get_singleton()->get(_name);
		if (filter_option == ProjectListFilter::FILTER_PATH && search_term!="" && path.findn(search_term)==-1)
			continue;

		String project = _name.get_slice("/",1);
		String conf=path.plus_file("engine.cfg");
		bool favorite = (_name.begins_with("favorite_projects/"))?true:false;

		uint64_t last_modified = 0;
		if (FileAccess::exists(conf)) {
			last_modified = FileAccess::get_modified_time(conf);

			String fscache = path.plus_file(".fscache");
			if (FileAccess::exists(fscache)) {
				uint64_t cache_modified = FileAccess::get_modified_time(fscache);
				if ( cache_modified > last_modified )
					last_modified = cache_modified;
			}

			ProjectItem item(project, path, conf, last_modified, favorite);
			if (favorite)
				favorite_projects.push_back(item);
			else
				projects.push_back(item);
		} else {
			//project doesn't exist on disk but it's in the XML settings file
			EditorSettings::get_singleton()->erase(_name); //remove it
		}
	}

	projects.sort();
	favorite_projects.sort();

	for(List<ProjectItem>::Element *E=projects.front();E;) {
		List<ProjectItem>::Element *next = E->next();
		if (favorite_projects.find(E->get()) != NULL)
			projects.erase(E->get());
		E=next;
	}
	for(List<ProjectItem>::Element *E=favorite_projects.back();E;E=E->prev()) {
		projects.push_front(E->get());
	}

	Ref<Texture> favorite_icon = get_icon("Favorites","EditorIcons");

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

		ProjectItem &item = E->get();
		String project = item.project;
		String path = item.path;
		String conf = item.conf;
		bool is_favorite = item.favorite;

		Ref<ConfigFile> cf = memnew( ConfigFile );
		Error err = cf->load(conf);
		ERR_CONTINUE(err!=OK);


		String project_name=TTR("Unnamed Project");

		if (cf->has_section_key("application","name")) {
			project_name = static_cast<String>(cf->get_value("application","name")).xml_unescape();
		}

		if (filter_option==ProjectListFilter::FILTER_NAME && search_term!="" && project_name.findn(search_term)==-1)
			continue;

		Ref<Texture> icon;
		if (cf->has_section_key("application","icon")) {
			String appicon = cf->get_value("application","icon");
			if (appicon!="") {
				Image img;
				Error err = img.load(appicon.replace_first("res://",path+"/"));
				if (err==OK) {

					img.resize(64,64);
					Ref<ImageTexture> it = memnew( ImageTexture );
					it->create_from_image(img);
					icon=it;
				}
			}
		}

		if (icon.is_null()) {
			icon=get_icon("DefaultProjectIcon","EditorIcons");
		}

		String main_scene;
		if (cf->has_section_key("application","main_scene")) {
			main_scene = cf->get_value("application","main_scene");
		}

		selected_list_copy.erase(project);

		HBoxContainer *hb = memnew( HBoxContainer );
		hb->set_meta("name",project);
		hb->set_meta("main_scene",main_scene);
		hb->set_meta("favorite",is_favorite);
		hb->connect("draw",this,"_panel_draw",varray(hb));
		hb->connect("input_event",this,"_panel_input",varray(hb));
		hb->add_constant_override("separation",10*EDSCALE);

		VBoxContainer *favorite_box = memnew( VBoxContainer );
		TextureButton *favorite = memnew( TextureButton );
		favorite->set_normal_texture(favorite_icon);
		if (!is_favorite)
			favorite->set_opacity(0.2);
		favorite->set_v_size_flags(SIZE_EXPAND);
		favorite->connect("pressed",this,"_favorite_pressed",varray(hb));
		favorite_box->add_child(favorite);
		hb->add_child(favorite_box);

		TextureFrame *tf = memnew( TextureFrame );
		tf->set_texture(icon);
		hb->add_child(tf);

		VBoxContainer *vb = memnew(VBoxContainer);
		hb->add_child(vb);
		Control *ec = memnew( Control );
		ec->set_custom_minimum_size(Size2(0,1));
		vb->add_child(ec);
		Label *title = memnew( Label(project_name) );
		title->add_font_override("font", gui_base->get_font("large","Fonts"));
		title->add_color_override("font_color",font_color);
		vb->add_child(title);
		Label *fpath = memnew( Label(path) );
		vb->add_child(fpath);
		fpath->set_opacity(0.5);
		fpath->add_color_override("font_color",font_color);

		scroll_childs->add_child(hb);
	}

	for (Map<String,String>::Element *E = selected_list_copy.front();E;E = E->next()) {
		String key = E->key();
		selected_list.erase(key);
	}

	scroll->set_v_scroll(0);

	_update_project_buttons();

	EditorSettings::get_singleton()->save();

	tabs->set_current_tab(0);
}