Refactor gameplay menus into owned scenes
This commit is contained in:
parent
46196a1adb
commit
a17fe88197
50 changed files with 3449 additions and 3619 deletions
39
ui/menus/GarrisonMenu.gd
Normal file
39
ui/menus/GarrisonMenu.gd
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
extends "res://ui/menus/ModalMenu.gd"
|
||||
|
||||
@onready var panel: Control = $Panel
|
||||
@onready var status: Label = $StatusLabel
|
||||
|
||||
var building_id: int = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
panel.changed.connect(refresh)
|
||||
|
||||
|
||||
func open_for(next_building_id: int) -> void:
|
||||
building_id = next_building_id
|
||||
panel.building_id = building_id
|
||||
open_menu()
|
||||
refresh()
|
||||
|
||||
|
||||
func close_menu() -> void:
|
||||
super.close_menu()
|
||||
building_id = 0
|
||||
panel.building_id = 0
|
||||
|
||||
|
||||
func refresh() -> void:
|
||||
if building_id == 0:
|
||||
return
|
||||
panel.building_id = building_id
|
||||
panel.refresh()
|
||||
var ordered: int = GameState.garrison_desired_total(building_id)
|
||||
var crewed: int = GameState.garrison_crew(building_id).size()
|
||||
if ordered == 0:
|
||||
status.text = "No vessels ordered. Only armed vessels can hold a position."
|
||||
elif crewed >= ordered:
|
||||
status.text = "Garrison at full strength"
|
||||
else:
|
||||
status.text = "%d of %d berths crewed - vessels are sent from the mothership as they become available" % [crewed, ordered]
|
||||
Loading…
Reference in a new issue