diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/create_dialog.cpp | 4 | ||||
-rw-r--r-- | editor/editor_data.cpp | 26 | ||||
-rw-r--r-- | editor/editor_data.h | 3 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 20 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 10 | ||||
-rw-r--r-- | editor/editor_node.cpp | 12 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 63 | ||||
-rw-r--r-- | editor/editor_toaster.cpp | 5 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.cpp | 46 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.h | 6 | ||||
-rw-r--r-- | editor/plugins/tiles/tile_map_editor.cpp | 2 | ||||
-rw-r--r-- | editor/script_create_dialog.cpp | 12 |
14 files changed, 116 insertions, 109 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 8ccfda1145..2d70934c9c 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -665,7 +665,7 @@ void CreateDialog::_save_and_update_favorite_list() { for (int i = 0; i < favorite_list.size(); i++) { String l = favorite_list[i]; String name = l.get_slicec(' ', 0); - if (!(ClassDB::class_exists(name) || ScriptServer::is_global_class(name))) { + if (!EditorNode::get_editor_data().is_type_recognized(name)) { continue; } f->store_line(l); @@ -692,7 +692,7 @@ void CreateDialog::_load_favorites_and_history() { String l = f->get_line().strip_edges(); String name = l.get_slicec(' ', 0); - if ((ClassDB::class_exists(name) || ScriptServer::is_global_class(name)) && !_is_class_disabled_by_feature_profile(name)) { + if (EditorNode::get_editor_data().is_type_recognized(name) && !_is_class_disabled_by_feature_profile(name)) { recent->add_item(l, EditorNode::get_singleton()->get_class_icon(name, icon_fallback)); } } diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 1febec2c04..d1ea0f2814 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -509,6 +509,32 @@ Variant EditorData::instance_custom_type(const String &p_type, const String &p_i return Variant(); } +const EditorData::CustomType *EditorData::get_custom_type_by_name(const String &p_type) const { + for (const KeyValue<String, Vector<CustomType>> &E : custom_types) { + for (const CustomType &F : E.value) { + if (F.name == p_type) { + return &F; + } + } + } + return nullptr; +} + +const EditorData::CustomType *EditorData::get_custom_type_by_path(const String &p_path) const { + for (const KeyValue<String, Vector<CustomType>> &E : custom_types) { + for (const CustomType &F : E.value) { + if (F.script->get_path() == p_path) { + return &F; + } + } + } + return nullptr; +} + +bool EditorData::is_type_recognized(const String &p_type) const { + return ClassDB::class_exists(p_type) || ScriptServer::is_global_class(p_type) || get_custom_type_by_name(p_type); +} + void EditorData::remove_custom_type(const String &p_type) { for (KeyValue<String, Vector<CustomType>> &E : custom_types) { for (int i = 0; i < E.value.size(); i++) { diff --git a/editor/editor_data.h b/editor/editor_data.h index 1da188c546..4f1740d4f0 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -184,6 +184,9 @@ public: Variant instance_custom_type(const String &p_type, const String &p_inherits); void remove_custom_type(const String &p_type); const HashMap<String, Vector<CustomType>> &get_custom_types() const { return custom_types; } + const CustomType *get_custom_type_by_name(const String &p_name) const; + const CustomType *get_custom_type_by_path(const String &p_path) const; + bool is_type_recognized(const String &p_type) const; void instantiate_object_properties(Object *p_object); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 36ca1619a4..629f72b974 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -145,6 +145,8 @@ void EditorFileDialog::_notification(int p_what) { if (!is_visible()) { set_process_shortcut_input(false); } + + invalidate(); // For consistency with the standard FileDialog. } break; case NOTIFICATION_WM_WINDOW_FOCUS_IN: { @@ -304,10 +306,6 @@ void EditorFileDialog::_post_popup() { } set_current_dir(current); - if (invalidated) { - update_file_list(); - invalidated = false; - } if (mode == FILE_MODE_SAVE_FILE) { file->grab_focus(); } else { @@ -320,19 +318,13 @@ void EditorFileDialog::_post_popup() { file_box->set_visible(true); } - if (is_visible() && !get_current_file().is_empty()) { + if (!get_current_file().is_empty()) { _request_single_thumbnail(get_current_dir().path_join(get_current_file())); } - if (is_visible()) { - _update_recent(); - - local_history.clear(); - local_history_pos = -1; - _push_history(); - - _update_favorites(); - } + local_history.clear(); + local_history_pos = -1; + _push_history(); set_process_shortcut_input(true); } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index c1a7b15121..b01d7bc8a7 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2743,7 +2743,7 @@ void EditorInspector::update_tree() { doc_name = p.name; // Set the category icon. - if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) { + if (!EditorNode::get_editor_data().is_type_recognized(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) { // If we have a category inside a script, search for the first script with a valid icon. Ref<Script> script = ResourceLoader::load(p.hint_string, "Script"); StringName base_type; @@ -2762,10 +2762,16 @@ void EditorInspector::update_tree() { while (script.is_valid()) { name = EditorNode::get_editor_data().script_class_get_name(script->get_path()); String icon_path = EditorNode::get_editor_data().script_class_get_icon_path(name); - if (name != StringName() && icon_path.length()) { + if (name != StringName() && !icon_path.is_empty()) { category->icon = ResourceLoader::load(icon_path, "Texture"); break; } + + const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_path(script->get_path()); + if (ctype) { + category->icon = ctype->icon; + break; + } script = script->get_base_script(); } if (category->icon.is_null() && has_theme_icon(base_type, SNAME("EditorIcons"))) { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 96b229b7ee..a2231f4601 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4335,16 +4335,8 @@ Ref<Texture2D> EditorNode::get_class_icon(const String &p_class, const String &p } } - const HashMap<String, Vector<EditorData::CustomType>> &p_map = EditorNode::get_editor_data().get_custom_types(); - for (const KeyValue<String, Vector<EditorData::CustomType>> &E : p_map) { - const Vector<EditorData::CustomType> &ct = E.value; - for (int i = 0; i < ct.size(); ++i) { - if (ct[i].name == p_class) { - if (ct[i].icon.is_valid()) { - return ct[i].icon; - } - } - } + if (const EditorData::CustomType *ctype = EditorNode::get_editor_data().get_custom_type_by_name(p_class)) { + return ctype->icon; } if (gui_base->has_theme_icon(p_class, SNAME("EditorIcons"))) { diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 5bf79635b8..9e983839f9 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -157,24 +157,15 @@ void EditorColorMap::create() { static Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_bottom, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, bool p_draw_center = true) { Ref<StyleBoxTexture> style(memnew(StyleBoxTexture)); style->set_texture(p_texture); - style->set_margin_size(SIDE_LEFT, p_left * EDSCALE); - style->set_margin_size(SIDE_RIGHT, p_right * EDSCALE); - style->set_margin_size(SIDE_BOTTOM, p_bottom * EDSCALE); - style->set_margin_size(SIDE_TOP, p_top * EDSCALE); - style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); + style->set_margin_size_individual(p_left * EDSCALE, p_top * EDSCALE, p_right * EDSCALE, p_bottom * EDSCALE); + style->set_default_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE); style->set_draw_center(p_draw_center); return style; } static Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) { Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty)); - style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); + style->set_default_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE); return style; } @@ -184,10 +175,7 @@ static Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = // Adjust level of detail based on the corners' effective sizes. style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE)); style->set_corner_radius_all(p_corner_width * EDSCALE); - style->set_default_margin(SIDE_LEFT, p_margin_left * EDSCALE); - style->set_default_margin(SIDE_RIGHT, p_margin_right * EDSCALE); - style->set_default_margin(SIDE_BOTTOM, p_margin_bottom * EDSCALE); - style->set_default_margin(SIDE_TOP, p_margin_top * EDSCALE); + style->set_default_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE); // Work around issue about antialiased edges being blurrier (GH-35279). style->set_anti_aliased(false); return style; @@ -600,10 +588,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Vector2 widget_default_margin = Vector2(extra_spacing + 6, extra_spacing + default_margin_size + 1) * EDSCALE; Ref<StyleBoxFlat> style_widget = style_default->duplicate(); - style_widget->set_default_margin(SIDE_LEFT, widget_default_margin.x); - style_widget->set_default_margin(SIDE_TOP, widget_default_margin.y); - style_widget->set_default_margin(SIDE_RIGHT, widget_default_margin.x); - style_widget->set_default_margin(SIDE_BOTTOM, widget_default_margin.y); + style_widget->set_default_margin_individual(widget_default_margin.x, widget_default_margin.y, widget_default_margin.x, widget_default_margin.y); style_widget->set_bg_color(dark_color_1); style_widget->set_border_color(dark_color_2); @@ -626,10 +611,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Style for windows, popups, etc.. Ref<StyleBoxFlat> style_popup = style_default->duplicate(); const int popup_margin_size = default_margin_size * EDSCALE * 3; - style_popup->set_default_margin(SIDE_LEFT, popup_margin_size); - style_popup->set_default_margin(SIDE_TOP, popup_margin_size); - style_popup->set_default_margin(SIDE_RIGHT, popup_margin_size); - style_popup->set_default_margin(SIDE_BOTTOM, popup_margin_size); + style_popup->set_default_margin_all(popup_margin_size); style_popup->set_border_color(contrast_color_1); const Color shadow_color = Color(0, 0, 0, dark_theme ? 0.3 : 0.1); style_popup->set_shadow_color(shadow_color); @@ -922,10 +904,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Checkbox Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate(); - sb_checkbox->set_default_margin(SIDE_LEFT, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE); - sb_checkbox->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin_all(default_margin_size * EDSCALE); theme->set_stylebox("normal", "CheckBox", sb_checkbox); theme->set_stylebox("pressed", "CheckBox", sb_checkbox); @@ -965,10 +944,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Use 1 pixel for the sides, since if 0 is used, the highlight of hovered items is drawn // on top of the popup border. This causes a 'gap' in the panel border when an item is highlighted, // and it looks weird. 1px solves this. - style_popup_menu->set_default_margin(SIDE_LEFT, EDSCALE); - style_popup_menu->set_default_margin(SIDE_TOP, 2 * EDSCALE); - style_popup_menu->set_default_margin(SIDE_RIGHT, EDSCALE); - style_popup_menu->set_default_margin(SIDE_BOTTOM, 2 * EDSCALE); + style_popup_menu->set_default_margin_individual(EDSCALE, 2 * EDSCALE, EDSCALE, 2 * EDSCALE); // Always display a border for PopupMenus so they can be distinguished from their background. style_popup_menu->set_border_width_all(EDSCALE); style_popup_menu->set_border_color(dark_color_2); @@ -1024,10 +1000,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { sub_inspector_bg->set_bg_color(dark_color_1.lerp(si_base_color, 0.08)); sub_inspector_bg->set_border_width_all(2 * EDSCALE); sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8)); - sub_inspector_bg->set_default_margin(SIDE_LEFT, 4 * EDSCALE); - sub_inspector_bg->set_default_margin(SIDE_RIGHT, 4 * EDSCALE); - sub_inspector_bg->set_default_margin(SIDE_BOTTOM, 4 * EDSCALE); - sub_inspector_bg->set_default_margin(SIDE_TOP, 4 * EDSCALE); + sub_inspector_bg->set_default_margin_all(4 * EDSCALE); sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0); sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0); @@ -1255,10 +1228,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { style_content_panel->set_corner_radius(CORNER_TOP_LEFT, 0); style_content_panel->set_corner_radius(CORNER_TOP_RIGHT, 0); // Compensate for the border. - style_content_panel->set_default_margin(SIDE_TOP, (2 + margin_size_extra) * EDSCALE); - style_content_panel->set_default_margin(SIDE_RIGHT, margin_size_extra * EDSCALE); - style_content_panel->set_default_margin(SIDE_BOTTOM, margin_size_extra * EDSCALE); - style_content_panel->set_default_margin(SIDE_LEFT, margin_size_extra * EDSCALE); + style_content_panel->set_default_margin_individual(margin_size_extra * EDSCALE, (2 + margin_size_extra) * EDSCALE, margin_size_extra * EDSCALE, margin_size_extra * EDSCALE); theme->set_stylebox("panel", "TabContainer", style_content_panel); // Bottom panel. @@ -1279,10 +1249,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // This stylebox is used in 3d and 2d viewports (no borders). Ref<StyleBoxFlat> style_content_panel_vp = style_content_panel->duplicate(); - style_content_panel_vp->set_default_margin(SIDE_LEFT, border_width * 2); - style_content_panel_vp->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE); - style_content_panel_vp->set_default_margin(SIDE_RIGHT, border_width * 2); - style_content_panel_vp->set_default_margin(SIDE_BOTTOM, border_width * 2); + style_content_panel_vp->set_default_margin_individual(border_width * 2, default_margin_size * EDSCALE, border_width * 2, border_width * 2); theme->set_stylebox("Content", "EditorStyles", style_content_panel_vp); // This stylebox is used by preview tabs in the Theme Editor. @@ -1361,6 +1328,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("separation", "HSplitContainer", default_margin_size * 2 * EDSCALE); theme->set_constant("separation", "VSplitContainer", default_margin_size * 2 * EDSCALE); + theme->set_constant("minimum_grab_thickness", "HSplitContainer", 6 * EDSCALE); + theme->set_constant("minimum_grab_thickness", "VSplitContainer", 6 * EDSCALE); + // Containers theme->set_constant("separation", "BoxContainer", default_margin_size * EDSCALE); theme->set_constant("separation", "HBoxContainer", default_margin_size * EDSCALE); @@ -1519,10 +1489,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // is only relevant for default tooltips. Ref<StyleBoxFlat> style_tooltip = style_popup->duplicate(); style_tooltip->set_shadow_size(0); - style_tooltip->set_default_margin(SIDE_LEFT, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_default_margin(SIDE_TOP, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_default_margin(SIDE_RIGHT, default_margin_size * EDSCALE * 0.5); - style_tooltip->set_default_margin(SIDE_BOTTOM, default_margin_size * EDSCALE * 0.5); + style_tooltip->set_default_margin_all(default_margin_size * EDSCALE * 0.5); style_tooltip->set_bg_color(dark_color_3 * Color(0.8, 0.8, 0.8, 0.9)); style_tooltip->set_border_width_all(0); theme->set_color("font_color", "TooltipLabel", font_hover_color); diff --git a/editor/editor_toaster.cpp b/editor/editor_toaster.cpp index e66b782f3c..6a5242f0c6 100644 --- a/editor/editor_toaster.cpp +++ b/editor/editor_toaster.cpp @@ -498,10 +498,7 @@ EditorToaster::EditorToaster() { Ref<StyleBoxFlat> boxes[] = { info_panel_style_background, warning_panel_style_background, error_panel_style_background }; for (int i = 0; i < 3; i++) { - boxes[i]->set_default_margin(SIDE_LEFT, int(stylebox_radius * 2.5)); - boxes[i]->set_default_margin(SIDE_RIGHT, int(stylebox_radius * 2.5)); - boxes[i]->set_default_margin(SIDE_TOP, 3); - boxes[i]->set_default_margin(SIDE_BOTTOM, 3); + boxes[i]->set_default_margin_individual(int(stylebox_radius * 2.5), 3, int(stylebox_radius * 2.5), 3); } // Theming (progress). diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 1231ac10ab..c79b43de09 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -101,10 +101,7 @@ void EditorAssetLibraryItem::_bind_methods() { EditorAssetLibraryItem::EditorAssetLibraryItem() { Ref<StyleBoxEmpty> border; border.instantiate(); - border->set_default_margin(SIDE_LEFT, 5 * EDSCALE); - border->set_default_margin(SIDE_RIGHT, 5 * EDSCALE); - border->set_default_margin(SIDE_BOTTOM, 5 * EDSCALE); - border->set_default_margin(SIDE_TOP, 5 * EDSCALE); + border->set_default_margin_all(5 * EDSCALE); add_theme_style_override("panel", border); HBoxContainer *hb = memnew(HBoxContainer); @@ -1510,10 +1507,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { Ref<StyleBoxEmpty> border2; border2.instantiate(); - border2->set_default_margin(SIDE_LEFT, 15 * EDSCALE); - border2->set_default_margin(SIDE_RIGHT, 35 * EDSCALE); - border2->set_default_margin(SIDE_BOTTOM, 15 * EDSCALE); - border2->set_default_margin(SIDE_TOP, 15 * EDSCALE); + border2->set_default_margin_individual(15 * EDSCALE, 15 * EDSCALE, 35 * EDSCALE, 15 * EDSCALE); PanelContainer *library_vb_border = memnew(PanelContainer); library_scroll->add_child(library_vb_border); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 9deb516ec4..c87da34143 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3959,10 +3959,8 @@ void CanvasItemEditor::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons"))); - for (int i = 0; i < 4; i++) { - select_sb->set_margin_size(Side(i), 4); - select_sb->set_default_margin(Side(i), 4); - } + select_sb->set_margin_size_all(4); + select_sb->set_default_margin_all(4); AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed)); _keying_changed(); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 76d05624d6..fe7713f175 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -40,6 +40,19 @@ #include "scene/resources/particle_process_material.h" #include "scene/resources/sky_material.h" +void MaterialEditor::gui_input(const Ref<InputEvent> &p_event) { + ERR_FAIL_COND(p_event.is_null()); + + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid() && (mm->get_button_mask() & MouseButton::MASK_LEFT) != MouseButton::NONE) { + rot.x -= mm->get_relative().y * 0.01; + rot.y -= mm->get_relative().x * 0.01; + + rot.x = CLAMP(rot.x, -Math_PI / 2, Math_PI / 2); + _update_rotation(); + } +} + void MaterialEditor::_update_theme_item_cache() { Control::_update_theme_item_cache(); @@ -77,6 +90,13 @@ void MaterialEditor::_notification(int p_what) { } } +void MaterialEditor::_update_rotation() { + Transform3D t; + t.basis.rotate(Vector3(0, 1, 0), -rot.y); + t.basis.rotate(Vector3(1, 0, 0), -rot.x); + rotation->set_transform(t); +} + void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) { material = p_material; camera->set_environment(p_env); @@ -102,6 +122,10 @@ void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_en } else { hide(); } + + rot.x = Math::deg_to_rad(-15.0); + rot.y = Math::deg_to_rad(30.0); + _update_rotation(); } void MaterialEditor::_button_pressed(Node *p_button) { @@ -130,9 +154,6 @@ void MaterialEditor::_button_pressed(Node *p_button) { } } -void MaterialEditor::_bind_methods() { -} - MaterialEditor::MaterialEditor() { // canvas item @@ -163,7 +184,7 @@ MaterialEditor::MaterialEditor() { viewport->set_msaa_3d(Viewport::MSAA_4X); camera = memnew(Camera3D); - camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3))); + camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 1.1))); // Use low field of view so the sphere/box is fully encompassed within the preview, // without much distortion. camera->set_perspective(20, 0.1, 10); @@ -183,18 +204,17 @@ MaterialEditor::MaterialEditor() { light2->set_color(Color(0.7, 0.7, 0.7)); viewport->add_child(light2); + rotation = memnew(Node3D); + viewport->add_child(rotation); + sphere_instance = memnew(MeshInstance3D); - viewport->add_child(sphere_instance); + rotation->add_child(sphere_instance); box_instance = memnew(MeshInstance3D); - viewport->add_child(box_instance); - - Transform3D box_xform; - box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg_to_rad(25.0)); - box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg_to_rad(-25.0)); - box_xform.basis.scale(Vector3(0.7, 0.7, 0.7)); - box_xform.origin.y = 0.05; - box_instance->set_transform(box_xform); + rotation->add_child(box_instance); + + box_instance->set_transform(Transform3D() * 0.25); + sphere_instance->set_transform(Transform3D() * 0.375); sphere_mesh.instantiate(); sphere_instance->set_mesh(sphere_mesh); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 7ce6deee65..8e64434d8b 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -45,11 +45,14 @@ class SubViewportContainer; class MaterialEditor : public Control { GDCLASS(MaterialEditor, Control); + Vector2 rot = Vector2(); + HBoxContainer *layout_2d = nullptr; ColorRect *rect_instance = nullptr; SubViewportContainer *vc = nullptr; SubViewport *viewport = nullptr; + Node3D *rotation = nullptr; MeshInstance3D *sphere_instance = nullptr; MeshInstance3D *box_instance = nullptr; DirectionalLight3D *light1 = nullptr; @@ -87,7 +90,8 @@ class MaterialEditor : public Control { protected: virtual void _update_theme_item_cache() override; void _notification(int p_what); - static void _bind_methods(); + void gui_input(const Ref<InputEvent> &p_event) override; + void _update_rotation(); public: void edit(Ref<Material> p_material, const Ref<Environment> &p_env); diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp index 3f2710f858..08f418c1f7 100644 --- a/editor/plugins/tiles/tile_map_editor.cpp +++ b/editor/plugins/tiles/tile_map_editor.cpp @@ -1359,11 +1359,11 @@ void TileMapEditorTilesPlugin::_stop_dragging() { for (int i = 0; i < sources_list->get_item_count(); i++) { if (int(sources_list->get_item_metadata(i)) == picked_source) { sources_list->set_current(i); + TilesEditorPlugin::get_singleton()->set_sources_lists_current(i); break; } } sources_list->ensure_current_is_visible(); - TilesEditorPlugin::get_singleton()->set_sources_lists_current(picked_source); } Ref<TileMapPattern> new_selection_pattern = tile_map->get_pattern(tile_map_layer, coords_array); diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 16ab441324..f57dfe4827 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -202,7 +202,7 @@ bool ScriptCreateDialog::_validate_parent(const String &p_string) { } } - return ClassDB::class_exists(p_string) || ScriptServer::is_global_class(p_string); + return EditorNode::get_editor_data().is_type_recognized(p_string); } bool ScriptCreateDialog::_validate_class(const String &p_string) { @@ -372,7 +372,15 @@ void ScriptCreateDialog::_create_new() { const ScriptLanguage::ScriptTemplate sinfo = _get_current_template(); - scr = ScriptServer::get_language(language_menu->get_selected())->make_template(sinfo.content, cname_param, parent_name->get_text()); + String parent_class = parent_name->get_text(); + if (!ClassDB::class_exists(parent_class) && !ScriptServer::is_global_class(parent_class)) { + // If base is a custom type, replace with script path instead. + const EditorData::CustomType *type = EditorNode::get_editor_data().get_custom_type_by_name(parent_class); + ERR_FAIL_NULL(type); + parent_class = "\"" + type->script->get_path() + "\""; + } + + scr = ScriptServer::get_language(language_menu->get_selected())->make_template(sinfo.content, cname_param, parent_class); if (has_named_classes) { String cname = class_name->get_text(); |