From d304187357594283ca419cf349cf92fd64f483ce Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 29 Sep 2020 01:31:41 -0400 Subject: [PATCH] Warn when creating a script with the same name as the parent class (cherry picked from commit 5a9037f828ce84a07c3e748e20b50b334b896991) --- editor/script_create_dialog.cpp | 29 +++++++++++++++++++++-------- editor/script_create_dialog.h | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index 3c95d408e7b..3cc1286b224 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -225,6 +225,14 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must return ""; } +String ScriptCreateDialog::_get_class_name() const { + if (has_named_classes) { + return class_name->get_text(); + } else { + return ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); + } +} + void ScriptCreateDialog::_class_name_changed(const String &p_name) { if (_validate_class(class_name->get_text())) { @@ -278,14 +286,7 @@ void ScriptCreateDialog::ok_pressed() { } void ScriptCreateDialog::_create_new() { - - String cname_param; - - if (has_named_classes) { - cname_param = class_name->get_text(); - } else { - cname_param = ProjectSettings::get_singleton()->localize_path(file_path->get_text()).get_file().get_basename(); - } + String cname_param = _get_class_name(); Ref