From f8db8a3faa30b71dca33ced38be16d3f93f43e8a Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Sun, 19 Mar 2017 00:36:26 +0100 Subject: Bring that Whole New World to the Old Continent too Applies the clang-format style to the 2.1 branch as done for master in 5dbf1809c6e3e905b94b8764e99491e608122261. --- core/path_remap.cpp | 104 +++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 55 deletions(-) (limited to 'core/path_remap.cpp') diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 5b0ab514d..6e8e09184 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -30,87 +30,85 @@ #include "globals.h" #include "os/os.h" #include "translation.h" -PathRemap* PathRemap::singleton=NULL; +PathRemap *PathRemap::singleton = NULL; -PathRemap* PathRemap::get_singleton() { +PathRemap *PathRemap::get_singleton() { return singleton; } -void PathRemap::add_remap(const String& p_from, const String& p_to,const String& p_locale) { +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(); + remap[p_from] = RemapData(); } - if (p_locale==String()) - remap[p_from].always=p_to; + if (p_locale == String()) + remap[p_from].always = p_to; else - remap[p_from].locale[p_locale]=p_to; + remap[p_from].locale[p_locale] = p_to; } +String PathRemap::get_remap(const String &p_from) const { -String PathRemap::get_remap(const String& p_from) const { - - const RemapData *ptr=remap.getptr(p_from); + const RemapData *ptr = remap.getptr(p_from); if (!ptr) { if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap failed: "+p_from); + print_line("remap failed: " + p_from); return p_from; } else { - const RemapData *ptr2=NULL; + 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]); + print_line("remap found: " + p_from + " -> " + ptr->locale[locale]); - ptr2=remap.getptr(ptr->locale[locale]); + ptr2 = remap.getptr(ptr->locale[locale]); - if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too + 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 (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]); + print_line("remap found: " + p_from + " -> " + ptr->locale[locale]); - ptr2=remap.getptr(ptr->locale[locale]); + ptr2 = remap.getptr(ptr->locale[locale]); - if (ptr2 && ptr2->always!=String()) //may have atlas or export remap too + 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 (ptr->always != String()) { if (OS::get_singleton()->is_stdout_verbose()) { - print_line("remap found: "+p_from+" -> "+ptr->always); + print_line("remap found: " + p_from + " -> " + ptr->always); } return ptr->always; } if (OS::get_singleton()->is_stdout_verbose()) - print_line("remap failed: "+p_from); + print_line("remap failed: " + p_from); return p_from; } } -bool PathRemap::has_remap(const String& p_from) const{ +bool PathRemap::has_remap(const String &p_from) const { return remap.has(p_from); } -void PathRemap::erase_remap(const String& p_from){ +void PathRemap::erase_remap(const String &p_from) { ERR_FAIL_COND(!remap.has(p_from)); remap.erase(p_from); @@ -129,35 +127,33 @@ void PathRemap::load_remaps() { { int rlen = remaps.size(); - ERR_FAIL_COND( rlen%2 ); + ERR_FAIL_COND(rlen % 2); DVector::Read r = remaps.read(); - for(int i=0;iget("remap/"+OS::get_singleton()->get_name()); -// remaps = Globals::get_singleton()->get("remap/PSP"); + 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 ); + ERR_FAIL_COND(rlen % 2); DVector::Read r = remaps.read(); - for(int i=0;i "+to); - add_remap(from,to); + 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")) { @@ -165,39 +161,37 @@ void PathRemap::load_remaps() { Dictionary remaps = Globals::get_singleton()->get("locale/translation_remaps"); List rk; remaps.get_key_list(&rk); - for(List::Element *E=rk.front();E;E=E->next()) { + for (List::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