Added input actions renaming
This commit is contained in:
parent
6e4b1ff838
commit
fa085a9c2c
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* editor_layout_dialog.cpp */
|
/* editor_name_dialog.cpp */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -27,39 +27,63 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#include "editor_layout_dialog.h"
|
#include "editor_name_dialog.h"
|
||||||
#include "object_type_db.h"
|
#include "object_type_db.h"
|
||||||
|
#include "os/keyboard.h"
|
||||||
|
|
||||||
void EditorLayoutDialog::clear_layout_name() {
|
void EditorNameDialog::_line_input_event(const InputEvent& p_event) {
|
||||||
|
|
||||||
layout_name->clear();
|
if (p_event.type == InputEvent::KEY) {
|
||||||
}
|
|
||||||
|
|
||||||
void EditorLayoutDialog::_post_popup() {
|
if (!p_event.key.pressed)
|
||||||
|
return;
|
||||||
|
|
||||||
ConfirmationDialog::_post_popup();
|
switch (p_event.key.scancode) {
|
||||||
layout_name->grab_focus();
|
case KEY_ENTER:
|
||||||
}
|
case KEY_RETURN: {
|
||||||
|
|
||||||
void EditorLayoutDialog::ok_pressed() {
|
if (get_hide_on_ok())
|
||||||
|
hide();
|
||||||
|
ok_pressed();
|
||||||
|
accept_event();
|
||||||
|
} break;
|
||||||
|
case KEY_ESCAPE: {
|
||||||
|
|
||||||
if (layout_name->get_text()!="") {
|
hide();
|
||||||
emit_signal("layout_selected", layout_name->get_text());
|
accept_event();
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayoutDialog::_bind_methods() {
|
void EditorNameDialog::_post_popup() {
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("layout_selected",PropertyInfo( Variant::STRING,"layout_name")));
|
ConfirmationDialog::_post_popup();
|
||||||
|
name->clear();
|
||||||
|
name->grab_focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorLayoutDialog::EditorLayoutDialog()
|
void EditorNameDialog::ok_pressed() {
|
||||||
|
|
||||||
|
if (name->get_text()!="") {
|
||||||
|
emit_signal("name_confirmed", name->get_text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorNameDialog::_bind_methods() {
|
||||||
|
|
||||||
|
ObjectTypeDB::bind_method("_line_input_event",&EditorNameDialog::_line_input_event);
|
||||||
|
|
||||||
|
ADD_SIGNAL(MethodInfo("name_confirmed",PropertyInfo( Variant::STRING,"name")));
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorNameDialog::EditorNameDialog()
|
||||||
{
|
{
|
||||||
|
name = memnew( LineEdit );
|
||||||
layout_name = memnew( LineEdit );
|
add_child(name);
|
||||||
layout_name->set_margin(MARGIN_TOP,5);
|
move_child(name, get_label()->get_index()+1);
|
||||||
layout_name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
|
name->set_margin(MARGIN_TOP,5);
|
||||||
layout_name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
|
name->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN,5);
|
||||||
add_child(layout_name);
|
name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,5);
|
||||||
move_child(layout_name, get_label()->get_index()+1);
|
name->connect("input_event", this, "_line_input_event");
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* editor_layout_dialog.h */
|
/* editor_name_dialog.h */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* This file is part of: */
|
/* This file is part of: */
|
||||||
/* GODOT ENGINE */
|
/* GODOT ENGINE */
|
||||||
@ -27,17 +27,19 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
#ifndef EDITOR_LAYOUT_DIALOG_H
|
#ifndef EDITOR_NAME_DIALOG_H
|
||||||
#define EDITOR_LAYOUT_DIALOG_H
|
#define EDITOR_NAME_DIALOG_H
|
||||||
|
|
||||||
#include "scene/gui/dialogs.h"
|
#include "scene/gui/dialogs.h"
|
||||||
#include "scene/gui/line_edit.h"
|
#include "scene/gui/line_edit.h"
|
||||||
|
|
||||||
class EditorLayoutDialog : public ConfirmationDialog {
|
class EditorNameDialog : public ConfirmationDialog {
|
||||||
|
|
||||||
OBJ_TYPE( EditorLayoutDialog, ConfirmationDialog );
|
OBJ_TYPE( EditorNameDialog, ConfirmationDialog );
|
||||||
|
|
||||||
LineEdit *layout_name;
|
LineEdit *name;
|
||||||
|
|
||||||
|
void _line_input_event(const InputEvent& p_event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -46,9 +48,10 @@ protected:
|
|||||||
virtual void _post_popup();
|
virtual void _post_popup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clear_layout_name();
|
|
||||||
|
|
||||||
EditorLayoutDialog();
|
LineEdit* get_line_edit() { return name; }
|
||||||
|
|
||||||
|
EditorNameDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITOR_LAYOUT_DIALOG_H
|
#endif // EDITOR_NAME_DIALOG_H
|
@ -4124,7 +4124,6 @@ void EditorNode::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
|
ObjectTypeDB::bind_method("_dock_move_right",&EditorNode::_dock_move_right);
|
||||||
|
|
||||||
ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
|
ObjectTypeDB::bind_method("_layout_menu_option",&EditorNode::_layout_menu_option);
|
||||||
ObjectTypeDB::bind_method("_layout_dialog_action",&EditorNode::_dialog_action);
|
|
||||||
|
|
||||||
ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
|
ObjectTypeDB::bind_method("set_current_scene",&EditorNode::set_current_scene);
|
||||||
ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
|
ObjectTypeDB::bind_method("set_current_version",&EditorNode::set_current_version);
|
||||||
@ -4624,7 +4623,6 @@ void EditorNode::_layout_menu_option(int p_id) {
|
|||||||
case SETTINGS_LAYOUT_SAVE: {
|
case SETTINGS_LAYOUT_SAVE: {
|
||||||
|
|
||||||
current_option=p_id;
|
current_option=p_id;
|
||||||
layout_dialog->clear_layout_name();
|
|
||||||
layout_dialog->set_title("Save Layout");
|
layout_dialog->set_title("Save Layout");
|
||||||
layout_dialog->get_ok()->set_text("Save");
|
layout_dialog->get_ok()->set_text("Save");
|
||||||
layout_dialog->popup_centered();
|
layout_dialog->popup_centered();
|
||||||
@ -4632,7 +4630,6 @@ void EditorNode::_layout_menu_option(int p_id) {
|
|||||||
case SETTINGS_LAYOUT_DELETE: {
|
case SETTINGS_LAYOUT_DELETE: {
|
||||||
|
|
||||||
current_option=p_id;
|
current_option=p_id;
|
||||||
layout_dialog->clear_layout_name();
|
|
||||||
layout_dialog->set_title("Delete Layout");
|
layout_dialog->set_title("Delete Layout");
|
||||||
layout_dialog->get_ok()->set_text("Delete");
|
layout_dialog->get_ok()->set_text("Delete");
|
||||||
layout_dialog->popup_centered();
|
layout_dialog->popup_centered();
|
||||||
@ -5427,13 +5424,13 @@ EditorNode::EditorNode() {
|
|||||||
p->add_separator();
|
p->add_separator();
|
||||||
p->add_item("About",SETTINGS_ABOUT);
|
p->add_item("About",SETTINGS_ABOUT);
|
||||||
|
|
||||||
layout_dialog = memnew( EditorLayoutDialog );
|
layout_dialog = memnew( EditorNameDialog );
|
||||||
gui_base->add_child(layout_dialog);
|
gui_base->add_child(layout_dialog);
|
||||||
layout_dialog->set_hide_on_ok(false);
|
layout_dialog->set_hide_on_ok(false);
|
||||||
layout_dialog->set_size(Size2(175, 70));
|
layout_dialog->set_size(Size2(175, 70));
|
||||||
confirm_error = memnew( AcceptDialog );
|
confirm_error = memnew( AcceptDialog );
|
||||||
layout_dialog->add_child(confirm_error);
|
layout_dialog->add_child(confirm_error);
|
||||||
layout_dialog->connect("layout_selected", this,"_layout_dialog_action");
|
layout_dialog->connect("name_confirmed", this,"_dialog_action");
|
||||||
|
|
||||||
sources_button = memnew( ToolButton );
|
sources_button = memnew( ToolButton );
|
||||||
right_menu_hb->add_child(sources_button);
|
right_menu_hb->add_child(sources_button);
|
||||||
|
@ -76,7 +76,7 @@
|
|||||||
#include "editor_reimport_dialog.h"
|
#include "editor_reimport_dialog.h"
|
||||||
#include "import_settings.h"
|
#include "import_settings.h"
|
||||||
#include "tools/editor/editor_plugin.h"
|
#include "tools/editor/editor_plugin.h"
|
||||||
#include "tools/editor/editor_layout_dialog.h"
|
#include "tools/editor/editor_name_dialog.h"
|
||||||
|
|
||||||
#include "fileserver/editor_file_server.h"
|
#include "fileserver/editor_file_server.h"
|
||||||
#include "editor_resource_preview.h"
|
#include "editor_resource_preview.h"
|
||||||
@ -290,7 +290,7 @@ class EditorNode : public Node {
|
|||||||
|
|
||||||
Ref<ConfigFile> default_theme;
|
Ref<ConfigFile> default_theme;
|
||||||
PopupMenu *editor_layouts;
|
PopupMenu *editor_layouts;
|
||||||
EditorLayoutDialog *layout_dialog;
|
EditorNameDialog *layout_dialog;
|
||||||
AcceptDialog *confirm_error;
|
AcceptDialog *confirm_error;
|
||||||
|
|
||||||
//OptimizedPresetsDialog *optimized_presets;
|
//OptimizedPresetsDialog *optimized_presets;
|
||||||
|
@ -338,6 +338,15 @@ void ProjectSettings::_action_button_pressed(Object* p_obj, int p_column,int p_i
|
|||||||
add_at="input/"+ti->get_text(0);
|
add_at="input/"+ti->get_text(0);
|
||||||
|
|
||||||
} else if (p_id==2) {
|
} else if (p_id==2) {
|
||||||
|
//rename
|
||||||
|
|
||||||
|
add_at="input/"+ti->get_text(0);
|
||||||
|
rename_action->popup_centered();
|
||||||
|
rename_action->get_line_edit()->set_text(ti->get_text(0));
|
||||||
|
rename_action->get_line_edit()->set_cursor_pos(ti->get_text(0).length());
|
||||||
|
rename_action->get_line_edit()->select_all();
|
||||||
|
|
||||||
|
} else if (p_id==3) {
|
||||||
//remove
|
//remove
|
||||||
|
|
||||||
if (ti->get_parent()==input_editor->get_root()) {
|
if (ti->get_parent()==input_editor->get_root()) {
|
||||||
@ -418,7 +427,8 @@ void ProjectSettings::_update_actions() {
|
|||||||
item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
|
item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK);
|
||||||
item->set_text(0,name);
|
item->set_text(0,name);
|
||||||
item->add_button(0,get_icon("Add","EditorIcons"),1);
|
item->add_button(0,get_icon("Add","EditorIcons"),1);
|
||||||
item->add_button(0,get_icon("Remove","EditorIcons"),2);
|
item->add_button(0,get_icon("Rename","EditorIcons"),2);
|
||||||
|
item->add_button(0,get_icon("Remove","EditorIcons"),3);
|
||||||
item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
|
item->set_custom_bg_color(0,get_color("prop_subsection","Editor"));
|
||||||
item->set_editable(0,true);
|
item->set_editable(0,true);
|
||||||
item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
|
item->set_checked(0,pi.usage&PROPERTY_USAGE_CHECKED);
|
||||||
@ -486,7 +496,7 @@ void ProjectSettings::_update_actions() {
|
|||||||
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
|
action->set_icon(0,get_icon("JoyAxis","EditorIcons"));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
action->add_button(0,get_icon("Remove","EditorIcons"),2);
|
action->add_button(0,get_icon("Remove","EditorIcons"),3);
|
||||||
action->set_metadata(0,i);
|
action->set_metadata(0,i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -616,6 +626,45 @@ void ProjectSettings::_action_add() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectSettings::_action_rename(const String &p_name) {
|
||||||
|
|
||||||
|
|
||||||
|
if (p_name.find("/")!=-1 || p_name.find(":")!=-1 || p_name=="") {
|
||||||
|
message->set_text("Invalid Action (Anything goes but / or :).");
|
||||||
|
message->popup_centered(Size2(300,100));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String new_name = "input/"+p_name;
|
||||||
|
|
||||||
|
if (Globals::get_singleton()->has(new_name)) {
|
||||||
|
message->set_text("Action '"+p_name+"' already exists!.");
|
||||||
|
message->popup_centered(Size2(300,100));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int order = Globals::get_singleton()->get_order(add_at);
|
||||||
|
Array va = Globals::get_singleton()->get(add_at);
|
||||||
|
bool persisting = Globals::get_singleton()->is_persisting(add_at);
|
||||||
|
|
||||||
|
undo_redo->create_action("Rename Input Action Event");
|
||||||
|
undo_redo->add_do_method(Globals::get_singleton(),"clear",add_at);
|
||||||
|
undo_redo->add_do_method(Globals::get_singleton(),"set",new_name,va);
|
||||||
|
undo_redo->add_do_method(Globals::get_singleton(),"set_persisting",new_name,persisting);
|
||||||
|
undo_redo->add_do_method(Globals::get_singleton(),"set_order",new_name,order);
|
||||||
|
undo_redo->add_undo_method(Globals::get_singleton(),"clear",new_name);
|
||||||
|
undo_redo->add_undo_method(Globals::get_singleton(),"set",add_at,va);
|
||||||
|
undo_redo->add_undo_method(Globals::get_singleton(),"set_persisting",add_at,persisting);
|
||||||
|
undo_redo->add_undo_method(Globals::get_singleton(),"set_order",add_at,order);
|
||||||
|
undo_redo->add_do_method(this,"_update_actions");
|
||||||
|
undo_redo->add_undo_method(this,"_update_actions");
|
||||||
|
undo_redo->add_do_method(this,"_settings_changed");
|
||||||
|
undo_redo->add_undo_method(this,"_settings_changed");
|
||||||
|
undo_redo->commit_action();
|
||||||
|
|
||||||
|
rename_action->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
|
void ProjectSettings::_item_checked(const String& p_item, bool p_check) {
|
||||||
|
|
||||||
@ -1219,6 +1268,7 @@ void ProjectSettings::_bind_methods() {
|
|||||||
ObjectTypeDB::bind_method(_MD("_action_adds"),&ProjectSettings::_action_adds);
|
ObjectTypeDB::bind_method(_MD("_action_adds"),&ProjectSettings::_action_adds);
|
||||||
ObjectTypeDB::bind_method(_MD("_action_persist_toggle"),&ProjectSettings::_action_persist_toggle);
|
ObjectTypeDB::bind_method(_MD("_action_persist_toggle"),&ProjectSettings::_action_persist_toggle);
|
||||||
ObjectTypeDB::bind_method(_MD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
|
ObjectTypeDB::bind_method(_MD("_action_button_pressed"),&ProjectSettings::_action_button_pressed);
|
||||||
|
ObjectTypeDB::bind_method(_MD("_action_rename"),&ProjectSettings::_action_rename);
|
||||||
ObjectTypeDB::bind_method(_MD("_update_actions"),&ProjectSettings::_update_actions);
|
ObjectTypeDB::bind_method(_MD("_update_actions"),&ProjectSettings::_update_actions);
|
||||||
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&ProjectSettings::_wait_for_key);
|
ObjectTypeDB::bind_method(_MD("_wait_for_key"),&ProjectSettings::_wait_for_key);
|
||||||
ObjectTypeDB::bind_method(_MD("_add_item"),&ProjectSettings::_add_item);
|
ObjectTypeDB::bind_method(_MD("_add_item"),&ProjectSettings::_add_item);
|
||||||
@ -1438,12 +1488,17 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
|
|||||||
add_child(popup_add);
|
add_child(popup_add);
|
||||||
popup_add->connect("item_pressed",this,"_add_item");
|
popup_add->connect("item_pressed",this,"_add_item");
|
||||||
|
|
||||||
|
rename_action = memnew( EditorNameDialog );
|
||||||
|
add_child(rename_action);
|
||||||
|
rename_action->set_hide_on_ok(false);
|
||||||
|
rename_action->set_size(Size2(200, 70));
|
||||||
|
rename_action->set_title("Rename Input Action");
|
||||||
|
rename_action->connect("name_confirmed", this,"_action_rename");
|
||||||
|
|
||||||
press_a_key = memnew( ConfirmationDialog );
|
press_a_key = memnew( ConfirmationDialog );
|
||||||
press_a_key->set_focus_mode(FOCUS_ALL);
|
press_a_key->set_focus_mode(FOCUS_ALL);
|
||||||
add_child(press_a_key);
|
add_child(press_a_key);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
l = memnew( Label );
|
l = memnew( Label );
|
||||||
l->set_text("Press a Key..");
|
l->set_text("Press a Key..");
|
||||||
l->set_area_as_parent_rect();
|
l->set_area_as_parent_rect();
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "optimized_save_dialog.h"
|
#include "optimized_save_dialog.h"
|
||||||
#include "undo_redo.h"
|
#include "undo_redo.h"
|
||||||
#include "editor_data.h"
|
#include "editor_data.h"
|
||||||
|
#include "editor_name_dialog.h"
|
||||||
//#include "project_export_settings.h"
|
//#include "project_export_settings.h"
|
||||||
|
|
||||||
class ProjectSettings : public AcceptDialog {
|
class ProjectSettings : public AcceptDialog {
|
||||||
@ -66,6 +67,8 @@ class ProjectSettings : public AcceptDialog {
|
|||||||
Label *device_index_label;
|
Label *device_index_label;
|
||||||
MenuButton *popup_platform;
|
MenuButton *popup_platform;
|
||||||
|
|
||||||
|
EditorNameDialog *rename_action;
|
||||||
|
|
||||||
LineEdit *action_name;
|
LineEdit *action_name;
|
||||||
Tree *input_editor;
|
Tree *input_editor;
|
||||||
bool setting;
|
bool setting;
|
||||||
@ -106,6 +109,7 @@ class ProjectSettings : public AcceptDialog {
|
|||||||
|
|
||||||
void _action_adds(String);
|
void _action_adds(String);
|
||||||
void _action_add();
|
void _action_add();
|
||||||
|
void _action_rename(const String& p_name);
|
||||||
void _device_input_add();
|
void _device_input_add();
|
||||||
|
|
||||||
void _item_checked(const String& p_item, bool p_check);
|
void _item_checked(const String& p_item, bool p_check);
|
||||||
|
Loading…
Reference in New Issue
Block a user