diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 8 | ||||
-rw-r--r-- | editor/editor_node.h | 2 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 51 | ||||
-rw-r--r-- | editor/editor_properties.h | 3 | ||||
-rw-r--r-- | editor/editor_resource_preview.h | 18 | ||||
-rw-r--r-- | editor/editor_settings.cpp | 6 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 6 | ||||
-rw-r--r-- | editor/import/resource_importer_csv_translation.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.cpp | 204 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.h | 65 | ||||
-rw-r--r-- | editor/plugins/mesh_editor_plugin.cpp | 77 | ||||
-rw-r--r-- | editor/plugins/mesh_editor_plugin.h | 15 | ||||
-rw-r--r-- | editor/plugins/particles_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/sprite_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/texture_editor_plugin.cpp | 41 | ||||
-rw-r--r-- | editor/plugins/texture_editor_plugin.h | 15 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 40 |
19 files changed, 457 insertions, 124 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1c9e07ae5b..a29b50185c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1460,7 +1460,7 @@ void EditorNode::edit_item(Object *p_object) { _set_editing_top_editors(p_object); _display_top_editors(true); } else { - _hide_top_editors(); + hide_top_editors(); } } @@ -1498,7 +1498,7 @@ void EditorNode::_save_default_environment() { } } -void EditorNode::_hide_top_editors() { +void EditorNode::hide_top_editors() { _display_top_editors(false); @@ -1675,7 +1675,7 @@ void EditorNode::_edit_current() { } else if (!editor_plugins_over->get_plugins_list().empty()) { - _hide_top_editors(); + hide_top_editors(); } } @@ -5904,6 +5904,8 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(SkeletonEditorPlugin(this))); add_editor_plugin(memnew(SkeletonIKEditorPlugin(this))); add_editor_plugin(memnew(PhysicalBonePlugin(this))); + add_editor_plugin(memnew(MeshEditorPlugin(this))); + add_editor_plugin(memnew(MaterialEditorPlugin(this))); for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) add_editor_plugin(EditorPlugins::create(i, this)); diff --git a/editor/editor_node.h b/editor/editor_node.h index 192dc649e9..267c70c773 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -452,7 +452,6 @@ private: void _instance_request(const Vector<String> &p_files); - void _hide_top_editors(); void _display_top_editors(bool p_display); void _set_top_editors(Vector<EditorPlugin *> p_editor_plugins_over); void _set_editing_top_editors(Object *p_current_object); @@ -677,6 +676,7 @@ public: void edit_item(Object *p_object); void edit_item_resource(RES p_resource); bool item_has_editor(Object *p_object); + void hide_top_editors(); void open_request(const String &p_path); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index a07cffb078..2b8d5bf6c9 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2443,6 +2443,38 @@ void EditorPropertyResource::_open_editor_pressed() { } } +void EditorPropertyResource::_fold_other_editors(Object *p_self) { + + if (this == p_self) { + return; + } + + RES res = get_edited_object()->get(get_edited_property()); + + if (!res.is_valid()) + return; + bool use_editor = false; + for (int i = 0; i < EditorNode::get_singleton()->get_editor_data().get_editor_plugin_count(); i++) { + EditorPlugin *ep = EditorNode::get_singleton()->get_editor_data().get_editor_plugin(i); + if (ep->handles(res.ptr())) { + use_editor = true; + } + } + + if (!use_editor) + return; + bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property()); + + opened_editor = false; + + if (unfolded) { + //refold + assign->set_pressed(false); + get_edited_object()->editor_set_section_unfold(get_edited_property(), false); + update_property(); + } +} + void EditorPropertyResource::update_property() { RES res = get_edited_object()->get(get_edited_property()); @@ -2487,12 +2519,20 @@ void EditorPropertyResource::update_property() { } if (use_editor) { + //open editor directly and hide other open of these + _open_editor_pressed(); + if (is_inside_tree()) { + get_tree()->call_deferred("call_group", "_editor_resource_properties", "_fold_other_editors", this); + } + opened_editor = true; + /* Button *open_in_editor = memnew(Button); open_in_editor->set_text(TTR("Open Editor")); open_in_editor->set_icon(get_icon("Edit", "EditorIcons")); sub_inspector_vbox->add_child(open_in_editor); open_in_editor->connect("pressed", this, "_open_editor_pressed"); open_in_editor->set_h_size_flags(SIZE_SHRINK_CENTER); + */ } } @@ -2506,6 +2546,10 @@ void EditorPropertyResource::update_property() { memdelete(sub_inspector_vbox); sub_inspector = NULL; sub_inspector_vbox = NULL; + if (opened_editor) { + EditorNode::get_singleton()->hide_top_editors(); + opened_editor = false; + } } } #endif @@ -2547,7 +2591,8 @@ void EditorPropertyResource::_resource_selected() { if (use_sub_inspector) { - get_edited_object()->editor_set_section_unfold(get_edited_property(), assign->is_pressed()); + bool unfold = !get_edited_object()->editor_is_section_unfolded(get_edited_property()); + get_edited_object()->editor_set_section_unfold(get_edited_property(), unfold); update_property(); } else { @@ -2726,10 +2771,12 @@ void EditorPropertyResource::_bind_methods() { ClassDB::bind_method(D_METHOD("_button_draw"), &EditorPropertyResource::_button_draw); ClassDB::bind_method(D_METHOD("_open_editor_pressed"), &EditorPropertyResource::_open_editor_pressed); ClassDB::bind_method(D_METHOD("_button_input"), &EditorPropertyResource::_button_input); + ClassDB::bind_method(D_METHOD("_fold_other_editors"), &EditorPropertyResource::_fold_other_editors); } EditorPropertyResource::EditorPropertyResource() { + opened_editor = false; sub_inspector = NULL; sub_inspector_vbox = NULL; use_sub_inspector = bool(EDITOR_GET("interface/inspector/open_resources_in_current_inspector")); @@ -2766,6 +2813,8 @@ EditorPropertyResource::EditorPropertyResource() { file = NULL; scene_tree = NULL; dropping = false; + + add_to_group("_editor_resource_properties"); } ////////////// DEFAULT PLUGIN ////////////////////// diff --git a/editor/editor_properties.h b/editor/editor_properties.h index df01ee83b5..574767890c 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -581,6 +581,9 @@ class EditorPropertyResource : public EditorProperty { void _button_input(const Ref<InputEvent> &p_event); void _open_editor_pressed(); + void _fold_other_editors(Object *p_self); + + bool opened_editor; protected: static void _bind_methods(); diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index 703ba34e43..9b9223a818 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -36,24 +36,6 @@ #include "scene/main/node.h" #include "scene/resources/texture.h" -/* make previews for: -*packdscene -*wav -*image -*mesh --font -*script -*material --shader --shader graph? --navigation mesh --collision? --occluder polygon --navigation polygon --tileset --curve and curve2D -*/ - class EditorResourcePreviewGenerator : public Reference { GDCLASS(EditorResourcePreviewGenerator, Reference); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 741a210950..94473cb989 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -780,12 +780,6 @@ void EditorSettings::create() { // Validate/create data dir and subdirectories dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (dir->change_dir(data_path) != OK) { - ERR_PRINT("Cannot find path for data directory!"); - memdelete(dir); - goto fail; - } - if (dir->change_dir(data_dir) != OK) { dir->make_dir_recursive(data_dir); if (dir->change_dir(data_dir) != OK) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3fe19c0b31..bc42a3f23b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -641,9 +641,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon("GuiVisibilityXray", "EditorIcons")); theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE); - Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1, 2, 0, 0, 0); + Ref<StyleBoxFlat> sub_inspector_bg = make_flat_stylebox(dark_color_1.linear_interpolate(accent_color, 0.08), 2, 0, 2, 2); sub_inspector_bg->set_border_width(MARGIN_LEFT, 2); sub_inspector_bg->set_border_color(MARGIN_LEFT, accent_color * Color(1, 1, 1, 0.3)); + sub_inspector_bg->set_border_width(MARGIN_RIGHT, 2); + sub_inspector_bg->set_border_color(MARGIN_RIGHT, accent_color * Color(1, 1, 1, 0.3)); + sub_inspector_bg->set_border_width(MARGIN_BOTTOM, 2); + sub_inspector_bg->set_border_color(MARGIN_BOTTOM, accent_color * Color(1, 1, 1, 0.3)); sub_inspector_bg->set_draw_center(true); theme->set_stylebox("sub_inspector_bg", "Editor", sub_inspector_bg); diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index b4b3e0e551..cfcdbc8de4 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -119,7 +119,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const if (key != "") { for (int i = 1; i < line.size(); i++) { - translations.write[i - 1]->add_message(key, line[i]); + translations.write[i - 1]->add_message(key, line[i].c_unescape()); } } diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index ce8cc77802..ebacccb03c 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -32,6 +32,210 @@ #include "scene/resources/particles_material.h" +void MaterialEditor::_notification(int p_what) { + + if (p_what == NOTIFICATION_PHYSICS_PROCESS) { + } + + if (p_what == NOTIFICATION_READY) { + + //get_scene()->connect("node_removed",this,"_node_removed"); + + if (first_enter) { + //it's in propertyeditor so.. could be moved around + + light_1_switch->set_normal_texture(get_icon("MaterialPreviewLight1", "EditorIcons")); + light_1_switch->set_pressed_texture(get_icon("MaterialPreviewLight1Off", "EditorIcons")); + light_2_switch->set_normal_texture(get_icon("MaterialPreviewLight2", "EditorIcons")); + light_2_switch->set_pressed_texture(get_icon("MaterialPreviewLight2Off", "EditorIcons")); + + sphere_switch->set_normal_texture(get_icon("MaterialPreviewSphereOff", "EditorIcons")); + sphere_switch->set_pressed_texture(get_icon("MaterialPreviewSphere", "EditorIcons")); + box_switch->set_normal_texture(get_icon("MaterialPreviewCubeOff", "EditorIcons")); + box_switch->set_pressed_texture(get_icon("MaterialPreviewCube", "EditorIcons")); + + first_enter = false; + } + } + + if (p_what == NOTIFICATION_DRAW) { + + Ref<Texture> checkerboard = get_icon("Checkerboard", "EditorIcons"); + Size2 size = get_size(); + + draw_texture_rect(checkerboard, Rect2(Point2(), size), true); + } +} + +void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) { + + material = p_material; + camera->set_environment(p_env); + if (!material.is_null()) { + sphere_instance->set_material_override(material); + box_instance->set_material_override(material); + } else { + + hide(); + } +} + +void MaterialEditor::_button_pressed(Node *p_button) { + + if (p_button == light_1_switch) { + light1->set_visible(!light_1_switch->is_pressed()); + } + + if (p_button == light_2_switch) { + light2->set_visible(!light_2_switch->is_pressed()); + } + + if (p_button == box_switch) { + box_instance->show(); + sphere_instance->hide(); + box_switch->set_pressed(true); + sphere_switch->set_pressed(false); + } + + if (p_button == sphere_switch) { + box_instance->hide(); + sphere_instance->show(); + box_switch->set_pressed(false); + sphere_switch->set_pressed(true); + } +} + +void MaterialEditor::_bind_methods() { + + ClassDB::bind_method(D_METHOD("_button_pressed"), &MaterialEditor::_button_pressed); +} + +MaterialEditor::MaterialEditor() { + + vc = memnew(ViewportContainer); + vc->set_stretch(true); + add_child(vc); + vc->set_anchors_and_margins_preset(PRESET_WIDE); + viewport = memnew(Viewport); + Ref<World> world; + world.instance(); + viewport->set_world(world); //use own world + vc->add_child(viewport); + viewport->set_disable_input(true); + viewport->set_transparent_background(true); + viewport->set_msaa(Viewport::MSAA_4X); + + camera = memnew(Camera); + camera->set_transform(Transform(Basis(), Vector3(0, 0, 3))); + camera->set_perspective(45, 0.1, 10); + camera->make_current(); + viewport->add_child(camera); + + light1 = memnew(DirectionalLight); + light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + viewport->add_child(light1); + + light2 = memnew(DirectionalLight); + light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + light2->set_color(Color(0.7, 0.7, 0.7)); + viewport->add_child(light2); + + sphere_instance = memnew(MeshInstance); + viewport->add_child(sphere_instance); + + box_instance = memnew(MeshInstance); + viewport->add_child(box_instance); + + Transform box_xform; + box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0)); + box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0)); + box_xform.basis.scale(Vector3(0.8, 0.8, 0.8)); + box_xform.origin.y = 0.2; + box_instance->set_transform(box_xform); + + sphere_mesh.instance(); + sphere_instance->set_mesh(sphere_mesh); + box_mesh.instance(); + box_instance->set_mesh(box_mesh); + box_instance->hide(); + + set_custom_minimum_size(Size2(1, 150) * EDSCALE); + + HBoxContainer *hb = memnew(HBoxContainer); + add_child(hb); + hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2); + + VBoxContainer *vb_shape = memnew(VBoxContainer); + hb->add_child(vb_shape); + + sphere_switch = memnew(TextureButton); + sphere_switch->set_toggle_mode(true); + sphere_switch->set_pressed(true); + vb_shape->add_child(sphere_switch); + sphere_switch->connect("pressed", this, "_button_pressed", varray(sphere_switch)); + + box_switch = memnew(TextureButton); + box_switch->set_toggle_mode(true); + box_switch->set_pressed(false); + vb_shape->add_child(box_switch); + box_switch->connect("pressed", this, "_button_pressed", varray(box_switch)); + + hb->add_spacer(); + + VBoxContainer *vb_light = memnew(VBoxContainer); + hb->add_child(vb_light); + + light_1_switch = memnew(TextureButton); + light_1_switch->set_toggle_mode(true); + vb_light->add_child(light_1_switch); + light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch)); + + light_2_switch = memnew(TextureButton); + light_2_switch->set_toggle_mode(true); + vb_light->add_child(light_2_switch); + light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch)); + + first_enter = true; +} + +/////////////////////// + +bool EditorInspectorPluginMaterial::can_handle(Object *p_object) { + + Material *material = Object::cast_to<Material>(p_object); + if (!material) + return false; + + return material->get_shader_mode() == Shader::MODE_SPATIAL; +} + +void EditorInspectorPluginMaterial::parse_begin(Object *p_object) { + + Material *material = Object::cast_to<Material>(p_object); + if (!material) { + return; + } + Ref<Material> m(material); + + MaterialEditor *editor = memnew(MaterialEditor); + editor->edit(m, env); + add_custom_control(editor); +} + +EditorInspectorPluginMaterial::EditorInspectorPluginMaterial() { + env.instance(); + Ref<ProceduralSky> proc_sky = memnew(ProceduralSky(true)); + env->set_sky(proc_sky); + env->set_background(Environment::BG_COLOR_SKY); +} + +MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) { + + Ref<EditorInspectorPluginMaterial> plugin; + plugin.instance(); + add_inspector_plugin(plugin); +} + String SpatialMaterialConversionPlugin::converts_to() const { return "ShaderMaterial"; diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 39935d3e12..c3f14c27e5 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -32,6 +32,71 @@ #define MATERIAL_EDITOR_PLUGIN_H #include "editor/property_editor.h" +#include "scene/resources/primitive_meshes.h" + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" +#include "scene/3d/camera.h" +#include "scene/3d/light.h" +#include "scene/3d/mesh_instance.h" +#include "scene/resources/material.h" + +class MaterialEditor : public Control { + + GDCLASS(MaterialEditor, Control); + + ViewportContainer *vc; + Viewport *viewport; + MeshInstance *sphere_instance; + MeshInstance *box_instance; + DirectionalLight *light1; + DirectionalLight *light2; + Camera *camera; + + Ref<SphereMesh> sphere_mesh; + Ref<CubeMesh> box_mesh; + + TextureButton *sphere_switch; + TextureButton *box_switch; + + TextureButton *light_1_switch; + TextureButton *light_2_switch; + + Ref<Material> material; + + void _button_pressed(Node *p_button); + bool first_enter; + +protected: + void _notification(int p_what); + + static void _bind_methods(); + +public: + void edit(Ref<Material> p_material, const Ref<Environment> &p_env); + MaterialEditor(); +}; + +class EditorInspectorPluginMaterial : public EditorInspectorPlugin { + GDCLASS(EditorInspectorPluginMaterial, EditorInspectorPlugin) + Ref<Environment> env; + +public: + virtual bool can_handle(Object *p_object); + virtual void parse_begin(Object *p_object); + + EditorInspectorPluginMaterial(); +}; + +class MaterialEditorPlugin : public EditorPlugin { + + GDCLASS(MaterialEditorPlugin, EditorPlugin); + +public: + virtual String get_name() const { return "Material"; } + + MaterialEditorPlugin(EditorNode *p_node); +}; class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin { GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin) diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index fcf515e3fc..6203035e25 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -80,26 +80,21 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { mesh = p_mesh; mesh_instance->set_mesh(mesh); - if (mesh.is_null()) { - - hide(); - } else { - rot_x = 0; - rot_y = 0; - _update_rotation(); - - AABB aabb = mesh->get_aabb(); - Vector3 ofs = aabb.position + aabb.size * 0.5; - float m = aabb.get_longest_axis_size(); - if (m != 0) { - m = 1.0 / m; - m *= 0.5; - Transform xform; - xform.basis.scale(Vector3(m, m, m)); - xform.origin = -xform.basis.xform(ofs); //-ofs*m; - //xform.origin.z -= aabb.get_longest_axis_size() * 2; - mesh_instance->set_transform(xform); - } + rot_x = Math::deg2rad(-15.0); + rot_y = Math::deg2rad(30.0); + _update_rotation(); + + AABB aabb = mesh->get_aabb(); + Vector3 ofs = aabb.position + aabb.size * 0.5; + float m = aabb.get_longest_axis_size(); + if (m != 0) { + m = 1.0 / m; + m *= 0.5; + Transform xform; + xform.basis.scale(Vector3(m, m, m)); + xform.origin = -xform.basis.xform(ofs); //-ofs*m; + //xform.origin.z -= aabb.get_longest_axis_size() * 2; + mesh_instance->set_transform(xform); } } @@ -128,8 +123,8 @@ MeshEditor::MeshEditor() { viewport->set_world(world); //use own world add_child(viewport); viewport->set_disable_input(true); + viewport->set_msaa(Viewport::MSAA_2X); set_stretch(true); - camera = memnew(Camera); camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1))); camera->set_perspective(45, 0.1, 10); @@ -176,39 +171,29 @@ MeshEditor::MeshEditor() { rot_y = 0; } -void MeshEditorPlugin::edit(Object *p_object) { - - Mesh *s = Object::cast_to<Mesh>(p_object); - if (!s) - return; - - mesh_editor->edit(Ref<Mesh>(s)); -} +/////////////////////// -bool MeshEditorPlugin::handles(Object *p_object) const { +bool EditorInspectorPluginMesh::can_handle(Object *p_object) { - return p_object->is_class("Mesh"); + return Object::cast_to<Mesh>(p_object) != NULL; } -void MeshEditorPlugin::make_visible(bool p_visible) { +void EditorInspectorPluginMesh::parse_begin(Object *p_object) { - if (p_visible) { - mesh_editor->show(); - //mesh_editor->set_process(true); - } else { - - mesh_editor->hide(); - //mesh_editor->set_process(false); + Mesh *mesh = Object::cast_to<Mesh>(p_object); + if (!mesh) { + return; } + Ref<Mesh> m(mesh); + + MeshEditor *editor = memnew(MeshEditor); + editor->edit(m); + add_custom_control(editor); } MeshEditorPlugin::MeshEditorPlugin(EditorNode *p_node) { - editor = p_node; - mesh_editor = memnew(MeshEditor); - add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, mesh_editor); - mesh_editor->hide(); -} - -MeshEditorPlugin::~MeshEditorPlugin() { + Ref<EditorInspectorPluginMesh> plugin; + plugin.instance(); + add_inspector_plugin(plugin); } diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 0275f45be9..8ada2dac90 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -72,22 +72,21 @@ public: MeshEditor(); }; +class EditorInspectorPluginMesh : public EditorInspectorPlugin { + GDCLASS(EditorInspectorPluginMesh, EditorInspectorPlugin) +public: + virtual bool can_handle(Object *p_object); + virtual void parse_begin(Object *p_object); +}; + class MeshEditorPlugin : public EditorPlugin { GDCLASS(MeshEditorPlugin, EditorPlugin); - MeshEditor *mesh_editor; - EditorNode *editor; - public: virtual String get_name() const { return "Mesh"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); MeshEditorPlugin(EditorNode *p_node); - ~MeshEditorPlugin(); }; #endif diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 95828064ac..0032850535 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -353,7 +353,11 @@ void ParticlesEditor::_generate_aabb() { node->set_emitting(false); } - node->set_visibility_aabb(rect); + UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Generate Visibility AABB")); + ur->add_do_method(node, "set_visibility_aabb", rect); + ur->add_undo_method(node, "set_visibility_aabb", node->get_visibility_aabb()); + ur->commit_action(); } void ParticlesEditor::edit(Particles *p_particles) { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 020a68a7ed..033a6c56d9 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -47,6 +47,9 @@ Ref<Shader> ShaderTextEditor::get_edited_shader() const { } void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { + if (shader == p_shader) { + return; + } shader = p_shader; _load_theme_settings(); @@ -415,6 +418,9 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) { if (p_shader.is_null() || !p_shader->is_text_shader()) return; + if (shader == p_shader) + return; + shader = p_shader; shader_editor->set_edited_shader(p_shader); @@ -438,8 +444,12 @@ void ShaderEditor::save_external_data() { void ShaderEditor::apply_shaders() { if (shader.is_valid()) { - shader->set_code(shader_editor->get_text_edit()->get_text()); - shader->set_edited(true); + String shader_code = shader->get_code(); + String editor_code = shader_editor->get_text_edit()->get_text(); + if (shader_code != editor_code) { + shader->set_code(editor_code); + shader->set_edited(true); + } } } diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 1e9ff87fd3..ed11d26f25 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2108,9 +2108,11 @@ void SpatialEditorViewport::_notification(int p_what) { set_process(visible); - if (visible) + if (visible) { _update_camera(0); - + } else { + set_freelook_active(false); + } call_deferred("update_transform_gizmo_view"); } diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index c1718dd8bf..3854d27567 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -91,6 +91,8 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float Vector<Vector2> outPoints; ClipperLib::PolyNode *p2 = out.GetFirst(); + ERR_FAIL_COND_V(!p2, points); + while (p2->IsHole()) { p2 = p2->GetNext(); } diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 0482ae86f3..831b2f3f16 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -138,39 +138,28 @@ TextureEditor::TextureEditor() { set_custom_minimum_size(Size2(1, 150)); } -void TextureEditorPlugin::edit(Object *p_object) { +// +bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - Texture *s = Object::cast_to<Texture>(p_object); - if (!s) - return; - - texture_editor->edit(Ref<Texture>(s)); -} - -bool TextureEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("Texture"); + return Object::cast_to<Texture>(p_object) != NULL; } -void TextureEditorPlugin::make_visible(bool p_visible) { +void EditorInspectorPluginTexture::parse_begin(Object *p_object) { - if (p_visible) { - texture_editor->show(); - //texture_editor->set_process(true); - } else { - - texture_editor->hide(); - //texture_editor->set_process(false); + Texture *texture = Object::cast_to<Texture>(p_object); + if (!texture) { + return; } + Ref<Texture> m(texture); + + TextureEditor *editor = memnew(TextureEditor); + editor->edit(m); + add_custom_control(editor); } TextureEditorPlugin::TextureEditorPlugin(EditorNode *p_node) { - editor = p_node; - texture_editor = memnew(TextureEditor); - add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, texture_editor); - texture_editor->hide(); -} - -TextureEditorPlugin::~TextureEditorPlugin() { + Ref<EditorInspectorPluginTexture> plugin; + plugin.instance(); + add_inspector_plugin(plugin); } diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 80ff4d6416..9c7d33df5a 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -52,22 +52,21 @@ public: TextureEditor(); }; +class EditorInspectorPluginTexture : public EditorInspectorPlugin { + GDCLASS(EditorInspectorPluginTexture, EditorInspectorPlugin) +public: + virtual bool can_handle(Object *p_object); + virtual void parse_begin(Object *p_object); +}; + class TextureEditorPlugin : public EditorPlugin { GDCLASS(TextureEditorPlugin, EditorPlugin); - TextureEditor *texture_editor; - EditorNode *editor; - public: virtual String get_name() const { return "Texture"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); TextureEditorPlugin(EditorNode *p_node); - ~TextureEditorPlugin(); }; #endif // TEXTURE_EDITOR_PLUGIN_H diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 75417d986c..e041c3d62e 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -3118,6 +3118,24 @@ bool TilesetEditorContext::_set(const StringName &p_name, const Variant &p_value } else if (name == "tileset_script") { tileset->set_script(p_value); return true; + } else if (name == "selected_collision_one_way") { + Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile()); + for (int index = 0; index < sd.size(); index++) { + if (sd[index].shape == tileset_editor->edited_collision_shape) { + tileset->tile_set_shape_one_way(tileset_editor->get_current_tile(), index, p_value); + return true; + } + } + return false; + } else if (name == "selected_collision_one_way_margin") { + Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile()); + for (int index = 0; index < sd.size(); index++) { + if (sd[index].shape == tileset_editor->edited_collision_shape) { + tileset->tile_set_shape_one_way_margin(tileset_editor->get_current_tile(), index, p_value); + return true; + } + } + return false; } tileset_editor->err_dialog->set_text(TTR("This property can't be changed.")); @@ -3160,6 +3178,24 @@ bool TilesetEditorContext::_get(const StringName &p_name, Variant &r_ret) const } else if (name == "selected_collision") { r_ret = tileset_editor->edited_collision_shape; v = true; + } else if (name == "selected_collision_one_way") { + Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile()); + for (int index = 0; index < sd.size(); index++) { + if (sd[index].shape == tileset_editor->edited_collision_shape) { + r_ret = sd[index].one_way_collision; + v = true; + break; + } + } + } else if (name == "selected_collision_one_way_margin") { + Vector<TileSet::ShapeData> sd = tileset->tile_get_shapes(tileset_editor->get_current_tile()); + for (int index = 0; index < sd.size(); index++) { + if (sd[index].shape == tileset_editor->edited_collision_shape) { + r_ret = sd[index].one_way_collision_margin; + v = true; + break; + } + } } else if (name == "selected_navigation") { r_ret = tileset_editor->edited_navigation_shape; v = true; @@ -3206,6 +3242,10 @@ void TilesetEditorContext::_get_property_list(List<PropertyInfo> *p_list) const } if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_COLLISION && tileset_editor->edited_collision_shape.is_valid()) { p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_collision", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_collision_shape->get_class())); + if (tileset_editor->edited_collision_shape.is_valid()) { + p_list->push_back(PropertyInfo(Variant::BOOL, "selected_collision_one_way", PROPERTY_HINT_NONE)); + p_list->push_back(PropertyInfo(Variant::REAL, "selected_collision_one_way_margin", PROPERTY_HINT_NONE)); + } } if (tileset_editor->edit_mode == TileSetEditor::EDITMODE_NAVIGATION && tileset_editor->edited_navigation_shape.is_valid()) { p_list->push_back(PropertyInfo(Variant::OBJECT, "selected_navigation", PROPERTY_HINT_RESOURCE_TYPE, tileset_editor->edited_navigation_shape->get_class())); |