diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 5 | ||||
-rw-r--r-- | core/bind/core_bind.h | 1 | ||||
-rw-r--r-- | core/dvector.h | 2 | ||||
-rw-r--r-- | core/image.cpp | 2 | ||||
-rw-r--r-- | core/io/config_file.cpp | 5 | ||||
-rw-r--r-- | core/io/config_file.h | 2 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 97 | ||||
-rw-r--r-- | core/io/resource_format_binary.h | 1 | ||||
-rw-r--r-- | core/io/resource_import.cpp | 238 | ||||
-rw-r--r-- | core/io/resource_import.h | 76 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 145 | ||||
-rw-r--r-- | core/io/resource_loader.h | 9 | ||||
-rw-r--r-- | core/object.h | 1 | ||||
-rw-r--r-- | core/pair.h | 9 | ||||
-rw-r--r-- | core/path_remap.cpp | 182 | ||||
-rw-r--r-- | core/path_remap.h | 35 | ||||
-rw-r--r-- | core/register_core_types.cpp | 11 | ||||
-rw-r--r-- | core/resource.cpp | 131 | ||||
-rw-r--r-- | core/resource.h | 54 | ||||
-rw-r--r-- | core/translation.cpp | 14 | ||||
-rw-r--r-- | core/translation.h | 1 |
21 files changed, 390 insertions, 631 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 80adafe092..5dbcfc86bc 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -106,17 +106,12 @@ bool _ResourceLoader::has(const String &p_path) { return ResourceCache::has(local_path); }; -Ref<ResourceImportMetadata> _ResourceLoader::load_import_metadata(const String& p_path) { - - return ResourceLoader::load_import_metadata(p_path); -} void _ResourceLoader::_bind_methods() { ClassDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL("")); ClassDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); - ClassDB::bind_method(_MD("load_import_metadata:ResourceImportMetadata","path"),&_ResourceLoader::load_import_metadata); ClassDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ClassDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); ClassDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 13081fc867..00cbb254d6 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -54,7 +54,6 @@ public: void set_abort_on_missing_resources(bool p_abort); PoolStringArray get_dependencies(const String& p_path); bool has(const String& p_path); - Ref<ResourceImportMetadata> load_import_metadata(const String& p_path); _ResourceLoader(); }; diff --git a/core/dvector.h b/core/dvector.h index cac9e8ef85..53a29738f7 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -89,7 +89,7 @@ class PoolVector { if (!alloc) return; - ERR_FAIL_COND(alloc->lock>0); +// ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all if (alloc->refcount.get()==1) return; //nothing to do diff --git a/core/image.cpp b/core/image.cpp index ed505b0f77..2d038691f2 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2155,7 +2155,7 @@ void Image::fix_alpha_edges() { return; //not needed PoolVector<uint8_t> dcopy = data; - PoolVector<uint8_t>::Read rp = data.read(); + PoolVector<uint8_t>::Read rp = dcopy.read(); const uint8_t *srcptr=rp.ptr(); PoolVector<uint8_t>::Write wp = data.write(); diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index a9de740806..b944906e78 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -119,7 +119,10 @@ void ConfigFile::get_section_keys(const String& p_section,List<String> *r_keys) } +void ConfigFile::erase_section(const String& p_section) { + values.erase(p_section); +} Error ConfigFile::save(const String& p_path){ @@ -215,6 +218,8 @@ void ConfigFile::_bind_methods(){ ClassDB::bind_method(_MD("get_sections"),&ConfigFile::_get_sections); ClassDB::bind_method(_MD("get_section_keys","section"),&ConfigFile::_get_section_keys); + ClassDB::bind_method(_MD("erase_section","section"),&ConfigFile::erase_section); + ClassDB::bind_method(_MD("load:Error","path"),&ConfigFile::load); ClassDB::bind_method(_MD("save:Error","path"),&ConfigFile::save); diff --git a/core/io/config_file.h b/core/io/config_file.h index 397342f90f..c9c4a9fbc0 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -54,6 +54,8 @@ public: void get_sections(List<String> *r_sections) const; void get_section_keys(const String& p_section,List<String> *r_keys) const; + void erase_section(const String& p_section); + Error save(const String& p_path); Error load(const String& p_path); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 8f8fce0891..c75e476764 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -759,30 +759,7 @@ Error ResourceInteractiveLoaderBinary::poll(){ resource_cache.push_back(res); if (main) { - if (importmd_ofs) { - f->seek(importmd_ofs); - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - imd->set_editor(get_unicode_string()); - int sc = f->get_32(); - for(int i=0;i<sc;i++) { - - String src = get_unicode_string(); - String md5 = get_unicode_string(); - imd->add_source(src,md5); - } - int pc = f->get_32(); - - for(int i=0;i<pc;i++) { - - String name = get_unicode_string(); - Variant val; - parse_variant(val); - imd->set_option(name,val); - } - res->set_import_metadata(imd); - - } f->close(); resource=res; error=ERR_FILE_EOF; @@ -849,9 +826,6 @@ void ResourceInteractiveLoaderBinary::get_dependencies(FileAccess *p_f,List<Stri for(int i=0;i<external_resources.size();i++) { String dep=external_resources[i].path; - if (dep.ends_with("*")) { - dep=ResourceLoader::guess_full_filename(dep,external_resources[i].type); - } if (p_add_types && external_resources[i].type!=String()) { dep+="::"+external_resources[i].type; @@ -1104,53 +1078,6 @@ bool ResourceFormatLoaderBinary::handles_type(const String& p_type) const{ return true; //handles all } -Error ResourceFormatLoaderBinary::load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const { - - - FileAccess *f = FileAccess::open(p_path,FileAccess::READ); - if (!f) { - return ERR_FILE_CANT_OPEN; - } - - Ref<ResourceInteractiveLoaderBinary> ria = memnew( ResourceInteractiveLoaderBinary ); - ria->local_path=GlobalConfig::get_singleton()->localize_path(p_path); - ria->res_path=ria->local_path; - //ria->set_local_path( Globals::get_singleton()->localize_path(p_path) ); - ria->recognize(f); - if(ria->error!=OK) - return ERR_FILE_UNRECOGNIZED; - f=ria->f; - uint64_t imp_ofs = f->get_64(); - - if (imp_ofs==0) - return ERR_UNAVAILABLE; - - f->seek(imp_ofs); - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - imd->set_editor(ria->get_unicode_string()); - int sc = f->get_32(); - for(int i=0;i<sc;i++) { - - String src = ria->get_unicode_string(); - String md5 = ria->get_unicode_string(); - imd->add_source(src,md5); - } - int pc = f->get_32(); - - for(int i=0;i<pc;i++) { - - String name = ria->get_unicode_string(); - Variant val; - ria->parse_variant(val); - imd->set_option(name,val); - } - - r_var=imd; - - return OK; - -} - void ResourceFormatLoaderBinary::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types) { @@ -2179,30 +2106,6 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ } f->seek_end(); - print_line("SAVING: "+p_path); - if (p_resource->get_import_metadata().is_valid()) { - uint64_t md_pos = f->get_pos(); - Ref<ResourceImportMetadata> imd=p_resource->get_import_metadata(); - save_unicode_string(imd->get_editor()); - f->store_32(imd->get_source_count()); - for(int i=0;i<imd->get_source_count();i++) { - save_unicode_string(imd->get_source_path(i)); - save_unicode_string(imd->get_source_md5(i)); - print_line("SAVE PATH: "+imd->get_source_path(i)); - print_line("SAVE MD5: "+imd->get_source_md5(i)); - } - List<String> options; - imd->get_options(&options); - f->store_32(options.size()); - for(List<String>::Element *E=options.front();E;E=E->next()) { - save_unicode_string(E->get()); - write_variant(imd->get_option(E->get())); - } - - f->seek(md_at); - f->store_64(md_pos); - f->seek_end(); - } f->store_buffer((const uint8_t*)"RSRC",4); //magic at end diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 611029e792..1dac51cc5c 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -109,7 +109,6 @@ public: virtual bool handles_type(const String& p_type) const; virtual String get_resource_type(const String &p_path) const; virtual void get_dependencies(const String& p_path, List<String> *p_dependencies, bool p_add_types=false); - virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const; virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp new file mode 100644 index 0000000000..d0799cdbe6 --- /dev/null +++ b/core/io/resource_import.cpp @@ -0,0 +1,238 @@ +#include "resource_import.h" +#include "variant_parser.h" + +Error ResourceFormatImporter::_get_path_and_type(const String& p_path, PathAndType &r_path_and_type) const { + + Error err; + FileAccess *f= FileAccess::open(p_path+".import",FileAccess::READ,&err); + + if (!f) + return err; + + VariantParser::StreamFile stream; + stream.f=f; + + String assign; + Variant value; + VariantParser::Tag next_tag; + + int lines=0; + String error_text; + while(true) { + + assign=Variant(); + next_tag.fields.clear(); + next_tag.name=String(); + + err = VariantParser::parse_tag_assign_eof(&stream,lines,error_text,next_tag,assign,value,NULL,true); + if (err==ERR_FILE_EOF) { + memdelete(f); + return OK; + } + else if (err!=OK) { + ERR_PRINTS("ResourceFormatImporter::load - "+p_path+".import:"+itos(lines)+" error: "+error_text); + memdelete(f); + return err; + } + + if (assign!=String()) { + if (assign=="path") { + r_path_and_type.path=value; + } else if (assign=="type") { + r_path_and_type.type=value; + } + + } else if (next_tag.name!="remap") { + break; + } + } + + memdelete(f); + + if (r_path_and_type.path==String() || r_path_and_type.type==String()) { + return ERR_FILE_CORRUPT; + } + return OK; + +} + + +RES ResourceFormatImporter::load(const String &p_path,const String& p_original_path,Error *r_error) { + + PathAndType pat; + Error err = _get_path_and_type(p_path,pat); + + if (err!=OK) { + + if (r_error) + *r_error=err; + + return RES(); + } + + + RES res = ResourceLoader::load(pat.path,pat.type,false,r_error); + +#ifdef TOOLS_ENABLED + res->set_import_last_modified_time( res->get_last_modified_time() ); //pass this, if used + res->set_import_path(pat.path); +#endif + + return res; + +} + +void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extensions) const{ + + print_line("getting exts from: "+itos(importers.size())); + Set<String> found; + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + List<String> local_exts; + E->get()->get_recognized_extensions(&local_exts); + for (List<String>::Element *F=local_exts.front();F;F=F->next()) { + if (!found.has(F->get())) { + print_line("adding ext "+String(F->get())); + p_extensions->push_back(F->get()); + found.insert(F->get()); + } + } + } +} + +void ResourceFormatImporter::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const{ + + if (p_type=="") { + return get_recognized_extensions(p_extensions); + } + + Set<String> found; + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + String res_type = E->get()->get_resource_type(); + if (res_type==String()) + continue; + + if (!ClassDB::is_parent_class(res_type,p_type)) + continue; + + List<String> local_exts; + E->get()->get_recognized_extensions(&local_exts); + for (List<String>::Element *F=local_exts.front();F;F=F->next()) { + if (!found.has(F->get())) { + p_extensions->push_back(F->get()); + found.insert(F->get()); + } + } + } +} + +bool ResourceFormatImporter::recognize_path(const String& p_path,const String& p_for_type) const{ + + return FileAccess::exists(p_path+".import"); + +} + +bool ResourceFormatImporter::can_be_imported(const String& p_path) const { + + return ResourceFormatLoader::recognize_path(p_path); +} + + +bool ResourceFormatImporter::handles_type(const String& p_type) const { + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + + String res_type = E->get()->get_resource_type(); + if (res_type==String()) + continue; + if (ClassDB::is_parent_class(res_type,p_type)) + return true; + + } + + return true; +} + +String ResourceFormatImporter::get_resource_type(const String &p_path) const { + + PathAndType pat; + Error err = _get_path_and_type(p_path,pat); + + if (err!=OK) { + + return ""; + } + + return pat.type; +} + +void ResourceFormatImporter::get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types){ + + PathAndType pat; + Error err = _get_path_and_type(p_path,pat); + + if (err!=OK) { + + return; + } + + return ResourceLoader::get_dependencies(pat.path,p_dependencies,p_add_types); +} + +Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String& p_name) { + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + if (E->get()->get_importer_name()==p_name) { + return E->get(); + } + } + + return Ref<ResourceImporter>(); +} + + +void ResourceFormatImporter::get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers) { + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + List<String> local_exts; + E->get()->get_recognized_extensions(&local_exts); + for (List<String>::Element *F=local_exts.front();F;F=F->next()) { + if (p_extension.to_lower()==F->get()) { + r_importers->push_back(E->get()); + } + } + } +} + +Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_extension(const String& p_extension) { + + + Ref<ResourceImporter> importer; + float priority=0; + + for (Set< Ref<ResourceImporter> >::Element *E=importers.front();E;E=E->next()) { + + List<String> local_exts; + E->get()->get_recognized_extensions(&local_exts); + for (List<String>::Element *F=local_exts.front();F;F=F->next()) { + if (p_extension.to_lower()==F->get() && E->get()->get_priority() > priority) { + importer=E->get(); + priority=E->get()->get_priority(); + } + } + } + + return importer; +} + +String ResourceFormatImporter::get_import_base_path(const String& p_for_file) const { + + return "res://.import/"+p_for_file.get_file()+"-"+p_for_file.md5_text(); +} + +ResourceFormatImporter *ResourceFormatImporter::singleton=NULL; + +ResourceFormatImporter::ResourceFormatImporter() { + singleton=this; +} diff --git a/core/io/resource_import.h b/core/io/resource_import.h new file mode 100644 index 0000000000..939cecfbd9 --- /dev/null +++ b/core/io/resource_import.h @@ -0,0 +1,76 @@ +#ifndef RESOURCE_IMPORT_H +#define RESOURCE_IMPORT_H + + +#include "io/resource_loader.h" +class ResourceImporter; + +class ResourceFormatImporter : public ResourceFormatLoader { + + struct PathAndType { + String path; + String type; + }; + + + Error _get_path_and_type(const String& p_path,PathAndType & r_path_and_type) const; + + static ResourceFormatImporter *singleton; + + Set< Ref<ResourceImporter> > importers; +public: + + static ResourceFormatImporter *get_singleton() { return singleton; } + virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const; + virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const; + virtual bool handles_type(const String& p_type) const; + virtual String get_resource_type(const String &p_path) const; + virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false); + + virtual bool can_be_imported(const String& p_path) const; + + + void add_importer(const Ref<ResourceImporter>& p_importer) { importers.insert(p_importer); } + Ref<ResourceImporter> get_importer_by_name(const String& p_name); + Ref<ResourceImporter> get_importer_by_extension(const String& p_extension); + void get_importers_for_extension(const String& p_extension,List<Ref<ResourceImporter> > *r_importers); + + String get_import_base_path(const String& p_for_file) const; + ResourceFormatImporter(); +}; + + +class ResourceImporter : public Reference { + + GDCLASS(ResourceImporter,Reference) +public: + virtual String get_importer_name() const=0; + virtual String get_visible_name() const=0; + virtual void get_recognized_extensions(List<String> *p_extensions) const=0; + virtual String get_save_extension() const=0; + virtual String get_resource_type() const=0; + virtual float get_priority() const { return 1.0; } + + struct ImportOption { + PropertyInfo option; + Variant default_value; + + ImportOption(const PropertyInfo& p_info,const Variant& p_default) { option=p_info; default_value=p_default; } + ImportOption() {} + }; + + + virtual int get_preset_count() const { return 0; } + virtual String get_preset_name(int p_idx) const { return String(); } + + virtual void get_import_options(List<ImportOption> *r_options,int p_preset=0) const=0; + virtual bool get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const=0; + + + virtual Error import(const String& p_source_file,const String& p_save_path,const Map<StringName,Variant>& p_options,List<String>* r_platform_variants,List<String>* r_gen_files=NULL)=0; + +}; + +#endif // RESOURCE_IMPORT_H diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 354efaa83f..fbf6a2cea2 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -47,21 +47,29 @@ Error ResourceInteractiveLoader::wait() { return err; } +bool ResourceFormatLoader::recognize_path(const String& p_path,const String& p_for_type) const { -bool ResourceFormatLoader::recognize(const String& p_extension) const { + String extension = p_path.get_extension(); List<String> extensions; - get_recognized_extensions(&extensions); + if (p_for_type==String()) { + get_recognized_extensions(&extensions); + } else { + get_recognized_extensions_for_type(p_for_type,&extensions); + } + for (List<String>::Element *E=extensions.front();E;E=E->next()) { - if (E->get().nocasecmp_to(p_extension.get_extension())==0) + if (E->get().nocasecmp_to(extension)==0) return true; } return false; + } + void ResourceFormatLoader::get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const { if (p_type=="" || handles_type(p_type)) @@ -166,7 +174,7 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p else local_path = GlobalConfig::get_singleton()->localize_path(p_path); - local_path=find_complete_path(local_path,p_type_hint); + ERR_FAIL_COND_V(local_path=="",RES()); if (!p_no_cache && ResourceCache::has(local_path)) { @@ -177,22 +185,16 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p return RES( ResourceCache::get(local_path ) ); } - String remapped_path = PathRemap::get_singleton()->get_remap(local_path); - if (OS::get_singleton()->is_stdout_verbose()) - print_line("load resource: "+remapped_path); - - String extension=remapped_path.get_extension(); + print_line("load resource: "+local_path); bool found=false; for (int i=0;i<loader_count;i++) { - if (!loader[i]->recognize(extension)) - continue; - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + if (!loader[i]->recognize_path(local_path,p_type_hint)) continue; found=true; - RES res = loader[i]->load(remapped_path,local_path,r_error); + RES res = loader[i]->load(local_path,local_path,r_error); if (res.is_null()) continue; if (!p_no_cache) @@ -201,7 +203,7 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p res->set_edited(false); if (timestamp_on_load) { - uint64_t mt = FileAccess::get_modified_time(remapped_path); + uint64_t mt = FileAccess::get_modified_time(local_path); //printf("mt %s: %lli\n",remapped_path.utf8().get_data(),mt); res->set_last_modified_time(mt); } @@ -220,82 +222,6 @@ RES ResourceLoader::load(const String &p_path, const String& p_type_hint, bool p } -Ref<ResourceImportMetadata> ResourceLoader::load_import_metadata(const String &p_path) { - - - - String local_path; - if (p_path.is_rel_path()) - local_path="res://"+p_path; - else - local_path = GlobalConfig::get_singleton()->localize_path(p_path); - - String extension=p_path.get_extension(); - Ref<ResourceImportMetadata> ret; - - for (int i=0;i<loader_count;i++) { - - if (!loader[i]->recognize(extension)) - continue; - - Error err = loader[i]->load_import_metadata(local_path,ret); - if (err==OK) - break; - } - - - return ret; - -} - - - -String ResourceLoader::find_complete_path(const String& p_path,const String& p_type) { - //this is an old vestige when the engine saved files without extension. - //remains here for compatibility with old projects and only because it - //can be sometimes nice to open files using .* from a script and have it guess - //the right extension. - - String local_path = p_path; - if (local_path.ends_with("*")) { - - //find the extension for resource that ends with * - local_path = local_path.substr(0,local_path.length()-1); - List<String> extensions; - get_recognized_extensions_for_type(p_type,&extensions); - List<String> candidates; - - for(List<String>::Element *E=extensions.front();E;E=E->next()) { - - String path = local_path+E->get(); - - if (PathRemap::get_singleton()->has_remap(path) || FileAccess::exists(path)) { - candidates.push_back(path); - } - - } - - - if (candidates.size()==0) { - return ""; - } else if (candidates.size()==1 || p_type=="") { - return candidates.front()->get(); - } else { - - for(List<String>::Element *E=candidates.front();E;E=E->next()) { - - String rt = get_resource_type(E->get()); - if (ClassDB::is_parent_class(rt,p_type)) { - return E->get(); - } - } - - return ""; - } - } - - return local_path; -} Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_path,const String& p_type_hint,bool p_no_cache,Error *r_error) { @@ -309,7 +235,7 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_ else local_path = GlobalConfig::get_singleton()->localize_path(p_path); - local_path=find_complete_path(local_path,p_type_hint); + ERR_FAIL_COND_V(local_path=="",Ref<ResourceInteractiveLoader>()); @@ -329,19 +255,14 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_ if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: "); - String remapped_path = PathRemap::get_singleton()->get_remap(local_path); - - String extension=remapped_path.get_extension(); bool found=false; for (int i=0;i<loader_count;i++) { - if (!loader[i]->recognize(extension)) - continue; - if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) + if (!loader[i]->recognize_path(local_path,p_type_hint)) continue; found=true; - Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(remapped_path,r_error); + Ref<ResourceInteractiveLoader> ril = loader[i]->load_interactive(local_path,r_error); if (ril.is_null()) continue; if (!p_no_cache) @@ -383,20 +304,16 @@ void ResourceLoader::get_dependencies(const String& p_path, List<String> *p_depe else local_path = GlobalConfig::get_singleton()->localize_path(p_path); - String remapped_path = PathRemap::get_singleton()->get_remap(local_path); - - String extension=remapped_path.get_extension(); - for (int i=0;i<loader_count;i++) { - if (!loader[i]->recognize(extension)) + if (!loader[i]->recognize_path(local_path)) continue; /* if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) continue; */ - loader[i]->get_dependencies(remapped_path,p_dependencies,p_add_types); + loader[i]->get_dependencies(local_path,p_dependencies,p_add_types); } } @@ -410,20 +327,17 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String, else local_path = GlobalConfig::get_singleton()->localize_path(p_path); - String remapped_path = PathRemap::get_singleton()->get_remap(local_path); - - String extension=remapped_path.get_extension(); for (int i=0;i<loader_count;i++) { - if (!loader[i]->recognize(extension)) + if (!loader[i]->recognize_path(local_path)) continue; /* if (p_type_hint!="" && !loader[i]->handles_type(p_type_hint)) continue; */ - return loader[i]->rename_dependencies(p_path,p_map); + return loader[i]->rename_dependencies(local_path,p_map); } @@ -432,17 +346,6 @@ Error ResourceLoader::rename_dependencies(const String &p_path,const Map<String, } -String ResourceLoader::guess_full_filename(const String &p_path,const String& p_type) { - - String local_path; - if (p_path.is_rel_path()) - local_path="res://"+p_path; - else - local_path = GlobalConfig::get_singleton()->localize_path(p_path); - - return find_complete_path(local_path,p_type); - -} String ResourceLoader::get_resource_type(const String &p_path) { @@ -452,8 +355,6 @@ String ResourceLoader::get_resource_type(const String &p_path) { else local_path = GlobalConfig::get_singleton()->localize_path(p_path); - String remapped_path = PathRemap::get_singleton()->get_remap(local_path); - String extension=remapped_path.get_extension(); for (int i=0;i<loader_count;i++) { diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 7979bd02a7..f464415e12 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -61,11 +61,10 @@ public: virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); virtual void get_recognized_extensions(List<String> *p_extensions) const=0; virtual void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions) const; - bool recognize(const String& p_extension) const; + virtual bool recognize_path(const String& p_path,const String& p_for_type=String()) const; virtual bool handles_type(const String& p_type) const=0; virtual String get_resource_type(const String &p_path) const=0; virtual void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false); - virtual Error load_import_metadata(const String &p_path, Ref<ResourceImportMetadata>& r_var) const { return ERR_UNAVAILABLE; } virtual Error rename_dependencies(const String &p_path,const Map<String,String>& p_map) { return OK; } virtual ~ResourceFormatLoader() {} @@ -92,14 +91,12 @@ class ResourceLoader { static DependencyErrorNotify dep_err_notify; static bool abort_on_missing_resource; - static String find_complete_path(const String& p_path,const String& p_type); public: static Ref<ResourceInteractiveLoader> load_interactive(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL); static RES load(const String &p_path,const String& p_type_hint="",bool p_no_cache=false,Error *r_error=NULL); - static Ref<ResourceImportMetadata> load_import_metadata(const String &p_path); static void get_recognized_extensions_for_type(const String& p_type,List<String> *p_extensions); static void add_resource_format_loader(ResourceFormatLoader *p_format_loader,bool p_at_front=false); @@ -107,8 +104,6 @@ public: static void get_dependencies(const String& p_path,List<String> *p_dependencies,bool p_add_types=false); static Error rename_dependencies(const String &p_path,const Map<String,String>& p_map); - static String guess_full_filename(const String &p_path,const String& p_type); - static void set_timestamp_on_load(bool p_timestamp) { timestamp_on_load=p_timestamp; } static void notify_load_error(const String& p_err) { if (err_notify) err_notify(err_notify_ud,p_err); } @@ -122,4 +117,6 @@ public: static bool get_abort_on_missing_resources() { return abort_on_missing_resource; } }; + + #endif diff --git a/core/object.h b/core/object.h index b9a800afc4..3032452ccf 100644 --- a/core/object.h +++ b/core/object.h @@ -103,6 +103,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_SCRIPT_VARIABLE=8192, PROPERTY_USAGE_STORE_IF_NULL=16384, PROPERTY_USAGE_ANIMATE_AS_TRIGGER=32768, + PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED=65536, PROPERTY_USAGE_DEFAULT=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL=PROPERTY_USAGE_STORAGE|PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_NETWORK|PROPERTY_USAGE_INTERNATIONALIZED, diff --git a/core/pair.h b/core/pair.h index d75cbed642..174ffb3883 100644 --- a/core/pair.h +++ b/core/pair.h @@ -39,4 +39,13 @@ struct Pair { Pair( F p_first, S p_second) { first=p_first; second=p_second; } }; +template<class F,class S> +struct PairSort { + + bool operator()(const Pair<F,S>& A, const Pair<F,S>& B) const { + return A.first < B.first; + } +}; + + #endif // PAIR_H diff --git a/core/path_remap.cpp b/core/path_remap.cpp index ed77fd8840..bbaba71bba 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -28,185 +28,3 @@ /*************************************************************************/ #include "path_remap.h" -#include "globals.h" -#include "os/os.h" -#include "translation.h" - -PathRemap* PathRemap::singleton=NULL; - -PathRemap* PathRemap::get_singleton() { - - return singleton; -} - -void PathRemap::add_remap(const String& p_from, const String& p_to,const String& p_locale) { - - if (!remap.has(p_from)) { - remap[p_from]=RemapData(); - } - - if (p_locale==String()) - remap[p_from].always=p_to; - else - remap[p_from].locale[p_locale]=p_to; -} - - -String PathRemap::get_remap(const String& p_from) const { - - const RemapData *ptr=remap.getptr(p_from); - if (!ptr) { - if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap failed: "+p_from); - return p_from; - } else { - - const RemapData *ptr2=NULL; - - String locale = TranslationServer::get_singleton()->get_locale(); - - if (ptr->locale.has(locale)) { - if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap found: "+p_from+" -> "+ptr->locale[locale]); - - ptr2=remap.getptr(ptr->locale[locale]); - - if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too - return ptr2->always; - else - return ptr->locale[locale]; - } - - int p = locale.find("_"); - if (p!=-1) { - locale=locale.substr(0,p); - if (ptr->locale.has(locale)) { - if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap found: "+p_from+" -> "+ptr->locale[locale]); - - ptr2=remap.getptr(ptr->locale[locale]); - - if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too - return ptr2->always; - else - return ptr->locale[locale]; - - } - } - - if (ptr->always!=String()) { - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("remap found: "+p_from+" -> "+ptr->always); - } - return ptr->always; - } - - if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap failed: "+p_from); - - return p_from; - } -} -bool PathRemap::has_remap(const String& p_from) const{ - - return remap.has(p_from); -} - -void PathRemap::erase_remap(const String& p_from){ - - ERR_FAIL_COND(!remap.has(p_from)); - remap.erase(p_from); -} - -void PathRemap::clear_remaps() { - - remap.clear(); -} - -void PathRemap::load_remaps() { - - // default remaps first - PoolVector<String> remaps; - if (GlobalConfig::get_singleton()->has("remap/all")) { - remaps = GlobalConfig::get_singleton()->get("remap/all"); - } - - { - int rlen = remaps.size(); - - ERR_FAIL_COND( rlen%2 ); - PoolVector<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 - if (GlobalConfig::get_singleton()->has("remap/"+OS::get_singleton()->get_name())) { - remaps = GlobalConfig::get_singleton()->get("remap/"+OS::get_singleton()->get_name()); - } else { - remaps.resize(0); - } - //remaps = Globals::get_singleton()->get("remap/PSP"); - { - int rlen = remaps.size(); - - ERR_FAIL_COND( rlen%2 ); - PoolVector<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 (GlobalConfig::get_singleton()->has("locale/translation_remaps")) { - - Dictionary remaps = GlobalConfig::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(); - PoolStringArray sa = remaps[E->get()]; - int sas = sa.size(); - PoolStringArray::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 PathRemap::_bind_methods() { - - ClassDB::bind_method(_MD("add_remap","from","to","locale"),&PathRemap::add_remap,DEFVAL(String())); - ClassDB::bind_method(_MD("has_remap","path"),&PathRemap::has_remap); - ClassDB::bind_method(_MD("get_remap","path"),&PathRemap::get_remap); - ClassDB::bind_method(_MD("erase_remap","path"),&PathRemap::erase_remap); - ClassDB::bind_method(_MD("clear_remaps"),&PathRemap::clear_remaps); -} - -PathRemap::PathRemap() { - - singleton=this; -} diff --git a/core/path_remap.h b/core/path_remap.h index a106030f95..966bb10ea5 100644 --- a/core/path_remap.h +++ b/core/path_remap.h @@ -29,39 +29,4 @@ #ifndef PATH_REMAP_H #define PATH_REMAP_H -#include "hash_map.h" -#include "ustring.h" -#include "object.h" - - -class PathRemap : public Object { - - GDCLASS(PathRemap,Object); - - static PathRemap* singleton; - struct RemapData { - String always; - Map<String,String> locale; - }; - - HashMap<String,RemapData> remap; -protected: - - static void _bind_methods(); -public: - - void add_remap(const String& p_from, const String& p_to,const String& p_locale=String()); - bool has_remap(const String& p_from) const; - //_FORCE_INLINE_ String get_remap(const String& p_from) const { const String *ptr=remap.getptr(p_from); if (!ptr) return p_from; else return *ptr; } - String get_remap(const String& p_from) const; - void erase_remap(const String& p_from); - void clear_remaps(); - - void load_remaps(); - - static PathRemap* get_singleton(); - - PathRemap(); -}; - #endif // PATH_REMAP_H diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 242d36042d..ab94b56cdc 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -45,6 +45,7 @@ #include "compressed_translation.h" #include "io/translation_loader_po.h" #include "io/resource_format_binary.h" +#include "io/resource_import.h" #include "io/stream_peer_ssl.h" #include "os/input.h" #include "core/io/xml_parser.h" @@ -57,7 +58,7 @@ static ResourceFormatSaverBinary *resource_saver_binary=NULL; static ResourceFormatLoaderBinary *resource_loader_binary=NULL; - +static ResourceFormatImporter *resource_format_importer=NULL; static _ResourceLoader *_resource_loader=NULL; static _ResourceSaver *_resource_saver=NULL; @@ -105,12 +106,14 @@ void register_core_types() { resource_loader_binary = memnew( ResourceFormatLoaderBinary ); ResourceLoader::add_resource_format_loader(resource_loader_binary); + resource_format_importer = memnew( ResourceFormatImporter ); + ResourceLoader::add_resource_format_loader(resource_format_importer); + ClassDB::register_class<Object>(); ClassDB::register_class<Reference>(); ClassDB::register_class<WeakRef>(); - ClassDB::register_class<ResourceImportMetadata>(); ClassDB::register_class<Resource>(); ClassDB::register_class<FuncRef>(); ClassDB::register_virtual_class<StreamPeer>(); @@ -179,13 +182,11 @@ void register_core_singletons() { GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Geometry",_Geometry::get_singleton()) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceLoader",_ResourceLoader::get_singleton()) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ResourceSaver",_ResourceSaver::get_singleton()) ); - GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("PathRemap",PathRemap::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("OS",_OS::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Engine",_Engine::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("ClassDB",_classdb ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Marshalls",_Marshalls::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("TranslationServer",TranslationServer::get_singleton() ) ); - GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("TS",TranslationServer::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("Input",Input::get_singleton() ) ); GlobalConfig::get_singleton()->add_singleton( GlobalConfig::Singleton("InputMap",InputMap::get_singleton() ) ); @@ -209,6 +210,8 @@ void unregister_core_types() { memdelete(resource_saver_binary); if (resource_loader_binary) memdelete(resource_loader_binary); + if (resource_format_importer) + memdelete(resource_format_importer); memdelete( resource_format_po ); diff --git a/core/resource.cpp b/core/resource.cpp index 6e8d9a8b17..9b5bac5f32 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -35,119 +35,6 @@ #include <stdio.h> -void ResourceImportMetadata::set_editor(const String& p_editor) { - - editor=p_editor; -} - -String ResourceImportMetadata::get_editor() const{ - - return editor; -} - -void ResourceImportMetadata::add_source(const String& p_path,const String& p_md5) { - - Source s; - s.md5=p_md5; - s.path=p_path; - sources.push_back(s); -} - -String ResourceImportMetadata::get_source_path(int p_idx) const{ - ERR_FAIL_INDEX_V(p_idx,sources.size(),String()); - return sources[p_idx].path; -} -String ResourceImportMetadata::get_source_md5(int p_idx) const{ - ERR_FAIL_INDEX_V(p_idx,sources.size(),String()); - return sources[p_idx].md5; -} - -void ResourceImportMetadata::set_source_md5(int p_idx,const String& p_md5) { - - ERR_FAIL_INDEX(p_idx,sources.size()); - sources[p_idx].md5=p_md5; - -} - -void ResourceImportMetadata::remove_source(int p_idx){ - - ERR_FAIL_INDEX(p_idx,sources.size()); - sources.remove(p_idx); - -} - -int ResourceImportMetadata::get_source_count() const { - - return sources.size(); -} -void ResourceImportMetadata::set_option(const String& p_key, const Variant& p_value) { - - if (p_value.get_type()==Variant::NIL) { - options.erase(p_key); - return; - } - - ERR_FAIL_COND(p_value.get_type() == Variant::OBJECT); - ERR_FAIL_COND(p_value.get_type() == Variant::_RID); - - options[p_key]=p_value; - -} - -bool ResourceImportMetadata::has_option(const String& p_key) const { - - return options.has(p_key); -} - -Variant ResourceImportMetadata::get_option(const String& p_key) const { - - ERR_FAIL_COND_V(!options.has(p_key),Variant()); - - return options[p_key]; -} - -void ResourceImportMetadata::get_options(List<String> *r_options) const { - - for(Map<String,Variant>::Element *E=options.front();E;E=E->next()) { - - r_options->push_back(E->key()); - } - -} - -PoolStringArray ResourceImportMetadata::_get_options() const { - - PoolStringArray option_names; - option_names.resize(options.size()); - int i=0; - for(Map<String,Variant>::Element *E=options.front();E;E=E->next()) { - - option_names.set(i++,E->key()); - } - - return option_names; -} - -void ResourceImportMetadata::_bind_methods() { - - ClassDB::bind_method(_MD("set_editor","name"),&ResourceImportMetadata::set_editor); - ClassDB::bind_method(_MD("get_editor"),&ResourceImportMetadata::get_editor); - ClassDB::bind_method(_MD("add_source","path","md5"),&ResourceImportMetadata::add_source, ""); - ClassDB::bind_method(_MD("get_source_path","idx"),&ResourceImportMetadata::get_source_path); - ClassDB::bind_method(_MD("get_source_md5","idx"),&ResourceImportMetadata::get_source_md5); - ClassDB::bind_method(_MD("set_source_md5","idx", "md5"),&ResourceImportMetadata::set_source_md5); - ClassDB::bind_method(_MD("remove_source","idx"),&ResourceImportMetadata::remove_source); - ClassDB::bind_method(_MD("get_source_count"),&ResourceImportMetadata::get_source_count); - ClassDB::bind_method(_MD("set_option","key","value"),&ResourceImportMetadata::set_option); - ClassDB::bind_method(_MD("get_option","key"),&ResourceImportMetadata::get_option); - ClassDB::bind_method(_MD("get_options"),&ResourceImportMetadata::_get_options); -} - -ResourceImportMetadata::ResourceImportMetadata() { - - -} - void Resource::emit_changed() { @@ -381,21 +268,6 @@ void Resource::notify_change_to_owners() { } } -void Resource::set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata) { -#ifdef TOOLS_ENABLED - import_metadata=p_metadata; -#endif -} - -Ref<ResourceImportMetadata> Resource::get_import_metadata() const { - -#ifdef TOOLS_ENABLED - return import_metadata; -#else - return Ref<ResourceImportMetadata>(); -#endif - -} #ifdef TOOLS_ENABLED @@ -461,8 +333,6 @@ void Resource::_bind_methods() { ClassDB::bind_method(_MD("set_name","name"),&Resource::set_name); ClassDB::bind_method(_MD("get_name"),&Resource::get_name); ClassDB::bind_method(_MD("get_rid"),&Resource::get_rid); - ClassDB::bind_method(_MD("set_import_metadata","metadata"),&Resource::set_import_metadata); - ClassDB::bind_method(_MD("get_import_metadata"),&Resource::get_import_metadata); ClassDB::bind_method(_MD("set_local_to_scene","enable"),&Resource::set_local_to_scene); ClassDB::bind_method(_MD("is_local_to_scene"),&Resource::is_local_to_scene); ClassDB::bind_method(_MD("get_local_scene:Node"),&Resource::get_local_scene); @@ -483,6 +353,7 @@ Resource::Resource() { #ifdef TOOLS_ENABLED last_modified_time=0; + import_last_modified_time=0; #endif subindex=0; diff --git a/core/resource.h b/core/resource.h index 2b071c8e1c..b29077a3b8 100644 --- a/core/resource.h +++ b/core/resource.h @@ -46,47 +46,6 @@ virtual String get_base_extension() const { return m_ext; }\ private: -class ResourceImportMetadata : public Reference { - - GDCLASS( ResourceImportMetadata, Reference ); - - struct Source { - String path; - String md5; - }; - - Vector<Source> sources; - String editor; - - Map<String,Variant> options; - - PoolStringArray _get_options() const; - -protected: - - static void _bind_methods(); -public: - - void set_editor(const String& p_editor); - String get_editor() const; - - void add_source(const String& p_path,const String& p_md5=""); - String get_source_path(int p_idx) const; - String get_source_md5(int p_idx) const; - void set_source_md5(int p_idx,const String& p_md5); - void remove_source(int p_idx); - int get_source_count() const; - - void set_option(const String& p_key, const Variant& p_value); - Variant get_option(const String& p_key) const; - bool has_option(const String& p_key) const; - - void get_options(List<String> *r_options) const; - - - ResourceImportMetadata(); -}; - class Resource : public Reference { @@ -106,8 +65,9 @@ friend class ResourceCache; virtual bool _use_builtin_script() const { return true; } #ifdef TOOLS_ENABLED - Ref<ResourceImportMetadata> import_metadata; uint64_t last_modified_time; + uint64_t import_last_modified_time; + String import_path; #endif bool local_to_scene; @@ -147,10 +107,6 @@ public: Ref<Resource> duplicate(bool p_subresources=false); Ref<Resource> duplicate_for_local_scene(Node *p_scene,Map<Ref<Resource>,Ref<Resource> >& remap_cache); - - void set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata); - Ref<ResourceImportMetadata> get_import_metadata() const; - void set_local_to_scene(bool p_enable); bool is_local_to_scene() const; virtual void setup_local_to_scene(); @@ -164,6 +120,12 @@ public: virtual void set_last_modified_time(uint64_t p_time) { last_modified_time=p_time; } uint64_t get_last_modified_time() const { return last_modified_time; } + virtual void set_import_last_modified_time(uint64_t p_time) { import_last_modified_time=p_time; } + uint64_t get_import_last_modified_time() const { return import_last_modified_time; } + + void set_import_path(const String& p_path) { import_path=p_path; } + String get_import_path() const { return import_path; } + #endif virtual RID get_rid() const; // some resources may offer conversion to RID diff --git a/core/translation.cpp b/core/translation.cpp index d5ec61b8d6..8835cb133c 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -751,6 +751,20 @@ static const char* locale_names[]={ 0 }; +bool TranslationServer::is_locale_valid(const String& p_locale) { + + const char **ptr=locale_list; + + while (*ptr) { + + if (*ptr==p_locale) + return true; + ptr++; + } + + return false; + +} Vector<String> TranslationServer::get_all_locales() { diff --git a/core/translation.h b/core/translation.h index 85ab4a229d..feed352549 100644 --- a/core/translation.h +++ b/core/translation.h @@ -102,6 +102,7 @@ public: static Vector<String> get_all_locales(); static Vector<String> get_all_locale_names(); + static bool is_locale_valid(const String& p_locale); void set_tool_translation(const Ref<Translation>& p_translation); StringName tool_translate(const StringName& p_message) const; |