Randoloot/scripts/planets/freighter_command.gd
2026-10-25 12:34:56 +01:00

77 lines
5.0 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends RefCounted
const MENU := preload("res://scripts/planets/freighter_menu.gd")
const NETWORK := preload("res://scripts/planets/mining_network.gd")
static func build(screen: Control) -> void:
var progress: Resource = screen.captain.expedition
var navigation := MENU.card(screen._content)
MENU.label(navigation, "NAWIGACJA / ODKRYTE UKŁADY", 14, MENU.GOLD)
MENU.label(navigation, "Obecny: System %d · Najdalszy odkryty: %d" % [GameState.system_level, GameState.highest_system], 12)
var row := MENU.row(navigation)
var destination := OptionButton.new()
destination.name = "SystemDestination"
destination.size_flags_horizontal = Control.SIZE_EXPAND_FILL
destination.add_theme_font_size_override("font_size", 11)
destination.add_theme_font_override("font", ThemeDB.fallback_font)
for level in range(1, GameState.highest_system + 1):
destination.add_item("System %d%s" % [level, " · HARD" if preload("res://scripts/levels/level_balance.gd").is_hard(level) else ""], level)
if GameState.active_distant_map.is_empty(): destination.select(GameState.system_level - 1)
destination.disabled = not GameState.active_distant_map.is_empty()
row.add_child(destination)
var travel := MENU.button(row, "LEĆ DO UKŁADU", func(): screen._travel_to_system(destination.get_selected_id()), true)
travel.name = "TravelToSystem"
travel.disabled = true
destination.item_selected.connect(func(_index): travel.disabled = not GameState.active_distant_map.is_empty() or destination.get_selected_id() == GameState.system_level)
MENU.label(navigation, "Nowe układy odblokujesz, przechodząc dalej przez tunel po pokonaniu przeciwników.", 11, MENU.MUTED)
preload("res://scripts/planets/distant_expeditions_panel.gd").build(screen)
var summary := MENU.card(screen._content)
MENU.label(summary, "SIEĆ WYDOBYWCZA", 14, MENU.GOLD)
var stock := MENU.label(summary, "", 13, Color("95dce8"))
screen._economy_labels["network"] = stock
MENU.label(summary, "Wydobycie: zasobność × (1 + zarządzanie / 100) deuteru/min. Bez załoganta: 0. Złoża nie wyczerpują się.", 11, MENU.MUTED)
MENU.label(summary, "Jeden załogant obsługuje jedną placówkę. Nowy przydział przenosi go z poprzedniej.", 11, MENU.MUTED)
if progress.mining_stations.is_empty():
MENU.label(summary, "Brak placówek. Szukaj głębokich złóż na planetach (szansa 60%). Budowa: zasobność × 10 części.", 12)
for station_id in progress.mining_stations:
var station: Dictionary = progress.mining_stations[station_id]
var card := MENU.card(screen._content)
MENU.label(card, "%s · SYSTEM %d" % [station.planet_name, station.system], 13, MENU.GOLD)
MENU.label(card, "Zasobność: %d / 100" % NETWORK.station_richness(station), 12, Color("95dce8"))
var member: Dictionary = progress.crew.get(str(station.get("crew_id", "")), {})
MENU.label(card, "Czeka na załoganta" if member.is_empty() else "%s · zarządzanie %d/100 · %.1f deuteru/min" % [member.name, member.management, NETWORK.station_rate(progress, station)], 12)
var assign_row := MENU.row(card)
var option := OptionButton.new()
option.name = "StationCrew_" + str(station_id).md5_text().substr(0, 8)
option.size_flags_horizontal = Control.SIZE_EXPAND_FILL
option.fit_to_longest_item = false
option.add_theme_font_size_override("font_size", 11)
option.add_theme_font_override("font", ThemeDB.fallback_font)
option.add_item("Bez przydziału")
option.set_item_metadata(0, "")
for crew_id in progress.crew:
var person: Dictionary = progress.crew[crew_id]
option.add_item("%s · %d/100" % [person.name, person.management])
option.set_item_metadata(option.item_count - 1, crew_id)
if str(station.get("crew_id", "")) == str(crew_id): option.select(option.item_count - 1)
assign_row.add_child(option)
var apply := MENU.button(assign_row, "PRZYDZIEL", screen._assign_station.bind(str(station_id), option))
apply.disabled = progress.crew.is_empty() and member.is_empty()
if progress.crew.is_empty(): MENU.label(screen._content, "Brak załogantów. Przygotuj kajutę i zatrudnij specjalistę spotkanego na planecie.", 12, MENU.MUTED)
screen._refresh_live_labels()
static func cabin(screen: Control) -> void:
var progress: Resource = screen.captain.expedition
var member := NETWORK.cabin_crew(progress, screen._tab)
var card := MENU.card(screen._content)
if member.is_empty():
MENU.label(card, "WOLNA KAJUTA", 14, MENU.GOLD)
MENU.label(card, "Przygotowana dla jednego załoganta. Specjalistów możesz zatrudniać na planetach.", 12)
return
MENU.label(card, str(member.name), 15, MENU.GOLD)
MENU.label(card, "Zarządzanie: %d / 100\nPremia do wydobycia: +%d%%\nPochodzenie: %s" % [member.management, member.management, member.planet_name], 12)
var assignment := "Bez przydziału"
for station in progress.mining_stations.values():
if str(station.get("crew_id", "")) == str(member.id): assignment = "%s · System %d" % [station.planet_name, station.system]
MENU.label(card, "Placówka: " + assignment, 12, Color("95dce8"))
MENU.button(card, "ZWOLNIJ ZAŁOGANTA", screen._dismiss_crew.bind(str(member.id)))