summaryrefslogtreecommitdiff
path: root/editor/create_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/create_dialog.cpp')
-rw-r--r--editor/create_dialog.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index e904fd94be..2dfb01826a 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+
#include "create_dialog.h"
#include "class_db.h"
@@ -37,7 +38,7 @@
#include "print_string.h"
#include "scene/gui/box_container.h"
-void CreateDialog::popup_create(bool p_dontclear) {
+void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) {
recent->clear();
@@ -89,11 +90,12 @@ void CreateDialog::popup_create(bool p_dontclear) {
popup_centered_ratio();
}
- if (p_dontclear)
+ if (p_dont_clear) {
search_box->select_all();
- else {
+ } else {
search_box->clear();
}
+
search_box->grab_focus();
_update_search();
@@ -104,8 +106,19 @@ void CreateDialog::popup_create(bool p_dontclear) {
if (enable_rl) {
search_options->add_constant_override("draw_relationship_lines", 1);
search_options->add_color_override("relationship_line_color", rl_color);
- } else
+ } else {
search_options->add_constant_override("draw_relationship_lines", 0);
+ }
+
+ is_replace_mode = p_replace_mode;
+
+ if (p_replace_mode) {
+ set_title(vformat(TTR("Change %s Type"), base_type));
+ get_ok()->set_text(TTR("Change"));
+ } else {
+ set_title(vformat(TTR("Create New %s"), base_type));
+ get_ok()->set_text(TTR("Create"));
+ }
}
void CreateDialog::_text_changed(const String &p_newtext) {
@@ -369,7 +382,11 @@ void CreateDialog::_notification(int p_what) {
void CreateDialog::set_base_type(const String &p_base) {
base_type = p_base;
- set_title(vformat(TTR("Create New %s"), p_base));
+ if (is_replace_mode)
+ set_title(vformat(TTR("Change %s Type"), p_base));
+ else
+ set_title(vformat(TTR("Create New %s"), p_base));
+
_update_search();
}
@@ -624,6 +641,8 @@ void CreateDialog::_bind_methods() {
CreateDialog::CreateDialog() {
+ is_replace_mode = false;
+
ClassDB::get_class_list(&type_list);
type_list.sort_custom<StringName::AlphCompare>();
@@ -678,7 +697,6 @@ CreateDialog::CreateDialog() {
search_box->connect("gui_input", this, "_sbox_input");
search_options = memnew(Tree);
vbc->add_margin_child(TTR("Matches:"), search_options, true);
- get_ok()->set_text(TTR("Create"));
get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);