Re-add attach button and context menu from 1880238c3e
This commit is contained in:
parent
1307ff7eb1
commit
d90809151f
4 changed files with 100 additions and 87 deletions
|
@ -57,10 +57,8 @@ void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
|
||||||
_tool_selected(TOOL_REPLACE);
|
_tool_selected(TOOL_REPLACE);
|
||||||
} else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
|
} else if (ED_IS_SHORTCUT("scene_tree/duplicate", p_event)) {
|
||||||
_tool_selected(TOOL_DUPLICATE);
|
_tool_selected(TOOL_DUPLICATE);
|
||||||
} else if (ED_IS_SHORTCUT("scene_tree/add_script", p_event)) {
|
} else if (ED_IS_SHORTCUT("scene_tree/attach_script", p_event)) {
|
||||||
_tool_selected(TOOL_CREATE_SCRIPT);
|
_tool_selected(TOOL_ATTACH_SCRIPT);
|
||||||
} else if (ED_IS_SHORTCUT("scene_tree/load_script", p_event)) {
|
|
||||||
_tool_selected(TOOL_LOAD_SCRIPT);
|
|
||||||
} else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
|
} else if(ED_IS_SHORTCUT("scene_tree/clear_script", p_event)) {
|
||||||
_tool_selected(TOOL_CLEAR_SCRIPT);
|
_tool_selected(TOOL_CLEAR_SCRIPT);
|
||||||
} else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
|
} else if (ED_IS_SHORTCUT("scene_tree/move_up", p_event)) {
|
||||||
|
@ -232,23 +230,6 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
|
||||||
scene_tree->set_selected(instanced_scene);
|
scene_tree->set_selected(instanced_scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeDock::_file_selected(String p_file) {
|
|
||||||
RES p_script = ResourceLoader::load(p_file, "Script");
|
|
||||||
if (p_script.is_null()) {
|
|
||||||
accept->get_ok()->set_text(TTR("Ugh"));
|
|
||||||
accept->set_text(vformat(TTR("Error loading script from %s"), p_file));
|
|
||||||
accept->popup_centered_minsize();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Node *selected = scene_tree->get_selected();
|
|
||||||
if (!selected)
|
|
||||||
return;
|
|
||||||
selected->set_script(p_script.get_ref_ptr());
|
|
||||||
editor->push_item(p_script.operator->());
|
|
||||||
file_dialog->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
|
bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {
|
||||||
int childCount = p_desired_node->get_child_count();
|
int childCount = p_desired_node->get_child_count();
|
||||||
|
|
||||||
|
@ -349,22 +330,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||||
//groups_editor->set_current(current);
|
//groups_editor->set_current(current);
|
||||||
//groups_editor->popup_centered_ratio();
|
//groups_editor->popup_centered_ratio();
|
||||||
} break;
|
} break;
|
||||||
case TOOL_LOAD_SCRIPT: {
|
case TOOL_ATTACH_SCRIPT: {
|
||||||
Node *selected = scene_tree->get_selected();
|
|
||||||
if (!selected)
|
|
||||||
break;
|
|
||||||
|
|
||||||
file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
|
||||||
|
|
||||||
List<String> extensions;
|
|
||||||
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
|
|
||||||
file_dialog->clear_filters();
|
|
||||||
for (List<String>::Element *E = extensions.front(); E; E = E->next())
|
|
||||||
file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
|
|
||||||
|
|
||||||
file_dialog->popup_centered_ratio();
|
|
||||||
} break;
|
|
||||||
case TOOL_CREATE_SCRIPT: {
|
|
||||||
|
|
||||||
Node *selected = scene_tree->get_selected();
|
Node *selected = scene_tree->get_selected();
|
||||||
if (!selected)
|
if (!selected)
|
||||||
|
@ -724,7 +690,6 @@ void SceneTreeDock::_notification(int p_what) {
|
||||||
button_add->set_icon(get_icon("Add", "EditorIcons"));
|
button_add->set_icon(get_icon("Add", "EditorIcons"));
|
||||||
button_instance->set_icon(get_icon("Instance", "EditorIcons"));
|
button_instance->set_icon(get_icon("Instance", "EditorIcons"));
|
||||||
button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
|
button_create_script->set_icon(get_icon("ScriptCreate","EditorIcons"));
|
||||||
button_load_script->set_icon(get_icon("Script", "EditorIcons"));
|
|
||||||
button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
|
button_clear_script->set_icon(get_icon("Remove", "EditorIcons"));
|
||||||
|
|
||||||
filter_icon->set_texture(get_icon("Zoom", "EditorIcons"));
|
filter_icon->set_texture(get_icon("Zoom", "EditorIcons"));
|
||||||
|
@ -1299,17 +1264,14 @@ void SceneTreeDock::_selection_changed() {
|
||||||
if (selection_size==1) {
|
if (selection_size==1) {
|
||||||
if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
|
if(EditorNode::get_singleton()->get_editor_selection()->get_selection().front()->key()->get_script().is_null()) {
|
||||||
button_create_script->show();
|
button_create_script->show();
|
||||||
button_load_script->show();
|
|
||||||
button_clear_script->hide();
|
button_clear_script->hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
button_create_script->hide();
|
button_create_script->hide();
|
||||||
button_load_script->hide();
|
|
||||||
button_clear_script->show();
|
button_clear_script->show();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
button_create_script->hide();
|
button_create_script->hide();
|
||||||
button_load_script->hide();
|
|
||||||
button_clear_script->hide();
|
button_clear_script->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1732,8 +1694,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
|
||||||
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
|
//menu->add_icon_item(get_icon("Groups","EditorIcons"),TTR("Edit Groups"),TOOL_GROUP);
|
||||||
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
|
//menu->add_icon_item(get_icon("Connect","EditorIcons"),TTR("Edit Connections"),TOOL_CONNECT);
|
||||||
menu->add_separator();
|
menu->add_separator();
|
||||||
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/add_script"), TOOL_CREATE_SCRIPT);
|
menu->add_icon_shortcut(get_icon("ScriptCreate", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/attach_script"), TOOL_ATTACH_SCRIPT);
|
||||||
menu->add_icon_shortcut(get_icon("Script", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/load_script"), TOOL_LOAD_SCRIPT);
|
|
||||||
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
|
menu->add_icon_shortcut(get_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("scene_tree/clear_script"), TOOL_CLEAR_SCRIPT);
|
||||||
menu->add_separator();
|
menu->add_separator();
|
||||||
}
|
}
|
||||||
|
@ -1776,7 +1737,7 @@ void SceneTreeDock::set_filter(const String &p_filter) {
|
||||||
void SceneTreeDock::open_script_dialog(Node* p_for_node) {
|
void SceneTreeDock::open_script_dialog(Node* p_for_node) {
|
||||||
|
|
||||||
scene_tree->set_selected(p_for_node,false);
|
scene_tree->set_selected(p_for_node,false);
|
||||||
_tool_selected(TOOL_CREATE_SCRIPT);
|
_tool_selected(TOOL_ATTACH_SCRIPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTreeDock::_bind_methods() {
|
void SceneTreeDock::_bind_methods() {
|
||||||
|
@ -1802,7 +1763,6 @@ void SceneTreeDock::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("_script_dropped"), &SceneTreeDock::_script_dropped);
|
ObjectTypeDB::bind_method(_MD("_script_dropped"), &SceneTreeDock::_script_dropped);
|
||||||
ObjectTypeDB::bind_method(_MD("_tree_rmb"), &SceneTreeDock::_tree_rmb);
|
ObjectTypeDB::bind_method(_MD("_tree_rmb"), &SceneTreeDock::_tree_rmb);
|
||||||
ObjectTypeDB::bind_method(_MD("_filter_changed"), &SceneTreeDock::_filter_changed);
|
ObjectTypeDB::bind_method(_MD("_filter_changed"), &SceneTreeDock::_filter_changed);
|
||||||
ObjectTypeDB::bind_method(_MD("_file_selected"), &SceneTreeDock::_file_selected);
|
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("instance"), &SceneTreeDock::instance);
|
ObjectTypeDB::bind_method(_MD("instance"), &SceneTreeDock::instance);
|
||||||
}
|
}
|
||||||
|
@ -1823,8 +1783,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
||||||
ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A);
|
ED_SHORTCUT("scene_tree/add_child_node", TTR("Add Child Node"), KEY_MASK_CMD | KEY_A);
|
||||||
ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"));
|
ED_SHORTCUT("scene_tree/instance_scene", TTR("Instance Child Scene"));
|
||||||
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
|
ED_SHORTCUT("scene_tree/change_node_type", TTR("Change Type"));
|
||||||
ED_SHORTCUT("scene_tree/add_script", TTR("Add Script"));
|
ED_SHORTCUT("scene_tree/attach_script", TTR("Attach Script"));
|
||||||
ED_SHORTCUT("scene_tree/load_script", TTR("Load Script"));
|
|
||||||
ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
|
ED_SHORTCUT("scene_tree/clear_script", TTR("Clear Script"));
|
||||||
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
|
ED_SHORTCUT("scene_tree/move_up", TTR("Move Up"), KEY_MASK_CMD | KEY_UP);
|
||||||
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
|
ED_SHORTCUT("scene_tree/move_down", TTR("Move Down"), KEY_MASK_CMD | KEY_DOWN);
|
||||||
|
@ -1860,19 +1819,12 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
||||||
filter->connect("text_changed", this, "_filter_changed");
|
filter->connect("text_changed", this, "_filter_changed");
|
||||||
|
|
||||||
tb = memnew(ToolButton);
|
tb = memnew(ToolButton);
|
||||||
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CREATE_SCRIPT, false));
|
tb->connect("pressed",this,"_tool_selected",make_binds(TOOL_ATTACH_SCRIPT, false));
|
||||||
tb->set_tooltip(TTR("Create a new script for the selected node."));
|
tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
|
||||||
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/add_script"));
|
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
|
||||||
filter_hbc->add_child(tb);
|
filter_hbc->add_child(tb);
|
||||||
button_create_script=tb;
|
button_create_script=tb;
|
||||||
|
|
||||||
tb = memnew(ToolButton);
|
|
||||||
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_LOAD_SCRIPT, false));
|
|
||||||
tb->set_tooltip(TTR("Load a script for the selected node."));
|
|
||||||
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/load_script"));
|
|
||||||
filter_hbc->add_child(tb);
|
|
||||||
button_load_script = tb;
|
|
||||||
|
|
||||||
tb = memnew(ToolButton);
|
tb = memnew(ToolButton);
|
||||||
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
|
tb->connect("pressed", this, "_tool_selected", make_binds(TOOL_CLEAR_SCRIPT, false));
|
||||||
tb->set_tooltip(TTR("Clear a script for the selected node."));
|
tb->set_tooltip(TTR("Clear a script for the selected node."));
|
||||||
|
@ -1902,11 +1854,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
|
||||||
add_child(create_dialog);
|
add_child(create_dialog);
|
||||||
create_dialog->connect("create", this, "_create");
|
create_dialog->connect("create", this, "_create");
|
||||||
|
|
||||||
file_dialog = memnew(EditorFileDialog);
|
|
||||||
add_child(file_dialog);
|
|
||||||
file_dialog->hide();
|
|
||||||
file_dialog->connect("file_selected", this, "_file_selected");
|
|
||||||
|
|
||||||
//groups_editor = memnew( GroupsEditor );
|
//groups_editor = memnew( GroupsEditor );
|
||||||
//add_child(groups_editor);
|
//add_child(groups_editor);
|
||||||
//groups_editor->set_undo_redo(&editor_data->get_undo_redo());
|
//groups_editor->set_undo_redo(&editor_data->get_undo_redo());
|
||||||
|
|
|
@ -58,8 +58,7 @@ class SceneTreeDock : public VBoxContainer {
|
||||||
TOOL_REPLACE,
|
TOOL_REPLACE,
|
||||||
TOOL_CONNECT,
|
TOOL_CONNECT,
|
||||||
TOOL_GROUP,
|
TOOL_GROUP,
|
||||||
TOOL_CREATE_SCRIPT,
|
TOOL_ATTACH_SCRIPT,
|
||||||
TOOL_LOAD_SCRIPT,
|
|
||||||
TOOL_CLEAR_SCRIPT,
|
TOOL_CLEAR_SCRIPT,
|
||||||
TOOL_MOVE_UP,
|
TOOL_MOVE_UP,
|
||||||
TOOL_MOVE_DOWN,
|
TOOL_MOVE_DOWN,
|
||||||
|
@ -75,12 +74,10 @@ class SceneTreeDock : public VBoxContainer {
|
||||||
|
|
||||||
int current_option;
|
int current_option;
|
||||||
CreateDialog *create_dialog;
|
CreateDialog *create_dialog;
|
||||||
EditorFileDialog *file_dialog;
|
|
||||||
|
|
||||||
ToolButton *button_add;
|
ToolButton *button_add;
|
||||||
ToolButton *button_instance;
|
ToolButton *button_instance;
|
||||||
ToolButton *button_create_script;
|
ToolButton *button_create_script;
|
||||||
ToolButton *button_load_script;
|
|
||||||
ToolButton *button_clear_script;
|
ToolButton *button_clear_script;
|
||||||
|
|
||||||
SceneTreeEditor *scene_tree;
|
SceneTreeEditor *scene_tree;
|
||||||
|
|
|
@ -94,6 +94,19 @@ void ScriptCreateDialog::_class_name_changed(const String &p_name) {
|
||||||
|
|
||||||
void ScriptCreateDialog::ok_pressed() {
|
void ScriptCreateDialog::ok_pressed() {
|
||||||
|
|
||||||
|
if (create_new){
|
||||||
|
_create_new();
|
||||||
|
} else {
|
||||||
|
_load_exist();
|
||||||
|
}
|
||||||
|
|
||||||
|
create_new = true;
|
||||||
|
_update_controls();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptCreateDialog::_create_new() {
|
||||||
|
|
||||||
if (class_name->is_editable() && !_validate(class_name->get_text())) {
|
if (class_name->is_editable() && !_validate(class_name->get_text())) {
|
||||||
|
|
||||||
alert->set_text(TTR("Class name is invalid!"));
|
alert->set_text(TTR("Class name is invalid!"));
|
||||||
|
@ -103,7 +116,6 @@ void ScriptCreateDialog::ok_pressed() {
|
||||||
if (!_validate(parent_name->get_text())) {
|
if (!_validate(parent_name->get_text())) {
|
||||||
alert->set_text(TTR("Parent class name is invalid!"));
|
alert->set_text(TTR("Parent class name is invalid!"));
|
||||||
alert->popup_centered_minsize();
|
alert->popup_centered_minsize();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,14 +148,27 @@ void ScriptCreateDialog::ok_pressed() {
|
||||||
alert->popup_centered_minsize();
|
alert->popup_centered_minsize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scr->set_path(lpath);
|
|
||||||
//EditorFileSystem::get_singleton()->update_file(lpath,scr->get_type());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hide();
|
hide();
|
||||||
emit_signal("script_created", scr);
|
emit_signal("script_created", scr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptCreateDialog::_load_exist() {
|
||||||
|
|
||||||
|
String path = file_path->get_text();
|
||||||
|
RES p_script = ResourceLoader::load(path, "Script");
|
||||||
|
if (p_script.is_null()) {
|
||||||
|
alert->get_ok()->set_text(TTR("Ugh"));
|
||||||
|
alert->set_text(vformat(TTR("Error loading script from %s"), path));
|
||||||
|
alert->popup_centered_minsize();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hide();
|
||||||
|
emit_signal("script_created", p_script.get_ref_ptr());
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptCreateDialog::_lang_changed(int l) {
|
void ScriptCreateDialog::_lang_changed(int l) {
|
||||||
|
|
||||||
l = language_menu->get_selected();
|
l = language_menu->get_selected();
|
||||||
|
@ -152,10 +177,35 @@ void ScriptCreateDialog::_lang_changed(int l) {
|
||||||
} else {
|
} else {
|
||||||
class_name->set_editable(false);
|
class_name->set_editable(false);
|
||||||
}
|
}
|
||||||
if (file_path->get_text().basename() == initial_bp) {
|
|
||||||
file_path->set_text(initial_bp + "." + ScriptServer::get_language(l)->get_extension());
|
String selected_ext = "."+ScriptServer::get_language(l)->get_extension();
|
||||||
_path_changed(file_path->get_text());
|
String path = file_path->get_text();
|
||||||
|
String extension = "";
|
||||||
|
if (path.find(".") >= 0) {
|
||||||
|
extension = path.extension();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extension.length() == 0) {
|
||||||
|
// add extension if none
|
||||||
|
path += selected_ext;
|
||||||
|
_path_changed(path);
|
||||||
|
} else {
|
||||||
|
// change extension by selected language
|
||||||
|
List<String> extensions;
|
||||||
|
// get all possible extensions for script
|
||||||
|
for (int l = 0; l<language_menu->get_item_count(); l++) {
|
||||||
|
ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
||||||
|
if (E->get().nocasecmp_to(extension) == 0) {
|
||||||
|
path = path.basename()+selected_ext;
|
||||||
|
_path_changed(path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_path->set_text(path);
|
||||||
_class_name_changed(class_name->get_text());
|
_class_name_changed(class_name->get_text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +225,10 @@ void ScriptCreateDialog::_browse_path() {
|
||||||
file_browse->clear_filters();
|
file_browse->clear_filters();
|
||||||
List<String> extensions;
|
List<String> extensions;
|
||||||
|
|
||||||
int l = language_menu->get_selected();
|
// get all possible extensions for script
|
||||||
ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
|
for (int l = 0; l < language_menu->get_item_count(); l++) {
|
||||||
|
ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
|
||||||
|
}
|
||||||
|
|
||||||
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
||||||
file_browse->add_filter("*." + E->get());
|
file_browse->add_filter("*." + E->get());
|
||||||
|
@ -228,43 +280,54 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
||||||
|
|
||||||
FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);
|
FileAccess *f = FileAccess::create(FileAccess::ACCESS_RESOURCES);
|
||||||
|
|
||||||
if (f->file_exists(p)) {
|
create_new = !f->file_exists(p);
|
||||||
|
|
||||||
path_error_label->set_text(TTR("File exists"));
|
|
||||||
path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
|
|
||||||
memdelete(f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memdelete(f);
|
memdelete(f);
|
||||||
|
|
||||||
String extension = p.extension();
|
String extension = p.extension();
|
||||||
List<String> extensions;
|
List<String> extensions;
|
||||||
|
|
||||||
int l = language_menu->get_selected();
|
// get all possible extensions for script
|
||||||
ScriptServer::get_language(l)->get_recognized_extensions(&extensions);
|
for (int l = 0; l < language_menu->get_item_count(); l++) {
|
||||||
|
ScriptServer::get_language( l )->get_recognized_extensions(&extensions);
|
||||||
|
}
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
int index = 0;
|
||||||
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
|
||||||
if (E->get().nocasecmp_to(extension) == 0) {
|
if (E->get().nocasecmp_to(extension) == 0) {
|
||||||
|
language_menu->select(index); // change Language option by extension
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
|
||||||
path_error_label->set_text(TTR("Invalid extension"));
|
path_error_label->set_text(TTR("Invalid extension"));
|
||||||
path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
|
path_error_label->add_color_override("font_color", Color(1, 0.4, 0.0, 0.8));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
path_error_label->set_text(TTR("Valid path"));
|
_update_controls();
|
||||||
|
|
||||||
path_error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
|
path_error_label->add_color_override("font_color", Color(0, 1.0, 0.8, 0.8));
|
||||||
|
|
||||||
path_valid = true;
|
path_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptCreateDialog::_update_controls() {
|
||||||
|
|
||||||
|
if (create_new) {
|
||||||
|
path_error_label->set_text(TTR("Create new script"));
|
||||||
|
get_ok()->set_text(TTR("Create"));
|
||||||
|
} else {
|
||||||
|
path_error_label->set_text(TTR("Load existing script"));
|
||||||
|
get_ok()->set_text(TTR("Load"));
|
||||||
|
}
|
||||||
|
parent_name->set_editable(create_new);
|
||||||
|
internal->set_disabled(!create_new);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptCreateDialog::_bind_methods() {
|
void ScriptCreateDialog::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method("_class_name_changed", &ScriptCreateDialog::_class_name_changed);
|
ObjectTypeDB::bind_method("_class_name_changed", &ScriptCreateDialog::_class_name_changed);
|
||||||
|
@ -339,7 +402,7 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
||||||
|
|
||||||
set_size(Size2(200, 150));
|
set_size(Size2(200, 150));
|
||||||
set_hide_on_ok(false);
|
set_hide_on_ok(false);
|
||||||
set_title(TTR("Create Node Script"));
|
set_title(TTR("Attach Node Script"));
|
||||||
|
|
||||||
file_browse = memnew(EditorFileDialog);
|
file_browse = memnew(EditorFileDialog);
|
||||||
file_browse->connect("file_selected", this, "_file_selected");
|
file_browse->connect("file_selected", this, "_file_selected");
|
||||||
|
@ -348,4 +411,6 @@ ScriptCreateDialog::ScriptCreateDialog() {
|
||||||
alert = memnew(AcceptDialog);
|
alert = memnew(AcceptDialog);
|
||||||
add_child(alert);
|
add_child(alert);
|
||||||
_lang_changed(0);
|
_lang_changed(0);
|
||||||
|
|
||||||
|
create_new = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ class ScriptCreateDialog : public ConfirmationDialog {
|
||||||
VBoxContainer *path_vb;
|
VBoxContainer *path_vb;
|
||||||
AcceptDialog *alert;
|
AcceptDialog *alert;
|
||||||
bool path_valid;
|
bool path_valid;
|
||||||
|
bool create_new;
|
||||||
String initial_bp;
|
String initial_bp;
|
||||||
|
|
||||||
void _path_changed(const String &p_path = String());
|
void _path_changed(const String &p_path = String());
|
||||||
|
@ -59,6 +60,9 @@ class ScriptCreateDialog : public ConfirmationDialog {
|
||||||
void _browse_path();
|
void _browse_path();
|
||||||
void _file_selected(const String &p_file);
|
void _file_selected(const String &p_file);
|
||||||
virtual void ok_pressed();
|
virtual void ok_pressed();
|
||||||
|
void _create_new();
|
||||||
|
void _load_exist();
|
||||||
|
void _update_controls();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
Loading…
Reference in a new issue