From a71917a883b3fe03616b1e84dcd855f65b6f87e1 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sun, 12 Mar 2023 00:23:30 -0500 Subject: [PATCH 01/10] Tree menu GUI for Marker Category Selection Addressing #77 --- Icon.gd | 3 + LocalData.gd | 27 +++++++ LocalData.tscn | 3 + Route.gd | 5 +- Route2D.gd | 7 ++ Route2D.tscn | 5 +- Spatial.gd | 212 +++++++++++++++++++++++++++++++++++++++---------- Spatial.tscn | 96 ++++++++++++++++------ project.godot | 1 + 9 files changed, 294 insertions(+), 65 deletions(-) create mode 100644 LocalData.gd create mode 100644 LocalData.tscn create mode 100644 Route2D.gd diff --git a/Icon.gd b/Icon.gd index 1d5dbaef..2cdd61ad 100644 --- a/Icon.gd +++ b/Icon.gd @@ -1,6 +1,9 @@ extends Sprite3D var texture_path +var category_name = "" +var is_editable = false + func set_icon_image(texture_path: String): self.texture_path = texture_path diff --git a/LocalData.gd b/LocalData.gd new file mode 100644 index 00000000..54082204 --- /dev/null +++ b/LocalData.gd @@ -0,0 +1,27 @@ +extends Node + +const LOCAL_DATA_PATH = "user://localdata.json" + +var visible_dict = {} +var _local_data + +func _ready(): + var file = File.new() + file.open(LOCAL_DATA_PATH, file.READ) + var text = file.get_as_text() + var datum = JSON.parse(text) + self._local_data = JSON.parse(text).result + load_local() + +func load_local(): + for key in self._local_data["visible_dict"].keys(): + self.visible_dict[key] = self._local_data["visible_dict"][key] + +func save_local(): + _local_data = { + "visible_dict": visible_dict + } + + var file = File.new() + file.open(LOCAL_DATA_PATH, File.WRITE) + file.store_string(JSON.print(self._local_data)) diff --git a/LocalData.tscn b/LocalData.tscn new file mode 100644 index 00000000..5ec353b0 --- /dev/null +++ b/LocalData.tscn @@ -0,0 +1,3 @@ +[gd_scene format=2] + +[node name="LocalData" type="Node"] diff --git a/Route.gd b/Route.gd index f0132264..7b46b3ee 100644 --- a/Route.gd +++ b/Route.gd @@ -1,8 +1,9 @@ extends Spatial var texture_path - +var category_name = "" var color = Color(0.9, 0.1, 0.1) +var is_editable = false var point_list := PoolVector3Array() @@ -17,6 +18,8 @@ func refresh_mesh(): for point_index in range(len(point_list)-1): var point:Vector3 = point_list[point_index] var next_point:Vector3 = point_list[point_index+1] + if point == Vector3(0,0,0) or next_point == Vector3(0,0,0): + continue var distance: float = point.distance_to(next_point) var normal: Vector3 = (next_point - point).normalized() diff --git a/Route2D.gd b/Route2D.gd new file mode 100644 index 00000000..f19e0214 --- /dev/null +++ b/Route2D.gd @@ -0,0 +1,7 @@ +extends Line2D + +var category_name = "" +var is_editable = false + +func _ready(): + pass # Replace with function body. diff --git a/Route2D.tscn b/Route2D.tscn index 5b3da3ed..8aed8671 100644 --- a/Route2D.tscn +++ b/Route2D.tscn @@ -1,4 +1,6 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://Route2D.gd" type="Script" id=1] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -27,3 +29,4 @@ material = SubResource( 2 ) points = PoolVector2Array( 0, 0, 0, 0, 0, 0 ) default_color = Color( 1, 1, 1, 1 ) texture_mode = 1 +script = ExtResource( 1 ) diff --git a/Spatial.gd b/Spatial.gd index 74c90986..a57f722b 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -20,6 +20,7 @@ var next_texture_path: String = "" # will be created. var currently_active_path = null var currently_active_path_2d = null +var currently_active_category = null var map_was_open = false @@ -54,6 +55,7 @@ func _ready(): taco_parser = TacoParser.new() x11_window_id_burrito = OS.get_native_handle(OS.WINDOW_HANDLE) OS.window_maximized = false + print(OS.get_current_screen()) # Start off with a small size before GW2 client is up OS.window_size = Vector2(800, 600) # Postion at top left corner @@ -286,6 +288,8 @@ func reset_minimap_masks(): var markerdata = Waypoint.Waypoint.new() var marker_file_dir = "user://protobins/" var marker_file_path = "" +var marker_packs_array = Array() +onready var marker_packs = get_node("Control/Dialogs/MarkerPacks/MarkerPacks") func load_waypoint_markers(map_id): self.marker_file_path = self.marker_file_dir + String(map_id) + ".data" @@ -384,7 +388,7 @@ onready var paths = $Paths onready var minimap = $Control/MiniMap func gen_map_markers(): - # Clear all the rendered assets to mak way for the new ones + # Clear all the rendered assets to make way for the new ones for path in paths.get_children(): path.queue_free() @@ -394,6 +398,9 @@ func gen_map_markers(): for icon in icons.get_children(): icon.queue_free() + marker_packs.clear() + build_category_tree() + # Load the data from the markers for path in self.markerdata.get_trail(): var path_points := PoolVector3Array() @@ -404,7 +411,7 @@ func gen_map_markers(): path_points.append(Vector3(trail_data.get_points_x()[index], trail_data.get_points_y()[index], trail_data.get_points_z()[index])) var texture_path = path.get_texture_path() var full_texture_path = self.marker_file_dir + texture_path.get_path() - gen_new_path(path_points, full_texture_path) + gen_new_path(path_points, full_texture_path, path.get_category().get_name()) for icon in self.markerdata.get_icon(): var position = icon.get_position() if position == null: @@ -413,13 +420,81 @@ func gen_map_markers(): var position_vector = Vector3(position.get_x(), position.get_y(), position.get_z()) var texture_path = icon.get_texture_path() if texture_path == null: - print("Warning: No texture found for icon") + #Some icons have their texture in a parent of the category. continue var full_texture_path = self.marker_file_dir + texture_path.get_path() - gen_new_icon(position_vector, full_texture_path) + gen_new_icon(position_vector, full_texture_path, icon.get_category().get_name()) + + +onready var local_data = get_node("Control/LocalData") + +func build_category_tree(): + var root = marker_packs.create_item() + root.set_text(0, "Markers available on current map") + root.set_selectable(0, false) + root.set_text(1, "Visible") + + for category in self.markerdata.get_category(): + add_category(root, category, category.get_name(), false) + + +func add_category(item: TreeItem, category, tree_path: String, collapsed: bool): + if category.get_name() != "": + var category_item = marker_packs.create_item(item) + category_item.set_text(0,category.get_display_name()) + category_item.set_metadata(0,category) + category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) + category_item.set_checked(1, self.local_data.visible_dict.get(tree_path, false)) + category_item.set_tooltip(1, "Show/Hide") + category_item.set_editable(1, true) + category_item.set_collapsed(collapsed) + for category_child in category.get_children(): + add_category(category_item, category_child, tree_path + "." + category_child.get_name(), true) + + +func switch_selected_category(category_item: TreeItem): + var selected_category_name = find_pedigree_name(category_item, category_item.get_metadata(0).get_name()) + local_data.visible_dict[selected_category_name] = category_item.is_checked(1) + switch_checkboxes(category_item, category_item.is_checked(1)) + + node_checkmark_switch(selected_category_name, category_item, self.paths) + node_checkmark_switch(selected_category_name, category_item, self.minimap) + node_checkmark_switch(selected_category_name, category_item, self.icons) + + $Control/LocalData.save_local() + + +func find_pedigree_name(category_item: TreeItem, pedigree_name: String): + var parent = category_item.get_parent() + if parent.is_selectable(0): + pedigree_name = parent.get_metadata(0).get_name() + "." + pedigree_name + pedigree_name = find_pedigree_name(parent, pedigree_name) + return pedigree_name + + +func node_checkmark_switch(selected_category_name: String, category_item, nodes): + for node in nodes.get_children(): + if node.category_name.begins_with(selected_category_name): + local_data.visible_dict[node.category_name] = category_item.is_checked(1) + if category_item.is_checked(1): + node.show() + else: + node.hide() + + +func switch_checkboxes(item: TreeItem, checked: bool): + if item.get_cell_mode(1) == TreeItem.CELL_MODE_CHECK: + item.set_checked(1, checked) + local_data.visible_dict[find_pedigree_name(item, item.get_metadata(0).get_name())] = checked + + var child_item = item.get_children() + while child_item != null: + switch_checkboxes(child_item, checked) + child_item = child_item.get_next() + + +func gen_new_path(points: Array, texture_path: String, category_name: String): -func gen_new_path(points: Array, texture_path: String): - var points_2d: PoolVector2Array = [] # Create the texture to use from an image file # TODO: We want to be able to cache this data so that if a texture is used # by multiple objects we only need to keep ony copy of it in memory. #22. @@ -439,13 +514,15 @@ func gen_new_path(points: Array, texture_path: String): texture.create_from_image(image, 22) # Create a new 3D route - var new_route = route_scene.instance() + # var new_curve = Curve3D.new() # for point in points: # new_curve.add_point(Vector3(point[0], point[1], -point[2])) # points_2d.append(Vector2(point[0], -point[2])) - # new_path.curve = new_curve +# path_3d_markers.append(new_path) + + var new_route = route_scene.instance() new_route.texture_path = texture_path # Save the location of the image for later #path_3d_markers.append(new_path) @@ -455,29 +532,44 @@ func gen_new_path(points: Array, texture_path: String): new_route.create_mesh(points_3d) new_route.set_texture(texture) + new_route.visible = self.local_data.visible_dict.get(category_name, false) + new_route.category_name = category_name + paths.add_child(new_route) + var points_2d_array = segment_2D_paths(points) + # Create a new 2D Path + for segment in points_2d_array: + var new_2d_path = path2d_scene.instance() + new_2d_path.points = segment + new_2d_path.texture = texture + new_2d_path.visible = self.local_data.visible_dict.get(category_name, false) + new_2d_path.category_name = category_name + minimap.add_child(new_2d_path) + + +func segment_2D_paths (points: Array): + var points_2d: PoolVector2Array = [] + var points_2d_array = [] for point in points: + if point == Vector3(0,0,0): + points_2d_array.append(points_2d) + points_2d = [] + continue points_2d.append(Vector2(point[0], -point[2])) - - # Create a new 2D Path - var new_2d_path = path2d_scene.instance() - new_2d_path.points = points_2d - new_2d_path.texture = texture - minimap.add_child(new_2d_path) - - self.currently_active_path = new_route - self.currently_active_path_2d = new_2d_path + points_2d_array.append(points_2d) + return points_2d_array ################################################################################ # ################################################################################ -func gen_new_icon(position: Vector3, texture_path: String): +func gen_new_icon(position: Vector3, texture_path: String, category_name: String): position.z = -position.z var new_icon = icon_scene.instance() new_icon.translation = position new_icon.set_icon_image(texture_path) - + new_icon.visible = self.local_data.visible_dict.get(category_name, false) + new_icon.category_name = category_name #icon_markers.append(new_icon) icons.add_child(new_icon) @@ -514,7 +606,6 @@ func _on_main_menu_toggle_pressed(): func _on_FileDialog_file_selected(path): pass - ################################################################################ # The adjust nodes button creates handles at all the node points to allow for # editing of them via in-game interface. (Nodes can only be edited if the input @@ -532,22 +623,22 @@ func gen_adjustment_nodes(): var route = self.paths.get_child(index) var path2d = self.minimap.get_child(index) #var curve: Curve3D = path.curve - for i in range(route.get_point_count()): - var gizmo_position = route.get_point_position(i) + if route.is_editable: + for i in range(route.get_point_count()): + var gizmo_position = route.get_point_position(i) # Simplistic cull to prevent nodes that are too far away to be # visible from being created. Additional work can be done here # if this is not enough of an optimization in the future. - if (gizmo_position.distance_squared_to(self.correct_player_position) > 10000): - continue - - var new_gizmo = gizmo_scene.instance() - new_gizmo.translation = gizmo_position - new_gizmo.link_point("path", route, path2d, i) - new_gizmo.connect("selected", self, "on_gizmo_selected") - new_gizmo.connect("deselected", self, "on_gizmo_deselected") - $Gizmos.add_child(new_gizmo) - + if (gizmo_position.distance_squared_to(self.correct_player_position) > 10000): + continue + var new_gizmo = gizmo_scene.instance() + new_gizmo.translation = gizmo_position + new_gizmo.link_point("path", route, path2d, i) + new_gizmo.connect("selected", self, "on_gizmo_selected") + new_gizmo.connect("deselected", self, "on_gizmo_deselected") + $Gizmos.add_child(new_gizmo) + for index in range(self.icons.get_child_count()): var icon = self.icons.get_child(index) var new_gizmo = gizmo_scene.instance() @@ -597,9 +688,10 @@ func _on_Dialog_hide(): func _on_LoadPath_pressed(): - var open_dialog: FileDialog = $Control/Dialogs/FileDialog - open_dialog.show() - open_dialog.set_current_dir(open_dialog.current_dir) + if $Control/Dialogs/MarkerPacks.is_visible(): + $Control/Dialogs/MarkerPacks.hide() + else: + $Control/Dialogs/MarkerPacks.show() func _on_RangesButton_pressed(): @@ -648,18 +740,27 @@ func _on_NewPath_pressed(): # Create a new icon and give it the texture ################################################################################ func _on_NewIcon_pressed(): - gen_new_icon(self.player_position, self.next_texture_path) + gen_new_icon(self.player_position, self.next_texture_path, "") # A new path point is created func _on_NewPathPoint_pressed(): if self.currently_active_path == null: - gen_new_path([self.player_position], self.next_texture_path) + gen_new_path([self.player_position], self.next_texture_path, self.currently_active_category.get_name()) else: var z_accurate_player_position = player_position z_accurate_player_position.z = -z_accurate_player_position.z self.currently_active_path.add_point(z_accurate_player_position) - self.currently_active_path_2d.add_point(Vector2(self.player_position.x, -self.player_position.z)) - + for path2d in minimap.get_children(): + if path2d.category_name == self.currently_active_path.category_name: + path2d.queue_free() + for segment in segment_2D_paths(self.currently_active_path.points()): + var new_2d_path = path2d_scene.instance() + new_2d_path.points = segment + new_2d_path.texture = self.currently_active_path.texture + new_2d_path.visible = self.currently_active_path.visibility + new_2d_path.category_name = self.currently_active_path.category_name + minimap.add_child(new_2d_path) + new_2d_path.refresh_mesh() ################################################################################ @@ -719,7 +820,7 @@ func _on_NewNodeAfter_pressed(): midpoint = ((start-end)/2) + end path.add_point(midpoint, index+1) - path2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) + #ath2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) clear_adjustment_nodes() gen_adjustment_nodes() @@ -760,3 +861,34 @@ func _on_Settings_pressed(): settings_dialog.load_settings() settings_dialog.show() + +func _on_MarkerPacks_cell_selected(): + var category_item = marker_packs.get_selected() + self.currently_active_category = category_item.get_metadata(0) + for path in self.paths.get_children(): + if path.category_name == find_pedigree_name(category_item, category_item.get_metadata(0).get_name()): + path.is_editable = true + self.currently_active_path = path + else: + path.is_editable = false + + +func _on_MarkerPacks_item_edited(): + var category_item = marker_packs.get_edited() + switch_selected_category(category_item) + + +func _on_ShowAll_pressed(): + var category_item = self.marker_packs.get_root().get_children() + while category_item != null: + category_item.set_checked(1, true) + switch_selected_category(category_item) + category_item = category_item.get_next() + + +func _on_HideAll_pressed(): + var category_item = self.marker_packs.get_root().get_children() + while category_item != null: + category_item.set_checked(1, false) + switch_selected_category(category_item) + category_item = category_item.get_next() diff --git a/Spatial.tscn b/Spatial.tscn index 825a6da9..27547567 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=2] +[gd_scene load_steps=18 format=2] [ext_resource path="res://Spatial.gd" type="Script" id=1] [ext_resource path="res://shaders/range_indicators.shader" type="Shader" id=2] @@ -12,6 +12,7 @@ [ext_resource path="res://icon_new_path.png" type="Texture" id=10] [ext_resource path="res://icon_new_point.png" type="Texture" id=11] [ext_resource path="res://SettingsDialog.gd" type="Script" id=12] +[ext_resource path="res://LocalData.gd" type="Script" id=13] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -185,18 +186,18 @@ margin_bottom = 672.0 window_title = "Open a File" mode = 0 access = 2 -current_dir = "." +current_dir = "/home/steph/Code/Projects/Burrito" current_file = "." -current_path = "." +current_path = "/home/steph/Code/Projects/Burrito/." __meta__ = { "_edit_use_anchors_": false } [node name="MainMenu" type="WindowDialog" parent="Control/Dialogs"] -margin_left = 48.1808 -margin_top = 88.7138 -margin_right = 261.181 -margin_bottom = 714.714 +margin_left = 48.0 +margin_top = 82.0 +margin_right = 268.0 +margin_bottom = 715.0 window_title = "Main Menu" resizable = true __meta__ = { @@ -211,26 +212,26 @@ __meta__ = { } [node name="VBoxContainer" type="VBoxContainer" parent="Control/Dialogs/MainMenu/ScrollContainer"] -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 284.0 size_flags_horizontal = 3 [node name="LoadPath" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 40.0 rect_min_size = Vector2( 0, 40 ) text = "Open Markers File" [node name="SavePath" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 44.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 84.0 rect_min_size = Vector2( 0, 40 ) text = "Save Markers File" [node name="HSeparator" type="HSeparator" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 88.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 92.0 [node name="PointEditor" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] @@ -243,19 +244,19 @@ text = "Editor Panel" [node name="OpenEditorQuickPanel" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 96.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 136.0 rect_min_size = Vector2( 0, 40 ) text = "Editor Panel" [node name="HSeparator3" type="HSeparator" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 140.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 144.0 [node name="Ranges" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 148.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 188.0 rect_min_size = Vector2( 0, 40 ) text = "Range Indicators" @@ -278,12 +279,12 @@ text = "Guacamole Script Editor" [node name="HSeparator4" type="HSeparator" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 192.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 196.0 [node name="Settings" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 200.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 240.0 rect_min_size = Vector2( 0, 40 ) text = "Settings" @@ -304,14 +305,14 @@ __meta__ = { [node name="ActivePath" type="CheckButton" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] visible = false -margin_top = 268.0 +margin_top = 244.0 margin_right = 213.0 -margin_bottom = 308.0 +margin_bottom = 284.0 text = "Active Path" [node name="ExitButton" type="Button" parent="Control/Dialogs/MainMenu/ScrollContainer/VBoxContainer"] margin_top = 244.0 -margin_right = 213.0 +margin_right = 220.0 margin_bottom = 284.0 rect_min_size = Vector2( 0, 40 ) text = "Exit Burrito" @@ -483,9 +484,9 @@ window_title = "Open a File" mode = 0 access = 2 filters = PoolStringArray( "*.png" ) -current_dir = "." +current_dir = "/home/steph/Code/Projects/Burrito" current_file = "." -current_path = "." +current_path = "/home/steph/Code/Projects/Burrito/." __meta__ = { "_edit_use_anchors_": false } @@ -498,9 +499,9 @@ margin_bottom = 624.833 window_title = "Save Path" resizable = true access = 2 -current_dir = "." +current_dir = "/home/steph/Code/Projects/Burrito" current_file = "." -current_path = "." +current_path = "/home/steph/Code/Projects/Burrito/." __meta__ = { "_edit_use_anchors_": false } @@ -725,6 +726,40 @@ margin_bottom = 200.0 rect_min_size = Vector2( 0, 100 ) size_flags_horizontal = 3 +[node name="MarkerPacks" type="WindowDialog" parent="Control/Dialogs"] +margin_left = 280.0 +margin_top = 105.0 +margin_right = 751.0 +margin_bottom = 486.0 +resizable = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarkerPacks" type="Tree" parent="Control/Dialogs/MarkerPacks"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 47.0 +size_flags_vertical = 3 +columns = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ShowAll" type="Button" parent="Control/Dialogs/MarkerPacks"] +margin_left = 5.0 +margin_top = 4.0 +margin_right = 115.0 +margin_bottom = 42.0 +text = "Show All" + +[node name="HideAll" type="Button" parent="Control/Dialogs/MarkerPacks"] +margin_left = 119.0 +margin_top = 4.0 +margin_right = 229.0 +margin_bottom = 42.0 +text = "Hide All" + [node name="Border" type="Control" parent="Control"] visible = false anchor_right = 1.0 @@ -792,6 +827,14 @@ anchor_bottom = 1.0 margin_top = -6.0 color = Color( 0, 0, 0, 1 ) +[node name="LocalData" type="Control" parent="Control"] +margin_right = 40.0 +margin_bottom = 40.0 +script = ExtResource( 13 ) +__meta__ = { +"_edit_use_anchors_": false +} + [node name="Paths" type="Spatial" parent="."] [node name="Icons" type="Spatial" parent="."] @@ -854,3 +897,10 @@ material/0 = SubResource( 4 ) [connection signal="pressed" from="Control/Dialogs/SettingsDialog/GridContainer/AutoLaunchBurritoLink" to="Control/Dialogs/SettingsDialog" method="save_settings"] [connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/WinePath" to="Control/Dialogs/SettingsDialog" method="save_settings"] [connection signal="text_changed" from="Control/Dialogs/SettingsDialog/GridContainer/EnvironmentVars" to="Control/Dialogs/SettingsDialog" method="save_settings"] +[connection signal="hide" from="Control/Dialogs/MarkerPacks" to="." method="_on_Dialog_hide"] +[connection signal="cell_selected" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_MarkerPacks_cell_selected"] +[connection signal="item_edited" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_MarkerPacks_item_edited"] +[connection signal="multi_selected" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_Tree_multi_selected"] +[connection signal="tree_entered" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_Tree_tree_entered"] +[connection signal="pressed" from="Control/Dialogs/MarkerPacks/ShowAll" to="." method="_on_ShowAll_pressed"] +[connection signal="pressed" from="Control/Dialogs/MarkerPacks/HideAll" to="." method="_on_HideAll_pressed"] diff --git a/project.godot b/project.godot index c8c06b63..6df2a49b 100644 --- a/project.godot +++ b/project.godot @@ -35,6 +35,7 @@ config/icon="res://icon.png" [autoload] Settings="*res://Settings.gd" +LocalData="*res://LocalData.gd" [display] From b2803eb62a95e72d3d8b7115eb28b39dbb28ffe5 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sun, 12 Mar 2023 00:29:42 -0500 Subject: [PATCH 02/10] removing absolute path --- Spatial.tscn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spatial.tscn b/Spatial.tscn index 27547567..c79b6f3e 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -186,9 +186,9 @@ margin_bottom = 672.0 window_title = "Open a File" mode = 0 access = 2 -current_dir = "/home/steph/Code/Projects/Burrito" +current_dir = "." current_file = "." -current_path = "/home/steph/Code/Projects/Burrito/." +current_path = "." __meta__ = { "_edit_use_anchors_": false } From 97ef50c39a58cf931565c5d70bb301baef6d69df Mon Sep 17 00:00:00 2001 From: klingbolt Date: Sun, 12 Mar 2023 18:16:12 -0400 Subject: [PATCH 03/10] Removed other path references --- Spatial.gd | 7 ++++++- Spatial.tscn | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index a57f722b..50956ad7 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -820,7 +820,7 @@ func _on_NewNodeAfter_pressed(): midpoint = ((start-end)/2) + end path.add_point(midpoint, index+1) - #ath2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) + #path2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) clear_adjustment_nodes() gen_adjustment_nodes() @@ -871,6 +871,11 @@ func _on_MarkerPacks_cell_selected(): self.currently_active_path = path else: path.is_editable = false + for icon in self.icons.get_children(): + if icon.category_name == find_pedigree_name(category_item, category_item.get_metadata(0).get_name()): + icon.is_editable = true + else: + icon.is_editable = false func _on_MarkerPacks_item_edited(): diff --git a/Spatial.tscn b/Spatial.tscn index c79b6f3e..a5cd171f 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -484,9 +484,9 @@ window_title = "Open a File" mode = 0 access = 2 filters = PoolStringArray( "*.png" ) -current_dir = "/home/steph/Code/Projects/Burrito" +current_dir = "." current_file = "." -current_path = "/home/steph/Code/Projects/Burrito/." +current_path = "." __meta__ = { "_edit_use_anchors_": false } @@ -499,9 +499,9 @@ margin_bottom = 624.833 window_title = "Save Path" resizable = true access = 2 -current_dir = "/home/steph/Code/Projects/Burrito" +current_dir = "." current_file = "." -current_path = "/home/steph/Code/Projects/Burrito/." +current_path = "." __meta__ = { "_edit_use_anchors_": false } From f6c6b3b0761e95d356fa45252ee607b6e8cdd171 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Tue, 18 Jul 2023 00:05:26 -0400 Subject: [PATCH 04/10] Addressing code review --- Icon.gd | 5 +- LocalData.gd | 27 ------ LocalData.tscn | 3 - Route.gd | 7 +- Route2D.gd | 7 -- Settings.gd | 8 +- Spatial.gd | 247 +++++++++++++++++++++++-------------------------- Spatial.tscn | 32 ++----- 8 files changed, 141 insertions(+), 195 deletions(-) delete mode 100644 LocalData.gd delete mode 100644 LocalData.tscn delete mode 100644 Route2D.gd diff --git a/Icon.gd b/Icon.gd index 2cdd61ad..c2af00cb 100644 --- a/Icon.gd +++ b/Icon.gd @@ -1,8 +1,9 @@ extends Sprite3D +var Waypoint = preload("res://waypoint.gd") + var texture_path -var category_name = "" -var is_editable = false +var waypoint = Waypoint.Icon.new() func set_icon_image(texture_path: String): self.texture_path = texture_path diff --git a/LocalData.gd b/LocalData.gd deleted file mode 100644 index 54082204..00000000 --- a/LocalData.gd +++ /dev/null @@ -1,27 +0,0 @@ -extends Node - -const LOCAL_DATA_PATH = "user://localdata.json" - -var visible_dict = {} -var _local_data - -func _ready(): - var file = File.new() - file.open(LOCAL_DATA_PATH, file.READ) - var text = file.get_as_text() - var datum = JSON.parse(text) - self._local_data = JSON.parse(text).result - load_local() - -func load_local(): - for key in self._local_data["visible_dict"].keys(): - self.visible_dict[key] = self._local_data["visible_dict"][key] - -func save_local(): - _local_data = { - "visible_dict": visible_dict - } - - var file = File.new() - file.open(LOCAL_DATA_PATH, File.WRITE) - file.store_string(JSON.print(self._local_data)) diff --git a/LocalData.tscn b/LocalData.tscn deleted file mode 100644 index 5ec353b0..00000000 --- a/LocalData.tscn +++ /dev/null @@ -1,3 +0,0 @@ -[gd_scene format=2] - -[node name="LocalData" type="Node"] diff --git a/Route.gd b/Route.gd index 7b46b3ee..aafac4fc 100644 --- a/Route.gd +++ b/Route.gd @@ -1,9 +1,10 @@ extends Spatial +var Waypoint = preload("res://waypoint.gd") + var texture_path -var category_name = "" var color = Color(0.9, 0.1, 0.1) -var is_editable = false +var waypoint = Waypoint.Trail.new() var point_list := PoolVector3Array() @@ -18,12 +19,12 @@ func refresh_mesh(): for point_index in range(len(point_list)-1): var point:Vector3 = point_list[point_index] var next_point:Vector3 = point_list[point_index+1] + # If the line starts or ends at map 0, don't draw the line. if point == Vector3(0,0,0) or next_point == Vector3(0,0,0): continue var distance: float = point.distance_to(next_point) var normal: Vector3 = (next_point - point).normalized() - #print(normal) var horizontal_tangent:Vector3 = Vector3(normal.z, 0, -normal.x).normalized() normal = Vector3(0,0,0) diff --git a/Route2D.gd b/Route2D.gd deleted file mode 100644 index f19e0214..00000000 --- a/Route2D.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends Line2D - -var category_name = "" -var is_editable = false - -func _ready(): - pass # Replace with function body. diff --git a/Settings.gd b/Settings.gd index 2d315cbd..880dcd61 100644 --- a/Settings.gd +++ b/Settings.gd @@ -3,6 +3,7 @@ extends Node const CONFIG_PATH = "user://settings.json" var _config_data = {} +var local_category_data = {} var override_size_enabled: bool = false; var override_size_height: int = 1080 @@ -22,6 +23,10 @@ func _ready(): if self._config_data == null: self._config_data = {} + + if "local_category_data" in self._config_data: + for key in self._config_data["local_category_data"].keys(): + self.local_category_data[key] = self._config_data["local_category_data"][key] if "override_size_enabled" in self._config_data: self.override_size_enabled = self._config_data["override_size_enabled"] @@ -45,8 +50,9 @@ func save(): "burrito_link_auto_launch_enabled": burrito_link_auto_launch_enabled, "burrito_link_wine_path": burrito_link_wine_path, "burrito_link_env_args": burrito_link_env_args, + "local_category_data": local_category_data } var file = File.new() file.open(CONFIG_PATH, File.WRITE) - file.store_string(JSON.print(self._config_data)) + file.store_string(JSON.print(self._config_data, " ")) diff --git a/Spatial.gd b/Spatial.gd index 50956ad7..f30e57a3 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -55,7 +55,6 @@ func _ready(): taco_parser = TacoParser.new() x11_window_id_burrito = OS.get_native_handle(OS.WINDOW_HANDLE) OS.window_maximized = false - print(OS.get_current_screen()) # Start off with a small size before GW2 client is up OS.window_size = Vector2(800, 600) # Postion at top left corner @@ -289,7 +288,7 @@ var markerdata = Waypoint.Waypoint.new() var marker_file_dir = "user://protobins/" var marker_file_path = "" var marker_packs_array = Array() -onready var marker_packs = get_node("Control/Dialogs/MarkerPacks/MarkerPacks") +onready var marker_packs = $Control/Dialogs/MarkerPacks/MarkerPacks func load_waypoint_markers(map_id): self.marker_file_path = self.marker_file_dir + String(map_id) + ".data" @@ -405,13 +404,19 @@ func gen_map_markers(): for path in self.markerdata.get_trail(): var path_points := PoolVector3Array() var trail_data = path.get_trail_data() - if trail_data.get_points_x().size() != trail_data.get_points_y().size() or trail_data.get_points_x().size() != trail_data.get_points_z().size() - print("Warning: Trail ", trail.get_category.get_name(), " does not have equal number of X, Y, and Z coordinates.") + if trail_data.get_points_x().size() != trail_data.get_points_y().size() or trail_data.get_points_x().size() != trail_data.get_points_z().size(): + print("Warning: Trail ", trail_data.get_category.get_name(), " does not have equal number of X, Y, and Z coordinates.") for index in range(0, trail_data.get_points_z().size()): path_points.append(Vector3(trail_data.get_points_x()[index], trail_data.get_points_y()[index], trail_data.get_points_z()[index])) var texture_path = path.get_texture_path() + if texture_path == null: + print("Warning: No texture found in " , path.get_category().name()) + continue var full_texture_path = self.marker_file_dir + texture_path.get_path() - gen_new_path(path_points, full_texture_path, path.get_category().get_name()) + #TODO This tree look up is unnescary if we make path a child of Category in protobuf + var split_name = path.get_category().get_name().split(".") + var category_item = search_category_tree(split_name.size(), split_name, self.marker_packs.get_root()) + gen_new_path(path_points, full_texture_path, path, category_item) for icon in self.markerdata.get_icon(): var position = icon.get_position() if position == null: @@ -420,13 +425,25 @@ func gen_map_markers(): var position_vector = Vector3(position.get_x(), position.get_y(), position.get_z()) var texture_path = icon.get_texture_path() if texture_path == null: - #Some icons have their texture in a parent of the category. + print("Warning: No texture found in " , icon.get_category().name()) continue var full_texture_path = self.marker_file_dir + texture_path.get_path() - gen_new_icon(position_vector, full_texture_path, icon.get_category().get_name()) - - -onready var local_data = get_node("Control/LocalData") + #TODO This tree look up is unnescary if we make path a child of Category in protobuf + var split_name = icon.get_category().get_name().split(".") + var category_item = search_category_tree(split_name.size(), split_name, self.marker_packs.get_root()) + gen_new_icon(position_vector, full_texture_path, icon, category_item) + +func search_category_tree(index, split_name, category_item): + if index == split_name.size(): + return category_item + var child_item = category_item.get_children() + while child_item != null: + if child_item.metadata(0) == split_name[index]: + print(child_item.metadata(0)) + return search_category_tree(index + 1, split_name, child_item) + category_item.next() + print("No category found for ", split_name) + return null func build_category_tree(): var root = marker_packs.create_item() @@ -435,65 +452,83 @@ func build_category_tree(): root.set_text(1, "Visible") for category in self.markerdata.get_category(): + marker_packs_array.append(category.get_name()) add_category(root, category, category.get_name(), false) - -func add_category(item: TreeItem, category, tree_path: String, collapsed: bool): - if category.get_name() != "": - var category_item = marker_packs.create_item(item) - category_item.set_text(0,category.get_display_name()) - category_item.set_metadata(0,category) - category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) - category_item.set_checked(1, self.local_data.visible_dict.get(tree_path, false)) - category_item.set_tooltip(1, "Show/Hide") - category_item.set_editable(1, true) - category_item.set_collapsed(collapsed) - for category_child in category.get_children(): - add_category(category_item, category_child, tree_path + "." + category_child.get_name(), true) +func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): + if category.get_name() == "": + print("Category found with no name. Full name ", full_category_name) + return + var category_item = marker_packs.create_item(item) + category_item.set_text(0,category.get_display_name()) + category_item.set_metadata(0, full_category_name) + category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) + category_item.set_checked(1, Settings.local_category_data.get(full_category_name, {}).get("checked", false)) + category_item.set_tooltip(1, "Show/Hide") + category_item.set_editable(1, true) + category_item.set_collapsed(collapsed) + for category_child in category.get_children(): + add_category(category_item, category_child, full_category_name + "." + category_child.get_name(), true) func switch_selected_category(category_item: TreeItem): - var selected_category_name = find_pedigree_name(category_item, category_item.get_metadata(0).get_name()) - local_data.visible_dict[selected_category_name] = category_item.is_checked(1) - switch_checkboxes(category_item, category_item.is_checked(1)) - - node_checkmark_switch(selected_category_name, category_item, self.paths) - node_checkmark_switch(selected_category_name, category_item, self.minimap) - node_checkmark_switch(selected_category_name, category_item, self.icons) - - $Control/LocalData.save_local() + Settings.local_category_data[category_item.get_metadata(0)] = { + "checked" : category_item.is_checked(1), + } + update_node_visibility(category_item, self.paths) + update_node_visibility(category_item, self.icons) + Settings.save() -func find_pedigree_name(category_item: TreeItem, pedigree_name: String): - var parent = category_item.get_parent() - if parent.is_selectable(0): - pedigree_name = parent.get_metadata(0).get_name() + "." + pedigree_name - pedigree_name = find_pedigree_name(parent, pedigree_name) - return pedigree_name - - -func node_checkmark_switch(selected_category_name: String, category_item, nodes): +func update_node_visibility(category_item: TreeItem, nodes): for node in nodes.get_children(): - if node.category_name.begins_with(selected_category_name): - local_data.visible_dict[node.category_name] = category_item.is_checked(1) - if category_item.is_checked(1): - node.show() + var node_name = node.waypoint.get_category().get_name() + if node_name.begins_with(category_item.get_metadata(0)): + if is_category_visible(category_item): + node.visible = true else: - node.hide() + node.visible = false + if node.get_name() == "Path": + var index = node.get_index() + var route2d = self.minimap.get_child(index) + route2d.visible= node.visible + +#Child visibility is contigent on all parents having permission +func is_category_visible(category_item: TreeItem) -> bool: + if category_item == marker_packs.get_root(): + return true + if category_item.is_checked(1): + return is_category_visible(category_item.get_parent()) + else: + return false -func switch_checkboxes(item: TreeItem, checked: bool): - if item.get_cell_mode(1) == TreeItem.CELL_MODE_CHECK: - item.set_checked(1, checked) - local_data.visible_dict[find_pedigree_name(item, item.get_metadata(0).get_name())] = checked - - var child_item = item.get_children() +func show_or_hide_all(show_or_hide: bool) : + if show_or_hide == false: + Settings.local_category_data.clear() + var category_item = self.marker_packs.get_root().get_children() + while category_item != null: + category_item.set_checked(1, show_or_hide) + change_all_categories(category_item, show_or_hide) + update_node_visibility(category_item, self.paths) + update_node_visibility(category_item, self.icons) + category_item = category_item.get_next() + Settings.save() + + +func change_all_categories(category_item: TreeItem, show_or_hide: bool): + category_item.set_checked(1, show_or_hide) + if show_or_hide == true: + Settings.local_category_data[category_item.get_metadata(0)] = { + "checked" : true, + } + var child_item = category_item.get_children() while child_item != null: - switch_checkboxes(child_item, checked) + change_all_categories(child_item, show_or_hide) child_item = child_item.get_next() -func gen_new_path(points: Array, texture_path: String, category_name: String): +func gen_new_path(points: Array, texture_path: String, waypoint_trail, category_item: TreeItem): # Create the texture to use from an image file # TODO: We want to be able to cache this data so that if a texture is used @@ -513,18 +548,8 @@ func gen_new_path(points: Array, texture_path: String, category_name: String): texture.storage = ImageTexture.STORAGE_COMPRESS_LOSSLESS texture.create_from_image(image, 22) - # Create a new 3D route - -# var new_curve = Curve3D.new() -# for point in points: -# new_curve.add_point(Vector3(point[0], point[1], -point[2])) -# points_2d.append(Vector2(point[0], -point[2])) -# new_path.curve = new_curve -# path_3d_markers.append(new_path) - var new_route = route_scene.instance() new_route.texture_path = texture_path # Save the location of the image for later - #path_3d_markers.append(new_path) var points_3d := PoolVector3Array() for point in points: @@ -532,45 +557,32 @@ func gen_new_path(points: Array, texture_path: String, category_name: String): new_route.create_mesh(points_3d) new_route.set_texture(texture) - new_route.visible = self.local_data.visible_dict.get(category_name, false) - new_route.category_name = category_name + new_route.waypoint = waypoint_trail + new_route.visible = is_category_visible(category_item) paths.add_child(new_route) - var points_2d_array = segment_2D_paths(points) # Create a new 2D Path - for segment in points_2d_array: - var new_2d_path = path2d_scene.instance() - new_2d_path.points = segment - new_2d_path.texture = texture - new_2d_path.visible = self.local_data.visible_dict.get(category_name, false) - new_2d_path.category_name = category_name - minimap.add_child(new_2d_path) - - -func segment_2D_paths (points: Array): - var points_2d: PoolVector2Array = [] - var points_2d_array = [] + var new_2d_path = path2d_scene.instance() + var points_2d := PoolVector2Array() for point in points: - if point == Vector3(0,0,0): - points_2d_array.append(points_2d) - points_2d = [] - continue points_2d.append(Vector2(point[0], -point[2])) - points_2d_array.append(points_2d) - return points_2d_array + new_2d_path.points = points_2d + new_2d_path.texture = texture + new_2d_path.visible = new_route.visible + minimap.add_child(new_2d_path) + ################################################################################ # ################################################################################ -func gen_new_icon(position: Vector3, texture_path: String, category_name: String): +func gen_new_icon(position: Vector3, texture_path: String, waypoint_icon, category_item: TreeItem): position.z = -position.z var new_icon = icon_scene.instance() new_icon.translation = position new_icon.set_icon_image(texture_path) - new_icon.visible = self.local_data.visible_dict.get(category_name, false) - new_icon.category_name = category_name - #icon_markers.append(new_icon) + new_icon.waypoint = waypoint_icon + new_icon.visible = is_category_visible(category_item) icons.add_child(new_icon) # This function take all of the currently rendered objects and converts it into @@ -623,13 +635,13 @@ func gen_adjustment_nodes(): var route = self.paths.get_child(index) var path2d = self.minimap.get_child(index) #var curve: Curve3D = path.curve - if route.is_editable: + if self.currently_active_category.get_metadata(0) == route.waypoint.get_category().get_name(): for i in range(route.get_point_count()): var gizmo_position = route.get_point_position(i) - # Simplistic cull to prevent nodes that are too far away to be - # visible from being created. Additional work can be done here - # if this is not enough of an optimization in the future. + # Simplistic cull to prevent nodes that are too far away to be + # visible from being created. Additional work can be done here + # if this is not enough of an optimization in the future. if (gizmo_position.distance_squared_to(self.correct_player_position) > 10000): continue var new_gizmo = gizmo_scene.instance() @@ -640,6 +652,7 @@ func gen_adjustment_nodes(): $Gizmos.add_child(new_gizmo) for index in range(self.icons.get_child_count()): + #TODO check for currently active category var icon = self.icons.get_child(index) var new_gizmo = gizmo_scene.instance() new_gizmo.translation = icon.translation @@ -740,27 +753,21 @@ func _on_NewPath_pressed(): # Create a new icon and give it the texture ################################################################################ func _on_NewIcon_pressed(): - gen_new_icon(self.player_position, self.next_texture_path, "") + var waypoint_icon = Waypoint.Icon.new() + waypoint_icon.set_name(self.currently_active_category.get_metadata(0)) + gen_new_icon(self.player_position, self.next_texture_path, waypoint_icon, self.currently_active_category) # A new path point is created func _on_NewPathPoint_pressed(): if self.currently_active_path == null: - gen_new_path([self.player_position], self.next_texture_path, self.currently_active_category.get_name()) + var waypoint_trail = Waypoint.Trail.new() + waypoint_trail.set_name(self.currently_active_category.get_metadata(0)) + gen_new_path([self.player_position], self.next_texture_path, waypoint_trail, self.currently_active_category) else: var z_accurate_player_position = player_position z_accurate_player_position.z = -z_accurate_player_position.z self.currently_active_path.add_point(z_accurate_player_position) - for path2d in minimap.get_children(): - if path2d.category_name == self.currently_active_path.category_name: - path2d.queue_free() - for segment in segment_2D_paths(self.currently_active_path.points()): - var new_2d_path = path2d_scene.instance() - new_2d_path.points = segment - new_2d_path.texture = self.currently_active_path.texture - new_2d_path.visible = self.currently_active_path.visibility - new_2d_path.category_name = self.currently_active_path.category_name - minimap.add_child(new_2d_path) - new_2d_path.refresh_mesh() + self.currently_active_path_2d.add_point(Vector2(self.player_position.x, -self.player_position.z)) ################################################################################ @@ -820,7 +827,7 @@ func _on_NewNodeAfter_pressed(): midpoint = ((start-end)/2) + end path.add_point(midpoint, index+1) - #path2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) + path2d.add_point(Vector2(midpoint.x, midpoint.z), index+1) clear_adjustment_nodes() gen_adjustment_nodes() @@ -864,18 +871,7 @@ func _on_Settings_pressed(): func _on_MarkerPacks_cell_selected(): var category_item = marker_packs.get_selected() - self.currently_active_category = category_item.get_metadata(0) - for path in self.paths.get_children(): - if path.category_name == find_pedigree_name(category_item, category_item.get_metadata(0).get_name()): - path.is_editable = true - self.currently_active_path = path - else: - path.is_editable = false - for icon in self.icons.get_children(): - if icon.category_name == find_pedigree_name(category_item, category_item.get_metadata(0).get_name()): - icon.is_editable = true - else: - icon.is_editable = false + self.currently_active_category = category_item func _on_MarkerPacks_item_edited(): @@ -884,16 +880,7 @@ func _on_MarkerPacks_item_edited(): func _on_ShowAll_pressed(): - var category_item = self.marker_packs.get_root().get_children() - while category_item != null: - category_item.set_checked(1, true) - switch_selected_category(category_item) - category_item = category_item.get_next() - + show_or_hide_all(true) func _on_HideAll_pressed(): - var category_item = self.marker_packs.get_root().get_children() - while category_item != null: - category_item.set_checked(1, false) - switch_selected_category(category_item) - category_item = category_item.get_next() + show_or_hide_all(false) diff --git a/Spatial.tscn b/Spatial.tscn index a5cd171f..e674a3fd 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=2] +[gd_scene load_steps=17 format=2] [ext_resource path="res://Spatial.gd" type="Script" id=1] [ext_resource path="res://shaders/range_indicators.shader" type="Shader" id=2] @@ -12,7 +12,6 @@ [ext_resource path="res://icon_new_path.png" type="Texture" id=10] [ext_resource path="res://icon_new_point.png" type="Texture" id=11] [ext_resource path="res://SettingsDialog.gd" type="Script" id=12] -[ext_resource path="res://LocalData.gd" type="Script" id=13] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -185,10 +184,9 @@ margin_right = 1307.0 margin_bottom = 672.0 window_title = "Open a File" mode = 0 -access = 2 -current_dir = "." -current_file = "." -current_path = "." +access = 1 +current_dir = "user://" +current_path = "user://" __meta__ = { "_edit_use_anchors_": false } @@ -482,11 +480,10 @@ margin_right = 1343.98 margin_bottom = 602.437 window_title = "Open a File" mode = 0 -access = 2 +access = 1 filters = PoolStringArray( "*.png" ) -current_dir = "." -current_file = "." -current_path = "." +current_dir = "user://" +current_path = "user://" __meta__ = { "_edit_use_anchors_": false } @@ -498,10 +495,9 @@ margin_right = 883.169 margin_bottom = 624.833 window_title = "Save Path" resizable = true -access = 2 -current_dir = "." -current_file = "." -current_path = "." +access = 1 +current_dir = "user://" +current_path = "user://" __meta__ = { "_edit_use_anchors_": false } @@ -827,14 +823,6 @@ anchor_bottom = 1.0 margin_top = -6.0 color = Color( 0, 0, 0, 1 ) -[node name="LocalData" type="Control" parent="Control"] -margin_right = 40.0 -margin_bottom = 40.0 -script = ExtResource( 13 ) -__meta__ = { -"_edit_use_anchors_": false -} - [node name="Paths" type="Spatial" parent="."] [node name="Icons" type="Spatial" parent="."] From 4a250442e99e6df83316081ef79574303fe103a3 Mon Sep 17 00:00:00 2001 From: klingbolt <89052698+klingbolt@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:34:40 -0400 Subject: [PATCH 05/10] Apply suggestions from code review --- Spatial.gd | 30 +++++++++++++++--------------- project.godot | 1 - 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index f30e57a3..21808c5e 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -397,7 +397,7 @@ func gen_map_markers(): for icon in icons.get_children(): icon.queue_free() - marker_packs.clear() + self.marker_packs.clear() build_category_tree() # Load the data from the markers @@ -405,7 +405,7 @@ func gen_map_markers(): var path_points := PoolVector3Array() var trail_data = path.get_trail_data() if trail_data.get_points_x().size() != trail_data.get_points_y().size() or trail_data.get_points_x().size() != trail_data.get_points_z().size(): - print("Warning: Trail ", trail_data.get_category.get_name(), " does not have equal number of X, Y, and Z coordinates.") + print("Warning: Trail ", path.get_category.get_name(), " does not have equal number of X, Y, and Z coordinates.") for index in range(0, trail_data.get_points_z().size()): path_points.append(Vector3(trail_data.get_points_x()[index], trail_data.get_points_y()[index], trail_data.get_points_z()[index])) var texture_path = path.get_texture_path() @@ -446,20 +446,20 @@ func search_category_tree(index, split_name, category_item): return null func build_category_tree(): - var root = marker_packs.create_item() + var root = self.marker_packs.create_item() root.set_text(0, "Markers available on current map") root.set_selectable(0, false) root.set_text(1, "Visible") for category in self.markerdata.get_category(): - marker_packs_array.append(category.get_name()) + self.marker_packs_array.append(category.get_name()) add_category(root, category, category.get_name(), false) func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): if category.get_name() == "": print("Category found with no name. Full name ", full_category_name) return - var category_item = marker_packs.create_item(item) + var category_item = self.marker_packs.create_item(item) category_item.set_text(0,category.get_display_name()) category_item.set_metadata(0, full_category_name) category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) @@ -503,28 +503,28 @@ func is_category_visible(category_item: TreeItem) -> bool: return false -func show_or_hide_all(show_or_hide: bool) : - if show_or_hide == false: +func show_or_hide_all(is_visible: bool) : + if is_visible == false: Settings.local_category_data.clear() var category_item = self.marker_packs.get_root().get_children() while category_item != null: - category_item.set_checked(1, show_or_hide) - change_all_categories(category_item, show_or_hide) + category_item.set_checked(1, is_visible) + change_all_categories(category_item, is_visible) update_node_visibility(category_item, self.paths) update_node_visibility(category_item, self.icons) category_item = category_item.get_next() Settings.save() -func change_all_categories(category_item: TreeItem, show_or_hide: bool): - category_item.set_checked(1, show_or_hide) - if show_or_hide == true: +func change_all_categories(category_item: TreeItem, is_visible: bool): + category_item.set_checked(1, is_visible) + if is_visible == true: Settings.local_category_data[category_item.get_metadata(0)] = { "checked" : true, } var child_item = category_item.get_children() while child_item != null: - change_all_categories(child_item, show_or_hide) + change_all_categories(child_item, is_visible) child_item = child_item.get_next() @@ -870,12 +870,12 @@ func _on_Settings_pressed(): func _on_MarkerPacks_cell_selected(): - var category_item = marker_packs.get_selected() + var category_item = self.marker_packs.get_selected() self.currently_active_category = category_item func _on_MarkerPacks_item_edited(): - var category_item = marker_packs.get_edited() + var category_item = self.marker_packs.get_edited() switch_selected_category(category_item) diff --git a/project.godot b/project.godot index 6df2a49b..c8c06b63 100644 --- a/project.godot +++ b/project.godot @@ -35,7 +35,6 @@ config/icon="res://icon.png" [autoload] Settings="*res://Settings.gd" -LocalData="*res://LocalData.gd" [display] From c9ae33d7f5a645a4b47772a9d71ebcd50366b885 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Tue, 18 Jul 2023 18:18:40 -0400 Subject: [PATCH 06/10] Added lines to check icon against current category --- Route2D.tscn | 5 +---- Spatial.gd | 15 +++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Route2D.tscn b/Route2D.tscn index 8aed8671..5b3da3ed 100644 --- a/Route2D.tscn +++ b/Route2D.tscn @@ -1,6 +1,4 @@ -[gd_scene load_steps=4 format=2] - -[ext_resource path="res://Route2D.gd" type="Script" id=1] +[gd_scene load_steps=3 format=2] [sub_resource type="Shader" id=1] code = "shader_type canvas_item; @@ -29,4 +27,3 @@ material = SubResource( 2 ) points = PoolVector2Array( 0, 0, 0, 0, 0, 0 ) default_color = Color( 1, 1, 1, 1 ) texture_mode = 1 -script = ExtResource( 1 ) diff --git a/Spatial.gd b/Spatial.gd index 21808c5e..bf8c97e6 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -634,7 +634,6 @@ func gen_adjustment_nodes(): for index in range(self.paths.get_child_count()): var route = self.paths.get_child(index) var path2d = self.minimap.get_child(index) - #var curve: Curve3D = path.curve if self.currently_active_category.get_metadata(0) == route.waypoint.get_category().get_name(): for i in range(route.get_point_count()): var gizmo_position = route.get_point_position(i) @@ -652,14 +651,14 @@ func gen_adjustment_nodes(): $Gizmos.add_child(new_gizmo) for index in range(self.icons.get_child_count()): - #TODO check for currently active category var icon = self.icons.get_child(index) - var new_gizmo = gizmo_scene.instance() - new_gizmo.translation = icon.translation - new_gizmo.link_point("icon", icon) - new_gizmo.connect("selected", self, "on_gizmo_selected") - new_gizmo.connect("deselected", self, "on_gizmo_deselected") - $Gizmos.add_child(new_gizmo) + if self.currently_active_category.get_metadata(0) == icon.waypoint.get_category().get_name(): + var new_gizmo = gizmo_scene.instance() + new_gizmo.translation = icon.translation + new_gizmo.link_point("icon", icon) + new_gizmo.connect("selected", self, "on_gizmo_selected") + new_gizmo.connect("deselected", self, "on_gizmo_deselected") + $Gizmos.add_child(new_gizmo) var currently_selected_node = null From 4106383a4ce73b9bdd24b58fd1612d4144269766 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 21 Jul 2023 21:14:49 -0400 Subject: [PATCH 07/10] Changes to search tree to account for incomplete Waypoints --- Icon.gd | 4 ++-- Route.gd | 6 +++--- Settings.gd | 4 +--- Spatial.gd | 26 +++++++++++++++++--------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Icon.gd b/Icon.gd index c2af00cb..a86c050c 100644 --- a/Icon.gd +++ b/Icon.gd @@ -1,9 +1,9 @@ extends Sprite3D -var Waypoint = preload("res://waypoint.gd") +const Waypoint = preload("res://waypoint.gd") var texture_path -var waypoint = Waypoint.Icon.new() +var waypoint := Waypoint.Icon.new() as Waypoint.Icon func set_icon_image(texture_path: String): self.texture_path = texture_path diff --git a/Route.gd b/Route.gd index aafac4fc..32d82d5d 100644 --- a/Route.gd +++ b/Route.gd @@ -1,10 +1,10 @@ extends Spatial -var Waypoint = preload("res://waypoint.gd") +const Waypoint = preload("res://waypoint.gd") var texture_path var color = Color(0.9, 0.1, 0.1) -var waypoint = Waypoint.Trail.new() +var waypoint := Waypoint.Trail.new() as Waypoint.Trail var point_list := PoolVector3Array() @@ -19,7 +19,7 @@ func refresh_mesh(): for point_index in range(len(point_list)-1): var point:Vector3 = point_list[point_index] var next_point:Vector3 = point_list[point_index+1] - # If the line starts or ends at map 0, don't draw the line. + # If the line starts or ends at map coordinates (0,0,0), don't draw the line. if point == Vector3(0,0,0) or next_point == Vector3(0,0,0): continue diff --git a/Settings.gd b/Settings.gd index 880dcd61..f163a5ed 100644 --- a/Settings.gd +++ b/Settings.gd @@ -25,9 +25,7 @@ func _ready(): self._config_data = {} if "local_category_data" in self._config_data: - for key in self._config_data["local_category_data"].keys(): - self.local_category_data[key] = self._config_data["local_category_data"][key] - + self.local_category_data = self._config_data["local_category_data"] if "override_size_enabled" in self._config_data: self.override_size_enabled = self._config_data["override_size_enabled"] if "override_size_height" in self._config_data: diff --git a/Spatial.gd b/Spatial.gd index bf8c97e6..f94c2a06 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -415,7 +415,7 @@ func gen_map_markers(): var full_texture_path = self.marker_file_dir + texture_path.get_path() #TODO This tree look up is unnescary if we make path a child of Category in protobuf var split_name = path.get_category().get_name().split(".") - var category_item = search_category_tree(split_name.size(), split_name, self.marker_packs.get_root()) + var category_item = search_category_tree(0, split_name, self.marker_packs.get_root()) gen_new_path(path_points, full_texture_path, path, category_item) for icon in self.markerdata.get_icon(): var position = icon.get_position() @@ -438,10 +438,13 @@ func search_category_tree(index, split_name, category_item): return category_item var child_item = category_item.get_children() while child_item != null: - if child_item.metadata(0) == split_name[index]: - print(child_item.metadata(0)) - return search_category_tree(index + 1, split_name, child_item) - category_item.next() + if child_item.get_text(0) != "No name": + var joined_name = "" + for i in range(index): + joined_name += split_name[i] + if child_item.get_metadata(0) == joined_name: + return search_category_tree(index + 1, split_name, child_item) + child_item = child_item.get_next() print("No category found for ", split_name) return null @@ -456,12 +459,14 @@ func build_category_tree(): add_category(root, category, category.get_name(), false) func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): + var category_item = self.marker_packs.create_item(item) if category.get_name() == "": + category_item.set_text(0, "No name") print("Category found with no name. Full name ", full_category_name) return - var category_item = self.marker_packs.create_item(item) - category_item.set_text(0,category.get_display_name()) - category_item.set_metadata(0, full_category_name) + else: + category_item.set_text(0,category.get_display_name()) + category_item.set_metadata(0, full_category_name) category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) category_item.set_checked(1, Settings.local_category_data.get(full_category_name, {}).get("checked", false)) category_item.set_tooltip(1, "Show/Hide") @@ -558,7 +563,10 @@ func gen_new_path(points: Array, texture_path: String, waypoint_trail, category_ new_route.create_mesh(points_3d) new_route.set_texture(texture) new_route.waypoint = waypoint_trail - new_route.visible = is_category_visible(category_item) + if category_item != null: + new_route.visible = is_category_visible(category_item) + else: + new_route.visible = false paths.add_child(new_route) From 8581a65888b45808ab8288b5280c114258045e96 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 28 Jul 2023 19:40:07 -0400 Subject: [PATCH 08/10] Addressing code review --- Icon.gd | 2 +- Route.gd | 2 +- Spatial.gd | 78 +++++++++++++++++++++------------------------------- Spatial.tscn | 16 ----------- 4 files changed, 34 insertions(+), 64 deletions(-) diff --git a/Icon.gd b/Icon.gd index a86c050c..d8d0c120 100644 --- a/Icon.gd +++ b/Icon.gd @@ -3,7 +3,7 @@ extends Sprite3D const Waypoint = preload("res://waypoint.gd") var texture_path -var waypoint := Waypoint.Icon.new() as Waypoint.Icon +var waypoint : Waypoint.Icon func set_icon_image(texture_path: String): self.texture_path = texture_path diff --git a/Route.gd b/Route.gd index 32d82d5d..f5ce246a 100644 --- a/Route.gd +++ b/Route.gd @@ -4,7 +4,7 @@ const Waypoint = preload("res://waypoint.gd") var texture_path var color = Color(0.9, 0.1, 0.1) -var waypoint := Waypoint.Trail.new() as Waypoint.Trail +var waypoint : Waypoint.Trail var point_list := PoolVector3Array() diff --git a/Spatial.gd b/Spatial.gd index f94c2a06..64e870a2 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -458,15 +458,15 @@ func build_category_tree(): self.marker_packs_array.append(category.get_name()) add_category(root, category, category.get_name(), false) + func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): var category_item = self.marker_packs.create_item(item) if category.get_name() == "": category_item.set_text(0, "No name") - print("Category found with no name. Full name ", full_category_name) + print("Category found with no name.") return - else: - category_item.set_text(0,category.get_display_name()) - category_item.set_metadata(0, full_category_name) + category_item.set_text(0, category.get_display_name()) + category_item.set_metadata(0, full_category_name) category_item.set_cell_mode(1, TreeItem.CELL_MODE_CHECK) category_item.set_checked(1, Settings.local_category_data.get(full_category_name, {}).get("checked", false)) category_item.set_tooltip(1, "Show/Hide") @@ -476,20 +476,31 @@ func add_category(item: TreeItem, category, full_category_name: String, collapse add_category(category_item, category_child, full_category_name + "." + category_child.get_name(), true) -func switch_selected_category(category_item: TreeItem): +func apply_category_visibility_to_nodes(category_item: TreeItem): Settings.local_category_data[category_item.get_metadata(0)] = { "checked" : category_item.is_checked(1), } - update_node_visibility(category_item, self.paths) - update_node_visibility(category_item, self.icons) - Settings.save() + var temporary_cateogry_visibility_data = populate_update_dict(category_item, {}) + update_node_visibility(temporary_cateogry_visibility_data, self.paths) + update_node_visibility(temporary_cateogry_visibility_data, self.icons) + + +# Builds a dictionary of the visibility of a specific category and all children +func populate_update_dict(category_item: TreeItem, category_visibility_data): + category_visibility_data[category_item.get_metadata(0)] = is_category_visible(category_item) + var child_item = category_item.get_children() + while child_item != null: + category_visibility_data = populate_update_dict(child_item, category_visibility_data) + child_item = child_item.get_next() + return category_visibility_data -func update_node_visibility(category_item: TreeItem, nodes): +#Updates the visibilty of a node and all children. +func update_node_visibility(cateogry_data, nodes): for node in nodes.get_children(): - var node_name = node.waypoint.get_category().get_name() - if node_name.begins_with(category_item.get_metadata(0)): - if is_category_visible(category_item): + var node_name = node.waypoint.get_category().get_name() + if node_name in cateogry_data: + if cateogry_data[node_name]: node.visible = true else: node.visible = false @@ -502,37 +513,14 @@ func update_node_visibility(category_item: TreeItem, nodes): func is_category_visible(category_item: TreeItem) -> bool: if category_item == marker_packs.get_root(): return true + if category_item == null: + return false if category_item.is_checked(1): return is_category_visible(category_item.get_parent()) else: return false -func show_or_hide_all(is_visible: bool) : - if is_visible == false: - Settings.local_category_data.clear() - var category_item = self.marker_packs.get_root().get_children() - while category_item != null: - category_item.set_checked(1, is_visible) - change_all_categories(category_item, is_visible) - update_node_visibility(category_item, self.paths) - update_node_visibility(category_item, self.icons) - category_item = category_item.get_next() - Settings.save() - - -func change_all_categories(category_item: TreeItem, is_visible: bool): - category_item.set_checked(1, is_visible) - if is_visible == true: - Settings.local_category_data[category_item.get_metadata(0)] = { - "checked" : true, - } - var child_item = category_item.get_children() - while child_item != null: - change_all_categories(child_item, is_visible) - child_item = child_item.get_next() - - func gen_new_path(points: Array, texture_path: String, waypoint_trail, category_item: TreeItem): # Create the texture to use from an image file @@ -590,7 +578,10 @@ func gen_new_icon(position: Vector3, texture_path: String, waypoint_icon, catego new_icon.translation = position new_icon.set_icon_image(texture_path) new_icon.waypoint = waypoint_icon - new_icon.visible = is_category_visible(category_item) + if category_item != null: + new_icon.visible = is_category_visible(category_item) + else: + new_icon.visible = false icons.add_child(new_icon) # This function take all of the currently rendered objects and converts it into @@ -761,14 +752,14 @@ func _on_NewPath_pressed(): ################################################################################ func _on_NewIcon_pressed(): var waypoint_icon = Waypoint.Icon.new() - waypoint_icon.set_name(self.currently_active_category.get_metadata(0)) + waypoint_icon.new_category().set_name(self.currently_active_category.get_metadata(0)) gen_new_icon(self.player_position, self.next_texture_path, waypoint_icon, self.currently_active_category) # A new path point is created func _on_NewPathPoint_pressed(): if self.currently_active_path == null: var waypoint_trail = Waypoint.Trail.new() - waypoint_trail.set_name(self.currently_active_category.get_metadata(0)) + waypoint_trail.new_category().set_name(self.currently_active_category.get_metadata(0)) gen_new_path([self.player_position], self.next_texture_path, waypoint_trail, self.currently_active_category) else: var z_accurate_player_position = player_position @@ -883,11 +874,6 @@ func _on_MarkerPacks_cell_selected(): func _on_MarkerPacks_item_edited(): var category_item = self.marker_packs.get_edited() - switch_selected_category(category_item) - + apply_category_visibility_to_nodes(category_item) -func _on_ShowAll_pressed(): - show_or_hide_all(true) -func _on_HideAll_pressed(): - show_or_hide_all(false) diff --git a/Spatial.tscn b/Spatial.tscn index e674a3fd..5db276b4 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -742,20 +742,6 @@ __meta__ = { "_edit_use_anchors_": false } -[node name="ShowAll" type="Button" parent="Control/Dialogs/MarkerPacks"] -margin_left = 5.0 -margin_top = 4.0 -margin_right = 115.0 -margin_bottom = 42.0 -text = "Show All" - -[node name="HideAll" type="Button" parent="Control/Dialogs/MarkerPacks"] -margin_left = 119.0 -margin_top = 4.0 -margin_right = 229.0 -margin_bottom = 42.0 -text = "Hide All" - [node name="Border" type="Control" parent="Control"] visible = false anchor_right = 1.0 @@ -890,5 +876,3 @@ material/0 = SubResource( 4 ) [connection signal="item_edited" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_MarkerPacks_item_edited"] [connection signal="multi_selected" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_Tree_multi_selected"] [connection signal="tree_entered" from="Control/Dialogs/MarkerPacks/MarkerPacks" to="." method="_on_Tree_tree_entered"] -[connection signal="pressed" from="Control/Dialogs/MarkerPacks/ShowAll" to="." method="_on_ShowAll_pressed"] -[connection signal="pressed" from="Control/Dialogs/MarkerPacks/HideAll" to="." method="_on_HideAll_pressed"] From c0a7c3c7cfdd5bed102c8836ffd783abbbc79035 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 28 Jul 2023 20:19:00 -0400 Subject: [PATCH 09/10] Addressed small changes --- Icon.gd | 2 +- Route.gd | 2 +- Spatial.gd | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Icon.gd b/Icon.gd index d8d0c120..1cd9164c 100644 --- a/Icon.gd +++ b/Icon.gd @@ -3,7 +3,7 @@ extends Sprite3D const Waypoint = preload("res://waypoint.gd") var texture_path -var waypoint : Waypoint.Icon +var waypoint: Waypoint.Icon func set_icon_image(texture_path: String): self.texture_path = texture_path diff --git a/Route.gd b/Route.gd index f5ce246a..07a87187 100644 --- a/Route.gd +++ b/Route.gd @@ -4,7 +4,7 @@ const Waypoint = preload("res://waypoint.gd") var texture_path var color = Color(0.9, 0.1, 0.1) -var waypoint : Waypoint.Trail +var waypoint: Waypoint.Trail var point_list := PoolVector3Array() diff --git a/Spatial.gd b/Spatial.gd index 64e870a2..e3dd86fa 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -415,7 +415,7 @@ func gen_map_markers(): var full_texture_path = self.marker_file_dir + texture_path.get_path() #TODO This tree look up is unnescary if we make path a child of Category in protobuf var split_name = path.get_category().get_name().split(".") - var category_item = search_category_tree(0, split_name, self.marker_packs.get_root()) + var category_item = search_category_tree(split_name, self.marker_packs.get_root()) gen_new_path(path_points, full_texture_path, path, category_item) for icon in self.markerdata.get_icon(): var position = icon.get_position() @@ -430,20 +430,20 @@ func gen_map_markers(): var full_texture_path = self.marker_file_dir + texture_path.get_path() #TODO This tree look up is unnescary if we make path a child of Category in protobuf var split_name = icon.get_category().get_name().split(".") - var category_item = search_category_tree(split_name.size(), split_name, self.marker_packs.get_root()) + var category_item = search_category_tree(split_name, self.marker_packs.get_root()) gen_new_icon(position_vector, full_texture_path, icon, category_item) -func search_category_tree(index, split_name, category_item): + +func search_category_tree(split_name, category_item, index: int = 0): if index == split_name.size(): return category_item var child_item = category_item.get_children() while child_item != null: - if child_item.get_text(0) != "No name": - var joined_name = "" - for i in range(index): - joined_name += split_name[i] - if child_item.get_metadata(0) == joined_name: - return search_category_tree(index + 1, split_name, child_item) + var joined_name = "" + for i in range(index): + joined_name += split_name[i] + if child_item.get_metadata(0) == joined_name: + return search_category_tree(split_name, child_item, index + 1) child_item = child_item.get_next() print("No category found for ", split_name) return null @@ -462,7 +462,9 @@ func build_category_tree(): func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): var category_item = self.marker_packs.create_item(item) if category.get_name() == "": + # If this is called, there is an error in the protobuf data category_item.set_text(0, "No name") + category_item.set_metadata(0, "") print("Category found with no name.") return category_item.set_text(0, category.get_display_name()) @@ -498,7 +500,7 @@ func populate_update_dict(category_item: TreeItem, category_visibility_data): #Updates the visibilty of a node and all children. func update_node_visibility(cateogry_data, nodes): for node in nodes.get_children(): - var node_name = node.waypoint.get_category().get_name() + var node_name = node.waypoint.get_category().get_name() if node_name in cateogry_data: if cateogry_data[node_name]: node.visible = true From 64d0c2649ada9749b6e2e469084a8621c96ce328 Mon Sep 17 00:00:00 2001 From: klingbolt Date: Fri, 28 Jul 2023 20:25:01 -0400 Subject: [PATCH 10/10] Added some types --- Spatial.gd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spatial.gd b/Spatial.gd index e3dd86fa..60c48d98 100644 --- a/Spatial.gd +++ b/Spatial.gd @@ -434,7 +434,7 @@ func gen_map_markers(): gen_new_icon(position_vector, full_texture_path, icon, category_item) -func search_category_tree(split_name, category_item, index: int = 0): +func search_category_tree(split_name: PoolStringArray, category_item: TreeItem, index: int = 0): if index == split_name.size(): return category_item var child_item = category_item.get_children() @@ -462,7 +462,7 @@ func build_category_tree(): func add_category(item: TreeItem, category, full_category_name: String, collapsed: bool): var category_item = self.marker_packs.create_item(item) if category.get_name() == "": - # If this is called, there is an error in the protobuf data + # If this is called, there is an error in the Waypoint data category_item.set_text(0, "No name") category_item.set_metadata(0, "") print("Category found with no name.")