diff options
Diffstat (limited to 'editor')
28 files changed, 239 insertions, 565 deletions
diff --git a/editor/SCsub b/editor/SCsub index 4431166ee6..6e8679b770 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -56,7 +56,7 @@ if env['tools']: except OSError: pass - _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc")) + _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor")) docs = sorted(docs) env.Depends("#editor/doc_data_compressed.gen.h", docs) @@ -66,10 +66,15 @@ if env['tools']: path = env.Dir('.').abspath - # Translations + # Editor translations tlist = glob.glob(path + "/translations/*.po") - env.Depends('#editor/translations.gen.h', tlist) - env.CommandNoCache('#editor/translations.gen.h', tlist, run_in_subprocess(editor_builders.make_translations_header)) + env.Depends('#editor/editor_translations.gen.h', tlist) + env.CommandNoCache('#editor/editor_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_editor_translations_header)) + + # Documentation translations + tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po") + env.Depends('#editor/doc_translations.gen.h', tlist) + env.CommandNoCache('#editor/doc_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_doc_translations_header)) # Fonts flist = glob.glob(path + "/../thirdparty/fonts/*.ttf") @@ -80,8 +85,6 @@ if env['tools']: env.add_source_files(env.editor_sources, "*.cpp") - SConscript('collada/SCsub') - SConscript('doc/SCsub') SConscript('debugger/SCsub') SConscript('fileserver/SCsub') SConscript('icons/SCsub') diff --git a/editor/collada/SCsub b/editor/collada/SCsub deleted file mode 100644 index 2b1e889fb0..0000000000 --- a/editor/collada/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 23df649851..60a15984ee 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -992,7 +992,7 @@ void ConnectionsDock::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().signals.size(); i++) { if (F->get().signals[i].name == signal_name.operator String()) { - descr = F->get().signals[i].description.strip_edges(); + descr = DTR(F->get().signals[i].description.strip_edges()); break; } } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 3e09a9a760..b220e82f6c 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -248,7 +248,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p item->set_collapsed(collapse); } - const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description; + const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description); item->set_tooltip(0, description); item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, base_type)); @@ -556,7 +556,7 @@ void CreateDialog::_item_selected() { if (!EditorHelp::get_doc_data()->class_list.has(name)) return; - help_bit->set_text(EditorHelp::get_doc_data()->class_list[name].brief_description); + help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[name].brief_description)); get_ok()->set_disabled(false); } diff --git a/editor/doc/SCsub b/editor/doc/SCsub deleted file mode 100644 index 2b1e889fb0..0000000000 --- a/editor/doc/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp deleted file mode 100644 index b0a89ff4b8..0000000000 --- a/editor/doc/doc_dump.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/*************************************************************************/ -/* doc_dump.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "doc_dump.h" - -#include "core/os/file_access.h" -#include "core/version.h" -#include "scene/main/node.h" - -static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { - - String tab; - for (int i = 0; i < p_tablevel; i++) - tab += "\t"; - f->store_string(tab + p_string + "\n"); -} - -struct _ConstantSort { - - String name; - int value; - bool operator<(const _ConstantSort &p_c) const { - - String left_a = name.find("_") == -1 ? name : name.substr(0, name.find("_")); - String left_b = p_c.name.find("_") == -1 ? p_c.name : p_c.name.substr(0, p_c.name.find("_")); - if (left_a == left_b) - return value < p_c.value; - else - return left_a < left_b; - } -}; - -static String _escape_string(const String &p_str) { - - String ret = p_str; - ret = ret.replace("&", "&"); - ret = ret.replace("<", ">"); - ret = ret.replace(">", "<"); - ret = ret.replace("'", "'"); - ret = ret.replace("\"", """); - for (char i = 1; i < 32; i++) { - - char chr[2] = { i, 0 }; - ret = ret.replace(chr, "&#" + String::num(i) + ";"); - } - ret = ret.utf8(); - return ret; -} -void DocDump::dump(const String &p_file) { - - List<StringName> class_list; - ClassDB::get_class_list(&class_list); - - class_list.sort_custom<StringName::AlphCompare>(); - - FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE); - - _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); - _write_string(f, 0, String("<doc version=\"") + VERSION_BRANCH + "\" name=\"Engine Types\">"); - - while (class_list.size()) { - - String name = class_list.front()->get(); - - String header = "<class name=\"" + name + "\""; - String inherits = ClassDB::get_parent_class(name); - if (inherits != "") - header += " inherits=\"" + inherits + "\""; - _write_string(f, 0, header); - - _write_string(f, 1, "<brief_description>"); - _write_string(f, 1, "</brief_description>"); - - _write_string(f, 1, "<description>"); - _write_string(f, 1, "</description>"); - - _write_string(f, 1, "<methods>"); - - List<MethodInfo> method_list; - ClassDB::get_method_list(name, &method_list, true); - method_list.sort(); - - for (List<MethodInfo>::Element *E = method_list.front(); E; E = E->next()) { - if (E->get().name == "" || E->get().name[0] == '_') - continue; //hidden - - MethodBind *m = ClassDB::get_method(name, E->get().name); - - String qualifiers; - if (E->get().flags & METHOD_FLAG_CONST) - qualifiers += "qualifiers=\"const\""; - - _write_string(f, 2, "<method name=\"" + _escape_string(E->get().name) + "\" " + qualifiers + " >"); - - for (int i = -1; i < E->get().arguments.size(); i++) { - - PropertyInfo arginfo; - - if (i == -1) { - - arginfo = E->get().return_val; - String type_name = (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) ? arginfo.hint_string : Variant::get_type_name(arginfo.type); - - if (arginfo.type == Variant::NIL) - continue; - _write_string(f, 3, "<return type=\"" + type_name + "\">"); - } else { - - arginfo = E->get().arguments[i]; - - String type_name; - - if (arginfo.hint == PROPERTY_HINT_RESOURCE_TYPE) - type_name = arginfo.hint_string; - else if (arginfo.type == Variant::NIL) - type_name = "Variant"; - else - type_name = Variant::get_type_name(arginfo.type); - - if (m && m->has_default_argument(i)) { - Variant default_arg = m->get_default_argument(i); - String default_arg_text = String(_escape_string(m->get_default_argument(i))); - - switch (default_arg.get_type()) { - - case Variant::NIL: - default_arg_text = "NULL"; - break; - // atomic types - case Variant::BOOL: - if (bool(default_arg)) - default_arg_text = "true"; - else - default_arg_text = "false"; - break; - case Variant::INT: - case Variant::FLOAT: - //keep it - break; - case Variant::STRING: - case Variant::STRING_NAME: - default_arg_text = "@\"" + default_arg_text + "\""; - break; - case Variant::NODE_PATH: - default_arg_text = "\"" + default_arg_text + "\""; - break; - case Variant::TRANSFORM: - if (default_arg.operator Transform() == Transform()) { - default_arg_text = ""; - } - - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; - break; - - case Variant::VECTOR2: - case Variant::RECT2: - case Variant::VECTOR3: - case Variant::PLANE: - case Variant::QUAT: - case Variant::AABB: - case Variant::BASIS: - case Variant::COLOR: - case Variant::PACKED_BYTE_ARRAY: - case Variant::PACKED_INT32_ARRAY: - case Variant::PACKED_FLOAT32_ARRAY: - case Variant::PACKED_INT64_ARRAY: - case Variant::PACKED_FLOAT64_ARRAY: - case Variant::PACKED_STRING_ARRAY: - case Variant::PACKED_VECTOR3_ARRAY: - case Variant::PACKED_COLOR_ARRAY: - default_arg_text = Variant::get_type_name(default_arg.get_type()) + "(" + default_arg_text + ")"; - break; - case Variant::OBJECT: - case Variant::DICTIONARY: - case Variant::ARRAY: - case Variant::_RID: - - default: { - } - } - - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + _escape_string(arginfo.name) + "\" type=\"" + type_name + "\" default=\"" + _escape_string(default_arg_text) + "\">"); - } else - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + type_name + "\">"); - } - - String hint; - switch (arginfo.hint) { - case PROPERTY_HINT_DIR: hint = "A directory."; break; - case PROPERTY_HINT_RANGE: hint = "Range - min: " + arginfo.hint_string.get_slice(",", 0) + " max: " + arginfo.hint_string.get_slice(",", 1) + " step: " + arginfo.hint_string.get_slice(",", 2); break; - case PROPERTY_HINT_ENUM: - hint = "Values: "; - for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) { - if (j > 0) hint += ", "; - hint += arginfo.hint_string.get_slice(",", j) + "=" + itos(j); - } - break; - case PROPERTY_HINT_LENGTH: hint = "Length: " + arginfo.hint_string; break; - case PROPERTY_HINT_FLAGS: - hint = "Values: "; - for (int j = 0; j < arginfo.hint_string.get_slice_count(","); j++) { - if (j > 0) hint += ", "; - hint += arginfo.hint_string.get_slice(",", j) + "=" + itos((uint64_t)1 << j); - } - break; - case PROPERTY_HINT_FILE: hint = "A file:"; break; - default: { - } - //case PROPERTY_HINT_RESOURCE_TYPE: hint="Type: "+arginfo.hint_string; break; - }; - if (hint != "") - _write_string(f, 4, hint); - - _write_string(f, 3, (i == -1) ? "</return>" : "</argument>"); - } - - _write_string(f, 3, "<description>"); - _write_string(f, 3, "</description>"); - - _write_string(f, 2, "</method>"); - } - - _write_string(f, 1, "</methods>"); - - List<MethodInfo> signal_list; - ClassDB::get_signal_list(name, &signal_list, true); - - if (signal_list.size()) { - - _write_string(f, 1, "<signals>"); - for (List<MethodInfo>::Element *EV = signal_list.front(); EV; EV = EV->next()) { - - _write_string(f, 2, "<signal name=\"" + EV->get().name + "\">"); - for (int i = 0; i < EV->get().arguments.size(); i++) { - PropertyInfo arginfo = EV->get().arguments[i]; - _write_string(f, 3, "<argument index=\"" + itos(i) + "\" name=\"" + arginfo.name + "\" type=\"" + Variant::get_type_name(arginfo.type) + "\">"); - _write_string(f, 3, "</argument>"); - } - _write_string(f, 3, "<description>"); - _write_string(f, 3, "</description>"); - - _write_string(f, 2, "</signal>"); - } - - _write_string(f, 1, "</signals>"); - } - - _write_string(f, 1, "<constants>"); - - List<String> constant_list; - ClassDB::get_integer_constant_list(name, &constant_list, true); - - /* constants are sorted in a special way */ - - List<_ConstantSort> constant_sort; - - for (List<String>::Element *E = constant_list.front(); E; E = E->next()) { - _ConstantSort cs; - cs.name = E->get(); - cs.value = ClassDB::get_integer_constant(name, E->get()); - constant_sort.push_back(cs); - } - - constant_sort.sort(); - - for (List<_ConstantSort>::Element *E = constant_sort.front(); E; E = E->next()) { - - _write_string(f, 2, "<constant name=\"" + E->get().name + "\" value=\"" + itos(E->get().value) + "\">"); - _write_string(f, 2, "</constant>"); - } - - _write_string(f, 1, "</constants>"); - _write_string(f, 0, "</class>"); - - class_list.erase(name); - } - - _write_string(f, 0, "</doc>"); - f->close(); - memdelete(f); -} diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h deleted file mode 100644 index f8f1b6f805..0000000000 --- a/editor/doc/doc_dump.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* doc_dump.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef DOC_DUMP_H -#define DOC_DUMP_H - -#include "core/class_db.h" - -class DocDump { -public: - static void dump(const String &p_file); -}; - -#endif // DOC_DUMP_H diff --git a/editor/doc/doc_data.cpp b/editor/doc_data.cpp index 66134b4428..66134b4428 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc_data.cpp diff --git a/editor/doc/doc_data.h b/editor/doc_data.h index 073705f0b1..073705f0b1 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc_data.h diff --git a/editor/editor_builders.py b/editor/editor_builders.py index 910c53e2ff..e8c23acf9e 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -73,15 +73,15 @@ def make_fonts_header(target, source, env): g.close() -def make_translations_header(target, source, env): +def make_translations_header(target, source, env, category): dst = target[0] g = open_utf8(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") - g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") - g.write("#define _EDITOR_TRANSLATIONS_H\n") + g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper())) + g.write("#define _{}_TRANSLATIONS_H\n".format(category.upper())) import zlib import os.path @@ -96,7 +96,7 @@ def make_translations_header(target, source, env): buf = zlib.compress(buf) name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - g.write("static const unsigned char _translation_" + name + "_compressed[] = {\n") + g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name)) for j in range(len(buf)): g.write("\t" + byte_to_str(buf[j]) + ",\n") @@ -104,15 +104,15 @@ def make_translations_header(target, source, env): xl_names.append([name, len(buf), str(decomp_size)]) - g.write("struct EditorTranslationList {\n") + g.write("struct {}TranslationList {{\n".format(category.capitalize())) g.write("\tconst char* lang;\n") g.write("\tint comp_size;\n") g.write("\tint uncomp_size;\n") g.write("\tconst unsigned char* data;\n") g.write("};\n\n") - g.write("static EditorTranslationList _editor_translations[] = {\n") + g.write("static {}TranslationList _{}_translations[] = {{\n".format(category.capitalize(), category)) for x in xl_names: - g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ", _translation_" + x[0] + "_compressed},\n") + g.write("\t{{ \"{}\", {}, {}, _{}_translation_{}_compressed }},\n".format(x[0], str(x[1]), str(x[2]), category, x[0])) g.write("\t{NULL, 0, 0, NULL}\n") g.write("};\n") @@ -120,5 +120,14 @@ def make_translations_header(target, source, env): g.close() + +def make_editor_translations_header(target, source, env): + make_translations_header(target, source, env, "editor") + + +def make_doc_translations_header(target, source, env): + make_translations_header(target, source, env, "doc") + + if __name__ == '__main__': subprocess_main(globals()) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 4526a3a52c..874f984844 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -433,7 +433,7 @@ void EditorHelp::_update_doc() { class_desc->push_color(text_color); class_desc->push_font(doc_bold_font); class_desc->push_indent(1); - _add_text(cd.brief_description); + _add_text(DTR(cd.brief_description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); @@ -458,7 +458,7 @@ void EditorHelp::_update_doc() { class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); - _add_text(cd.description); + _add_text(DTR(cd.description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); @@ -480,7 +480,7 @@ void EditorHelp::_update_doc() { class_desc->add_newline(); for (int i = 0; i < cd.tutorials.size(); i++) { - const String link = cd.tutorials[i]; + const String link = DTR(cd.tutorials[i]); String linktxt = link; const int seppos = linktxt.find("//"); if (seppos != -1) { @@ -726,7 +726,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->add_text(" "); class_desc->push_color(comment_color); - _add_text(cd.theme_properties[i].description); + _add_text(DTR(cd.theme_properties[i].description)); class_desc->pop(); class_desc->pop(); } @@ -796,7 +796,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_color(comment_color); class_desc->push_indent(1); - _add_text(cd.signals[i].description); + _add_text(DTR(cd.signals[i].description)); class_desc->pop(); // indent class_desc->pop(); class_desc->pop(); // font @@ -893,7 +893,7 @@ void EditorHelp::_update_doc() { //class_desc->add_text(" "); class_desc->push_indent(1); class_desc->push_color(comment_color); - _add_text(enum_list[i].description); + _add_text(DTR(enum_list[i].description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); // indent @@ -959,7 +959,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); class_desc->push_color(comment_color); - _add_text(constants[i].description); + _add_text(DTR(constants[i].description)); class_desc->pop(); class_desc->pop(); class_desc->pop(); // indent @@ -1070,7 +1070,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); if (cd.properties[i].description.strip_edges() != String()) { - _add_text(cd.properties[i].description); + _add_text(DTR(cd.properties[i].description)); } else { class_desc->add_image(get_icon("Error", "EditorIcons")); class_desc->add_text(" "); @@ -1123,7 +1123,7 @@ void EditorHelp::_update_doc() { class_desc->push_font(doc_font); class_desc->push_indent(1); if (methods_filtered[i].description.strip_edges() != String()) { - _add_text(methods_filtered[i].description); + _add_text(DTR(methods_filtered[i].description)); } else { class_desc->add_image(get_icon("Error", "EditorIcons")); class_desc->add_text(" "); @@ -1449,7 +1449,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } void EditorHelp::_add_text(const String &p_bbcode) { - _add_text_to_rt(p_bbcode, class_desc); } diff --git a/editor/editor_help.h b/editor/editor_help.h index a690e10e7e..0d3ecf9bd0 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -32,7 +32,7 @@ #define EDITOR_HELP_H #include "editor/code_editor.h" -#include "editor/doc/doc_data.h" +#include "editor/doc_data.h" #include "editor/editor_plugin.h" #include "scene/gui/margin_container.h" #include "scene/gui/menu_button.h" diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index fe3ed23dee..be3ee397e8 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1551,7 +1551,7 @@ void EditorInspector::update_tree() { if (E) { descr = E->get().brief_description; } - class_descr_cache[type2] = descr; + class_descr_cache[type2] = DTR(descr); } category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); @@ -1703,7 +1703,7 @@ void EditorInspector::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().properties.size(); i++) { if (F->get().properties[i].name == propname.operator String()) { - descr = F->get().properties[i].description.strip_edges(); + descr = DTR(F->get().properties[i].description.strip_edges()); break; } } @@ -1713,7 +1713,7 @@ void EditorInspector::update_tree() { // Likely a theme property. for (int i = 0; i < F->get().theme_properties.size(); i++) { if (F->get().theme_properties[i].name == slices[1]) { - descr = F->get().theme_properties[i].description.strip_edges(); + descr = DTR(F->get().theme_properties[i].description.strip_edges()); break; } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 61480c3c20..f40762586e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6584,6 +6584,18 @@ EditorNode::EditorNode() { particles_mat_convert.instance(); resource_conversion_plugins.push_back(particles_mat_convert); + Ref<ProceduralSkyMaterialConversionPlugin> procedural_sky_mat_convert; + procedural_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(procedural_sky_mat_convert); + + Ref<PanoramaSkyMaterialConversionPlugin> panorama_sky_mat_convert; + panorama_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(panorama_sky_mat_convert); + + Ref<PhysicalSkyMaterialConversionPlugin> physical_sky_mat_convert; + physical_sky_mat_convert.instance(); + resource_conversion_plugins.push_back(physical_sky_mat_convert); + Ref<VisualShaderConversionPlugin> vshader_convert; vshader_convert.instance(); resource_conversion_plugins.push_back(vshader_convert); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3f54761c15..a32b736851 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -44,8 +44,9 @@ #include "core/os/os.h" #include "core/project_settings.h" #include "core/version.h" +#include "editor/doc_translations.gen.h" #include "editor/editor_node.h" -#include "editor/translations.gen.h" +#include "editor/editor_translations.gen.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "scene/main/viewport.h" @@ -982,14 +983,12 @@ void EditorSettings::setup_language() { String lang = get("interface/editor/editor_language"); if (lang == "en") - return; //none to do + return; // Default, nothing to do. + // Load editor translation for configured/detected locale. EditorTranslationList *etl = _editor_translations; - while (etl->data) { - if (etl->lang == lang) { - Vector<uint8_t> data; data.resize(etl->uncomp_size); Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); @@ -997,7 +996,7 @@ void EditorSettings::setup_language() { FileAccessMemory *fa = memnew(FileAccessMemory); fa->open_custom(data.ptr(), data.size()); - Ref<Translation> tr = TranslationLoaderPO::load_translation(fa, NULL, "translation_" + String(etl->lang)); + Ref<Translation> tr = TranslationLoaderPO::load_translation(fa); if (tr.is_valid()) { tr->set_locale(etl->lang); @@ -1008,6 +1007,29 @@ void EditorSettings::setup_language() { etl++; } + + // Load class reference translation. + DocTranslationList *dtl = _doc_translations; + while (dtl->data) { + if (dtl->lang == lang) { + Vector<uint8_t> data; + data.resize(dtl->uncomp_size); + Compression::decompress(data.ptrw(), dtl->uncomp_size, dtl->data, dtl->comp_size, Compression::MODE_DEFLATE); + + FileAccessMemory *fa = memnew(FileAccessMemory); + fa->open_custom(data.ptr(), data.size()); + + Ref<Translation> tr = TranslationLoaderPO::load_translation(fa); + + if (tr.is_valid()) { + tr->set_locale(dtl->lang); + TranslationServer::get_singleton()->set_doc_translation(tr); + break; + } + } + + dtl++; + } } void EditorSettings::setup_network() { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 39d4b70a6a..1263eb166b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -187,8 +187,7 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = exceptions.insert("EditorHandle"); exceptions.insert("Editor3DHandle"); exceptions.insert("Godot"); - exceptions.insert("PanoramaSky"); - exceptions.insert("ProceduralSky"); + exceptions.insert("Sky"); exceptions.insert("EditorControlAnchor"); exceptions.insert("DefaultProjectIcon"); exceptions.insert("GuiCloseCustomizable"); diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp deleted file mode 100644 index 52ab80cc48..0000000000 --- a/editor/file_type_cache.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************/ -/* file_type_cache.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "file_type_cache.h" - -#include "core/os/file_access.h" -#include "core/project_settings.h" - -FileTypeCache *FileTypeCache::singleton = NULL; - -bool FileTypeCache::has_file(const String &p_path) const { - - GLOBAL_LOCK_FUNCTION - return file_type_map.has(p_path); -} - -String FileTypeCache::get_file_type(const String &p_path) const { - - GLOBAL_LOCK_FUNCTION - ERR_FAIL_COND_V(!file_type_map.has(p_path), ""); - return file_type_map[p_path]; -} -void FileTypeCache::set_file_type(const String &p_path, const String &p_type) { - - GLOBAL_LOCK_FUNCTION - file_type_map[p_path] = p_type; -} - -void FileTypeCache::load() { - - GLOBAL_LOCK_FUNCTION - String project = ProjectSettings::get_singleton()->get_resource_path(); - FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ); - - if (!f) { - - WARN_PRINT("Can't open file_type_cache.cch."); - return; - } - - file_type_map.clear(); - while (!f->eof_reached()) { - - String path = f->get_line(); - if (f->eof_reached()) - break; - String type = f->get_line(); - set_file_type(path, type); - } - - memdelete(f); -} - -void FileTypeCache::save() { - - GLOBAL_LOCK_FUNCTION - String project = ProjectSettings::get_singleton()->get_resource_path(); - FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE); - - ERR_FAIL_COND_MSG(!f, "Can't open file_type_cache.cch for writing, not saving file type cache!"); - - const String *K = NULL; - - while ((K = file_type_map.next(K))) { - - f->store_line(*K); - f->store_line(file_type_map[*K]); - } - - memdelete(f); -} - -FileTypeCache::FileTypeCache() { - - ERR_FAIL_COND_MSG(singleton, "FileTypeCache singleton already exist."); - singleton = this; -} diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h deleted file mode 100644 index 216effea00..0000000000 --- a/editor/file_type_cache.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************/ -/* file_type_cache.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef FILE_TYPE_CACHE_H -#define FILE_TYPE_CACHE_H - -#include "core/object.h" - -class FileTypeCache : Object { - - GDCLASS(FileTypeCache, Object); - - HashMap<String, String> file_type_map; - - static FileTypeCache *singleton; - -public: - static FileTypeCache *get_singleton() { return singleton; } - - bool has_file(const String &p_path) const; - String get_file_type(const String &p_path) const; - void set_file_type(const String &p_path, const String &p_type); - - void load(); - void save(); - - FileTypeCache(); -}; - -#endif // FILE_TYPE_CACHE_H diff --git a/editor/icons/Sky.svg b/editor/icons/Sky.svg new file mode 100644 index 0000000000..356a966fe9 --- /dev/null +++ b/editor/icons/Sky.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="8" x2="8" y1="1040.4" y2="1050.4"><stop offset="0" stop-color="#1ec3ff"/><stop offset="1" stop-color="#b2e1ff"/></linearGradient><g transform="translate(0 -1037.4)"><path d="m8 1040.4a7 7 0 0 0 -7 7 7 7 0 0 0 .68555 3h12.631a7 7 0 0 0 .68359-3 7 7 0 0 0 -7-7z" fill="url(#a)"/><path d="m10 7c-.554 0-1 .446-1 1h-1c-.554 0-1 .446-1 1s.446 1 1 1h2c.554 0 1-.446 1-1h1c.554 0 1-.446 1-1s-.446-1-1-1zm-7 3c-.554 0-1 .446-1 1s.446 1 1 1h1c.554 0 1-.446 1-1s-.446-1-1-1z" fill="#fff" transform="translate(0 1037.4)"/></g></svg>
\ No newline at end of file diff --git a/editor/collada/collada.cpp b/editor/import/collada.cpp index 8ef9d17083..8ef9d17083 100644 --- a/editor/collada/collada.cpp +++ b/editor/import/collada.cpp diff --git a/editor/collada/collada.h b/editor/import/collada.h index 4707d7d779..4707d7d779 100644 --- a/editor/collada/collada.h +++ b/editor/import/collada.h diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 3cc6e7a50c..f7da8c27f9 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -31,8 +31,8 @@ #include "editor_import_collada.h" #include "core/os/os.h" -#include "editor/collada/collada.h" #include "editor/editor_node.h" +#include "editor/import/collada.h" #include "scene/3d/camera.h" #include "scene/3d/light.h" #include "scene/3d/mesh_instance.h" diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index b39465f618..d388296927 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "editor/editor_scale.h" #include "scene/gui/viewport_container.h" #include "scene/resources/particles_material.h" +#include "scene/resources/sky_material.h" void MaterialEditor::_notification(int p_what) { @@ -221,8 +222,8 @@ void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() { env.instance(); - Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true)); - env->set_sky(proc_sky); + Ref<Sky> sky = memnew(Sky()); + env->set_sky(sky); env->set_background(Environment::BG_COLOR); env->set_ambient_source(Environment::AMBIENT_SOURCE_SKY); env->set_reflection_source(Environment::REFLECTION_SOURCE_SKY); @@ -356,3 +357,117 @@ Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p smat->set_render_priority(mat->get_render_priority()); return smat; } + +String ProceduralSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool ProceduralSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> ProceduralSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<ProceduralSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PanoramaSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PanoramaSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PanoramaSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PanoramaSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} + +String PhysicalSkyMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool PhysicalSkyMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> PhysicalSkyMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { + + Ref<PhysicalSkyMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 95a6c4bf8f..84e69425d0 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -127,4 +127,31 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; }; +class ProceduralSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(ProceduralSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PanoramaSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PanoramaSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + +class PhysicalSkyMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(PhysicalSkyMaterialConversionPlugin, EditorResourceConversionPlugin); + +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const; +}; + #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index c305c181cc..2f1274a99a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2419,9 +2419,10 @@ void SpatialEditorViewport::_notification(int p_what) { Transform t = sp->get_global_gizmo_transform(); exist = true; - if (se->last_xform == t) + if (se->last_xform == t && !se->last_xform_dirty) continue; changed = true; + se->last_xform_dirty = false; se->last_xform = t; VisualInstance *vi = Object::cast_to<VisualInstance>(sp); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 9f78efacaf..b67459b9d0 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -482,10 +482,14 @@ public: Transform original; // original location when moving Transform original_local; Transform last_xform; // last transform + bool last_xform_dirty; Spatial *sp; RID sbox_instance; - SpatialEditorSelectedItem() { sp = NULL; } + SpatialEditorSelectedItem() { + sp = NULL; + last_xform_dirty = true; + } ~SpatialEditorSelectedItem(); }; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 94f9bf2767..4e157e927e 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -505,7 +505,7 @@ private: set_message(TTR("Couldn't create project.godot in project path."), MESSAGE_ERROR); } else { f->store_line("[gd_resource type=\"Environment\" load_steps=2 format=2]"); - f->store_line("[sub_resource type=\"ProceduralSky\" id=1]"); + f->store_line("[sub_resource type=\"Sky\" id=1]"); f->store_line("[resource]"); f->store_line("background_mode = 2"); f->store_line("background_sky = SubResource( 1 )"); diff --git a/editor/translations/extract.py b/editor/translations/extract.py index e7ebda32df..10859c7c90 100755 --- a/editor/translations/extract.py +++ b/editor/translations/extract.py @@ -34,7 +34,7 @@ matches.sort() unique_str = [] unique_loc = {} main_po = """ -# LANGUAGE translation of the Godot Engine editor +# LANGUAGE translation of the Godot Engine editor. # Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. # Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). # This file is distributed under the same license as the Godot source code. @@ -45,6 +45,8 @@ main_po = """ msgid "" msgstr "" "Project-Id-Version: Godot Engine editor\\n" +"Report-Msgid-Bugs-To: https://github.com/godotengine/godot\\n" +"MIME-Version: 1.0\\n" "Content-Type: text/plain; charset=UTF-8\\n" "Content-Transfer-Encoding: 8-bit\\n" """ |