diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2017-03-05 16:44:50 +0100 |
commit | 5dbf1809c6e3e905b94b8764e99491e608122261 (patch) | |
tree | 5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /editor/import/resource_importer_csv_translation.cpp | |
parent | 45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff) | |
download | redot-engine-5dbf1809c6e3e905b94b8764e99491e608122261.tar.gz |
A Whole New World (clang-format edition)
I can show you the code
Pretty, with proper whitespace
Tell me, coder, now when did
You last write readable code?
I can open your eyes
Make you see your bad indent
Force you to respect the style
The core devs agreed upon
A whole new world
A new fantastic code format
A de facto standard
With some sugar
Enforced with clang-format
A whole new world
A dazzling style we all dreamed of
And when we read it through
It's crystal clear
That now we're in a whole new world of code
Diffstat (limited to 'editor/import/resource_importer_csv_translation.cpp')
-rw-r--r-- | editor/import/resource_importer_csv_translation.cpp | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index faf62d2839..3be89920fb 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -28,21 +28,21 @@ /*************************************************************************/ #include "resource_importer_csv_translation.h" +#include "compressed_translation.h" +#include "io/resource_saver.h" #include "os/file_access.h" #include "translation.h" -#include "io/resource_saver.h" -#include "compressed_translation.h" String ResourceImporterCSVTranslation::get_importer_name() const { return "csv_translation"; } -String ResourceImporterCSVTranslation::get_visible_name() const{ +String ResourceImporterCSVTranslation::get_visible_name() const { return "CSV Translation"; } -void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const{ +void ResourceImporterCSVTranslation::get_recognized_extensions(List<String> *p_extensions) const { p_extensions->push_back("csv"); } @@ -51,12 +51,12 @@ String ResourceImporterCSVTranslation::get_save_extension() const { return ""; //does not save a single resoure } -String ResourceImporterCSVTranslation::get_resource_type() const{ +String ResourceImporterCSVTranslation::get_resource_type() const { return "StreamCSVTranslation"; } -bool ResourceImporterCSVTranslation::get_option_visibility(const String& p_option,const Map<StringName,Variant>& p_options) const { +bool ResourceImporterCSVTranslation::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; } @@ -69,33 +69,27 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const { return ""; } +void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const { -void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options,int p_preset) const { - - - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"compress"),true)); - + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); } - - -Error ResourceImporterCSVTranslation::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) { - +Error ResourceImporterCSVTranslation::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) { bool compress = p_options["compress"]; - FileAccessRef f = FileAccess::open(p_source_file,FileAccess::READ); + FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); - ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); Vector<String> line = f->get_csv_line(); - if (line.size()<=1) { + if (line.size() <= 1) { return ERR_PARSE_ERROR; } Vector<String> locales; Vector<Ref<Translation> > translations; - for(int i=1;i<line.size();i++) { + for (int i = 1; i < line.size(); i++) { String locale = line[i]; if (!TranslationServer::is_locale_valid(locale)) { @@ -111,44 +105,38 @@ Error ResourceImporterCSVTranslation::import(const String& p_source_file, const line = f->get_csv_line(); - while(line.size()==locales.size()+1) { + while (line.size() == locales.size() + 1) { String key = line[0]; - if (key!="") { + if (key != "") { - for(int i=1;i<line.size();i++) { - translations[i-1]->add_message(key,line[i]); + for (int i = 1; i < line.size(); i++) { + translations[i - 1]->add_message(key, line[i]); } } line = f->get_csv_line(); } - - for(int i=0;i<translations.size();i++) { + for (int i = 0; i < translations.size(); i++) { Ref<Translation> xlt = translations[i]; if (compress) { - Ref<PHashTranslation> cxl = memnew( PHashTranslation ); - cxl->generate( xlt ); - xlt=cxl; + Ref<PHashTranslation> cxl = memnew(PHashTranslation); + cxl->generate(xlt); + xlt = cxl; } - String save_path = p_source_file.get_basename()+"."+translations[i]->get_locale()+".xl"; + String save_path = p_source_file.get_basename() + "." + translations[i]->get_locale() + ".xl"; - ResourceSaver::save(save_path,xlt); + ResourceSaver::save(save_path, xlt); if (r_gen_files) { r_gen_files->push_back(save_path); } } - - return OK; - } -ResourceImporterCSVTranslation::ResourceImporterCSVTranslation() -{ - +ResourceImporterCSVTranslation::ResourceImporterCSVTranslation() { } |