Merge pull request #75864 from KoBeWi/assassin_of_shaders
This commit is contained in:
commit
f6bf51ca49
|
@ -622,7 +622,7 @@ void EditorData::remove_scene(int p_idx) {
|
|||
}
|
||||
|
||||
if (!edited_scene[p_idx].path.is_empty()) {
|
||||
ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path);
|
||||
EditorNode::get_singleton()->emit_signal("scene_closed", edited_scene[p_idx].path);
|
||||
}
|
||||
|
||||
undo_redo_manager->discard_history(edited_scene[p_idx].history_id);
|
||||
|
|
|
@ -6332,6 +6332,7 @@ void EditorNode::_bind_methods() {
|
|||
ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "path")));
|
||||
ADD_SIGNAL(MethodInfo("project_settings_changed"));
|
||||
ADD_SIGNAL(MethodInfo("scene_changed"));
|
||||
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "path")));
|
||||
}
|
||||
|
||||
static Node *_resource_get_edited_scene() {
|
||||
|
|
|
@ -1642,6 +1642,7 @@ void ScriptEditor::_notification(int p_what) {
|
|||
get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed));
|
||||
InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open));
|
||||
EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search));
|
||||
EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
@ -1676,7 +1677,7 @@ bool ScriptEditor::can_take_away_focus() const {
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
|
||||
void ScriptEditor::_close_builtin_scripts_from_scene(const String &p_scene) {
|
||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||
|
||||
|
@ -1686,7 +1687,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed
|
||||
if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { // Is an internal script and belongs to scene being closed.
|
||||
_close_tab(i, false);
|
||||
i--;
|
||||
}
|
||||
|
@ -4090,6 +4091,8 @@ ScriptEditor::ScriptEditor() {
|
|||
Ref<EditorJSONSyntaxHighlighter> json_syntax_highlighter;
|
||||
json_syntax_highlighter.instantiate();
|
||||
register_syntax_highlighter(json_syntax_highlighter);
|
||||
|
||||
EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene));
|
||||
}
|
||||
|
||||
ScriptEditor::~ScriptEditor() {
|
||||
|
|
|
@ -482,6 +482,7 @@ class ScriptEditor : public PanelContainer {
|
|||
void _on_find_in_files_modified_files(PackedStringArray paths);
|
||||
|
||||
static void _open_script_request(const String &p_path);
|
||||
void _close_builtin_scripts_from_scene(const String &p_scene);
|
||||
|
||||
static ScriptEditor *script_editor;
|
||||
|
||||
|
@ -523,8 +524,6 @@ public:
|
|||
void notify_script_close(const Ref<Script> &p_script);
|
||||
void notify_script_changed(const Ref<Script> &p_script);
|
||||
|
||||
void close_builtin_scripts_from_scene(const String &p_scene);
|
||||
|
||||
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
|
||||
void update_doc(const String &p_name);
|
||||
void clear_docs_from_script(const Ref<Script> &p_script);
|
||||
|
|
|
@ -236,6 +236,26 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
|
|||
EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs.
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) {
|
||||
for (uint32_t i = 0; i < edited_shaders.size();) {
|
||||
Ref<Shader> &shader = edited_shaders[i].shader;
|
||||
if (shader.is_valid()) {
|
||||
if (shader->is_built_in() && shader->get_path().begins_with(p_scene)) {
|
||||
_close_shader(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Ref<ShaderInclude> &include = edited_shaders[i].shader_inc;
|
||||
if (include.is_valid()) {
|
||||
if (include->is_built_in() && include->get_path().begins_with(p_scene)) {
|
||||
_close_shader(i);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_resource_saved(Object *obj) {
|
||||
// May have been renamed on save.
|
||||
for (EditedShader &edited_shader : edited_shaders) {
|
||||
|
@ -430,6 +450,14 @@ void ShaderEditorPlugin::drop_data_fw(const Point2 &p_point, const Variant &p_da
|
|||
}
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ShaderEditorPlugin::_close_builtin_shaders_from_scene));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
ShaderEditorPlugin::ShaderEditorPlugin() {
|
||||
main_split = memnew(HSplitContainer);
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ class ShaderEditorPlugin : public EditorPlugin {
|
|||
void _menu_item_pressed(int p_index);
|
||||
void _resource_saved(Object *obj);
|
||||
void _close_shader(int p_index);
|
||||
void _close_builtin_shaders_from_scene(const String &p_scene);
|
||||
|
||||
void _shader_created(Ref<Shader> p_shader);
|
||||
void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
|
||||
|
@ -92,6 +93,9 @@ class ShaderEditorPlugin : public EditorPlugin {
|
|||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
public:
|
||||
virtual String get_name() const override { return "Shader"; }
|
||||
virtual void edit(Object *p_object) override;
|
||||
|
|
Loading…
Reference in New Issue