summaryrefslogtreecommitdiff
path: root/modules/visual_script
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2021-11-06 02:15:19 +0100
committerkobewi <kobewi4e@gmail.com>2021-11-07 23:51:12 +0100
commit134e4d168b30fa7b28fc784672ec521d0b634ee9 (patch)
treed4fa46a6377209f4add1c4d807a0c8e02a9aa545 /modules/visual_script
parent7538c052158071e68054b6e6e0d5a2e9df8ee4f2 (diff)
Improve save handling for built-in scripts
Diffstat (limited to 'modules/visual_script')
-rw-r--r--modules/visual_script/visual_script_editor.cpp25
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 49ae79e22a..2d1f95b08e 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -2582,18 +2582,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;