mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Improve save handling for built-in scripts
This commit is contained in:
parent
7538c05215
commit
134e4d168b
6 changed files with 93 additions and 54 deletions
|
@ -375,18 +375,21 @@ void ScriptTextEditor::ensure_focus() {
|
|||
String ScriptTextEditor::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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue