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; }
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); } }
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); }
void _update_text() { test_label->set_text(""); test_label->set_text(test_string->get_text()); test_label->add_color_override("font_color",test_color->get_color()); }
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=="")); }
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); }