소스 검색

-Fix shortcuts for OSX code completion, fixes #1111
-Fixed how translation fallbacks works, fixes #1011

Juan Linietsky 10 년 전
부모
커밋
a8bcb96ad4
4개의 변경된 파일69개의 추가작업 그리고 17개의 파일을 삭제
  1. 59 15
      core/translation.cpp
  2. 4 0
      scene/gui/text_edit.cpp
  3. 2 2
      scene/resources/surface_tool.cpp
  4. 4 0
      tools/editor/plugins/script_editor_plugin.cpp

+ 59 - 15
core/translation.cpp

@@ -550,7 +550,7 @@ StringName TranslationServer::translate(const StringName& p_message) const {
 			continue; // locale not match
 
 		//near match
-		bool match = (l!=lptr);
+		bool match = (l!=locale);
 
 		if (near_match && !match)
 			continue; //only near-match once
@@ -570,6 +570,42 @@ StringName TranslationServer::translate(const StringName& p_message) const {
 
 	}
 
+	if (!res) {
+		//try again with fallback
+		if (fallback.length()>=2) {
+
+			const CharType *fptr=&fallback[0];
+			bool near_match=false;
+			for (const Set< Ref<Translation> >::Element *E=translations.front();E;E=E->next()) {
+
+				const Ref<Translation>& t = E->get();
+				String l = t->get_locale();
+				if (fptr[0]!=l[0] || fptr[1]!=l[1])
+					continue; // locale not match
+
+				//near match
+				bool match = (l!=fallback);
+
+				if (near_match && !match)
+					continue; //only near-match once
+
+				StringName r=t->get_message(p_message);
+
+				if (!r)
+					continue;
+
+				res=r;
+
+				if (match)
+					break;
+				else
+					near_match=true;
+
+			}
+		}
+	}
+
+
 	if (!res)
 		return p_message;
 
@@ -604,9 +640,27 @@ bool TranslationServer::_load_translations(const String& p_from) {
 
 void TranslationServer::setup() {
 
-
-	set_locale( GLOBAL_DEF("locale/default",OS::get_singleton()->get_locale()) );
-	fallback = GLOBAL_DEF("locale/fallback","");
+	String test = GLOBAL_DEF("locale/test","");
+	test=test.strip_edges();
+	if (test!="")
+		set_locale( test );
+	else
+		set_locale( OS::get_singleton()->get_locale() );
+	fallback = GLOBAL_DEF("locale/fallback","en");
+#ifdef TOOLS_ENABLED
+
+	{
+		String options="";
+		int idx=0;
+		while(locale_list[idx]) {
+			if (idx>0)
+				options+=", ";
+			options+=locale_list[idx];
+			idx++;
+		}
+		Globals::get_singleton()->set_custom_property_info("locale/fallback",PropertyInfo(Variant::STRING,"locale/fallback",PROPERTY_HINT_ENUM,options));
+	}
+#endif
 	//load translations
 
 }
@@ -629,6 +683,7 @@ void TranslationServer::load_translations() {
 
 	String locale = get_locale();
 	bool found = _load_translations("locale/translations"); //all
+
 	if (_load_translations("locale/translations_"+locale.substr(0,2)))
 		found=true;
 	if ( locale.substr(0,2) != locale ) {
@@ -637,17 +692,6 @@ void TranslationServer::load_translations() {
 	}
 
 
-	if (!found && fallback!="") { //none found anywhere, use fallback
-
-		_load_translations("locale/translations_"+fallback.substr(0,2));
-		if ( fallback.substr(0,2) != fallback ) {
-			_load_translations("locale/translations_"+fallback);
-		}
-
-		this->locale=fallback;
-
-	}
-
 }
 
 TranslationServer::TranslationServer() {

+ 4 - 0
scene/gui/text_edit.cpp

@@ -1957,7 +1957,11 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
 					update();
 				} break;
 				case KEY_SPACE: {
+#ifdef OSX_ENABLED
+					if (completion_enabled && k.mod.meta) { //cmd-space is spotlight shortcut in OSX
+#else
 					if (completion_enabled && k.mod.command) {
+#endif
 						
 						query_code_comple();
 						scancode_handled=true;

+ 2 - 2
scene/resources/surface_tool.cpp

@@ -650,8 +650,8 @@ void SurfaceTool::mikktGetTexCoord(const SMikkTSpaceContext * pContext, float fv
 	Vector<List<Vertex>::Element*> &varr = *((Vector<List<Vertex>::Element*>*)pContext->m_pUserData);
 	Vector2 v = varr[iFace*3+iVert]->get().uv;
 	fvTexcOut[0]=v.x;
-	//fvTexcOut[1]=v.y;
-	fvTexcOut[1]=1.0-v.y;
+	fvTexcOut[1]=v.y;
+	//fvTexcOut[1]=1.0-v.y;
 
 }
 void SurfaceTool::mikktSetTSpaceBasic(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert){

+ 4 - 0
tools/editor/plugins/script_editor_plugin.cpp

@@ -1602,7 +1602,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
 	edit_menu->get_popup()->add_item("Toggle Comment",EDIT_TOGGLE_COMMENT,KEY_MASK_CMD|KEY_K);
 	edit_menu->get_popup()->add_item("Clone Down",EDIT_CLONE_DOWN,KEY_MASK_CMD|KEY_B);
 	edit_menu->get_popup()->add_separator();
+#ifdef OSX_ENABLED
+	edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_META|KEY_SPACE);
+#else
 	edit_menu->get_popup()->add_item("Complete Symbol",EDIT_COMPLETE,KEY_MASK_CMD|KEY_SPACE);
+#endif
 	edit_menu->get_popup()->add_item("Auto Indent",EDIT_AUTO_INDENT,KEY_MASK_CMD|KEY_I);
 	edit_menu->get_popup()->connect("item_pressed", this,"_menu_option");