From bbada82f8088e18b663f087484fcbb662dd76a5a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 17 Jul 2017 21:05:38 -0300 Subject: -Reorganized all properties of project settings (Sorry, Again). (Lot's of bloat accumulated, so it was time for clean up.) -Made EditorSettings and ProjectSettings search more useful (search in sections too) --- editor/editor_node.cpp | 17 +- editor/editor_run.cpp | 8 +- editor/import/resource_importer_obj.cpp | 335 ++++++++++++++++++++------- editor/import/resource_importer_obj.h | 25 +- editor/import/resource_importer_texture.cpp | 8 +- editor/import_dock.cpp | 1 - editor/plugins/canvas_item_editor_plugin.cpp | 4 +- editor/plugins/spatial_editor_plugin.cpp | 16 +- editor/project_export.cpp | 2 +- editor/project_settings.cpp | 2 +- editor/property_editor.cpp | 31 ++- editor/property_editor.h | 6 +- editor/settings_config_dialog.cpp | 2 +- 13 files changed, 327 insertions(+), 130 deletions(-) (limited to 'editor') diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 497a8ca452..00609b22d7 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -163,7 +163,7 @@ void EditorNode::_update_scene_tabs() { void EditorNode::_update_title() { - String appname = GlobalConfig::get_singleton()->get("application/name"); + String appname = GlobalConfig::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 +272,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(GlobalConfig::get_singleton()->get("display/window/size/width"), GlobalConfig::get_singleton()->get("display/window/size/height"))); ResourceImporterTexture::get_singleton()->update_imports(); } @@ -1132,7 +1132,7 @@ 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()->set("application/run/main_scene", p_file); GlobalConfig::get_singleton()->save(); //would be nice to show the project manager opened with the highlighted field.. _run(false, ""); // automatically run the project @@ -1731,7 +1731,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; @@ -5151,10 +5151,6 @@ EditorNode::EditorNode() { import_wav.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_wav); - Ref import_obj; - import_obj.instance(); - ResourceFormatImporter::get_singleton()->add_importer(import_obj); - Ref import_scene; import_scene.instance(); ResourceFormatImporter::get_singleton()->add_importer(import_scene); @@ -5163,6 +5159,10 @@ EditorNode::EditorNode() { Ref import_collada; import_collada.instance(); import_scene->add_importer(import_collada); + + Ref import_obj; + import_obj.instance(); + import_scene->add_importer(import_obj); } } @@ -5937,6 +5937,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(); diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index a8106b4eec..8d01484b34 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -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 = GlobalConfig::get_singleton()->get("display/window/size/width"); + desired_size.y = GlobalConfig::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 = GlobalConfig::get_singleton()->get("display/window/size/test_width"); + test_size.y = GlobalConfig::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/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 4a2f37e319..9bb598ec92 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 *r_extensions) const { -String ResourceImporterOBJ::get_visible_name() const { - - return "OBJ As Mesh"; + r_extensions->push_back("obj"); } -void ResourceImporterOBJ::get_recognized_extensions(List *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 > &material_map, List *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 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 &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 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 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 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 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 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 = 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 = 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 = 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); -void ResourceImporterOBJ::get_import_options(List *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")); + Ref texture = ResourceLoader::load(path); + + 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 &p_options, List *r_platform_variants, List *r_gen_files) { +Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List *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 mesh; + mesh.instance(); - Ref mesh = Ref(memnew(ArrayMesh)); Map > 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 vertices; Vector normals; Vector uvs; String name; + Map > > material_map; + Ref 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 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 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 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 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 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,105 @@ 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); + } + + if (l.begins_with("o ") || f->eof_reached()) { + + MeshInstance *mi = memnew(MeshInstance); + mi->set_name(name); + mi->set_mesh(mesh); - has_index_data = false; + scene->add_child(mi); + mi->set_owner(scene); - if (f->eof_reached()) - break; + mesh.instance(); + current_group = ""; + current_material = ""; } - if (l.begins_with("o ")) //name + if (f->eof_reached()) { + break; + } + + 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 > lib; + Error err = _parse_material_library(current_material_library, lib, r_missing_deps); + if (err == OK) { + material_map[current_material_library] = lib; + } + } } } @@ -243,10 +413,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 EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags) { -ResourceImporterOBJ::ResourceImporterOBJ() { + return Ref(); +} +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 *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 *r_options, int p_preset = 0) const; - virtual bool get_option_visibility(const String &p_option, const Map &p_options) const; + Error _parse_material_library(const String &p_path, Map > &material_map, List *r_missing_deps); - virtual Error import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files = NULL); +public: + virtual uint32_t get_import_flags() const; + virtual void get_extensions(List *r_extensions) const; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List *r_missing_deps, Error *r_err = NULL); + virtual Ref 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..7e23a422f7 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -418,24 +418,24 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (compress_mode == COMPRESS_VIDEO_RAM) { //must import in all formats //Android, GLES 2.x - if (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_s3tc")) { + if (GlobalConfig::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")) { + if (GlobalConfig::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 (GlobalConfig::get_singleton()->get("rendering/vram_formats/use_etc2")) { + if (GlobalConfig::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 (GlobalConfig::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/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index b2d3aafd13..b059e63467 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -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(GlobalConfig::get_singleton()->get("display/window/size/width"), GlobalConfig::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(GlobalConfig::get_singleton()->get("display/window/size/width"), GlobalConfig::get_singleton()->get("display/window/size/height")); Rect2 local_rect = Rect2(Point2(), viewport->get_size() - Size2(vmin.width, hmin.height)); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index d7f4781e89..58fc32309f 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -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 = GlobalConfig::get_singleton()->get("rendering/quality/shadow_atlas/size"); + int atlas_q0 = GlobalConfig::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_0_subdiv"); + int atlas_q1 = GlobalConfig::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_1_subdiv"); + int atlas_q2 = GlobalConfig::get_singleton()->get("rendering/quality/shadow_atlas/quadrant_2_subdiv"); + int atlas_q3 = GlobalConfig::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 = GlobalConfig::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 = GlobalConfig::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(GlobalConfig::get_singleton()->get("display/window/size/width"), GlobalConfig::get_singleton()->get("display/window/size/height")); float aspect = ss.aspect(); Size2 s = get_size(); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 355f8ba22e..ce22ed4731 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -763,7 +763,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); diff --git a/editor/project_settings.cpp b/editor/project_settings.cpp index 17a35282de..f72c655561 100644 --- a/editor/project_settings.cpp +++ b/editor/project_settings.cpp @@ -1411,7 +1411,7 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { globals_editor->get_property_editor()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo()); //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"); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 8a9fd2cde5..6fac9eb652 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -4331,7 +4331,7 @@ PropertyEditor::PropertyEditor() { _prop_edited = "property_edited"; - hide_script = false; + hide_script = true; use_folding = false; undo_redo = NULL; @@ -4512,6 +4512,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 +4610,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 +4621,9 @@ void SectionedPropertyEditor::update_category_list() { Vector 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 +4638,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); } } } @@ -4640,6 +4653,18 @@ void SectionedPropertyEditor::update_category_list() { } } +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() { return editor; @@ -4649,6 +4674,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..1ae44e473b 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -1,4 +1,4 @@ -/*************************************************************************/ +/*************************************************************************/ /* property_editor.h */ /*************************************************************************/ /* This file is part of: */ @@ -307,11 +307,15 @@ class SectionedPropertyEditor : public HBoxContainer { Map 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/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 6f613981b8..6c64f3af42 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -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"); -- cgit v1.2.3