From 57d6826d5a5e10bc9a73af1406f07c3573820f87 Mon Sep 17 00:00:00 2001 From: ToasterPanic Date: Sat, 6 Dec 2025 17:23:14 -0500 Subject: [PATCH] Multiple navigation goal support, general control improvements --- project.godot | 6 +++++ scenes/game.tscn | 14 ++++++++++-- scenes/navigation_item.tscn | 20 ++++++++++++++++ scripts/game.gd | 42 ++++++++++++++++++++++++++++++---- scripts/navigation_item.gd | 7 ++++++ scripts/navigation_item.gd.uid | 1 + 6 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 scenes/navigation_item.tscn create mode 100644 scripts/navigation_item.gd create mode 100644 scripts/navigation_item.gd.uid diff --git a/project.godot b/project.godot index bec7207..31b518a 100644 --- a/project.godot +++ b/project.godot @@ -199,6 +199,12 @@ navpanel={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":4,"pressure":0.0,"pressed":true,"script":null) ] } +ui_back={ +"deadzone": 0.2, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194308,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"script":null) +] +} [physics] diff --git a/scenes/game.tscn b/scenes/game.tscn index fe629bd..ab4a5eb 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -292,6 +292,7 @@ grow_vertical = 2 theme = ExtResource("15_ir15t") [node name="Start" type="HFlowContainer" parent="UI/Control/Navpanel"] +visible = false layout_mode = 2 theme_override_constants/v_separation = 0 @@ -334,11 +335,11 @@ layout_mode = 2 size_flags_horizontal = 3 text = "navigation" -[node name="Button2" type="Button" parent="UI/Control/Navpanel/Start"] +[node name="Quit" type="Button" parent="UI/Control/Navpanel/Start"] custom_minimum_size = Vector2(256, 0) layout_mode = 2 size_flags_horizontal = 3 -text = "test" +text = "quit" [node name="Cheery" type="Label" parent="UI/Control/Navpanel/Start"] custom_minimum_size = Vector2(256, 0) @@ -417,6 +418,14 @@ text = "PICK ROUTE" label_settings = SubResource("LabelSettings_5newe") horizontal_alignment = 1 +[node name="Scroll" type="ScrollContainer" parent="UI/Control/Navpanel/NavigationRoutes"] +custom_minimum_size = Vector2(256, 512) +layout_mode = 2 + +[node name="Box" type="VBoxContainer" parent="UI/Control/Navpanel/NavigationRoutes/Scroll"] +custom_minimum_size = Vector2(256, 0) +layout_mode = 2 + [node name="NavpanelBack" type="Button" parent="UI/Control/Navpanel/NavigationRoutes"] custom_minimum_size = Vector2(256, 0) layout_mode = 2 @@ -554,6 +563,7 @@ color = Color(1, 1, 1, 0) [connection signal="body_entered" from="Orbits/SpaceStation1/SpaceStation1/EnterHitbox" to="Orbits/SpaceStation1/SpaceStation1" method="_on_enter_hitbox_body_entered"] [connection signal="body_shape_entered" from="Player/Hitbox" to="Player" method="_on_hitbox_body_shape_entered"] [connection signal="pressed" from="UI/Control/Navpanel/Start/Navigation" to="." method="_on_navigation_pressed"] +[connection signal="pressed" from="UI/Control/Navpanel/Start/Quit" to="." method="_on_quit_pressed"] [connection signal="pressed" from="UI/Control/Navpanel/Navigation/NewRoute" to="." method="_on_new_route_pressed"] [connection signal="pressed" from="UI/Control/Navpanel/Navigation/CancelRoute" to="." method="_on_cancel_route_pressed"] [connection signal="pressed" from="UI/Control/Navpanel/Navigation/NavpanelBack" to="." method="_on_navpanel_back_pressed"] diff --git a/scenes/navigation_item.tscn b/scenes/navigation_item.tscn new file mode 100644 index 0000000..c9f1172 --- /dev/null +++ b/scenes/navigation_item.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=3 uid="uid://cky1bhmlnicwx"] + +[ext_resource type="Script" uid="uid://usvp2plv7qsx" path="res://scripts/navigation_item.gd" id="1_vuhx2"] + +[node name="NavigationItem" type="VBoxContainer"] +script = ExtResource("1_vuhx2") + +[node name="RichTextLabel" type="RichTextLabel" parent="."] +layout_mode = 2 +bbcode_enabled = true +text = "[font size=24]space station 1[/font] +1000u away" +fit_content = true +scroll_active = false + +[node name="Button" type="Button" parent="."] +layout_mode = 2 +text = "navigate" + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/scripts/game.gd b/scripts/game.gd index 4e518bf..fcc7542 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -73,6 +73,14 @@ func _ready() -> void: $Player.global_position = spawn_points[global.stats.location].global_position $Player.rotation = spawn_points[global.stats.location].rotation + for n in navigation_points: + var navigation_item = preload("res://scenes/navigation_item.tscn").instantiate() + + navigation_item.goal = n + navigation_item.game = self + + $UI/Control/Navpanel/NavigationRoutes/Scroll/Box.add_child(navigation_item) + var i = 0 while i < 1024 / 3: var star = star_scene.instantiate() @@ -213,10 +221,13 @@ func _set_navpanel_menu(menu: String) -> void: if n.get_name() == menu: n.visible = true - for o in n.get_children(): - if o.is_class("Button"): - o.grab_focus() - break + if menu == "NavigationRoutes": + n.get_node("Scroll/Box").get_children()[0].get_node("Button").grab_focus() + else: + for o in n.get_children(): + if o.is_class("Button"): + o.grab_focus() + break else: n.visible = false @@ -234,6 +245,16 @@ func _input(event: InputEvent) -> void: $UI/Control/Navpanel.visible = true _set_navpanel_menu("Start") + elif event.is_action_pressed("ui_back"): + if $UI/Control/Navpanel.visible: + $UiSelect.play() + + if $UI/Control/Navpanel/NavigationRoutes.visible: + _set_navpanel_menu("Navigation") + elif $UI/Control/Navpanel/Start.visible: + $UI/Control/Navpanel.visible = false + else: + _set_navpanel_menu("Start") func _on_tree_exiting() -> void: @@ -253,9 +274,20 @@ func _on_navpanel_back_pressed() -> void: func _on_new_route_pressed() -> void: $UiSelect.play() - global.stats.navigation_goal = navigation_points[0] + _set_navpanel_menu("NavigationRoutes") func _on_cancel_route_pressed() -> void: $UiSelect.play() global.stats.navigation_goal = null + + +func _on_quit_pressed() -> void: + $UiSelect.play() + $UI/Control/Navpanel.visible = false + + +func _navigation_item_pressed(goal) -> void: + global.stats.navigation_goal = goal + $UiSelect.play() + _set_navpanel_menu("Navigation") diff --git a/scripts/navigation_item.gd b/scripts/navigation_item.gd new file mode 100644 index 0000000..7dd497f --- /dev/null +++ b/scripts/navigation_item.gd @@ -0,0 +1,7 @@ +extends VBoxContainer + +var goal = null +var game = null + +func _on_button_pressed() -> void: + game._navigation_item_pressed(goal) diff --git a/scripts/navigation_item.gd.uid b/scripts/navigation_item.gd.uid new file mode 100644 index 0000000..9980d65 --- /dev/null +++ b/scripts/navigation_item.gd.uid @@ -0,0 +1 @@ +uid://usvp2plv7qsx