This commit is contained in:
Spartan322
2025-08-13 19:56:49 -04:00
419 changed files with 812199 additions and 295836 deletions

View File

@@ -268,7 +268,7 @@ void ShaderEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
}
_update_shader_list();
_shader_selected(selected_shader_idx);
_shader_selected(selected_shader_idx, false);
_set_text_shader_zoom_factor(p_layout->get_value("ShaderEditor", "text_shader_zoom_factor", 1.0f));
}
@@ -372,7 +372,7 @@ void ShaderEditorPlugin::apply_changes() {
}
}
void ShaderEditorPlugin::_shader_selected(int p_index) {
void ShaderEditorPlugin::_shader_selected(int p_index, bool p_push_item) {
if (p_index >= (int)edited_shaders.size()) {
return;
}
@@ -385,11 +385,13 @@ void ShaderEditorPlugin::_shader_selected(int p_index) {
shader_tabs->set_current_tab(p_index);
shader_list->select(p_index);
// Avoid `Shader` being edited when editing `ShaderInclude` due to inspector refreshing.
if (edited_shaders[p_index].shader.is_valid()) {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader.ptr());
} else {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader_inc.ptr());
if (p_push_item) {
// Avoid `Shader` being edited when editing `ShaderInclude` due to inspector refreshing.
if (edited_shaders[p_index].shader.is_valid()) {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader.ptr());
} else {
EditorNode::get_singleton()->push_item_no_inspector(edited_shaders[p_index].shader_inc.ptr());
}
}
}
@@ -635,14 +637,16 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
shader_list->set_visible(!shader_list->is_visible());
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
TextShaderEditor *editor = Object::cast_to<TextShaderEditor>(edited_shaders[index].shader_editor);
if (editor) {
editor->get_code_editor()->update_toggle_files_button();
} else {
VisualShaderEditor *vs_editor = Object::cast_to<VisualShaderEditor>(edited_shaders[index].shader_editor);
if (vs_editor) {
vs_editor->update_toggle_files_button();
if (index != -1) {
ERR_FAIL_INDEX(index, (int)edited_shaders.size());
TextShaderEditor *editor = Object::cast_to<TextShaderEditor>(edited_shaders[index].shader_editor);
if (editor) {
editor->get_code_editor()->update_toggle_files_button();
} else {
VisualShaderEditor *vs_editor = Object::cast_to<VisualShaderEditor>(edited_shaders[index].shader_editor);
if (vs_editor) {
vs_editor->update_toggle_files_button();
}
}
}
} break;
@@ -798,6 +802,7 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
VisualShaderEditor *vs_editor = Object::cast_to<VisualShaderEditor>(p_editor);
if (vs_editor) {
file_menu->get_parent()->remove_child(file_menu);
file_menu->set_switch_on_hover(false);
bar->add_child(file_menu);
bar->move_child(file_menu, 2); // Toggle Files Panel button + separator.
@@ -811,6 +816,7 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
// Just swapped from a visual shader editor.
if (file_menu->get_parent() != menu_hb) {
file_menu->get_parent()->remove_child(file_menu);
file_menu->set_switch_on_hover(true);
menu_hb->add_child(file_menu);
menu_hb->move_child(file_menu, 0);
@@ -902,6 +908,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
main_container->add_child(menu_hb);
file_menu = memnew(MenuButton);
file_menu->set_text(TTR("File"));
file_menu->set_switch_on_hover(true);
file_menu->set_shortcut_context(files_split);
_setup_popup_menu(FILE, file_menu->get_popup());
file_menu->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &ShaderEditorPlugin::_menu_item_pressed));
@@ -932,7 +939,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
shader_list->set_theme_type_variation("ItemListSecondary");
shader_list->set_custom_minimum_size(Size2(100, 60) * EDSCALE);
files_split->add_child(shader_list);
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected));
shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected).bind(true));
shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked));
shader_list->set_allow_rmb_select(true);
SET_DRAG_FORWARDING_GCD(shader_list, ShaderEditorPlugin);