From 818c21ecac7fe79ebb2a5924294618ed5c6360bd Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Sun, 1 Sep 2024 06:13:06 +0300 Subject: [PATCH] Line filter is implemented --- godot/main/editor.tscn | 321 +++++++++++++++-------- src/modules/stream/road_lines_editor.cpp | 154 +++++++++-- src/modules/stream/road_lines_editor.h | 5 + 3 files changed, 348 insertions(+), 132 deletions(-) diff --git a/godot/main/editor.tscn b/godot/main/editor.tscn index f0d5308..a2cf48b 100644 --- a/godot/main/editor.tscn +++ b/godot/main/editor.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://main/editor.gd" type="Script" id=1] [ext_resource path="res://terrain/terrain_draw.png" type="Image" id=2] @@ -44,6 +44,9 @@ extents = Vector3( 50, 1, 50 ) [sub_resource type="CubeMesh" id=13] size = Vector3( 4, 4, 120 ) +[sub_resource type="CubeMesh" id=14] +size = Vector3( 3, 60, 3 ) + [node name="editor" type="Spatial"] script = ExtResource( 1 ) @@ -53,10 +56,10 @@ script = ExtResource( 1 ) anchor_left = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = -160.0 +margin_left = -232.0 [node name="ColorRect" type="ColorRect" parent="VBoxContainer"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 30.0 rect_min_size = Vector2( 160, 30 ) size_flags_horizontal = 3 @@ -77,58 +80,58 @@ valign = 1 [node name="select_buildings" type="Button" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 34.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 54.0 text = "Buildings Mode" [node name="select_navigation" type="Button" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 58.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 78.0 text = "Navigation Mode" [node name="select_poi" type="Button" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 82.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 102.0 text = "POI Mode" [node name="select_road_lines" type="Button" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 106.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 126.0 text = "Road Lines Mode" [node name="select_npc" type="Button" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 130.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 150.0 text = "NPC Mode" [node name="v_buildings" type="VBoxContainer" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 154.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 274.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_buildings"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 4.0 [node name="Label" type="Label" parent="VBoxContainer/v_buildings"] margin_top = 8.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 22.0 text = "Buildings mode" [node name="buildings_edit_mode" type="OptionButton" parent="VBoxContainer/v_buildings"] unique_name_in_owner = true margin_top = 26.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 46.0 text = "Select" items = [ "Select", null, false, 0, null, "Move", null, false, 1, null, "Rotate", null, false, 2, null ] @@ -136,193 +139,300 @@ selected = 0 [node name="Label2" type="Label" parent="VBoxContainer/v_buildings"] margin_top = 50.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 64.0 text = "Building type" [node name="building_type" type="OptionButton" parent="VBoxContainer/v_buildings"] unique_name_in_owner = true margin_top = 68.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 88.0 text = "Building Type" [node name="HSeparator2" type="HSeparator" parent="VBoxContainer/v_buildings"] margin_top = 92.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 96.0 [node name="buildings_save" type="Button" parent="VBoxContainer/v_buildings"] unique_name_in_owner = true margin_top = 100.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 120.0 text = "Save Buildings" [node name="v_navigation" type="VBoxContainer" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 278.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 300.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_navigation"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 4.0 [node name="Label" type="Label" parent="VBoxContainer/v_navigation"] margin_top = 8.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 22.0 text = "Navigation mode" [node name="v_poi" type="VBoxContainer" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 304.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 326.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_poi"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 4.0 [node name="Label" type="Label" parent="VBoxContainer/v_poi"] margin_top = 8.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 22.0 text = "POI mode" [node name="v_road_lines" type="VBoxContainer" parent="VBoxContainer"] unique_name_in_owner = true margin_top = 330.0 -margin_right = 162.0 -margin_bottom = 724.0 +margin_right = 232.0 +margin_bottom = 712.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_road_lines"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 4.0 [node name="road_lines_base" type="PanelContainer" parent="VBoxContainer/v_road_lines"] unique_name_in_owner = true margin_top = 8.0 -margin_right = 162.0 -margin_bottom = 328.0 +margin_right = 232.0 +margin_bottom = 316.0 [node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base"] margin_left = 7.0 margin_top = 7.0 -margin_right = 155.0 -margin_bottom = 313.0 +margin_right = 225.0 +margin_bottom = 301.0 size_flags_horizontal = 3 size_flags_vertical = 3 +[node name="road_lines_menu_block" type="HBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +unique_name_in_owner = true +margin_right = 218.0 +margin_bottom = 20.0 + +[node name="road_lines_file_menu" type="MenuButton" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_menu_block"] +unique_name_in_owner = true +margin_right = 35.0 +margin_bottom = 20.0 +focus_mode = 2 +text = "File" +items = [ "Save Lines", null, 0, false, false, 101, 0, null, "", false ] + +[node name="road_lines_edit_menu" type="MenuButton" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_menu_block"] +unique_name_in_owner = true +margin_left = 39.0 +margin_right = 75.0 +margin_bottom = 20.0 +focus_mode = 2 +text = "Edit" +items = [ "Undo", null, 0, false, false, 201, 0, null, "", false ] + +[node name="road_lines_point_menu" type="MenuButton" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_menu_block"] +unique_name_in_owner = true +margin_left = 79.0 +margin_right = 124.0 +margin_bottom = 20.0 +text = "Point" +items = [ "", null, 0, false, false, 0, 0, null, "", true, "Create", null, 0, false, false, 11, 0, null, "", false, "Remove", null, 0, false, false, 12, 0, null, "", false, "", null, 0, false, false, 3, 0, null, "", true, "Point To Cursor", null, 0, false, false, 51, 0, null, "", false, "Cursor To Point", null, 0, false, false, 52, 0, null, "", false, "Item 6", null, 0, false, false, 6, 0, null, "", false, "Item 7", null, 0, false, false, 7, 0, null, "", false ] + +[node name="road_lines_line_menu" type="MenuButton" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_menu_block"] +unique_name_in_owner = true +margin_left = 128.0 +margin_right = 167.0 +margin_bottom = 20.0 +focus_mode = 2 +text = "Line" +items = [ "Create", null, 0, false, false, 21, 0, null, "", false, "Delete", null, 0, false, false, 22, 0, null, "", false ] + +[node name="HSeparator3" type="HSeparator" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +margin_top = 24.0 +margin_right = 218.0 +margin_bottom = 28.0 + [node name="Label" type="Label" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] -margin_right = 148.0 -margin_bottom = 14.0 +margin_top = 32.0 +margin_right = 218.0 +margin_bottom = 46.0 text = "Road Lines mode" +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +margin_top = 50.0 +margin_right = 218.0 +margin_bottom = 74.0 + +[node name="Label" type="Label" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/HBoxContainer"] +margin_top = 5.0 +margin_right = 41.0 +margin_bottom = 19.0 +text = "Filter: " + +[node name="road_lines_filter" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/HBoxContainer"] +unique_name_in_owner = true +margin_left = 45.0 +margin_right = 218.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + [node name="lines_list" type="ItemList" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] unique_name_in_owner = true -margin_top = 18.0 -margin_right = 148.0 -margin_bottom = 118.0 -rect_min_size = Vector2( 0, 100 ) +margin_top = 78.0 +margin_right = 218.0 +margin_bottom = 158.0 +rect_min_size = Vector2( 0, 80 ) size_flags_horizontal = 3 [node name="line_index" type="SpinBox" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] unique_name_in_owner = true -margin_top = 122.0 -margin_right = 148.0 -margin_bottom = 146.0 - -[node name="road_lines_set_point" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] -unique_name_in_owner = true -margin_top = 150.0 -margin_right = 148.0 -margin_bottom = 170.0 -text = "Set Point To Cursor" - -[node name="road_lines_move_cursor" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] -unique_name_in_owner = true -margin_top = 174.0 -margin_right = 148.0 -margin_bottom = 194.0 -text = "Move Cursor To Point" +margin_top = 162.0 +margin_right = 218.0 +margin_bottom = 186.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +margin_top = 190.0 +margin_right = 218.0 +margin_bottom = 194.0 + +[node name="Label2" type="Label" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] margin_top = 198.0 -margin_right = 148.0 -margin_bottom = 202.0 +margin_right = 218.0 +margin_bottom = 212.0 +text = "Cursor position" -[node name="road_lines_create_point" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +[node name="road_lines_cursor_position" type="VBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] unique_name_in_owner = true -margin_top = 206.0 -margin_right = 148.0 -margin_bottom = 226.0 -text = "Create Point" +margin_top = 216.0 +margin_right = 218.0 +margin_bottom = 240.0 -[node name="road_lines_remove_point" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_cursor_position"] +margin_right = 218.0 +margin_bottom = 24.0 + +[node name="cursor_x" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_cursor_position/HBoxContainer"] unique_name_in_owner = true -margin_top = 230.0 -margin_right = 148.0 -margin_bottom = 250.0 -text = "Remove Point" +margin_right = 58.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 -[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] -margin_top = 254.0 -margin_right = 148.0 -margin_bottom = 258.0 - -[node name="road_lines_create_new_line" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +[node name="cursor_y" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_cursor_position/HBoxContainer"] unique_name_in_owner = true -margin_top = 262.0 -margin_right = 148.0 -margin_bottom = 282.0 -text = "Creeate New Line" +margin_left = 62.0 +margin_right = 120.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 -[node name="road_lines_delete_line" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +[node name="cursor_z" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_cursor_position/HBoxContainer"] unique_name_in_owner = true -margin_top = 286.0 -margin_right = 148.0 -margin_bottom = 306.0 -text = "Delete Line" +margin_left = 124.0 +margin_right = 182.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + +[node name="road_lines_set_cursor_position" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_cursor_position/HBoxContainer"] +unique_name_in_owner = true +margin_left = 186.0 +margin_right = 218.0 +margin_bottom = 24.0 +text = "Set" + +[node name="HSeparator4" type="HSeparator" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +margin_top = 244.0 +margin_right = 218.0 +margin_bottom = 248.0 + +[node name="Label3" type="Label" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +margin_top = 252.0 +margin_right = 218.0 +margin_bottom = 266.0 +text = "Point position" + +[node name="road_lines_point_position" type="VBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer"] +unique_name_in_owner = true +margin_top = 270.0 +margin_right = 218.0 +margin_bottom = 294.0 + +[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_point_position"] +margin_right = 218.0 +margin_bottom = 24.0 + +[node name="point_x" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_point_position/HBoxContainer2"] +unique_name_in_owner = true +margin_right = 58.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + +[node name="point_y" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_point_position/HBoxContainer2"] +unique_name_in_owner = true +margin_left = 62.0 +margin_right = 120.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + +[node name="point_z" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_point_position/HBoxContainer2"] +unique_name_in_owner = true +margin_left = 124.0 +margin_right = 182.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 + +[node name="road_lines_set_point_position" type="Button" parent="VBoxContainer/v_road_lines/road_lines_base/VBoxContainer/road_lines_point_position/HBoxContainer2"] +unique_name_in_owner = true +margin_left = 186.0 +margin_right = 218.0 +margin_bottom = 24.0 +text = "Set" [node name="road_lines_create_new_line_dlg" type="PanelContainer" parent="VBoxContainer/v_road_lines"] unique_name_in_owner = true -margin_top = 332.0 -margin_right = 162.0 -margin_bottom = 394.0 +margin_top = 320.0 +margin_right = 232.0 +margin_bottom = 382.0 [node name="v" type="VBoxContainer" parent="VBoxContainer/v_road_lines/road_lines_create_new_line_dlg"] margin_left = 7.0 margin_top = 7.0 -margin_right = 155.0 +margin_right = 225.0 margin_bottom = 55.0 [node name="road_lines_create_new_line_name" type="LineEdit" parent="VBoxContainer/v_road_lines/road_lines_create_new_line_dlg/v"] unique_name_in_owner = true -margin_right = 148.0 +margin_right = 218.0 margin_bottom = 24.0 [node name="road_lines_create_new_cancel" type="Button" parent="VBoxContainer/v_road_lines/road_lines_create_new_line_dlg/v"] unique_name_in_owner = true margin_top = 28.0 -margin_right = 148.0 +margin_right = 218.0 margin_bottom = 48.0 text = "Cancel" [node name="v_npc" type="VBoxContainer" parent="VBoxContainer"] unique_name_in_owner = true -margin_top = 728.0 -margin_right = 162.0 -margin_bottom = 750.0 +margin_top = 716.0 +margin_right = 232.0 +margin_bottom = 738.0 [node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_npc"] -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 4.0 [node name="Label" type="Label" parent="VBoxContainer/v_npc"] margin_top = 8.0 -margin_right = 162.0 +margin_right = 232.0 margin_bottom = 22.0 text = "NPC mode" @@ -367,20 +477,6 @@ monitoring = false transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0 ) shape = SubResource( 12 ) -[node name="line_cursor" type="MeshInstance" parent="."] -unique_name_in_owner = true -mesh = SubResource( 10 ) -material/0 = SubResource( 11 ) - -[node name="Area" type="Area" parent="line_cursor"] -collision_layer = 32768 -collision_mask = 32768 -monitoring = false - -[node name="CollisionShape" type="CollisionShape" parent="line_cursor/Area"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0 ) -shape = SubResource( 12 ) - [node name="building_rot_cursor" type="Spatial" parent="."] [node name="building_rot_cursor" type="MeshInstance" parent="building_rot_cursor"] @@ -397,3 +493,20 @@ monitoring = false [node name="CollisionShape" type="CollisionShape" parent="building_rot_cursor/building_rot_cursor/Area"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0 ) shape = SubResource( 12 ) + +[node name="line_cursor" type="Spatial" parent="."] +unique_name_in_owner = true + +[node name="Area" type="Area" parent="line_cursor"] +collision_layer = 32768 +collision_mask = 32768 +monitoring = false + +[node name="CollisionShape" type="CollisionShape" parent="line_cursor/Area"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0 ) +shape = SubResource( 12 ) + +[node name="mi" type="MeshInstance" parent="line_cursor"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 30, 0 ) +mesh = SubResource( 14 ) +material/0 = SubResource( 11 ) diff --git a/src/modules/stream/road_lines_editor.cpp b/src/modules/stream/road_lines_editor.cpp index bf7980d..513ad2b 100644 --- a/src/modules/stream/road_lines_editor.cpp +++ b/src/modules/stream/road_lines_editor.cpp @@ -5,11 +5,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include "world_editor.h" #include "from_string.h" #include "road_lines_editor.h" @@ -75,19 +77,23 @@ public: : Object() , editor(editor) { - Node *lines_list_node = - editor->scene()->get_node(NodePath("%lines_list")); + LineEdit *filter = + editor->get_as_node("%road_lines_filter"); + filter->connect("text_changed", this, "filter_handler"); + filter->connect("text_entered", this, "filter_handler"); ItemList *lines_list = - Object::cast_to(lines_list_node); + editor->get_as_node("%lines_list"); lines_list->connect("item_selected", this, "handler"); } virtual ~HandleSelection() { - Node *lines_list_node = - editor->scene()->get_node(NodePath("%lines_list")); ItemList *lines_list = - Object::cast_to(lines_list_node); + editor->get_as_node("%lines_list"); lines_list->disconnect("item_selected", this, "handler"); + LineEdit *filter = + editor->get_as_node("%road_lines_filter"); + filter->disconnect("text_entered", this, "filter_handler"); + filter->disconnect("text_changed", this, "filter_handler"); } protected: @@ -95,16 +101,20 @@ protected: { if (index < 0) return; - Node *lines_list_node = - editor->scene()->get_node(NodePath("%lines_list")); ItemList *lines_list = - Object::cast_to(lines_list_node); + editor->get_as_node("%lines_list"); editor->select_line(lines_list->get_item_text(index)); } + void filter_handler(const String &text) + { + editor->line_list_filter_changed(text); + } static void _bind_methods() { ClassDB::bind_method(D_METHOD("handler", "index"), &HandleSelection::handler); + ClassDB::bind_method(D_METHOD("filter_handler", "text"), + &HandleSelection::filter_handler); } }; @@ -121,16 +131,9 @@ public: editor->get_as_node("%line_index"); sp_line_point->connect("value_changed", this, "handle_value_change"); - Button *bt_line_set_point = - editor->get_as_node