コード例 #1
0
ファイル: editor_help.cpp プロジェクト: HiddenDark/godot
EditorHelp::EditorHelp(EditorNode *p_editor) {

	editor=p_editor;

	VBoxContainer *vbc = this;

	HBoxContainer *panel_hb = memnew( HBoxContainer );

	Button *b = memnew( Button );
	b->set_text("Class List");
	panel_hb->add_child(b);
	vbc->add_child(panel_hb);
	b->set_toggle_mode(true);
	b->set_pressed(true);
	b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_LIST));
	class_list_button=b;
	class_list_button->hide();

	b = memnew( Button );
	b->set_text("Class");
	panel_hb->add_child(b);
	edited_class=b;
	edited_class->hide();
	b->set_toggle_mode(true);
	b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_DESC));

	b = memnew( Button );
	b->set_text("Search in Classes");
	panel_hb->add_child(b);
	b->connect("pressed",this,"_button_pressed",make_binds(CLASS_SEARCH));

	Control *expand = memnew( Control );
	expand->set_h_size_flags(SIZE_EXPAND_FILL);
	panel_hb->add_child(expand);

	b = memnew( Button );
	panel_hb->add_child(b);
	back=b;
	b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_PREV));

	b = memnew( Button );
	panel_hb->add_child(b);
	forward=b;
	b->connect("pressed",this,"_button_pressed",make_binds(PAGE_CLASS_NEXT));

	Separator *hs = memnew( VSeparator );
	panel_hb->add_child(hs);
	EmptyControl *ec = memnew( EmptyControl );
	ec->set_minsize(Size2(200,1));
	panel_hb->add_child(ec);
	search = memnew( LineEdit );
	ec->add_child(search);
	search->set_area_as_parent_rect();
	search->connect("text_entered",this,"_search");

	b = memnew( Button );
	b->set_text("Find");
	panel_hb->add_child(b);
	b->connect("pressed",this,"_button_pressed",make_binds(PAGE_SEARCH));

	hs = memnew( VSeparator );
	panel_hb->add_child(hs);

	h_split = memnew( HSplitContainer );
	h_split->set_v_size_flags(SIZE_EXPAND_FILL);


	vbc->add_child(h_split);

	class_list = memnew( Tree );
	h_split->add_child(class_list);
	//class_list->connect("meta_clicked",this,"_class_list_select");
	//class_list->set_selection_enabled(true);

	{
		PanelContainer *pc = memnew( PanelContainer );
		pc->add_style_override("panel",get_stylebox("normal","TextEdit"));
		h_split->add_child(pc);
		class_desc = memnew( RichTextLabel );
		pc->add_child(class_desc);
		class_desc->connect("meta_clicked",this,"_class_desc_select");
	}

	class_desc->get_v_scroll()->connect("value_changed",this,"_scroll_changed");
	class_desc->set_selection_enabled(true);
	editor=p_editor;
	history_pos=0;
	scroll_locked=false;
	select_locked=false;
	set_process_unhandled_key_input(true);
	h_split->set_split_offset(200);
	class_list->connect("cell_selected",this,"_tree_item_selected");
	class_desc->hide();

	class_search = memnew( EditorHelpSearch(editor) );
	editor->get_gui_base()->add_child(class_search);
	class_search->connect("go_to_help",this,"_help_callback");
//	prev_search_page=-1;
}
コード例 #2
0
ファイル: project_manager.cpp プロジェクト: 0871087123/godot
void ProjectManager::_load_recent_projects() {

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

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

	Color font_color = get_color("font_color","Tree");

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

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

		String project = _name.get_slice("/",1);
		String path = EditorSettings::get_singleton()->get(_name);
		String conf=path.plus_file("engine.cfg");

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

		Ref<Texture> icon;
		String project_name="Unnamed Project";


		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 (cf->has_section_key("application","name")) {
			project_name = cf->get_value("application","name");
		}

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


		HBoxContainer *hb = memnew( HBoxContainer );
		hb->set_meta("name",project);
		hb->set_meta("main_scene",main_scene);
		hb->connect("draw",this,"_panel_draw",varray(hb));
		hb->connect("input_event",this,"_panel_input",varray(hb));
		TextureFrame *tf = memnew( TextureFrame );
		tf->set_texture(icon);
		hb->add_child(tf);
		VBoxContainer *vb = memnew(VBoxContainer);
		hb->add_child(vb);
		EmptyControl *ec = memnew( EmptyControl );
		ec->set_minsize(Size2(0,1));
		vb->add_child(ec);
		Label *title = memnew( Label(project_name) );
		title->add_font_override("font",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);
	}

	erase_btn->set_disabled(selected=="");
	open_btn->set_disabled(selected=="");
	if (selected=="")
		run_btn->set_disabled(true);
}
コード例 #3
0
ファイル: project_manager.cpp プロジェクト: 9cat/godot
void ProjectManager::_load_recent_projects() {

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

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

	Color font_color = 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;
		bool favorite = (_name.begins_with("favorite_projects/"))?true:false;

		String project = _name.get_slice("/",1);
		String path = EditorSettings::get_singleton()->get(_name);
		String conf=path.plus_file("engine.cfg");

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

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

		Ref<Texture> icon;
		String project_name="Unnamed Project";

		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 (cf->has_section_key("application","name")) {
			project_name = cf->get_value("application","name");
		}

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

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

		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);
		EmptyControl *ec = memnew( EmptyControl );
		ec->set_minsize(Size2(0,1));
		vb->add_child(ec);
		Label *title = memnew( Label(project_name) );
		title->add_font_override("font",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);
	}

	erase_btn->set_disabled(selected_list.size()<1);
	open_btn->set_disabled(selected_list.size()<1);
	run_btn->set_disabled(selected_list.size()<1 || (selected_list.size()==1 && single_selected_main==""));
}