diff options
Diffstat (limited to 'tools/editor/project_settings.cpp')
-rw-r--r-- | tools/editor/project_settings.cpp | 105 |
1 files changed, 68 insertions, 37 deletions
diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 6be1abf52f..02d95abfa2 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -245,7 +245,7 @@ void ProjectSettings::_device_input_add() { undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->commit_action(); - + _show_last_added(ie); } @@ -283,7 +283,34 @@ void ProjectSettings::_press_a_key_confirm() { undo_redo->add_undo_method(this,"_settings_changed"); undo_redo->commit_action(); + _show_last_added(ie); +} + +void ProjectSettings::_show_last_added(const InputEvent& p_event) { + TreeItem *r = input_editor->get_root(); + if (!r) + return; + r=r->get_children(); + if (!r) + return; + bool found = false; + while(r){ + TreeItem *child = r->get_children(); + while(child){ + Variant input = child->get_meta("__input"); + if (p_event==input){ + child->select(0); + found = true; + break; + } + child=child->get_next(); + } + if (found) break; + r=r->get_next(); + } + + if (found) input_editor->ensure_cursor_is_visible(); } void ProjectSettings::_wait_for_key(const InputEvent& p_event) { @@ -337,7 +364,7 @@ void ProjectSettings::_add_item(int p_item){ device_index->add_item(TTR("Button 7")); device_index->add_item(TTR("Button 8")); device_index->add_item(TTR("Button 9")); - device_input->popup_centered(Size2(350,95)); + device_input->popup_centered_minsize(Size2(350,95)); } break; case InputEvent::JOYSTICK_MOTION: { @@ -349,12 +376,12 @@ void ProjectSettings::_add_item(int p_item){ String desc = _axis_names[i]; device_index->add_item(TTR("Axis")+" "+itos(i/2)+" "+(i&1?"+":"-")+desc); } - device_input->popup_centered(Size2(350,95)); + device_input->popup_centered_minsize(Size2(350,95)); } break; case InputEvent::JOYSTICK_BUTTON: { - device_id->set_val(0); + device_id->set_val(3); device_index_label->set_text(TTR("Joystick Button Index:")); device_index->clear(); @@ -362,7 +389,7 @@ void ProjectSettings::_add_item(int p_item){ device_index->add_item(itos(i)+": "+String(_button_names[i])); } - device_input->popup_centered(Size2(350,95)); + device_input->popup_centered_minsize(Size2(350,95)); } break; default:{} @@ -543,6 +570,7 @@ void ProjectSettings::_update_actions() { } action->add_button(0,get_icon("Remove","EditorIcons"),2); action->set_metadata(0,i); + action->set_meta("__input", ie); } } } @@ -1375,34 +1403,35 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { input_base->set_area_as_parent_rect();; tab_container->add_child(input_base); + VBoxContainer *vbc = memnew( VBoxContainer ); + input_base->add_child(vbc); + vbc->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 5 ); + vbc->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 5 ); + vbc->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 ); + vbc->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 ); + l = memnew( Label ); - input_base->add_child(l); + vbc->add_child(l); l->set_pos(Point2(6,5)); l->set_text(TTR("Action:")); + hbc = memnew( HBoxContainer ); + vbc->add_child(hbc); + action_name = memnew( LineEdit ); - action_name->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO); - action_name->set_begin( Point2(5,25) ); - action_name->set_end( Point2(0.85,26) ); - input_base->add_child(action_name); + action_name->set_h_size_flags(SIZE_EXPAND_FILL); + hbc->add_child(action_name); action_name->connect("text_entered",this,"_action_adds"); add = memnew( Button ); - input_base->add_child(add); - add->set_anchor(MARGIN_LEFT,ANCHOR_RATIO); - add->set_begin( Point2(0.86,25) ); - add->set_anchor(MARGIN_RIGHT,ANCHOR_END); - add->set_end( Point2(5,26) ); + hbc->add_child(add); + add->set_custom_minimum_size(Size2(150, 0)); add->set_text(TTR("Add")); add->connect("pressed",this,"_action_add"); input_editor = memnew( Tree ); - input_base->add_child(input_editor); - input_editor->set_area_as_parent_rect(); - input_editor->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 55 ); - input_editor->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 ); - input_editor->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 ); - input_editor->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 ); + vbc->add_child(input_editor); + input_editor->set_v_size_flags(SIZE_EXPAND_FILL); input_editor->connect("item_edited",this,"_action_edited"); input_editor->connect("cell_selected",this,"_action_selected"); input_editor->connect("button_pressed",this,"_action_button_pressed"); @@ -1431,30 +1460,32 @@ ProjectSettings::ProjectSettings(EditorData *p_data) { device_input->get_ok()->set_text(TTR("Add")); device_input->connect("confirmed",this,"_device_input_add"); - l = memnew( Label ); - l->set_text(TTR("Device:")); - l->set_pos(Point2(15,10)); - device_input->add_child(l); + hbc = memnew( HBoxContainer ); + device_input->add_child(hbc); + device_input->set_child_rect(hbc); + + VBoxContainer *vbc_left = memnew( VBoxContainer ); + hbc->add_child(vbc_left); l = memnew( Label ); - l->set_text(TTR("Index:")); - l->set_pos(Point2(90,10)); - device_input->add_child(l); - device_index_label=l; + l->set_text(TTR("Device:")); + vbc_left->add_child(l); device_id = memnew( SpinBox ); - device_id->set_pos(Point2(20,30)); - device_id->set_size(Size2(70,10)); device_id->set_val(0); + vbc_left->add_child(device_id); - device_input->add_child(device_id); + VBoxContainer *vbc_right = memnew( VBoxContainer ); + hbc->add_child(vbc_right); + vbc_right->set_h_size_flags(SIZE_EXPAND_FILL); - device_index = memnew( OptionButton ); - device_index->set_pos(Point2(95,30)); - device_index->set_size(Size2(300,10)); - device_index->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10); + l = memnew( Label ); + l->set_text(TTR("Index:")); + vbc_right->add_child(l); + device_index_label=l; - device_input->add_child(device_index); + device_index = memnew( OptionButton ); + vbc_right->add_child(device_index); /* save = memnew( Button ); |