diff options
Diffstat (limited to 'editor')
37 files changed, 1193 insertions, 462 deletions
diff --git a/editor/SCsub b/editor/SCsub index 839d8e74c1..315865ad32 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -41,7 +41,7 @@ def make_doc_header(target, source, env): src = s.srcnode().abspath f = open_utf8(src, "r") content = f.read() - buf+=content + buf+=content buf = encode_utf8(docbegin + buf + docend) decomp_size = len(buf) @@ -385,13 +385,13 @@ def make_license_header(target, source, env): def _make_doc_data_class_path(to_path): - g = open_utf8(os.path.join(to_path,"doc_data_class_path.gen.h"), "wb") + g = open_utf8(os.path.join(to_path,"doc_data_class_path.gen.h"), "w") g.write("static const int _doc_data_class_path_count="+str(len(env.doc_class_path))+";\n") g.write("struct _DocDataClassPath { const char* name; const char* path; };\n") g.write("static const _DocDataClassPath _doc_data_class_paths["+str(len(env.doc_class_path)+1)+"]={\n"); for c in env.doc_class_path: - g.write("{\""+c+"\",\""+env.doc_class_path[c]+"\"},\n") + g.write("{\""+c+"\",\""+env.doc_class_path[c]+"\"},\n") g.write("{NULL,NULL}\n") g.write("};\n") @@ -414,7 +414,7 @@ if (env["tools"] == "yes"): docs=[] print("cdir is: "+env.Dir('#').abspath) for f in os.listdir(os.path.join(env.Dir('#').abspath,"doc/classes")): - docs.append("#doc/classes/"+f) + docs.append("#doc/classes/"+f) _make_doc_data_class_path(os.path.join(env.Dir('#').abspath,"editor/doc")) diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 47360ff7fb..40493c1de3 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -2898,10 +2898,6 @@ void AnimationKeyEditor::_notification(int p_what) { zoomicon->set_custom_minimum_size(Size2(24 * EDSCALE, 0)); zoomicon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); - menu_add_track->get_popup()->add_icon_item(get_icon("KeyValue", "EditorIcons"), "Add Normal Track", ADD_TRACK_MENU_ADD_VALUE_TRACK); - menu_add_track->get_popup()->add_icon_item(get_icon("KeyXform", "EditorIcons"), "Add Transform Track", ADD_TRACK_MENU_ADD_TRANSFORM_TRACK); - menu_add_track->get_popup()->add_icon_item(get_icon("KeyCall", "EditorIcons"), "Add Call Func Track", ADD_TRACK_MENU_ADD_CALL_TRACK); - menu_track->set_icon(get_icon("Tools", "EditorIcons")); menu_track->get_popup()->add_item(TTR("Scale Selection"), TRACK_MENU_SCALE); menu_track->get_popup()->add_item(TTR("Scale From Cursor"), TRACK_MENU_SCALE_PIVOT); @@ -3817,6 +3813,9 @@ AnimationKeyEditor::AnimationKeyEditor() { hb->add_child(menu_add_track); menu_add_track->get_popup()->connect("id_pressed", this, "_menu_add_track"); menu_add_track->set_tooltip(TTR("Add new tracks.")); + menu_add_track->get_popup()->add_icon_item(get_icon("KeyValue", "EditorIcons"), "Add Normal Track", ADD_TRACK_MENU_ADD_VALUE_TRACK); + menu_add_track->get_popup()->add_icon_item(get_icon("KeyXform", "EditorIcons"), "Add Transform Track", ADD_TRACK_MENU_ADD_TRANSFORM_TRACK); + menu_add_track->get_popup()->add_icon_item(get_icon("KeyCall", "EditorIcons"), "Add Call Func Track", ADD_TRACK_MENU_ADD_CALL_TRACK); move_up_button = memnew(ToolButton); hb->add_child(move_up_button); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 344cb87aa6..9797a2e9f5 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -54,12 +54,7 @@ void CreateDialog::popup_create(bool p_dontclear) { TreeItem *ti = recent->create_item(root); ti->set_text(0, l); - if (has_icon(l, "EditorIcons")) { - - ti->set_icon(0, get_icon(l, "EditorIcons")); - } else { - ti->set_icon(0, get_icon("Object", "EditorIcons")); - } + ti->set_icon(0, _get_editor_icon(l)); } } @@ -122,6 +117,29 @@ void CreateDialog::_sbox_input(const Ref<InputEvent> &p_ie) { } } +Ref<Texture> CreateDialog::_get_editor_icon(const String &p_type) const { + + if (has_icon(p_type, "EditorIcons")) { + return get_icon(p_type, "EditorIcons"); + } + + const Map<String, Vector<EditorData::CustomType> > &p_map = EditorNode::get_editor_data().get_custom_types(); + for (const Map<String, Vector<EditorData::CustomType> >::Element *E = p_map.front(); E; E = E->next()) { + const Vector<EditorData::CustomType> &ct = E->value(); + for (int i = 0; i < ct.size(); ++i) { + if (ct[i].name == p_type) { + if (ct[i].icon.is_valid()) { + return ct[i].icon; + } else { + return get_icon("Object", "EditorIcons"); + } + } + } + } + + return get_icon("Object", "EditorIcons"); +} + void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) { if (p_types.has(p_type)) @@ -457,13 +475,7 @@ void CreateDialog::_update_favorite_list() { TreeItem *ti = favorites->create_item(root); String l = favorite_list[i]; ti->set_text(0, l); - - if (has_icon(l, "EditorIcons")) { - - ti->set_icon(0, get_icon(l, "EditorIcons")); - } else { - ti->set_icon(0, get_icon("Object", "EditorIcons")); - } + ti->set_icon(0, _get_editor_icon(l)); } } diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 31f106ea22..a523539ba0 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -74,6 +74,8 @@ class CreateDialog : public ConfirmationDialog { void _confirmed(); void _text_changed(const String &p_newtext); + Ref<Texture> _get_editor_icon(const String &p_type) const; + void add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select); Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 272a5af59b..d35dc53ae1 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -170,6 +170,8 @@ static void return_doc_from_retinfo(DocData::MethodDoc &p_method, const Property if (p_retinfo.type == Variant::INT && p_retinfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { p_method.return_enum = p_retinfo.class_name; + if (p_method.return_enum.begins_with("_")) //proxy class + p_method.return_enum = p_method.return_enum.substr(1, p_method.return_enum.length()); p_method.return_type = "int"; } else if (p_retinfo.class_name != StringName()) { p_method.return_type = p_retinfo.class_name; @@ -190,6 +192,8 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr if (p_arginfo.type == Variant::INT && p_arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { p_argument.enumeration = p_arginfo.class_name; + if (p_argument.enumeration.begins_with("_")) //proxy class + p_argument.enumeration = p_argument.enumeration.substr(1, p_argument.enumeration.length()); p_argument.type = "int"; } else if (p_arginfo.class_name != StringName()) { p_argument.type = p_arginfo.class_name; diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index cfb3abfd1d..658c12d4d0 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -64,7 +64,7 @@ void EditorDirDialog::_update_dir(TreeItem *p_item, EditorFileSystemDirectory *p } } -void EditorDirDialog::reload(const String &p_with_path) { +void EditorDirDialog::reload(const String &p_path) { if (!is_visible_in_tree()) { must_reload = true; @@ -73,7 +73,7 @@ void EditorDirDialog::reload(const String &p_with_path) { tree->clear(); TreeItem *root = tree->create_item(); - _update_dir(root, EditorFileSystem::get_singleton()->get_filesystem(), p_with_path); + _update_dir(root, EditorFileSystem::get_singleton()->get_filesystem(), p_path); _item_collapsed(root); must_reload = false; } diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 8623b9acdb..ad9bc4a662 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -476,19 +476,77 @@ void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String & memdelete(da); } -Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata) { +void EditorExportPlugin::add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap) { + + ExtraFile ef; + ef.data = p_file; + ef.path = p_path; + ef.remap = p_remap; + extra_files.push_back(ef); +} + +void EditorExportPlugin::add_shared_object(const String &p_path) { + + shared_objects.push_back(p_path); +} + +void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features) { + + if (get_script_instance()) { + get_script_instance()->call("_export_file", p_path, p_type, p_features); + } +} + +void EditorExportPlugin::_export_begin_script(const PoolVector<String> &p_features) { + + if (get_script_instance()) { + get_script_instance()->call("_export_begin", p_features); + } +} + +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { +} + +void EditorExportPlugin::_export_begin(const Set<String> &p_features) { +} + +void EditorExportPlugin::skip() { + + skipped = true; +} + +void EditorExportPlugin::_bind_methods() { + + ClassDB::bind_method(D_METHOD("add_shared_object", "path"), &EditorExportPlugin::add_shared_object); + ClassDB::bind_method(D_METHOD("add_file", "path", "file", "remap"), &EditorExportPlugin::add_file); + ClassDB::bind_method(D_METHOD("skip"), &EditorExportPlugin::skip); + + BIND_VMETHOD(MethodInfo("_export_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::POOL_STRING_ARRAY, "features"))); + BIND_VMETHOD(MethodInfo("_export_begin", PropertyInfo(Variant::POOL_STRING_ARRAY, "features"))); +} + +EditorExportPlugin::EditorExportPlugin() { + skipped = false; +} + +Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) { Ref<EditorExportPlatform> platform = p_preset->get_platform(); List<String> feature_list; platform->get_preset_features(p_preset, &feature_list); //figure out features Set<String> features; + PoolVector<String> features_pv; for (List<String>::Element *E = feature_list.front(); E; E = E->next()) { features.insert(E->get()); + features_pv.push_back(E->get()); } + Vector<Ref<EditorExportPlugin> > export_plugins = EditorExport::get_singleton()->get_export_plugins(); + //figure out paths of files that will be exported Set<String> paths; + Vector<String> path_remaps; if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) { //find stuff @@ -508,6 +566,25 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & _edit_filter_list(paths, p_preset->get_include_filter(), false); _edit_filter_list(paths, p_preset->get_exclude_filter(), true); + //initial export plugin callback + for (int i = 0; i < export_plugins.size(); i++) { + if (export_plugins[i]->get_script_instance()) { //script based + export_plugins[i]->_export_begin_script(features_pv); + } else { + export_plugins[i]->_export_begin(features); + } + if (p_so_func) { + for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { + p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + } + } + for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { + p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, 0, paths.size()); + } + + export_plugins[i]->_clear(); + } + //store everything in the export medium int idx = 0; int total = paths.size(); @@ -515,6 +592,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & for (Set<String>::Element *E = paths.front(); E; E = E->next()) { String path = E->get(); + String type = ResourceLoader::get_resource_type(path); if (FileAccess::exists(path + ".import")) { //file is imported, replace by what it imports @@ -551,9 +629,42 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & p_func(p_udata, path + ".import", array, idx, total); } else { + + bool do_export = true; + for (int i = 0; i < export_plugins.size(); i++) { + if (export_plugins[i]->get_script_instance()) { //script based + export_plugins[i]->_export_file_script(path, type, features_pv); + } else { + export_plugins[i]->_export_file(path, type, features); + } + if (p_so_func) { + for (int j = 0; j < export_plugins[i]->shared_objects.size(); j++) { + p_so_func(p_udata, export_plugins[i]->shared_objects[j]); + } + } + + for (int j = 0; j < export_plugins[i]->extra_files.size(); j++) { + p_func(p_udata, export_plugins[i]->extra_files[j].path, export_plugins[i]->extra_files[j].data, idx, total); + if (export_plugins[i]->extra_files[j].remap) { + do_export = false; //if remap, do not + path_remaps.push_back(path); + path_remaps.push_back(export_plugins[i]->extra_files[j].path); + } + } + + if (export_plugins[i]->skipped) { + do_export = false; + } + export_plugins[i]->_clear(); + + if (!do_export) + break; //apologies, not exporting + } //just store it as it comes - Vector<uint8_t> array = FileAccess::get_file_as_array(path); - p_func(p_udata, path, array, idx, total); + if (do_export) { + Vector<uint8_t> array = FileAccess::get_file_as_array(path); + p_func(p_udata, path, array, idx, total); + } } idx++; @@ -575,9 +686,14 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } } + ProjectSettings::CustomMap custom_map; + if (path_remaps.size()) { + custom_map["path_remap/remapped_paths"] = path_remaps; + } + String config_file = "project.binary"; String engine_cfb = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp" + config_file; - ProjectSettings::get_singleton()->save_custom(engine_cfb, ProjectSettings::CustomMap(), custom_list); + ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); p_func(p_udata, "res://" + config_file, data, idx, total); @@ -867,6 +983,23 @@ void EditorExport::remove_export_preset(int p_idx) { export_presets.remove(p_idx); } +void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { + + if (export_plugins.find(p_plugin) == 1) { + export_plugins.push_back(p_plugin); + } +} + +void EditorExport::remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { + + export_plugins.erase(p_plugin); +} + +Vector<Ref<EditorExportPlugin> > EditorExport::get_export_plugins() { + + return export_plugins; +} + void EditorExport::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -1113,9 +1246,13 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr } DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - da->copy(template_path, p_path); + Error err = da->copy(template_path, p_path, get_chmod_flags()); memdelete(da); + if (err != OK) { + return err; + } + String pck_path = p_path.get_basename() + ".pck"; return save_pack(p_preset, pck_path); @@ -1169,5 +1306,17 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { } } +int EditorExportPlatformPC::get_chmod_flags() const { + + return chmod_flags; +} + +void EditorExportPlatformPC::set_chmod_flags(int p_flags) { + + chmod_flags = p_flags; +} + EditorExportPlatformPC::EditorExportPlatformPC() { + + chmod_flags = -1; } diff --git a/editor/editor_export.h b/editor/editor_export.h index 3b99c68c85..50379b9683 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -124,6 +124,7 @@ class EditorExportPlatform : public Reference { public: typedef Error (*EditorExportSaveFunction)(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total); + typedef Error (*EditorExportSaveSharedObject)(void *p_userdata, const String &p_path); private: struct SavedData { @@ -189,7 +190,7 @@ public: virtual String get_name() const = 0; virtual Ref<Texture> get_logo() const = 0; - Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata); + Error export_project_files(const Ref<EditorExportPreset> &p_preset, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func = NULL); Error save_pack(const Ref<EditorExportPreset> &p_preset, const String &p_path); Error save_zip(const Ref<EditorExportPreset> &p_preset, const String &p_path); @@ -219,11 +220,49 @@ public: EditorExportPlatform(); }; +class EditorExportPlugin : public Reference { + GDCLASS(EditorExportPlugin, Reference) + + friend class EditorExportPlatform; + + Vector<String> shared_objects; + struct ExtraFile { + String path; + Vector<uint8_t> data; + bool remap; + }; + Vector<ExtraFile> extra_files; + bool skipped; + + _FORCE_INLINE_ void _clear() { + shared_objects.clear(); + extra_files.clear(); + skipped = false; + } + + void _export_file_script(const String &p_path, const String &p_type, const PoolVector<String> &p_features); + void _export_begin_script(const PoolVector<String> &p_features); + +protected: + void add_file(const String &p_path, const Vector<uint8_t> &p_file, bool p_remap); + void add_shared_object(const String &p_path); + void skip(); + + virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); + virtual void _export_begin(const Set<String> &p_features); + + static void _bind_methods(); + +public: + EditorExportPlugin(); +}; + class EditorExport : public Node { GDCLASS(EditorExport, Node); Vector<Ref<EditorExportPlatform> > export_platforms; Vector<Ref<EditorExportPreset> > export_presets; + Vector<Ref<EditorExportPlugin> > export_plugins; Timer *save_timer; bool block_save; @@ -251,6 +290,10 @@ public: Ref<EditorExportPreset> get_export_preset(int p_idx); void remove_export_preset(int p_idx); + void add_export_plugin(const Ref<EditorExportPlugin> &p_plugin); + void remove_export_plugin(const Ref<EditorExportPlugin> &p_plugin); + Vector<Ref<EditorExportPlugin> > get_export_plugins(); + void load_config(); bool poll_export_platforms(); @@ -276,6 +319,7 @@ class EditorExportPlatformPC : public EditorExportPlatform { Set<String> extra_features; bool use64; + int chmod_flags; public: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features); @@ -304,6 +348,9 @@ public: void add_platform_feature(const String &p_feature); virtual void get_platform_features(List<String> *r_features); + int get_chmod_flags() const; + void set_chmod_flags(int p_flags); + EditorExportPlatformPC(); }; diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 0d6c552d1d..288b923e87 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -107,8 +107,6 @@ void EditorFileDialog::_notification(int p_what) { fav_down->set_icon(get_icon("MoveDown", "EditorIcons")); fav_rm->set_icon(get_icon("RemoveSmall", "EditorIcons")); - Theme::get_default()->clear_icon("ResizedFile", "EditorIcons"); - Theme::get_default()->clear_icon("ResizedFolder", "EditorIcons"); update_file_list(); } } @@ -1198,6 +1196,9 @@ void EditorFileDialog::_bind_methods() { BIND_ENUM_CONSTANT(ACCESS_RESOURCES); BIND_ENUM_CONSTANT(ACCESS_USERDATA); BIND_ENUM_CONSTANT(ACCESS_FILESYSTEM); + + BIND_ENUM_CONSTANT(DISPLAY_THUMBNAILS); + BIND_ENUM_CONSTANT(DISPLAY_LIST); } void EditorFileDialog::set_show_hidden_files(bool p_show) { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 3ab3f05906..d806b825ba 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -73,13 +73,13 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p m_name->add_fallback(FontFallback); // the custom spacings might only work with Noto Sans -#define MAKE_DEFAULT_FONT(m_name, m_size) \ - Ref<DynamicFont> m_name; \ - m_name.instance(); \ - m_name->set_size(m_size); \ - m_name->set_font_data(DefaultFont); \ - m_name->set_spacing(DynamicFont::SPACING_TOP, -1); \ - m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -1); \ +#define MAKE_DEFAULT_FONT(m_name, m_size) \ + Ref<DynamicFont> m_name; \ + m_name.instance(); \ + m_name->set_size(m_size); \ + m_name->set_font_data(DefaultFont); \ + m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \ + m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \ MAKE_FALLBACKS(m_name); void editor_register_fonts(Ref<Theme> p_theme) { @@ -119,7 +119,7 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<DynamicFontData> dfmono; dfmono.instance(); - dfmono->set_font_ptr(_font_source_code_pro, _font_source_code_pro_size); + dfmono->set_font_ptr(_font_mononoki_Regular, _font_mononoki_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/font_size")) * EDSCALE); @@ -147,7 +147,9 @@ void editor_register_fonts(Ref<Theme> p_theme) { Ref<DynamicFont> df_doc_code; df_doc_code.instance(); - df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 14)) * EDSCALE); + df_doc_code->set_size(int(EDITOR_DEF("text_editor/help/help_source_font_size", 18)) * EDSCALE); + df_doc_code->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); + df_doc_code->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); df_doc_code->set_font_data(dfmono); MAKE_FALLBACKS(df_doc_code); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index a5baf62ea0..6c8bd0f14b 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -607,7 +607,9 @@ void EditorHelp::_add_type(const String &p_type, const String &p_enum) { t = p_enum.get_slice(".", 0); } } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color")); + const Color text_color = get_color("default_color", "RichTextLabel"); + const Color type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5); + class_desc->push_color(type_color); if (can_ref) { if (p_enum == "") { class_desc->push_meta("#" + t); //class @@ -642,24 +644,32 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->clear(); method_line.clear(); + section_line.clear(); edited_class = p_class; //edited_class->show(); - DocData::ClassDoc cd = doc->class_list[p_class]; //make a copy, so we can sort without worrying + // Colors + const Color title_color = get_color("accent_color", "Editor"); + const Color text_color = get_color("font_color", "RichTextLabel"); + const Color highlight_color = get_color("highlight_color", "RichTextLabel"); + const Color base_type_color = title_color.linear_interpolate(text_color, 0.5); + const Color comment_color = Color(text_color.r, text_color.g, text_color.b, 0.6); + const Color symbol_color = comment_color; + const Color value_color = Color(text_color.r, text_color.g, text_color.b, 0.4); + const Color qualifier_color = Color(text_color.r, text_color.g, text_color.b, 0.8); - Color h_color; + DocData::ClassDoc cd = doc->class_list[p_class]; //make a copy, so we can sort without worrying Ref<Font> doc_font = get_font("doc", "EditorFonts"); Ref<Font> doc_title_font = get_font("doc_title", "EditorFonts"); Ref<Font> doc_code_font = get_font("doc_source", "EditorFonts"); - String link_color_text = Color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")).to_html(false); - - h_color = Color(1, 1, 1, 1); + String link_color_text = title_color.to_html(false); + section_line.push_back(Pair<String, int>(TTR("Top"), 0)); class_desc->push_font(doc_title_font); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->add_text(TTR("Class:") + " "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color")); + class_desc->push_color(highlight_color); _add_text(p_class); class_desc->pop(); class_desc->pop(); @@ -668,7 +678,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (cd.inherits != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Inherits:") + " "); class_desc->pop(); @@ -702,7 +712,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (E->get().inherits == cd.name) { if (!found) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Inherited by:") + " "); class_desc->pop(); @@ -730,10 +740,11 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } class_desc->add_newline(); + class_desc->add_newline(); if (cd.brief_description != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Brief Description:")); class_desc->pop(); @@ -741,7 +752,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { //class_desc->add_newline(); class_desc->add_newline(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); _add_text(cd.brief_description); @@ -750,6 +761,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->add_newline(); class_desc->add_newline(); + class_desc->add_newline(); } Set<String> skip_methods; @@ -757,7 +769,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (cd.properties.size()) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Members"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Members:")); class_desc->pop(); @@ -775,7 +788,6 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_align(RichTextLabel::ALIGN_RIGHT); class_desc->push_font(doc_code_font); _add_type(cd.properties[i].type, cd.properties[i].enumeration); - class_desc->add_text(" "); class_desc->pop(); class_desc->pop(); class_desc->pop(); @@ -800,7 +812,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } class_desc->push_font(doc_code_font); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(highlight_color); _add_text(cd.properties[i].name); if (describe) { @@ -835,7 +847,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (sort_methods) methods.sort(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Public Methods"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Public Methods:")); class_desc->pop(); @@ -852,9 +865,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { bool is_vararg = methods[i].qualifiers.find("vararg") != -1; - class_desc->push_cell(); - method_line[methods[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + + class_desc->push_cell(); class_desc->push_align(RichTextLabel::ALIGN_RIGHT); class_desc->push_font(doc_code_font); _add_type(methods[i].return_type, methods[i].return_enum); @@ -862,23 +875,24 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); //align class_desc->pop(); //font class_desc->pop(); //cell + class_desc->push_cell(); class_desc->push_font(doc_code_font); - if (true || methods[i].description != "") { //always describe method + if (methods[i].description != "") { method_descr = true; class_desc->push_meta("@" + methods[i].name); } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(highlight_color); _add_text(methods[i].name); class_desc->pop(); if (methods[i].description != "") - class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->pop(); // pop meta + class_desc->push_color(symbol_color); class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); if (j > 0) class_desc->add_text(", "); _add_type(methods[i].arguments[j].type, methods[i].arguments[j].enumeration); @@ -886,7 +900,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_text(methods[i].arguments[j].name); if (methods[i].arguments[j].default_value != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text("="); class_desc->pop(); _add_text(methods[i].arguments[j].default_value); @@ -896,21 +910,21 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } if (is_vararg) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); if (methods[i].arguments.size()) class_desc->add_text(", "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text("..."); class_desc->pop(); class_desc->pop(); } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(qualifier_color); class_desc->add_text(" "); _add_text(methods[i].qualifiers); class_desc->pop(); @@ -927,42 +941,54 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (cd.theme_properties.size()) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("GUI Theme Items"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("GUI Theme Items:")); class_desc->pop(); class_desc->pop(); - class_desc->add_newline(); + // class_desc->add_newline(); class_desc->push_indent(1); + class_desc->push_table(2); + class_desc->set_table_column_expand(1, 1); //class_desc->add_newline(); for (int i = 0; i < cd.theme_properties.size(); i++) { theme_property_line[cd.theme_properties[i].name] = class_desc->get_line_count() - 2; //gets overridden if description + + class_desc->push_cell(); + class_desc->push_align(RichTextLabel::ALIGN_RIGHT); class_desc->push_font(doc_code_font); _add_type(cd.theme_properties[i].type); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); - class_desc->add_text(" "); + class_desc->pop(); + class_desc->pop(); + class_desc->pop(); + + class_desc->push_cell(); + class_desc->push_font(doc_code_font); + class_desc->push_color(highlight_color); _add_text(cd.theme_properties[i].name); class_desc->pop(); class_desc->pop(); - if (true || cd.theme_properties[i].description != "") { //always describe properties + if (cd.theme_properties[i].description != "") { class_desc->push_font(doc_font); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); _add_text(cd.theme_properties[i].description); class_desc->pop(); class_desc->pop(); } - - class_desc->add_newline(); + class_desc->pop(); // cell } + class_desc->pop(); // table class_desc->pop(); class_desc->add_newline(); + class_desc->add_newline(); } if (cd.signals.size()) { @@ -970,7 +996,9 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (sort_methods) { cd.signals.sort(); } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + + section_line.push_back(Pair<String, int>(TTR("Signals"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Signals:")); class_desc->pop(); @@ -987,14 +1015,14 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_code_font); // monofont //_add_type("void"); //class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(highlight_color); _add_text(cd.signals[i].name); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(cd.signals[i].arguments.size() ? "( " : "("); class_desc->pop(); for (int j = 0; j < cd.signals[i].arguments.size(); j++) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); if (j > 0) class_desc->add_text(", "); _add_type(cd.signals[i].arguments[j].type); @@ -1002,7 +1030,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_text(cd.signals[i].arguments[j].name); if (cd.signals[i].arguments[j].default_value != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text("="); class_desc->pop(); _add_text(cd.signals[i].arguments[j].default_value); @@ -1011,13 +1039,13 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(cd.signals[i].arguments.size() ? " )" : ")"); class_desc->pop(); class_desc->pop(); // end monofont if (cd.signals[i].description != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); class_desc->add_text(" "); _add_text(cd.signals[i].description); class_desc->pop(); @@ -1050,7 +1078,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (enums.size()) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Enumerations:")); class_desc->pop(); @@ -1064,7 +1093,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { enum_line[E->key()] = class_desc->get_line_count() - 2; - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->add_text(TTR("enum ")); class_desc->pop(); class_desc->push_font(doc_code_font); @@ -1073,9 +1102,11 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { e = e.get_slice(".", 1); } + class_desc->push_color(highlight_color); class_desc->add_text(e); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->pop(); + class_desc->push_color(symbol_color); class_desc->add_text(":"); class_desc->pop(); class_desc->add_newline(); @@ -1086,20 +1117,20 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { for (int i = 0; i < enum_list.size(); i++) { class_desc->push_font(doc_code_font); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color")); + class_desc->push_color(highlight_color); _add_text(enum_list[i].name); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(value_color); _add_text(enum_list[i].value); class_desc->pop(); class_desc->pop(); if (enum_list[i].description != "") { class_desc->push_font(doc_font); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); _add_text(enum_list[i].description); class_desc->pop(); class_desc->pop(); @@ -1119,7 +1150,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (constants.size()) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Constants:")); class_desc->pop(); @@ -1133,20 +1165,20 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { constant_line[constants[i].name] = class_desc->get_line_count() - 2; class_desc->push_font(doc_code_font); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/base_type_color")); + class_desc->push_color(highlight_color); _add_text(constants[i].name); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(" = "); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(value_color); _add_text(constants[i].value); class_desc->pop(); class_desc->pop(); if (constants[i].description != "") { class_desc->push_font(doc_font); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); _add_text(constants[i].description); class_desc->pop(); class_desc->pop(); @@ -1162,16 +1194,16 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (cd.description != "") { + section_line.push_back(Pair<String, int>(TTR("Description"), class_desc->get_line_count() - 2)); description_line = class_desc->get_line_count() - 2; - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Description:")); class_desc->pop(); class_desc->pop(); class_desc->add_newline(); - class_desc->add_newline(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); _add_text(cd.description); @@ -1180,11 +1212,13 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->add_newline(); class_desc->add_newline(); + class_desc->add_newline(); } if (property_descr) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Property Description:")); class_desc->pop(); @@ -1201,7 +1235,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_type(cd.properties[i].type, cd.properties[i].enumeration); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(highlight_color); _add_text(cd.properties[i].name); class_desc->pop(); //color @@ -1214,11 +1248,11 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_font); class_desc->push_indent(2); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(comment_color); class_desc->add_text("Setter: "); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->add_text(cd.properties[i].setter + "(value)"); class_desc->pop(); //color @@ -1232,11 +1266,11 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->push_font(doc_font); class_desc->push_indent(2); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(comment_color); class_desc->add_text("Getter: "); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->add_text(cd.properties[i].getter + "()"); class_desc->pop(); //color @@ -1247,7 +1281,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->add_newline(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); if (cd.properties[i].description.strip_edges() != String()) { @@ -1255,7 +1289,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } else { class_desc->add_image(get_icon("Error", "EditorIcons")); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); class_desc->append_bbcode(TTR("There is currently no description for this property. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); class_desc->pop(); } @@ -1270,7 +1304,8 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { if (method_descr) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2)); + class_desc->push_color(title_color); class_desc->push_font(doc_title_font); class_desc->add_text(TTR("Method Description:")); class_desc->pop(); @@ -1289,14 +1324,14 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_type(methods[i].return_type, methods[i].return_enum); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(highlight_color); _add_text(methods[i].name); class_desc->pop(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(methods[i].arguments.size() || is_vararg ? "( " : "("); class_desc->pop(); for (int j = 0; j < methods[i].arguments.size(); j++) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); if (j > 0) class_desc->add_text(", "); _add_type(methods[i].arguments[j].type, methods[i].arguments[j].enumeration); @@ -1304,7 +1339,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { _add_text(methods[i].arguments[j].name); if (methods[i].arguments[j].default_value != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text("="); class_desc->pop(); _add_text(methods[i].arguments[j].default_value); @@ -1314,21 +1349,21 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } if (is_vararg) { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); if (methods[i].arguments.size()) class_desc->add_text(", "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text("..."); class_desc->pop(); class_desc->pop(); } - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/symbol_color")); + class_desc->push_color(symbol_color); class_desc->add_text(methods[i].arguments.size() || is_vararg ? " )" : ")"); class_desc->pop(); if (methods[i].qualifiers != "") { - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + class_desc->push_color(qualifier_color); class_desc->add_text(" "); _add_text(methods[i].qualifiers); class_desc->pop(); @@ -1337,7 +1372,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { class_desc->pop(); class_desc->add_newline(); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); + class_desc->push_color(text_color); class_desc->push_font(doc_font); class_desc->push_indent(1); if (methods[i].description.strip_edges() != String()) { @@ -1345,7 +1380,7 @@ Error EditorHelp::_goto_desc(const String &p_class, int p_vscr) { } else { class_desc->add_image(get_icon("Error", "EditorIcons")); class_desc->add_text(" "); - class_desc->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/comment_color")); + class_desc->push_color(comment_color); class_desc->append_bbcode(TTR("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!").replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text)); class_desc->pop(); } @@ -1419,70 +1454,16 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { DocData *doc = EditorHelp::get_doc_data(); String base_path; - /*p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/text_color")); - p_rt->push_font( get_font("normal","Fonts") ); - p_rt->push_indent(1);*/ - int pos = 0; - Ref<Font> doc_font = p_rt->get_font("doc", "EditorFonts"); Ref<Font> doc_code_font = p_rt->get_font("doc_source", "EditorFonts"); + Color font_color_hl = p_rt->get_color("highlight_color", "RichTextLabel"); + Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges(); - //change newlines for double newlines - for (int i = 0; i < bbcode.length(); i++) { - - //find valid newlines (double) - if (bbcode[i] == '\n') { - bool dnl = false; - int j = i + 1; - for (; j < p_bbcode.length(); j++) { - if (bbcode[j] == ' ') - continue; - if (bbcode[j] == '\n') { - dnl = true; - break; - } - break; - } - - if (dnl) { - bbcode[i] = 0xFFFF; - //keep - i = j; - } else { - bbcode = bbcode.insert(i, "\n"); - i++; - //bbcode[i]=' '; - //i=j-1; - } - } - } - - //remove double spaces or spaces after newlines - for (int i = 0; i < bbcode.length(); i++) { - - if (bbcode[i] == ' ' || bbcode[i] == '\n' || bbcode[i] == 0xFFFF) { - - for (int j = i + 1; j < p_bbcode.length(); j++) { - if (bbcode[j] == ' ') { - bbcode.remove(j); - j--; - continue; - } else { - break; - } - } - } - } - - //change newlines to double newlines - - CharType dnls[2] = { 0xFFFF, 0 }; - bbcode = bbcode.replace(dnls, "\n"); - List<String> tag_stack; + int pos = 0; while (pos < bbcode.length()) { int brk_pos = bbcode.find("[", pos); @@ -1500,7 +1481,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { int brk_end = bbcode.find("]", brk_pos + 1); if (brk_end == -1) { - //no close, add the rest p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos)); break; @@ -1512,6 +1492,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); if (tag_stack.size()) { } + if (!tag_ok) { p_rt->add_text("["); @@ -1527,7 +1508,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag.begins_with("method ")) { String m = tag.substr(7, tag.length()); - p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + p_rt->push_color(link_color); p_rt->push_meta("@" + m); p_rt->add_text(m + "()"); p_rt->pop(); @@ -1536,7 +1517,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (doc->class_list.has(tag)) { - p_rt->push_color(EditorSettings::get_singleton()->get("text_editor/highlighting/keyword_color")); + p_rt->push_color(link_color); p_rt->push_meta("#" + tag); p_rt->add_text(tag); p_rt->pop(); @@ -1552,13 +1533,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { } else if (tag == "i") { //use italics font - Color text_color = EditorSettings::get_singleton()->get("text_editor/highlighting/text_color"); - //no italics so emphasize with color - text_color.r *= 1.1; - text_color.g *= 1.1; - text_color.b *= 1.1; - p_rt->push_color(text_color); - //p_rt->push_font(get_font("italic","Fonts")); + p_rt->push_color(font_color_hl); pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag == "codeblock") { @@ -1728,6 +1703,7 @@ void EditorHelp::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { class_desc->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1))); + } break; default: break; @@ -1744,9 +1720,23 @@ void EditorHelp::go_to_class(const String &p_class, int p_scroll) { _goto_desc(p_class, p_scroll); } +Vector<Pair<String, int> > EditorHelp::get_sections() { + Vector<Pair<String, int> > sections; + + for (int i = 0; i < section_line.size(); i++) { + sections.push_back(Pair<String, int>(section_line[i].first, i)); + } + return sections; +} + +void EditorHelp::scroll_to_section(int p_section_index) { + int line = section_line[p_section_index].second; + class_desc->scroll_to_line(line); +} + void EditorHelp::popup_search() { - search_dialog->popup_centered(Size2(250, 80)); + search_dialog->popup_centered(Size2(250, 80) * EDSCALE); search->grab_focus(); } @@ -1825,7 +1815,6 @@ EditorHelp::EditorHelp() { search_dialog->get_ok()->set_text(TTR("Find")); search_dialog->connect("confirmed", this, "_search_cbk"); search_dialog->set_hide_on_ok(false); - search_dialog->set_self_modulate(Color(1, 1, 1, 0.8)); /*class_search = memnew( EditorHelpSearch(editor) ); editor->get_gui_base()->add_child(class_search); diff --git a/editor/editor_help.h b/editor/editor_help.h index f937e4a723..92c0e2f4d1 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -118,6 +118,7 @@ class EditorHelp : public VBoxContainer { String edited_class; + Vector<Pair<String, int> > section_line; Map<String, int> method_line; Map<String, int> signal_line; Map<String, int> property_line; @@ -168,6 +169,9 @@ public: void go_to_help(const String &p_help); void go_to_class(const String &p_class, int p_scroll = 0); + Vector<Pair<String, int> > get_sections(); + void scroll_to_section(int p_section_index); + void popup_search(); void search_again(); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3735c30578..d7cce71b90 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -254,6 +254,7 @@ void EditorNode::_notification(int p_what) { get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->set_auto_accept_quit(false); get_tree()->connect("files_dropped", this, "_dropped_files"); + property_editable_warning->set_icon(gui_base->get_icon("NodeWarning", "EditorIcons")); } if (p_what == NOTIFICATION_EXIT_TREE) { @@ -1387,6 +1388,11 @@ static bool overrides_external_editor(Object *p_object) { return script->get_language()->overrides_external_editor(); } +void EditorNode::_property_editable_warning_pressed() { + + property_editable_warning_dialog->popup_centered_minsize(); +} + void EditorNode::_edit_current() { uint32_t current = editor_history.get_current(); @@ -1398,6 +1404,9 @@ void EditorNode::_edit_current() { this->current = current_obj; editor_path->update_path(); + String editable_warning; //none by default + property_editable_warning->hide(); //hide by default + if (!current_obj) { scene_tree_dock->set_selected(NULL); @@ -1425,6 +1434,22 @@ void EditorNode::_edit_current() { node_dock->set_node(NULL); object_menu->set_disabled(false); EditorNode::get_singleton()->get_import_dock()->set_edit_path(current_res->get_path()); + + int subr_idx = current_res->get_path().find("::"); + if (subr_idx != -1) { + String base_path = current_res->get_path().substr(0, subr_idx); + if (FileAccess::exists(base_path + ".import")) { + editable_warning = TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow."); + } else { + if (!get_edited_scene() || get_edited_scene()->get_filename() != base_path) { + editable_warning = TTR("This resource belongs to a scene that was instanced or inherited.\nChanges to it will not be kept when saving the current scene."); + } + } + } else if (current_res->get_path().is_resource_file()) { + if (FileAccess::exists(current_res->get_path() + ".import")) { + editable_warning = TTR("This resource was imported, so it's not editable. Change it's settings in the import panel and re-import."); + } + } } else if (is_node) { Node *current_node = Object::cast_to<Node>(current_obj); @@ -1440,12 +1465,24 @@ void EditorNode::_edit_current() { } object_menu->get_popup()->clear(); + if (get_edited_scene() && get_edited_scene()->get_filename() != String()) { + String source_scene = get_edited_scene()->get_filename(); + if (FileAccess::exists(source_scene + ".import")) { + editable_warning = TTR("This scene was imported, so changes to it will not be kept.\nInstancing it or inheriting will allow making changes to it.\nPlease read the documentation relevant to importing scenes to better understand this workflow."); + } + } + } else { property_editor->edit(current_obj); node_dock->set_node(NULL); } + if (editable_warning != String()) { + property_editable_warning->show(); //hide by default + property_editable_warning_dialog->set_text(editable_warning); + } + /* Take care of PLUGIN EDITOR */ EditorPlugin *main_plugin = editor_data.get_editor(current_obj); @@ -2743,14 +2780,6 @@ Dictionary EditorNode::_get_main_scene_state() { state["property_edit_offset"] = get_property_editor()->get_scene_tree()->get_vscroll_bar()->get_value(); state["saved_version"] = saved_version; state["node_filter"] = scene_tree_dock->get_filter(); - int current = -1; - for (int i = 0; i < editor_table.size(); i++) { - if (editor_plugin_screen == editor_table[i]) { - current = i; - break; - } - } - state["editor_index"] = current; return state; } @@ -2761,29 +2790,32 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) { changing_scene = false; - if (p_state.has("editor_index")) { - - int index = p_state["editor_index"]; - int current = -1; - for (int i = 0; i < editor_table.size(); i++) { - if (editor_plugin_screen == editor_table[i]) { - current = i; - break; - } + int current = -1; + for (int i = 0; i < editor_table.size(); i++) { + if (editor_plugin_screen == editor_table[i]) { + current = i; + break; } + } + if (p_state.has("editor_index")) { + int index = p_state["editor_index"]; if (current < 2) { //if currently in spatial/2d, only switch to spatial/2d. if curently in script, stay there if (index < 2 || !get_edited_scene()) { _editor_select(index); - } else { - //use heuristic instead - int n2d = 0, n3d = 0; - _find_node_types(get_edited_scene(), n2d, n3d); - if (n2d > n3d) { - _editor_select(EDITOR_2D); - } else if (n3d > n2d) { - _editor_select(EDITOR_3D); - } + } + } + } + + if (get_edited_scene()) { + if (current < 2) { + //use heuristic instead + int n2d = 0, n3d = 0; + _find_node_types(get_edited_scene(), n2d, n3d); + if (n2d > n3d) { + _editor_select(EDITOR_2D); + } else if (n3d > n2d) { + _editor_select(EDITOR_3D); } } } @@ -3214,9 +3246,9 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorFileSystemDirectory>(); ClassDB::register_virtual_class<ScriptEditor>(); ClassDB::register_virtual_class<EditorInterface>(); + ClassDB::register_class<EditorExportPlugin>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? - //ClassDB::register_class<EditorExportPlugin>(); //ClassDB::register_class<EditorScenePostImport>(); //ClassDB::register_type<EditorImportExport>(); } @@ -3306,9 +3338,9 @@ void EditorNode::_editor_file_dialog_unregister(EditorFileDialog *p_dialog) { Vector<EditorNodeInitCallback> EditorNode::_init_callbacks; -Error EditorNode::export_preset(const String &preset, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after) { +Error EditorNode::export_preset(const String &p_preset, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after) { - export_defer.preset = preset; + export_defer.preset = p_preset; export_defer.path = p_path; export_defer.debug = p_debug; export_defer.password = p_password; @@ -4471,6 +4503,7 @@ void EditorNode::_bind_methods() { ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history); ClassDB::bind_method("_dropped_files", &EditorNode::_dropped_files); ClassDB::bind_method("_toggle_distraction_free_mode", &EditorNode::_toggle_distraction_free_mode); + ClassDB::bind_method("_property_editable_warning_pressed", &EditorNode::_property_editable_warning_pressed); ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base); ClassDB::bind_method(D_METHOD("_bottom_panel_switch"), &EditorNode::_bottom_panel_switch); @@ -4816,7 +4849,7 @@ EditorNode::EditorNode() { scene_root_parent = memnew(PanelContainer); scene_root_parent->set_custom_minimum_size(Size2(0, 80) * EDSCALE); scene_root_parent->add_style_override("panel", gui_base->get_stylebox("Content", "EditorStyles")); - + scene_root_parent->set_draw_behind_parent(true); srt->add_child(scene_root_parent); scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); @@ -5232,6 +5265,14 @@ EditorNode::EditorNode() { search_bar->add_child(clear_button); clear_button->connect("pressed", this, "_clear_search_box"); + property_editable_warning = memnew(Button); + property_editable_warning->set_text(TTR("Changes may be lost!")); + prop_editor_base->add_child(property_editable_warning); + property_editable_warning_dialog = memnew(AcceptDialog); + gui_base->add_child(property_editable_warning_dialog); + property_editable_warning->hide(); + property_editable_warning->connect("pressed", this, "_property_editable_warning_pressed"); + property_editor = memnew(PropertyEditor); property_editor->set_autoclear(true); property_editor->set_show_categories(true); @@ -5244,6 +5285,7 @@ EditorNode::EditorNode() { property_editor->hide_top_label(); property_editor->register_text_enter(search_box); + Button *property_editable_warning; prop_editor_base->add_child(property_editor); property_editor->set_undo_redo(&editor_data.get_undo_redo()); diff --git a/editor/editor_node.h b/editor/editor_node.h index ea74bcbd9d..33031e5634 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -262,6 +262,9 @@ private: Button *property_forward; SceneTreeDock *scene_tree_dock; PropertyEditor *property_editor; + Button *property_editable_warning; + AcceptDialog *property_editable_warning_dialog; + void _property_editable_warning_pressed(); NodeDock *node_dock; ImportDock *import_dock; VBoxContainer *prop_editor_vb; @@ -712,7 +715,7 @@ public: void show_warning(const String &p_text, const String &p_title = "Warning!"); - Error export_preset(const String &p_platform, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false); + Error export_preset(const String &p_preset, const String &p_path, bool p_debug, const String &p_password, bool p_quit_after = false); static void register_editor_types(); static void unregister_editor_types(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 86acfcc50e..246599be11 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -530,6 +530,14 @@ void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importe EditorFileSystem::get_singleton()->scan(); } +void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) { + EditorExport::get_singleton()->add_export_plugin(p_exporter); +} + +void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) { + EditorExport::get_singleton()->remove_export_plugin(p_exporter); +} + void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { @@ -585,6 +593,8 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin); ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin); + ClassDB::bind_method(D_METHOD("add_export_plugin", "exporter"), &EditorPlugin::add_export_plugin); + ClassDB::bind_method(D_METHOD("remove_export_plugin", "exporter"), &EditorPlugin::remove_export_plugin); ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled); ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 99328f8149..18530e9ce4 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -191,6 +191,9 @@ public: void add_import_plugin(const Ref<EditorImportPlugin> &p_importer); void remove_import_plugin(const Ref<EditorImportPlugin> &p_importer); + void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter); + void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter); + EditorPlugin(); virtual ~EditorPlugin(); }; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3bb6345d73..d4ee6b2d17 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -599,8 +599,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { hints["global/default_project_export_path"] = PropertyInfo(Variant::STRING, "global/default_project_export_path", PROPERTY_HINT_GLOBAL_DIR); set("interface/show_script_in_scene_tabs", false); - set("text_editor/theme/color_theme", "Default"); - hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Default"); + set("text_editor/theme/color_theme", "Adaptive"); + hints["text_editor/theme/color_theme"] = PropertyInfo(Variant::STRING, "text_editor/theme/color_theme", PROPERTY_HINT_ENUM, "Adaptive,Default"); set("text_editor/theme/line_spacing", 4); @@ -739,6 +739,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("docks/property_editor/texture_preview_width", 48); set("docks/property_editor/auto_refresh_interval", 0.3); set("text_editor/help/doc_path", ""); + set("text_editor/help/show_help_index", true); set("filesystem/import/ask_save_before_reimport", false); @@ -923,13 +924,13 @@ void EditorSettings::load_favorites() { } void EditorSettings::list_text_editor_themes() { - String themes = "Default"; + String themes = "Adaptive,Default"; DirAccess *d = DirAccess::open(settings_path + "/text_editor_themes"); if (d) { d->list_dir_begin(); String file = d->get_next(); while (file != String()) { - if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default") { + if (file.get_extension() == "tet" && file.get_basename().to_lower() != "default" && file.get_basename().to_lower() != "adaptive") { themes += "," + file.get_basename(); } file = d->get_next(); @@ -941,7 +942,7 @@ void EditorSettings::list_text_editor_themes() { } void EditorSettings::load_text_editor_theme() { - if (get("text_editor/theme/color_theme") == "Default") { + if (get("text_editor/theme/color_theme") == "Default" || get("text_editor/theme/color_theme") == "Adaptive") { _load_default_text_editor_theme(); // sorry for "Settings changed" console spam return; } @@ -998,7 +999,7 @@ bool EditorSettings::save_text_editor_theme() { String p_file = get("text_editor/theme/color_theme"); - if (p_file.get_file().to_lower() == "default") { + if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive") { return false; } String theme_path = get_settings_path() + "/text_editor_themes/" + p_file + ".tet"; @@ -1010,7 +1011,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { p_file += ".tet"; } - if (p_file.get_file().to_lower() == "default.tet") { + if (p_file.get_file().to_lower() == "default.tet" || p_file.get_file().to_lower() == "adaptive.tet") { return false; } if (_save_text_editor_theme(p_file)) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index cacd26a20a..0cba024595 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -285,6 +285,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("contrast_color_1", "Editor", contrast_color_1); theme->set_color("contrast_color_2", "Editor", contrast_color_2); + theme->set_color("font_color", "Editor", font_color); + Color success_color = accent_color.linear_interpolate(Color(.6, 1, .6), 0.8); Color warning_color = accent_color.linear_interpolate(Color(1, 1, .2), 0.8); Color error_color = accent_color.linear_interpolate(Color(1, .2, .2), 0.8); @@ -367,6 +369,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Tabs Ref<StyleBoxFlat> style_tab_selected = style_default->duplicate(); + style_tab_selected->set_border_width_all(border_width); + style_tab_selected->set_border_width(MARGIN_BOTTOM, 0); + style_tab_selected->set_border_color_all(dark_color_3); + style_tab_selected->set_expand_margin_size(MARGIN_BOTTOM, border_width); style_tab_selected->set_default_margin(MARGIN_LEFT, 10 * EDSCALE); style_tab_selected->set_default_margin(MARGIN_RIGHT, 10 * EDSCALE); style_tab_selected->set_bg_color(tab_color); @@ -433,19 +439,6 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("MenuHover", "EditorStyles", style_menu_hover_border); - // Content of each tab - Ref<StyleBoxFlat> style_content_panel = style_default->duplicate(); - style_content_panel->set_border_color_all(base_color); - - // this is the stylebox used in 3d and 2d viewports (no borders) - Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate(); - style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width); - style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size); - style_content_panel_vp->set_default_margin(MARGIN_RIGHT, border_width); - style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width); - theme->set_stylebox("panel", "TabContainer", style_content_panel); - theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); - // Buttons theme->set_stylebox("normal", "Button", style_widget); theme->set_stylebox("hover", "Button", style_widget_hover); @@ -606,6 +599,20 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("button_pressed", "Tabs", style_menu); theme->set_stylebox("button", "Tabs", style_menu); + // Content of each tab + Ref<StyleBoxFlat> style_content_panel = style_default->duplicate(); + style_content_panel->set_border_color_all(dark_color_3); + style_content_panel->set_border_width_all(border_width); + + // this is the stylebox used in 3d and 2d viewports (no borders) + Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate(); + style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width); + style_content_panel_vp->set_default_margin(MARGIN_TOP, default_margin_size); + style_content_panel_vp->set_default_margin(MARGIN_LEFT, border_width); + style_content_panel_vp->set_default_margin(MARGIN_BOTTOM, border_width); + theme->set_stylebox("panel", "TabContainer", style_content_panel); + theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); + // Separators (no separators) theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width)); theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, true)); @@ -632,6 +639,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("normal", "TextEdit", style_widget); theme->set_stylebox("focus", "TextEdit", style_widget_hover); theme->set_constant("side_margin", "TabContainer", 0); + theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons")); // H/VSplitContainer theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon("GuiVsplitBg", "EditorIcons"), 1, 1, 1, 1)); @@ -704,7 +712,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { //RichTextLabel Color rtl_combined_bg_color = dark_color_1.linear_interpolate(script_bg_color, script_bg_color.a); - Color rtl_font_color = (rtl_combined_bg_color.r + rtl_combined_bg_color.g + rtl_combined_bg_color.b > 0.5 * 3) ? Color(0, 0, 0) : Color(1, 1, 1); + Color rtl_mono_color = (rtl_combined_bg_color.r + rtl_combined_bg_color.g + rtl_combined_bg_color.b > 1.5) ? Color(0, 0, 0) : Color(1, 1, 1); + Color rtl_font_color = rtl_mono_color.linear_interpolate(rtl_combined_bg_color, 0.25); theme->set_color("default_color", "RichTextLabel", rtl_font_color); theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox()); theme->set_stylebox("normal", "RichTextLabel", style_tree_bg); @@ -715,6 +724,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_code_focus->set_bg_color(rtl_combined_bg_color); theme->set_stylebox("code_focus", "RichTextLabel", style_code_focus); + theme->set_color("font_color", "RichTextLabel", rtl_font_color); + theme->set_color("highlight_color", "RichTextLabel", rtl_mono_color); + // Panel theme->set_stylebox("panel", "Panel", make_flat_stylebox(dark_color_1, 6, 4, 6, 4)); @@ -776,6 +788,80 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // FileDialog theme->set_color("files_disabled", "FileDialog", font_color_disabled); + // adaptive script theme constants + // for comments and elements with lower relevance + const Color dim_color = Color(font_color.r, font_color.g, font_color.b, 0.5); + + const float mono_value = mono_color.r; + const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.1); + const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.3); + const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.5); + const Color alpha4 = Color(mono_value, mono_value, mono_value, 0.7); + + // editor main color + const Color main_color = Color::html(dark_theme ? "#57b3ff" : "#0480ff"); + + const Color symbol_color = Color::html("#5792ff").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color keyword_color = main_color.linear_interpolate(mono_color, 0.4); + const Color basetype_color = Color::html(dark_theme ? "#42ffc2" : "#00c161"); + const Color type_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.7 : 0.5); + const Color comment_color = dim_color; + const Color string_color = Color::html(dark_theme ? "#ffd942" : "#ffd118").linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + + const Color te_background_color = Color(0, 0, 0, 0); + const Color completion_background_color = base_color; + const Color completion_selected_color = alpha1; + const Color completion_existing_color = alpha2; + const Color completion_scroll_color = alpha1; + const Color completion_font_color = font_color; + const Color text_color = font_color; + const Color line_number_color = dim_color; + const Color caret_color = mono_color; + const Color caret_background_color = mono_color.inverted(); + const Color text_selected_color = dark_color_3; + const Color selection_color = alpha3; + const Color brace_mismatch_color = error_color; + const Color current_line_color = alpha1; + const Color line_length_guideline_color = warning_color; + const Color word_highlighted_color = alpha1; + const Color number_color = basetype_color.linear_interpolate(mono_color, dark_theme ? 0.5 : 0.3); + const Color function_color = main_color; + const Color member_variable_color = mono_color; + const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); + const Color breakpoint_color = error_color; + const Color search_result_color = alpha1; + const Color search_result_border_color = alpha4; + + theme->set_color("text_editor/theme/symbol_color", "Editor", symbol_color); + theme->set_color("text_editor/theme/keyword_color", "Editor", keyword_color); + theme->set_color("text_editor/theme/basetype_color", "Editor", basetype_color); + theme->set_color("text_editor/theme/type_color", "Editor", type_color); + theme->set_color("text_editor/theme/comment_color", "Editor", comment_color); + theme->set_color("text_editor/theme/string_color", "Editor", string_color); + theme->set_color("text_editor/theme/background_color", "Editor", te_background_color); + theme->set_color("text_editor/theme/completion_background_color", "Editor", completion_background_color); + theme->set_color("text_editor/theme/completion_selected_color", "Editor", completion_selected_color); + theme->set_color("text_editor/theme/completion_existing_color", "Editor", completion_existing_color); + theme->set_color("text_editor/theme/completion_scroll_color", "Editor", completion_scroll_color); + theme->set_color("text_editor/theme/completion_font_color", "Editor", completion_font_color); + theme->set_color("text_editor/theme/text_color", "Editor", text_color); + theme->set_color("text_editor/theme/line_number_color", "Editor", line_number_color); + theme->set_color("text_editor/theme/caret_color", "Editor", caret_color); + theme->set_color("text_editor/theme/caret_background_color", "Editor", caret_background_color); + theme->set_color("text_editor/theme/text_selected_color", "Editor", text_selected_color); + theme->set_color("text_editor/theme/selection_color", "Editor", selection_color); + theme->set_color("text_editor/theme/brace_mismatch_color", "Editor", brace_mismatch_color); + theme->set_color("text_editor/theme/current_line_color", "Editor", current_line_color); + theme->set_color("text_editor/theme/line_length_guideline_color", "Editor", line_length_guideline_color); + theme->set_color("text_editor/theme/word_highlighted_color", "Editor", word_highlighted_color); + theme->set_color("text_editor/theme/number_color", "Editor", number_color); + theme->set_color("text_editor/theme/function_color", "Editor", function_color); + theme->set_color("text_editor/theme/member_variable_color", "Editor", member_variable_color); + theme->set_color("text_editor/theme/mark_color", "Editor", mark_color); + theme->set_color("text_editor/theme/breakpoint_color", "Editor", breakpoint_color); + theme->set_color("text_editor/theme/search_result_color", "Editor", search_result_color); + theme->set_color("text_editor/theme/search_result_border_color", "Editor", search_result_border_color); + return theme; } diff --git a/editor/icons/icon_GUI_tab.svg b/editor/icons/icon_GUI_tab.svg new file mode 100644 index 0000000000..3eed0680c0 --- /dev/null +++ b/editor/icons/icon_GUI_tab.svg @@ -0,0 +1,5 @@ +<svg width="8" height="8" version="1.1" viewBox="0 0 8 8" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1044.4)"> +<path transform="translate(0 1044.4)" d="m6 0v8h2v-8h-2zm-5.0137 0.0019531a1 1 0 0 0 -0.69336 0.29102 1 1 0 0 0 0 1.4141l2.293 2.293-2.293 2.293a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l3-3a1.0001 1.0001 0 0 0 0 -1.4141l-3-3a1 1 0 0 0 -0.7207 -0.29102z" fill="#fff" fill-opacity=".19608"/> +</g> +</svg> diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index a483c3776f..652977b98a 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -119,7 +119,7 @@ public: virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; - void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animation, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); + void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map); diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index 054124da8f..414b091475 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -476,7 +476,7 @@ void AnimationTreeEditor::_draw_node(const StringName &p_node) { Color font_color = get_color("font_color", "PopupMenu"); Color font_color_title = get_color("font_color_hover", "PopupMenu"); font_color_title.a *= 0.8; - Ref<Texture> slot_icon = get_icon("NodeRealSlot", "EditorIcons"); + Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons"); Size2 size = get_node_size(p_node); Point2 pos = anim_tree->node_get_pos(p_node); @@ -599,7 +599,7 @@ void AnimationTreeEditor::_draw_node(const StringName &p_node) { if (editable) { - Ref<Texture> arrow = get_icon("arrow", "Tree"); + Ref<Texture> arrow = get_icon("GuiDropdown", "EditorIcons"); Point2 arrow_ofs(w - arrow->get_width(), Math::floor((h - arrow->get_height()) / 2)); arrow->draw(ci, ofs + arrow_ofs); } @@ -671,7 +671,7 @@ Point2 AnimationTreeEditor::_get_slot_pos(const StringName &p_node_id, bool p_in Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); Ref<Font> font = get_font("font", "PopupMenu"); - Ref<Texture> slot_icon = get_icon("NodeRealSlot", "EditorIcons"); + Ref<Texture> slot_icon = get_icon("VisualShaderPort", "EditorIcons"); Size2 size = get_node_size(p_node_id); Point2 pos = anim_tree->node_get_pos(p_node_id); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2b2358f3d0..b28da54c6d 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -845,6 +845,8 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); + + se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); } if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0])) { @@ -1411,6 +1413,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) { se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); + se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); return; } @@ -1432,6 +1435,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) { se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); + se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); return; } @@ -1441,6 +1445,7 @@ void CanvasItemEditor::_viewport_gui_input(const Ref<InputEvent> &p_event) { if (drag != DRAG_NONE) { drag_from = transform.affine_inverse().xform(click); se->undo_state = canvas_item->edit_get_state(); + se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); return; } } @@ -1993,6 +1998,23 @@ void CanvasItemEditor::_viewport_draw() { Rect2 rect = canvas_item->get_item_rect(); + if (drag != DRAG_NONE && drag != DRAG_PIVOT) { + const Transform2D pre_drag_xform = transform * se->pre_drag_xform; + const Color pre_drag_color = Color(0.4, 0.6, 1, 0.7); + + Vector2 pre_drag_endpoints[4] = { + + pre_drag_xform.xform(rect.position), + pre_drag_xform.xform(rect.position + Vector2(rect.size.x, 0)), + pre_drag_xform.xform(rect.position + rect.size), + pre_drag_xform.xform(rect.position + Vector2(0, rect.size.y)) + }; + + for (int i = 0; i < 4; i++) { + viewport->draw_line(pre_drag_endpoints[i], pre_drag_endpoints[(i + 1) % 4], pre_drag_color, 2); + } + } + Transform2D xform = transform * canvas_item->get_global_transform_with_canvas(); VisualServer::get_singleton()->canvas_item_add_set_transform(ci, xform); @@ -2301,19 +2323,24 @@ void CanvasItemEditor::_notification(int p_what) { Rect2 r = canvas_item->get_item_rect(); Transform2D xform = canvas_item->get_transform(); - float anchors[4]; - Vector2 pivot; + if (r != se->prev_rect || xform != se->prev_xform) { + viewport->update(); + se->prev_rect = r; + se->prev_xform = xform; + } + if (Object::cast_to<Control>(canvas_item)) { + float anchors[4]; + Vector2 pivot; + pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); anchors[MARGIN_LEFT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_LEFT); anchors[MARGIN_RIGHT] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_RIGHT); anchors[MARGIN_TOP] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_TOP); anchors[MARGIN_BOTTOM] = Object::cast_to<Control>(canvas_item)->get_anchor(MARGIN_BOTTOM); - if (r != se->prev_rect || xform != se->prev_xform || pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) { + if (pivot != se->prev_pivot || anchors[MARGIN_LEFT] != se->prev_anchors[MARGIN_LEFT] || anchors[MARGIN_RIGHT] != se->prev_anchors[MARGIN_RIGHT] || anchors[MARGIN_TOP] != se->prev_anchors[MARGIN_TOP] || anchors[MARGIN_BOTTOM] != se->prev_anchors[MARGIN_BOTTOM]) { viewport->update(); - se->prev_rect = r; - se->prev_xform = xform; se->prev_pivot = pivot; se->prev_anchors[MARGIN_LEFT] = anchors[MARGIN_LEFT]; se->prev_anchors[MARGIN_RIGHT] = anchors[MARGIN_RIGHT]; diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 2e1a2eac5f..f61bfc9ebb 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -58,6 +58,8 @@ public: Vector2 prev_pivot; float prev_anchors[4]; + Transform2D pre_drag_xform; + CanvasItemEditorSelectedItem() { prev_rot = 0; } }; @@ -315,7 +317,7 @@ class CanvasItemEditor : public VBoxContainer { void _prepare_drag(const Point2 &p_click_pos); DragType _get_anchor_handle_drag_type(const Point2 &p_click, Vector2 &r_point); - float _anchor_snap(float anchor, bool *snapped = NULL, float p_opposite_anchor = -1); + float _anchor_snap(float p_anchor, bool *p_snapped = NULL, float p_opposite_anchor = -1); Vector2 _anchor_to_position(Control *p_control, Vector2 anchor); Vector2 _position_to_anchor(Control *p_control, Vector2 position); diff --git a/editor/plugins/navigation_mesh_editor_plugin.h b/editor/plugins/navigation_mesh_editor_plugin.h index 3009e2addc..bac7f608ab 100644 --- a/editor/plugins/navigation_mesh_editor_plugin.h +++ b/editor/plugins/navigation_mesh_editor_plugin.h @@ -56,7 +56,7 @@ class NavigationMeshEditor : public Control { protected: void _node_removed(Node *p_node); static void _bind_methods(); - void _notification(int p_what); + void _notification(int p_option); public: void edit(NavigationMeshInstance *p_nav_mesh_instance); @@ -74,8 +74,8 @@ class NavigationMeshEditorPlugin : public EditorPlugin { public: virtual String get_name() const { return "NavigationMesh"; } bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; + virtual void edit(Object *p_object); + virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); NavigationMeshEditorPlugin(EditorNode *p_node); diff --git a/editor/plugins/navigation_mesh_generator.h b/editor/plugins/navigation_mesh_generator.h index 48e7dfe53f..0a1c497f8f 100644 --- a/editor/plugins/navigation_mesh_generator.h +++ b/editor/plugins/navigation_mesh_generator.h @@ -56,7 +56,7 @@ protected: rcPolyMeshDetail *detail_mesh, Vector<float> &verticies, Vector<int> &indices); public: - static void bake(Ref<NavigationMesh> p_nav_mesh, Node *p_base); + static void bake(Ref<NavigationMesh> p_nav_mesh, Node *p_node); static void clear(Ref<NavigationMesh> p_nav_mesh); }; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 6f03d086ca..9af5885a17 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -421,8 +421,10 @@ void ScriptEditor::_go_to_tab(int p_idx) { _update_history_arrows(); _update_script_colors(); _update_members_overview(); + _update_help_overview(); _update_selected_editor_menu(); _update_members_overview_visibility(); + _update_help_overview_visibility(); } void ScriptEditor::_add_recent_script(String p_path) { @@ -555,6 +557,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { _update_script_names(); _update_members_overview_visibility(); + _update_help_overview_visibility(); _save_layout(); } @@ -1110,6 +1113,7 @@ void ScriptEditor::_notification(int p_what) { editor->connect("resource_saved", this, "_res_saved_callback"); script_list->connect("item_selected", this, "_script_selected"); members_overview->connect("item_selected", this, "_members_overview_selected"); + help_overview->connect("item_selected", this, "_help_overview_selected"); script_split->connect("dragged", this, "_script_split_dragged"); autosave_timer->connect("timeout", this, "_autosave_scripts"); { @@ -1278,6 +1282,15 @@ void ScriptEditor::_members_overview_selected(int p_idx) { se->ensure_focus(); } +void ScriptEditor::_help_overview_selected(int p_idx) { + Node *current = tab_container->get_child(tab_container->get_current_tab()); + EditorHelp *se = Object::cast_to<EditorHelp>(current); + if (!se) { + return; + } + se->scroll_to_section(help_overview->get_item_metadata(p_idx)); +} + void ScriptEditor::_script_selected(int p_idx) { grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing @@ -1387,14 +1400,58 @@ void ScriptEditor::_update_members_overview() { } } +void ScriptEditor::_update_help_overview_visibility() { + + int selected = tab_container->get_current_tab(); + if (selected < 0 || selected >= tab_container->get_child_count()) + return; + + Node *current = tab_container->get_child(tab_container->get_current_tab()); + EditorHelp *se = Object::cast_to<EditorHelp>(current); + if (!se) { + help_overview->set_visible(false); + return; + } + + if (help_overview_enabled) { + help_overview->set_visible(true); + } else { + help_overview->set_visible(false); + } +} + +void ScriptEditor::_update_help_overview() { + + int selected = tab_container->get_current_tab(); + if (selected < 0 || selected >= tab_container->get_child_count()) + return; + + Node *current = tab_container->get_child(tab_container->get_current_tab()); + EditorHelp *se = Object::cast_to<EditorHelp>(current); + if (!se) { + return; + } + + help_overview->clear(); + + Vector<Pair<String, int> > sections = se->get_sections(); + for (int i = 0; i < sections.size(); i++) { + help_overview->add_item(sections[i].first); + help_overview->set_item_metadata(i, sections[i].second); + } +} + +void _help_overview_selected(int p_idx) { +} + void ScriptEditor::_update_script_colors() { bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_enabled"); bool highlight_current = EditorSettings::get_singleton()->get("text_editor/open_scripts/highlight_current_script"); int hist_size = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_history_size"); - Color hot_color = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_hot_color"); - Color cold_color = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_cold_color"); + Color hot_color = get_color("accent_color", "Editor"); + Color cold_color = get_color("font_color", "Editor"); for (int i = 0; i < script_list->get_item_count(); i++) { @@ -1531,6 +1588,7 @@ void ScriptEditor::_update_script_names() { } _update_members_overview(); + _update_help_overview(); _update_script_colors(); } @@ -1624,9 +1682,10 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool break; } ERR_FAIL_COND_V(!se, false); - tab_container->add_child(se); + // load script before adding as child else editor will crash at theme loading se->set_edited_script(p_script); + tab_container->add_child(se); se->set_tooltip_request_func("_get_debug_tooltip", this); if (se->get_edit_menu()) { se->get_edit_menu()->hide(); @@ -1785,7 +1844,9 @@ void ScriptEditor::_editor_settings_changed() { use_space_indentation = EditorSettings::get_singleton()->get("text_editor/indent/type"); members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/show_members_overview"); + help_overview_enabled = EditorSettings::get_singleton()->get("text_editor/help/show_help_index"); _update_members_overview_visibility(); + _update_help_overview_visibility(); float autosave_time = EditorSettings::get_singleton()->get("text_editor/files/autosave_interval_secs"); if (autosave_time > 0) { @@ -2164,6 +2225,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_update_script_names", &ScriptEditor::_update_script_names); ClassDB::bind_method("_tree_changed", &ScriptEditor::_tree_changed); ClassDB::bind_method("_members_overview_selected", &ScriptEditor::_members_overview_selected); + ClassDB::bind_method("_help_overview_selected", &ScriptEditor::_help_overview_selected); ClassDB::bind_method("_script_selected", &ScriptEditor::_script_selected); ClassDB::bind_method("_script_created", &ScriptEditor::_script_created); ClassDB::bind_method("_script_split_dragged", &ScriptEditor::_script_split_dragged); @@ -2193,6 +2255,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { pending_auto_reload = false; auto_reload_running_scripts = false; members_overview_enabled = true; + help_overview_enabled = true; editor = p_editor; VBoxContainer *main_container = memnew(VBoxContainer); @@ -2221,6 +2284,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { members_overview->set_custom_minimum_size(Size2(0, 100)); //need to give a bit of limit to avoid it from disappearing members_overview->set_v_size_flags(SIZE_EXPAND_FILL); + help_overview = memnew(ItemList); + list_split->add_child(help_overview); + help_overview->set_custom_minimum_size(Size2(0, 100)); //need to give a bit of limit to avoid it from disappearing + help_overview->set_v_size_flags(SIZE_EXPAND_FILL); + tab_container = memnew(TabContainer); tab_container->set_tabs_visible(false); script_split->add_child(tab_container); @@ -2520,8 +2588,6 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) { EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true); EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true); EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15); - EDITOR_DEF("text_editor/open_scripts/script_temperature_hot_color", Color::html("ed5e5e")); - EDITOR_DEF("text_editor/open_scripts/script_temperature_cold_color", Color(1, 1, 1, 0.3)); EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(1, 1, 1, 0.5)); EDITOR_DEF("text_editor/open_scripts/group_help_pages", true); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path")); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index d2677c6a4a..03fc4da7ce 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -187,6 +187,8 @@ class ScriptEditor : public PanelContainer { HSplitContainer *script_split; ItemList *members_overview; bool members_overview_enabled; + ItemList *help_overview; + bool help_overview_enabled; VSplitContainer *list_split; TabContainer *tab_container; EditorFileDialog *file_dialog; @@ -294,6 +296,10 @@ class ScriptEditor : public PanelContainer { void _members_overview_selected(int p_idx); void _script_selected(int p_idx); + void _update_help_overview_visibility(); + void _update_help_overview(); + void _help_overview_selected(int p_idx); + void _find_scripts(Node *p_base, Node *p_current, Set<Ref<Script> > &used); void _tree_changed(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index d2cb96bf3b..c875ee7011 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -75,35 +75,98 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->clear_colors(); - /* keyword color */ - - text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0))); - text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0))); - text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"))); - text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"))); - text_edit->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"))); - text_edit->add_color_override("completion_font_color", EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"))); - text_edit->add_color_override("font_color", EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0))); - text_edit->add_color_override("line_number_color", EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0))); - text_edit->add_color_override("caret_color", EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0))); - text_edit->add_color_override("caret_background_color", EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0))); - text_edit->add_color_override("font_selected_color", EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1))); - text_edit->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1))); - text_edit->add_color_override("brace_mismatch_color", EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2))); - text_edit->add_color_override("current_line_color", EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15))); - text_edit->add_color_override("line_length_guideline_color", EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0))); - text_edit->add_color_override("word_highlighted_color", EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15))); - text_edit->add_color_override("number_color", EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2))); - text_edit->add_color_override("function_color", EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8))); - text_edit->add_color_override("member_variable_color", EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3))); - text_edit->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4))); - text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2))); - text_edit->add_color_override("search_result_color", EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1))); - text_edit->add_color_override("search_result_border_color", EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1))); - text_edit->add_color_override("symbol_color", EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff))); - text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); + Color completion_background_color = EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0)); + Color completion_selected_color = EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244")); + Color completion_existing_color = EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")); + Color completion_scroll_color = EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")); + Color completion_font_color = EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")); + Color text_color = EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0)); + Color line_number_color = EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0)); + Color caret_color = EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0)); + Color caret_background_color = EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0)); + Color text_selected_color = EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1)); + Color selection_color = EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)); + Color brace_mismatch_color = EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)); + Color current_line_color = EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)); + Color line_length_guideline_color = EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0)); + Color word_highlighted_color = EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)); + Color number_color = EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2)); + Color function_color = EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8)); + Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)); + Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); + Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); + Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); + Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)); Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2)); + Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0)); + Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4)); + Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff)); + Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff)); + + // Adapt + if (EditorSettings::get_singleton()->get("text_editor/theme/color_theme") == "Adaptive") { + Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); + + symbol_color = tm->get_color("text_editor/theme/symbol_color", "Editor"); + keyword_color = tm->get_color("text_editor/theme/keyword_color", "Editor"); + basetype_color = tm->get_color("text_editor/theme/basetype_color", "Editor"); + type_color = tm->get_color("text_editor/theme/type_color", "Editor"); + comment_color = tm->get_color("text_editor/theme/comment_color", "Editor"); + string_color = tm->get_color("text_editor/theme/string_color", "Editor"); + background_color = tm->get_color("text_editor/theme/background_color", "Editor"); + completion_background_color = tm->get_color("text_editor/theme/completion_background_color", "Editor"); + completion_selected_color = tm->get_color("text_editor/theme/completion_selected_color", "Editor"); + completion_existing_color = tm->get_color("text_editor/theme/completion_existing_color", "Editor"); + completion_scroll_color = tm->get_color("text_editor/theme/completion_scroll_color", "Editor"); + completion_font_color = tm->get_color("text_editor/theme/completion_font_color", "Editor"); + text_color = tm->get_color("text_editor/theme/text_color", "Editor"); + line_number_color = tm->get_color("text_editor/theme/line_number_color", "Editor"); + caret_color = tm->get_color("text_editor/theme/caret_color", "Editor"); + caret_background_color = tm->get_color("text_editor/theme/caret_background_color", "Editor"); + text_selected_color = tm->get_color("text_editor/theme/text_selected_color", "Editor"); + selection_color = tm->get_color("text_editor/theme/selection_color", "Editor"); + brace_mismatch_color = tm->get_color("text_editor/theme/brace_mismatch_color", "Editor"); + current_line_color = tm->get_color("text_editor/theme/current_line_color", "Editor"); + line_length_guideline_color = tm->get_color("text_editor/theme/line_length_guideline_color", "Editor"); + word_highlighted_color = tm->get_color("text_editor/theme/word_highlighted_color", "Editor"); + number_color = tm->get_color("text_editor/theme/number_color", "Editor"); + function_color = tm->get_color("text_editor/theme/function_color", "Editor"); + member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor"); + mark_color = tm->get_color("text_editor/theme/mark_color", "Editor"); + breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor"); + search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor"); + search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor"); + } + + text_edit->add_color_override("background_color", background_color); + text_edit->add_color_override("completion_background_color", completion_background_color); + text_edit->add_color_override("completion_selected_color", completion_selected_color); + text_edit->add_color_override("completion_existing_color", completion_existing_color); + text_edit->add_color_override("completion_scroll_color", completion_scroll_color); + text_edit->add_color_override("completion_font_color", completion_font_color); + text_edit->add_color_override("font_color", text_color); + text_edit->add_color_override("line_number_color", line_number_color); + text_edit->add_color_override("caret_color", caret_color); + text_edit->add_color_override("caret_background_color", caret_background_color); + text_edit->add_color_override("font_selected_color", text_selected_color); + text_edit->add_color_override("selection_color", selection_color); + text_edit->add_color_override("brace_mismatch_color", brace_mismatch_color); + text_edit->add_color_override("current_line_color", current_line_color); + text_edit->add_color_override("line_length_guideline_color", line_length_guideline_color); + text_edit->add_color_override("word_highlighted_color", word_highlighted_color); + text_edit->add_color_override("number_color", number_color); + text_edit->add_color_override("function_color", function_color); + text_edit->add_color_override("member_variable_color", member_variable_color); + text_edit->add_color_override("mark_color", mark_color); + text_edit->add_color_override("breakpoint_color", breakpoint_color); + text_edit->add_color_override("search_result_color", search_result_color); + text_edit->add_color_override("search_result_border_color", search_result_border_color); + text_edit->add_color_override("symbol_color", symbol_color); + + text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); List<String> keywords; script->get_language()->get_reserved_words(&keywords); @@ -113,8 +176,6 @@ void ScriptTextEditor::_load_theme_settings() { } //colorize core types - Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0)); - text_edit->add_keyword_color("String", basetype_color); text_edit->add_keyword_color("Vector2", basetype_color); text_edit->add_keyword_color("Rect2", basetype_color); @@ -140,8 +201,6 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_keyword_color("PoolColorArray", basetype_color); //colorize engine types - Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4)); - List<StringName> types; ClassDB::get_class_list(&types); @@ -155,7 +214,6 @@ void ScriptTextEditor::_load_theme_settings() { } //colorize comments - Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff)); List<String> comments; script->get_language()->get_comment_delimiters(&comments); @@ -169,7 +227,6 @@ void ScriptTextEditor::_load_theme_settings() { } //colorize strings - Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff)); List<String> strings; script->get_language()->get_string_delimiters(&strings); @@ -209,6 +266,7 @@ void ScriptTextEditor::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { //emit_signal("name_changed"); + _load_theme_settings(); } } @@ -492,8 +550,6 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { script = p_script; - _load_theme_settings(); - code_editor->get_text_edit()->set_text(script->get_source_code()); code_editor->get_text_edit()->clear_undo_history(); code_editor->get_text_edit()->tag_saved_version(); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 1b02f18d85..b0ee1a32ca 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -60,33 +60,96 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->clear_colors(); - /* keyword color */ - - get_text_edit()->add_color_override("background_color", EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0))); - get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0))); - get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244"))); - get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf"))); - get_text_edit()->add_color_override("completion_scroll_color", EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff"))); - get_text_edit()->add_color_override("completion_font_color", EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa"))); - get_text_edit()->add_color_override("font_color", EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0))); - get_text_edit()->add_color_override("line_number_color", EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0))); - get_text_edit()->add_color_override("caret_color", EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0))); - get_text_edit()->add_color_override("caret_background_color", EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0))); - get_text_edit()->add_color_override("font_selected_color", EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1))); - get_text_edit()->add_color_override("selection_color", EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1))); - get_text_edit()->add_color_override("brace_mismatch_color", EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2))); - get_text_edit()->add_color_override("current_line_color", EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15))); - get_text_edit()->add_color_override("word_highlighted_color", EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15))); - get_text_edit()->add_color_override("number_color", EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2))); - get_text_edit()->add_color_override("function_color", EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8))); - get_text_edit()->add_color_override("member_variable_color", EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3))); - get_text_edit()->add_color_override("mark_color", EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4))); - get_text_edit()->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2))); - get_text_edit()->add_color_override("search_result_color", EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1))); - get_text_edit()->add_color_override("search_result_border_color", EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1))); - get_text_edit()->add_color_override("symbol_color", EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff))); + Color background_color = EDITOR_DEF("text_editor/highlighting/background_color", Color(0, 0, 0, 0)); + Color completion_background_color = EDITOR_DEF("text_editor/highlighting/completion_background_color", Color(0, 0, 0, 0)); + Color completion_selected_color = EDITOR_DEF("text_editor/highlighting/completion_selected_color", Color::html("434244")); + Color completion_existing_color = EDITOR_DEF("text_editor/highlighting/completion_existing_color", Color::html("21dfdfdf")); + Color completion_scroll_color = EDITOR_DEF("text_editor/highlighting/completion_scroll_color", Color::html("ffffff")); + Color completion_font_color = EDITOR_DEF("text_editor/highlighting/completion_font_color", Color::html("aaaaaa")); + Color text_color = EDITOR_DEF("text_editor/highlighting/text_color", Color(0, 0, 0)); + Color line_number_color = EDITOR_DEF("text_editor/highlighting/line_number_color", Color(0, 0, 0)); + Color caret_color = EDITOR_DEF("text_editor/highlighting/caret_color", Color(0, 0, 0)); + Color caret_background_color = EDITOR_DEF("text_editor/highlighting/caret_background_color", Color(0, 0, 0)); + Color text_selected_color = EDITOR_DEF("text_editor/highlighting/text_selected_color", Color(1, 1, 1)); + Color selection_color = EDITOR_DEF("text_editor/highlighting/selection_color", Color(0.2, 0.2, 1)); + Color brace_mismatch_color = EDITOR_DEF("text_editor/highlighting/brace_mismatch_color", Color(1, 0.2, 0.2)); + Color current_line_color = EDITOR_DEF("text_editor/highlighting/current_line_color", Color(0.3, 0.5, 0.8, 0.15)); + Color line_length_guideline_color = EDITOR_DEF("text_editor/highlighting/line_length_guideline_color", Color(0, 0, 0)); + Color word_highlighted_color = EDITOR_DEF("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)); + Color number_color = EDITOR_DEF("text_editor/highlighting/number_color", Color(0.9, 0.6, 0.0, 2)); + Color function_color = EDITOR_DEF("text_editor/highlighting/function_color", Color(0.4, 0.6, 0.8)); + Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)); + Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); + Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); + Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); + Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)); Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2)); + Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0)); + Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4)); + Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff)); + Color string_color = EDITOR_DEF("text_editor/highlighting/string_color", Color::hex(0x6b6f00ff)); + + // Adapt + if (EditorSettings::get_singleton()->get("text_editor/theme/color_theme") == "Adaptive") { + Ref<Theme> tm = EditorNode::get_singleton()->get_theme_base()->get_theme(); + + symbol_color = tm->get_color("text_editor/theme/symbol_color", "Editor"); + keyword_color = tm->get_color("text_editor/theme/keyword_color", "Editor"); + basetype_color = tm->get_color("text_editor/theme/basetype_color", "Editor"); + type_color = tm->get_color("text_editor/theme/type_color", "Editor"); + comment_color = tm->get_color("text_editor/theme/comment_color", "Editor"); + string_color = tm->get_color("text_editor/theme/string_color", "Editor"); + background_color = tm->get_color("text_editor/theme/background_color", "Editor"); + completion_background_color = tm->get_color("text_editor/theme/completion_background_color", "Editor"); + completion_selected_color = tm->get_color("text_editor/theme/completion_selected_color", "Editor"); + completion_existing_color = tm->get_color("text_editor/theme/completion_existing_color", "Editor"); + completion_scroll_color = tm->get_color("text_editor/theme/completion_scroll_color", "Editor"); + completion_font_color = tm->get_color("text_editor/theme/completion_font_color", "Editor"); + text_color = tm->get_color("text_editor/theme/text_color", "Editor"); + line_number_color = tm->get_color("text_editor/theme/line_number_color", "Editor"); + caret_color = tm->get_color("text_editor/theme/caret_color", "Editor"); + caret_background_color = tm->get_color("text_editor/theme/caret_background_color", "Editor"); + text_selected_color = tm->get_color("text_editor/theme/text_selected_color", "Editor"); + selection_color = tm->get_color("text_editor/theme/selection_color", "Editor"); + brace_mismatch_color = tm->get_color("text_editor/theme/brace_mismatch_color", "Editor"); + current_line_color = tm->get_color("text_editor/theme/current_line_color", "Editor"); + line_length_guideline_color = tm->get_color("text_editor/theme/line_length_guideline_color", "Editor"); + word_highlighted_color = tm->get_color("text_editor/theme/word_highlighted_color", "Editor"); + number_color = tm->get_color("text_editor/theme/number_color", "Editor"); + function_color = tm->get_color("text_editor/theme/function_color", "Editor"); + member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor"); + mark_color = tm->get_color("text_editor/theme/mark_color", "Editor"); + breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor"); + search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor"); + search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor"); + } + + get_text_edit()->add_color_override("background_color", background_color); + get_text_edit()->add_color_override("completion_background_color", completion_background_color); + get_text_edit()->add_color_override("completion_selected_color", completion_selected_color); + get_text_edit()->add_color_override("completion_existing_color", completion_existing_color); + get_text_edit()->add_color_override("completion_scroll_color", completion_scroll_color); + get_text_edit()->add_color_override("completion_font_color", completion_font_color); + get_text_edit()->add_color_override("font_color", text_color); + get_text_edit()->add_color_override("line_number_color", line_number_color); + get_text_edit()->add_color_override("caret_color", caret_color); + get_text_edit()->add_color_override("caret_background_color", caret_background_color); + get_text_edit()->add_color_override("font_selected_color", text_selected_color); + get_text_edit()->add_color_override("selection_color", selection_color); + get_text_edit()->add_color_override("brace_mismatch_color", brace_mismatch_color); + get_text_edit()->add_color_override("current_line_color", current_line_color); + get_text_edit()->add_color_override("line_length_guideline_color", line_length_guideline_color); + get_text_edit()->add_color_override("word_highlighted_color", word_highlighted_color); + get_text_edit()->add_color_override("number_color", number_color); + get_text_edit()->add_color_override("function_color", function_color); + get_text_edit()->add_color_override("member_variable_color", member_variable_color); + get_text_edit()->add_color_override("mark_color", mark_color); + get_text_edit()->add_color_override("breakpoint_color", breakpoint_color); + get_text_edit()->add_color_override("search_result_color", search_result_color); + get_text_edit()->add_color_override("search_result_border_color", search_result_border_color); + get_text_edit()->add_color_override("symbol_color", symbol_color); List<String> keywords; ShaderLanguage::get_keyword_list(&keywords); @@ -115,8 +178,6 @@ void ShaderTextEditor::_load_theme_settings() { //Color basetype_color= EDITOR_DEF("text_editor/base_type_color",Color(0.3,0.3,0.0)); //colorize comments - Color comment_color = EDITOR_DEF("text_editor/highlighting/comment_color", Color::hex(0x797e7eff)); - get_text_edit()->add_color_region("/*", "*/", comment_color, false); get_text_edit()->add_color_region("//", "", comment_color, false); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index dbeb1bc202..a6ab36ed27 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -76,18 +76,29 @@ void SpatialEditorViewport::_update_camera(float p_interp_delta) { } else camera->set_perspective(get_fov(), get_znear(), get_zfar()); - float inertia = EDITOR_DEF("editors/3d/orbit_inertia", 0.5); - inertia = MAX(0, inertia); + //when not being manipulated, move softly + float free_orbit_inertia = EDITOR_DEF("editors/3d/free_orbit_inertia", 0.15); + float free_translation_inertia = EDITOR_DEF("editors/3d/free_translation_inertia", 0.15); + //when being manipulated, move more quickly + float manip_orbit_inertia = EDITOR_DEF("editors/3d/manipulation_orbit_inertia", 0.075); + float manip_translation_inertia = EDITOR_DEF("editors/3d/manipulation_translation_inertia", 0.075); + + //determine if being manipulated + bool manipulated = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL); + + float orbit_inertia = MAX(0.00001, manipulated ? manip_orbit_inertia : free_orbit_inertia); + float translation_inertia = MAX(0.0001, manipulated ? manip_translation_inertia : free_translation_inertia); Cursor old_camera_cursor = camera_cursor; camera_cursor = cursor; - camera_cursor.x_rot = Math::lerp(old_camera_cursor.x_rot, cursor.x_rot, p_interp_delta * (1 / inertia)); - camera_cursor.y_rot = Math::lerp(old_camera_cursor.y_rot, cursor.y_rot, p_interp_delta * (1 / inertia)); + camera_cursor.x_rot = Math::lerp(old_camera_cursor.x_rot, cursor.x_rot, MIN(1.f, p_interp_delta * (1 / orbit_inertia))); + camera_cursor.y_rot = Math::lerp(old_camera_cursor.y_rot, cursor.y_rot, MIN(1.f, p_interp_delta * (1 / orbit_inertia))); - bool disable_interp = (Input::get_singleton()->get_mouse_button_mask() & (2 | 4)) || Input::get_singleton()->is_key_pressed(KEY_SHIFT) || Input::get_singleton()->is_key_pressed(KEY_ALT) || Input::get_singleton()->is_key_pressed(KEY_CONTROL); + camera_cursor.pos = old_camera_cursor.pos.linear_interpolate(cursor.pos, MIN(1.f, p_interp_delta * (1 / translation_inertia))); + camera_cursor.distance = Math::lerp(old_camera_cursor.distance, cursor.distance, MIN(1.f, p_interp_delta * (1 / translation_inertia))); - if (p_interp_delta == 0 || disable_interp || is_freelook_active()) { + if (p_interp_delta == 0 || is_freelook_active()) { camera_cursor = cursor; } diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 43856116a6..b85ffd6c67 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -72,6 +72,14 @@ void TileMapEditor::_menu_option(int p_option) { switch (p_option) { + case OPTION_PAINTING: { + // NOTE: We do not set tool = TOOL_PAINTING as this begins painting + // immediately without pressing the left mouse button first + tool = TOOL_NONE; + + canvas_item_editor->update(); + + } break; case OPTION_BUCKET: { tool = TOOL_BUCKET; @@ -703,7 +711,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } else { - + // Mousebutton was released if (tool != TOOL_NONE) { if (tool == TOOL_PAINTING) { @@ -801,6 +809,9 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(this, "_fill_points", points, pop); undo_redo->commit_action(); + + // We want to keep the bucket-tool active + return true; } tool = TOOL_NONE; @@ -1046,9 +1057,25 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } - if (tool != TOOL_NONE || !mouse_over) + if (!mouse_over) { + // Editor shortcuts should not fire if mouse not in viewport return false; + } + if (ED_IS_SHORTCUT("tile_map_editor/paint_tile", p_event)) { + // NOTE: We do not set tool = TOOL_PAINTING as this begins painting + // immediately without pressing the left mouse button first + tool = TOOL_NONE; + canvas_item_editor->update(); + + return true; + } + if (ED_IS_SHORTCUT("tile_map_editor/bucket_fill", p_event)) { + tool = TOOL_BUCKET; + canvas_item_editor->update(); + + return true; + } if (ED_IS_SHORTCUT("tile_map_editor/erase_selection", p_event)) { _menu_option(OPTION_ERASE_SELECTION); @@ -1458,7 +1485,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { ED_SHORTCUT("tile_map_editor/erase_selection", TTR("Erase selection"), KEY_DELETE); ED_SHORTCUT("tile_map_editor/find_tile", TTR("Find tile"), KEY_MASK_CMD + KEY_F); - ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose")); + ED_SHORTCUT("tile_map_editor/transpose", TTR("Transpose"), KEY_T); ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A); ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S); @@ -1512,7 +1539,8 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { PopupMenu *p = options->get_popup(); - p->add_item(TTR("Bucket"), OPTION_BUCKET); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P), OPTION_PAINTING); + p->add_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_G), OPTION_BUCKET); p->add_separator(); p->add_item(TTR("Pick Tile"), OPTION_PICK_TILE, KEY_CONTROL); p->add_separator(); diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index e863c4bf3d..de9b9e8e0d 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -68,7 +68,8 @@ class TileMapEditor : public VBoxContainer { OPTION_PICK_TILE, OPTION_SELECT, OPTION_DUPLICATE, - OPTION_ERASE_SELECTION + OPTION_ERASE_SELECTION, + OPTION_PAINTING, }; TileMap *node; diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index cca5e1f6a0..78d544fdcf 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -59,11 +59,13 @@ public: enum Mode { MODE_NEW, MODE_IMPORT, - MODE_INSTALL + MODE_INSTALL, + MODE_RENAME }; private: Mode mode; + Button *browse; Label *pp, *pn; Label *error; LineEdit *project_path; @@ -91,20 +93,20 @@ private: return ""; } - if (mode != MODE_IMPORT) { + if (mode == MODE_IMPORT || mode == MODE_RENAME) { - if (d->file_exists("project.godot")) { + if (valid_path != "" && !d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, project.godot must not exist.")); + error->set_text(TTR("Invalid project path, project.godot must exist.")); memdelete(d); return ""; } } else { - if (valid_path != "" && !d->file_exists("project.godot")) { + if (d->file_exists("project.godot")) { - error->set_text(TTR("Invalid project path, project.godot must exist.")); + error->set_text(TTR("Invalid project path, project.godot must not exist.")); memdelete(d); return ""; } @@ -172,6 +174,17 @@ private: void _text_changed(const String &p_text) { _test_path(); + error->set_text(""); + if (p_text == "") { + + error->set_text(TTR("Name cannot be empty")); + get_ok()->set_disabled(true); + return; + } + get_ok()->set_disabled(false); + } + + void _name_changed(const String &p_text) { } void ok_pressed() { @@ -182,138 +195,165 @@ private: return; } - if (mode == MODE_IMPORT) { - // nothing to do + if (mode == MODE_RENAME) { + + String dir = _test_path(); + if (dir == "") { + error->set_text(TTR("Invalid project path (changed anything?).")); + return; + } + + ProjectSettings *current = memnew(ProjectSettings); + current->add_singleton(ProjectSettings::Singleton("Current")); + + if (current->setup(dir, "")) { + error->set_text(TTR("Couldn't get project.godot in project path.")); + } else { + ProjectSettings::CustomMap edited_settings; + edited_settings["application/config/name"] = project_name->get_text(); + + if (current->save_custom(dir.plus_file("/project.godot"), edited_settings, Vector<String>(), true)) { + error->set_text(TTR("Couldn't edit project.godot in project path.")); + } + } + + hide(); + emit_signal("project_renamed"); } else { - if (mode == MODE_NEW) { - ProjectSettings::CustomMap initial_settings; - initial_settings["application/config/name"] = project_name->get_text(); - initial_settings["application/config/icon"] = "res://icon.png"; - initial_settings["rendering/environment/default_environment"] = "res://default_env.tres"; + if (mode == MODE_IMPORT) { + // nothing to do + } else { + if (mode == MODE_NEW) { - if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("/project.godot"), initial_settings, Vector<String>(), false)) { - error->set_text(TTR("Couldn't create project.godot in project path.")); - } else { - ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); + ProjectSettings::CustomMap initial_settings; + initial_settings["application/config/name"] = project_name->get_text(); + initial_settings["application/config/icon"] = "res://icon.png"; + initial_settings["rendering/environment/default_environment"] = "res://default_env.tres"; - FileAccess *f = FileAccess::open(dir.plus_file("/default_env.tres"), FileAccess::WRITE); - if (!f) { + if (ProjectSettings::get_singleton()->save_custom(dir.plus_file("/project.godot"), initial_settings, Vector<String>(), false)) { error->set_text(TTR("Couldn't create project.godot in project path.")); } 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("[resource]"); - f->store_line("background_mode = 2"); - f->store_line("background_sky = SubResource( 1 )"); - memdelete(f); + ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); + + FileAccess *f = FileAccess::open(dir.plus_file("/default_env.tres"), FileAccess::WRITE); + if (!f) { + error->set_text(TTR("Couldn't create project.godot in project path.")); + } 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("[resource]"); + f->store_line("background_mode = 2"); + f->store_line("background_sky = SubResource( 1 )"); + memdelete(f); + } } - } - } else if (mode == MODE_INSTALL) { + } else if (mode == MODE_INSTALL) { - FileAccess *src_f = NULL; - zlib_filefunc_def io = zipio_create_io_from_file(&src_f); + FileAccess *src_f = NULL; + zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); - if (!pkg) { + unzFile pkg = unzOpen2(zip_path.utf8().get_data(), &io); + if (!pkg) { - dialog_error->set_text(TTR("Error opening package file, not in zip format.")); - return; - } + dialog_error->set_text(TTR("Error opening package file, not in zip format.")); + return; + } - int ret = unzGoToFirstFile(pkg); + int ret = unzGoToFirstFile(pkg); - Vector<String> failed_files; + Vector<String> failed_files; - int idx = 0; - while (ret == UNZ_OK) { + int idx = 0; + while (ret == UNZ_OK) { - //get filename - unz_file_info info; - char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + //get filename + unz_file_info info; + char fname[16384]; + ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); - String path = fname; + String path = fname; - int depth = 1; //stuff from github comes with tag - bool skip = false; - while (depth > 0) { - int pp = path.find("/"); - if (pp == -1) { - skip = true; - break; + int depth = 1; //stuff from github comes with tag + bool skip = false; + while (depth > 0) { + int pp = path.find("/"); + if (pp == -1) { + skip = true; + break; + } + path = path.substr(pp + 1, path.length()); + depth--; } - path = path.substr(pp + 1, path.length()); - depth--; - } - if (skip || path == String()) { - // - } else if (path.ends_with("/")) { // a dir + if (skip || path == String()) { + // + } else if (path.ends_with("/")) { // a dir - path = path.substr(0, path.length() - 1); + path = path.substr(0, path.length() - 1); - DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - da->make_dir(dir.plus_file(path)); - memdelete(da); + DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + da->make_dir(dir.plus_file(path)); + memdelete(da); - } else { + } else { - Vector<uint8_t> data; - data.resize(info.uncompressed_size); + Vector<uint8_t> data; + data.resize(info.uncompressed_size); - //read - unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); - unzCloseCurrentFile(pkg); + //read + unzOpenCurrentFile(pkg); + unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzCloseCurrentFile(pkg); - FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE); + FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE); - if (f) { - f->store_buffer(data.ptr(), data.size()); - memdelete(f); - } else { - failed_files.push_back(path); + if (f) { + f->store_buffer(data.ptr(), data.size()); + memdelete(f); + } else { + failed_files.push_back(path); + } } - } - idx++; - ret = unzGoToNextFile(pkg); - } + idx++; + ret = unzGoToNextFile(pkg); + } - unzClose(pkg); + unzClose(pkg); - if (failed_files.size()) { - String msg = TTR("The following files failed extraction from package:") + "\n\n"; - for (int i = 0; i < failed_files.size(); i++) { + if (failed_files.size()) { + String msg = TTR("The following files failed extraction from package:") + "\n\n"; + for (int i = 0; i < failed_files.size(); i++) { - if (i > 15) { - msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; - break; + if (i > 15) { + msg += "\nAnd " + itos(failed_files.size() - i) + " more files."; + break; + } + msg += failed_files[i] + "\n"; } - msg += failed_files[i] + "\n"; - } - dialog_error->set_text(msg); - dialog_error->popup_centered_minsize(); + dialog_error->set_text(msg); + dialog_error->popup_centered_minsize(); - } else { - dialog_error->set_text(TTR("Package Installed Successfully!")); - dialog_error->popup_centered_minsize(); + } else { + dialog_error->set_text(TTR("Package Installed Successfully!")); + dialog_error->popup_centered_minsize(); + } } } - } - dir = dir.replace("\\", "/"); - if (dir.ends_with("/")) - dir = dir.substr(0, dir.length() - 1); - String proj = dir.replace("/", "::"); - EditorSettings::get_singleton()->set("projects/" + proj, dir); - EditorSettings::get_singleton()->save(); + dir = dir.replace("\\", "/"); + if (dir.ends_with("/")) + dir = dir.substr(0, dir.length() - 1); + String proj = dir.replace("/", "::"); + EditorSettings::get_singleton()->set("projects/" + proj, dir); + EditorSettings::get_singleton()->save(); - hide(); - emit_signal("project_created", dir); + hide(); + emit_signal("project_created", dir); + } } protected: @@ -325,6 +365,7 @@ protected: ClassDB::bind_method("_path_selected", &NewProjectDialog::_path_selected); ClassDB::bind_method("_file_selected", &NewProjectDialog::_file_selected); ADD_SIGNAL(MethodInfo("project_created")); + ADD_SIGNAL(MethodInfo("project_renamed")); } public: @@ -340,44 +381,85 @@ public: mode = p_mode; } - void show_dialog() { - - project_path->clear(); - project_name->clear(); + void set_project_path(const String &p_path) { + project_path->set_text(p_path); + } - if (mode == MODE_IMPORT) { - set_title(TTR("Import Existing Project")); - get_ok()->set_text(TTR("Import")); - pp->set_text(TTR("Project Path (Must Exist):")); - pn->set_text(TTR("Project Name:")); - pn->hide(); - project_name->hide(); + void show_dialog() { - popup_centered(Size2(500, 125) * EDSCALE); + if (mode == MODE_RENAME) { - } else if (mode == MODE_NEW) { + project_path->set_editable(false); + browse->set_disabled(true); - set_title(TTR("Create New Project")); - get_ok()->set_text(TTR("Create")); + set_title(TTR("Rename Project")); + get_ok()->set_text(TTR("Rename")); pp->set_text(TTR("Project Path:")); pn->set_text(TTR("Project Name:")); pn->show(); project_name->show(); - popup_centered(Size2(500, 145) * EDSCALE); - } else if (mode == MODE_INSTALL) { + String dir = _test_path(); + if (dir == "") { + error->set_text(TTR("Invalid project path (changed anything?).")); + return; + } + ProjectSettings *current = memnew(ProjectSettings); + current->add_singleton(ProjectSettings::Singleton("Current")); - set_title(TTR("Install Project:") + " " + zip_title); - get_ok()->set_text(TTR("Install")); - pp->set_text(TTR("Project Path:")); - pn->hide(); - project_name->hide(); + if (current->setup(dir, "")) { + error->set_text(TTR("Couldn't get project.godot in project path.")); + } else { + if (current->has("application/config/name")) { + String appname = current->get("application/config/name"); + project_name->set_text(appname); + } + } popup_centered(Size2(500, 125) * EDSCALE); - } - project_path->grab_focus(); + project_name->grab_focus(); - _test_path(); + } else { + + project_path->clear(); + project_name->clear(); + project_path->set_editable(true); + browse->set_disabled(false); + + if (mode == MODE_IMPORT) { + set_title(TTR("Import Existing Project")); + get_ok()->set_text(TTR("Import")); + pp->set_text(TTR("Project Path (Must Exist):")); + pn->set_text(TTR("Project Name:")); + pn->hide(); + project_name->hide(); + + popup_centered(Size2(500, 125) * EDSCALE); + + } else if (mode == MODE_NEW) { + + set_title(TTR("Create New Project")); + get_ok()->set_text(TTR("Create")); + pp->set_text(TTR("Project Path:")); + pn->set_text(TTR("Project Name:")); + pn->show(); + project_name->show(); + + popup_centered(Size2(500, 145) * EDSCALE); + } else if (mode == MODE_INSTALL) { + + set_title(TTR("Install Project:") + " " + zip_title); + get_ok()->set_text(TTR("Install")); + pp->set_text(TTR("Project Path:")); + pn->hide(); + project_name->hide(); + + popup_centered(Size2(500, 125) * EDSCALE); + } + project_path->grab_focus(); + + _test_path(); + } } NewProjectDialog() { @@ -399,7 +481,7 @@ public: pphb->add_child(project_path); project_path->set_h_size_flags(SIZE_EXPAND_FILL); - Button *browse = memnew(Button); + browse = memnew(Button); pphb->add_child(browse); browse->set_text(TTR("Browse")); browse->connect("pressed", this, "_browse_path"); @@ -495,6 +577,7 @@ void ProjectManager::_update_project_buttons() { erase_btn->set_disabled(selected_list.size() < 1); open_btn->set_disabled(selected_list.size() < 1); + rename_btn->set_disabled(selected_list.size() < 1); } void ProjectManager::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { @@ -889,6 +972,10 @@ void ProjectManager::_load_recent_projects() { tabs->set_current_tab(0); } +void ProjectManager::_on_project_renamed() { + _load_recent_projects(); +} + void ProjectManager::_on_project_created(const String &dir) { bool has_already = false; for (int i = 0; i < scroll_childs->get_child_count(); i++) { @@ -1091,6 +1178,21 @@ void ProjectManager::_import_project() { npdialog->show_dialog(); } +void ProjectManager::_rename_project() { + + if (selected_list.size() == 0) { + return; + } + + for (Map<String, String>::Element *E = selected_list.front(); E; E = E->next()) { + const String &selected = E->key(); + String path = EditorSettings::get_singleton()->get("projects/" + selected); + npdialog->set_project_path(path); + npdialog->set_mode(NewProjectDialog::MODE_RENAME); + npdialog->show_dialog(); + } +} + void ProjectManager::_erase_project_confirm() { if (selected_list.size() == 0) { @@ -1185,10 +1287,12 @@ void ProjectManager::_bind_methods() { ClassDB::bind_method("_scan_begin", &ProjectManager::_scan_begin); ClassDB::bind_method("_import_project", &ProjectManager::_import_project); ClassDB::bind_method("_new_project", &ProjectManager::_new_project); + ClassDB::bind_method("_rename_project", &ProjectManager::_rename_project); ClassDB::bind_method("_erase_project", &ProjectManager::_erase_project); ClassDB::bind_method("_erase_project_confirm", &ProjectManager::_erase_project_confirm); ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog); ClassDB::bind_method("_load_recent_projects", &ProjectManager::_load_recent_projects); + ClassDB::bind_method("_on_project_renamed", &ProjectManager::_on_project_renamed); ClassDB::bind_method("_on_project_created", &ProjectManager::_on_project_created); ClassDB::bind_method("_update_scroll_pos", &ProjectManager::_update_scroll_pos); ClassDB::bind_method("_panel_draw", &ProjectManager::_panel_draw); @@ -1349,6 +1453,12 @@ ProjectManager::ProjectManager() { tree_vb->add_child(import); import->connect("pressed", this, "_import_project"); + Button *rename = memnew(Button); + rename->set_text(TTR("Rename")); + tree_vb->add_child(rename); + rename->connect("pressed", this, "_rename_project"); + rename_btn = rename; + Button *erase = memnew(Button); erase->set_text(TTR("Remove")); tree_vb->add_child(erase); @@ -1404,6 +1514,7 @@ ProjectManager::ProjectManager() { npdialog = memnew(NewProjectDialog); gui_base->add_child(npdialog); + npdialog->connect("project_renamed", this, "_on_project_renamed"); npdialog->connect("project_created", this, "_on_project_created"); _load_recent_projects(); diff --git a/editor/project_manager.h b/editor/project_manager.h index 9fcf10a0d9..67fe0b503f 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -45,6 +45,7 @@ class ProjectManager : public Control { Button *erase_btn; Button *open_btn; + Button *rename_btn; Button *run_btn; FileDialog *scan_dir; @@ -79,6 +80,7 @@ class ProjectManager : public Control { void _open_project_confirm(); void _import_project(); void _new_project(); + void _rename_project(); void _erase_project(); void _erase_project_confirm(); void _update_project_buttons(); @@ -87,6 +89,7 @@ class ProjectManager : public Control { void _load_recent_projects(); void _on_project_created(const String &dir); + void _on_project_renamed(); void _update_scroll_pos(const String &dir); void _scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index c7a4e1fc3b..b7300b9610 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -861,13 +861,13 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: menu->add_separator(); } - menu->add_icon_item(get_icon("Load", "EditorIcons"), "Load", OBJ_MENU_LOAD); + menu->add_icon_item(get_icon("Load", "EditorIcons"), TTR("Load"), OBJ_MENU_LOAD); if (!RES(v).is_null()) { - menu->add_icon_item(get_icon("Edit", "EditorIcons"), "Edit", OBJ_MENU_EDIT); - menu->add_icon_item(get_icon("Clear", "EditorIcons"), "Clear", OBJ_MENU_CLEAR); - menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), "Make Unique", OBJ_MENU_MAKE_UNIQUE); + menu->add_icon_item(get_icon("Edit", "EditorIcons"), TTR("Edit"), OBJ_MENU_EDIT); + menu->add_icon_item(get_icon("Clear", "EditorIcons"), TTR("Clear"), OBJ_MENU_CLEAR); + menu->add_icon_item(get_icon("Duplicate", "EditorIcons"), TTR("Make Unique"), OBJ_MENU_MAKE_UNIQUE); RES r = v; if (r.is_valid() && r->get_path().is_resource_file()) { menu->add_separator(); diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index b92ebed167..4bcbe073ee 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -189,7 +189,7 @@ Vector<Pair<String, Ref<Texture> > > EditorQuickOpen::_sort_fs(Vector<Pair<Strin Vector<Pair<String, Ref<Texture> > > sorted_list; if (search_text == String() || list.size() == 0) - return sorted_list; + return list; Vector<float> scores; scores.resize(list.size()); diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index 6cb5f0a70c..64ac2535a9 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -150,7 +150,7 @@ class ScriptEditorDebugger : public Control { void _scene_tree_selected(); void _scene_tree_request(); void _parse_message(const String &p_msg, const Array &p_data); - void _set_reason_text(const String &p_msg, MessageType p_type); + void _set_reason_text(const String &p_reason, MessageType p_type); void _scene_tree_property_select_object(ObjectID p_object); void _scene_tree_property_value_edited(const String &p_prop, const Variant &p_value); |