void AnimationPlayerEditor::_file_selected(String p_file) { ERR_FAIL_COND(!player); Ref<Resource> res = ResourceLoader::load(p_file,"Animation"); ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND( !res->is_type("Animation") ); if (p_file.find_last("/")!=-1) { p_file=p_file.substr( p_file.find_last("/")+1, p_file.length() ); } if (p_file.find_last("\\")!=-1) { p_file=p_file.substr( p_file.find_last("\\")+1, p_file.length() ); } if (p_file.find(".")!=-1) p_file=p_file.substr(0,p_file.find(".")); undo_redo->create_action("Load Animation"); undo_redo->add_do_method(player,"add_animation",p_file,res); undo_redo->add_undo_method(player,"remove_animation",p_file); if (player->has_animation(p_file)) { undo_redo->add_undo_method(player,"add_animation",p_file,player->get_animation(p_file)); } undo_redo->add_do_method(this,"_animation_player_changed",player); undo_redo->add_undo_method(this,"_animation_player_changed",player); undo_redo->commit_action(); }
void AnimationPlayerEditor::_dialog_action(String p_file) { switch (current_option) { case RESOURCE_LOAD: { ERR_FAIL_COND(!player); Ref<Resource> res = ResourceLoader::load(p_file, "Animation"); ERR_FAIL_COND(res.is_null()); ERR_FAIL_COND(!res->is_type("Animation")); if (p_file.find_last("/") != -1) { p_file = p_file.substr(p_file.find_last("/") + 1, p_file.length()); } if (p_file.find_last("\\") != -1) { p_file = p_file.substr(p_file.find_last("\\") + 1, p_file.length()); } if (p_file.find(".") != -1) p_file = p_file.substr(0, p_file.find(".")); undo_redo->create_action("Load Animation"); undo_redo->add_do_method(player, "add_animation", p_file, res); undo_redo->add_undo_method(player, "remove_animation", p_file); if (player->has_animation(p_file)) { undo_redo->add_undo_method(player, "add_animation", p_file, player->get_animation(p_file)); } undo_redo->add_do_method(this, "_animation_player_changed", player); undo_redo->add_undo_method(this, "_animation_player_changed", player); undo_redo->commit_action(); break; } case RESOURCE_SAVE: { String current = animation->get_item_text(animation->get_selected()); if (current != "") { Ref<Animation> anim = player->get_animation(current); ERR_FAIL_COND(!anim->cast_to<Resource>()) RES current_res = RES(anim->cast_to<Resource>()); _animation_save_in_path(current_res, p_file); } } } }
void FileDialog::set_current_path(const String& p_path) { if (!p_path.size()) return; int pos=MAX( p_path.find_last("/"), p_path.find_last("\\") ); if (pos==-1) { set_current_file(p_path); } else { String dir=p_path.substr(0,pos); String file=p_path.substr(pos+1,p_path.length()); set_current_dir(dir); set_current_file(file); } }
void FileDialog::set_current_file(const String &p_file) { file->set_text(p_file); update_dir(); invalidate(); int lp = p_file.find_last("."); if (lp != -1) { file->select(0, lp); file->grab_focus(); } }
String ProjectSettings::localize_path(const String &p_path) const { if (resource_path == "") return p_path; //not initialized yet if (p_path.begins_with("res://") || p_path.begins_with("user://") || (p_path.is_abs_path() && !p_path.begins_with(resource_path))) return p_path.simplify_path(); DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String path = p_path.replace("\\", "/").simplify_path(); if (dir->change_dir(path) == OK) { String cwd = dir->get_current_dir(); cwd = cwd.replace("\\", "/"); memdelete(dir); // Ensure that we end with a '/'. // This is important to ensure that we do not wrongly localize the resource path // in an absolute path that just happens to contain this string but points to a // different folder (e.g. "/my/project" as resource_path would be contained in // "/my/project_data", even though the latter is not part of res://. // `plus_file("")` is an easy way to ensure we have a trailing '/'. const String res_path = resource_path.plus_file(""); if (!cwd.begins_with(res_path)) { return p_path; }; return cwd.replace_first(res_path, "res://"); } else { memdelete(dir); int sep = path.find_last("/"); if (sep == -1) { return "res://" + path; }; String parent = path.substr(0, sep); String plocal = localize_path(parent); if (plocal == "") { return ""; }; return plocal + path.substr(sep, path.size() - sep); }; }
void EditorFileDialog::set_current_file(const String &p_file) { file->set_text(p_file); update_dir(); invalidate(); int lp = p_file.find_last("."); if (lp != -1) { file->select(0, lp); file->grab_focus(); } if (is_visible_in_tree()) _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); }
String Globals::localize_path(const String& p_path) const { if (resource_path=="") return p_path; //not initialied yet if (p_path.begins_with("res://") || p_path.begins_with("user://") || (p_path.is_abs_path() && !p_path.begins_with(resource_path))) return p_path.simplify_path(); DirAccess *dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); String path = p_path.replace("\\","/").simplify_path(); if (dir->change_dir(path)==OK) { String cwd = dir->get_current_dir(); cwd = cwd.replace("\\","/"); memdelete(dir); if (!cwd.begins_with(resource_path)) { return p_path; }; return cwd.replace_first(resource_path, "res:/"); } else { memdelete(dir); int sep = path.find_last("/"); if (sep == -1) { return "res://"+path; }; String parent = path.substr(0, sep); String plocal = localize_path(parent); if (plocal == "") { return ""; }; return plocal + path.substr(sep, path.size() - sep); }; }
void ScriptCreateDialog::_file_selected(const String &p_file) { String p = ProjectSettings::get_singleton()->localize_path(p_file); if (is_browsing_parent) { parent_name->set_text("\"" + p + "\""); _class_name_changed("\"" + p + "\""); } else { file_path->set_text(p); _path_changed(p); String filename = p.get_file().get_basename(); int select_start = p.find_last(filename); file_path->select(select_start, select_start + filename.length()); file_path->set_cursor_position(select_start + filename.length()); file_path->grab_focus(); } }
void PathRemap::load_remaps() { // default remaps first DVector<String> remaps = Globals::get_singleton()->get("remap/all"); { int rlen = remaps.size(); ERR_FAIL_COND( rlen%2 ); DVector<String>::Read r = remaps.read(); for(int i=0;i<rlen/2;i++) { String from = r[i*2+0]; String to = r[i*2+1]; add_remap(from,to); } } // platform remaps second, so override remaps = Globals::get_singleton()->get("remap/"+OS::get_singleton()->get_name()); // remaps = Globals::get_singleton()->get("remap/PSP"); { int rlen = remaps.size(); ERR_FAIL_COND( rlen%2 ); DVector<String>::Read r = remaps.read(); for(int i=0;i<rlen/2;i++) { String from = r[i*2+0]; String to = r[i*2+1]; // print_line("add remap: "+from+" -> "+to); add_remap(from,to); } } //locale based remaps if (Globals::get_singleton()->has("locale/translation_remaps")) { Dictionary remaps = Globals::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; remaps.get_key_list(&rk); for(List<Variant>::Element *E=rk.front();E;E=E->next()) { String source = E->get(); StringArray sa = remaps[E->get()]; int sas = sa.size(); StringArray::Read r = sa.read(); for(int i=0;i<sas;i++) { String s = r[i]; int qp = s.find_last(":"); if (qp!=-1) { String path = s.substr(0,qp); String locale = s.substr(qp+1,s.length()); add_remap(source,path,locale); } } } } }
void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { const int UTF8_FLAG = 0x00000100; print_line("*******************GORRRGLE***********************"); uint32_t header = decode_uint32(&p_manifest[0]); uint32_t filesize = decode_uint32(&p_manifest[4]); uint32_t string_block_len = decode_uint32(&p_manifest[16]); uint32_t string_count = decode_uint32(&p_manifest[20]); uint32_t string_flags = decode_uint32(&p_manifest[28]); const uint32_t string_table_begins = 40; Vector<String> string_table; printf("stirng block len: %i\n",string_block_len); printf("stirng count: %i\n",string_count); printf("flags: %x\n",string_flags); for(int i=0;i<string_count;i++) { uint32_t offset = decode_uint32(&p_manifest[string_table_begins+i*4]); offset+=string_table_begins+string_count*4; String str = _parse_string(&p_manifest[offset],string_flags&UTF8_FLAG); if (str.begins_with("godot-project-name")) { if (str=="godot-project-name") { //project name str = get_project_name(); } else { String lang = str.substr(str.find_last("-")+1,str.length()).replace("-","_"); String prop = "application/name_"+lang; if (Globals::get_singleton()->has(prop)) { str = Globals::get_singleton()->get(prop); } else { str = get_project_name(); } } } string_table.push_back(str); } //write a new string table, but use 16 bits Vector<uint8_t> ret; ret.resize(string_table_begins+string_table.size()*4); for(int i=0;i<string_table_begins;i++) { ret[i]=p_manifest[i]; } int ofs=0; for(int i=0;i<string_table.size();i++) { encode_uint32(ofs,&ret[string_table_begins+i*4]); ofs+=string_table[i].length()*2+2+2; } ret.resize(ret.size()+ofs); uint8_t *chars=&ret[ret.size()-ofs]; for(int i=0;i<string_table.size();i++) { String s = string_table[i]; encode_uint16(s.length(),chars); chars+=2; for(int j=0;j<s.length();j++) { encode_uint16(s[j],chars); chars+=2; } encode_uint16(0,chars); chars+=2; } //pad while(ret.size()%4) ret.push_back(0); //change flags to not use utf8 encode_uint32(string_flags&~0x100,&ret[28]); //change length encode_uint32(ret.size()-12,&ret[16]); //append the rest... int rest_from = 12+string_block_len; int rest_to = ret.size(); int rest_len = (p_manifest.size() - rest_from); ret.resize(ret.size() + (p_manifest.size() - rest_from) ); for(int i=0;i<rest_len;i++) { ret[rest_to+i]=p_manifest[rest_from+i]; } //finally update the size encode_uint32(ret.size(),&ret[4]); p_manifest=ret; printf("end\n"); }
RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_original_path) { if (p_path.extension()=="cube") { // open as cubemap txture CubeMap* ptr = memnew(CubeMap); Ref<CubeMap> cubemap( ptr ); Error err; FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err); if (err) { ERR_FAIL_COND_V( err, RES() ); } String base_path=p_path.substr( 0, p_path.find_last("/")+1 ); for(int i=0;i<6;i++) { String file = f->get_line().strip_edges(); Image image; Error err = ImageLoader::load_image(base_path+file,&image); if (err) { memdelete(f); ERR_FAIL_COND_V( err, RES() ); } if (i==0) { //cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP); } static const CubeMap::Side cube_side[6]= { CubeMap::SIDE_LEFT, CubeMap::SIDE_RIGHT, CubeMap::SIDE_BOTTOM, CubeMap::SIDE_TOP, CubeMap::SIDE_FRONT, CubeMap::SIDE_BACK }; cubemap->set_side(cube_side[i],image); } memdelete(f); cubemap->set_name(p_path.get_file()); return cubemap; } else { // simple image ImageTexture* ptr = memnew(ImageTexture); Ref<ImageTexture> texture( ptr ); uint64_t begtime; double total; Image image; if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); Error err = ImageLoader::load_image(p_path,&image); if (!err && debug_load_times) { double total=(double)(OS::get_singleton()->get_ticks_usec()-begtime)/1000000.0; print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height())); print_line(" -load: "+rtos(total)); } ERR_EXPLAIN("Failed loading image: "+p_path); ERR_FAIL_COND_V(err, RES()); #ifdef DEBUG_ENABLED #ifdef TOOLS_ENABLED if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) { if (bool(Globals::get_singleton()->get("debug/max_texture_size_alert"))) { OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!"); } ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+"."); ERR_FAIL_V(RES()); } #endif #endif uint32_t flags=0; if (bool(GLOBAL_DEF("texture_import/filter",true))) flags|=Texture::FLAG_FILTER; if (bool(GLOBAL_DEF("texture_import/gen_mipmaps",true))) flags|=Texture::FLAG_MIPMAPS; if (bool(GLOBAL_DEF("texture_import/repeat",true))) flags|=Texture::FLAG_REPEAT; if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); //print_line("img: "+p_path+" flags: "+itos(flags)); texture->create_from_image( image,flags ); texture->set_name(p_path.get_file()); if (debug_load_times) { total=(double)(OS::get_singleton()->get_ticks_usec()-begtime)/1000000.0; print_line(" -make texture: "+rtos(total)); } return RES( texture ); } }
void ProjectSettings::_update_translations() { //update translations if (updating_translations) return; updating_translations=true; translation_list->clear(); TreeItem *root = translation_list->create_item(NULL); translation_list->set_hide_root(true); if (Globals::get_singleton()->has("locale/translations")) { StringArray translations = Globals::get_singleton()->get("locale/translations"); for(int i=0;i<translations.size();i++) { TreeItem *t = translation_list->create_item(root); t->set_editable(0,false); t->set_text(0,translations[i].replace_first("res://","")); t->set_tooltip(0,translations[i]); t->set_metadata(0,i); t->add_button(0,get_icon("Del","EditorIcons"),0); } } //update translation remaps String remap_selected; if (translation_remap->get_selected()) { remap_selected = translation_remap->get_selected()->get_metadata(0); } translation_remap->clear(); translation_remap_options->clear(); root = translation_remap->create_item(NULL); TreeItem *root2 = translation_remap_options->create_item(NULL); translation_remap->set_hide_root(true); translation_remap_options->set_hide_root(true); translation_res_option_add_button->set_disabled(true); Vector<String> langs = TranslationServer::get_all_locales(); Vector<String> names = TranslationServer::get_all_locale_names(); String langnames; for(int i=0;i<names.size();i++) { if (i>0) langnames+=","; langnames+=names[i]; } if (Globals::get_singleton()->has("locale/translation_remaps")) { Dictionary remaps = Globals::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; remaps.get_key_list(&rk); Vector<String> keys; for(List<Variant>::Element *E=rk.front();E;E=E->next()) { keys.push_back(E->get()); } keys.sort(); for(int i=0;i<keys.size();i++) { TreeItem *t = translation_remap->create_item(root); t->set_editable(0,false); t->set_text(0,keys[i].replace_first("res://","")); t->set_tooltip(0,keys[i]); t->set_metadata(0,keys[i]); t->add_button(0,get_icon("Del","EditorIcons"),0); if (keys[i]==remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); StringArray selected = remaps[keys[i]]; for(int j=0;j<selected.size();j++) { String s = selected[j]; int qp = s.find_last(":"); String path = s.substr(0,qp); String locale = s.substr(qp+1,s.length()); TreeItem *t2 = translation_remap_options->create_item(root2); t2->set_editable(0,false); t2->set_text(0,path.replace_first("res://","")); t2->set_tooltip(0,path); t2->set_metadata(0,j); t2->add_button(0,get_icon("Del","EditorIcons"),0); t2->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); t2->set_text(1,langnames); t2->set_editable(1,true); t2->set_metadata(1,path); int idx = langs.find(locale); if (idx<0) idx=0; t2->set_range(1,idx); } } } } updating_translations=false; }
Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phase) { RID_OwnerBase::init_rid(); OS::get_singleton()->initialize_core(); ObjectTypeDB::init(); MAIN_PRINT("Main: Initialize CORE"); register_core_types(); register_core_driver_types(); MAIN_PRINT("Main: Initialize Globals"); Thread::_main_thread_id = Thread::get_caller_ID(); globals = memnew( Globals ); input_map = memnew( InputMap ); path_remap = memnew( PathRemap ); translation_server = memnew( TranslationServer ); performance = memnew( Performance ); globals->add_singleton(Globals::Singleton("Performance",performance)); MAIN_PRINT("Main: Parse CMDLine"); /* argument parsing and main creation */ List<String> args; List<String> main_args; for(int i=0;i<argc;i++) { args.push_back(String::utf8(argv[i])); } List<String>::Element *I=args.front(); I=args.front(); while (I) { I->get()=unescape_cmdline(I->get().strip_escapes()); // print_line("CMD: "+I->get()); I=I->next(); } I=args.front(); video_mode = OS::get_singleton()->get_default_video_mode(); String video_driver=""; String audio_driver=""; String game_path="."; String debug_mode; String debug_host; String main_pack; bool quiet_stdout=false; int rtm=-1; String remotefs; String remotefs_pass; String screen = ""; List<String> pack_list; Vector<String> breakpoints; bool use_custom_res=true; bool force_res=false; I=args.front(); packed_data = PackedData::get_singleton(); if (!packed_data) packed_data = memnew(PackedData); #ifdef MINIZIP_ENABLED //XXX: always get_singleton() == 0x0 zip_packed_data = ZipArchive::get_singleton(); //TODO: remove this temporary fix if (!zip_packed_data) { zip_packed_data = memnew(ZipArchive); } packed_data->add_pack_source(zip_packed_data); #endif bool editor=false; while(I) { List<String>::Element *N=I->next(); if (I->get() == "-noop") { // no op } else if (I->get()=="-h" || I->get()=="--help" || I->get()=="/?") { // resolution goto error; } else if (I->get()=="-r") { // resolution if (I->next()) { String vm=I->next()->get(); if (vm.find("x")==-1) { // invalid parameter format OS::get_singleton()->print("Invalid -r argument: %s\n",vm.utf8().get_data()); goto error; } int w=vm.get_slice("x",0).to_int(); int h=vm.get_slice("x",1).to_int(); if (w==0 || h==0) { OS::get_singleton()->print("Invalid -r resolution, x and y must be >0\n"); goto error; } video_mode.width=w; video_mode.height=h; force_res=true; N=I->next()->next(); } else { OS::get_singleton()->print("Invalid -p argument, needs resolution\n"); goto error; } } else if (I->get()=="-p") { // position if (I->next()) { String vm=I->next()->get(); if (vm.find("x")==-1) { // invalid parameter format OS::get_singleton()->print("Invalid -p argument: %s\n",vm.utf8().get_data()); goto error; } int x=vm.get_slice("x",0).to_int(); int y=vm.get_slice("x",1).to_int(); init_custom_pos=Point2(x,y); init_use_custom_pos=true; N=I->next()->next(); } else { OS::get_singleton()->print("Invalid -r argument, needs position\n"); goto error; } } else if (I->get()=="-mx") { // video driver init_maximized=true; } else if (I->get()=="-w") { // video driver init_windowed=true; } else if (I->get()=="-vd") { // video driver if (I->next()) { video_driver=I->next()->get(); N=I->next()->next(); } else { OS::get_singleton()->print("Invalid -cd argument, needs driver name\n"); goto error; } } else if (I->get()=="-lang") { // language if (I->next()) { locale=I->next()->get(); N=I->next()->next(); } else { OS::get_singleton()->print("Invalid -lang argument, needs language code\n"); goto error; } } else if (I->get()=="-rfs") { // language if (I->next()) { remotefs=I->next()->get(); N=I->next()->next(); } else { goto error; } } else if (I->get()=="-rfs_pass") { // language if (I->next()) { remotefs_pass=I->next()->get(); N=I->next()->next(); } else { goto error; } } else if (I->get()=="-rthread") { // language if (I->next()) { if (I->next()->get()=="safe") rtm=OS::RENDER_THREAD_SAFE; else if (I->next()->get()=="unsafe") rtm=OS::RENDER_THREAD_UNSAFE; else if (I->next()->get()=="separate") rtm=OS::RENDER_SEPARATE_THREAD; N=I->next()->next(); } else { goto error; } } else if (I->get()=="-ad") { // video driver if (I->next()) { audio_driver=I->next()->get(); N=I->next()->next(); } else { goto error; } } else if (I->get()=="-f") { // fullscreen //video_mode.fullscreen=false; init_fullscreen=true; } else if (I->get()=="-e" || I->get()=="-editor") { // fonud editor editor=true; } else if (I->get()=="-nowindow") { // fullscreen OS::get_singleton()->set_no_window_mode(true); } else if (I->get()=="-quiet") { // fullscreen quiet_stdout=true; } else if (I->get()=="-v") { // fullscreen OS::get_singleton()->_verbose_stdout=true; } else if (I->get()=="-path") { // resolution if (I->next()) { String p = I->next()->get(); if (OS::get_singleton()->set_cwd(p)==OK) { //nothing } else { game_path=I->next()->get(); //use game_path instead } N=I->next()->next(); } else { goto error; } } else if (I->get()=="-bp") { // /breakpoints if (I->next()) { String bplist = I->next()->get(); breakpoints= bplist.split(","); N=I->next()->next(); } else { goto error; } } else if (I->get()=="-fdelay") { // resolution if (I->next()) { OS::get_singleton()->set_frame_delay(I->next()->get().to_int()); N=I->next()->next(); } else { goto error; } } else if (I->get()=="-timescale") { // resolution if (I->next()) { OS::get_singleton()->set_time_scale(I->next()->get().to_double()); N=I->next()->next(); } else { goto error; } } else if (I->get() == "-pack") { if (I->next()) { pack_list.push_back(I->next()->get()); N = I->next()->next(); } else { goto error; }; } else if (I->get() == "-main_pack") { if (I->next()) { main_pack=I->next()->get(); N = I->next()->next(); } else { goto error; }; } else if (I->get()=="-debug" || I->get()=="-d") { debug_mode="local"; } else if (I->get()=="-debugcol" || I->get()=="-dc") { debug_collisions=true; } else if (I->get()=="-debugnav" || I->get()=="-dn") { debug_navigation=true; } else if (I->get()=="-editor_scene") { if (I->next()) { Globals::get_singleton()->set("editor_scene",game_path=I->next()->get()); } else { goto error; } } else if (I->get()=="-rdebug") { if (I->next()) { debug_mode="remote"; debug_host=I->next()->get(); if (debug_host.find(":")==-1) { //wrong host OS::get_singleton()->print("Invalid debug host string\n"); goto error; } N=I->next()->next(); } else { goto error; } } else { //test for game path bool gpfound=false; if (!I->get().begins_with("-") && game_path=="") { DirAccess* da = DirAccess::open(I->get()); if (da!=NULL) { game_path=I->get(); gpfound=true; memdelete(da); } } if (!gpfound) { main_args.push_back(I->get()); } } I=N; } GLOBAL_DEF("debug/max_remote_stdout_chars_per_second",2048); if (debug_mode == "remote") { ScriptDebuggerRemote *sdr = memnew( ScriptDebuggerRemote ); uint16_t debug_port = GLOBAL_DEF("debug/remote_port",6007); if (debug_host.find(":")!=-1) { debug_port=debug_host.get_slicec(':',1).to_int(); debug_host=debug_host.get_slicec(':',0); } Error derr = sdr->connect_to_host(debug_host,debug_port); if (derr!=OK) { memdelete(sdr); } else { script_debugger=sdr; } } else if (debug_mode=="local") { script_debugger = memnew( ScriptDebuggerLocal ); } if (remotefs!="") { file_access_network_client=memnew(FileAccessNetworkClient); int port; if (remotefs.find(":")!=-1) { port=remotefs.get_slicec(':',1).to_int(); remotefs=remotefs.get_slicec(':',0); } else { port=6010; } Error err = file_access_network_client->connect(remotefs,port,remotefs_pass); if (err) { OS::get_singleton()->printerr("Could not connect to remotefs: %s:%i\n",remotefs.utf8().get_data(),port); goto error; } FileAccess::make_default<FileAccessNetwork>(FileAccess::ACCESS_RESOURCES); } if (script_debugger) { //there is a debugger, parse breakpoints for(int i=0;i<breakpoints.size();i++) { String bp = breakpoints[i]; int sp=bp.find_last(":"); if (sp==-1) { ERR_EXPLAIN("Invalid breakpoint: '"+bp+"', expected file:line format."); ERR_CONTINUE(sp==-1); } script_debugger->insert_breakpoint(bp.substr(sp+1,bp.length()).to_int(),bp.substr(0,sp)); } } #ifdef TOOLS_ENABLED if (editor) { packed_data->set_disabled(true); globals->set_disable_platform_override(true); StreamPeerSSL::initialize_certs=false; //will be initialized by editor } #endif if (globals->setup(game_path,main_pack)!=OK) { #ifdef TOOLS_ENABLED editor=false; #else OS::get_singleton()->print("error: Couldn't load game path '%s'\n",game_path.ascii().get_data()); goto error; #endif } if (editor) { main_args.push_back("-editor"); init_maximized=true; use_custom_res=false; } if (bool(Globals::get_singleton()->get("application/disable_stdout"))) { quiet_stdout=true; } if (bool(Globals::get_singleton()->get("application/disable_stderr"))) { _print_error_enabled = false; }; if (quiet_stdout) _print_line_enabled=false; OS::get_singleton()->set_cmdline(execpath, main_args); #ifdef TOOLS_ENABLED if (main_args.size()==0 && (!Globals::get_singleton()->has("application/main_loop_type")) && (!Globals::get_singleton()->has("application/main_scene") || String(Globals::get_singleton()->get("application/main_scene"))=="")) use_custom_res=false; //project manager (run without arguments) #endif input_map->load_from_globals(); if (video_driver=="") // specified in engine.cfg video_driver=_GLOBAL_DEF("display/driver",Variant((const char*)OS::get_singleton()->get_video_driver_name(0))); if (!force_res && use_custom_res && globals->has("display/width")) video_mode.width=globals->get("display/width"); if (!force_res &&use_custom_res && globals->has("display/height")) video_mode.height=globals->get("display/height"); if (use_custom_res && globals->has("display/fullscreen")) video_mode.fullscreen=globals->get("display/fullscreen"); if (use_custom_res && globals->has("display/resizable")) video_mode.resizable=globals->get("display/resizable"); if (use_custom_res && globals->has("display/borderless_window")) video_mode.borderless_window = globals->get("display/borderless_window"); if (!force_res && use_custom_res && globals->has("display/test_width") && globals->has("display/test_height")) { int tw = globals->get("display/test_width"); int th = globals->get("display/test_height"); if (tw>0 && th>0) { video_mode.width=tw; video_mode.height=th; } } GLOBAL_DEF("display/width",video_mode.width); GLOBAL_DEF("display/height",video_mode.height); GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); GLOBAL_DEF("display/resizable",video_mode.resizable); GLOBAL_DEF("display/borderless_window", video_mode.borderless_window); GLOBAL_DEF("display/test_width",0); GLOBAL_DEF("display/test_height",0); OS::get_singleton()->_pixel_snap=GLOBAL_DEF("display/use_2d_pixel_snap",false); OS::get_singleton()->_keep_screen_on=GLOBAL_DEF("display/keep_screen_on",true); if (rtm==-1) { rtm=GLOBAL_DEF("render/thread_model",OS::RENDER_THREAD_SAFE); if (rtm>=1) //hack for now rtm=1; } if (rtm>=0 && rtm<3) { if (editor) { rtm=OS::RENDER_THREAD_SAFE; } OS::get_singleton()->_render_thread_mode=OS::RenderThreadMode(rtm); } /* Determine Video Driver */ if (audio_driver=="") { // specified in engine.cfg audio_driver=GLOBAL_DEF("audio/driver",OS::get_singleton()->get_audio_driver_name(0)); } for (int i=0;i<OS::get_singleton()->get_video_driver_count();i++) { if (video_driver==OS::get_singleton()->get_video_driver_name(i)) { video_driver_idx=i; break; } } if (video_driver_idx<0) { OS::get_singleton()->alert( "Invalid Video Driver: "+video_driver ); video_driver_idx = 0; //goto error; } for (int i=0;i<OS::get_singleton()->get_audio_driver_count();i++) { if (audio_driver==OS::get_singleton()->get_audio_driver_name(i)) { audio_driver_idx=i; break; } } if (audio_driver_idx<0) { OS::get_singleton()->alert( "Invalid Audio Driver: "+audio_driver ); audio_driver_idx = 0; //goto error; } { String orientation = GLOBAL_DEF("display/orientation","landscape"); if (orientation=="portrait") OS::get_singleton()->set_screen_orientation(OS::SCREEN_PORTRAIT); else if (orientation=="reverse_landscape") OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_LANDSCAPE); else if (orientation=="reverse_portrait") OS::get_singleton()->set_screen_orientation(OS::SCREEN_REVERSE_PORTRAIT); else if (orientation=="sensor_landscape") OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_LANDSCAPE); else if (orientation=="sensor_portrait") OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR_PORTRAIT); else if (orientation=="sensor") OS::get_singleton()->set_screen_orientation(OS::SCREEN_SENSOR); else OS::get_singleton()->set_screen_orientation(OS::SCREEN_LANDSCAPE); } OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/fixed_fps",60)); OS::get_singleton()->set_target_fps(GLOBAL_DEF("application/target_fps",0)); if (!OS::get_singleton()->_verbose_stdout) //overrided OS::get_singleton()->_verbose_stdout=GLOBAL_DEF("debug/verbose_stdout",false); message_queue = memnew( MessageQueue ); Globals::get_singleton()->register_global_defaults(); if (p_second_phase) return setup2(); return OK; error: video_driver=""; audio_driver=""; game_path=""; args.clear(); main_args.clear(); print_help(execpath); if (performance) memdelete(performance); if (input_map) memdelete(input_map); if (translation_server) memdelete( translation_server ); if (globals) memdelete(globals); if (script_debugger) memdelete(script_debugger); if (packed_data) memdelete(packed_data); if (file_access_network_client) memdelete(file_access_network_client); if(path_remap) memdelete(path_remap); // Note 1: *zip_packed_data live into *packed_data // Note 2: PackedData::~PackedData destroy this. //#ifdef MINIZIP_ENABLED // if (zip_packed_data) // memdelete( zip_packed_data ); //#endif unregister_core_driver_types(); unregister_core_types(); OS::get_singleton()->_cmdline.clear(); if (message_queue) memdelete( message_queue); OS::get_singleton()->finalize_core(); locale=String(); return ERR_INVALID_PARAMETER; }
void EditorAssetInstaller::open(const String& p_path,int p_depth) { package_path=p_path; Set<String> files_sorted; FileAccess *src_f=NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(p_path.utf8().get_data(), &io); if (!pkg) { error->set_text("Error opening package file, not in zip format."); return; } int ret = unzGoToFirstFile(pkg); while(ret==UNZ_OK) { //get filename unz_file_info info; char fname[16384]; ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); String name=fname; files_sorted.insert(name); ret = unzGoToNextFile(pkg); } Map<String,Ref<Texture> > extension_guess; { extension_guess["png"]=get_icon("Texture","EditorIcons"); extension_guess["jpg"]=get_icon("Texture","EditorIcons"); extension_guess["tex"]=get_icon("Texture","EditorIcons"); extension_guess["atex"]=get_icon("Texture","EditorIcons"); extension_guess["dds"]=get_icon("Texture","EditorIcons"); extension_guess["scn"]=get_icon("PackedScene","EditorIcons"); extension_guess["tscn"]=get_icon("PackedScene","EditorIcons"); extension_guess["xml"]=get_icon("PackedScene","EditorIcons"); extension_guess["xscn"]=get_icon("PackedScene","EditorIcons"); extension_guess["mtl"]=get_icon("Material","EditorIcons"); extension_guess["shd"]=get_icon("Shader","EditorIcons"); extension_guess["gd"]=get_icon("GDScript","EditorIcons"); } Ref<Texture> generic_extension = get_icon("Object","EditorIcons"); unzClose(pkg); updating=true; tree->clear(); TreeItem *root=tree->create_item(); root->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); root->set_checked(0,true); root->set_icon(0,get_icon("folder","FileDialog")); root->set_text(0,"res://"); root->set_editable(0,true); Map<String,TreeItem*> dir_map; for(Set<String>::Element *E=files_sorted.front();E;E=E->next()) { String path = E->get(); int depth=p_depth; bool skip=false; while(depth>0) { int pp = path.find("/"); if (pp==-1) { skip=true; break; } path=path.substr(pp+1,path.length()); depth--; } if (skip || path==String()) continue; bool isdir=false; if (path.ends_with("/")) { //a directory path=path.substr(0,path.length()-1); isdir=true; } int pp = path.find_last("/"); TreeItem *parent; if (pp==-1) { parent=root; } else { String ppath=path.substr(0,pp); print_line("PPATH IS: "+ppath); ERR_CONTINUE(!dir_map.has(ppath)); parent=dir_map[ppath]; } TreeItem *ti = tree->create_item(parent); ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); ti->set_checked(0,true); ti->set_editable(0,true); if (isdir) { dir_map[path]=ti; ti->set_text(0,path.get_file()+"/"); ti->set_icon(0,get_icon("folder","FileDialog")); } else { String file = path.get_file(); String extension = file.extension().to_lower(); if (extension_guess.has(extension)) { ti->set_icon(0,extension_guess[extension]); } else { ti->set_icon(0,generic_extension); } ti->set_text(0,file); String res_path = "res://"+path; if (FileAccess::exists(res_path)) { ti->set_custom_color(0,Color(1,0.3,0.2)); ti->set_tooltip(0,res_path+" (Already Exists)"); ti->set_checked(0,false); } else { ti->set_tooltip(0,res_path); } ti->set_metadata(0,res_path); } status_map[E->get()]=ti; } popup_centered_ratio(); updating=false; }
void EditorFileSystem::_scan_scenes() { ERR_FAIL_COND(!scanning || scandir); //read .fscache HashMap<String,FileCache> file_cache; HashMap<String,DirCache> dir_cache; DirCache *dc=NULL; String cpath; sources_changed.clear(); String project=Globals::get_singleton()->get_resource_path(); FileAccess *f =FileAccess::open(project+"/.fscache",FileAccess::READ); if (f) { //read the disk cache while(!f->eof_reached()) { String l = f->get_line().strip_edges(); if (l==String()) continue; if (l.begins_with("::")) { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 3); String name = split[1]; dir_cache[name]=DirCache(); dc=&dir_cache[name]; dc->modification_time=split[2].to_int64(); if (name!="res://") { cpath=name+"/"; int sp=name.find_last("/"); if (sp==5) sp=6; String pd = name.substr(0,sp); DirCache *dcp = dir_cache.getptr(pd); ERR_CONTINUE(!dcp); dcp->subdirs.insert(name.get_file()); } else { cpath=name; } } else { Vector<String> split = l.split("::"); ERR_CONTINUE( split.size() != 4); String name = split[0]; String file; if (!name.begins_with("res://")) { file=name; name=cpath+name; } else { file=name.get_file(); } FileCache fc; fc.type=split[1]; fc.modification_time=split[2].to_int64(); String meta = split[3].strip_edges(); fc.meta.enabled=false; if (meta.find("<>")!=-1){ Vector<String> spl = meta.split("<>"); int sc = spl.size()-1; if (sc%3==0){ fc.meta.enabled=true; fc.meta.import_editor=spl[0]; fc.meta.sources.resize(sc/3); for(int i=0;i<fc.meta.sources.size();i++) { fc.meta.sources[i].path=spl[1+i*3+0]; fc.meta.sources[i].md5=spl[1+i*3+1]; fc.meta.sources[i].modified_time=spl[1+i*3+2].to_int64(); } } } file_cache[name]=fc; ERR_CONTINUE(!dc); dc->files.insert(file); } } f->close(); memdelete(f); } total=0; DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); //da->change_dir( Globals::get_singleton()->get_resource_path() ); List<String> extensionsl; ResourceLoader::get_recognized_extensions_for_type("",&extensionsl); Set<String> extensions; for(List<String>::Element *E = extensionsl.front();E;E=E->next()) { extensions.insert(E->get()); } EditorProgressBG scan_progress("efs","ScanFS",100); md_count=0; scandir=_scan_dir(da,extensions,"",0,1,"",file_cache,dir_cache,scan_progress); memdelete(da); if (abort_scan && scandir) { memdelete(scandir); scandir=NULL; } //save back the findings f=FileAccess::open(project+"/.fscache",FileAccess::WRITE); _save_type_cache_fs(scandir,f); f->close(); memdelete(f); scanning=false; }
RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) { if (r_error) *r_error=ERR_CANT_OPEN; if (p_path.extension()=="cube") { // open as cubemap txture CubeMap* ptr = memnew(CubeMap); Ref<CubeMap> cubemap( ptr ); Error err; FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err); if (err) { ERR_FAIL_COND_V( err, RES() ); } String base_path=p_path.substr( 0, p_path.find_last("/")+1 ); for(int i=0;i<6;i++) { String file = f->get_line().strip_edges(); Image image; Error err = ImageLoader::load_image(base_path+file,&image); if (err) { memdelete(f); ERR_FAIL_COND_V( err, RES() ); } if (i==0) { //cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP); } static const CubeMap::Side cube_side[6]= { CubeMap::SIDE_LEFT, CubeMap::SIDE_RIGHT, CubeMap::SIDE_BOTTOM, CubeMap::SIDE_TOP, CubeMap::SIDE_FRONT, CubeMap::SIDE_BACK }; cubemap->set_side(cube_side[i],image); } memdelete(f); cubemap->set_name(p_path.get_file()); if (r_error) *r_error=OK; return cubemap; } else { // simple image ImageTexture* ptr = memnew(ImageTexture); Ref<ImageTexture> texture( ptr ); uint64_t begtime; double total; Image image; if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); Error err = ImageLoader::load_image(p_path,&image); if (!err && debug_load_times) { double total=(double)(OS::get_singleton()->get_ticks_usec()-begtime)/1000000.0; print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height())); print_line(" -load: "+rtos(total)); } ERR_EXPLAIN("Failed loading image: "+p_path); ERR_FAIL_COND_V(err, RES()); if (r_error) *r_error=ERR_FILE_CORRUPT; #ifdef DEBUG_ENABLED #ifdef TOOLS_ENABLED if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) { if (bool(Globals::get_singleton()->get("debug/max_texture_size_alert"))) { OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!"); } ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+"."); ERR_FAIL_V(RES()); } #endif #endif uint32_t flags=0; FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); Map<String,bool> flags_found; if (f2) { while(!f2->eof_reached()) { String l2 = f2->get_line(); int eqpos = l2.find("="); if (eqpos!=-1) { String flag=l2.substr(0,eqpos).strip_edges(); String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); flags_found[flag]=(val=="true" || val=="1")?true:false; } } memdelete(f2); } if (flags_found.has("filter")) { if (flags_found["filter"]) flags|=Texture::FLAG_FILTER; } else if (bool(GLOBAL_DEF("image_loader/filter",true))) { flags|=Texture::FLAG_FILTER; } if (flags_found.has("gen_mipmaps")) { if (flags_found["gen_mipmaps"]) flags|=Texture::FLAG_MIPMAPS; } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) { flags|=Texture::FLAG_MIPMAPS; } if (flags_found.has("repeat")) { if (flags_found["repeat"]) flags|=Texture::FLAG_REPEAT; } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) { flags|=Texture::FLAG_REPEAT; } if (flags_found.has("anisotropic")) { if (flags_found["anisotropic"]) flags|=Texture::FLAG_ANISOTROPIC_FILTER; } if (flags_found.has("tolinear")) { if (flags_found["tolinear"]) flags|=Texture::FLAG_CONVERT_TO_LINEAR; } if (flags_found.has("mirroredrepeat")) { if (flags_found["mirroredrepeat"]) flags|=Texture::FLAG_MIRRORED_REPEAT; } if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); //print_line("img: "+p_path+" flags: "+itos(flags)); texture->create_from_image( image,flags ); texture->set_name(p_path.get_file()); if (debug_load_times) { total=(double)(OS::get_singleton()->get_ticks_usec()-begtime)/1000000.0; print_line(" -make texture: "+rtos(total)); } if (r_error) *r_error=OK; return RES( texture ); } }
void ScenesDock::_file_option(int p_option) { switch(p_option) { case FILE_SHOW_IN_EXPLORER: case FILE_OPEN: { int idx=-1; for(int i=0;i<files->get_item_count();i++) { if (files->is_selected(i)) { idx=i; break; } } if (idx<0) return; String path = files->get_item_metadata(idx); if (p_option == FILE_SHOW_IN_EXPLORER) { String dir = Globals::get_singleton()->globalize_path(path); dir = dir.substr(0, dir.find_last("/")); OS::get_singleton()->shell_open(String("file://")+dir); return; } if (path.ends_with("/")) { if (path!="res://") { path=path.substr(0,path.length()-1); } this->path=path; _update_files(false); current_path->set_text(path); _push_to_history(); } else { if (ResourceLoader::get_resource_type(path)=="PackedScene") { editor->open_request(path); } else { editor->load_resource(path); } } } break; case FILE_INSTANCE: { for (int i = 0; i<files->get_item_count(); i++) { String path =files->get_item_metadata(i); if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") { emit_signal("instance",path); } } } break; case FILE_DEPENDENCIES: { int idx = files->get_current(); if (idx<0 || idx>=files->get_item_count()) break; String path = files->get_item_metadata(idx); deps_editor->edit(path); } break; case FILE_OWNERS: { int idx = files->get_current(); if (idx<0 || idx>=files->get_item_count()) break; String path = files->get_item_metadata(idx); owners_editor->show(path); } break; case FILE_MOVE: { move_dirs.clear();; move_files.clear(); for(int i=0;i<files->get_item_count();i++) { String path = files->get_item_metadata(i); if (!files->is_selected(i)) continue; if (files->get_item_text(i)=="..") { EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'")); return; } if (path.ends_with("/")) { move_dirs.push_back(path.substr(0,path.length()-1)); } else { move_files.push_back(path); } } if (move_dirs.empty() && move_files.size()==1) { rename_dialog->clear_filters(); rename_dialog->add_filter("*."+move_files[0].extension()); rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); rename_dialog->set_current_path(move_files[0]); rename_dialog->popup_centered_ratio(); rename_dialog->set_title(TTR("Pick New Name and Location For:")+" "+move_files[0].get_file()); } else { //just move move_dialog->popup_centered_ratio(); } } break; case FILE_REMOVE: { Vector<String> torem; for(int i=0;i<files->get_item_count();i++) { String path = files->get_item_metadata(i); if (path.ends_with("/") || !files->is_selected(i)) continue; torem.push_back(path); } if (torem.empty()) { EditorNode::get_singleton()->show_warning(TTR("No files selected!")); break; } remove_dialog->show(torem); //1) find if used //2) warn } break; case FILE_INFO: { } break; } }
void FileSystemDock::_file_option(int p_option) { switch(p_option) { case FILE_SHOW_IN_EXPLORER: case FILE_OPEN: { int idx=-1; for(int i=0;i<files->get_item_count();i++) { if (files->is_selected(i)) { idx=i; break; } } if (idx<0) return; String path = files->get_item_metadata(idx); if (p_option == FILE_SHOW_IN_EXPLORER) { String dir = Globals::get_singleton()->globalize_path(path); dir = dir.substr(0, dir.find_last("/")); OS::get_singleton()->shell_open(String("file://")+dir); return; } if (path.ends_with("/")) { if (path!="res://") { path=path.substr(0,path.length()-1); } this->path=path; _update_files(false); current_path->set_text(path); _push_to_history(); } else { if (ResourceLoader::get_resource_type(path)=="PackedScene") { editor->open_request(path); } else { editor->load_resource(path); } } } break; case FILE_INSTANCE: { Vector<String> paths; for (int i = 0; i<files->get_item_count(); i++) { if (!files->is_selected(i)) continue; String path =files->get_item_metadata(i); if (EditorFileSystem::get_singleton()->get_file_type(path)=="PackedScene") { paths.push_back(path); } } if (!paths.empty()) { emit_signal("instance", paths); } } break; case FILE_DEPENDENCIES: { int idx = files->get_current(); if (idx<0 || idx>=files->get_item_count()) break; String path = files->get_item_metadata(idx); deps_editor->edit(path); } break; case FILE_OWNERS: { int idx = files->get_current(); if (idx<0 || idx>=files->get_item_count()) break; String path = files->get_item_metadata(idx); owners_editor->show(path); } break; case FILE_MOVE: { move_dirs.clear();; move_files.clear(); for(int i=0;i<files->get_item_count();i++) { String path = files->get_item_metadata(i); if (!files->is_selected(i)) continue; if (files->get_item_text(i)=="..") { EditorNode::get_singleton()->show_warning(TTR("Can't operate on '..'")); return; } if (path.ends_with("/")) { move_dirs.push_back(path.substr(0,path.length()-1)); } else { move_files.push_back(path); } } if (move_dirs.empty() && move_files.size()==1) { rename_dialog->clear_filters(); rename_dialog->add_filter("*."+move_files[0].extension()); rename_dialog->set_mode(EditorFileDialog::MODE_SAVE_FILE); rename_dialog->set_current_path(move_files[0]); rename_dialog->popup_centered_ratio(); rename_dialog->set_title(TTR("Pick New Name and Location For:")+" "+move_files[0].get_file()); } else { //just move move_dialog->popup_centered_ratio(); } } break; case FILE_REMOVE: { Vector<String> torem; for(int i=0;i<files->get_item_count();i++) { String path = files->get_item_metadata(i); if (path.ends_with("/") || !files->is_selected(i)) continue; torem.push_back(path); } if (torem.empty()) { EditorNode::get_singleton()->show_warning(TTR("No files selected!")); break; } remove_dialog->show(torem); //1) find if used //2) warn } break; case FILE_INFO: { } break; case FILE_REIMPORT: { Vector<String> reimport; for(int i=0;i<files->get_item_count();i++) { if (!files->is_selected(i)) continue; String path = files->get_item_metadata(i); reimport.push_back(path); } ERR_FAIL_COND(reimport.size()==0); Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(reimport[0]); ERR_FAIL_COND(!rimd.is_valid()); String editor=rimd->get_editor(); if (editor.begins_with("texture_")) { //compatibility fix for old texture format editor="texture"; } Ref<EditorImportPlugin> rimp = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor); ERR_FAIL_COND(!rimp.is_valid()); if (reimport.size()==1) { rimp->import_dialog(reimport[0]); } else { rimp->reimport_multiple_files(reimport); } } break; case FILE_COPY_PATH: int idx = files->get_current(); if (idx<0 || idx>=files->get_item_count()) break; String path = files->get_item_metadata(idx); OS::get_singleton()->set_clipboard(path); } }