diff options
Diffstat (limited to 'editor')
50 files changed, 933 insertions, 204 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index c8c8c7d891..0dbe230699 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -946,7 +946,7 @@ void AnimationBezierTrackEdit::gui_input(const Ref<InputEvent> &p_event) { } if (menu->get_item_count()) { - menu->set_as_minsize(); + menu->reset_size(); menu->set_position(popup_pos); menu->popup(); } diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 53f585d06b..6586fcd5ce 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2748,7 +2748,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(get_theme_icon(SNAME("TrackDiscrete"), SNAME("EditorIcons")), TTR("Discrete"), MENU_CALL_MODE_DISCRETE); menu->add_icon_item(get_theme_icon(SNAME("TrackTrigger"), SNAME("EditorIcons")), TTR("Trigger"), MENU_CALL_MODE_TRIGGER); menu->add_icon_item(get_theme_icon(SNAME("TrackCapture"), SNAME("EditorIcons")), TTR("Capture"), MENU_CALL_MODE_CAPTURE); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + update_mode_rect.position + Vector2(0, update_mode_rect.size.height); menu->set_position(popup_pos); @@ -2766,7 +2766,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_icon_item(get_theme_icon(SNAME("InterpRaw"), SNAME("EditorIcons")), TTR("Nearest"), MENU_INTERPOLATION_NEAREST); menu->add_icon_item(get_theme_icon(SNAME("InterpLinear"), SNAME("EditorIcons")), TTR("Linear"), MENU_INTERPOLATION_LINEAR); menu->add_icon_item(get_theme_icon(SNAME("InterpCubic"), SNAME("EditorIcons")), TTR("Cubic"), MENU_INTERPOLATION_CUBIC); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + interp_mode_rect.position + Vector2(0, interp_mode_rect.size.height); menu->set_position(popup_pos); @@ -2783,7 +2783,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->clear(); menu->add_icon_item(get_theme_icon(SNAME("InterpWrapClamp"), SNAME("EditorIcons")), TTR("Clamp Loop Interp"), MENU_LOOP_CLAMP); menu->add_icon_item(get_theme_icon(SNAME("InterpWrapLoop"), SNAME("EditorIcons")), TTR("Wrap Loop Interp"), MENU_LOOP_WRAP); - menu->set_as_minsize(); + menu->reset_size(); Vector2 popup_pos = get_screen_position() + loop_wrap_rect.position + Vector2(0, loop_wrap_rect.size.height); menu->set_position(popup_pos); @@ -2885,7 +2885,7 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { menu->add_separator(); menu->add_icon_item(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), TTR("Delete Key(s)"), MENU_KEY_DELETE); } - menu->set_as_minsize(); + menu->reset_size(); menu->set_position(get_screen_position() + get_local_mouse_position()); menu->popup(); @@ -3588,7 +3588,7 @@ void AnimationTrackEditor::commit_insert_queue() { } } - if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true)) && num_tracks > 0) { + if (bool(EDITOR_GET("editors/animation/confirm_insert_track")) && num_tracks > 0) { // Potentially a new key, does not exist. if (num_tracks == 1) { // TRANSLATORS: %s will be replaced by a phrase describing the target of track. diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 4b263e5152..32e3c3679a 100644 --- a/editor/debugger/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -659,7 +659,7 @@ EditorProfiler::EditorProfiler() { h_split->add_child(graph); graph->set_h_size_flags(SIZE_EXPAND_FILL); - int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024); + int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 1024); frame_metrics.resize(metric_size); total_metrics = 0; last_metric = -1; diff --git a/editor/debugger/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index 5df86c70fe..554a9dc6a5 100644 --- a/editor/debugger/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -789,7 +789,7 @@ EditorVisualProfiler::EditorVisualProfiler() { h_split->add_child(graph); graph->set_h_size_flags(SIZE_EXPAND_FILL); - int metric_size = CLAMP(int(EDITOR_DEF("debugger/profiler_frame_history_size", 600)), 60, 1024); + int metric_size = CLAMP(int(EDITOR_GET("debugger/profiler_frame_history_size")), 60, 1024); frame_metrics.resize(metric_size); last_metric = -1; //cursor_metric=-1; diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 9c0bd91121..b64b48b4ee 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1332,7 +1332,7 @@ EditorAudioBuses::EditorAudioBuses() { List<String> ext; ResourceLoader::get_recognized_extensions_for_type("AudioBusLayout", &ext); for (const String &E : ext) { - file_dialog->add_filter("*." + E + "; Audio Bus Layout"); + file_dialog->add_filter(vformat("*.%s; %s", E, TTR("Audio Bus Layout"))); } add_child(file_dialog); file_dialog->connect("file_selected", callable_mp(this, &EditorAudioBuses::_file_dialog_callback)); diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 295b477080..1afd59e99c 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -542,7 +542,7 @@ void EditorExportPlatform::_edit_filter_list(Set<String> &r_list, const String & filters.push_back(f); } - DirAccess *da = DirAccess::open("res://"); + DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); ERR_FAIL_NULL(da); _edit_files_with_filter(da, filters, r_list, exclude); memdelete(da); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 675ef808e1..a83379dca4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -691,15 +691,11 @@ void EditorProperty::unhandled_key_input(const Ref<InputEvent> &p_event) { } const Color *EditorProperty::_get_property_colors() { - const Color base = get_theme_color(SNAME("accent_color"), SNAME("Editor")); - const float saturation = base.get_s() * 0.75; - const float value = base.get_v(); - static Color c[4]; - c[0].set_hsv(0.0 / 3.0 + 0.05, saturation, value); - c[1].set_hsv(1.0 / 3.0 + 0.05, saturation, value); - c[2].set_hsv(2.0 / 3.0 + 0.05, saturation, value); - c[3].set_hsv(1.5 / 3.0 + 0.05, saturation, value); + c[0] = get_theme_color(SNAME("property_color_x"), SNAME("Editor")); + c[1] = get_theme_color(SNAME("property_color_y"), SNAME("Editor")); + c[2] = get_theme_color(SNAME("property_color_z"), SNAME("Editor")); + c[3] = get_theme_color(SNAME("property_color_w"), SNAME("Editor")); return c; } @@ -3514,7 +3510,9 @@ void EditorInspector::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_inspector_bg(); - update_tree(); + if (EditorSettings::get_singleton()->check_changed_settings_in_group("interface/inspector")) { + update_tree(); + } } break; } } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ddb9c93f04..42eaf8bd89 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -701,22 +701,29 @@ void EditorNode::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); - theme = create_custom_theme(theme_base->get_theme()); - theme_base->set_theme(theme); - gui_base->set_theme(theme); + bool theme_changed = + EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") || + EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme"); - gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); - scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); - bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); - scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); - scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); + if (theme_changed) { + theme = create_custom_theme(theme_base->get_theme()); + + theme_base->set_theme(theme); + gui_base->set_theme(theme); - file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); - project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); - debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); - settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); - help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + gui_base->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Background"), SNAME("EditorStyles"))); + scene_root_parent->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("Content"), SNAME("EditorStyles"))); + bottom_panel->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); + scene_tabs->add_theme_style_override("tab_selected", gui_base->get_theme_stylebox(SNAME("SceneTabFG"), SNAME("EditorStyles"))); + scene_tabs->add_theme_style_override("tab_unselected", gui_base->get_theme_stylebox(SNAME("SceneTabBG"), SNAME("EditorStyles"))); + + file_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + project_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + debug_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + settings_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + help_menu->add_theme_style_override("hover", gui_base->get_theme_stylebox(SNAME("MenuHover"), SNAME("EditorStyles"))); + } if (EDITOR_GET("interface/scene_tabs/resize_if_many_tabs")) { scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); @@ -725,7 +732,7 @@ void EditorNode::_notification(int p_what) { } _update_scene_tabs(); - recent_scenes->set_as_minsize(); + recent_scenes->reset_size(); // debugger area if (EditorDebuggerNode::get_singleton()->is_visible()) { @@ -3784,7 +3791,7 @@ void EditorNode::_update_recent_scenes() { recent_scenes->add_separator(); recent_scenes->add_shortcut(ED_SHORTCUT("editor/clear_recent", TTR("Clear Recent Scenes"))); - recent_scenes->set_as_minsize(); + recent_scenes->reset_size(); } void EditorNode::_quick_opened() { @@ -5425,7 +5432,7 @@ void EditorNode::remove_tool_menu_item(const String &p_name) { memdelete(n); } tool_menu->remove_item(i); - tool_menu->set_as_minsize(); + tool_menu->reset_size(); return; } } @@ -6023,18 +6030,10 @@ EditorNode::EditorNode() { // defs here, use EDITOR_GET in logic EDITOR_DEF_RST("interface/scene_tabs/always_show_close_button", false); - EDITOR_DEF_RST("interface/scene_tabs/resize_if_many_tabs", true); - EDITOR_DEF_RST("interface/scene_tabs/minimum_width", 50); - EDITOR_DEF("run/output/always_clear_output_on_play", true); - EDITOR_DEF("run/output/always_open_output_on_play", true); - EDITOR_DEF("run/output/always_close_output_on_stop", true); - EDITOR_DEF("run/auto_save/save_before_running", true); EDITOR_DEF("interface/editor/save_on_focus_loss", false); - EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true); EDITOR_DEF("interface/editor/show_update_spinner", false); EDITOR_DEF("interface/editor/update_continuously", false); EDITOR_DEF_RST("interface/scene_tabs/restore_scenes_on_load", true); - EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true); EDITOR_DEF_RST("interface/inspector/capitalize_properties", true); EDITOR_DEF_RST("interface/inspector/default_float_step", 0.001); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::FLOAT, "interface/inspector/default_float_step", PROPERTY_HINT_RANGE, "0,1,0")); @@ -6048,7 +6047,6 @@ EditorNode::EditorNode() { EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT)); EDITOR_DEF("interface/inspector/default_color_picker_shape", (int32_t)ColorPicker::SHAPE_VHS_CIRCLE); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_shape", PROPERTY_HINT_ENUM, "HSV Rectangle,HSV Rectangle Wheel,VHS Circle", PROPERTY_USAGE_DEFAULT)); - EDITOR_DEF("run/auto_save/save_before_running", true); ED_SHORTCUT("canvas_item_editor/pan_view", TTR("Pan View"), Key::SPACE); @@ -6204,7 +6202,7 @@ EditorNode::EditorNode() { dock_vb->add_child(dock_float); - dock_select_popup->set_as_minsize(); + dock_select_popup->reset_size(); dock_select_rect_over = -1; dock_popup_selected = -1; for (int i = 0; i < DOCK_SLOT_MAX; i++) { @@ -6256,8 +6254,8 @@ EditorNode::EditorNode() { scene_tabs->set_select_with_rmb(true); scene_tabs->add_tab("unsaved"); scene_tabs->set_tab_alignment(TabBar::ALIGNMENT_LEFT); - scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/scene_tabs/always_show_close_button", false)) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); - scene_tabs->set_min_width(int(EDITOR_DEF("interface/scene_tabs/minimum_width", 50)) * EDSCALE); + scene_tabs->set_tab_close_display_policy((bool(EDITOR_GET("interface/scene_tabs/always_show_close_button")) ? TabBar::CLOSE_BUTTON_SHOW_ALWAYS : TabBar::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); + scene_tabs->set_min_width(int(EDITOR_GET("interface/scene_tabs/minimum_width")) * EDSCALE); scene_tabs->set_drag_to_rearrange_enabled(true); scene_tabs->connect("tab_changed", callable_mp(this, &EditorNode::_scene_tab_changed)); scene_tabs->connect("tab_button_pressed", callable_mp(this, &EditorNode::_scene_tab_script_edited)); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 68a3fabe1e..d93d495ff6 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -1185,7 +1185,7 @@ void EditorPropertyLayers::_button_pressed() { } Rect2 gp = button->get_screen_rect(); - layers->set_as_minsize(); + layers->reset_size(); Vector2 popup_pos = gp.position - Vector2(layers->get_contents_minimum_size().x, 0); layers->set_position(popup_pos); layers->popup(); @@ -1626,7 +1626,7 @@ void EditorPropertyVector2::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 2; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -1720,7 +1720,7 @@ void EditorPropertyRect2::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - spin[i]->set_custom_label_color(true, colors[i % 2]); + spin[i]->add_theme_color_override("label_color", colors[i % 2]); } } break; } @@ -1849,7 +1849,7 @@ void EditorPropertyVector3::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 3; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -1939,7 +1939,7 @@ void EditorPropertyVector2i::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 2; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -2033,7 +2033,7 @@ void EditorPropertyRect2i::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - spin[i]->set_custom_label_color(true, colors[i % 2]); + spin[i]->add_theme_color_override("label_color", colors[i % 2]); } } break; } @@ -2135,7 +2135,7 @@ void EditorPropertyVector3i::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 3; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -2228,7 +2228,7 @@ void EditorPropertyPlane::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -2322,7 +2322,7 @@ void EditorPropertyQuaternion::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 4; i++) { - spin[i]->set_custom_label_color(true, colors[i]); + spin[i]->add_theme_color_override("label_color", colors[i]); } } break; } @@ -2419,7 +2419,7 @@ void EditorPropertyAABB::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 6; i++) { - spin[i]->set_custom_label_color(true, colors[i % 3]); + spin[i]->add_theme_color_override("label_color", colors[i % 3]); } } break; } @@ -2505,9 +2505,9 @@ void EditorPropertyTransform2D::_notification(int p_what) { for (int i = 0; i < 6; i++) { // For Transform2D, use the 4th color (cyan) for the origin vector. if (i % 3 == 2) { - spin[i]->set_custom_label_color(true, colors[3]); + spin[i]->add_theme_color_override("label_color", colors[3]); } else { - spin[i]->set_custom_label_color(true, colors[i % 3]); + spin[i]->add_theme_color_override("label_color", colors[i % 3]); } } } break; @@ -2599,7 +2599,7 @@ void EditorPropertyBasis::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 9; i++) { - spin[i]->set_custom_label_color(true, colors[i % 3]); + spin[i]->add_theme_color_override("label_color", colors[i % 3]); } } break; } @@ -2696,7 +2696,7 @@ void EditorPropertyTransform3D::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { const Color *colors = _get_property_colors(); for (int i = 0; i < 12; i++) { - spin[i]->set_custom_label_color(true, colors[i % 4]); + spin[i]->add_theme_color_override("label_color", colors[i % 4]); } } break; } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 61261af608..d354be9af5 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -175,7 +175,7 @@ void EditorPropertyArray::_change_type(Object *p_button, int p_index) { Button *button = Object::cast_to<Button>(p_button); changing_type_index = p_index; Rect2 rect = button->get_screen_rect(); - change_type->set_as_minsize(); + change_type->reset_size(); change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0)); change_type->popup(); } @@ -751,7 +751,7 @@ void EditorPropertyDictionary::_change_type(Object *p_button, int p_index) { Button *button = Object::cast_to<Button>(p_button); Rect2 rect = button->get_screen_rect(); - change_type->set_as_minsize(); + change_type->reset_size(); change_type->set_position(rect.get_end() - Vector2(change_type->get_contents_minimum_size().x, 0)); change_type->popup(); changing_type_index = p_index; diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 2f14667fc0..a7b2a4cfa6 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -149,7 +149,7 @@ void EditorResourcePicker::_update_menu() { _update_menu_items(); Rect2 gt = edit_button->get_screen_rect(); - edit_menu->set_as_minsize(); + edit_menu->reset_size(); int ms = edit_menu->get_contents_minimum_size().width; Vector2 popup_pos = gt.get_end() - Vector2(ms, 0); edit_menu->set_position(popup_pos); @@ -337,7 +337,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { // Ensure that the FileSystem dock is visible. TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(file_system_dock->get_index()); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); } break; default: { @@ -476,7 +476,7 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) { _update_menu_items(); Vector2 pos = get_screen_position() + mb->get_position(); - edit_menu->set_as_minsize(); + edit_menu->reset_size(); edit_menu->set_position(pos); edit_menu->popup(); } @@ -905,7 +905,12 @@ void EditorScriptPicker::set_create_options(Object *p_menu_node) { } menu_node->add_icon_item(get_theme_icon(SNAME("ScriptCreate"), SNAME("EditorIcons")), TTR("New Script"), OBJ_MENU_NEW_SCRIPT); - menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + if (script_owner) { + Ref<Script> script = script_owner->get_script(); + if (script.is_valid()) { + menu_node->add_icon_item(get_theme_icon(SNAME("ScriptExtend"), SNAME("EditorIcons")), TTR("Extend Script"), OBJ_MENU_EXTEND_SCRIPT); + } + } menu_node->add_separator(); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 6bd11fcdd6..52ff7e3c19 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -63,6 +63,7 @@ bool EditorSettings::_set(const StringName &p_name, const Variant &p_value) { bool changed = _set_only(p_name, p_value); if (changed) { + changed_settings.insert(p_name); emit_signal(SNAME("settings_changed")); } return true; @@ -553,6 +554,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/behavior/files/autosave_interval_secs", 0); _initial_set("text_editor/behavior/files/restore_scripts_on_load", true); _initial_set("text_editor/behavior/files/convert_indent_on_save", true); + _initial_set("text_editor/behavior/files/auto_reload_scripts_on_external_change", false); // Script list _initial_set("text_editor/script_list/show_members_overview", true); @@ -585,6 +587,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // Use a similar color to the 2D editor selection. EDITOR_SETTING_USAGE(Variant::COLOR, PROPERTY_HINT_NONE, "editors/3d/selection_box_color", Color(1.0, 0.5, 0), "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED) + _initial_set("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + _initial_set("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1)); + _initial_set("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); // If a line is a multiple of this, it uses the primary grid color. // Use a power of 2 value by default as it's more common to use powers of 2 in level design. @@ -708,6 +713,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { // SSL EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "network/ssl/editor_ssl_certificates", _SYSTEM_CERTS_PATH, "*.crt,*.pem") + // Profiler + _initial_set("debugger/profiler_frame_history_size", 600); + /* Extra config */ EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "project_manager/sorting_order", 0, "Name,Path,Last Edited") @@ -941,10 +949,34 @@ void EditorSettings::save() { if (err != OK) { ERR_PRINT("Error saving editor settings to " + singleton->config_file_path); } else { + singleton->changed_settings.clear(); print_verbose("EditorSettings: Save OK!"); } } +Array EditorSettings::get_changed_settings() const { + Array arr; + for (const String &setting : changed_settings) { + arr.push_back(setting); + } + + return arr; +} + +bool EditorSettings::check_changed_settings_in_group(const String &p_setting_prefix) const { + for (const String &setting : changed_settings) { + if (setting.begins_with(p_setting_prefix)) { + return true; + } + } + + return false; +} + +void EditorSettings::mark_setting_changed(const String &p_setting) { + changed_settings.insert(p_setting); +} + void EditorSettings::destroy() { if (!singleton.ptr()) { return; @@ -1621,6 +1653,10 @@ void EditorSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("set_builtin_action_override", "name", "actions_list"), &EditorSettings::set_builtin_action_override); + ClassDB::bind_method(D_METHOD("check_changed_settings_in_group", "setting_prefix"), &EditorSettings::check_changed_settings_in_group); + ClassDB::bind_method(D_METHOD("get_changed_settings"), &EditorSettings::get_changed_settings); + ClassDB::bind_method(D_METHOD("mark_setting_changed", "setting"), &EditorSettings::mark_setting_changed); + ADD_SIGNAL(MethodInfo("settings_changed")); BIND_CONSTANT(NOTIFICATION_EDITOR_SETTINGS_CHANGED); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index f0fec3acc7..65723a24f8 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -77,6 +77,8 @@ private: static Ref<EditorSettings> singleton; + Set<String> changed_settings; + HashMap<String, PropertyInfo> hints; HashMap<String, VariantContainer> props; int last_order; @@ -140,6 +142,9 @@ public: bool property_can_revert(const String &p_setting); Variant property_get_revert(const String &p_setting); void add_property_hint(const PropertyInfo &p_hint); + Array get_changed_settings() const; + bool check_changed_settings_in_group(const String &p_setting_prefix) const; + void mark_setting_changed(const String &p_setting); void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; } Ref<Resource> get_resource_clipboard() const { return clipboard; } diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 75bba64e2e..8ecdcfff65 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -134,9 +134,13 @@ void EditorSettingsDialog::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { _update_icons(); - // Update theme colors. - inspector->update_category_list(); - _update_shortcuts(); + + bool update_shortcuts_tab = + EditorSettings::get_singleton()->check_changed_settings_in_group("shortcuts") || + EditorSettings::get_singleton()->check_changed_settings_in_group("builtin_action_overrides"); + if (update_shortcuts_tab) { + _update_shortcuts(); + } } break; } } @@ -215,6 +219,8 @@ void EditorSettingsDialog::_update_builtin_action(const String &p_name, const Ar Array old_input_array = EditorSettings::get_singleton()->get_builtin_action_overrides(p_name); undo_redo->create_action(TTR("Edit Built-in Action") + " '" + p_name + "'"); + undo_redo->add_do_method(EditorSettings::get_singleton(), "mark_setting_changed", "builtin_action_overrides"); + undo_redo->add_undo_method(EditorSettings::get_singleton(), "mark_setting_changed", "builtin_action_overrides"); undo_redo->add_do_method(EditorSettings::get_singleton(), "set_builtin_action_override", p_name, p_events); undo_redo->add_undo_method(EditorSettings::get_singleton(), "set_builtin_action_override", p_name, old_input_array); undo_redo->add_do_method(this, "_settings_changed"); @@ -230,6 +236,8 @@ void EditorSettingsDialog::_update_shortcut_events(const String &p_path, const A undo_redo->create_action(TTR("Edit Shortcut") + " '" + p_path + "'"); undo_redo->add_do_method(current_sc.ptr(), "set_events", p_events); undo_redo->add_undo_method(current_sc.ptr(), "set_events", current_sc->get_events()); + undo_redo->add_do_method(EditorSettings::get_singleton(), "mark_setting_changed", "shortcuts"); + undo_redo->add_undo_method(EditorSettings::get_singleton(), "mark_setting_changed", "shortcuts"); undo_redo->add_do_method(this, "_update_shortcuts"); undo_redo->add_undo_method(this, "_update_shortcuts"); undo_redo->add_do_method(this, "_settings_changed"); diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp index a4a9e691a0..509a316ef3 100644 --- a/editor/editor_spin_slider.cpp +++ b/editor/editor_spin_slider.cpp @@ -300,12 +300,7 @@ void EditorSpinSlider::_draw_spin_slider() { int vofs = (size.height - font->get_height(font_size)) / 2 + font->get_ascent(font_size); Color fc = get_theme_color(is_read_only() ? SNAME("font_uneditable_color") : SNAME("font_color"), SNAME("LineEdit")); - Color lc; - if (use_custom_label_color) { - lc = custom_label_color; - } else { - lc = fc; - } + Color lc = get_theme_color(is_read_only() ? SNAME("read_only_label_color") : SNAME("label_color")); if (flat && !label.is_empty()) { Color label_bg_color = get_theme_color(SNAME("dark_color_3"), SNAME("Editor")); @@ -605,11 +600,6 @@ bool EditorSpinSlider::is_flat() const { return flat; } -void EditorSpinSlider::set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color) { - use_custom_label_color = p_use_custom_label_color; - custom_label_color = p_custom_label_color; -} - void EditorSpinSlider::_focus_entered() { _ensure_input_popup(); Rect2 gr = get_screen_rect(); @@ -689,5 +679,4 @@ EditorSpinSlider::EditorSpinSlider() { value_input_just_closed = false; hide_slider = false; read_only = false; - use_custom_label_color = false; } diff --git a/editor/editor_spin_slider.h b/editor/editor_spin_slider.h index 7e3f2051ac..4e52980804 100644 --- a/editor/editor_spin_slider.h +++ b/editor/editor_spin_slider.h @@ -76,9 +76,6 @@ class EditorSpinSlider : public Range { bool hide_slider; bool flat; - bool use_custom_label_color; - Color custom_label_color; - void _evaluate_input_text(); void _update_value_input_stylebox(); @@ -112,8 +109,6 @@ public: void set_flat(bool p_enable); bool is_flat() const; - void set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color); - void setup_and_show() { _focus_entered(); } LineEdit *get_line_edit(); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index e97ea389be..01757dd332 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -467,6 +467,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("axis_y_color", "Editor", Color(0.53, 0.84, 0.01)); theme->set_color("axis_z_color", "Editor", Color(0.16, 0.55, 0.96)); + const float prop_color_saturation = accent_color.get_s() * 0.75; + const float prop_color_value = accent_color.get_v(); + + theme->set_color("property_color_x", "Editor", Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_y", "Editor", Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_z", "Editor", Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_w", "Editor", Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("font_color", "Editor", font_color); theme->set_color("highlighted_font_color", "Editor", font_hover_color); theme->set_color("disabled_font_color", "Editor", font_disabled_color); @@ -868,6 +876,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)); theme->set_constant("sub_inspector_font_offset", "Editor", 4 * EDSCALE); + // EditorSpinSlider. + theme->set_color("label_color", "EditorSpinSlider", font_color); + theme->set_color("read_only_label_color", "EditorSpinSlider", font_readonly_color); + Ref<StyleBoxFlat> style_property_bg = style_default->duplicate(); style_property_bg->set_bg_color(highlight_color); style_property_bg->set_border_width_all(0); @@ -1160,7 +1172,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("can_fold", "CodeEdit", theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); theme->set_icon("executing_line", "CodeEdit", theme->get_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons"))); - theme->set_constant("line_spacing", "CodeEdit", EDITOR_DEF("text_editor/appearance/whitespace/line_spacing", 6)); + theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing")); // H/VSplitContainer theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiVsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1)); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 3cad600002..0a8d35aff1 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -645,7 +645,7 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_ // To support custom Android builds, we install the Java source code and buildsystem // from android_source.zip to the project's res://android folder. - DirAccessRef da = DirAccess::open("res://"); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES); ERR_FAIL_COND_V(!da, ERR_CANT_CREATE); // Make res://android dir (if it does not exist). diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 4a6aa11938..df0af69359 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -298,8 +298,8 @@ void EditorFileServer::_thread_start(void *s) { void EditorFileServer::start() { stop(); - port = EDITOR_DEF("filesystem/file_server/port", 6010); - password = EDITOR_DEF("filesystem/file_server/password", ""); + port = EDITOR_GET("filesystem/file_server/port"); + password = EDITOR_GET("filesystem/file_server/password"); cmd = CMD_ACTIVATE; } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index b41123c0dd..e8a2a46dd2 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -396,12 +396,25 @@ void FileSystemDock::_notification(int p_what) { } } else if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) { tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN); + } else if ((String(dd["type"]) == "nodes")) { + holding_branch = true; + TreeItem *item = tree->get_next_selected(tree->get_root()); + while (item) { + tree_items_selected_on_drag_begin.push_back(item); + item = tree->get_next_selected(item); + } + list_items_selected_on_drag_begin = files->get_selected_items(); } } } break; case NOTIFICATION_DRAG_END: { tree->set_drop_mode_flags(0); + + if (holding_branch) { + holding_branch = false; + _reselect_items_selected_on_drag_begin(true); + } } break; case NOTIFICATION_THEME_CHANGED: { @@ -512,7 +525,7 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa if (target_path.ends_with("/")) { target_path = target_path.substr(0, target_path.length() - 1); } - DirAccess *dirAccess = DirAccess::open("res://"); + DirAccess *dirAccess = DirAccess::create(DirAccess::ACCESS_RESOURCES); if (dirAccess->file_exists(p_path)) { path = target_path; } else if (dirAccess->dir_exists(p_path)) { @@ -2647,8 +2660,79 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { call_deferred(SNAME("_update_import_dock")); } +void FileSystemDock::_tree_mouse_exited() { + if (holding_branch) { + _reselect_items_selected_on_drag_begin(); + } +} + +void FileSystemDock::_reselect_items_selected_on_drag_begin(bool reset) { + TreeItem *selected_item = tree->get_next_selected(tree->get_root()); + if (selected_item) { + selected_item->deselect(0); + } + if (!tree_items_selected_on_drag_begin.is_empty()) { + bool reselected = false; + for (TreeItem *item : tree_items_selected_on_drag_begin) { + if (item->get_tree()) { + item->select(0); + reselected = true; + } + } + + if (reset) { + tree_items_selected_on_drag_begin.clear(); + } + + if (!reselected) { + // If couldn't reselect the items selected on drag begin, select the "res://" item. + tree->get_root()->get_child(1)->select(0); + } + } + + files->deselect_all(); + if (!list_items_selected_on_drag_begin.is_empty()) { + for (const int idx : list_items_selected_on_drag_begin) { + files->select(idx, false); + } + + if (reset) { + list_items_selected_on_drag_begin.clear(); + } + } +} + void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { Ref<InputEventKey> key = p_event; + + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid()) { + TreeItem *item = tree->get_item_at_position(mm->get_position()); + if (item && holding_branch) { + String fpath = item->get_metadata(0); + while (!fpath.ends_with("/") && fpath != "res://" && item->get_parent()) { // Find the parent folder tree item. + item = item->get_parent(); + fpath = item->get_metadata(0); + } + + TreeItem *deselect_item = tree->get_next_selected(tree->get_root()); + while (deselect_item) { + deselect_item->deselect(0); + deselect_item = tree->get_next_selected(deselect_item); + } + item->select(0); + + if (display_mode == DisplayMode::DISPLAY_MODE_SPLIT) { + files->deselect_all(); + // Try to select the corresponding file list item. + const int files_item_idx = files->find_metadata(fpath); + if (files_item_idx != -1) { + files->select(files_item_idx); + } + } + } + } + if (key.is_valid() && key->is_pressed() && !key->is_echo()) { if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) { _tree_rmb_option(FILE_DUPLICATE); @@ -2669,6 +2753,43 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { } void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { + Ref<InputEventMouseMotion> mm = p_event; + if (mm.is_valid() && holding_branch) { + const int item_idx = files->get_item_at_position(mm->get_position()); + if (item_idx != -1) { + files->deselect_all(); + String fpath = files->get_item_metadata(item_idx); + if (fpath.ends_with("/") || fpath == "res://") { + files->select(item_idx); + } + + TreeItem *deselect_item = tree->get_next_selected(tree->get_root()); + while (deselect_item) { + deselect_item->deselect(0); + deselect_item = tree->get_next_selected(deselect_item); + } + + // Try to select the corresponding tree item. + TreeItem *tree_item = tree->get_item_with_text(files->get_item_text(item_idx)); + if (tree_item) { + tree_item->select(0); + } else { + // Find parent folder. + fpath = fpath.substr(0, fpath.rfind("/") + 1); + if (fpath.size() > String("res://").size()) { + fpath = fpath.left(fpath.size() - 2); // Remove last '/'. + const int slash_idx = fpath.rfind("/"); + fpath = fpath.substr(slash_idx + 1, fpath.size() - slash_idx - 1); + } + + tree_item = tree->get_item_with_text(fpath); + if (tree_item) { + tree_item->select(0); + } + } + } + } + Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed() && !key->is_echo()) { if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) { @@ -2932,6 +3053,7 @@ FileSystemDock::FileSystemDock() { tree->connect("empty_rmb", callable_mp(this, &FileSystemDock::_tree_rmb_empty)); tree->connect("nothing_selected", callable_mp(this, &FileSystemDock::_tree_empty_selected)); tree->connect("gui_input", callable_mp(this, &FileSystemDock::_tree_gui_input)); + tree->connect("mouse_exited", callable_mp(this, &FileSystemDock::_tree_mouse_exited)); file_list_vb = memnew(VBoxContainer); file_list_vb->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 21c50beeb2..d457c6acd4 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -185,6 +185,13 @@ private: ItemList *files; bool import_dock_needs_update; + bool holding_branch = false; + Vector<TreeItem *> tree_items_selected_on_drag_begin; + PackedInt32Array list_items_selected_on_drag_begin; + + void _tree_mouse_exited(); + void _reselect_items_selected_on_drag_begin(bool reset = false); + Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, String p_file_type); bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); Vector<String> _compute_uncollapsed_paths(); diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp index ebfb0b32fb..f0a2d7d553 100644 --- a/editor/import/dynamic_font_import_settings.cpp +++ b/editor/import/dynamic_font_import_settings.cpp @@ -767,7 +767,6 @@ bool DynamicFontImportSettings::_char_update(int32_t p_char) { selected_chars.insert(p_char); return true; } - label_glyphs->set_text(TTR("Preloaded glyphs: ") + itos(selected_glyphs.size())); } void DynamicFontImportSettings::_range_update(int32_t p_start, int32_t p_end) { diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index 7071042818..d9dd273ed4 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -104,16 +104,16 @@ String ResourceImporterLayeredTexture::get_save_extension() const { String ResourceImporterLayeredTexture::get_resource_type() const { switch (mode) { case MODE_CUBEMAP: { - return "StreamCubemap"; + return "CompressedCubemap"; } break; case MODE_2D_ARRAY: { - return "StreamTexture2DArray"; + return "CompressedTexture2DArray"; } break; case MODE_CUBEMAP_ARRAY: { - return "StreamCubemapArray"; + return "CompressedCubemapArray"; } break; case MODE_3D: { - return "StreamTexture3D"; + return "CompressedTexture3D"; } break; } ERR_FAIL_V(String()); @@ -263,7 +263,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons f->store_8('T'); f->store_8('L'); - f->store_32(StreamTextureLayered::FORMAT_VERSION); + f->store_32(CompressedTextureLayered::FORMAT_VERSION); f->store_32(p_images.size()); // For 2d layers or 3d depth. f->store_32(mode); f->store_32(0); diff --git a/editor/import/resource_importer_layered_texture.h b/editor/import/resource_importer_layered_texture.h index edd981c63d..58e5c47d8d 100644 --- a/editor/import/resource_importer_layered_texture.h +++ b/editor/import/resource_importer_layered_texture.h @@ -35,7 +35,7 @@ #include "core/io/resource_importer.h" #include "core/object/ref_counted.h" -class StreamTexture2D; +class CompressedTexture2D; class LayeredTextureImport : public RefCounted { GDCLASS(LayeredTextureImport, RefCounted); diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 35a20e85c1..1561fc788c 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -37,7 +37,7 @@ #include "editor/editor_file_system.h" #include "editor/editor_node.h" -void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) { +void ResourceImporterTexture::_texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RS::TextureDetectRoughnessChannel p_channel) { ERR_FAIL_COND(p_tex.is_null()); MutexLock lock(singleton->mutex); @@ -53,7 +53,7 @@ void ResourceImporterTexture::_texture_reimport_roughness(const Ref<StreamTextur singleton->make_flags[path].normal_path_for_roughness = p_normal_path; } -void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p_tex) { +void ResourceImporterTexture::_texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex) { ERR_FAIL_COND(p_tex.is_null()); MutexLock lock(singleton->mutex); @@ -67,7 +67,7 @@ void ResourceImporterTexture::_texture_reimport_3d(const Ref<StreamTexture2D> &p singleton->make_flags[path].flags |= MAKE_3D_FLAG; } -void ResourceImporterTexture::_texture_reimport_normal(const Ref<StreamTexture2D> &p_tex) { +void ResourceImporterTexture::_texture_reimport_normal(const Ref<CompressedTexture2D> &p_tex) { ERR_FAIL_COND(p_tex.is_null()); MutexLock lock(singleton->mutex); @@ -153,11 +153,11 @@ void ResourceImporterTexture::get_recognized_extensions(List<String> *p_extensio } String ResourceImporterTexture::get_save_extension() const { - return "stex"; + return "ctex"; } String ResourceImporterTexture::get_resource_type() const { - return "StreamTexture2D"; + return "CompressedTexture2D"; } bool ResourceImporterTexture::get_option_visibility(const String &p_path, const String &p_option, const Map<StringName, Variant> &p_options) const { @@ -231,7 +231,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image bool lossless_force_png = ProjectSettings::get_singleton()->get("rendering/textures/lossless_compression/force_png") || !Image::_webp_mem_loader_func; // WebP module disabled. bool use_webp = !lossless_force_png && p_image->get_width() <= 16383 && p_image->get_height() <= 16383; // WebP has a size limit - f->store_32(use_webp ? StreamTexture2D::DATA_FORMAT_WEBP : StreamTexture2D::DATA_FORMAT_PNG); + f->store_32(use_webp ? CompressedTexture2D::DATA_FORMAT_WEBP : CompressedTexture2D::DATA_FORMAT_PNG); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); f->store_32(p_image->get_mipmap_count()); @@ -253,7 +253,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } break; case COMPRESS_LOSSY: { - f->store_32(StreamTexture2D::DATA_FORMAT_WEBP); + f->store_32(CompressedTexture2D::DATA_FORMAT_WEBP); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); f->store_32(p_image->get_mipmap_count()); @@ -273,7 +273,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image image->compress_from_channels(p_compress_format, p_channels, p_lossy_quality); - f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE); + f->store_32(CompressedTexture2D::DATA_FORMAT_IMAGE); f->store_16(image->get_width()); f->store_16(image->get_height()); f->store_32(image->get_mipmap_count()); @@ -285,7 +285,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image f->store_buffer(r, dl); } break; case COMPRESS_VRAM_UNCOMPRESSED: { - f->store_32(StreamTexture2D::DATA_FORMAT_IMAGE); + f->store_32(CompressedTexture2D::DATA_FORMAT_IMAGE); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); f->store_32(p_image->get_mipmap_count()); @@ -299,7 +299,7 @@ void ResourceImporterTexture::save_to_stex_format(FileAccess *f, const Ref<Image } break; case COMPRESS_BASIS_UNIVERSAL: { - f->store_32(StreamTexture2D::DATA_FORMAT_BASIS_UNIVERSAL); + f->store_32(CompressedTexture2D::DATA_FORMAT_BASIS_UNIVERSAL); f->store_16(p_image->get_width()); f->store_16(p_image->get_height()); f->store_32(p_image->get_mipmap_count()); @@ -326,26 +326,26 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String f->store_8('2'); //godot streamable texture 2D //format version - f->store_32(StreamTexture2D::FORMAT_VERSION); + f->store_32(CompressedTexture2D::FORMAT_VERSION); //texture may be resized later, so original size must be saved first f->store_32(p_image->get_width()); f->store_32(p_image->get_height()); uint32_t flags = 0; if (p_streamable) { - flags |= StreamTexture2D::FORMAT_BIT_STREAM; + flags |= CompressedTexture2D::FORMAT_BIT_STREAM; } if (p_mipmaps) { - flags |= StreamTexture2D::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit + flags |= CompressedTexture2D::FORMAT_BIT_HAS_MIPMAPS; //mipmaps bit } if (p_detect_3d) { - flags |= StreamTexture2D::FORMAT_BIT_DETECT_3D; + flags |= CompressedTexture2D::FORMAT_BIT_DETECT_3D; } if (p_detect_roughness) { - flags |= StreamTexture2D::FORMAT_BIT_DETECT_ROUGNESS; + flags |= CompressedTexture2D::FORMAT_BIT_DETECT_ROUGNESS; } if (p_detect_normal) { - flags |= StreamTexture2D::FORMAT_BIT_DETECT_NORMAL; + flags |= CompressedTexture2D::FORMAT_BIT_DETECT_NORMAL; } f->store_32(flags); @@ -540,19 +540,19 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (!bptc_ldr && can_s3tc && is_ldr) { image_compress_mode = Image::COMPRESS_S3TC; } - _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); + _save_stex(image, p_save_path + ".s3tc.ctex", compress_mode, lossy, image_compress_mode, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("s3tc"); formats_imported.push_back("s3tc"); } if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc2")) { - _save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); + _save_stex(image, p_save_path + ".etc2.ctex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("etc2"); formats_imported.push_back("etc2"); } if (ProjectSettings::get_singleton()->get("rendering/textures/vram_compression/import_etc")) { - _save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); + _save_stex(image, p_save_path + ".etc.ctex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, true, mipmap_limit, normal_image, roughness_channel); r_platform_variants->push_back("etc"); formats_imported.push_back("etc"); } @@ -562,7 +562,7 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String } } else { //import normally - _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); + _save_stex(image, p_save_path + ".ctex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, stream, detect_3d, detect_roughness, detect_normal, force_normal, srgb_friendly_pack, false, mipmap_limit, normal_image, roughness_channel); } if (r_metadata) { @@ -638,9 +638,9 @@ ResourceImporterTexture *ResourceImporterTexture::singleton = nullptr; ResourceImporterTexture::ResourceImporterTexture() { singleton = this; - StreamTexture2D::request_3d_callback = _texture_reimport_3d; - StreamTexture2D::request_roughness_callback = _texture_reimport_roughness; - StreamTexture2D::request_normal_callback = _texture_reimport_normal; + CompressedTexture2D::request_3d_callback = _texture_reimport_3d; + CompressedTexture2D::request_roughness_callback = _texture_reimport_roughness; + CompressedTexture2D::request_normal_callback = _texture_reimport_normal; } ResourceImporterTexture::~ResourceImporterTexture() { diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index ea2318fb33..bd43eaef58 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -37,7 +37,7 @@ #include "scene/resources/texture.h" #include "servers/rendering_server.h" -class StreamTexture2D; +class CompressedTexture2D; class ResourceImporterTexture : public ResourceImporter { GDCLASS(ResourceImporterTexture, ResourceImporter); @@ -67,9 +67,9 @@ protected: Map<StringName, MakeInfo> make_flags; - static void _texture_reimport_roughness(const Ref<StreamTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel); - static void _texture_reimport_3d(const Ref<StreamTexture2D> &p_tex); - static void _texture_reimport_normal(const Ref<StreamTexture2D> &p_tex); + static void _texture_reimport_roughness(const Ref<CompressedTexture2D> &p_tex, const String &p_normal_path, RenderingServer::TextureDetectRoughnessChannel p_channel); + static void _texture_reimport_3d(const Ref<CompressedTexture2D> &p_tex); + static void _texture_reimport_normal(const Ref<CompressedTexture2D> &p_tex); static ResourceImporterTexture *singleton; static const char *compression_formats[]; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 4e06253041..f500268ad3 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -1269,8 +1269,8 @@ SceneImportSettings::SceneImportSettings() { item_save_path = memnew(EditorFileDialog); item_save_path->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); - item_save_path->add_filter("*.tres;Text Resource"); - item_save_path->add_filter("*.res;Binary Resource"); + item_save_path->add_filter("*.tres; " + TTR("Text Resource")); + item_save_path->add_filter("*.res; " + TTR("Binary Resource")); add_child(item_save_path); item_save_path->connect("file_selected", callable_mp(this, &SceneImportSettings::_save_path_changed)); diff --git a/editor/plugin_config_dialog.cpp b/editor/plugin_config_dialog.cpp index 48ea3013f7..d5e7c312d9 100644 --- a/editor/plugin_config_dialog.cpp +++ b/editor/plugin_config_dialog.cpp @@ -117,7 +117,7 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { if (name_edit->get_text().is_empty()) { is_valid = false; name_validation->set_texture(invalid_icon); - name_validation->set_tooltip(TTR("Plugin name cannot not be blank.")); + name_validation->set_tooltip(TTR("Plugin name cannot be blank.")); } if (script_edit->get_text().get_extension() != ext) { is_valid = false; @@ -127,7 +127,7 @@ void PluginConfigDialog::_on_required_text_changed(const String &) { if (script_edit->get_text().get_basename().is_empty()) { is_valid = false; script_validation->set_texture(invalid_icon); - script_validation->set_tooltip(TTR("Script name cannot not be blank.")); + script_validation->set_tooltip(TTR("Script name cannot be blank.")); } if (subfolder_edit->get_text().is_empty()) { is_valid = false; diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index ad126d28f6..dd166ccd1d 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -547,6 +547,7 @@ void AnimationPlayerEditor::_animation_name_edited() { Ref<Animation> anim = player->get_animation(current); Ref<Animation> new_anim = _animation_clone(anim); + new_anim->set_name(new_name); undo_redo->create_action(TTR("Duplicate Animation")); undo_redo->add_do_method(player, "add_animation", new_name, new_anim); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 9e9915cfa4..50f253b167 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -44,8 +44,8 @@ static inline void setup_http_request(HTTPRequest *request) { request->set_use_threads(EDITOR_DEF("asset_library/use_threads", true)); - const String proxy_host = EDITOR_DEF("network/http_proxy/host", ""); - const int proxy_port = EDITOR_DEF("network/http_proxy/port", -1); + const String proxy_host = EDITOR_GET("network/http_proxy/host"); + const int proxy_port = EDITOR_GET("network/http_proxy/port"); request->set_http_proxy(proxy_host, proxy_port); request->set_https_proxy(proxy_host, proxy_port); } diff --git a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp index affe10a01d..643a470425 100644 --- a/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_collision_sdf_editor_plugin.cpp @@ -152,7 +152,7 @@ void GPUParticlesCollisionSDF3DEditorPlugin::_sdf_save_path_and_bake(const Strin } config->set_value("remap", "importer", "3d_texture"); - config->set_value("remap", "type", "StreamTexture3D"); + config->set_value("remap", "type", "CompressedTexture3D"); if (!config->has_section_key("params", "compress/mode")) { config->set_value("params", "compress/mode", 3); //user may want another compression, so leave it be } diff --git a/editor/plugins/lightmap_gi_editor_plugin.cpp b/editor/plugins/lightmap_gi_editor_plugin.cpp index 5992e52162..aef97f059a 100644 --- a/editor/plugins/lightmap_gi_editor_plugin.cpp +++ b/editor/plugins/lightmap_gi_editor_plugin.cpp @@ -138,7 +138,7 @@ LightmapGIEditorPlugin::LightmapGIEditorPlugin() { file_dialog = memnew(EditorFileDialog); file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE); - file_dialog->add_filter("*.lmbake ; LightMap Bake"); + file_dialog->add_filter("*.lmbake ; " + TTR("LightMap Bake")); file_dialog->set_title(TTR("Select lightmap bake file:")); file_dialog->connect("file_selected", callable_mp(this, &LightmapGIEditorPlugin::_bake_select_file)); bake->add_child(file_dialog); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 3d40755b7a..468341a593 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -317,7 +317,6 @@ void MeshLibraryEditorPlugin::make_visible(bool p_visible) { } MeshLibraryEditorPlugin::MeshLibraryEditorPlugin() { - EDITOR_DEF("editors/grid_map/preview_size", 64); mesh_library_editor = memnew(MeshLibraryEditor); EditorNode::get_singleton()->get_main_control()->add_child(mesh_library_editor); diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 23f3087553..8aa8ba1f00 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -876,7 +876,7 @@ EditorNode3DGizmo::~EditorNode3DGizmo() { ///// void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color &p_color, bool p_billboard, bool p_on_top, bool p_use_vertex_color) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + Color instantiated_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instantiated"); Vector<Ref<StandardMaterial3D>> mats; @@ -918,7 +918,7 @@ void EditorNode3DGizmoPlugin::create_material(const String &p_name, const Color } void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top, const Color &p_albedo) { - Color instantiated_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instantiated", Color(0.7, 0.7, 0.7, 0.6)); + Color instantiated_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/instantiated"); Vector<Ref<StandardMaterial3D>> icons; @@ -2251,7 +2251,7 @@ void Position3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// PhysicalBone3DGizmoPlugin::PhysicalBone3DGizmoPlugin() { - create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1))); + create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint")); } bool PhysicalBone3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { @@ -2384,7 +2384,7 @@ void PhysicalBone3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ///// RayCast3DGizmoPlugin::RayCast3DGizmoPlugin() { - const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); @@ -2438,7 +2438,7 @@ void SpringArm3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } SpringArm3DGizmoPlugin::SpringArm3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); } @@ -2457,7 +2457,7 @@ int SpringArm3DGizmoPlugin::get_priority() const { ///// VehicleWheel3DGizmoPlugin::VehicleWheel3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); } @@ -2528,7 +2528,7 @@ void VehicleWheel3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { /////////// SoftDynamicBody3DGizmoPlugin::SoftDynamicBody3DGizmoPlugin() { - Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); create_handle_material("handles"); } @@ -3976,7 +3976,7 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// CollisionObject3DGizmoPlugin::CollisionObject3DGizmoPlugin() { - const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); @@ -4026,7 +4026,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { //// CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() { - const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); @@ -4627,7 +4627,7 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ///// CollisionPolygon3DGizmoPlugin::CollisionPolygon3DGizmoPlugin() { - const Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/shape", Color(0.5, 0.7, 1)); + const Color gizmo_color = EDITOR_GET("editors/3d_gizmos/gizmo_colors/shape"); create_material("shape_material", gizmo_color); const float gizmo_value = gizmo_color.get_v(); const Color gizmo_color_disabled = Color(gizmo_value, gizmo_value, gizmo_value, 0.65); @@ -5024,7 +5024,7 @@ void JointGizmosDrawer::draw_cone(const Transform3D &p_offset, const Basis &p_ba //// Joint3DGizmoPlugin::Joint3DGizmoPlugin() { - create_material("joint_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint", Color(0.5, 0.8, 1))); + create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint")); create_material("joint_body_a_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_a", Color(0.6, 0.8, 1))); create_material("joint_body_b_material", EDITOR_DEF("editors/3d_gizmos/gizmo_colors/joint_body_b", Color(0.6, 0.9, 1))); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 002c879cdc..3927aaa438 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -2037,14 +2037,16 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (ED_IS_SHORTCUT("spatial_editor/cancel_transform", p_event) && _edit.mode != TRANSFORM_NONE) { cancel_transform(); } - if (ED_IS_SHORTCUT("spatial_editor/instant_translate", p_event)) { - begin_transform(TRANSFORM_TRANSLATE, true); - } - if (ED_IS_SHORTCUT("spatial_editor/instant_rotate", p_event)) { - begin_transform(TRANSFORM_ROTATE, true); - } - if (ED_IS_SHORTCUT("spatial_editor/instant_scale", p_event)) { - begin_transform(TRANSFORM_SCALE, true); + if (!is_freelook_active()) { + if (ED_IS_SHORTCUT("spatial_editor/instant_translate", p_event)) { + begin_transform(TRANSFORM_TRANSLATE, true); + } + if (ED_IS_SHORTCUT("spatial_editor/instant_rotate", p_event)) { + begin_transform(TRANSFORM_ROTATE, true); + } + if (ED_IS_SHORTCUT("spatial_editor/instant_scale", p_event)) { + begin_transform(TRANSFORM_SCALE, true); + } } // Freelook doesn't work in orthogonal mode. @@ -2284,7 +2286,7 @@ void Node3DEditorViewport::scale_freelook_speed(real_t scale) { Point2i Node3DEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const { Point2i relative; - if (bool(EDITOR_DEF("editors/3d/navigation/warped_mouse_panning", false))) { + if (bool(EDITOR_GET("editors/3d/navigation/warped_mouse_panning"))) { relative = Input::get_singleton()->warp_mouse_motion(p_ev_mouse_motion, surface->get_global_rect()); } else { relative = p_ev_mouse_motion->get_relative(); @@ -6920,19 +6922,19 @@ void Node3DEditor::_add_environment_to_scene(bool p_already_added_sun) { } void Node3DEditor::_update_theme() { - tool_button[Node3DEditor::TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); - tool_button[Node3DEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); - - tool_option_button[Node3DEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); - tool_option_button[Node3DEditor::TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); - tool_option_button[Node3DEditor::TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_SELECT]->set_icon(get_theme_icon(SNAME("ToolSelect"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_MOVE]->set_icon(get_theme_icon(SNAME("ToolMove"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_ROTATE]->set_icon(get_theme_icon(SNAME("ToolRotate"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_SCALE]->set_icon(get_theme_icon(SNAME("ToolScale"), SNAME("EditorIcons"))); + tool_button[TOOL_MODE_LIST_SELECT]->set_icon(get_theme_icon(SNAME("ListSelect"), SNAME("EditorIcons"))); + tool_button[TOOL_LOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Lock"), SNAME("EditorIcons"))); + tool_button[TOOL_UNLOCK_SELECTED]->set_icon(get_theme_icon(SNAME("Unlock"), SNAME("EditorIcons"))); + tool_button[TOOL_GROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Group"), SNAME("EditorIcons"))); + tool_button[TOOL_UNGROUP_SELECTED]->set_icon(get_theme_icon(SNAME("Ungroup"), SNAME("EditorIcons"))); + + tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_icon(get_theme_icon(SNAME("Object"), SNAME("EditorIcons"))); + tool_option_button[TOOL_OPT_USE_SNAP]->set_icon(get_theme_icon(SNAME("Snap"), SNAME("EditorIcons"))); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_icon(get_theme_icon(SNAME("Camera3D"), SNAME("EditorIcons"))); view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT), get_theme_icon(SNAME("Panels1"), SNAME("EditorIcons"))); view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_2_VIEWPORTS), get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); diff --git a/editor/plugins/ot_features_plugin.cpp b/editor/plugins/ot_features_plugin.cpp index f8e6054848..9cd428a2d4 100644 --- a/editor/plugins/ot_features_plugin.cpp +++ b/editor/plugins/ot_features_plugin.cpp @@ -53,7 +53,7 @@ void OpenTypeFeaturesEditor::_notification(int p_what) { button->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))); button->set_size(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons"))->get_size()); - spin->set_custom_label_color(true, base); + spin->add_theme_color_override("label_color", base); } break; } } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index f096b2abb1..2812c4aaaf 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1062,7 +1062,7 @@ void Polygon2DEditor::_uv_draw() { for (int i = 0; i < uvs.size(); i++) { int next = uv_draw_max > 0 ? (i + 1) % uv_draw_max : 0; - if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_DEF("editors/polygon_editor/show_previous_outline", true)) { + if (i < uv_draw_max && uv_drag && uv_move_current == UV_MODE_EDIT_POINT && EDITOR_GET("editors/polygon_editor/show_previous_outline")) { uv_edit_draw->draw_line(mtx.xform(points_prev[i]), mtx.xform(points_prev[next]), prev_color, Math::round(EDSCALE)); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a4a2919034..d506a1f3ab 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -682,7 +682,7 @@ void ScriptEditor::_update_recent_scripts() { recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files"))); recent_scripts->set_item_disabled(recent_scripts->get_item_id(recent_scripts->get_item_count() - 1), rc.is_empty()); - recent_scripts->set_as_minsize(); + recent_scripts->reset_size(); } void ScriptEditor::_open_recent_script(int p_idx) { @@ -810,7 +810,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { } if (idx >= 0) { if (history_pos >= 0) { - idx = history[history_pos].control->get_index(); + idx = tab_container->get_tab_idx_from_control(history[history_pos].control); } tab_container->set_current_tab(idx); } else { @@ -1046,7 +1046,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) { bool need_ask = false; bool need_reload = false; - bool use_autoreload = bool(EDITOR_DEF("text_editor/behavior/files/auto_reload_scripts_on_external_change", false)); + bool use_autoreload = bool(EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change")); for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i)); @@ -1429,7 +1429,7 @@ void ScriptEditor::_menu_option(int p_option) { file_system_dock->navigate_to_path(path); // Ensure that the FileSystem dock is visible. TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(file_system_dock->get_index()); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); } } break; case CLOSE_DOCS: { @@ -1635,7 +1635,7 @@ void ScriptEditor::_notification(int p_what) { filename->add_theme_style_override("normal", EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox(SNAME("normal"), SNAME("LineEdit"))); - recent_scripts->set_as_minsize(); + recent_scripts->reset_size(); if (is_inside_tree()) { _update_script_colors(); @@ -2723,7 +2723,7 @@ void ScriptEditor::_editor_settings_changed() { _update_script_colors(); _update_script_names(); - ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save", true)); + ScriptServer::set_reload_scripts_on_save(EDITOR_GET("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save")); } void ScriptEditor::_filesystem_changed() { @@ -3125,7 +3125,7 @@ void ScriptEditor::_make_script_list_context_menu() { } void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { - if (!bool(EDITOR_DEF("text_editor/behavior/files/restore_scripts_on_load", true))) { + if (!bool(EDITOR_GET("text_editor/behavior/files/restore_scripts_on_load"))) { return; } @@ -3376,7 +3376,7 @@ void ScriptEditor::_update_history_pos(int p_new_pos) { } history_pos = p_new_pos; - tab_container->set_current_tab(history[history_pos].control->get_index()); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(history[history_pos].control)); n = history[history_pos].control; @@ -4039,7 +4039,7 @@ ScriptEditorPlugin::ScriptEditorPlugin() { script_editor->hide(); - EDITOR_DEF("text_editor/behavior/files/auto_reload_scripts_on_external_change", true); + EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change"); ScriptServer::set_reload_scripts_on_save(EDITOR_DEF("text_editor/behavior/files/auto_reload_and_parse_scripts_on_save", true)); EDITOR_DEF("text_editor/behavior/files/open_dominant_script_on_scene_change", true); EDITOR_DEF("text_editor/external/use_external_editor", false); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index b87f2995ed..3138801cdb 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -521,7 +521,7 @@ void ScriptTextEditor::_update_errors() { errors_panel->pop(); // Table CodeEdit *te = code_editor->get_text_editor(); - bool highlight_safe = EDITOR_DEF("text_editor/appearance/gutters/highlight_type_safe_lines", true); + bool highlight_safe = EDITOR_GET("text_editor/appearance/gutters/highlight_type_safe_lines"); bool last_is_safe = false; for (int i = 0; i < te->get_line_count(); i++) { if (errors.is_empty()) { diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index cea1a0e808..382138a995 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -520,7 +520,7 @@ void ShaderEditor::_check_for_external_edit() { return; } - bool use_autoreload = bool(EDITOR_DEF("text_editor/behavior/files/auto_reload_scripts_on_external_change", false)); + bool use_autoreload = bool(EDITOR_GET("text_editor/behavior/files/auto_reload_scripts_on_external_change")); if (shader->get_last_modified_time() != FileAccess::get_modified_time(shader->get_path())) { if (use_autoreload) { _reload_shader_from_disk(); diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 17fe4fdc50..a7c06ada5c 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -64,8 +64,8 @@ void TexturePreview::_update_metadata_label_text() { String format; if (Object::cast_to<ImageTexture>(*texture)) { format = Image::get_format_name(Object::cast_to<ImageTexture>(*texture)->get_format()); - } else if (Object::cast_to<StreamTexture2D>(*texture)) { - format = Image::get_format_name(Object::cast_to<StreamTexture2D>(*texture)->get_format()); + } else if (Object::cast_to<CompressedTexture2D>(*texture)) { + format = Image::get_format_name(Object::cast_to<CompressedTexture2D>(*texture)->get_format()); } else { format = texture->get_class(); } @@ -110,7 +110,7 @@ TexturePreview::TexturePreview(Ref<Texture2D> p_texture, bool p_show_metadata) { } bool EditorInspectorPluginTexture::can_handle(Object *p_object) { - return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<StreamTexture2D>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; + return Object::cast_to<ImageTexture>(p_object) != nullptr || Object::cast_to<AtlasTexture>(p_object) != nullptr || Object::cast_to<CompressedTexture2D>(p_object) != nullptr || Object::cast_to<AnimatedTexture>(p_object) != nullptr; } void EditorInspectorPluginTexture::parse_begin(Object *p_object) { diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 74e3372730..d313b98a7f 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -2077,7 +2077,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito List<String> ext; ResourceLoader::get_recognized_extensions_for_type("Theme", &ext); for (const String &E : ext) { - import_another_theme_dialog->add_filter("*." + E + "; Theme Resource"); + import_another_theme_dialog->add_filter(vformat("*.%s; %s", E, TTR("Theme Resource"))); } import_another_file_hb->add_child(import_another_theme_dialog); import_another_theme_dialog->connect("file_selected", callable_mp(this, &ThemeItemEditorDialog::_select_another_theme_cbk)); @@ -3664,7 +3664,7 @@ ThemeEditor::ThemeEditor() { List<String> ext; ResourceLoader::get_recognized_extensions_for_type("PackedScene", &ext); for (const String &E : ext) { - preview_scene_dialog->add_filter("*." + E + "; Scene"); + preview_scene_dialog->add_filter(vformat("*.%s; %s", E, TTR("Scene"))); } main_hs->add_child(preview_scene_dialog); preview_scene_dialog->connect("file_selected", callable_mp(this, &ThemeEditor::_preview_scene_dialog_cbk)); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index a821faf6b3..94906acb63 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -555,7 +555,7 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id) { } if (custom_editor) { - if (is_curve || (hb == nullptr && !vsnode->is_use_prop_slots() && vsnode->get_output_port_count() > 0 && vsnode->get_output_port_name(0) == "" && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == ""))) { + if (is_curve || (hb == nullptr && !vsnode->is_use_prop_slots() && (vsnode->get_output_port_count() == 0 || vsnode->get_output_port_name(0) == "") && (vsnode->get_input_port_count() == 0 || vsnode->get_input_port_name(0) == ""))) { //will be embedded in first port } else { port_offset++; @@ -1074,6 +1074,7 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { hide(); } else { if (changed) { // to avoid tree collapse + _update_varying_tree(); _update_options_menu(); _update_preview(); _update_graph(); @@ -1460,6 +1461,7 @@ void VisualShaderEditor::_set_mode(int p_which) { edit_type_fog->set_visible(false); edit_type = edit_type_sky; custom_mode_box->set_visible(false); + varying_button->hide(); mode = MODE_FLAGS_SKY; } else if (p_which == VisualShader::MODE_FOG) { edit_type_standard->set_visible(false); @@ -1468,6 +1470,7 @@ void VisualShaderEditor::_set_mode(int p_which) { edit_type_fog->set_visible(true); edit_type = edit_type_fog; custom_mode_box->set_visible(false); + varying_button->hide(); mode = MODE_FLAGS_FOG; } else if (p_which == VisualShader::MODE_PARTICLES) { edit_type_standard->set_visible(false); @@ -1480,6 +1483,7 @@ void VisualShaderEditor::_set_mode(int p_which) { } else { custom_mode_box->set_visible(true); } + varying_button->hide(); mode = MODE_FLAGS_PARTICLES; } else { edit_type_particles->set_visible(false); @@ -1488,6 +1492,7 @@ void VisualShaderEditor::_set_mode(int p_which) { edit_type_fog->set_visible(false); edit_type = edit_type_standard; custom_mode_box->set_visible(false); + varying_button->show(); mode = MODE_FLAGS_SPATIAL_CANVASITEM; } visual_shader->set_shader_type(get_current_shader_type()); @@ -1616,6 +1621,7 @@ void VisualShaderEditor::_update_graph() { Vector<int> nodes = visual_shader->get_node_list(type); _update_uniforms(false); + _update_varyings(); graph_plugin->clear_links(); graph_plugin->make_dirty(true); @@ -2778,6 +2784,116 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri } } +void VisualShaderEditor::_add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type) { + undo_redo->create_action(vformat(TTR("Add Varying to Visual Shader: %s"), p_name)); + + undo_redo->add_do_method(visual_shader.ptr(), "add_varying", p_name, p_mode, p_type); + undo_redo->add_undo_method(visual_shader.ptr(), "remove_varying", p_name); + + undo_redo->add_do_method(this, "_update_varyings"); + undo_redo->add_undo_method(this, "_update_varyings"); + + for (int i = 0; i <= VisualShader::TYPE_LIGHT; i++) { + if (p_mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { + continue; + } + + VisualShader::Type type = VisualShader::Type(i); + Vector<int> nodes = visual_shader->get_node_list(type); + + for (int j = 0; j < nodes.size(); j++) { + int node_id = nodes[j]; + Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, node_id); + Ref<VisualShaderNodeVarying> var = vsnode; + + if (var.is_valid()) { + undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, node_id); + undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, node_id); + } + } + } + + undo_redo->add_do_method(this, "_update_varying_tree"); + undo_redo->add_undo_method(this, "_update_varying_tree"); + undo_redo->commit_action(); +} + +void VisualShaderEditor::_remove_varying(const String &p_name) { + undo_redo->create_action(vformat(TTR("Remove Varying from Visual Shader: %s"), p_name)); + + VisualShader::VaryingMode mode = visual_shader->get_varying_mode(p_name); + + undo_redo->add_do_method(visual_shader.ptr(), "remove_varying", p_name); + undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", p_name, mode, visual_shader->get_varying_type(p_name)); + + undo_redo->add_do_method(this, "_update_varyings"); + undo_redo->add_undo_method(this, "_update_varyings"); + + for (int i = 0; i <= VisualShader::TYPE_LIGHT; i++) { + if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT && i == 0) { + continue; + } + + VisualShader::Type type = VisualShader::Type(i); + Vector<int> nodes = visual_shader->get_node_list(type); + + for (int j = 0; j < nodes.size(); j++) { + int node_id = nodes[j]; + Ref<VisualShaderNode> vsnode = visual_shader->get_node(type, node_id); + Ref<VisualShaderNodeVarying> var = vsnode; + + if (var.is_valid()) { + String var_name = var->get_varying_name(); + + if (var_name == p_name) { + undo_redo->add_do_method(var.ptr(), "set_varying_name", "[None]"); + undo_redo->add_undo_method(var.ptr(), "set_varying_name", var_name); + undo_redo->add_do_method(var.ptr(), "set_varying_type", VisualShader::VARYING_TYPE_FLOAT); + undo_redo->add_undo_method(var.ptr(), "set_varying_type", var->get_varying_type()); + } + undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type, node_id); + undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type, node_id); + } + } + + List<VisualShader::Connection> connections; + visual_shader->get_node_connections(type, &connections); + + for (VisualShader::Connection &E : connections) { + Ref<VisualShaderNodeVaryingGetter> var_getter = Object::cast_to<VisualShaderNodeVaryingGetter>(visual_shader->get_node(type, E.from_node).ptr()); + if (var_getter.is_valid() && E.from_port > 0) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + } + Ref<VisualShaderNodeVaryingSetter> var_setter = Object::cast_to<VisualShaderNodeVaryingSetter>(visual_shader->get_node(type, E.to_node).ptr()); + if (var_setter.is_valid() && E.to_port > 0) { + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + } + } + } + + undo_redo->add_do_method(this, "_update_varying_tree"); + undo_redo->add_undo_method(this, "_update_varying_tree"); + undo_redo->commit_action(); +} + +void VisualShaderEditor::_update_varyings() { + VisualShaderNodeVarying::clear_varyings(); + + for (int i = 0; i < visual_shader->get_varyings_count(); i++) { + const VisualShader::Varying *var = visual_shader->get_varying_by_index(i); + + if (var != nullptr) { + VisualShaderNodeVarying::add_varying(var->name, var->mode, var->type); + } + } +} + void VisualShaderEditor::_node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node) { VisualShader::Type type = get_current_shader_type(); drag_buffer.push_back({ type, p_node, p_from, p_to }); @@ -3364,6 +3480,49 @@ void VisualShaderEditor::_show_members_dialog(bool at_mouse_pos, VisualShaderNod node_filter->select_all(); } +void VisualShaderEditor::_show_varying_menu() { + varying_options->set_item_disabled(int(VaryingMenuOptions::REMOVE), visual_shader->get_varyings_count() == 0); + varying_options->set_position(graph->get_screen_position() + varying_button->get_position() + Size2(0, varying_button->get_size().height)); + varying_options->popup(); +} + +void VisualShaderEditor::_varying_menu_id_pressed(int p_idx) { + switch (VaryingMenuOptions(p_idx)) { + case VaryingMenuOptions::ADD: { + _show_add_varying_dialog(); + } break; + case VaryingMenuOptions::REMOVE: { + _show_remove_varying_dialog(); + } break; + default: + break; + } +} + +void VisualShaderEditor::_show_add_varying_dialog() { + _varying_name_changed(varying_name->get_text()); + + add_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE)); + add_varying_dialog->popup(); + + // Keep dialog within window bounds. + Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size()); + Rect2 dialog_rect = Rect2(add_varying_dialog->get_position(), add_varying_dialog->get_size()); + Vector2 difference = (dialog_rect.get_end() - window_rect.get_end()).max(Vector2()); + add_varying_dialog->set_position(add_varying_dialog->get_position() - difference); +} + +void VisualShaderEditor::_show_remove_varying_dialog() { + remove_varying_dialog->set_position(graph->get_screen_position() + varying_button->get_position() + Point2(5 * EDSCALE, 65 * EDSCALE)); + remove_varying_dialog->popup(); + + // Keep dialog within window bounds. + Rect2 window_rect = Rect2(DisplayServer::get_singleton()->window_get_position(), DisplayServer::get_singleton()->window_get_size()); + Rect2 dialog_rect = Rect2(remove_varying_dialog->get_position(), remove_varying_dialog->get_size()); + Vector2 difference = (dialog_rect.get_end() - window_rect.get_end()).max(Vector2()); + remove_varying_dialog->set_position(remove_varying_dialog->get_position() - difference); +} + void VisualShaderEditor::_sbox_input(const Ref<InputEvent> &p_ie) { Ref<InputEventKey> ie = p_ie; if (ie.is_valid() && (ie->get_keycode() == Key::UP || ie->get_keycode() == Key::DOWN || ie->get_keycode() == Key::ENTER || ie->get_keycode() == Key::KP_ENTER)) { @@ -3416,8 +3575,10 @@ void VisualShaderEditor::_notification(int p_what) { Color function_color = EDITOR_GET("text_editor/theme/highlighting/function_color"); Color number_color = EDITOR_GET("text_editor/theme/highlighting/number_color"); Color members_color = EDITOR_GET("text_editor/theme/highlighting/member_variable_color"); + Color error_color = get_theme_color(SNAME("error_color"), SNAME("Editor")); preview_text->add_theme_color_override("background_color", background_color); + varying_error_label->add_theme_color_override("font_color", error_color); for (const String &E : keyword_list) { if (ShaderLanguage::is_control_flow_keyword(E)) { @@ -3445,7 +3606,7 @@ void VisualShaderEditor::_notification(int p_what) { error_panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("Panel"))); error_label->add_theme_font_override("font", get_theme_font(SNAME("status_source"), SNAME("EditorFonts"))); error_label->add_theme_font_size_override("font_size", get_theme_font_size(SNAME("status_source_size"), SNAME("EditorFonts"))); - error_label->add_theme_color_override("font_color", get_theme_color(SNAME("error_color"), SNAME("Editor"))); + error_label->add_theme_color_override("font_color", error_color); } tools->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Tools"), SNAME("EditorIcons"))); @@ -3828,6 +3989,75 @@ void VisualShaderEditor::_uniform_select_item(Ref<VisualShaderNodeUniformRef> p_ undo_redo->commit_action(); } +void VisualShaderEditor::_varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name) { + String prev_name = p_varying->get_varying_name(); + + if (p_name == prev_name) { + return; + } + + bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); + + UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); + undo_redo->create_action(TTR("Varying Name Changed")); + + undo_redo->add_do_method(p_varying.ptr(), "set_varying_name", p_name); + undo_redo->add_undo_method(p_varying.ptr(), "set_varying_name", prev_name); + + VisualShader::VaryingType vtype = p_varying->get_varying_type_by_name(p_name); + VisualShader::VaryingType prev_vtype = p_varying->get_varying_type_by_name(prev_name); + + bool type_changed = vtype != prev_vtype; + + if (type_changed) { + undo_redo->add_do_method(p_varying.ptr(), "set_varying_type", vtype); + undo_redo->add_undo_method(p_varying.ptr(), "set_varying_type", prev_vtype); + } + + // update ports + for (int type_id = 0; type_id < VisualShader::TYPE_MAX; type_id++) { + VisualShader::Type type = VisualShader::Type(type_id); + int id = visual_shader->find_node_id(type, p_varying); + + if (id != VisualShader::NODE_ID_INVALID) { + if (type_changed) { + List<VisualShader::Connection> conns; + visual_shader->get_node_connections(type, &conns); + + for (const VisualShader::Connection &E : conns) { + if (is_getter) { + if (E.from_node == id) { + if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.to_node)->get_input_port_type(E.to_port))) { + continue; + } + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + } + } else { + if (E.to_node == id) { + if (visual_shader->is_port_types_compatible(p_varying->get_varying_type_by_name(p_name), visual_shader->get_node(type, E.from_node)->get_output_port_type(E.from_port))) { + continue; + } + undo_redo->add_do_method(visual_shader.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(visual_shader.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_do_method(graph_plugin.ptr(), "disconnect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + undo_redo->add_undo_method(graph_plugin.ptr(), "connect_nodes", type, E.from_node, E.from_port, E.to_node, E.to_port); + } + } + } + } + + undo_redo->add_do_method(graph_plugin.ptr(), "update_node", type_id, id); + undo_redo->add_undo_method(graph_plugin.ptr(), "update_node", type_id, id); + break; + } + } + + undo_redo->commit_action(); +} + void VisualShaderEditor::_float_constant_selected(int p_which) { ERR_FAIL_INDEX(p_which, MAX_FLOAT_CONST_DEFS); @@ -3882,6 +4112,92 @@ void VisualShaderEditor::_member_cancel() { from_slot = -1; } +void VisualShaderEditor::_update_varying_tree() { + varyings->clear(); + TreeItem *root = varyings->create_item(); + + int count = visual_shader->get_varyings_count(); + + for (int i = 0; i < count; i++) { + const VisualShader::Varying *varying = visual_shader->get_varying_by_index(i); + + if (varying) { + TreeItem *item = varyings->create_item(root); + item->set_text(0, varying->name); + + if (i == 0) { + item->select(0); + } + + switch (varying->type) { + case VisualShader::VARYING_TYPE_FLOAT: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons"))); + break; + case VisualShader::VARYING_TYPE_VECTOR_2D: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons"))); + break; + case VisualShader::VARYING_TYPE_VECTOR_3D: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons"))); + break; + case VisualShader::VARYING_TYPE_COLOR: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons"))); + break; + case VisualShader::VARYING_TYPE_TRANSFORM: + item->set_icon(0, EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons"))); + break; + default: + break; + } + } + } + + varying_options->set_item_disabled(int(VaryingMenuOptions::REMOVE), count == 0); +} + +void VisualShaderEditor::_varying_create() { + _add_varying(varying_name->get_text(), (VisualShader::VaryingMode)varying_mode->get_selected(), (VisualShader::VaryingType)varying_type->get_selected()); + add_varying_dialog->hide(); +} + +void VisualShaderEditor::_varying_name_changed(const String &p_text) { + String name = p_text; + + if (!name.is_valid_identifier()) { + varying_error_label->show(); + varying_error_label->set_text(TTR("Invalid name for varying.")); + add_varying_dialog->get_ok_button()->set_disabled(true); + return; + } + if (visual_shader->has_varying(name)) { + varying_error_label->show(); + varying_error_label->set_text(TTR("Varying with that name is already exist.")); + add_varying_dialog->get_ok_button()->set_disabled(true); + return; + } + if (varying_error_label->is_visible()) { + varying_error_label->hide(); + add_varying_dialog->set_size(Size2(add_varying_dialog->get_size().x, 0)); + } + add_varying_dialog->get_ok_button()->set_disabled(false); +} + +void VisualShaderEditor::_varying_deleted() { + TreeItem *item = varyings->get_selected(); + + if (item != nullptr) { + _remove_varying(item->get_text(0)); + remove_varying_dialog->hide(); + } +} + +void VisualShaderEditor::_varying_selected() { + add_varying_dialog->get_ok_button()->set_disabled(false); +} + +void VisualShaderEditor::_varying_unselected() { + add_varying_dialog->get_ok_button()->set_disabled(true); +} + void VisualShaderEditor::_tools_menu_option(int p_idx) { TreeItem *category = members->get_root()->get_first_child(); @@ -4155,9 +4471,12 @@ void VisualShaderEditor::_bind_methods() { ClassDB::bind_method("_node_changed", &VisualShaderEditor::_node_changed); ClassDB::bind_method("_input_select_item", &VisualShaderEditor::_input_select_item); ClassDB::bind_method("_uniform_select_item", &VisualShaderEditor::_uniform_select_item); + ClassDB::bind_method("_varying_select_item", &VisualShaderEditor::_varying_select_item); ClassDB::bind_method("_set_node_size", &VisualShaderEditor::_set_node_size); ClassDB::bind_method("_clear_copy_buffer", &VisualShaderEditor::_clear_copy_buffer); ClassDB::bind_method("_update_uniforms", &VisualShaderEditor::_update_uniforms); + ClassDB::bind_method("_update_varyings", &VisualShaderEditor::_update_varyings); + ClassDB::bind_method("_update_varying_tree", &VisualShaderEditor::_update_varying_tree); ClassDB::bind_method("_set_mode", &VisualShaderEditor::_set_mode); ClassDB::bind_method("_nodes_dragged", &VisualShaderEditor::_nodes_dragged); ClassDB::bind_method("_float_constant_selected", &VisualShaderEditor::_float_constant_selected); @@ -4284,11 +4603,23 @@ VisualShaderEditor::VisualShaderEditor() { add_node = memnew(Button); add_node->set_flat(true); - graph->get_zoom_hbox()->add_child(add_node); add_node->set_text(TTR("Add Node...")); + graph->get_zoom_hbox()->add_child(add_node); graph->get_zoom_hbox()->move_child(add_node, 0); add_node->connect("pressed", callable_mp(this, &VisualShaderEditor::_show_members_dialog), varray(false, VisualShaderNode::PORT_TYPE_MAX, VisualShaderNode::PORT_TYPE_MAX)); + varying_button = memnew(Button); + varying_button->set_flat(true); + varying_button->set_text(TTR("Manage Varyings")); + graph->get_zoom_hbox()->add_child(varying_button); + varying_button->connect("pressed", callable_mp(this, &VisualShaderEditor::_show_varying_menu)); + + varying_options = memnew(PopupMenu); + add_child(varying_options); + varying_options->add_item(TTR("Add Varying"), int(VaryingMenuOptions::ADD)); + varying_options->add_item(TTR("Remove Varying"), int(VaryingMenuOptions::REMOVE)); + varying_options->connect("id_pressed", callable_mp(this, &VisualShaderEditor::_varying_menu_id_pressed)); + preview_shader = memnew(Button); preview_shader->set_flat(true); preview_shader->set_toggle_mode(true); @@ -4412,6 +4743,74 @@ VisualShaderEditor::VisualShaderEditor() { members_dialog->connect("cancelled", callable_mp(this, &VisualShaderEditor::_member_cancel)); add_child(members_dialog); + // add varyings dialog + { + add_varying_dialog = memnew(ConfirmationDialog); + add_varying_dialog->set_title(TTR("Create Shader Varying")); + add_varying_dialog->set_exclusive(false); + add_varying_dialog->get_ok_button()->set_text(TTR("Create")); + add_varying_dialog->get_ok_button()->connect("pressed", callable_mp(this, &VisualShaderEditor::_varying_create)); + add_varying_dialog->get_ok_button()->set_disabled(true); + add_child(add_varying_dialog); + + VBoxContainer *vb = memnew(VBoxContainer); + add_varying_dialog->add_child(vb); + + HBoxContainer *hb = memnew(HBoxContainer); + vb->add_child(hb); + hb->set_h_size_flags(SIZE_EXPAND_FILL); + + varying_type = memnew(OptionButton); + hb->add_child(varying_type); + varying_type->add_item("Float"); + varying_type->add_item("Vector2"); + varying_type->add_item("Vector3"); + varying_type->add_item("Color"); + varying_type->add_item("Transform"); + + varying_name = memnew(LineEdit); + hb->add_child(varying_name); + varying_name->set_custom_minimum_size(Size2(150 * EDSCALE, 0)); + varying_name->set_h_size_flags(SIZE_EXPAND_FILL); + varying_name->connect("text_changed", callable_mp(this, &VisualShaderEditor::_varying_name_changed)); + + varying_mode = memnew(OptionButton); + hb->add_child(varying_mode); + varying_mode->add_item("Vertex -> [Fragment, Light]"); + varying_mode->add_item("Fragment -> Light"); + + varying_error_label = memnew(Label); + vb->add_child(varying_error_label); + varying_error_label->set_h_size_flags(SIZE_EXPAND_FILL); + + varying_error_label->hide(); + } + + // remove varying dialog + { + remove_varying_dialog = memnew(ConfirmationDialog); + remove_varying_dialog->set_title(TTR("Delete Shader Varying")); + remove_varying_dialog->set_exclusive(false); + remove_varying_dialog->get_ok_button()->set_text(TTR("Delete")); + remove_varying_dialog->get_ok_button()->connect("pressed", callable_mp(this, &VisualShaderEditor::_varying_deleted)); + add_child(remove_varying_dialog); + + VBoxContainer *vb = memnew(VBoxContainer); + remove_varying_dialog->add_child(vb); + + varyings = memnew(Tree); + vb->add_child(varyings); + varyings->set_h_size_flags(SIZE_EXPAND_FILL); + varyings->set_v_size_flags(SIZE_EXPAND_FILL); + varyings->set_hide_root(true); + varyings->set_allow_reselect(true); + varyings->set_hide_folding(false); + varyings->set_custom_minimum_size(Size2(180 * EDSCALE, 200 * EDSCALE)); + varyings->connect("item_activated", callable_mp(this, &VisualShaderEditor::_varying_deleted)); + varyings->connect("item_selected", callable_mp(this, &VisualShaderEditor::_varying_selected)); + varyings->connect("nothing_selected", callable_mp(this, &VisualShaderEditor::_varying_unselected)); + } + alert = memnew(AcceptDialog); alert->get_label()->set_autowrap_mode(Label::AUTOWRAP_WORD); alert->get_label()->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER); @@ -4578,6 +4977,10 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), { "point_size" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Tangent", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "tangent"), { "tangent" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("VertexId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex_id"), { "vertex_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewIndex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewMonoLeft", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewRight", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Alpha", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "alpha"), { "alpha" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Binormal", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "binormal"), { "binormal" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); @@ -4591,6 +4994,9 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Tangent", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "tangent"), { "tangent" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Vertex", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("View", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), { "view" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewIndex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewMonoLeft", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ViewRight", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Albedo", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "albedo"), { "albedo" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Attenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "attenuation"), { "attenuation" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); @@ -4601,6 +5007,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("LightColor", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "light_color"), { "light_color" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Metallic", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "metallic"), { "metallic" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Roughness", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "roughness"), { "roughness" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("ShadowAttenuation", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "shadow_attenuation"), { "shadow_attenuation" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("Specular", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_light_shader_mode, "specular"), { "specular" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); add_options.push_back(AddOption("View", "Input", "Light", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view"), { "view" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); @@ -4610,9 +5017,11 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Canvas", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "canvas"), { "canvas" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("InstanceCustom", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom"), { "instance_custom" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("InstanceCustomAlpha", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_custom_alpha"), { "instance_custom_alpha" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("InstanceId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "instance_id"), { "instance_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("PointSize", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "point_size"), { "point_size" }, VisualShaderNode::PORT_TYPE_SCALAR, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("Screen", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "screen"), { "screen" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("Vertex", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_mode, "vertex"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_2D, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("VertexId", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "vertex_id"), { "vertex_id" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("World", "Input", "Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_shader_mode, "world"), { "world" }, VisualShaderNode::PORT_TYPE_TRANSFORM, TYPE_FLAGS_VERTEX, Shader::MODE_CANVAS_ITEM)); add_options.push_back(AddOption("AtLightPass", "Input", "Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "at_light_pass"), { "at_light_pass" }, VisualShaderNode::PORT_TYPE_BOOLEAN, TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM)); @@ -4989,6 +5398,10 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("Expression", "Special", "", "VisualShaderNodeExpression", TTR("Custom Godot Shader Language expression, with custom amount of input and output ports. This is a direct injection of code into the vertex/fragment/light function, do not use it to write the function declarations inside."))); add_options.push_back(AddOption("GlobalExpression", "Special", "", "VisualShaderNodeGlobalExpression", TTR("Custom Godot Shader Language expression, which is placed on top of the resulted shader. You can place various function definitions inside and call it later in the Expressions. You can also declare varyings, uniforms and constants."))); add_options.push_back(AddOption("UniformRef", "Special", "", "VisualShaderNodeUniformRef", TTR("A reference to an existing uniform."))); + add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("VaryingSetter", "Special", "", "VisualShaderNodeVaryingSetter", TTR("Set varying parameter."), {}, -1, TYPE_FLAGS_VERTEX | TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL)); + add_options.push_back(AddOption("VaryingGetter", "Special", "", "VisualShaderNodeVaryingGetter", TTR("Get varying parameter."), {}, -1, TYPE_FLAGS_FRAGMENT | TYPE_FLAGS_LIGHT, Shader::MODE_CANVAS_ITEM)); + add_options.push_back(AddOption("VaryingSetter", "Special", "", "VisualShaderNodeVaryingSetter", TTR("Set varying parameter."), {}, -1, TYPE_FLAGS_VERTEX | TYPE_FLAGS_FRAGMENT, Shader::MODE_CANVAS_ITEM)); custom_node_option_idx = add_options.size(); @@ -5102,6 +5515,82 @@ public: //////////////// +class VisualShaderNodePluginVaryingEditor : public OptionButton { + GDCLASS(VisualShaderNodePluginVaryingEditor, OptionButton); + + Ref<VisualShaderNodeVarying> varying; + +public: + void _notification(int p_what) { + if (p_what == NOTIFICATION_READY) { + connect("item_selected", callable_mp(this, &VisualShaderNodePluginVaryingEditor::_item_selected)); + } + } + + void _item_selected(int p_item) { + VisualShaderEditor *editor = VisualShaderEditor::get_singleton(); + if (editor) { + editor->call_deferred(SNAME("_varying_select_item"), varying, get_item_text(p_item)); + } + } + + void setup(const Ref<VisualShaderNodeVarying> &p_varying, VisualShader::Type p_type) { + varying = p_varying; + + Ref<Texture2D> type_icon[] = { + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("float"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector2"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Vector3"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Color"), SNAME("EditorIcons")), + EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Transform3D"), SNAME("EditorIcons")), + }; + + bool is_getter = Ref<VisualShaderNodeVaryingGetter>(p_varying.ptr()).is_valid(); + + add_item("[None]"); + + int to_select = -1; + for (int i = 0, j = 0; i < varying->get_varyings_count(); i++) { + VisualShader::VaryingMode mode = varying->get_varying_mode_by_index(i); + if (is_getter) { + if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT) { + if (p_type != VisualShader::TYPE_LIGHT) { + j++; + continue; + } + } else { + if (p_type != VisualShader::TYPE_FRAGMENT && p_type != VisualShader::TYPE_LIGHT) { + j++; + continue; + } + } + } else { + if (mode == VisualShader::VARYING_MODE_FRAG_TO_LIGHT) { + if (p_type != VisualShader::TYPE_FRAGMENT) { + j++; + continue; + } + } else { + if (p_type != VisualShader::TYPE_VERTEX) { + j++; + continue; + } + } + } + if (varying->get_varying_name() == varying->get_varying_name_by_index(i)) { + to_select = i - j + 1; + } + add_icon_item(type_icon[varying->get_varying_type_by_index(i)], varying->get_varying_name_by_index(i)); + } + + if (to_select >= 0) { + select(to_select); + } + } +}; + +//////////////// + class VisualShaderNodePluginUniformRefEditor : public OptionButton { GDCLASS(VisualShaderNodePluginUniformRefEditor, OptionButton); @@ -5280,18 +5769,24 @@ public: }; Control *VisualShaderNodePluginDefault::create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node) { + Ref<VisualShader> p_shader = Ref<VisualShader>(p_parent_resource.ptr()); + + if (p_shader.is_valid() && (p_node->is_class("VisualShaderNodeVaryingGetter") || p_node->is_class("VisualShaderNodeVaryingSetter"))) { + VisualShaderNodePluginVaryingEditor *editor = memnew(VisualShaderNodePluginVaryingEditor); + editor->setup(p_node, p_shader->get_shader_type()); + return editor; + } + if (p_node->is_class("VisualShaderNodeUniformRef")) { - //create input - VisualShaderNodePluginUniformRefEditor *uniform_editor = memnew(VisualShaderNodePluginUniformRefEditor); - uniform_editor->setup(p_node); - return uniform_editor; + VisualShaderNodePluginUniformRefEditor *editor = memnew(VisualShaderNodePluginUniformRefEditor); + editor->setup(p_node); + return editor; } if (p_node->is_class("VisualShaderNodeInput")) { - //create input - VisualShaderNodePluginInputEditor *input_editor = memnew(VisualShaderNodePluginInputEditor); - input_editor->setup(p_node); - return input_editor; + VisualShaderNodePluginInputEditor *editor = memnew(VisualShaderNodePluginInputEditor); + editor->setup(p_node); + return editor; } Vector<StringName> properties = p_node->get_editable_properties(); @@ -5408,6 +5903,22 @@ void EditorPropertyShaderMode::_option_selected(int p_which) { } } + //4. delete varyings (if needed) + if (p_which == VisualShader::MODE_PARTICLES || p_which == VisualShader::MODE_SKY || p_which == VisualShader::MODE_FOG) { + int var_count = visual_shader->get_varyings_count(); + + if (var_count > 0) { + for (int i = 0; i < var_count; i++) { + const VisualShader::Varying *var = visual_shader->get_varying_by_index(i); + undo_redo->add_do_method(visual_shader.ptr(), "remove_varying", var->name); + undo_redo->add_undo_method(visual_shader.ptr(), "add_varying", var->name, var->mode, var->type); + } + + undo_redo->add_do_method(editor, "_update_varyings"); + undo_redo->add_undo_method(editor, "_update_varyings"); + } + } + undo_redo->add_do_method(editor, "_update_options_menu"); undo_redo->add_undo_method(editor, "_update_options_menu"); diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h index 02beba971b..e26b606397 100644 --- a/editor/plugins/visual_shader_editor_plugin.h +++ b/editor/plugins/visual_shader_editor_plugin.h @@ -139,6 +139,8 @@ class VisualShaderEditor : public VBoxContainer { Ref<VisualShader> visual_shader; GraphEdit *graph = nullptr; Button *add_node = nullptr; + Button *varying_button = nullptr; + PopupMenu *varying_options = nullptr; Button *preview_shader = nullptr; OptionButton *edit_type = nullptr; @@ -169,6 +171,15 @@ class VisualShaderEditor : public VBoxContainer { PopupMenu *constants_submenu = nullptr; MenuButton *tools = nullptr; + ConfirmationDialog *add_varying_dialog = nullptr; + OptionButton *varying_type = nullptr; + LineEdit *varying_name = nullptr; + OptionButton *varying_mode = nullptr; + Label *varying_error_label = nullptr; + + ConfirmationDialog *remove_varying_dialog = nullptr; + Tree *varyings = nullptr; + PopupPanel *comment_title_change_popup = nullptr; LineEdit *comment_title_change_edit = nullptr; @@ -232,6 +243,11 @@ class VisualShaderEditor : public VBoxContainer { SET_COMMENT_DESCRIPTION, }; + enum class VaryingMenuOptions { + ADD, + REMOVE, + }; + Tree *members = nullptr; AcceptDialog *alert = nullptr; LineEdit *node_filter = nullptr; @@ -241,6 +257,11 @@ class VisualShaderEditor : public VBoxContainer { void _tools_menu_option(int p_idx); void _show_members_dialog(bool at_mouse_pos, VisualShaderNode::PortType p_input_port_type = VisualShaderNode::PORT_TYPE_MAX, VisualShaderNode::PortType p_output_port_type = VisualShaderNode::PORT_TYPE_MAX); + void _show_varying_menu(); + void _varying_menu_id_pressed(int p_idx); + void _show_add_varying_dialog(); + void _show_remove_varying_dialog(); + void _update_graph(); struct AddOption { @@ -291,6 +312,8 @@ class VisualShaderEditor : public VBoxContainer { void _setup_node(VisualShaderNode *p_node, const Vector<Variant> &p_ops); void _add_node(int p_idx, const Vector<Variant> &p_ops, String p_resource_path = "", int p_node_idx = -1); + void _add_varying(const String &p_name, VisualShader::VaryingMode p_mode, VisualShader::VaryingType p_type); + void _remove_varying(const String &p_name); void _update_options_menu(); void _set_mode(int p_which); @@ -394,6 +417,7 @@ class VisualShaderEditor : public VBoxContainer { void _input_select_item(Ref<VisualShaderNodeInput> input, String name); void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name); + void _varying_select_item(Ref<VisualShaderNodeVarying> p_varying, String p_name); void _float_constant_selected(int p_which); @@ -425,6 +449,13 @@ class VisualShaderEditor : public VBoxContainer { void _member_create(); void _member_cancel(); + void _varying_create(); + void _varying_name_changed(const String &p_text); + void _varying_deleted(); + void _varying_selected(); + void _varying_unselected(); + void _update_varying_tree(); + Vector2 menu_point; void _node_menu_id_pressed(int p_idx); @@ -436,6 +467,7 @@ class VisualShaderEditor : public VBoxContainer { void _update_created_node(GraphNode *node); void _update_uniforms(bool p_update_refs); void _update_uniform_refs(Set<String> &p_names); + void _update_varyings(); void _visibility_changed(); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 1a111bcbfc..17db955cc7 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -883,7 +883,8 @@ void ProjectExportDialog::_export_project() { List<String> extension_list = platform->get_binary_extensions(current); for (int i = 0; i < extension_list.size(); i++) { - export_project->add_filter("*." + extension_list[i] + " ; " + platform->get_name() + " Export"); + // TRANSLATORS: This is the name of a project export file format. %s will be replaced by the platform name. + export_project->add_filter(vformat("*.%s; %s", extension_list[i], vformat(TTR("%s Export"), platform->get_name()))); } if (!current->get_export_path().is_empty()) { diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 79aed36eeb..78f6fe58d0 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1057,6 +1057,8 @@ public: } }; + bool project_opening_initiated; + ProjectList(); ~ProjectList(); @@ -1136,6 +1138,7 @@ ProjectList::ProjectList() { add_child(_scroll_children); _icon_load_index = 0; + project_opening_initiated = false; } ProjectList::~ProjectList() { @@ -1818,7 +1821,9 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { emit_signal(SNAME(SIGNAL_SELECTION_CHANGED)); - if (!mb->is_ctrl_pressed() && mb->is_double_click()) { + // Do not allow opening a project more than once using a single project manager instance. + // Opening the same project in several editor instances at once can lead to various issues. + if (!mb->is_ctrl_pressed() && mb->is_double_click() && !project_opening_initiated) { emit_signal(SNAME(SIGNAL_PROJECT_ASK_OPEN)); } } @@ -2140,6 +2145,8 @@ void ProjectManager::_open_selected_projects() { ERR_FAIL_COND(err); } + _project_list->project_opening_initiated = true; + _dim_window(); get_tree()->quit(); } diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 4d708dc7e0..7059509e72 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -63,7 +63,7 @@ void ProjectSettingsEditor::queue_save() { } void ProjectSettingsEditor::set_plugins_page() { - tab_container->set_current_tab(plugin_settings->get_index()); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(plugin_settings)); } void ProjectSettingsEditor::update_plugins() { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index cd65ee7ae6..0282504c70 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -228,7 +228,7 @@ void CustomPropertyEditor::_menu_option(int p_which) { file_system_dock->navigate_to_path(r->get_path()); // Ensure that the FileSystem dock is visible. TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(file_system_dock->get_index()); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); } break; default: { if (p_which >= CONVERT_BASE_ID) { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 628e7880a1..571b87a0aa 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1535,7 +1535,7 @@ void SceneTreeDock::perform_node_renames(Node *p_base, Map<Node *, NodePath> *p_ } } - bool autorename_animation_tracks = bool(EDITOR_DEF("editors/animation/autorename_animation_tracks", true)); + bool autorename_animation_tracks = bool(EDITOR_GET("editors/animation/autorename_animation_tracks")); if (autorename_animation_tracks && Object::cast_to<AnimationPlayer>(p_base)) { AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_base); diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index ba65828ac1..c6a8a928db 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -135,7 +135,8 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i set_selected(n); - NodeDock::get_singleton()->get_parent()->call("set_current_tab", NodeDock::get_singleton()->get_index()); + TabContainer *tab_container = Object::cast_to<TabContainer>(NodeDock::get_singleton()->get_parent()); + NodeDock::get_singleton()->get_parent()->call("set_current_tab", tab_container->get_tab_idx_from_control(NodeDock::get_singleton())); NodeDock::get_singleton()->show_connections(); } else if (p_id == BUTTON_GROUPS) { @@ -144,7 +145,8 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_i set_selected(n); - NodeDock::get_singleton()->get_parent()->call("set_current_tab", NodeDock::get_singleton()->get_index()); + TabContainer *tab_container = Object::cast_to<TabContainer>(NodeDock::get_singleton()->get_parent()); + NodeDock::get_singleton()->get_parent()->call("set_current_tab", tab_container->get_tab_idx_from_control(NodeDock::get_singleton())); NodeDock::get_singleton()->show_groups(); } } |