Skip to content

Commit

Permalink
List facilities on galaxy map
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Aug 18, 2024
1 parent 7beb981 commit 4cf25ef
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
33 changes: 29 additions & 4 deletions galaxy/map/galaxy_map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class_name GalaxyMap
@export var current_or_destination_heading: Label
@export var system_name_label: Label
@export var ports_label: Label
@export var facilities_heading: Label
@export var facilities_label: Label

## The player's [HyperdriveSystem]. Must be set before displaying.
var hyperdrive_system: HyperdriveSystem
Expand Down Expand Up @@ -86,11 +88,34 @@ func _update_selection_state() -> void:
self.current_or_destination_heading.text = "CURRENT SYSTEM"

self.system_name_label.text = presented_system.name
if presented_system.planets:
self.ports_label.text = "\n".join(PackedStringArray(presented_system.planets.map(func(planet: Planet) -> String:
return planet.name)))
else:

if not presented_system.planets:
self.ports_label.text = "(none)"
self.facilities_label.visible = false
self.facilities_heading.visible = false
return

self.facilities_heading.visible = true
self.facilities_label.visible = true

var facilities_flags: int = 0
var ports := PackedStringArray()
for planet in presented_system.planets:
ports.append(planet.name)
facilities_flags |= planet.facilities

var facilities := PackedStringArray()
if facilities_flags & Planet.REFUEL:
facilities.append("Fuel")
if facilities_flags & Planet.MISSIONS:
facilities.append("Missions")
if facilities_flags & Planet.OUTFITTER:
facilities.append("Outfitter")
if facilities_flags & Planet.SHIPYARD:
facilities.append("Shipyard")

self.ports_label.text = "\n".join(ports)
self.facilities_label.text = "\n".join(facilities) if facilities else "(none)"

func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_galaxy_map"):
Expand Down
18 changes: 17 additions & 1 deletion galaxy/map/galaxy_map_window.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://d3lphosly5y8b" path="res://galaxy/map/galaxy_map_hyperlane.tscn" id="4_1iwcw"]
[ext_resource type="Material" uid="uid://cs5s3tb7vagsi" path="res://screens/shared_ui/premultiplied_canvas_material.tres" id="6_00km2"]

[node name="GalaxyMapWindow" type="Window" node_paths=PackedStringArray("galaxy_map_3d", "camera", "current_or_destination_heading", "system_name_label", "ports_label")]
[node name="GalaxyMapWindow" type="Window" node_paths=PackedStringArray("galaxy_map_3d", "camera", "current_or_destination_heading", "system_name_label", "ports_label", "facilities_heading", "facilities_label")]
own_world_3d = true
transparent_bg = true
title = "Galaxy Map"
Expand All @@ -23,6 +23,8 @@ camera = NodePath("PanelContainer/HSplitContainer/LeftContainer/SubViewportConta
current_or_destination_heading = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/CurrentOrDestinationHeading")
system_name_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/SystemNameLabel")
ports_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/PortsLabel")
facilities_heading = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/FacilitiesHeading")
facilities_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/FacilitiesLabel")

[node name="PanelContainer" type="PanelContainer" parent="."]
anchors_preset = 15
Expand Down Expand Up @@ -91,6 +93,20 @@ use_parent_material = true
layout_mode = 2
text = "Earth"

[node name="Padding2" type="Control" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
custom_minimum_size = Vector2(2.08165e-12, 16)
layout_mode = 2

[node name="FacilitiesHeading" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "FACILITIES"

[node name="FacilitiesLabel" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
material = ExtResource("6_00km2")
layout_mode = 2
text = "Bar"

[connection signal="close_requested" from="." to="." method="_on_window_close_requested"]

[editable path="PanelContainer/HSplitContainer/LeftContainer/SubViewportContainer/SubViewport/GalaxyMap3D"]
4 changes: 2 additions & 2 deletions screens/game/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ script = ExtResource("11_ag0i7")
max_volume = 10.0
commodities = {}

[sub_resource type="Resource" id="Resource_4ccso"]
[sub_resource type="Resource" id="Resource_ytpox"]
resource_local_to_scene = true
script = ExtResource("13_q2g24")
max_fuel = 6.0
Expand Down Expand Up @@ -180,7 +180,7 @@ hull = SubResource("Resource_ffax2")
shield = SubResource("Resource_75c8j")
battery = SubResource("Resource_xpwk4")
cargo_hold = SubResource("Resource_bsv1l")
hyperdrive = SubResource("Resource_4ccso")
hyperdrive = SubResource("Resource_ytpox")

[node name="CombatObject" parent="HyperspaceSceneSwitcher/Sol/PlayerCorvette" index="3" node_paths=PackedStringArray("targeted_sound")]
targeted_sound = NodePath("../Player/TargetedSound")
Expand Down

0 comments on commit 4cf25ef

Please sign in to comment.