diff options
Diffstat (limited to 'editor')
60 files changed, 1338 insertions, 707 deletions
diff --git a/editor/SCsub b/editor/SCsub index f0d378c097..fd56c9d772 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -268,6 +268,8 @@ def make_license_header(target, source, env): tp_license = "" tp_current = 0 + tp_licensetext.append([tp_licensename, tp_licensebody]) + about_thirdparty = "" about_tp_copyright_count = "" about_tp_license = "" diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 1798e66e8a..45da365695 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -3774,6 +3774,7 @@ AnimationKeyEditor::AnimationKeyEditor() { zoom->set_max(2.0); zoom->set_value(1.0); zoom->set_h_size_flags(SIZE_EXPAND_FILL); + zoom->set_v_size_flags(SIZE_EXPAND_FILL); zoom->set_stretch_ratio(2); hb->add_child(zoom); zoom->connect("value_changed", this, "_scroll_changed"); diff --git a/editor/asset_library_editor_plugin.cpp b/editor/asset_library_editor_plugin.cpp index 27d468bc25..74e21b31ea 100644 --- a/editor/asset_library_editor_plugin.cpp +++ b/editor/asset_library_editor_plugin.cpp @@ -1228,8 +1228,8 @@ void EditorAssetLibrary::_asset_open() { void EditorAssetLibrary::_manage_plugins() { - ProjectSettings::get_singleton()->popup_project_settings(); - ProjectSettings::get_singleton()->set_plugins_page(); + ProjectSettingsEditor::get_singleton()->popup_project_settings(); + ProjectSettingsEditor::get_singleton()->set_plugins_page(); } void EditorAssetLibrary::_install_external_asset(String p_zip_path, String p_title) { diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp index 2f234c441a..ab1e397ccc 100644 --- a/editor/collada/collada.cpp +++ b/editor/collada/collada.cpp @@ -306,7 +306,7 @@ void Collada::_parse_image(XMLParser &parser) { String path = parser.get_attribute_value("source").strip_edges(); if (path.find("://") == -1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path - image.path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path.percent_decode()); + image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path.percent_decode()); } } else { @@ -323,11 +323,11 @@ void Collada::_parse_image(XMLParser &parser) { if (path.find("://") == -1 && path.is_rel_path()) { // path is relative to file being loaded, so convert to a resource path - path = GlobalConfig::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path); + path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir() + "/" + path); } else if (path.find("file:///") == 0) { path = path.replace_first("file:///", ""); - path = GlobalConfig::get_singleton()->localize_path(path); + path = ProjectSettings::get_singleton()->localize_path(path); } image.path = path; @@ -2556,7 +2556,7 @@ Error Collada::load(const String &p_path, int p_flags) { Error err = parser.open(p_path); ERR_FAIL_COND_V(err, err); - state.local_path = GlobalConfig::get_singleton()->localize_path(p_path); + state.local_path = ProjectSettings::get_singleton()->localize_path(p_path); state.import_flags = p_flags; /* Skip headers */ err = OK; diff --git a/editor/collada/collada.h b/editor/collada/collada.h index ca60c392dd..38e66a7e45 100644 --- a/editor/collada/collada.h +++ b/editor/collada/collada.h @@ -32,7 +32,7 @@ #ifndef COLLADA_H #define COLLADA_H -#include "global_config.h" +#include "project_settings.h" #include "io/xml_parser.h" #include "map.h" #include "scene/resources/material.h" diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 6a79f99354..fa90cd36b3 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "doc_data.h" -#include "global_config.h" +#include "project_settings.h" #include "global_constants.h" #include "io/compression.h" #include "io/marshalls.h" @@ -568,14 +568,14 @@ void DocData::generate(bool p_basic_types) { c.constants.push_back(cd); } - List<GlobalConfig::Singleton> singletons; - GlobalConfig::get_singleton()->get_singletons(&singletons); + List<ProjectSettings::Singleton> singletons; + ProjectSettings::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List<GlobalConfig::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) { PropertyDoc pd; - GlobalConfig::Singleton &s = E->get(); + ProjectSettings::Singleton &s = E->get(); pd.name = s.name; pd.type = s.ptr->get_class(); while (String(ClassDB::get_parent_class(pd.type)) != "Object") diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index b83ac69141..399c22bf2c 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -30,7 +30,7 @@ #include "editor_autoload_settings.h" #include "editor_node.h" -#include "global_config.h" +#include "project_settings.h" #include "global_constants.h" #define PREVIEW_LIST_MAX_SIZE 10 @@ -115,12 +115,12 @@ void EditorAutoloadSettings::_autoload_add() { UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); undo_redo->create_action(TTR("Add AutoLoad")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), name, "*" + path); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path); - if (GlobalConfig::get_singleton()->has(name)) { - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name)); + if (ProjectSettings::get_singleton()->has(name)) { + undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); } else { - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, Variant()); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant()); } undo_redo->add_do_method(this, "update_autoload"); @@ -169,7 +169,7 @@ void EditorAutoloadSettings::_autoload_edited() { return; } - if (GlobalConfig::get_singleton()->has("autoload/" + name)) { + if (ProjectSettings::get_singleton()->has("autoload/" + name)) { ti->set_text(0, old_name); EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name)); return; @@ -179,18 +179,18 @@ void EditorAutoloadSettings::_autoload_edited() { name = "autoload/" + name; - int order = GlobalConfig::get_singleton()->get_order(selected_autoload); - String path = GlobalConfig::get_singleton()->get(selected_autoload); + int order = ProjectSettings::get_singleton()->get_order(selected_autoload); + String path = ProjectSettings::get_singleton()->get(selected_autoload); undo_redo->create_action(TTR("Rename Autoload")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), name, path); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", name, order); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", selected_autoload); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, path); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", selected_autoload); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), selected_autoload, path); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", selected_autoload, order); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", name); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), selected_autoload, path); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_autoload, order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name); undo_redo->add_do_method(this, "update_autoload"); undo_redo->add_undo_method(this, "update_autoload"); @@ -207,8 +207,8 @@ void EditorAutoloadSettings::_autoload_edited() { bool checked = ti->is_checked(2); String base = "autoload/" + ti->get_text(0); - int order = GlobalConfig::get_singleton()->get_order(base); - String path = GlobalConfig::get_singleton()->get(base); + int order = ProjectSettings::get_singleton()->get_order(base); + String path = ProjectSettings::get_singleton()->get(base); if (path.begins_with("*")) path = path.substr(1, path.length()); @@ -218,11 +218,11 @@ void EditorAutoloadSettings::_autoload_edited() { undo_redo->create_action(TTR("Toggle AutoLoad Globals")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), base, path); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), base, GlobalConfig::get_singleton()->get(base)); + undo_redo->add_do_property(ProjectSettings::get_singleton(), base, path); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), base, ProjectSettings::get_singleton()->get(base)); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", base, order); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", base, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", base, order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", base, order); undo_redo->add_do_method(this, "update_autoload"); undo_redo->add_undo_method(this, "update_autoload"); @@ -262,16 +262,16 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu String swap_name = "autoload/" + swap->get_text(0); - int order = GlobalConfig::get_singleton()->get_order(name); - int swap_order = GlobalConfig::get_singleton()->get_order(swap_name); + int order = ProjectSettings::get_singleton()->get_order(name); + int swap_order = ProjectSettings::get_singleton()->get_order(swap_name); undo_redo->create_action(TTR("Move Autoload")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", name, swap_order); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", name, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", name, swap_order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", name, order); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", swap_name, order); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", swap_name, swap_order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", swap_name, order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", swap_name, swap_order); undo_redo->add_do_method(this, "update_autoload"); undo_redo->add_undo_method(this, "update_autoload"); @@ -283,15 +283,15 @@ void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_colu } break; case BUTTON_DELETE: { - int order = GlobalConfig::get_singleton()->get_order(name); + int order = ProjectSettings::get_singleton()->get_order(name); undo_redo->create_action(TTR("Remove Autoload")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), name, Variant()); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, Variant()); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name)); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_persisting", name, true); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", order); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_persisting", name, true); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", order); undo_redo->add_do_method(this, "update_autoload"); undo_redo->add_undo_method(this, "update_autoload"); @@ -322,7 +322,7 @@ void EditorAutoloadSettings::update_autoload() { TreeItem *root = tree->create_item(); List<PropertyInfo> props; - GlobalConfig::get_singleton()->get_property_list(&props); + ProjectSettings::get_singleton()->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { @@ -332,14 +332,14 @@ void EditorAutoloadSettings::update_autoload() { continue; String name = pi.name.get_slice("/", 1); - String path = GlobalConfig::get_singleton()->get(pi.name); + String path = ProjectSettings::get_singleton()->get(pi.name); if (name.empty()) continue; AutoLoadInfo info; info.name = pi.name; - info.order = GlobalConfig::get_singleton()->get_order(pi.name); + info.order = ProjectSettings::get_singleton()->get_order(pi.name); autoload_cache.push_back(info); @@ -459,7 +459,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & move_to_back = true; } - int order = GlobalConfig::get_singleton()->get_order("autoload/" + name); + int order = ProjectSettings::get_singleton()->get_order("autoload/" + name); AutoLoadInfo aux; List<AutoLoadInfo>::Element *E = NULL; @@ -476,7 +476,7 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & orders.resize(autoload_cache.size()); for (int i = 0; i < autoloads.size(); i++) { - aux.order = GlobalConfig::get_singleton()->get_order("autoload/" + autoloads[i]); + aux.order = ProjectSettings::get_singleton()->get_order("autoload/" + autoloads[i]); List<AutoLoadInfo>::Element *I = autoload_cache.find(aux); @@ -506,8 +506,8 @@ void EditorAutoloadSettings::drop_data_fw(const Point2 &p_point, const Variant & i = 0; for (List<AutoLoadInfo>::Element *E = autoload_cache.front(); E; E = E->next()) { - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", E->get().name, orders[i++]); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", E->get().name, E->get().order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", E->get().name, orders[i++]); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", E->get().name, E->get().order); } orders.clear(); diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 58ffa223fb..f8dbd9abe5 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -31,7 +31,7 @@ #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -353,6 +353,7 @@ void EditorData::notify_edited_scene_changed() { for (int i = 0; i < editor_plugins.size(); i++) { editor_plugins[i]->edited_scene_changed(); + editor_plugins[i]->notify_scene_changed(get_edited_scene_root()); } } @@ -488,8 +489,14 @@ void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) { } void EditorData::remove_scene(int p_idx) { ERR_FAIL_INDEX(p_idx, edited_scene.size()); - if (edited_scene[p_idx].root) + if (edited_scene[p_idx].root) { + + for (int i = 0; i < editor_plugins.size(); i++) { + editor_plugins[i]->notify_scene_closed(edited_scene[p_idx].root->get_filename()); + } + memdelete(edited_scene[p_idx].root); + } if (current_edited_scene > p_idx) current_edited_scene--; @@ -615,6 +622,17 @@ int EditorData::get_edited_scene_count() const { return edited_scene.size(); } +Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const { + + Vector<EditedScene> out_edited_scenes_list = Vector<EditedScene>(); + + for (int i = 0; i < edited_scene.size(); i++) { + out_edited_scenes_list.push_back(edited_scene[i]); + } + + return out_edited_scenes_list; +} + void EditorData::set_edited_scene_version(uint64_t version, int scene_idx) { ERR_FAIL_INDEX(current_edited_scene, edited_scene.size()); if (scene_idx < 0) { diff --git a/editor/editor_data.h b/editor/editor_data.h index 50f0d5fd41..a601b5019d 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -31,6 +31,7 @@ #define EDITOR_DATA_H #include "editor/editor_plugin.h" +#include "editor/plugins/script_editor_plugin.h" #include "list.h" #include "pair.h" #include "scene/resources/texture.h" @@ -109,6 +110,17 @@ public: Ref<Texture> icon; }; + struct EditedScene { + Node *root; + Dictionary editor_states; + List<Node *> selection; + Vector<EditorHistory::History> history_stored; + int history_current; + Dictionary custom_state; + uint64_t version; + NodePath live_edit_root; + }; + private: Vector<EditorPlugin *> editor_plugins; @@ -124,17 +136,6 @@ private: void _cleanup_history(); - struct EditedScene { - Node *root; - Dictionary editor_states; - List<Node *> selection; - Vector<EditorHistory::History> history_stored; - int history_current; - Dictionary custom_state; - uint64_t version; - NodePath live_edit_root; - }; - Vector<EditedScene> edited_scene; int current_edited_scene; @@ -180,6 +181,7 @@ public: int get_edited_scene() const; Node *get_edited_scene_root(int p_idx = -1); int get_edited_scene_count() const; + Vector<EditedScene> get_edited_scenes() const; String get_scene_title(int p_idx) const; String get_scene_path(int p_idx) const; String get_scene_type(int p_idx) const; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 5cd00738a2..6bf92ddd2d 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -33,13 +33,13 @@ #include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" #include "io/config_file.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "io/zip_io.h" #include "os/dir_access.h" #include "os/file_access.h" +#include "project_settings.h" #include "script_language.h" #include "version.h" @@ -200,6 +200,17 @@ Vector<String> EditorExportPreset::get_patches() const { return patches; } +void EditorExportPreset::set_custom_features(const String &p_custom_features) { + + custom_features = p_custom_features; + EditorExport::singleton->save_presets(); +} + +String EditorExportPreset::get_custom_features() const { + + return custom_features; +} + EditorExportPreset::EditorExportPreset() { export_filter = EXPORT_ALL_RESOURCES; @@ -491,9 +502,23 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & //save config! - String config_file = "godot.cfb"; + Vector<String> custom_list; + + if (p_preset->get_custom_features() != String()) { + + Vector<String> tmp_custom_list = p_preset->get_custom_features().split(","); + + for (int i = 0; i < tmp_custom_list.size(); i++) { + String f = tmp_custom_list[i].strip_edges(); + if (f != String()) { + custom_list.push_back(f); + } + } + } + + String config_file = "project.binary"; String engine_cfb = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp" + config_file; - GlobalConfig::get_singleton()->save_custom(engine_cfb); + ProjectSettings::get_singleton()->save_custom(engine_cfb, ProjectSettings::CustomMap(), custom_list); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); p_func(p_udata, "res://" + config_file, data, idx, total); @@ -691,6 +716,7 @@ void EditorExport::_save() { config->set_value(section, "name", preset->get_name()); config->set_value(section, "platform", preset->get_platform()->get_name()); config->set_value(section, "runnable", preset->is_runnable()); + config->set_value(section, "custom_features", preset->get_custom_features()); bool save_files = false; switch (preset->get_export_filter()) { case EditorExportPreset::EXPORT_ALL_RESOURCES: { @@ -823,6 +849,10 @@ void EditorExport::load_config() { preset->set_name(config->get_value(section, "name")); preset->set_runnable(config->get_value(section, "runnable")); + if (config->has_section_key(section, "custom_features")) { + preset->set_custom_features(config->get_value(section, "custom_features")); + } + String export_filter = config->get_value(section, "export_filter"); bool get_files = false; @@ -931,6 +961,11 @@ String EditorExportPlatformPC::get_name() const { return name; } + +String EditorExportPlatformPC::get_os_name() const { + + return os_name; +} Ref<Texture> EditorExportPlatformPC::get_logo() const { return logo; @@ -1033,6 +1068,10 @@ void EditorExportPlatformPC::set_name(const String &p_name) { name = p_name; } +void EditorExportPlatformPC::set_os_name(const String &p_name) { + os_name = p_name; +} + void EditorExportPlatformPC::set_logo(const Ref<Texture> &p_logo) { logo = p_logo; } @@ -1055,6 +1094,20 @@ void EditorExportPlatformPC::set_debug_32(const String &p_file) { debug_file_32 = p_file; } +void EditorExportPlatformPC::add_platform_feature(const String &p_feature) { + + extra_features.insert(p_feature); +} + +void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { + r_features->push_back("pc"); //all pcs support "pc" + r_features->push_back("s3tc"); //all pcs support "s3tc" compression + r_features->push_back(get_os_name()); //OS name is a feature + for (Set<String>::Element *E = extra_features.front(); E; E = E->next()) { + r_features->push_back(E->get()); + } +} + EditorExportPlatformPC::EditorExportPlatformPC() { } @@ -1065,7 +1118,6 @@ EditorExportPlatformPC::EditorExportPlatformPC() { #include "editor/plugins/script_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" #include "io/config_file.h" #include "io/md5.h" #include "io/resource_loader.h" @@ -1074,14 +1126,15 @@ EditorExportPlatformPC::EditorExportPlatformPC() { #include "io_plugins/editor_texture_import_plugin.h" #include "os/dir_access.h" #include "os/file_access.h" +#include "project_settings.h" #include "script_language.h" #include "version.h" String EditorImportPlugin::validate_source_path(const String& p_path) { - String gp = GlobalConfig::get_singleton()->globalize_path(p_path); - String rp = GlobalConfig::get_singleton()->get_resource_path(); + String gp = ProjectSettings::get_singleton()->globalize_path(p_path); + String rp = ProjectSettings::get_singleton()->get_resource_path(); if (!rp.ends_with("/")) rp+="/"; @@ -1091,7 +1144,7 @@ String EditorImportPlugin::validate_source_path(const String& p_path) { String EditorImportPlugin::expand_source_path(const String& p_path) { if (p_path.is_rel_path()) { - return GlobalConfig::get_singleton()->get_resource_path().plus_file(p_path).simplify_path(); + return ProjectSettings::get_singleton()->get_resource_path().plus_file(p_path).simplify_path(); } else { return p_path; } @@ -1766,7 +1819,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func { MD5_CTX ctx; MD5Init(&ctx); - String path = GlobalConfig::get_singleton()->get_resource_path()+"::"+String(E->get())+"::"+get_name(); + String path = ProjectSettings::get_singleton()->get_resource_path()+"::"+String(E->get())+"::"+get_name(); MD5Update(&ctx,(unsigned char*)path.utf8().get_data(),path.utf8().length()); MD5Final(&ctx); md5 = String::md5(ctx.digest); @@ -1875,11 +1928,11 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func int flags=0; - if (GlobalConfig::get_singleton()->get("image_loader/filter")) + if (ProjectSettings::get_singleton()->get("image_loader/filter")) flags|=EditorTextureImportPlugin::IMAGE_FLAG_FILTER; - if (!GlobalConfig::get_singleton()->get("image_loader/gen_mipmaps")) + if (!ProjectSettings::get_singleton()->get("image_loader/gen_mipmaps")) flags|=EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS; - if (!GlobalConfig::get_singleton()->get("image_loader/repeat")) + if (!ProjectSettings::get_singleton()->get("image_loader/repeat")) flags|=EditorTextureImportPlugin::IMAGE_FLAG_REPEAT; flags|=EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA; @@ -1988,7 +2041,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func StringName engine_cfg="res://project.godot"; StringName boot_splash; { - String splash=GlobalConfig::get_singleton()->get("application/boot_splash"); //avoid splash from being converted + String splash=ProjectSettings::get_singleton()->get("application/boot_splash"); //avoid splash from being converted splash=splash.strip_edges(); if (splash!=String()) { if (!splash.begins_with("res://")) @@ -1999,7 +2052,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func } StringName custom_cursor; { - String splash=GlobalConfig::get_singleton()->get("display/custom_mouse_cursor"); //avoid splash from being converted + String splash=ProjectSettings::get_singleton()->get("display/custom_mouse_cursor"); //avoid splash from being converted splash=splash.strip_edges(); if (splash!=String()) { if (!splash.begins_with("res://")) @@ -2083,9 +2136,9 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func } - String remap_file="godot.cfb"; + String remap_file="project.binary"; String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+remap_file; - GlobalConfig::get_singleton()->save_custom(engine_cfb,custom); + ProjectSettings::get_singleton()->save_custom(engine_cfb,custom); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); Error err = p_func(p_udata,"res://"+remap_file,data,counter,files.size()); diff --git a/editor/editor_export.h b/editor/editor_export.h index 64381fbb35..dc4b198575 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -70,6 +70,8 @@ private: String name; + String custom_features; + protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; @@ -107,6 +109,9 @@ public: void remove_patch(int p_idx); Vector<String> get_patches() const; + void set_custom_features(const String &p_custom_features); + String get_custom_features() const; + const List<PropertyInfo> &get_properties() const { return properties; } EditorExportPreset(); @@ -153,12 +158,13 @@ private: static Error _save_zip_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total); protected: - virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0; bool exists_export_template(String template_file_name, String *err) const; String find_export_template(String template_file_name, String *err = NULL) const; void gen_export_flags(Vector<String> &r_flags, int p_flags); public: + virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) = 0; + struct ExportOption { PropertyInfo option; Variant default_value; @@ -175,6 +181,7 @@ public: virtual void get_export_options(List<ExportOption> *r_options) = 0; virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { return true; } + virtual String get_os_name() const = 0; virtual String get_name() const = 0; virtual Ref<Texture> get_logo() const = 0; @@ -203,6 +210,7 @@ public: virtual String get_binary_extension() const = 0; virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) = 0; + virtual void get_platform_features(List<String> *r_features) = 0; EditorExportPlatform(); }; @@ -253,6 +261,7 @@ class EditorExportPlatformPC : public EditorExportPlatform { Ref<ImageTexture> logo; String name; + String os_name; String extension; String release_file_32; @@ -260,6 +269,8 @@ class EditorExportPlatformPC : public EditorExportPlatform { String debug_file_32; String debug_file_64; + Set<String> extra_features; + bool use64; public: @@ -268,6 +279,7 @@ public: virtual void get_export_options(List<ExportOption> *r_options); virtual String get_name() const; + virtual String get_os_name() const; virtual Ref<Texture> get_logo() const; virtual bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const; @@ -276,6 +288,7 @@ public: void set_extension(const String &p_extension); void set_name(const String &p_name); + void set_os_name(const String &p_name); void set_logo(const Ref<Texture> &p_loco); @@ -284,6 +297,9 @@ public: void set_debug_64(const String &p_file); void set_debug_32(const String &p_file); + void add_platform_feature(const String &p_feature); + virtual void get_platform_features(List<String> *r_features); + EditorExportPlatformPC(); }; diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index f314f772d1..f0f84416bf 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -32,12 +32,12 @@ #include "editor_node.h" #include "editor_resource_preview.h" #include "editor_settings.h" -#include "global_config.h" #include "io/resource_import.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "os/os.h" +#include "project_settings.h" #include "variant_parser.h" EditorFileSystem *EditorFileSystem::singleton = NULL; @@ -137,7 +137,7 @@ EditorFileSystemDirectory *EditorFileSystemDirectory::get_parent() { void EditorFileSystemDirectory::_bind_methods() { ClassDB::bind_method(D_METHOD("get_subdir_count"), &EditorFileSystemDirectory::get_subdir_count); - ClassDB::bind_method(D_METHOD("get_subdir", "idx"), &EditorFileSystemDirectory::get_subdir); + ClassDB::bind_method(D_METHOD("get_subdir:EditorFileSystemDirectory", "idx"), &EditorFileSystemDirectory::get_subdir); ClassDB::bind_method(D_METHOD("get_file_count"), &EditorFileSystemDirectory::get_file_count); ClassDB::bind_method(D_METHOD("get_file", "idx"), &EditorFileSystemDirectory::get_file); ClassDB::bind_method(D_METHOD("get_file_path", "idx"), &EditorFileSystemDirectory::get_file_path); @@ -179,7 +179,7 @@ void EditorFileSystem::_scan_filesystem() { sources_changed.clear(); file_cache.clear(); - String project = GlobalConfig::get_singleton()->get_resource_path(); + String project = ProjectSettings::get_singleton()->get_resource_path(); String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache2"); FileAccess *f = FileAccess::open(fscache, FileAccess::READ); @@ -1008,7 +1008,7 @@ bool EditorFileSystem::_find_file(const String &p_file, EditorFileSystemDirector if (!filesystem || scanning) return false; - String f = GlobalConfig::get_singleton()->localize_path(p_file); + String f = ProjectSettings::get_singleton()->localize_path(p_file); if (!f.begins_with("res://")) return false; @@ -1121,7 +1121,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p if (!filesystem || scanning) return NULL; - String f = GlobalConfig::get_singleton()->localize_path(p_path); + String f = ProjectSettings::get_singleton()->localize_path(p_path); if (!f.begins_with("res://")) return NULL; @@ -1335,7 +1335,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { f->store_line("[params]"); f->store_line(""); - //store options in provided order, to avoid file changing + //store options in provided order, to avoid file changing. Order is also important because first match is accepted first. for (List<ResourceImporter::ImportOption>::Element *E = opts.front(); E; E = E->next()) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 497a8ca452..990628d6af 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -39,7 +39,6 @@ #include "editor_help.h" #include "editor_settings.h" #include "editor_themes.h" -#include "global_config.h" #include "io/config_file.h" #include "io/stream_peer_ssl.h" #include "io/zip_io.h" @@ -52,12 +51,14 @@ #include "os/os.h" #include "path_remap.h" #include "print_string.h" +#include "project_settings.h" #include "pvrtc_compress.h" #include "register_exporters.h" #include "scene/resources/packed_scene.h" #include "servers/physics_2d_server.h" #include "translation.h" #include "version.h" +#include "version_hash.gen.h" #include <stdio.h> // plugins #include "asset_library_editor_plugin.h" @@ -163,7 +164,7 @@ void EditorNode::_update_scene_tabs() { void EditorNode::_update_title() { - String appname = GlobalConfig::get_singleton()->get("application/name"); + String appname = ProjectSettings::get_singleton()->get("application/config/name"); String title = appname.empty() ? String(VERSION_FULL_NAME) : String(_MKSTR(VERSION_NAME) + String(" - ") + appname); String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String(); if (!edited.empty()) @@ -272,7 +273,7 @@ void EditorNode::_notification(int p_what) { } editor_selection->update(); - scene_root->set_size_override(true, Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height"))); + scene_root->set_size_override(true, Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height"))); ResourceImporterTexture::get_singleton()->update_imports(); } @@ -519,7 +520,7 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St flg|=ResourceSaver::FLAG_RELATIVE_PATHS; */ - String path = GlobalConfig::get_singleton()->localize_path(p_path); + String path = ProjectSettings::get_singleton()->localize_path(p_path); Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err != OK) { @@ -870,7 +871,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { //save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5 String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); - String cache_base = GlobalConfig::get_singleton()->globalize_path(p_file).md5_text(); + String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail @@ -950,7 +951,7 @@ void EditorNode::_save_scene(String p_file, int idx) { _save_edited_subresources(scene, processed, flg); editor_data.save_editor_external_data(); if (err == OK) { - scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_file)); + scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_file)); //EditorFileSystem::get_singleton()->update_file(p_file,sdata->get_type()); if (idx < 0 || idx == editor_data.get_edited_scene()) set_current_version(editor_data.get_undo_redo().get_version()); @@ -1029,7 +1030,7 @@ void EditorNode::_import_action(const String &p_action) { EditorImport::generate_version_hashes(src); - Node *dst = SceneLoader::load(editor_data.get_imported_scene(GlobalConfig::get_singleton()->localize_path(_tmp_import_path))); + Node *dst = SceneLoader::load(editor_data.get_imported_scene(ProjectSettings::get_singleton()->localize_path(_tmp_import_path))); if (!dst) { @@ -1132,8 +1133,8 @@ void EditorNode::_dialog_action(String p_file) { } break; case SETTINGS_PICK_MAIN_SCENE: { - GlobalConfig::get_singleton()->set("application/main_scene", p_file); - GlobalConfig::get_singleton()->save(); + ProjectSettings::get_singleton()->set("application/run/main_scene", p_file); + ProjectSettings::get_singleton()->save(); //would be nice to show the project manager opened with the highlighted field.. _run(false, ""); // automatically run the project } break; @@ -1575,6 +1576,11 @@ void EditorNode::_edit_current() { editor_plugin_screen->make_visible(true); + int plugin_count = editor_data.get_editor_plugin_count(); + for (int i = 0; i < plugin_count; i++) { + editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name()); + } + for (int i = 0; i < editor_table.size(); i++) { main_editor_buttons[i]->set_pressed(editor_table[i] == main_plugin); @@ -1628,7 +1634,7 @@ void EditorNode::_edit_current() { p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES); p->add_separator(); - p->add_icon_shortcut(gui_base->get_icon("Help", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); + p->add_icon_shortcut(gui_base->get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); } List<MethodInfo> methods; @@ -1731,7 +1737,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { if (run_filename == "") { //evidently, run the scene - main_scene = GLOBAL_DEF("application/main_scene", ""); + main_scene = GLOBAL_DEF("application/run/main_scene", ""); if (main_scene == "") { current_option = -1; @@ -1797,7 +1803,7 @@ void EditorNode::_run(bool p_current, const String &p_custom) { List<String> breakpoints; editor_data.get_editor_breakpoints(&breakpoints); - args = GlobalConfig::get_singleton()->get("editor/main_run_args"); + args = ProjectSettings::get_singleton()->get("editor/main_run_args"); Error error = editor_run.run(run_filename, args, breakpoints); @@ -2264,7 +2270,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } instanced_scene->generate_instance_state(); - instanced_scene->set_filename( GlobalConfig::get_singleton()->localize_path(external_file) ); + instanced_scene->set_filename( ProjectSettings::get_singleton()->localize_path(external_file) ); editor_data.get_undo_redo().create_action("Instance Scene"); editor_data.get_undo_redo().add_do_method(parent,"add_child",instanced_scene); @@ -2865,6 +2871,11 @@ void EditorNode::_editor_select(int p_which) { editor_plugin_screen->make_visible(true); editor_plugin_screen->selected_notify(); + int plugin_count = editor_data.get_editor_plugin_count(); + for (int i = 0; i < plugin_count; i++) { + editor_data.get_editor_plugin(i)->notify_main_screen_changed(editor_plugin_screen->get_name()); + } + if (EditorSettings::get_singleton()->get("interface/separate_distraction_mode")) { if (p_which == EDITOR_SCRIPT) { set_distraction_free_mode(script_distraction); @@ -2913,7 +2924,6 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor) { } } - //singleton->main_editor_tabs->add_tab(p_editor->get_name()); singleton->editor_table.erase(p_editor); } p_editor->make_visible(false); @@ -2935,9 +2945,9 @@ void EditorNode::_update_addon_config() { } if (enabled_addons.size() == 0) { - GlobalConfig::get_singleton()->set("editor_plugins/enabled", Variant()); + ProjectSettings::get_singleton()->set("editor_plugins/enabled", Variant()); } else { - GlobalConfig::get_singleton()->set("editor_plugins/enabled", enabled_addons); + ProjectSettings::get_singleton()->set("editor_plugins/enabled", enabled_addons); } project_settings->queue_save(); @@ -3278,7 +3288,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b if (p_clear_errors) load_errors->clear(); - String lpath = GlobalConfig::get_singleton()->localize_path(p_scene); + String lpath = ProjectSettings::get_singleton()->localize_path(p_scene); if (!lpath.begins_with("res://")) { @@ -3566,7 +3576,7 @@ void EditorNode::animation_editor_make_visible(bool p_visible) { #endif void EditorNode::_add_to_recent_scenes(const String &p_scene) { - String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); + String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); String name = p_scene; name = name.replace("res://", ""); @@ -3583,21 +3593,12 @@ void EditorNode::_add_to_recent_scenes(const String &p_scene) { void EditorNode::_open_recent_scene(int p_idx) { - String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); + String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); ERR_FAIL_INDEX(p_idx, rc.size()); String path = "res://" + rc[p_idx]; - - /*if (unsaved_cache) { - _recent_scene=rc[p_idx]; - open_recent_confirmation->set_text("Discard current scene and open:\n'"+rc[p_idx]+"'"); - open_recent_confirmation->get_label()->set_align(Label::ALIGN_CENTER); - open_recent_confirmation->popup_centered(Size2(400,100)); - return; - }*/ - load_scene(path); } @@ -3635,13 +3636,13 @@ void EditorNode::_save_optimized() { } - project_settings->add_remapped_path(GlobalConfig::get_singleton()->localize_path(get_edited_scene()->get_filename()),GlobalConfig::get_singleton()->localize_path(path),platform); + project_settings->add_remapped_path(ProjectSettings::get_singleton()->localize_path(get_edited_scene()->get_filename()),ProjectSettings::get_singleton()->localize_path(path),platform); #endif } void EditorNode::_update_recent_scenes() { - String base = "_" + GlobalConfig::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); + String base = "_" + ProjectSettings::get_singleton()->get_resource_path().replace("\\", "::").replace("/", "::"); Vector<String> rc = EDITOR_DEF(base + "/_recent_scenes", Array()); recent_scenes->clear(); for (int i = 0; i < rc.size(); i++) { @@ -3756,6 +3757,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorResourcePreviewGenerator>(); ClassDB::register_class<EditorFileSystem>(); ClassDB::register_class<EditorFileSystemDirectory>(); + ClassDB::register_virtual_class<ScriptEditor>(); //ClassDB::register_type<EditorImporter>(); //ClassDB::register_type<EditorPostImport>(); @@ -5151,10 +5153,6 @@ EditorNode::EditorNode() { import_wav.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_wav); - Ref<ResourceImporterOBJ> import_obj; - import_obj.instance(); - ResourceFormatImporter::get_singleton()->add_importer(import_obj); - Ref<ResourceImporterScene> import_scene; import_scene.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_scene); @@ -5163,6 +5161,10 @@ EditorNode::EditorNode() { Ref<EditorSceneImporterCollada> import_collada; import_collada.instance(); import_scene->add_importer(import_collada); + + Ref<EditorOBJImporter> import_obj; + import_obj.instance(); + import_scene->add_importer(import_obj); } } @@ -5222,28 +5224,9 @@ EditorNode::EditorNode() { main_vbox->set_area_as_parent_rect(8); main_vbox->set_margin(MARGIN_TOP, 5); -#if 0 - PanelContainer *top_dark_panel = memnew( PanelContainer ); - Ref<StyleBoxTexture> top_dark_sb; - top_dark_sb.instance(); - top_dark_sb->set_texture(theme->get_icon("PanelTop","EditorIcons")); - for(int i=0;i<4;i++) { - top_dark_sb->set_margin_size(Margin(i),3); - top_dark_sb->set_default_margin(Margin(i),0); - } - top_dark_sb->set_expand_margin_size(MARGIN_LEFT,20); - top_dark_sb->set_expand_margin_size(MARGIN_RIGHT,20); - - top_dark_panel->add_style_override("panel",top_dark_sb); - VBoxContainer *top_dark_vb = memnew( VBoxContainer ); - main_vbox->add_child(top_dark_panel); - top_dark_panel->add_child(top_dark_vb); -#endif - menu_hb = memnew(HBoxContainer); main_vbox->add_child(menu_hb); - //top_dark_vb->add_child(scene_tabs); //left left_l_hsplit = memnew(HSplitContainer); main_vbox->add_child(left_l_hsplit); @@ -5318,10 +5301,10 @@ EditorNode::EditorNode() { main_hsplit->connect("dragged", this, "_dock_split_dragged"); right_hsplit->connect("dragged", this, "_dock_split_dragged"); - dock_select_popoup = memnew(PopupPanel); - gui_base->add_child(dock_select_popoup); + dock_select_popup = memnew(PopupPanel); + gui_base->add_child(dock_select_popup); VBoxContainer *dock_vb = memnew(VBoxContainer); - dock_select_popoup->add_child(dock_vb); + dock_select_popup->add_child(dock_vb); HBoxContainer *dock_hb = memnew(HBoxContainer); dock_tab_move_left = memnew(ToolButton); @@ -5348,14 +5331,13 @@ EditorNode::EditorNode() { dock_select->set_v_size_flags(Control::SIZE_EXPAND_FILL); dock_vb->add_child(dock_select); - dock_select_popoup->set_as_minsize(); + dock_select_popup->set_as_minsize(); dock_select_rect_over = -1; dock_popup_selected = -1; - //dock_select_popoup->set_(Size2(20,20)); for (int i = 0; i < DOCK_SLOT_MAX; i++) { dock_slot[i]->set_custom_minimum_size(Size2(230, 220) * EDSCALE); dock_slot[i]->set_v_size_flags(Control::SIZE_EXPAND_FILL); - dock_slot[i]->set_popup(dock_select_popoup); + dock_slot[i]->set_popup(dock_select_popup); dock_slot[i]->connect("pre_popup_pressed", this, "_dock_pre_popup", varray(i)); dock_slot[i]->set_tab_align(TabContainer::ALIGN_LEFT); } @@ -5376,10 +5358,6 @@ EditorNode::EditorNode() { top_split->add_child(srt); srt->add_constant_override("separation", 0); - /* main_editor_tabs = memnew( Tabs ); - main_editor_tabs->connect("tab_changed",this,"_editor_select"); - main_editor_tabs->set_tab_close_display_policy(Tabs::SHOW_NEVER); -*/ tab_preview_panel = memnew(Panel); tab_preview_panel->set_size(Size2(100, 100) * EDSCALE); tab_preview_panel->hide(); @@ -5442,7 +5420,7 @@ EditorNode::EditorNode() { VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); scene_root->set_disable_input(true); scene_root->set_as_audio_listener_2d(true); - //scene_root->set_size_override(true,Size2(GlobalConfig::get_singleton()->get("display/width"),GlobalConfig::get_singleton()->get("display/height"))); + //scene_root->set_size_override(true,Size2(ProjectSettings::get_singleton()->get("display/width"),ProjectSettings::get_singleton()->get("display/height"))); //scene_root->set_world_2d( Ref<World2D>( memnew( World2D )) ); @@ -5493,7 +5471,6 @@ EditorNode::EditorNode() { p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/close_scene", TTR("Close Scene"), KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_W), FILE_CLOSE); p->add_separator(); - //p->add_shortcut(ED_SHORTCUT("editor/save_scene",TTR("Close Goto Prev. Scene")),FILE_OPEN_PREV,KEY_MASK_SHIFT+KEY_MASK_CMD+KEY_P); p->add_submenu_item(TTR("Open Recent"), "RecentScenes", FILE_OPEN_RECENT); p->add_separator(); p->add_shortcut(ED_SHORTCUT("editor/quick_open_scene", TTR("Quick Open Scene.."), KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_O), FILE_QUICK_OPEN_SCENE); @@ -5561,35 +5538,6 @@ EditorNode::EditorNode() { menu_hb->add_spacer(); menu_hb->add_child(editor_region); -//menu_hb->add_spacer(); -#if 0 - node_menu = memnew( MenuButton ); - node_menu->set_text("Node"); - node_menu->set_position( Point2( 50,0) ); - menu_panel->add_child( node_menu ); - - p=node_menu->get_popup(); - p->add_item("Create",NODE_CREATE); - p->add_item("Instance",NODE_INSTANCE); - p->add_separator(); - p->add_item("Reparent",NODE_REPARENT); - p->add_item("Move Up",NODE_MOVE_UP); - p->add_item("Move Down",NODE_MOVE_DOWN); - p->add_separator(); - p->add_item("Duplicate",NODE_DUPLICATE); - p->add_separator(); - p->add_item("Remove (Branch)",NODE_REMOVE_BRANCH); - p->add_item("Remove (Element)",NODE_REMOVE_ELEMENT); - p->add_separator(); - p->add_item("Edit Subscriptions..",NODE_CONNECTIONS); - p->add_item("Edit Groups..",NODE_GROUPS); - - resource_menu = memnew( MenuButton ); - resource_menu->set_text("Resource"); - resource_menu->set_position( Point2( 90,0) ); - menu_panel->add_child( resource_menu ); -#endif - debug_menu = memnew(MenuButton); debug_menu->set_text(TTR("Debug")); debug_menu->add_style_override("hover", gui_base->get_stylebox("MenuHover", "EditorStyles")); @@ -5642,7 +5590,7 @@ EditorNode::EditorNode() { p = help_menu->get_popup(); p->connect("id_pressed", this, "_menu_option"); p->add_icon_item(gui_base->get_icon("ClassList", "EditorIcons"), TTR("Classes"), HELP_CLASSES); - p->add_icon_item(gui_base->get_icon("Help", "EditorIcons"), TTR("Search"), HELP_SEARCH); + p->add_icon_item(gui_base->get_icon("HelpSearch", "EditorIcons"), TTR("Search"), HELP_SEARCH); p->add_separator(); p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Q&A"), HELP_QA); @@ -5651,11 +5599,6 @@ EditorNode::EditorNode() { p->add_separator(); p->add_icon_item(gui_base->get_icon("GodotDocs", "EditorIcons"), TTR("About"), HELP_ABOUT); - //Separator *s1 = memnew( VSeparator ); - //menu_panel->add_child(s1); - //s1->set_position(Point2(210,4)); - //s1->set_size(Point2(10,15)); - play_cc = memnew(CenterContainer); play_cc->set_mouse_filter(Control::MOUSE_FILTER_IGNORE); menu_hb->add_child(play_cc); @@ -5680,7 +5623,6 @@ EditorNode::EditorNode() { play_button->set_shortcut(ED_SHORTCUT("editor/play", TTR("Play"), KEY_F5)); pause_button = memnew(ToolButton); - //menu_panel->add_child(pause_button); - not needed for now? pause_button->set_toggle_mode(true); pause_button->set_icon(gui_base->get_icon("Pause", "EditorIcons")); pause_button->set_focus_mode(Control::FOCUS_NONE); @@ -5708,9 +5650,6 @@ EditorNode::EditorNode() { native_play_button->get_popup()->connect("id_pressed", this, "_run_in_device"); run_native->connect("native_run", this, "_menu_option", varray(RUN_PLAY_NATIVE)); - //VSeparator *s1 = memnew( VSeparator ); - //play_hb->add_child(s1); - play_scene_button = memnew(ToolButton); play_hb->add_child(play_scene_button); play_scene_button->set_toggle_mode(true); @@ -5729,24 +5668,6 @@ EditorNode::EditorNode() { play_custom_scene_button->set_tooltip(TTR("Play custom scene")); play_custom_scene_button->set_shortcut(ED_SHORTCUT("editor/play_custom_scene", TTR("Play Custom Scene"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_F5)); - /* - run_settings_button = memnew( ToolButton ); - //menu_hb->add_child(run_settings_button); - //run_settings_button->set_toggle_mode(true); - run_settings_button->set_focus_mode(Control::FOCUS_NONE); - run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons")); - run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SCENE_SETTINGS)); -*/ - - /* - run_settings_button = memnew( ToolButton ); - menu_panel->add_child(run_settings_button); - run_settings_button->set_position(Point2(305,0)); - run_settings_button->set_focus_mode(Control::FOCUS_NONE); - run_settings_button->set_icon(gui_base->get_icon("Run","EditorIcons")); - run_settings_button->connect("pressed", this,"_menu_option",make_binds(RUN_SETTINGS)); -*/ - progress_hb = memnew(BackgroundProgress); //menu_hb->add_child(progress_hb); @@ -5785,52 +5706,15 @@ EditorNode::EditorNode() { p->add_check_item(TTR("Disable Update Spinner"), SETTINGS_UPDATE_SPINNER_HIDE); p->set_item_checked(1, true); - //sources_button->connect(); - - /* - Separator *s2 = memnew( VSeparator ); - menu_panel->add_child(s2); - s2->set_position(Point2(338,4)); - s2->set_size(Point2(10,15)); -*/ - - //editor_hsplit = memnew( HSplitContainer ); - //main_split->add_child(editor_hsplit); - //editor_hsplit->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - //editor_vsplit = memnew( VSplitContainer ); - //editor_hsplit->add_child(editor_vsplit); - - //top_pallete = memnew( TabContainer ); scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data)); scene_tree_dock->set_name(TTR("Scene")); - //top_pallete->add_child(scene_tree_dock); dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock); #if 0 resources_dock = memnew( ResourcesDock(this) ); resources_dock->set_name("Resources"); - //top_pallete->add_child(resources_dock); dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(resources_dock); - //top_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL); #endif dock_slot[DOCK_SLOT_LEFT_BR]->hide(); - /*Control *editor_spacer = memnew( Control ); - editor_spacer->set_custom_minimum_size(Size2(260,200)); - editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL); - editor_vsplit->add_child( editor_spacer ); - editor_spacer->add_child( top_pallete ); - top_pallete->set_area_as_parent_rect();*/ - - //prop_pallete = memnew( TabContainer ); - - //prop_pallete->set_v_size_flags(Control::SIZE_EXPAND_FILL); - - /*editor_spacer = memnew( Control ); - editor_spacer->set_custom_minimum_size(Size2(260,200)); - editor_spacer->set_v_size_flags(Control::SIZE_EXPAND_FILL); - editor_vsplit->add_child( editor_spacer ); - editor_spacer->add_child( prop_pallete ); - prop_pallete->set_area_as_parent_rect();*/ VBoxContainer *prop_editor_base = memnew(VBoxContainer); prop_editor_base->set_name(TTR("Inspector")); // Properties? @@ -5937,6 +5821,7 @@ EditorNode::EditorNode() { property_editor->set_use_folding(true); property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); property_editor->set_use_doc_hints(true); + property_editor->set_hide_script(false); property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/capitalize_properties", true))); property_editor->hide_top_label(); @@ -5971,7 +5856,6 @@ EditorNode::EditorNode() { } else { dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock); } - //prop_pallete->add_child(filesystem_dock); filesystem_dock->connect("open", this, "open_request"); filesystem_dock->connect("instance", this, "_instance_request"); @@ -6022,17 +5906,6 @@ EditorNode::EditorNode() { //progress_hb->set_h_size_flags(Control::SIZE_EXPAND_FILL); - /* - animation_menu = memnew( ToolButton ); - animation_menu->set_position(Point2(500,0)); - animation_menu->set_size(Size2(20,20)); - animation_menu->set_toggle_mode(true); - animation_menu->set_focus_mode(Control::FOCUS_NONE); - menu_panel->add_child(animation_menu); - animation_menu->set_icon(gui_base->get_icon("Animation","EditorIcons")); - animation_menu->connect("pressed",this,"_animation_visibility_toggle"); -*/ - orphan_resources = memnew(OrphanResourcesDialog); gui_base->add_child(orphan_resources); @@ -6076,7 +5949,7 @@ EditorNode::EditorNode() { settings_config_dialog = memnew(EditorSettingsDialog); gui_base->add_child(settings_config_dialog); - project_settings = memnew(ProjectSettings(&editor_data)); + project_settings = memnew(ProjectSettingsEditor(&editor_data)); gui_base->add_child(project_settings); import_confirmation = memnew(ConfirmationDialog); @@ -6087,10 +5960,6 @@ EditorNode::EditorNode() { import_confirmation->connect("custom_action", this, "_import_action"); gui_base->add_child(import_confirmation); - open_recent_confirmation = memnew(ConfirmationDialog); - add_child(open_recent_confirmation); - open_recent_confirmation->connect("confirmed", this, "_open_recent_scene_confirm"); - run_settings_dialog = memnew(RunSettingsDialog); gui_base->add_child(run_settings_dialog); @@ -6118,14 +5987,18 @@ EditorNode::EditorNode() { logo->set_texture(gui_base->get_icon("Logo", "EditorIcons")); hbc->add_child(logo); + String hash = String(VERSION_HASH); + if (hash.length() != 0) + hash = "." + hash.left(7); + Label *about_text = memnew(Label); about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); - about_text->set_text(VERSION_FULL_NAME + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + + about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + TTR("Godot Engine contributors") + "\n"); hbc->add_child(about_text); TabContainer *tc = memnew(TabContainer); - tc->set_custom_minimum_size(Size2(600, 240) * EDSCALE); + tc->set_custom_minimum_size(Size2(630, 240) * EDSCALE); tc->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(tc); @@ -6153,14 +6026,14 @@ EditorNode::EditorNode() { dev_vbc->add_child(lbl); ItemList *il = memnew(ItemList); - il->set_max_columns(32); + il->set_max_columns(16); il->set_h_size_flags(Control::SIZE_EXPAND_FILL); - il->set_custom_minimum_size(Size2(0, i == 3 ? DEV_NAMES_COUNT * 7.6 : 30) * EDSCALE); + il->set_fixed_column_width(230 * EDSCALE); + il->set_auto_height(true); const char **dev_names_ptr = dev_src[i]; while (*dev_names_ptr) il->add_item(String::utf8(*dev_names_ptr++), NULL, false); dev_vbc->add_child(il); - il->set_fixed_column_width(240 * EDSCALE); HSeparator *hs = memnew(HSeparator); hs->set_modulate(Color(0, 0, 0, 0)); @@ -6407,7 +6280,7 @@ EditorNode::EditorNode() { Physics2DServer::get_singleton()->set_active(false); // no physics by default if editor ScriptServer::set_scripting_enabled(false); // no scripting by default if editor - //GlobalConfig::get_singleton()->set("render/room_cull_enabled",false); + //ProjectSettings::get_singleton()->set("render/room_cull_enabled",false); reference_resource_mem = true; save_external_resources_mem = true; @@ -6420,7 +6293,7 @@ EditorNode::EditorNode() { //store project name in ssettings String project_name; //figure it out from path - project_name = GlobalConfig::get_singleton()->get_resource_path().replace("\\", "/"); + project_name = ProjectSettings::get_singleton()->get_resource_path().replace("\\", "/"); print_line("path: " + project_name); if (project_name.length() && project_name[project_name.length() - 1] == '/') project_name = project_name.substr(0, project_name.length() - 1); @@ -6428,7 +6301,7 @@ EditorNode::EditorNode() { project_name = project_name.replace("/", "::"); if (project_name != "") { - EditorSettings::get_singleton()->set("projects/" + project_name, GlobalConfig::get_singleton()->get_resource_path()); + EditorSettings::get_singleton()->set("projects/" + project_name, ProjectSettings::get_singleton()->get_resource_path()); EditorSettings::get_singleton()->raise_order("projects/" + project_name); EditorSettings::get_singleton()->save(); } @@ -6509,8 +6382,8 @@ EditorNode::EditorNode() { _initializing_addons = true; Vector<String> addons; - if (GlobalConfig::get_singleton()->has("editor_plugins/enabled")) { - addons = GlobalConfig::get_singleton()->get("editor_plugins/enabled"); + if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) { + addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled"); } for (int i = 0; i < addons.size(); i++) { diff --git a/editor/editor_node.h b/editor/editor_node.h index 991cf1df71..e5a4cf654a 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -64,7 +64,7 @@ #include "editor/editor_log.h" #include "editor/editor_run_script.h" #include "editor/project_export.h" -#include "editor/project_settings.h" +#include "editor/project_settings_editor.h" #include "editor/resources_dock.h" #include "editor/run_settings_dialog.h" #include "editor/scene_tree_dock.h" @@ -247,10 +247,7 @@ private: Control *vp_base; PaneDrag *pd; //PaneDrag *pd_anim; - Panel *menu_panel; - //HSplitContainer *editor_hsplit; - //VSplitContainer *editor_vsplit; CenterContainer *play_cc; HBoxContainer *menu_hb; Control *viewport; @@ -300,7 +297,6 @@ private: ConfirmationDialog *confirmation; ConfirmationDialog *save_confirmation; ConfirmationDialog *import_confirmation; - ConfirmationDialog *open_recent_confirmation; ConfirmationDialog *pick_main_scene; AcceptDialog *accept; AcceptDialog *about; @@ -314,7 +310,7 @@ private: //OptimizedPresetsDialog *optimized_presets; EditorSettingsDialog *settings_config_dialog; RunSettingsDialog *run_settings_dialog; - ProjectSettings *project_settings; + ProjectSettingsEditor *project_settings; EditorFileDialog *file; ExportTemplateManager *export_template_manager; FileDialog *file_templates; @@ -326,8 +322,6 @@ private: String current_path; MenuButton *update_menu; - //TabContainer *prop_pallete; - //TabContainer *top_pallete; String defer_load_scene; String defer_export; String defer_export_platform; @@ -363,7 +357,7 @@ private: TabContainer *dock_slot[DOCK_SLOT_MAX]; Rect2 dock_select_rect[DOCK_SLOT_MAX]; int dock_select_rect_over; - PopupPanel *dock_select_popoup; + PopupPanel *dock_select_popup; Control *dock_select; ToolButton *dock_tab_move_left; ToolButton *dock_tab_move_right; diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 606fd8ee5e..c65065db43 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -171,6 +171,46 @@ void EditorPlugin::set_input_event_forwarding_always_enabled() { always_input_forwarding_list->add_plugin(this); } +Node *EditorPlugin::get_edited_scene_root() { + return EditorNode::get_singleton()->get_edited_scene(); +} + +Array EditorPlugin::get_open_scenes() const { + + Array ret; + Vector<EditorData::EditedScene> scenes = EditorNode::get_singleton()->get_editor_data().get_edited_scenes(); + + int scns_amount = scenes.size(); + for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) { + if (scenes[idx_scn].root == NULL) + continue; + ret.push_back(scenes[idx_scn].root->get_filename()); + } + return ret; +} + +ScriptEditor *EditorPlugin::get_script_editor() { + return ScriptEditor::get_singleton(); +} + +void EditorPlugin::notify_scene_changed(const Node *scn_root) { + if (scn_root == NULL) return; + emit_signal("scene_changed", scn_root); +} + +void EditorPlugin::notify_main_screen_changed(const String &screen_name) { + + if (screen_name == last_main_screen_name) + return; + + emit_signal("main_screen_changed", screen_name); + last_main_screen_name = screen_name; +} + +void EditorPlugin::notify_scene_closed(const String &scene_filepath) { + emit_signal("scene_closed", scene_filepath); +} + Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial *p_spatial) { //?? if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) { @@ -392,13 +432,17 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("get_undo_redo:UndoRedo"), &EditorPlugin::_get_undo_redo); ClassDB::bind_method(D_METHOD("get_selection:EditorSelection"), &EditorPlugin::get_selection); ClassDB::bind_method(D_METHOD("get_editor_settings:EditorSettings"), &EditorPlugin::get_editor_settings); + ClassDB::bind_method(D_METHOD("get_script_editor:ScriptEditor"), &EditorPlugin::get_script_editor); ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); - ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource); + ClassDB::bind_method(D_METHOD("edit_resource", "resource:Resource"), &EditorPlugin::edit_resource); ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorPlugin::open_scene_from_path); ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorPlugin::reload_scene_from_path); - ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin); - ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin); + ClassDB::bind_method(D_METHOD("add_import_plugin", "importer:EditorImportPlugin"), &EditorPlugin::add_import_plugin); + ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer:EditorImportPlugin"), &EditorPlugin::remove_import_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_open_scenes"), &EditorPlugin::get_open_scenes); + ClassDB::bind_method(D_METHOD("get_edited_scene_root:Node"), &EditorPlugin::get_edited_scene_root); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); @@ -420,6 +464,10 @@ void EditorPlugin::_bind_methods() { ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile"))); + ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root:Node"))); + ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath:String"))); + ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name:String"))); + BIND_CONSTANT(CONTAINER_TOOLBAR); BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU); BIND_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE); @@ -442,6 +490,7 @@ void EditorPlugin::_bind_methods() { EditorPlugin::EditorPlugin() { undo_redo = NULL; input_event_forwarding_always_enabled = false; + last_main_screen_name = ""; } EditorPlugin::~EditorPlugin() { diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 3653851d5a..a0f64fb1ea 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -52,6 +52,8 @@ class EditorImportPlugin; class EditorExportPlugin; class EditorResourcePreview; class EditorFileSystem; +class EditorToolAddons; +class ScriptEditor; class EditorPlugin : public Node { @@ -63,6 +65,8 @@ class EditorPlugin : public Node { bool input_event_forwarding_always_enabled; + String last_main_screen_name; + protected: static void _bind_methods(); UndoRedo &get_undo_redo() { return *undo_redo; } @@ -113,6 +117,14 @@ public: void set_input_event_forwarding_always_enabled(); bool is_input_event_forwarding_always_enabled() { return input_event_forwarding_always_enabled; } + Node *get_edited_scene_root(); + Array get_open_scenes() const; + ScriptEditor *get_script_editor(); + + void notify_main_screen_changed(const String &screen_name); + void notify_scene_changed(const Node *scn_root); + void notify_scene_closed(const String &scene_filepath); + virtual Ref<SpatialEditorGizmo> create_spatial_gizmo(Spatial *p_spatial); virtual bool forward_canvas_gui_input(const Transform2D &p_canvas_xform, const Ref<InputEvent> &p_event); virtual void forward_draw_over_canvas(const Transform2D &p_canvas_xform, Control *p_canvas); diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index c6b9d4bb41..6ab1468b1d 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -30,7 +30,7 @@ #include "editor_plugin_settings.h" #include "editor_node.h" -#include "global_config.h" +#include "project_settings.h" #include "io/config_file.h" #include "os/file_access.h" #include "os/main_loop.h" @@ -82,7 +82,7 @@ void EditorPluginSettings::update_plugins() { plugins.sort(); - Vector<String> active_plugins = GlobalConfig::get_singleton()->get("editor_plugins/enabled"); + Vector<String> active_plugins = ProjectSettings::get_singleton()->get("editor_plugins/enabled"); for (int i = 0; i < plugins.size(); i++) { diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 5d68de3bb6..3a6b34b7b4 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -31,7 +31,7 @@ #include "editor_scale.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "message_queue.h" @@ -206,7 +206,7 @@ void EditorResourcePreview::_thread() { } else { String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); - String cache_base = GlobalConfig::get_singleton()->globalize_path(item.path).md5_text(); + String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index a8106b4eec..aa97dd237b 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -30,7 +30,7 @@ #include "editor_run.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" EditorRun::Status EditorRun::get_status() const { @@ -40,7 +40,7 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li List<String> args; - String resource_path = GlobalConfig::get_singleton()->get_resource_path(); + String resource_path = ProjectSettings::get_singleton()->get_resource_path(); String remote_host = EditorSettings::get_singleton()->get("network/debug/remote_host"); int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); @@ -79,12 +79,12 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li Size2 desired_size; - desired_size.x = GlobalConfig::get_singleton()->get("display/window/width"); - desired_size.y = GlobalConfig::get_singleton()->get("display/window/height"); + desired_size.x = ProjectSettings::get_singleton()->get("display/window/size/width"); + desired_size.y = ProjectSettings::get_singleton()->get("display/window/size/height"); Size2 test_size; - test_size.x = GlobalConfig::get_singleton()->get("display/window/test_width"); - test_size.y = GlobalConfig::get_singleton()->get("display/window/test_height"); + test_size.x = ProjectSettings::get_singleton()->get("display/window/size/test_width"); + test_size.y = ProjectSettings::get_singleton()->get("display/window/size/test_height"); if (test_size.x > 0 && test_size.y > 0) { desired_size = test_size; diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp index 8bd1b8f4fd..0e980b040e 100644 --- a/editor/editor_run_script.cpp +++ b/editor/editor_run_script.cpp @@ -81,8 +81,8 @@ void EditorScript::set_editor(EditorNode *p_editor) { void EditorScript::_bind_methods() { - ClassDB::bind_method(D_METHOD("add_root_node", "node"), &EditorScript::add_root_node); - ClassDB::bind_method(D_METHOD("get_scene"), &EditorScript::get_scene); + ClassDB::bind_method(D_METHOD("add_root_node", "node:Node"), &EditorScript::add_root_node); + ClassDB::bind_method(D_METHOD("get_scene:Node"), &EditorScript::get_scene); BIND_VMETHOD(MethodInfo("_run")); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 4ab1a435f8..e653502c0e 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -30,7 +30,7 @@ #include "editor_settings.h" #include "editor_node.h" -#include "global_config.h" +#include "project_settings.h" #include "io/compression.h" #include "io/config_file.h" #include "io/file_access_memory.h" @@ -329,7 +329,7 @@ void EditorSettings::create() { dir->change_dir("config"); - String pcp = GlobalConfig::get_singleton()->get_resource_path(); + String pcp = ProjectSettings::get_singleton()->get_resource_path(); if (pcp.ends_with("/")) pcp = config_path.substr(0, pcp.size() - 1); pcp = pcp.get_file() + "-" + pcp.md5_text(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ce9b004ce1..4e8f7029ff 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -69,6 +69,15 @@ static Ref<StyleBoxFlat> make_flat_stylebox(Color color, float p_margin_left = - return style; } +static Ref<StyleBoxLine> make_line_stylebox(Color color, int thickness = 1, float grow = 1, bool vertical = false) { + Ref<StyleBoxLine> style(memnew(StyleBoxLine)); + style->set_color(color); + style->set_grow(grow); + style->set_thickness(thickness); + style->set_vertical(vertical); + return style; +} + static Ref<StyleBoxFlat> change_border_color(Ref<StyleBoxFlat> p_style, Color p_color) { Ref<StyleBoxFlat> style = p_style->duplicate(); style->set_light_color(p_color); @@ -143,6 +152,9 @@ Ref<Theme> create_editor_theme() { Color title_color_hl_text_color = dark_bg ? Color(1, 1, 1, 0.9) : Color(0, 0, 0, 0.9); Ref<Texture> title_hl_close_icon = theme->get_icon((dark_bg ? "GuiCloseLight" : "GuiCloseDark"), "EditorIcons"); + bool dark_base = ((base_color.r + base_color.g + base_color.b) / 3.0) < 0.5; + Color separator_color = dark_base ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1); + theme->set_color("highlight_color", "Editor", highlight_color); theme->set_color("base_color", "Editor", base_color); theme->set_color("dark_color_1", "Editor", dark_color_1); @@ -244,7 +256,7 @@ Ref<Theme> create_editor_theme() { theme->set_color("icon_color_pressed", "Button", Color(highlight_color.r * 1.15, highlight_color.g * 1.15, highlight_color.b * 1.15, highlight_color.a)); // OptionButton - Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4); + Ref<StyleBoxFlat> style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 8, 4); style_option_button->set_border_size(border_width); style_option_button->set_light_color(light_color_1); style_option_button->set_dark_color(light_color_1); @@ -259,6 +271,8 @@ Ref<Theme> create_editor_theme() { theme->set_color("font_color_pressed", "OptionButton", highlight_color); theme->set_color("icon_color_hover", "OptionButton", HIGHLIGHT_COLOR_LIGHT); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); + theme->set_constant("arrow_margin", "OptionButton", 4); + theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); @@ -271,7 +285,7 @@ Ref<Theme> create_editor_theme() { style_popup_menu->set_dark_color(light_color_1); style_popup_menu->set_border_blend(false); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); - theme->set_stylebox("separator", "PopupMenu", make_empty_stylebox()); + theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, border_width, 8 - border_width)); // Tree & ItemList background Ref<StyleBoxFlat> style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4); @@ -362,8 +376,8 @@ Ref<Theme> create_editor_theme() { theme->set_icon("close", "Tabs", title_hl_close_icon); // Separatos (no separatos) - theme->set_stylebox("separator", "HSeparator", make_empty_stylebox()); - theme->set_stylebox("separator", "VSeparator", make_empty_stylebox()); + 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)); // Debugger Ref<StyleBoxFlat> style_panel_debugger = make_flat_stylebox(dark_color_2, 0, 4, 0, 0); diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp index de6ee171ae..100ebe21cd 100644 --- a/editor/file_type_cache.cpp +++ b/editor/file_type_cache.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "file_type_cache.h" -#include "global_config.h" +#include "project_settings.h" #include "os/file_access.h" FileTypeCache *FileTypeCache::singleton = NULL; @@ -55,7 +55,7 @@ void FileTypeCache::set_file_type(const String &p_path, const String &p_type) { void FileTypeCache::load() { GLOBAL_LOCK_FUNCTION - String project = GlobalConfig::get_singleton()->get_resource_path(); + String project = ProjectSettings::get_singleton()->get_resource_path(); FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::READ); if (!f) { @@ -80,7 +80,7 @@ void FileTypeCache::load() { void FileTypeCache::save() { GLOBAL_LOCK_FUNCTION - String project = GlobalConfig::get_singleton()->get_resource_path(); + String project = ProjectSettings::get_singleton()->get_resource_path(); FileAccess *f = FileAccess::open(project + "/file_type_cache.cch", FileAccess::WRITE); if (!f) { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index fe66cd7009..ae3fdede73 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -31,7 +31,7 @@ #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -879,7 +879,7 @@ void FileSystemDock::_file_option(int p_option) { String path = files->get_item_metadata(idx); if (p_option == FILE_SHOW_IN_EXPLORER) { - String dir = GlobalConfig::get_singleton()->globalize_path(path); + String dir = ProjectSettings::get_singleton()->globalize_path(path); dir = dir.substr(0, dir.find_last("/")); OS::get_singleton()->shell_open(String("file://") + dir); return; @@ -1067,7 +1067,7 @@ void FileSystemDock::_folder_option(int p_option) { break; case FOLDER_SHOW_IN_EXPLORER: String path = item->get_metadata(tree->get_selected_column()); - String dir = GlobalConfig::get_singleton()->globalize_path(path); + String dir = ProjectSettings::get_singleton()->globalize_path(path); OS::get_singleton()->shell_open(String("file://") + dir); return; } diff --git a/editor/icons/2x/icon_variant.png b/editor/icons/2x/icon_variant.png Binary files differnew file mode 100644 index 0000000000..bb8075a069 --- /dev/null +++ b/editor/icons/2x/icon_variant.png diff --git a/editor/icons/icon_variant.png b/editor/icons/icon_variant.png Binary files differindex 1ae2812ff7..af7590345e 100644 --- a/editor/icons/icon_variant.png +++ b/editor/icons/icon_variant.png diff --git a/editor/icons/source/icon_variant.svg b/editor/icons/source/icon_variant.svg new file mode 100644 index 0000000000..d966190ab0 --- /dev/null +++ b/editor/icons/source/icon_variant.svg @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + viewBox="0 0 16 16" + id="svg2" + version="1.1" + inkscape:version="0.92+devel unknown" + inkscape:export-filename="/home/djrm/Projects/godot/tools/editor/icons/icon_add_track.png" + inkscape:export-xdpi="45" + inkscape:export-ydpi="45" + sodipodi:docname="icon_variant.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="22.627418" + inkscape:cx="12.635414" + inkscape:cy="11.860443" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + units="px" + inkscape:snap-bbox="true" + inkscape:bbox-paths="true" + inkscape:bbox-nodes="true" + inkscape:snap-bbox-edge-midpoints="true" + inkscape:snap-bbox-midpoints="false" + inkscape:snap-object-midpoints="true" + inkscape:snap-center="true" + inkscape:window-width="1920" + inkscape:window-height="1016" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:snap-midpoints="true" + inkscape:snap-smooth-nodes="true" + inkscape:object-nodes="true" + inkscape:document-rotation="0"> + <inkscape:grid + type="xygrid" + id="grid3336" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-1036.3622)"> + <g + transform="translate(0,-3)" + id="layer1-5" + inkscape:label="Layer 1" + style="fill:#e0e0e0;fill-opacity:1"> + <rect + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect4320" + width="2" + height="5.9999666" + x="3" + y="1044.3622" /> + <rect + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect4324" + width="2" + height="5.9999843" + x="6" + y="1044.3622" /> + <rect + y="1044.3622" + x="3" + height="2.0000174" + width="1" + id="rect4326" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 3,1044.3622 a 3,3 0 0 0 -3,3 h 2 a 1.0000174,1.0000174 0 0 1 1,-1 z" + id="path4328" + inkscape:connector-curvature="0" /> + <path + id="path4330" + d="m 14,1050.3622 a 3,3 0 0 1 -3,-3 h 2 a 1.0000174,1.0000174 0 0 0 1,1 z" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + inkscape:connector-curvature="0" /> + <rect + transform="scale(1,-1)" + y="-1052.3622" + x="14" + height="7.9999843" + width="2" + id="rect4334" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <rect + transform="scale(1,-1)" + y="-1047.3622" + x="11" + height="2.9999826" + width="2" + id="rect4338" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path4340" + d="m 3,1050.3622 a 3,3 0 0 1 -3,-3 h 2 a 1.0000174,1.0000174 0 0 0 1,1 z" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + inkscape:connector-curvature="0" + id="path4342" + d="m 8,1044.3622 a 3,3 0 0 1 3,3 H 9 a 1.0000174,1.0000174 0 0 0 -1,-1 z" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <rect + y="1047.3622" + x="9" + height="3.0000174" + width="2" + id="rect4344" + style="fill:#e0e0e0;fill-opacity:1;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + </g> + </g> +</svg> diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 4a2f37e319..25548f7899 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -31,82 +31,206 @@ #include "io/resource_saver.h" #include "os/file_access.h" +#include "scene/3d/mesh_instance.h" +#include "scene/3d/spatial.h" #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" -String ResourceImporterOBJ::get_importer_name() const { +uint32_t EditorOBJImporter::get_import_flags() const { - return "obj_mesh"; + return IMPORT_SCENE; } +void EditorOBJImporter::get_extensions(List<String> *r_extensions) const { -String ResourceImporterOBJ::get_visible_name() const { - - return "OBJ As Mesh"; + r_extensions->push_back("obj"); } -void ResourceImporterOBJ::get_recognized_extensions(List<String> *p_extensions) const { - p_extensions->push_back("obj"); -} -String ResourceImporterOBJ::get_save_extension() const { - return "mesh"; -} +Error EditorOBJImporter::_parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) { -String ResourceImporterOBJ::get_resource_type() const { + FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); + ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); - return "ArrayMesh"; -} + Ref<SpatialMaterial> current; + String current_name; + String base_path = p_path.get_base_dir(); + while (true) { -bool ResourceImporterOBJ::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + String l = f->get_line().strip_edges(); - return true; -} + if (l.begins_with("newmtl ")) { + //vertex -int ResourceImporterOBJ::get_preset_count() const { - return 0; -} -String ResourceImporterOBJ::get_preset_name(int p_idx) const { + current_name = l.replace("newmtl", "").strip_edges(); + current.instance(); + material_map[current_name] = current; + } else if (l.begins_with("Ka ")) { + //uv + print_line("Warning: Ambient light for material '" + current_name + "' is ignored in PBR"); - return String(); -} + } else if (l.begins_with("Kd ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + Vector<String> v = l.split(" ", false); + ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA); + Color c = current->get_albedo(); + c.r = v[1].to_float(); + c.g = v[2].to_float(); + c.b = v[3].to_float(); + current->set_albedo(c); + } else if (l.begins_with("Ks ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + Vector<String> v = l.split(" ", false); + ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA); + float r = v[1].to_float(); + float g = v[2].to_float(); + float b = v[3].to_float(); + float metalness = MAX(r, MAX(g, b)); + current->set_metallic(metalness); + } else if (l.begins_with("Ns ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + Vector<String> v = l.split(" ", false); + ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA); + float s = v[1].to_float(); + current->set_metallic((1000.0 - s) / 1000.0); + } else if (l.begins_with("d ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + Vector<String> v = l.split(" ", false); + ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA); + float d = v[1].to_float(); + Color c = current->get_albedo(); + c.a = d; + current->set_albedo(c); + if (c.a < 0.99) { + current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + } + } else if (l.begins_with("Tr ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + Vector<String> v = l.split(" ", false); + ERR_FAIL_COND_V(v.size() != 2, ERR_INVALID_DATA); + float d = v[1].to_float(); + Color c = current->get_albedo(); + c.a = 1.0 - d; + current->set_albedo(c); + if (c.a < 0.99) { + current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + } + + } else if (l.begins_with("map_Ka ")) { + //uv + print_line("Warning: Ambient light texture for material '" + current_name + "' is ignored in PBR"); + + } else if (l.begins_with("map_Kd ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + + String p = l.replace("map_Kd", "").replace("\\", "/").strip_edges(); + String path = base_path.plus_file(p); + + Ref<Texture> texture = ResourceLoader::load(path); + + if (texture.is_valid()) { + current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + } else { + r_missing_deps->push_back(path); + } + + } else if (l.begins_with("map_Ks ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + + String p = l.replace("map_Ks", "").replace("\\", "/").strip_edges(); + String path = base_path.plus_file(p); + + Ref<Texture> texture = ResourceLoader::load(path); + + if (texture.is_valid()) { + current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); + } else { + r_missing_deps->push_back(path); + } + + } else if (l.begins_with("map_Ns ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + + String p = l.replace("map_Ns", "").replace("\\", "/").strip_edges(); + String path = base_path.plus_file(p); + + Ref<Texture> texture = ResourceLoader::load(path); + + if (texture.is_valid()) { + current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); + } else { + r_missing_deps->push_back(path); + } + } else if (l.begins_with("map_bump ")) { + //normal + ERR_FAIL_COND_V(current.is_null(), ERR_FILE_CORRUPT); + + String p = l.replace("map_bump", "").replace("\\", "/").strip_edges(); + String path = base_path.plus_file(p); + + Ref<Texture> texture = ResourceLoader::load(path); -void ResourceImporterOBJ::get_import_options(List<ImportOption> *r_options, int p_preset) const { - - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/tangents"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate/normals"), true)); - //not for nowp - //r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/materials"))); - //r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL,"import/textures"))); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/flip_faces"), false)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/smooth_shading"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/weld_vertices"), true)); - r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/weld_tolerance", PROPERTY_HINT_RANGE, "0.00001,16,0.00001"), 0.0001)); - //r_options->push_back(PropertyInfo(Variant::INT,"compress/bitrate",PROPERTY_HINT_ENUM,"64,96,128,192")); + if (texture.is_valid()) { + current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); + current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); + } else { + r_missing_deps->push_back(path); + } + } else if (f->eof_reached()) { + break; + } + } + + return OK; } -Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { +Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { - FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); - ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); + FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); + + if (r_err) { + *r_err = ERR_CANT_OPEN; + } + + ERR_FAIL_COND_V(!f, NULL); + + if (r_err) { + *r_err = OK; + } + + Spatial *scene = memnew(Spatial); + + Ref<ArrayMesh> mesh; + mesh.instance(); - Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); Map<String, Ref<Material> > name_map; - bool generate_normals = p_options["generate/normals"]; - bool generate_tangents = p_options["generate/tangents"]; - bool flip_faces = p_options["force/flip_faces"]; - bool force_smooth = p_options["force/smooth_shading"]; - bool weld_vertices = p_options["force/weld_vertices"]; - float weld_tolerance = p_options["force/weld_tolerance"]; + bool generate_tangents = p_flags & IMPORT_GENERATE_TANGENT_ARRAYS; + bool flip_faces = false; + //bool flip_faces = p_options["force/flip_faces"]; + //bool force_smooth = p_options["force/smooth_shading"]; + //bool weld_vertices = p_options["force/weld_vertices"]; + //float weld_tolerance = p_options["force/weld_tolerance"]; + Vector<Vector3> vertices; Vector<Vector3> normals; Vector<Vector2> uvs; String name; + Map<String, Map<String, Ref<SpatialMaterial> > > material_map; + Ref<SurfaceTool> surf_tool = memnew(SurfaceTool); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); - if (force_smooth) - surf_tool->add_smooth_group(true); - int has_index_data = false; + + String current_material_library; + String current_material; + String current_group; while (true) { @@ -115,7 +239,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s if (l.begins_with("v ")) { //vertex Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA); + ERR_FAIL_COND_V(v.size() < 4, NULL); Vector3 vtx; vtx.x = v[1].to_float(); vtx.y = v[2].to_float(); @@ -124,7 +248,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s } else if (l.begins_with("vt ")) { //uv Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 3, ERR_INVALID_DATA); + ERR_FAIL_COND_V(v.size() < 3, NULL); Vector2 uv; uv.x = v[1].to_float(); uv.y = 1.0 - v[2].to_float(); @@ -133,7 +257,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s } else if (l.begins_with("vn ")) { //normal Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA); + ERR_FAIL_COND_V(v.size() < 4, NULL); Vector3 nrm; nrm.x = v[1].to_float(); nrm.y = v[2].to_float(); @@ -142,21 +266,20 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s } else if (l.begins_with("f ")) { //vertex - has_index_data = true; Vector<String> v = l.split(" ", false); - ERR_FAIL_COND_V(v.size() < 4, ERR_INVALID_DATA); + ERR_FAIL_COND_V(v.size() < 4, NULL); //not very fast, could be sped up Vector<String> face[3]; face[0] = v[1].split("/"); face[1] = v[2].split("/"); - ERR_FAIL_COND_V(face[0].size() == 0, ERR_PARSE_ERROR); - ERR_FAIL_COND_V(face[0].size() != face[1].size(), ERR_PARSE_ERROR); + ERR_FAIL_COND_V(face[0].size() == 0, NULL); + ERR_FAIL_COND_V(face[0].size() != face[1].size(), NULL); for (int i = 2; i < v.size() - 1; i++) { face[2] = v[i + 1].split("/"); - ERR_FAIL_COND_V(face[0].size() != face[2].size(), ERR_PARSE_ERROR); + ERR_FAIL_COND_V(face[0].size() != face[2].size(), NULL); for (int j = 0; j < 3; j++) { int idx = j; @@ -169,7 +292,7 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s int norm = face[idx][2].to_int() - 1; if (norm < 0) norm += normals.size() + 1; - ERR_FAIL_INDEX_V(norm, normals.size(), ERR_PARSE_ERROR); + ERR_FAIL_INDEX_V(norm, normals.size(), NULL); surf_tool->add_normal(normals[norm]); } @@ -177,58 +300,109 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s int uv = face[idx][1].to_int() - 1; if (uv < 0) uv += uvs.size() + 1; - ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_PARSE_ERROR); + ERR_FAIL_INDEX_V(uv, uvs.size(), NULL); surf_tool->add_uv(uvs[uv]); } int vtx = face[idx][0].to_int() - 1; if (vtx < 0) vtx += vertices.size() + 1; - ERR_FAIL_INDEX_V(vtx, vertices.size(), ERR_PARSE_ERROR); + ERR_FAIL_INDEX_V(vtx, vertices.size(), NULL); Vector3 vertex = vertices[vtx]; - if (weld_vertices) - vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance)); + //if (weld_vertices) + // vertex.snap(Vector3(weld_tolerance, weld_tolerance, weld_tolerance)); surf_tool->add_vertex(vertex); } face[1] = face[2]; } - } else if (l.begins_with("s ") && !force_smooth) { //smoothing + } else if (l.begins_with("s ")) { //smoothing String what = l.substr(2, l.length()).strip_edges(); if (what == "off") surf_tool->add_smooth_group(false); else surf_tool->add_smooth_group(true); + } else if (l.begins_with("g ") || l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh - } else if (l.begins_with("o ") || f->eof_reached()) { //new surface or done - - if (has_index_data) { - //new object/surface - if (generate_normals || force_smooth) + if (surf_tool->get_vertex_array().size()) { + //another group going on, commit it + if (normals.size() == 0) { surf_tool->generate_normals(); - if (uvs.size() && (normals.size() || generate_normals) && generate_tangents) + } + + if (generate_tangents && uvs.size()) { surf_tool->generate_tangents(); + } surf_tool->index(); + + print_line("current material library " + current_material_library + " has " + itos(material_map.has(current_material_library))); + print_line("current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material))); + + if (material_map.has(current_material_library) && material_map[current_material_library].has(current_material)) { + surf_tool->set_material(material_map[current_material_library][current_material]); + } + mesh = surf_tool->commit(mesh); - if (name == "") - name = vformat(TTR("Surface %d"), mesh->get_surface_count() - 1); - mesh->surface_set_name(mesh->get_surface_count() - 1, name); - name = ""; + + if (current_material != String()) { + mesh->surface_set_name(mesh->get_surface_count() - 1, current_material.get_basename()); + } else if (current_group != String()) { + mesh->surface_set_name(mesh->get_surface_count() - 1, current_group); + } + + print_line("Added surface :" + mesh->surface_get_name(mesh->get_surface_count() - 1)); surf_tool->clear(); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); - if (force_smooth) - surf_tool->add_smooth_group(true); + } - has_index_data = false; + if (l.begins_with("o ") || f->eof_reached()) { - if (f->eof_reached()) - break; + MeshInstance *mi = memnew(MeshInstance); + mi->set_name(name); + mi->set_mesh(mesh); + + scene->add_child(mi); + mi->set_owner(scene); + + mesh.instance(); + current_group = ""; + current_material = ""; + } + + if (f->eof_reached()) { + break; } - if (l.begins_with("o ")) //name + if (l.begins_with("o ")) { name = l.substr(2, l.length()).strip_edges(); + } + + if (l.begins_with("usemtl ")) { + + current_material = l.replace("usemtl", "").strip_edges(); + } + + if (l.begins_with("g ")) { + + current_group = l.substr(2, l.length()).strip_edges(); + } + + } else if (l.begins_with("mtllib ")) { //parse material + + current_material_library = l.replace("mtllib", "").strip_edges(); + if (!material_map.has(current_material_library)) { + Map<String, Ref<SpatialMaterial> > lib; + Error err = _parse_material_library(current_material_library, lib, r_missing_deps); + if (err == ERR_CANT_OPEN) { + String dir = p_path.get_base_dir(); + err = _parse_material_library(dir.plus_file(current_material_library), lib, r_missing_deps); + } + if (err == OK) { + material_map[current_material_library] = lib; + } + } } } @@ -243,10 +417,11 @@ Error ResourceImporterOBJ::import(const String &p_source_file, const String &p_s } */ - Error err = ResourceSaver::save(p_save_path + ".mesh", mesh); - - return err; + return scene; } +Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags) { -ResourceImporterOBJ::ResourceImporterOBJ() { + return Ref<Animation>(); +} +EditorOBJImporter::EditorOBJImporter() { } diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index b7443c71a6..c8285ce6c9 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -30,26 +30,21 @@ #ifndef RESOURCEIMPORTEROBJ_H #define RESOURCEIMPORTEROBJ_H -#include "io/resource_import.h" +#include "import/resource_importer_scene.h" -class ResourceImporterOBJ : public ResourceImporter { - GDCLASS(ResourceImporterOBJ, ResourceImporter) -public: - virtual String get_importer_name() const; - virtual String get_visible_name() const; - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual String get_save_extension() const; - virtual String get_resource_type() const; +class EditorOBJImporter : public EditorSceneImporter { - virtual int get_preset_count() const; - virtual String get_preset_name(int p_idx) const; + GDCLASS(EditorOBJImporter, EditorSceneImporter); - 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; + Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); +public: + virtual uint32_t get_import_flags() const; + virtual void get_extensions(List<String> *r_extensions) const; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags); - ResourceImporterOBJ(); + EditorOBJImporter(); }; #endif // RESOURCEIMPORTEROBJ_H diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 3834e52fab..98020ed9b8 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -416,26 +416,26 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String bool force_normal = normal == 1; if (compress_mode == COMPRESS_VIDEO_RAM) { - //must import in all formats + //must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc). //Android, GLES 2.x - if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_s3tc")) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) { _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("s3tc"); } - if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_etc")) { - _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); - r_platform_variants->push_back("etc"); - } - - if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_etc2")) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("etc2"); } - if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_pvrtc")) { + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) { + _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); + r_platform_variants->push_back("etc"); + } + + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) { _save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("pvrtc"); diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 6c7a633477..24647734ce 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -328,7 +328,6 @@ ImportDock::ImportDock() { add_child(import_opts); import_opts->set_v_size_flags(SIZE_EXPAND_FILL); import_opts->hide_top_label(); - import_opts->set_hide_script(true); hb = memnew(HBoxContainer); add_child(hb); diff --git a/editor/io_plugins/editor_export_scene.cpp b/editor/io_plugins/editor_export_scene.cpp index bdf9dc6844..390217053a 100644 --- a/editor/io_plugins/editor_export_scene.cpp +++ b/editor/io_plugins/editor_export_scene.cpp @@ -30,7 +30,7 @@ #include "editor_export_scene.h" #if 0 #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/dir_access.h" @@ -63,7 +63,7 @@ Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref< uint64_t sd=0; String smd5; - String gp = GlobalConfig::get_singleton()->globalize_path(p_path); + String gp = ProjectSettings::get_singleton()->globalize_path(p_path); String md5=gp.md5_text(); String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/"); diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp index fed02b0e72..5f0e928844 100644 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/editor/io_plugins/editor_scene_import_plugin.cpp @@ -31,7 +31,7 @@ #if 0 #include "editor/create_dialog.h" #include "editor/editor_node.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "os/os.h" @@ -672,9 +672,9 @@ void EditorSceneImportDialog::_choose_save_file(const String& p_path) { void EditorSceneImportDialog::_choose_script(const String& p_path) { - String p = GlobalConfig::get_singleton()->localize_path(p_path); + String p = ProjectSettings::get_singleton()->localize_path(p_path); if (!p.is_resource_file()) - p=GlobalConfig::get_singleton()->get_resource_path().path_to(p_path.get_base_dir())+p_path.get_file(); + p=ProjectSettings::get_singleton()->get_resource_path().path_to(p_path.get_base_dir())+p_path.get_file(); script_path->set_text(p); } @@ -727,7 +727,7 @@ void EditorSceneImportDialog::_import(bool p_and_open) { if (texture_action->get_selected()==0) dst_path=save_path->get_text();//.get_base_dir(); else - dst_path=GlobalConfig::get_singleton()->get("import/shared_textures"); + dst_path=ProjectSettings::get_singleton()->get("import/shared_textures"); uint32_t flags=0; @@ -1277,7 +1277,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce set_hide_on_ok(false); GLOBAL_DEF("import/shared_textures","res://"); - GlobalConfig::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR)); + ProjectSettings::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR)); import_hb->add_constant_override("separation",30); @@ -2812,7 +2812,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c String path = texture->get_path(); String fname= path.get_file(); - String target_path = GlobalConfig::get_singleton()->localize_path(target_res_path.plus_file(fname)); + String target_path = ProjectSettings::get_singleton()->localize_path(target_res_path.plus_file(fname)); progress.step(TTR("Import Image:")+" "+fname,3+(idx)*100/imagemap.size()); idx++; diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp index d48675fa30..842c43f4de 100644 --- a/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/editor/io_plugins/editor_texture_import_plugin.cpp @@ -33,7 +33,7 @@ #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor_atlas.h" -#include "global_config.h" +#include "project_settings.h" #include "io/image_loader.h" #include "io/marshalls.h" #include "io/resource_saver.h" @@ -1653,7 +1653,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c uint8_t f4[4]; encode_uint32(flags,&f4[0]); MD5Init(&ctx); - String gp = GlobalConfig::get_singleton()->globalize_path(p_path); + String gp = ProjectSettings::get_singleton()->globalize_path(p_path); CharString cs = gp.utf8(); MD5Update(&ctx,(unsigned char*)cs.get_data(),cs.length()); MD5Update(&ctx,f4,4); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index c3e1f60ccc..82b03d3a19 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -31,7 +31,7 @@ #include "editor/animation_editor.h" #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/keyboard.h" @@ -372,7 +372,7 @@ void AnimationPlayerEditor::_animation_save_in_path(const Ref<Resource> &p_resou flg |= ResourceSaver::FLAG_RELATIVE_PATHS; */ - String path = GlobalConfig::get_singleton()->localize_path(p_path); + String path = ProjectSettings::get_singleton()->localize_path(p_path); Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err != OK) { diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index d67832e10b..156a74144c 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "animation_tree_editor_plugin.h" -#include "core/global_config.h" #include "core/io/resource_loader.h" +#include "core/project_settings.h" #include "os/input.h" #include "os/keyboard.h" #include "scene/gui/menu_button.h" @@ -371,6 +371,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); + edit_scroll[0]->set_step(0.01); edit_scroll[0]->set_value(anim_tree->mix_node_get_amount(edited_node)); edit_scroll[0]->set_begin(Point2(15, 25)); edit_scroll[0]->show(); @@ -383,6 +384,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); + edit_scroll[0]->set_step(0.01); edit_scroll[0]->set_value(anim_tree->blend2_node_get_amount(edited_node)); edit_scroll[0]->set_begin(Point2(15, 25)); edit_scroll[0]->show(); @@ -398,6 +400,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[0]->show(); edit_scroll[0]->set_min(-1); edit_scroll[0]->set_max(1); + edit_scroll[0]->set_step(0.01); edit_scroll[0]->set_value(anim_tree->blend3_node_get_amount(edited_node)); edit_scroll[0]->set_begin(Point2(15, 25)); edit_scroll[0]->show(); @@ -411,6 +414,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[0]->show(); edit_scroll[0]->set_min(0); edit_scroll[0]->set_max(1); + edit_scroll[0]->set_step(0.01); edit_scroll[0]->set_value(anim_tree->blend4_node_get_amount(edited_node).x); edit_scroll[0]->set_begin(Point2(15, 25)); edit_scroll[0]->show(); @@ -419,6 +423,7 @@ void AnimationTreeEditor::_popup_edit_dialog() { edit_label[1]->show(); edit_scroll[1]->set_min(0); edit_scroll[1]->set_max(1); + edit_scroll[1]->set_step(0.01); edit_scroll[1]->set_value(anim_tree->blend4_node_get_amount(edited_node).y); edit_scroll[1]->set_begin(Point2(15, 75)); edit_scroll[1]->show(); @@ -1408,7 +1413,7 @@ AnimationTreeEditor::AnimationTreeEditor() { file_dialog = memnew(EditorFileDialog); file_dialog->set_enable_multiple_selection(true); - file_dialog->set_current_dir(GlobalConfig::get_singleton()->get_resource_path()); + file_dialog->set_current_dir(ProjectSettings::get_singleton()->get_resource_path()); add_child(file_dialog); file_dialog->connect("file_selected", this, "_file_dialog_selected"); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index b2d3aafd13..4f07fdba2b 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -35,7 +35,7 @@ #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/script_editor_debugger.h" -#include "global_config.h" +#include "project_settings.h" #include "os/input.h" #include "os/keyboard.h" #include "print_string.h" @@ -2007,7 +2007,7 @@ void CanvasItemEditor::_viewport_draw() { VisualServer::get_singleton()->canvas_item_add_line(ci, transform.xform(display_rotate_from), transform.xform(display_rotate_to), rotate_color); } - Size2 screen_size = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height")); + Size2 screen_size = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")); Vector2 screen_endpoints[4] = { transform.xform(Vector2(0, 0)), @@ -2323,7 +2323,7 @@ void CanvasItemEditor::_update_scrollbars() { h_scroll->set_begin(Point2(0, size.height - hmin.height)); h_scroll->set_end(Point2(size.width - vmin.width, size.height)); - Size2 screen_rect = Size2(GlobalConfig::get_singleton()->get("display/window/width"), GlobalConfig::get_singleton()->get("display/window/height")); + Size2 screen_rect = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")); Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height)); @@ -3386,6 +3386,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_loc_button = memnew(Button("loc")); key_loc_button->set_toggle_mode(true); + key_loc_button->set_flat(true); key_loc_button->set_pressed(true); key_loc_button->set_focus_mode(FOCUS_NONE); key_loc_button->add_color_override("font_color", Color(1, 0.6, 0.6)); @@ -3394,6 +3395,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { animation_hb->add_child(key_loc_button); key_rot_button = memnew(Button("rot")); key_rot_button->set_toggle_mode(true); + key_rot_button->set_flat(true); key_rot_button->set_pressed(true); key_rot_button->set_focus_mode(FOCUS_NONE); key_rot_button->add_color_override("font_color", Color(1, 0.6, 0.6)); @@ -3402,12 +3404,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { animation_hb->add_child(key_rot_button); key_scale_button = memnew(Button("scl")); key_scale_button->set_toggle_mode(true); + key_scale_button->set_flat(true); key_scale_button->set_focus_mode(FOCUS_NONE); key_scale_button->add_color_override("font_color", Color(1, 0.6, 0.6)); key_scale_button->add_color_override("font_color_pressed", Color(0.6, 1, 0.6)); key_scale_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_SCALE)); animation_hb->add_child(key_scale_button); key_insert_button = memnew(Button); + key_insert_button->set_flat(true); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY)); key_insert_button->set_tooltip(TTR("Insert Keys")); @@ -3693,7 +3697,7 @@ bool CanvasItemEditorViewport::_create_instance(Node *parent, String &path, cons } } - instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(path)); + instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene); editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene()); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 7f8581535c..ce6eefd694 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -186,7 +186,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from) { Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path) { String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); - String cache_base = GlobalConfig::get_singleton()->globalize_path(p_path).md5_text(); + String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); //does not have it, try to load a cached thumbnail diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 3524c34d62..c32ed1064f 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -204,7 +204,7 @@ void PathSpatialGizmo::redraw() { if (c.is_null()) return; - PoolVector<Vector3> v3a = c->tesselate(); + PoolVector<Vector3> v3a = c->tessellate(); //PoolVector<Vector3> v3a=c->get_baked_points(); int v3s = v3a.size(); @@ -289,7 +289,7 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp if (mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT && (curve_create->is_pressed() || (curve_edit->is_pressed() && mb->get_control()))) { //click into curve, break it down - PoolVector<Vector3> v3a = c->tesselate(); + PoolVector<Vector3> v3a = c->tessellate(); int idx = 0; int rc = v3a.size(); int closest_seg = -1; diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index ea7a84d2f4..463b6360ad 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "resource_preloader_editor_plugin.h" #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" void ResourcePreloaderEditor::_gui_input(Ref<InputEvent> p_event) { diff --git a/editor/plugins/sample_editor_plugin.cpp b/editor/plugins/sample_editor_plugin.cpp index a9af5823e3..0b99ab5460 100644 --- a/editor/plugins/sample_editor_plugin.cpp +++ b/editor/plugins/sample_editor_plugin.cpp @@ -31,7 +31,7 @@ #if 0 #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" diff --git a/editor/plugins/sample_library_editor_plugin.cpp b/editor/plugins/sample_library_editor_plugin.cpp index 9eb1af70d1..04c805165f 100644 --- a/editor/plugins/sample_library_editor_plugin.cpp +++ b/editor/plugins/sample_library_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "sample_library_editor_plugin.h" #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "sample_editor_plugin.h" #include "scene/main/viewport.h" diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index d10831eea1..c90d66f914 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -32,7 +32,7 @@ #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "editor/script_editor_debugger.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/file_access.h" @@ -405,6 +405,8 @@ void ScriptEditor::_go_to_tab(int p_idx) { script_icon->set_texture(c->cast_to<ScriptEditorBase>()->get_icon()); if (is_visible_in_tree()) c->cast_to<ScriptEditorBase>()->ensure_focus(); + + notify_script_changed(c->cast_to<ScriptEditorBase>()->get_edited_script()); } if (c->cast_to<EditorHelp>()) { @@ -510,7 +512,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save) { apply_scripts(); } current->clear_edit_menu(); - + notify_script_close(current->get_edited_script()); } else { EditorHelp *help = tab_container->get_child(selected)->cast_to<EditorHelp>(); _add_recent_script(help->get_class()); @@ -777,6 +779,31 @@ void ScriptEditor::_file_dialog_action(String p_file) { file_dialog_option = -1; } +Ref<Script> ScriptEditor::_get_current_script() { + + int selected = tab_container->get_current_tab(); + if (selected < 0 || selected >= tab_container->get_child_count()) + return NULL; + + ScriptEditorBase *current = tab_container->get_child(selected)->cast_to<ScriptEditorBase>(); + if (current) { + return current->get_edited_script(); + } else { + return NULL; + } +} + +Array ScriptEditor::_get_open_scripts() const { + + Array ret; + Vector<Ref<Script> > scripts = get_open_scripts(); + int scrits_amount = scripts.size(); + for (int idx_script = 0; idx_script < scrits_amount; idx_script++) { + ret.push_back(scripts[idx_script]); + } + return ret; +} + void ScriptEditor::_menu_option(int p_option) { switch (p_option) { @@ -1127,6 +1154,14 @@ void ScriptEditor::edited_scene_changed() { _update_modified_scripts_for_external_editor(); } +void ScriptEditor::notify_script_close(const Ref<Script> &p_script) { + emit_signal("script_close", p_script); +} + +void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) { + emit_signal("editor_script_changed", p_script); +} + static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_script) { if (p_node->get_script() == p_script) @@ -1568,8 +1603,8 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); Dictionary keys; - keys["project"] = GlobalConfig::get_singleton()->get_resource_path(); - keys["file"] = GlobalConfig::get_singleton()->globalize_path(p_script->get_path()); + keys["project"] = ProjectSettings::get_singleton()->get_resource_path(); + keys["file"] = ProjectSettings::get_singleton()->globalize_path(p_script->get_path()); keys["line"] = p_line >= 0 ? p_line : 0; keys["col"] = p_col; @@ -1662,6 +1697,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool if (p_line >= 0) se->goto_line(p_line - 1); + notify_script_changed(p_script); return true; } @@ -2038,6 +2074,8 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { n->cast_to<ScriptEditorBase>()->set_edit_state(history[history_pos].state); n->cast_to<ScriptEditorBase>()->ensure_focus(); + + notify_script_changed(n->cast_to<ScriptEditorBase>()->get_edited_script()); } if (n->cast_to<EditorHelp>()) { @@ -2065,6 +2103,21 @@ void ScriptEditor::_history_back() { _update_history_pos(history_pos - 1); } } + +Vector<Ref<Script> > ScriptEditor::get_open_scripts() const { + + Vector<Ref<Script> > out_scripts = Vector<Ref<Script> >(); + + for (int i = 0; i < tab_container->get_child_count(); i++) { + ScriptEditorBase *se = tab_container->get_child(i)->cast_to<ScriptEditorBase>(); + if (!se) + continue; + out_scripts.push_back(se->get_edited_script()); + } + + return out_scripts; +} + void ScriptEditor::set_scene_root_script(Ref<Script> p_script) { bool open_dominant = EditorSettings::get_singleton()->get("text_editor/files/open_dominant_script_on_scene_change"); @@ -2158,6 +2211,12 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_history_back", &ScriptEditor::_history_back); ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts); ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input); + + ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script); + ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts); + + ADD_SIGNAL(MethodInfo("editor_script_changed", PropertyInfo(Variant::OBJECT, "script:Script"))); + ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::STRING, "script:String"))); } ScriptEditor::ScriptEditor(EditorNode *p_editor) { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 010a5604ec..d8a9415df1 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -321,6 +321,9 @@ class ScriptEditor : public PanelContainer { int file_dialog_option; void _file_dialog_action(String p_file); + Ref<Script> _get_current_script(); + Array _get_open_scripts() const; + static void _open_script_request(const String &p_path); static ScriptEditor *script_editor; @@ -354,11 +357,15 @@ public: void get_window_layout(Ref<ConfigFile> p_layout); void set_scene_root_script(Ref<Script> p_script); + Vector<Ref<Script> > get_open_scripts() const; bool script_goto_method(Ref<Script> p_script, const String &p_method); virtual void edited_scene_changed(); + void notify_script_close(const Ref<Script> &p_script); + void notify_script_changed(const Ref<Script> &p_script); + void close_builtin_scripts_from_scene(const String &p_scene); void goto_help(const String &p_desc) { _help_class_goto(p_desc); } diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 83741c7fb8..e260b1ea22 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1276,8 +1276,6 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha)); } color_panel->set_position(get_global_transform().xform(get_local_mouse_pos())); - Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height + 10); - color_panel->set_size(ms); } else { have_color = false; } @@ -1360,7 +1358,6 @@ ScriptTextEditor::ScriptTextEditor() { add_child(color_panel); color_picker = memnew(ColorPicker); color_panel->add_child(color_picker); - color_panel->set_child_rect(color_picker); //NOT color_picker->connect("color_changed", this, "_color_changed"); edit_hb = memnew(HBoxContainer); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index d7f4781e89..8e6e92d48b 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -36,7 +36,7 @@ #include "editor/editor_settings.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/spatial_editor_gizmos.h" -#include "global_config.h" +#include "project_settings.h" #include "os/keyboard.h" #include "print_string.h" #include "scene/3d/camera.h" @@ -1717,11 +1717,11 @@ void SpatialEditorViewport::_notification(int p_what) { //update shadow atlas if changed - int shadowmap_size = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/size"); - int atlas_q0 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_0_subdiv"); - int atlas_q1 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_1_subdiv"); - int atlas_q2 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_2_subdiv"); - int atlas_q3 = GlobalConfig::get_singleton()->get("rendering/shadow_atlas/quadrant_3_subdiv"); + int shadowmap_size = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/size"); + int atlas_q0 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_0_subdiv"); + int atlas_q1 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_1_subdiv"); + int atlas_q2 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_2_subdiv"); + int atlas_q3 = ProjectSettings::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_3_subdiv"); viewport->set_shadow_atlas_size(shadowmap_size); viewport->set_shadow_atlas_quadrant_subdiv(0, Viewport::ShadowAtlasQuadrantSubdiv(atlas_q0)); @@ -1731,10 +1731,10 @@ void SpatialEditorViewport::_notification(int p_what) { //update msaa if changed - int msaa_mode = GlobalConfig::get_singleton()->get("rendering/quality/msaa"); + int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa"); viewport->set_msaa(Viewport::MSAA(msaa_mode)); - bool hdr = GlobalConfig::get_singleton()->get("rendering/quality/hdr"); + bool hdr = ProjectSettings::get_singleton()->get("rendering/quality/depth/hdr"); viewport->set_hdr(hdr); bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION)); @@ -1834,7 +1834,7 @@ void SpatialEditorViewport::_draw() { if (previewing) { - Size2 ss = Size2(GlobalConfig::get_singleton()->get("display/width"), GlobalConfig::get_singleton()->get("display/height")); + Size2 ss = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")); float aspect = ss.aspect(); Size2 s = get_size(); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d06c065f4f..fa80894f7b 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "sprite_frames_editor_plugin.h" #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" #include "scene/3d/sprite_3d.h" diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index c4fe15e61c..70a1227c52 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -30,7 +30,7 @@ #include "texture_editor_plugin.h" #include "editor/editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_loader.h" void TextureEditor::_gui_input(Ref<InputEvent> p_event) { diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 355f8ba22e..b498044a65 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -32,7 +32,7 @@ #include "editor_data.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "io/image_loader.h" #include "io/resource_loader.h" #include "io/resource_saver.h" @@ -51,6 +51,7 @@ void ProjectExportDialog::_notification(int p_what) { case NOTIFICATION_READY: { delete_preset->set_icon(get_icon("Del", "EditorIcons")); connect("confirmed", this, "_export_pck_zip"); + custom_feature_display->get_parent_control()->add_style_override("panel", get_stylebox("bg", "Tree")); } break; case NOTIFICATION_POPUP_HIDE: { EditorSettings::get_singleton()->set("interface/dialogs/export_bounds", get_rect()); @@ -240,9 +241,62 @@ void ProjectExportDialog::_edit_preset(int p_index) { export_button->set_disabled(false); } + custom_features->set_text(current->get_custom_features()); + _update_feature_list(); + updating = false; } +void ProjectExportDialog::_update_feature_list() { + + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); + + Set<String> fset; + List<String> features; + + current->get_platform()->get_platform_features(&features); + current->get_platform()->get_preset_features(current, &features); + + String custom = current->get_custom_features(); + Vector<String> custom_list = custom.split(","); + for (int i = 0; i < custom_list.size(); i++) { + String f = custom_list[i].strip_edges(); + if (f != String()) { + features.push_back(f); + } + } + + for (List<String>::Element *E = features.front(); E; E = E->next()) { + fset.insert(E->get()); + } + + custom_feature_display->clear(); + for (Set<String>::Element *E = fset.front(); E; E = E->next()) { + String f = E->get(); + if (E->next()) { + f += ", "; + } + custom_feature_display->add_text(f); + } +} + +void ProjectExportDialog::_custom_features_changed(const String &p_text) { + + if (updating) + return; + + Ref<EditorExportPreset> current = EditorExport::get_singleton()->get_export_preset(presets->get_current()); + ERR_FAIL_COND(current.is_null()); + + current->set_custom_features(p_text); + _update_feature_list(); +} + +void ProjectExportDialog::_tab_changed(int) { + _update_feature_list(); +} + void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, int p_id) { TreeItem *ti = (TreeItem *)p_item; @@ -294,10 +348,10 @@ void ProjectExportDialog::_patch_selected(const String &p_path) { if (patch_index >= patches.size()) { - current->add_patch(GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + "*"); + current->add_patch(ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + "*"); } else { String enabled = patches[patch_index].ends_with("*") ? String("*") : String(); - current->set_patch(patch_index, GlobalConfig::get_singleton()->get_resource_path().path_to(p_path) + enabled); + current->set_patch(patch_index, ProjectSettings::get_singleton()->get_resource_path().path_to(p_path) + enabled); } _edit_preset(presets->get_current()); @@ -705,6 +759,8 @@ void ProjectExportDialog::_bind_methods() { ClassDB::bind_method("_open_export_template_manager", &ProjectExportDialog::_open_export_template_manager); ClassDB::bind_method("_export_project", &ProjectExportDialog::_export_project); ClassDB::bind_method("_export_project_to_path", &ProjectExportDialog::_export_project_to_path); + ClassDB::bind_method("_custom_features_changed", &ProjectExportDialog::_custom_features_changed); + ClassDB::bind_method("_tab_changed", &ProjectExportDialog::_tab_changed); } ProjectExportDialog::ProjectExportDialog() { @@ -763,7 +819,7 @@ ProjectExportDialog::ProjectExportDialog() { parameters->set_name(TTR("Options")); parameters->hide_top_label(); parameters->set_v_size_flags(SIZE_EXPAND_FILL); - parameters->set_hide_script(true); + parameters->connect("property_edited", this, "_update_parameters"); VBoxContainer *resources_vb = memnew(VBoxContainer); @@ -828,6 +884,21 @@ ProjectExportDialog::ProjectExportDialog() { patch_erase->connect("confirmed", this, "_patch_deleted"); add_child(patch_erase); + VBoxContainer *feature_vb = memnew(VBoxContainer); + feature_vb->set_name(TTR("Features")); + custom_features = memnew(LineEdit); + custom_features->connect("text_changed", this, "_custom_features_changed"); + feature_vb->add_margin_child(TTR("Custom (comma-separated):"), custom_features); + Panel *features_panel = memnew(Panel); + custom_feature_display = memnew(RichTextLabel); + features_panel->add_child(custom_feature_display); + custom_feature_display->set_area_as_parent_rect(10 * EDSCALE); + custom_feature_display->set_v_size_flags(SIZE_EXPAND_FILL); + feature_vb->add_margin_child(TTR("Feature List:"), features_panel, true); + sections->add_child(feature_vb); + + sections->connect("tab_changed", this, "_tab_changed"); + //disable by default name->set_editable(false); runnable->set_disabled(true); diff --git a/editor/project_export.h b/editor/project_export.h index a3bbfc52ff..29c24005e0 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -40,6 +40,7 @@ #include "scene/gui/label.h" #include "scene/gui/link_button.h" #include "scene/gui/option_button.h" +#include "scene/gui/rich_text_label.h" #include "scene/gui/tab_container.h" #include "scene/gui/tree.h" #include "scene/main/timer.h" @@ -91,6 +92,9 @@ private: Button *export_button; + LineEdit *custom_features; + RichTextLabel *custom_feature_display; + Label *export_error; HBoxContainer *export_templates_error; @@ -132,6 +136,11 @@ private: void _export_project(); void _export_project_to_path(const String &p_path); + void _update_feature_list(); + void _custom_features_changed(const String &p_text); + + void _tab_changed(int); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index e3f22c833e..acf5fe02cc 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -202,10 +202,10 @@ private: f->store_line("\n"); f->store_line("[application]"); f->store_line("\n"); - f->store_line("name=\"" + project_name->get_text() + "\""); - f->store_line("icon=\"res://icon.png\""); + f->store_line("config/name=\"" + project_name->get_text() + "\""); + f->store_line("config/icon=\"res://icon.png\""); f->store_line("[rendering]"); - f->store_line("viewport/default_environment=\"res://default_env.tres\""); + f->store_line("environment/default_environment=\"res://default_env.tres\""); memdelete(f); ResourceSaver::save(dir.plus_file("/icon.png"), get_icon("DefaultProjectIcon", "EditorIcons")); @@ -811,16 +811,16 @@ void ProjectManager::_load_recent_projects() { String project_name = TTR("Unnamed Project"); - if (cf->has_section_key("application", "name")) { - project_name = static_cast<String>(cf->get_value("application", "name")).xml_unescape(); + if (cf->has_section_key("application", "config/name")) { + project_name = static_cast<String>(cf->get_value("application", "config/name")).xml_unescape(); } if (filter_option == ProjectListFilter::FILTER_NAME && search_term != "" && project_name.findn(search_term) == -1) continue; Ref<Texture> icon; - if (cf->has_section_key("application", "icon")) { - String appicon = cf->get_value("application", "icon"); + if (cf->has_section_key("application", "config/icon")) { + String appicon = cf->get_value("application", "config/icon"); if (appicon != "") { Ref<Image> img; img.instance(); @@ -840,8 +840,8 @@ void ProjectManager::_load_recent_projects() { } String main_scene; - if (cf->has_section_key("application", "main_scene")) { - main_scene = cf->get_value("application", "main_scene"); + if (cf->has_section_key("application", "run/main_scene")) { + main_scene = cf->get_value("application", "run/main_scene"); } selected_list_copy.erase(project); diff --git a/editor/project_settings.cpp b/editor/project_settings_editor.cpp index 17a35282de..6d23e874df 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings_editor.cpp @@ -27,17 +27,17 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "project_settings.h" +#include "project_settings_editor.h" #include "editor_node.h" -#include "global_config.h" #include "global_constants.h" #include "os/keyboard.h" +#include "project_settings.h" #include "scene/gui/margin_container.h" #include "scene/gui/tab_container.h" #include "translation.h" -ProjectSettings *ProjectSettings::singleton = NULL; +ProjectSettingsEditor *ProjectSettingsEditor::singleton = NULL; static const char *_button_names[JOY_BUTTON_MAX] = { "PS Cross, XBox A, Nintendo B", @@ -72,11 +72,11 @@ static const char *_axis_names[JOY_AXIS_MAX * 2] = { "", " (R2)" }; -void ProjectSettings::_notification(int p_what) { +void ProjectSettingsEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - globals_editor->edit(GlobalConfig::get_singleton()); + globals_editor->edit(ProjectSettings::get_singleton()); search_button->set_icon(get_icon("Search", "EditorIcons")); clear_button->set_icon(get_icon("Close", "EditorIcons")); @@ -112,7 +112,7 @@ void ProjectSettings::_notification(int p_what) { } } -void ProjectSettings::_action_selected() { +void ProjectSettingsEditor::_action_selected() { TreeItem *ti = input_editor->get_selected(); if (!ti || !ti->is_editable(0)) @@ -122,7 +122,7 @@ void ProjectSettings::_action_selected() { edit_idx = -1; } -void ProjectSettings::_action_edited() { +void ProjectSettingsEditor::_action_edited() { TreeItem *ti = input_editor->get_selected(); if (!ti) @@ -146,7 +146,7 @@ void ProjectSettings::_action_edited() { String action_prop = "input/" + new_name; - if (GlobalConfig::get_singleton()->has(action_prop)) { + if (ProjectSettings::get_singleton()->has(action_prop)) { ti->set_text(0, old_name); add_at = "input/" + old_name; @@ -156,17 +156,17 @@ void ProjectSettings::_action_edited() { return; } - int order = GlobalConfig::get_singleton()->get_order(add_at); - Array va = GlobalConfig::get_singleton()->get(add_at); + int order = ProjectSettings::get_singleton()->get_order(add_at); + Array va = ProjectSettings::get_singleton()->get(add_at); setting = true; undo_redo->create_action(TTR("Rename Input Action Event")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", add_at); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", action_prop, va); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set_order", action_prop, order); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", action_prop); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", add_at, va); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", add_at, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", add_at); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, va); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", action_prop, order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", action_prop); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, va); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", add_at, order); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -177,12 +177,12 @@ void ProjectSettings::_action_edited() { add_at = action_prop; } -void ProjectSettings::_device_input_add() { +void ProjectSettingsEditor::_device_input_add() { Ref<InputEvent> ie; String name = add_at; int idx = edit_idx; - Variant old_val = GlobalConfig::get_singleton()->get(name); + Variant old_val = ProjectSettings::get_singleton()->get(name); Array arr = old_val; // ie.device = device_id->get_value(); // ie.type = add_type; @@ -260,8 +260,8 @@ void ProjectSettings::_device_input_add() { } undo_redo->create_action(TTR("Add Input Action Event")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -271,7 +271,7 @@ void ProjectSettings::_device_input_add() { _show_last_added(ie, name); } -void ProjectSettings::_press_a_key_confirm() { +void ProjectSettingsEditor::_press_a_key_confirm() { if (last_wait_for_key.is_null()) return; @@ -287,7 +287,7 @@ void ProjectSettings::_press_a_key_confirm() { String name = add_at; int idx = edit_idx; - Variant old_val = GlobalConfig::get_singleton()->get(name); + Variant old_val = ProjectSettings::get_singleton()->get(name); Array arr = old_val; for (int i = 0; i < arr.size(); i++) { @@ -307,8 +307,8 @@ void ProjectSettings::_press_a_key_confirm() { } undo_redo->create_action(TTR("Add Input Action Event")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, arr); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -318,7 +318,7 @@ void ProjectSettings::_press_a_key_confirm() { _show_last_added(ie, name); } -void ProjectSettings::_show_last_added(const Ref<InputEvent> &p_event, const String &p_name) { +void ProjectSettingsEditor::_show_last_added(const Ref<InputEvent> &p_event, const String &p_name) { TreeItem *r = input_editor->get_root(); String name = p_name; @@ -351,7 +351,7 @@ void ProjectSettings::_show_last_added(const Ref<InputEvent> &p_event, const Str if (found) input_editor->ensure_cursor_is_visible(); } -void ProjectSettings::_wait_for_key(const Ref<InputEvent> &p_event) { +void ProjectSettingsEditor::_wait_for_key(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; @@ -373,7 +373,7 @@ void ProjectSettings::_wait_for_key(const Ref<InputEvent> &p_event) { } } -void ProjectSettings::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { +void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { add_type = InputType(p_item); @@ -458,7 +458,7 @@ void ProjectSettings::_add_item(int p_item, Ref<InputEvent> p_exiting_event) { } } -void ProjectSettings::_edit_item(Ref<InputEvent> p_exiting_event) { +void ProjectSettingsEditor::_edit_item(Ref<InputEvent> p_exiting_event) { InputType ie_type; @@ -480,7 +480,7 @@ void ProjectSettings::_edit_item(Ref<InputEvent> p_exiting_event) { _add_item(ie_type, p_exiting_event); } -void ProjectSettings::_action_activated() { +void ProjectSettingsEditor::_action_activated() { TreeItem *ti = input_editor->get_selected(); @@ -489,7 +489,7 @@ void ProjectSettings::_action_activated() { String name = "input/" + ti->get_parent()->get_text(0); int idx = ti->get_metadata(0); - Array va = GlobalConfig::get_singleton()->get(name); + Array va = ProjectSettings::get_singleton()->get(name); ERR_FAIL_INDEX(idx, va.size()); @@ -503,7 +503,7 @@ void ProjectSettings::_action_activated() { _edit_item(ie); } -void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_id) { +void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) { TreeItem *ti = p_obj->cast_to<TreeItem>(); @@ -528,13 +528,13 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ //remove main thing String name = "input/" + ti->get_text(0); - Variant old_val = GlobalConfig::get_singleton()->get(name); - int order = GlobalConfig::get_singleton()->get_order(name); + Variant old_val = ProjectSettings::get_singleton()->get(name); + int order = ProjectSettings::get_singleton()->get_order(name); undo_redo->create_action(TTR("Add Input Action")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "clear", name); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set_order", name, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", name); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", name, order); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -544,7 +544,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ } else { //remove action String name = "input/" + ti->get_parent()->get_text(0); - Variant old_val = GlobalConfig::get_singleton()->get(name); + Variant old_val = ProjectSettings::get_singleton()->get(name); int idx = ti->get_metadata(0); Array va = old_val; @@ -559,8 +559,8 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ va.resize(va.size() - 1); undo_redo->create_action(TTR("Erase Input Action Event")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "set", name, old_val); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -579,7 +579,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ //edit action String name = "input/" + ti->get_parent()->get_text(0); int idx = ti->get_metadata(0); - Array va = GlobalConfig::get_singleton()->get(name); + Array va = ProjectSettings::get_singleton()->get(name); ERR_FAIL_INDEX(idx, va.size()); @@ -596,7 +596,7 @@ void ProjectSettings::_action_button_pressed(Object *p_obj, int p_column, int p_ } } -void ProjectSettings::_update_actions() { +void ProjectSettingsEditor::_update_actions() { if (setting) return; @@ -606,7 +606,7 @@ void ProjectSettings::_update_actions() { input_editor->set_hide_root(true); List<PropertyInfo> props; - GlobalConfig::get_singleton()->get_property_list(&props); + ProjectSettings::get_singleton()->get_property_list(&props); for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { @@ -622,14 +622,14 @@ void ProjectSettings::_update_actions() { //item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); item->set_text(0, name); item->add_button(0, get_icon("Add", "EditorIcons"), 1, false, TTR("Add Event")); - if (!GlobalConfig::get_singleton()->get_input_presets().find(pi.name)) { + if (!ProjectSettings::get_singleton()->get_input_presets().find(pi.name)) { item->add_button(0, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove")); item->set_editable(0, true); } item->set_custom_bg_color(0, get_color("prop_subsection", "Editor")); //item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED); - Array actions = GlobalConfig::get_singleton()->get(pi.name); + Array actions = ProjectSettings::get_singleton()->get(pi.name); for (int i = 0; i < actions.size(); i++) { @@ -706,7 +706,7 @@ void ProjectSettings::_update_actions() { } } -void ProjectSettings::popup_project_settings() { +void ProjectSettingsEditor::popup_project_settings() { // Restore valid window bounds or pop up at default size. if (EditorSettings::get_singleton()->has("interface/dialogs/project_settings_bounds")) { @@ -720,7 +720,7 @@ void ProjectSettings::popup_project_settings() { plugin_settings->update_plugins(); } -void ProjectSettings::_item_selected() { +void ProjectSettingsEditor::_item_selected() { TreeItem *ti = globals_editor->get_property_editor()->get_scene_tree()->get_selected(); if (!ti) @@ -729,15 +729,15 @@ void ProjectSettings::_item_selected() { return; category->set_text(globals_editor->get_current_section()); property->set_text(ti->get_text(0)); - popup_platform->set_disabled(false); + popup_copy_to_feature->set_disabled(false); } -void ProjectSettings::_item_adds(String) { +void ProjectSettingsEditor::_item_adds(String) { _item_add(); } -void ProjectSettings::_item_add() { +void ProjectSettingsEditor::_item_add() { Variant value; switch (type->get_selected()) { @@ -765,12 +765,12 @@ void ProjectSettings::_item_add() { undo_redo->create_action("Add Global Property"); - undo_redo->add_do_property(GlobalConfig::get_singleton(), name, value); + undo_redo->add_do_property(ProjectSettings::get_singleton(), name, value); - if (GlobalConfig::get_singleton()->has(name)) { - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name)); + if (ProjectSettings::get_singleton()->has(name)) { + undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); } else { - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, Variant()); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant()); } undo_redo->add_do_method(globals_editor, "update_category_list"); @@ -786,20 +786,35 @@ void ProjectSettings::_item_add() { _settings_changed(); } -void ProjectSettings::_item_del() { +void ProjectSettingsEditor::_item_del() { - String catname = category->get_text().strip_edges(); - //ERR_FAIL_COND(!catname.is_valid_identifier()); - String propname = property->get_text().strip_edges(); - //ERR_FAIL_COND(!propname.is_valid_identifier()); + String path = globals_editor->get_property_editor()->get_selected_path(); + if (path == String()) { + EditorNode::get_singleton()->show_warning(TTR("Select an setting item first!")); + return; + } - String name = catname != "" ? catname + "/" + propname : propname; + String property = globals_editor->get_current_section().plus_file(path); - undo_redo->create_action("Delete Global Property"); + if (!ProjectSettings::get_singleton()->has(property)) { + EditorNode::get_singleton()->show_warning(TTR("No property '" + property + "' exists.")); + return; + } - undo_redo->add_do_property(GlobalConfig::get_singleton(), name, Variant()); + if (ProjectSettings::get_singleton()->get_order(property) < ProjectSettings::NO_BUILTIN_ORDER_BASE) { + EditorNode::get_singleton()->show_warning(TTR("Setting '" + property + "' is internal, and it can't be deleted.")); + return; + } - undo_redo->add_undo_property(GlobalConfig::get_singleton(), name, GlobalConfig::get_singleton()->get(name)); + print_line("to delete.. " + property); + undo_redo->create_action(TTR("Delete Item")); + + Variant value = ProjectSettings::get_singleton()->get(property); + int order = ProjectSettings::get_singleton()->get_order(property); + + undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", property, order); undo_redo->add_do_method(globals_editor, "update_category_list"); undo_redo->add_undo_method(globals_editor, "update_category_list"); @@ -808,16 +823,14 @@ void ProjectSettings::_item_del() { undo_redo->add_undo_method(this, "_settings_changed"); undo_redo->commit_action(); - - _settings_changed(); } -void ProjectSettings::_action_adds(String) { +void ProjectSettingsEditor::_action_adds(String) { _action_add(); } -void ProjectSettings::_action_add() { +void ProjectSettingsEditor::_action_add() { String action = action_name->get_text(); if (action.find("/") != -1 || action.find(":") != -1 || action == "") { @@ -826,7 +839,7 @@ void ProjectSettings::_action_add() { return; } - if (GlobalConfig::get_singleton()->has("input/" + action)) { + if (ProjectSettings::get_singleton()->has("input/" + action)) { message->set_text(vformat(TTR("Action '%s' already exists!"), action)); message->popup_centered(Size2(300, 100)); return; @@ -835,8 +848,8 @@ void ProjectSettings::_action_add() { Array va; String name = "input/" + action; undo_redo->create_action(TTR("Add Input Action Event")); - undo_redo->add_do_method(GlobalConfig::get_singleton(), "set", name, va); - undo_redo->add_undo_method(GlobalConfig::get_singleton(), "clear", name); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name); undo_redo->add_do_method(this, "_update_actions"); undo_redo->add_undo_method(this, "_update_actions"); undo_redo->add_do_method(this, "_settings_changed"); @@ -859,66 +872,119 @@ void ProjectSettings::_action_add() { input_editor->ensure_cursor_is_visible(); } -void ProjectSettings::_item_checked(const String &p_item, bool p_check) { +void ProjectSettingsEditor::_item_checked(const String &p_item, bool p_check) { } -void ProjectSettings::_save() { +void ProjectSettingsEditor::_save() { - Error err = GlobalConfig::get_singleton()->save(); + Error err = ProjectSettings::get_singleton()->save(); message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK.")); message->popup_centered(Size2(300, 100)); } -void ProjectSettings::_settings_prop_edited(const String &p_name) { +void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) { String full_item = globals_editor->get_full_item_path(p_name); _settings_changed(); } -void ProjectSettings::_settings_changed() { +void ProjectSettingsEditor::_settings_changed() { timer->start(); } -void ProjectSettings::queue_save() { +void ProjectSettingsEditor::queue_save() { _settings_changed(); } -void ProjectSettings::_copy_to_platform(int p_which) { +void ProjectSettingsEditor::_copy_to_platform_about_to_show() { - String catname = category->get_text(); - if (!catname.is_valid_identifier()) { - message->set_text("Invalid Category.\nValid characters: a-z,A-Z,0-9 or _"); - message->popup_centered(Size2(300, 100)); - return; + Set<String> presets; + + presets.insert("s3tc"); + presets.insert("etc"); + presets.insert("etc2"); + presets.insert("pvrtc"); + presets.insert("debug"); + presets.insert("release"); + + for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { + List<String> p; + EditorExport::get_singleton()->get_export_platform(i)->get_platform_features(&p); + for (List<String>::Element *E = p.front(); E; E = E->next()) { + presets.insert(E->get()); + } } - String propname = property->get_text(); - if (!propname.is_valid_identifier()) { - message->set_text("Invalid Property.\nValid characters: a-z,A-Z,0-9 or _"); - message->popup_centered(Size2(300, 100)); + for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) { + + List<String> p; + EditorExport::get_singleton()->get_export_preset(i)->get_platform()->get_preset_features(EditorExport::get_singleton()->get_export_preset(i), &p); + for (List<String>::Element *E = p.front(); E; E = E->next()) { + presets.insert(E->get()); + } + + String custom = EditorExport::get_singleton()->get_export_preset(i)->get_custom_features(); + Vector<String> custom_list = custom.split(","); + for (int i = 0; i < custom_list.size(); i++) { + String f = custom_list[i].strip_edges(); + if (f != String()) { + presets.insert(f); + } + } + } + + popup_copy_to_feature->get_popup()->clear(); + int id = 0; + for (Set<String>::Element *E = presets.front(); E; E = E->next()) { + popup_copy_to_feature->get_popup()->add_item(E->get(), id++); + } +} + +void ProjectSettingsEditor::_copy_to_platform(int p_which) { + + String path = globals_editor->get_property_editor()->get_selected_path(); + if (path == String()) { + EditorNode::get_singleton()->show_warning(TTR("Select an setting item first!")); return; } - String name = catname + "/" + propname; - Variant value = GlobalConfig::get_singleton()->get(name); + String property = globals_editor->get_current_section().plus_file(path); - catname += "." + popup_platform->get_popup()->get_item_text(p_which); - name = catname + "/" + propname; + undo_redo->create_action(TTR("Override for Feature")); - GlobalConfig::get_singleton()->set(name, value); - globals_editor->get_property_editor()->update_tree(); + Variant value = ProjectSettings::get_singleton()->get(property); + if (property.find(".") != -1) { //overwriting overwrite, keep overwrite + undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value); + } + + String feature = popup_copy_to_feature->get_popup()->get_item_text(p_which); + String new_path = property + "." + feature; + + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", new_path, value); + if (ProjectSettings::get_singleton()->has(new_path)) { + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", new_path, ProjectSettings::get_singleton()->get(new_path)); + } + + undo_redo->add_do_method(globals_editor, "update_category_list"); + undo_redo->add_undo_method(globals_editor, "update_category_list"); + + undo_redo->add_do_method(this, "_settings_changed"); + undo_redo->add_undo_method(this, "_settings_changed"); + + undo_redo->commit_action(); } -void ProjectSettings::add_translation(const String &p_translation) { +void ProjectSettingsEditor::add_translation(const String &p_translation) { _translation_add(p_translation); } -void ProjectSettings::_translation_add(const String &p_path) { +void ProjectSettingsEditor::_translation_add(const String &p_path) { - PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations"); + PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); for (int i = 0; i < translations.size(); i++) { @@ -928,8 +994,8 @@ void ProjectSettings::_translation_add(const String &p_path) { translations.push_back(p_path); undo_redo->create_action(TTR("Add Translation")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translations", translations); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translations", ProjectSettings::get_singleton()->get("locale/translations")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -937,27 +1003,27 @@ void ProjectSettings::_translation_add(const String &p_path) { undo_redo->commit_action(); } -void ProjectSettings::_translation_file_open() { +void ProjectSettingsEditor::_translation_file_open() { translation_file_open->popup_centered_ratio(); } -void ProjectSettings::_translation_delete(Object *p_item, int p_column, int p_button) { +void ProjectSettingsEditor::_translation_delete(Object *p_item, int p_column, int p_button) { TreeItem *ti = p_item->cast_to<TreeItem>(); ERR_FAIL_COND(!ti); int idx = ti->get_metadata(0); - PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations"); + PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); ERR_FAIL_INDEX(idx, translations.size()); translations.remove(idx); undo_redo->create_action(TTR("Remove Translation")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translations", translations); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translations", GlobalConfig::get_singleton()->get("locale/translations")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translations", translations); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translations", ProjectSettings::get_singleton()->get("locale/translations")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -965,18 +1031,18 @@ void ProjectSettings::_translation_delete(Object *p_item, int p_column, int p_bu undo_redo->commit_action(); } -void ProjectSettings::_translation_res_file_open() { +void ProjectSettingsEditor::_translation_res_file_open() { translation_res_file_open->popup_centered_ratio(); } -void ProjectSettings::_translation_res_add(const String &p_path) { +void ProjectSettingsEditor::_translation_res_add(const String &p_path) { Variant prev; Dictionary remaps; - if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) { - remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) { + remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); prev = remaps; } @@ -986,8 +1052,8 @@ void ProjectSettings::_translation_res_add(const String &p_path) { remaps[p_path] = PoolStringArray(); undo_redo->create_action(TTR("Add Remapped Path")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", prev); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", prev); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -995,15 +1061,15 @@ void ProjectSettings::_translation_res_add(const String &p_path) { undo_redo->commit_action(); } -void ProjectSettings::_translation_res_option_file_open() { +void ProjectSettingsEditor::_translation_res_option_file_open() { translation_res_option_file_open->popup_centered_ratio(); } -void ProjectSettings::_translation_res_option_add(const String &p_path) { +void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) { - ERR_FAIL_COND(!GlobalConfig::get_singleton()->has("locale/translation_remaps")); + ERR_FAIL_COND(!ProjectSettings::get_singleton()->has("locale/translation_remaps")); - Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); TreeItem *k = translation_remap->get_selected(); ERR_FAIL_COND(!k); @@ -1016,8 +1082,8 @@ void ProjectSettings::_translation_res_option_add(const String &p_path) { remaps[key] = r; undo_redo->create_action(TTR("Resource Remap Add Remap")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -1025,7 +1091,7 @@ void ProjectSettings::_translation_res_option_add(const String &p_path) { undo_redo->commit_action(); } -void ProjectSettings::_translation_res_select() { +void ProjectSettingsEditor::_translation_res_select() { if (updating_translations) return; @@ -1033,15 +1099,15 @@ void ProjectSettings::_translation_res_select() { call_deferred("_update_translations"); } -void ProjectSettings::_translation_res_option_changed() { +void ProjectSettingsEditor::_translation_res_option_changed() { if (updating_translations) return; - if (!GlobalConfig::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) return; - Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); TreeItem *k = translation_remap->get_selected(); ERR_FAIL_COND(!k); @@ -1065,8 +1131,8 @@ void ProjectSettings::_translation_res_option_changed() { updating_translations = true; undo_redo->create_action(TTR("Change Resource Remap Language")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -1075,15 +1141,15 @@ void ProjectSettings::_translation_res_option_changed() { updating_translations = false; } -void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int p_button) { +void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column, int p_button) { if (updating_translations) return; - if (!GlobalConfig::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) return; - Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); TreeItem *k = p_item->cast_to<TreeItem>(); @@ -1093,8 +1159,8 @@ void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int remaps.erase(key); undo_redo->create_action(TTR("Remove Resource Remap")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -1102,15 +1168,15 @@ void ProjectSettings::_translation_res_delete(Object *p_item, int p_column, int undo_redo->commit_action(); } -void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_column, int p_button) { +void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button) { if (updating_translations) return; - if (!GlobalConfig::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) return; - Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); TreeItem *k = translation_remap->get_selected(); ERR_FAIL_COND(!k); @@ -1127,8 +1193,8 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_colum remaps[key] = r; undo_redo->create_action(TTR("Remove Resource Remap Option")); - undo_redo->add_do_property(GlobalConfig::get_singleton(), "locale/translation_remaps", remaps); - undo_redo->add_undo_property(GlobalConfig::get_singleton(), "locale/translation_remaps", GlobalConfig::get_singleton()->get("locale/translation_remaps")); + undo_redo->add_do_property(ProjectSettings::get_singleton(), "locale/translation_remaps", remaps); + undo_redo->add_undo_property(ProjectSettings::get_singleton(), "locale/translation_remaps", ProjectSettings::get_singleton()->get("locale/translation_remaps")); undo_redo->add_do_method(this, "_update_translations"); undo_redo->add_undo_method(this, "_update_translations"); undo_redo->add_do_method(this, "_settings_changed"); @@ -1136,7 +1202,7 @@ void ProjectSettings::_translation_res_option_delete(Object *p_item, int p_colum undo_redo->commit_action(); } -void ProjectSettings::_update_translations() { +void ProjectSettingsEditor::_update_translations() { //update translations @@ -1148,9 +1214,9 @@ void ProjectSettings::_update_translations() { translation_list->clear(); TreeItem *root = translation_list->create_item(NULL); translation_list->set_hide_root(true); - if (GlobalConfig::get_singleton()->has("locale/translations")) { + if (ProjectSettings::get_singleton()->has("locale/translations")) { - PoolStringArray translations = GlobalConfig::get_singleton()->get("locale/translations"); + PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); for (int i = 0; i < translations.size(); i++) { TreeItem *t = translation_list->create_item(root); @@ -1186,9 +1252,9 @@ void ProjectSettings::_update_translations() { langnames += names[i]; } - if (GlobalConfig::get_singleton()->has("locale/translation_remaps")) { + if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) { - Dictionary remaps = GlobalConfig::get_singleton()->get("locale/translation_remaps"); + Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; remaps.get_key_list(&rk); Vector<String> keys; @@ -1241,7 +1307,7 @@ void ProjectSettings::_update_translations() { updating_translations = false; } -void ProjectSettings::_toggle_search_bar(bool p_pressed) { +void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) { globals_editor->get_property_editor()->set_use_filter(p_pressed); @@ -1258,7 +1324,7 @@ void ProjectSettings::_toggle_search_bar(bool p_pressed) { } } -void ProjectSettings::_clear_search_box() { +void ProjectSettingsEditor::_clear_search_box() { if (search_box->get_text() == "") return; @@ -1267,52 +1333,54 @@ void ProjectSettings::_clear_search_box() { globals_editor->get_property_editor()->update_tree(); } -void ProjectSettings::set_plugins_page() { +void ProjectSettingsEditor::set_plugins_page() { tab_container->set_current_tab(plugin_settings->get_index()); } -void ProjectSettings::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettings::_item_selected); - ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettings::_item_add); - ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettings::_item_adds); - ClassDB::bind_method(D_METHOD("_item_del"), &ProjectSettings::_item_del); - ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettings::_item_checked); - ClassDB::bind_method(D_METHOD("_save"), &ProjectSettings::_save); - ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettings::_action_add); - ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettings::_action_adds); - ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettings::_action_selected); - ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettings::_action_edited); - ClassDB::bind_method(D_METHOD("_action_activated"), &ProjectSettings::_action_activated); - ClassDB::bind_method(D_METHOD("_action_button_pressed"), &ProjectSettings::_action_button_pressed); - ClassDB::bind_method(D_METHOD("_update_actions"), &ProjectSettings::_update_actions); - ClassDB::bind_method(D_METHOD("_wait_for_key"), &ProjectSettings::_wait_for_key); - ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettings::_add_item, DEFVAL(Variant())); - ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettings::_device_input_add); - ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettings::_press_a_key_confirm); - ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettings::_settings_prop_edited); - ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettings::_copy_to_platform); - ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettings::_update_translations); - ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettings::_translation_delete); - ClassDB::bind_method(D_METHOD("_settings_changed"), &ProjectSettings::_settings_changed); - ClassDB::bind_method(D_METHOD("_translation_add"), &ProjectSettings::_translation_add); - ClassDB::bind_method(D_METHOD("_translation_file_open"), &ProjectSettings::_translation_file_open); - - ClassDB::bind_method(D_METHOD("_translation_res_add"), &ProjectSettings::_translation_res_add); - ClassDB::bind_method(D_METHOD("_translation_res_file_open"), &ProjectSettings::_translation_res_file_open); - ClassDB::bind_method(D_METHOD("_translation_res_option_add"), &ProjectSettings::_translation_res_option_add); - ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"), &ProjectSettings::_translation_res_option_file_open); - ClassDB::bind_method(D_METHOD("_translation_res_select"), &ProjectSettings::_translation_res_select); - ClassDB::bind_method(D_METHOD("_translation_res_option_changed"), &ProjectSettings::_translation_res_option_changed); - ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettings::_translation_res_delete); - ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettings::_translation_res_option_delete); - - ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettings::_clear_search_box); - ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettings::_toggle_search_bar); +void ProjectSettingsEditor::_bind_methods() { + + ClassDB::bind_method(D_METHOD("_item_selected"), &ProjectSettingsEditor::_item_selected); + ClassDB::bind_method(D_METHOD("_item_add"), &ProjectSettingsEditor::_item_add); + ClassDB::bind_method(D_METHOD("_item_adds"), &ProjectSettingsEditor::_item_adds); + ClassDB::bind_method(D_METHOD("_item_del"), &ProjectSettingsEditor::_item_del); + ClassDB::bind_method(D_METHOD("_item_checked"), &ProjectSettingsEditor::_item_checked); + ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save); + ClassDB::bind_method(D_METHOD("_action_add"), &ProjectSettingsEditor::_action_add); + ClassDB::bind_method(D_METHOD("_action_adds"), &ProjectSettingsEditor::_action_adds); + ClassDB::bind_method(D_METHOD("_action_selected"), &ProjectSettingsEditor::_action_selected); + ClassDB::bind_method(D_METHOD("_action_edited"), &ProjectSettingsEditor::_action_edited); + ClassDB::bind_method(D_METHOD("_action_activated"), &ProjectSettingsEditor::_action_activated); + ClassDB::bind_method(D_METHOD("_action_button_pressed"), &ProjectSettingsEditor::_action_button_pressed); + ClassDB::bind_method(D_METHOD("_update_actions"), &ProjectSettingsEditor::_update_actions); + ClassDB::bind_method(D_METHOD("_wait_for_key"), &ProjectSettingsEditor::_wait_for_key); + ClassDB::bind_method(D_METHOD("_add_item"), &ProjectSettingsEditor::_add_item, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("_device_input_add"), &ProjectSettingsEditor::_device_input_add); + ClassDB::bind_method(D_METHOD("_press_a_key_confirm"), &ProjectSettingsEditor::_press_a_key_confirm); + ClassDB::bind_method(D_METHOD("_settings_prop_edited"), &ProjectSettingsEditor::_settings_prop_edited); + ClassDB::bind_method(D_METHOD("_copy_to_platform"), &ProjectSettingsEditor::_copy_to_platform); + ClassDB::bind_method(D_METHOD("_update_translations"), &ProjectSettingsEditor::_update_translations); + ClassDB::bind_method(D_METHOD("_translation_delete"), &ProjectSettingsEditor::_translation_delete); + ClassDB::bind_method(D_METHOD("_settings_changed"), &ProjectSettingsEditor::_settings_changed); + ClassDB::bind_method(D_METHOD("_translation_add"), &ProjectSettingsEditor::_translation_add); + ClassDB::bind_method(D_METHOD("_translation_file_open"), &ProjectSettingsEditor::_translation_file_open); + + ClassDB::bind_method(D_METHOD("_translation_res_add"), &ProjectSettingsEditor::_translation_res_add); + ClassDB::bind_method(D_METHOD("_translation_res_file_open"), &ProjectSettingsEditor::_translation_res_file_open); + ClassDB::bind_method(D_METHOD("_translation_res_option_add"), &ProjectSettingsEditor::_translation_res_option_add); + ClassDB::bind_method(D_METHOD("_translation_res_option_file_open"), &ProjectSettingsEditor::_translation_res_option_file_open); + ClassDB::bind_method(D_METHOD("_translation_res_select"), &ProjectSettingsEditor::_translation_res_select); + ClassDB::bind_method(D_METHOD("_translation_res_option_changed"), &ProjectSettingsEditor::_translation_res_option_changed); + ClassDB::bind_method(D_METHOD("_translation_res_delete"), &ProjectSettingsEditor::_translation_res_delete); + ClassDB::bind_method(D_METHOD("_translation_res_option_delete"), &ProjectSettingsEditor::_translation_res_option_delete); + + ClassDB::bind_method(D_METHOD("_clear_search_box"), &ProjectSettingsEditor::_clear_search_box); + ClassDB::bind_method(D_METHOD("_toggle_search_bar"), &ProjectSettingsEditor::_toggle_search_bar); + + ClassDB::bind_method(D_METHOD("_copy_to_platform_about_to_show"), &ProjectSettingsEditor::_copy_to_platform_about_to_show); } -ProjectSettings::ProjectSettings(EditorData *p_data) { +ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { singleton = this; set_title(TTR("Project Settings (project.godot)")); @@ -1388,11 +1456,6 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { add->set_text(TTR("Add")); add->connect("pressed", this, "_item_add"); - Button *del = memnew(Button); - add_prop_bar->add_child(del); - del->set_text(TTR("Del")); - del->connect("pressed", this, "_item_del"); - search_bar = memnew(HBoxContainer); search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL); hbc->add_child(search_bar); @@ -1409,9 +1472,10 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { globals_editor = memnew(SectionedPropertyEditor); props_base->add_child(globals_editor); globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); + globals_editor->get_property_editor()->set_property_selectable(true); //globals_editor->hide_top_label(); globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); - globals_editor->get_property_editor()->register_text_enter(search_box); + globals_editor->register_search_box(search_box); globals_editor->get_property_editor()->get_scene_tree()->connect("cell_selected", this, "_item_selected"); globals_editor->get_property_editor()->connect("property_toggled", this, "_item_checked", varray(), CONNECT_DEFERRED); globals_editor->get_property_editor()->connect("property_edited", this, "_settings_prop_edited"); @@ -1430,15 +1494,17 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { save->connect("pressed",this,"_save"); */ - hbc = memnew(HBoxContainer); - props_base->add_child(hbc); + Button *del = memnew(Button); + hbc->add_child(del); + del->set_text(TTR("Delete")); + del->connect("pressed", this, "_item_del"); - popup_platform = memnew(MenuButton); - popup_platform->set_text(TTR("Copy To Platform..")); - popup_platform->set_disabled(true); - hbc->add_child(popup_platform); + add_prop_bar->add_child(memnew(VSeparator)); - hbc->add_spacer(); + popup_copy_to_feature = memnew(MenuButton); + popup_copy_to_feature->set_text(TTR("Override For..")); + popup_copy_to_feature->set_disabled(true); + add_prop_bar->add_child(popup_copy_to_feature); /*List<StringName> ep; EditorImportExport::get_singleton()->get_export_platforms(&ep); @@ -1446,11 +1512,13 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { for(List<StringName>::Element *E=ep.front();E;E=E->next()) { - popup_platform->get_popup()->add_item( E->get() ); + popup_copy_to_feature->get_popup()->add_item( E->get() ); }*/ - popup_platform->get_popup()->connect("id_pressed", this, "_copy_to_platform"); + popup_copy_to_feature->get_popup()->connect("id_pressed", this, "_copy_to_platform"); + popup_copy_to_feature->get_popup()->connect("about_to_show", this, "_copy_to_platform_about_to_show"); + get_ok()->set_text(TTR("Close")); set_hide_on_ok(true); @@ -1665,7 +1733,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { timer = memnew(Timer); timer->set_wait_time(1.5); - timer->connect("timeout", GlobalConfig::get_singleton(), "save"); + timer->connect("timeout", ProjectSettings::get_singleton(), "save"); timer->set_one_shot(true); add_child(timer); diff --git a/editor/project_settings.h b/editor/project_settings_editor.h index 03140a854b..4390a23d60 100644 --- a/editor/project_settings.h +++ b/editor/project_settings_editor.h @@ -40,8 +40,8 @@ //#include "project_export_settings.h" -class ProjectSettings : public AcceptDialog { - GDCLASS(ProjectSettings, AcceptDialog); +class ProjectSettingsEditor : public AcceptDialog { + GDCLASS(ProjectSettingsEditor, AcceptDialog); enum InputType { INPUT_KEY, @@ -78,7 +78,7 @@ class ProjectSettings : public AcceptDialog { SpinBox *device_id; OptionButton *device_index; Label *device_index_label; - MenuButton *popup_platform; + MenuButton *popup_copy_to_feature; LineEdit *action_name; Tree *input_editor; @@ -145,9 +145,11 @@ class ProjectSettings : public AcceptDialog { void _toggle_search_bar(bool p_pressed); void _clear_search_box(); - ProjectSettings(); + void _copy_to_platform_about_to_show(); - static ProjectSettings *singleton; + ProjectSettingsEditor(); + + static ProjectSettingsEditor *singleton; protected: void _notification(int p_what); @@ -155,13 +157,13 @@ protected: public: void add_translation(const String &p_translation); - static ProjectSettings *get_singleton() { return singleton; } + static ProjectSettingsEditor *get_singleton() { return singleton; } void popup_project_settings(); void set_plugins_page(); void queue_save(); - ProjectSettings(EditorData *p_data); + ProjectSettingsEditor(EditorData *p_data); }; #endif // PROJECT_SETTINGS_H diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 8a9fd2cde5..c2af2445cc 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -37,8 +37,6 @@ #include "editor_help.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" -#include "global_config.h" #include "io/image_loader.h" #include "io/resource_loader.h" #include "multi_node_edit.h" @@ -46,6 +44,8 @@ #include "os/keyboard.h" #include "pair.h" #include "print_string.h" +#include "project_settings.h" +#include "project_settings.h" #include "property_selector.h" #include "scene/gui/label.h" #include "scene/main/viewport.h" @@ -415,7 +415,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: int idx = i * 10 + j; CheckBox *c = checks20[idx]; - c->set_text(GlobalConfig::get_singleton()->get(basename + "/layer_" + itos(idx + 1))); + c->set_text(ProjectSettings::get_singleton()->get(basename + "/layer_" + itos(idx + 1))); c->set_pressed(flgs & (1 << (i * 10 + j))); c->show(); } @@ -815,16 +815,12 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: color_picker = memnew(ColorPicker); add_child(color_picker); color_picker->hide(); - color_picker->set_area_as_parent_rect(); - for (int i = 0; i < 4; i++) - color_picker->set_margin((Margin)i, 5); color_picker->connect("color_changed", this, "_color_changed"); } color_picker->show(); color_picker->set_edit_alpha(hint != PROPERTY_HINT_COLOR_NO_ALPHA); color_picker->set_pick_color(v); - set_size(Size2(307 * EDSCALE, 460 * EDSCALE)); color_picker->set_focus_on_line_edit(); /* int ofs=80; @@ -1023,7 +1019,7 @@ void CustomPropertyEditor::_file_selected(String p_file) { if (hint == PROPERTY_HINT_FILE || hint == PROPERTY_HINT_DIR) { - v = GlobalConfig::get_singleton()->localize_path(p_file); + v = ProjectSettings::get_singleton()->localize_path(p_file); emit_signal("variant_changed"); hide(); } @@ -3006,8 +3002,18 @@ void PropertyEditor::update_tree() { String name = (basename.find("/") != -1) ? basename.right(basename.find_last("/") + 1) : basename; - if (capitalize_paths) - name = name.camelcase_to_underscore().capitalize(); + if (capitalize_paths) { + int dot = name.find("."); + if (dot != -1) { + String ov = name.right(dot); + name = name.substr(0, dot); + name = name.camelcase_to_underscore().capitalize(); + name += ov; + + } else { + name = name.camelcase_to_underscore().capitalize(); + } + } String path = basename.left(basename.find_last("/")); @@ -3050,7 +3056,7 @@ void PropertyEditor::update_tree() { //item->set_custom_bg_color(1,col); } item->set_editable(0, false); - item->set_selectable(0, false); + item->set_selectable(0, property_selectable); if (p.usage & PROPERTY_USAGE_CHECKABLE) { @@ -3063,6 +3069,18 @@ void PropertyEditor::update_tree() { item->set_text(0, name); item->set_tooltip(0, p.name); + if (name.find(".") != -1) { + Color textcol = get_color("font_color", "Tree"); + textcol.a *= 0.5; + //override :D + item->set_custom_color(0, textcol); + item->set_custom_color(1, textcol); + + Color iconcol(1, 1, 1, 0.6); + item->set_icon_color(0, iconcol); + item->set_icon_color(1, iconcol); + } + if (use_doc_hints) { StringName setter; StringName type; @@ -4312,6 +4330,11 @@ void PropertyEditor::register_text_enter(Node *p_line_edit) { search_box->connect("text_changed", this, "_filter_changed"); } +void PropertyEditor::set_property_selectable(bool p_selectable) { + property_selectable = p_selectable; + update_tree(); +} + void PropertyEditor::set_subsection_selectable(bool p_selectable) { if (p_selectable == subsection_selectable) @@ -4331,7 +4354,7 @@ PropertyEditor::PropertyEditor() { _prop_edited = "property_edited"; - hide_script = false; + hide_script = true; use_folding = false; undo_redo = NULL; @@ -4398,6 +4421,7 @@ PropertyEditor::PropertyEditor() { updating_folding = true; use_filter = false; subsection_selectable = false; + property_selectable = false; show_type_icons = EDITOR_DEF("interface/show_type_icons", false); } @@ -4512,6 +4536,7 @@ public: void SectionedPropertyEditor::_bind_methods() { ClassDB::bind_method("_section_selected", &SectionedPropertyEditor::_section_selected); + ClassDB::bind_method("_search_changed", &SectionedPropertyEditor::_search_changed); ClassDB::bind_method("update_category_list", &SectionedPropertyEditor::update_category_list); } @@ -4609,6 +4634,10 @@ void SectionedPropertyEditor::update_category_list() { if (pi.name.find(":") != -1 || pi.name == "script" || pi.name == "resource_name" || pi.name == "resource_path") continue; + + if (search_box && search_box->get_text() != String() && pi.name.findn(search_box->get_text()) == -1) + continue; + int sp = pi.name.find("/"); if (sp == -1) pi.name = "Global/" + pi.name; @@ -4616,7 +4645,9 @@ void SectionedPropertyEditor::update_category_list() { Vector<String> sectionarr = pi.name.split("/"); String metasection; - for (int i = 0; i < MIN(2, sectionarr.size() - 1); i++) { + int sc = MIN(2, sectionarr.size() - 1); + + for (int i = 0; i < sc; i++) { TreeItem *parent = section_map[metasection]; @@ -4631,6 +4662,12 @@ void SectionedPropertyEditor::update_category_list() { section_map[metasection] = ms; ms->set_text(0, sectionarr[i].capitalize()); ms->set_metadata(0, metasection); + ms->set_selectable(0, false); + } + + if (i == sc - 1) { + //if it has children, make selectable + section_map[metasection]->set_selectable(0, true); } } } @@ -4638,6 +4675,20 @@ void SectionedPropertyEditor::update_category_list() { if (section_map.has(selected_category)) { section_map[selected_category]->select(0); } + + editor->update_tree(); +} + +void SectionedPropertyEditor::register_search_box(LineEdit *p_box) { + + search_box = p_box; + editor->register_text_enter(p_box); + search_box->connect("text_changed", this, "_search_changed"); +} + +void SectionedPropertyEditor::_search_changed(const String &p_what) { + + update_category_list(); } PropertyEditor *SectionedPropertyEditor::get_property_editor() { @@ -4649,6 +4700,8 @@ SectionedPropertyEditor::SectionedPropertyEditor() { obj = -1; + search_box = NULL; + VBoxContainer *left_vb = memnew(VBoxContainer); left_vb->set_custom_minimum_size(Size2(160, 0) * EDSCALE); add_child(left_vb); diff --git a/editor/property_editor.h b/editor/property_editor.h index 47bd807c3f..273eff371e 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -1,4 +1,4 @@ -/*************************************************************************/ +/*************************************************************************/ /* property_editor.h */ /*************************************************************************/ /* This file is part of: */ @@ -191,6 +191,7 @@ class PropertyEditor : public Control { bool subsection_selectable; bool hide_script; bool use_folding; + bool property_selectable; bool updating_folding; @@ -288,6 +289,7 @@ public: void register_text_enter(Node *p_line_edit); void set_subsection_selectable(bool p_selectable); + void set_property_selectable(bool p_selectable); void set_use_folding(bool p_enable); PropertyEditor(); @@ -307,11 +309,15 @@ class SectionedPropertyEditor : public HBoxContainer { Map<String, TreeItem *> section_map; PropertyEditor *editor; + LineEdit *search_box; static void _bind_methods(); void _section_selected(); + void _search_changed(const String &p_what); + public: + void register_search_box(LineEdit *p_box); PropertyEditor *get_property_editor(); void edit(Object *p_object); String get_full_item_path(const String &p_item); diff --git a/editor/resources_dock.cpp b/editor/resources_dock.cpp index ddecfd108f..d3b68d92e4 100644 --- a/editor/resources_dock.cpp +++ b/editor/resources_dock.cpp @@ -32,10 +32,10 @@ #include "editor_file_system.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "project_settings.h" +#include "project_settings_editor.h" void ResourcesDock::_tool_selected(int p_tool) { @@ -124,7 +124,7 @@ void ResourcesDock::save_resource(const String &p_path, const Ref<Resource> &p_r flg|=ResourceSaver::FLAG_RELATIVE_PATHS; */ - String path = GlobalConfig::get_singleton()->localize_path(p_path); + String path = ProjectSettings::get_singleton()->localize_path(p_path); Error err = ResourceSaver::save(path, p_resource, flg | ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS); if (err != OK) { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index cdae9baaf2..a9e998e76a 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -37,7 +37,7 @@ #include "editor/plugins/spatial_editor_plugin.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "multi_node_edit.h" #include "os/keyboard.h" #include "scene/main/viewport.h" @@ -183,7 +183,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node } } - instanced_scene->set_filename(GlobalConfig::get_singleton()->localize_path(p_files[i])); + instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(p_files[i])); instances.push_back(instanced_scene); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 4a9b64639b..c3a3410717 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -31,7 +31,7 @@ #include "editor/editor_scale.h" #include "editor_file_system.h" -#include "global_config.h" +#include "project_settings.h" #include "io/resource_saver.h" #include "os/file_access.h" #include "script_language.h" @@ -167,7 +167,7 @@ void ScriptCreateDialog::_create_new() { scr->set_name(cname); if (!is_built_in) { - String lpath = GlobalConfig::get_singleton()->localize_path(file_path->get_text()); + String lpath = ProjectSettings::get_singleton()->localize_path(file_path->get_text()); scr->set_path(lpath); Error err = ResourceSaver::save(lpath, scr, ResourceSaver::FLAG_CHANGE_PATH); if (err != OK) { @@ -305,7 +305,7 @@ void ScriptCreateDialog::_browse_path(bool browse_parent) { void ScriptCreateDialog::_file_selected(const String &p_file) { - String p = GlobalConfig::get_singleton()->localize_path(p_file); + String p = ProjectSettings::get_singleton()->localize_path(p_file); if (is_browsing_parent) { parent_name->set_text("\"" + p + "\""); _class_name_changed("\"" + p + "\""); @@ -327,7 +327,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) { return; } - p = GlobalConfig::get_singleton()->localize_path(p); + p = ProjectSettings::get_singleton()->localize_path(p); if (!p.begins_with("res://")) { _msg_path_valid(false, TTR("Path is not local")); _update_dialog(); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 9dce48937c..2af3bd5f31 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -32,7 +32,7 @@ #include "editor_node.h" #include "editor_profiler.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "main/performance.h" #include "property_editor.h" #include "scene/gui/dialogs.h" @@ -1625,24 +1625,24 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { hbc->add_child(memnew(VSeparator)); - step = memnew(Button); + step = memnew(ToolButton); hbc->add_child(step); step->set_tooltip(TTR("Step Into")); step->connect("pressed", this, "debug_step"); - next = memnew(Button); + next = memnew(ToolButton); hbc->add_child(next); next->set_tooltip(TTR("Step Over")); next->connect("pressed", this, "debug_next"); hbc->add_child(memnew(VSeparator)); - dobreak = memnew(Button); + dobreak = memnew(ToolButton); hbc->add_child(dobreak); dobreak->set_tooltip(TTR("Break")); dobreak->connect("pressed", this, "debug_break"); - docontinue = memnew(Button); + docontinue = memnew(ToolButton); hbc->add_child(docontinue); docontinue->set_tooltip(TTR("Continue")); docontinue->connect("pressed", this, "debug_continue"); @@ -1816,7 +1816,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { vmem_total->set_editable(false); vmem_total->set_custom_minimum_size(Size2(100, 1) * EDSCALE); vmem_hb->add_child(vmem_total); - vmem_refresh = memnew(Button); + vmem_refresh = memnew(ToolButton); vmem_hb->add_child(vmem_refresh); vmem_vb->add_child(vmem_hb); vmem_refresh->connect("pressed", this, "_video_mem_request"); @@ -1849,30 +1849,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { } { // misc - VBoxContainer *info_left = memnew(VBoxContainer); - info_left->set_h_size_flags(SIZE_EXPAND_FILL); + GridContainer *info_left = memnew(GridContainer); + info_left->set_columns(2); info_left->set_name(TTR("Misc")); tabs->add_child(info_left); clicked_ctrl = memnew(LineEdit); - info_left->add_margin_child(TTR("Clicked Control:"), clicked_ctrl); + clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL); + info_left->add_child(memnew(Label(TTR("Clicked Control:")))); + info_left->add_child(clicked_ctrl); clicked_ctrl_type = memnew(LineEdit); - info_left->add_margin_child(TTR("Clicked Control Type:"), clicked_ctrl_type); + info_left->add_child(memnew(Label(TTR("Clicked Control Type:")))); + info_left->add_child(clicked_ctrl_type); live_edit_root = memnew(LineEdit); + live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL); { HBoxContainer *lehb = memnew(HBoxContainer); Label *l = memnew(Label(TTR("Live Edit Root:"))); - lehb->add_child(l); - l->set_h_size_flags(SIZE_EXPAND_FILL); + info_left->add_child(l); + lehb->add_child(live_edit_root); le_set = memnew(Button(TTR("Set From Tree"))); lehb->add_child(le_set); le_clear = memnew(Button(TTR("Clear"))); lehb->add_child(le_clear); info_left->add_child(lehb); - MarginContainer *mc = memnew(MarginContainer); - mc->add_child(live_edit_root); - info_left->add_child(mc); le_set->set_disabled(true); le_clear->set_disabled(true); } diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 6f613981b8..eec047cd9a 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -32,7 +32,7 @@ #include "editor_file_system.h" #include "editor_node.h" #include "editor_settings.h" -#include "global_config.h" +#include "project_settings.h" #include "os/keyboard.h" #include "scene/gui/margin_container.h" @@ -332,7 +332,7 @@ EditorSettingsDialog::EditorSettingsDialog() { property_editor = memnew(SectionedPropertyEditor); //property_editor->hide_top_label(); property_editor->get_property_editor()->set_use_filter(true); - property_editor->get_property_editor()->register_text_enter(search_box); + property_editor->register_search_box(search_box); property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbc->add_child(property_editor); property_editor->get_property_editor()->connect("property_edited", this, "_settings_property_edited"); |