Преглед изворни кода

Fixed shader editor when no files are currently in shader list

Anutrix пре 3 година
родитељ
комит
119e1a2937
2 измењених фајлова са 4 додато и 2 уклоњено
  1. 2 2
      editor/plugins/shader_editor_plugin.cpp
  2. 2 0
      editor/plugins/shader_editor_plugin.h

+ 2 - 2
editor/plugins/shader_editor_plugin.cpp

@@ -1241,7 +1241,7 @@ void ShaderEditorPlugin::_update_shader_list() {
 		shader_list->select(shader_tabs->get_current_tab());
 	}
 
-	for (int i = 1; i < FILE_MAX; i++) {
+	for (int i = FILE_SAVE; i < FILE_MAX; i++) {
 		file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), edited_shaders.size() == 0);
 	}
 
@@ -1592,7 +1592,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() {
 	file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditorPlugin::_menu_item_pressed));
 	file_hb->add_child(file_menu);
 
-	for (int i = 2; i < FILE_MAX; i++) {
+	for (int i = FILE_SAVE; i < FILE_MAX; i++) {
 		file_menu->get_popup()->set_item_disabled(file_menu->get_popup()->get_item_index(i), true);
 	}
 

+ 2 - 0
editor/plugins/shader_editor_plugin.h

@@ -219,6 +219,8 @@ class ShaderEditorPlugin : public EditorPlugin {
 
 	LocalVector<EditedShader> edited_shaders;
 
+	// Always valid operations come first in the enum, file-specific ones
+	// should go after FILE_SAVE which is used to build the menu accordingly.
 	enum {
 		FILE_NEW,
 		FILE_NEW_INCLUDE,