Fix default script name in ScriptCreateDialog
It would default either to '.gd' when created from the script editor, or to 'res:///NodeName.gd' (three '/') when created from the scene tree dock.
This commit is contained in:
parent
c7fc3dcab3
commit
fb77cdf2f2
3 changed files with 16 additions and 17 deletions
|
@ -946,7 +946,7 @@ void ScriptEditor::_menu_option(int p_option) {
|
||||||
|
|
||||||
switch (p_option) {
|
switch (p_option) {
|
||||||
case FILE_NEW: {
|
case FILE_NEW: {
|
||||||
script_create_dialog->config("Node", ".gd");
|
script_create_dialog->config("Node", "new_script");
|
||||||
script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
|
script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE);
|
||||||
} break;
|
} break;
|
||||||
case FILE_NEW_TEXTFILE: {
|
case FILE_NEW_TEXTFILE: {
|
||||||
|
@ -1749,7 +1749,7 @@ void ScriptEditor::_update_script_names() {
|
||||||
} break;
|
} break;
|
||||||
case DISPLAY_DIR_AND_NAME: {
|
case DISPLAY_DIR_AND_NAME: {
|
||||||
if (!path.get_base_dir().get_file().empty()) {
|
if (!path.get_base_dir().get_file().empty()) {
|
||||||
sd.name = path.get_base_dir().get_file() + "/" + name;
|
sd.name = path.get_base_dir().get_file().plus_file(name);
|
||||||
} else {
|
} else {
|
||||||
sd.name = name;
|
sd.name = name;
|
||||||
}
|
}
|
||||||
|
@ -2114,8 +2114,6 @@ void ScriptEditor::_editor_play() {
|
||||||
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
|
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_STEP), true);
|
||||||
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false);
|
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), false);
|
||||||
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
|
debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true);
|
||||||
|
|
||||||
//debugger_gui->start_listening(Globals::get_singleton()->get("debug/debug_port"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditor::_editor_pause() {
|
void ScriptEditor::_editor_pause() {
|
||||||
|
|
|
@ -224,7 +224,7 @@ void SceneTreeDock::_perform_instance_scenes(const Vector<String> &p_files, Node
|
||||||
String new_name = parent->validate_child_name(instanced_scene);
|
String new_name = parent->validate_child_name(instanced_scene);
|
||||||
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
||||||
editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name);
|
editor_data->get_undo_redo().add_do_method(sed, "live_debug_instance_node", edited_scene->get_path_to(parent), p_files[i], new_name);
|
||||||
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name));
|
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_data->get_undo_redo().commit_action();
|
editor_data->get_undo_redo().commit_action();
|
||||||
|
@ -354,9 +354,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||||
if (path == "") {
|
if (path == "") {
|
||||||
String root_path = editor_data->get_edited_scene_root()->get_filename();
|
String root_path = editor_data->get_edited_scene_root()->get_filename();
|
||||||
if (root_path == "") {
|
if (root_path == "") {
|
||||||
path = "res://" + selected->get_name();
|
path = String("res://").plus_file(selected->get_name());
|
||||||
} else {
|
} else {
|
||||||
path = root_path.get_base_dir() + "/" + selected->get_name();
|
path = root_path.get_base_dir().plus_file(selected->get_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -535,7 +535,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
|
||||||
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
||||||
|
|
||||||
editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
|
editor_data->get_undo_redo().add_do_method(sed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
|
||||||
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + dup->get_name()));
|
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(dup->get_name())));
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_data->get_undo_redo().commit_action();
|
editor_data->get_undo_redo().commit_action();
|
||||||
|
@ -1429,7 +1429,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
|
||||||
}
|
}
|
||||||
|
|
||||||
editor_data->get_undo_redo().add_do_method(sed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc);
|
editor_data->get_undo_redo().add_do_method(sed, "live_debug_reparent_node", edited_scene->get_path_to(node), edited_scene->get_path_to(new_parent), new_name, p_position_in_parent + inc);
|
||||||
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)) + "/" + new_name), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index());
|
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_reparent_node", NodePath(String(edited_scene->get_path_to(new_parent)).plus_file(new_name)), edited_scene->get_path_to(node->get_parent()), node->get_name(), node->get_index());
|
||||||
|
|
||||||
if (p_keep_global_xform) {
|
if (p_keep_global_xform) {
|
||||||
if (Object::cast_to<Node2D>(node))
|
if (Object::cast_to<Node2D>(node))
|
||||||
|
@ -1661,7 +1661,7 @@ void SceneTreeDock::_create() {
|
||||||
String new_name = parent->validate_child_name(child);
|
String new_name = parent->validate_child_name(child);
|
||||||
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
ScriptEditorDebugger *sed = ScriptEditor::get_singleton()->get_debugger();
|
||||||
editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", edited_scene->get_path_to(parent), child->get_class(), new_name);
|
editor_data->get_undo_redo().add_do_method(sed, "live_debug_create_node", edited_scene->get_path_to(parent), child->get_class(), new_name);
|
||||||
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)) + "/" + new_name));
|
editor_data->get_undo_redo().add_undo_method(sed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).plus_file(new_name)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ void ScriptCreateDialog::config(const String &p_base_name, const String &p_base_
|
||||||
class_name->deselect();
|
class_name->deselect();
|
||||||
parent_name->set_text(p_base_name);
|
parent_name->set_text(p_base_name);
|
||||||
parent_name->deselect();
|
parent_name->deselect();
|
||||||
|
|
||||||
if (p_base_path != "") {
|
if (p_base_path != "") {
|
||||||
initial_bp = p_base_path.get_basename();
|
initial_bp = p_base_path.get_basename();
|
||||||
file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension());
|
file_path->set_text(initial_bp + "." + ScriptServer::get_language(language_menu->get_selected())->get_extension());
|
||||||
|
@ -359,7 +360,7 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
||||||
|
|
||||||
is_path_valid = false;
|
is_path_valid = false;
|
||||||
is_new_script_created = true;
|
is_new_script_created = true;
|
||||||
String p = p_path;
|
String p = p_path.strip_edges();
|
||||||
|
|
||||||
if (p == "") {
|
if (p == "") {
|
||||||
_msg_path_valid(false, TTR("Path is empty"));
|
_msg_path_valid(false, TTR("Path is empty"));
|
||||||
|
@ -367,6 +368,12 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p.get_file().get_basename() == "") {
|
||||||
|
_msg_path_valid(false, TTR("Filename is empty"));
|
||||||
|
_update_dialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p = ProjectSettings::get_singleton()->localize_path(p);
|
p = ProjectSettings::get_singleton()->localize_path(p);
|
||||||
if (!p.begins_with("res://")) {
|
if (!p.begins_with("res://")) {
|
||||||
_msg_path_valid(false, TTR("Path is not local"));
|
_msg_path_valid(false, TTR("Path is not local"));
|
||||||
|
@ -443,12 +450,6 @@ void ScriptCreateDialog::_path_changed(const String &p_path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p.get_file().get_basename() == "") {
|
|
||||||
_msg_path_valid(false, TTR("Filename is empty"));
|
|
||||||
_update_dialog();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* All checks passed */
|
/* All checks passed */
|
||||||
|
|
||||||
is_path_valid = true;
|
is_path_valid = true;
|
||||||
|
|
Loading…
Reference in a new issue