Skip to content

Commit

Permalink
Show trading information on galaxy map
Browse files Browse the repository at this point in the history
Resolves #72.
  • Loading branch information
jspahrsummers committed Aug 18, 2024
1 parent 4cf25ef commit 0b67eed
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
19 changes: 17 additions & 2 deletions galaxy/map/galaxy_map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class_name GalaxyMap
@export var ports_label: Label
@export var facilities_heading: Label
@export var facilities_label: Label
@export var commodities_heading: Label
@export var commodities_label: Label

## The player's [HyperdriveSystem]. Must be set before displaying.
var hyperdrive_system: HyperdriveSystem
Expand Down Expand Up @@ -82,21 +84,25 @@ func _update_selection_state() -> void:
var presented_system: StarSystem
if self.hyperdrive_system.jump_destination:
presented_system = self.hyperdrive_system.jump_destination
self.current_or_destination_heading.text = "DESTINATION SYSTEM"
self.current_or_destination_heading.text = "Destination system"
else:
presented_system = self.hyperdrive_system.current_system()
self.current_or_destination_heading.text = "CURRENT SYSTEM"
self.current_or_destination_heading.text = "Current system"

self.system_name_label.text = presented_system.name

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

self.facilities_heading.visible = true
self.facilities_label.visible = true
self.commodities_heading.visible = true
self.commodities_label.visible = true

var facilities_flags: int = 0
var ports := PackedStringArray()
Expand All @@ -116,6 +122,15 @@ func _update_selection_state() -> void:

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

var commodities := PackedStringArray()
if presented_system.market:
for commodity: Commodity in presented_system.market.commodities:
commodities.append(commodity.name)

self.commodities_label.text = "\n".join(commodities)
else:
self.commodities_label.text = "(none)"

func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_galaxy_map"):
Expand Down
35 changes: 31 additions & 4 deletions galaxy/map/galaxy_map_window.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[gd_scene load_steps=7 format=3 uid="uid://bksd1ida60ymi"]
[gd_scene load_steps=8 format=3 uid="uid://bksd1ida60ymi"]

[ext_resource type="Script" path="res://galaxy/map/galaxy_map.gd" id="1_ksqdq"]
[ext_resource type="PackedScene" uid="uid://kqong7nrl4p2" path="res://galaxy/map/galaxy_map_3d.tscn" id="1_rlhp4"]
[ext_resource type="Resource" uid="uid://bcva4l4cpt70c" path="res://galaxy/main_galaxy.tres" id="2_okeml"]
[ext_resource type="PackedScene" uid="uid://ckdnlnrybk4mh" path="res://galaxy/map/galaxy_map_system.tscn" id="3_do8cs"]
[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"]
[ext_resource type="LabelSettings" uid="uid://dcpdwtq5b48gc" path="res://galaxy/map/multiline_label_settings.tres" id="7_073cv"]

[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")]
[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", "commodities_heading", "commodities_label")]
own_world_3d = true
transparent_bg = true
title = "Galaxy Map"
Expand All @@ -25,6 +26,8 @@ system_name_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBox
ports_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/PortsLabel")
facilities_heading = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/FacilitiesHeading")
facilities_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/FacilitiesLabel")
commodities_heading = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/CommoditiesHeading")
commodities_label = NodePath("PanelContainer/HSplitContainer/RightContainer/VBoxContainer/CommoditiesLabel")

[node name="PanelContainer" type="PanelContainer" parent="."]
anchors_preset = 15
Expand Down Expand Up @@ -68,44 +71,68 @@ theme_override_constants/margin_left = 0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/HSplitContainer/RightContainer"]
material = ExtResource("6_00km2")
layout_mode = 2
theme_override_constants/separation = 0

[node name="CurrentOrDestinationHeading" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "CURRENT SYSTEM"
uppercase = true

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

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

[node name="PortsHeading" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "PORTS"
uppercase = true

[node name="PortsLabel" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "Earth"
label_settings = ExtResource("7_073cv")

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

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

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

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

[node name="CommoditiesHeading" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "TRADING"
uppercase = true

[node name="CommoditiesLabel" type="Label" parent="PanelContainer/HSplitContainer/RightContainer/VBoxContainer"]
use_parent_material = true
layout_mode = 2
text = "Food
Industrial Equipment
Semiconductors"
label_settings = ExtResource("7_073cv")

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

Expand Down
4 changes: 4 additions & 0 deletions galaxy/map/multiline_label_settings.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[gd_resource type="LabelSettings" format=3 uid="uid://dcpdwtq5b48gc"]

[resource]
line_spacing = 2.08165e-12

0 comments on commit 0b67eed

Please sign in to comment.