From fdaa2920eb21fff3320a17e9239e04dfadecdb00 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 18 Apr 2015 14:38:54 -0300 Subject: Updated copyright year in all headers --- core/path_remap.cpp | 322 ++++++++++++++++++++++++++-------------------------- 1 file changed, 161 insertions(+), 161 deletions(-) (limited to 'core/path_remap.cpp') diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 34675c4575..2ef39470a0 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -26,163 +26,163 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#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 { - - 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]); - 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]); - 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 - DVector remaps = Globals::get_singleton()->get("remap/all"); - - { - int rlen = remaps.size(); - - 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"); - { - int rlen = remaps.size(); - - ERR_FAIL_COND( rlen%2 ); - DVector::Read r = remaps.read(); - for(int i=0;i "+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 rk; - remaps.get_key_list(&rk); - 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;iis_stdout_verbose()) + print_line("remap failed: "+p_from); + return p_from; + } else { + + 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]); + 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]); + 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 + DVector remaps = Globals::get_singleton()->get("remap/all"); + + { + int rlen = remaps.size(); + + 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"); + { + int rlen = remaps.size(); + + ERR_FAIL_COND( rlen%2 ); + DVector::Read r = remaps.read(); + for(int i=0;i "+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 rk; + remaps.get_key_list(&rk); + 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