Skip to content

Commit

Permalink
Better selection state
Browse files Browse the repository at this point in the history
  • Loading branch information
jspahrsummers committed Aug 23, 2024
1 parent 4b63ed7 commit ae95806
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions galaxy/map/galaxy_map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ func _on_jump_path_changed(_hyperdrive_system: HyperdriveSystem) -> void:
self._update_selection_state()

func _update_selection_state() -> void:
var current_system := self.hyperdrive_system.current_system()

var jump_path := self.hyperdrive_system.get_jump_path()
var jump_names := jump_path.map(func(system: StarSystem) -> StringName: return system.name)
for system_name: String in self._system_nodes:
var node: GalaxyMapSystem = self._system_nodes[system_name]
node.selected = system_name in jump_names
node.current = system_name in jump_names or system_name == current_system.name
node.selected = system_name == jump_names[-1] if jump_path else false

for hyperlane_name: String in self._hyperlane_nodes:
var node: GalaxyMapHyperlane = self._hyperlane_nodes[hyperlane_name]
Expand All @@ -103,7 +106,7 @@ func _update_selection_state() -> void:
presented_system = jump_path[-1]
self.current_or_destination_heading.text = "Destination system"
else:
presented_system = self.hyperdrive_system.current_system()
presented_system = current_system
self.current_or_destination_heading.text = "Current system"

self.system_name_label.text = presented_system.name
Expand Down
4 changes: 2 additions & 2 deletions galaxy/map/galaxy_map_system.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class_name GalaxyMapSystem
## When [member current] is true, this material overrides the [member mesh]'s material.
@export var current_node_material: Material

## Whether the system represented by this node is the player's current system.
## Whether the system represented by this node is the player's current system or part of the current hyperspace path.
@export var current: bool:
set(value):
current = value
Expand All @@ -21,7 +21,7 @@ class_name GalaxyMapSystem
## When [member selected] is true, this sprite is shown.
@export var selected_sprite: Sprite3D

## Whether this system has been selected by the player in the galaxy map.
## Whether this system is currently selected by the player in the galaxy map.
@export var selected: bool:
set(value):
selected = value
Expand Down

0 comments on commit ae95806

Please sign in to comment.