diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-09 21:46:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-09 21:46:58 +0100 |
commit | e3f3fc517a610d308e92dbc98b38def0f6e81c94 (patch) | |
tree | 517a75bbb781ddde6784e6693b306a9bb2799961 /modules | |
parent | 081c1ceda4f6e2dbc7c010611e9ec836106a967d (diff) | |
parent | 134e4d168b30fa7b28fc784672ec521d0b634ee9 (diff) |
Merge pull request #54653 from KoBeWi/built_in_scripts_deserved_that
Improve save handling for built-in scripts
Diffstat (limited to 'modules')
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 7b4fbc67fc..c74d6f9a4a 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2587,18 +2587,21 @@ void VisualScriptEditor::reload_text() { String VisualScriptEditor::get_name() { String name; - if (!script->is_built_in()) { - name = script->get_path().get_file(); - if (is_unsaved()) { - if (script->get_path().is_empty()) { - name = TTR("[unsaved]"); - } - name += "(*)"; + name = script->get_path().get_file(); + if (name.is_empty()) { + // This appears for newly created built-in scripts before saving the scene. + name = TTR("[unsaved]"); + } else if (script->is_built_in()) { + const String &script_name = script->get_name(); + if (script_name != "") { + // If the built-in script has a custom resource name defined, + // display the built-in script name as follows: `ResourceName (scene_file.tscn)` + name = vformat("%s (%s)", script_name, name.get_slice("::", 0)); } - } else if (script->get_name() != "") { - name = script->get_name(); - } else { - name = script->get_class() + "(" + itos(script->get_instance_id()) + ")"; + } + + if (is_unsaved()) { + name += "(*)"; } return name; |