You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Add create new script button to script editor menu
This commit is contained in:
@@ -211,7 +211,6 @@ void ScriptEditorQuickOpen::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed);
|
ObjectTypeDB::bind_method(_MD("_confirmed"),&ScriptEditorQuickOpen::_confirmed);
|
||||||
ObjectTypeDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input);
|
ObjectTypeDB::bind_method(_MD("_sbox_input"),&ScriptEditorQuickOpen::_sbox_input);
|
||||||
|
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line")));
|
ADD_SIGNAL(MethodInfo("goto_line",PropertyInfo(Variant::INT,"line")));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -547,6 +546,10 @@ void ScriptEditor::_show_debugger(bool p_show) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEditor::_script_created(Ref<Script> p_script) {
|
||||||
|
editor->push_item(p_script.operator->());
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEditor::_goto_script_line2(int p_line) {
|
void ScriptEditor::_goto_script_line2(int p_line) {
|
||||||
|
|
||||||
int selected = tab_container->get_current_tab();
|
int selected = tab_container->get_current_tab();
|
||||||
@@ -574,7 +577,7 @@ void ScriptEditor::_close_current_tab() {
|
|||||||
int selected = tab_container->get_current_tab();
|
int selected = tab_container->get_current_tab();
|
||||||
if (selected<0 || selected>=tab_container->get_child_count())
|
if (selected<0 || selected>=tab_container->get_child_count())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>();
|
ScriptTextEditor *current = tab_container->get_child(selected)->cast_to<ScriptTextEditor>();
|
||||||
if (!current)
|
if (!current)
|
||||||
return;
|
return;
|
||||||
@@ -753,7 +756,6 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||||||
|
|
||||||
|
|
||||||
if (p_option==FILE_OPEN) {
|
if (p_option==FILE_OPEN) {
|
||||||
|
|
||||||
editor->open_resource("Script");
|
editor->open_resource("Script");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -766,8 +768,11 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch(p_option) {
|
switch(p_option) {
|
||||||
|
case FILE_NEW: {
|
||||||
|
script_create_dialog->config("Node", ".gd");
|
||||||
|
script_create_dialog->popup_centered(Size2(300, 300));
|
||||||
|
} break;
|
||||||
case FILE_SAVE: {
|
case FILE_SAVE: {
|
||||||
|
|
||||||
if (!_test_script_times_on_disk())
|
if (!_test_script_times_on_disk())
|
||||||
return;
|
return;
|
||||||
editor->save_resource( current->get_edited_script() );
|
editor->save_resource( current->get_edited_script() );
|
||||||
@@ -1419,6 +1424,7 @@ void ScriptEditor::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names);
|
ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names);
|
||||||
ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed);
|
ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed);
|
||||||
ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected);
|
ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected);
|
||||||
|
ObjectTypeDB::bind_method("_script_created",&ScriptEditor::_script_created);
|
||||||
ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged);
|
ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1803,6 +1809,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||||||
file_menu = memnew( MenuButton );
|
file_menu = memnew( MenuButton );
|
||||||
menu_hb->add_child(file_menu);
|
menu_hb->add_child(file_menu);
|
||||||
file_menu->set_text("File");
|
file_menu->set_text("File");
|
||||||
|
file_menu->get_popup()->add_item("New",FILE_NEW);
|
||||||
file_menu->get_popup()->add_item("Open",FILE_OPEN);
|
file_menu->get_popup()->add_item("Open",FILE_OPEN);
|
||||||
file_menu->get_popup()->add_separator();
|
file_menu->get_popup()->add_separator();
|
||||||
file_menu->get_popup()->add_item("Save",FILE_SAVE,KEY_MASK_ALT|KEY_MASK_CMD|KEY_S);
|
file_menu->get_popup()->add_item("Save",FILE_SAVE,KEY_MASK_ALT|KEY_MASK_CMD|KEY_S);
|
||||||
@@ -1899,6 +1906,9 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||||||
add_child(erase_tab_confirm);
|
add_child(erase_tab_confirm);
|
||||||
erase_tab_confirm->connect("confirmed", this,"_close_current_tab");
|
erase_tab_confirm->connect("confirmed", this,"_close_current_tab");
|
||||||
|
|
||||||
|
script_create_dialog = memnew(ScriptCreateDialog);
|
||||||
|
add_child(script_create_dialog);
|
||||||
|
script_create_dialog->connect("script_created", this, "_script_created");
|
||||||
|
|
||||||
goto_line_dialog = memnew(GotoLineDialog);
|
goto_line_dialog = memnew(GotoLineDialog);
|
||||||
add_child(goto_line_dialog);
|
add_child(goto_line_dialog);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#define SCRIPT_EDITOR_PLUGIN_H
|
#define SCRIPT_EDITOR_PLUGIN_H
|
||||||
|
|
||||||
#include "tools/editor/editor_plugin.h"
|
#include "tools/editor/editor_plugin.h"
|
||||||
|
#include "tools/editor/script_create_dialog.h"
|
||||||
#include "scene/gui/tab_container.h"
|
#include "scene/gui/tab_container.h"
|
||||||
#include "scene/gui/text_edit.h"
|
#include "scene/gui/text_edit.h"
|
||||||
#include "scene/gui/menu_button.h"
|
#include "scene/gui/menu_button.h"
|
||||||
@@ -115,7 +116,7 @@ class ScriptEditor : public VBoxContainer {
|
|||||||
|
|
||||||
EditorNode *editor;
|
EditorNode *editor;
|
||||||
enum {
|
enum {
|
||||||
|
FILE_NEW,
|
||||||
FILE_OPEN,
|
FILE_OPEN,
|
||||||
FILE_SAVE,
|
FILE_SAVE,
|
||||||
FILE_SAVE_AS,
|
FILE_SAVE_AS,
|
||||||
@@ -167,6 +168,7 @@ class ScriptEditor : public VBoxContainer {
|
|||||||
FindReplaceDialog *find_replace_dialog;
|
FindReplaceDialog *find_replace_dialog;
|
||||||
GotoLineDialog *goto_line_dialog;
|
GotoLineDialog *goto_line_dialog;
|
||||||
ConfirmationDialog *erase_tab_confirm;
|
ConfirmationDialog *erase_tab_confirm;
|
||||||
|
ScriptCreateDialog *script_create_dialog;
|
||||||
ScriptEditorDebugger* debugger;
|
ScriptEditorDebugger* debugger;
|
||||||
ToolButton *scripts_visible;
|
ToolButton *scripts_visible;
|
||||||
|
|
||||||
@@ -207,6 +209,7 @@ class ScriptEditor : public VBoxContainer {
|
|||||||
void _breaked(bool p_breaked,bool p_can_debug);
|
void _breaked(bool p_breaked,bool p_can_debug);
|
||||||
void _show_debugger(bool p_show);
|
void _show_debugger(bool p_show);
|
||||||
void _update_window_menu();
|
void _update_window_menu();
|
||||||
|
void _script_created(Ref<Script> p_script);
|
||||||
|
|
||||||
void _editor_settings_changed();
|
void _editor_settings_changed();
|
||||||
void _autosave_scripts();
|
void _autosave_scripts();
|
||||||
|
|||||||
@@ -74,17 +74,17 @@ bool ScriptCreateDialog::_validate(const String& p_string) {
|
|||||||
void ScriptCreateDialog::_class_name_changed(const String& p_name) {
|
void ScriptCreateDialog::_class_name_changed(const String& p_name) {
|
||||||
|
|
||||||
if (!_validate(parent_name->get_text())) {
|
if (!_validate(parent_name->get_text())) {
|
||||||
error_label->set_text("INVALID PARENT CLASS NAME");
|
error_label->set_text("Invaild parent class name");
|
||||||
error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
|
error_label->add_color_override("font_color",Color(1,0.4,0.0,0.8));
|
||||||
} else if (class_name->is_editable()) {
|
} else if (class_name->is_editable()) {
|
||||||
if (class_name->get_text()=="") {
|
if (class_name->get_text()=="") {
|
||||||
error_label->set_text("Valid Chars: a-z A-Z 0-9 _");
|
error_label->set_text("Valid Chars: a-z A-Z 0-9 _");
|
||||||
error_label->add_color_override("font_color",Color(1,1,1,0.6));
|
error_label->add_color_override("font_color",Color(1,1,1,0.6));
|
||||||
} else if (!_validate(class_name->get_text())) {
|
} else if (!_validate(class_name->get_text())) {
|
||||||
error_label->set_text("INVALID CLASS NAME");
|
error_label->set_text("Invalid class name");
|
||||||
error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8));
|
error_label->add_color_override("font_color",Color(1,0.2,0.2,0.8));
|
||||||
} else {
|
} else {
|
||||||
error_label->set_text("Name is Valid");
|
error_label->set_text("Valid Name");
|
||||||
error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
|
error_label->add_color_override("font_color",Color(0,1.0,0.8,0.8));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user