47 lines
2.5 KiB
GDScript
47 lines
2.5 KiB
GDScript
extends RefCounted
|
||
const MENU := preload("res://scripts/planets/freighter_menu.gd")
|
||
const DATA := preload("res://scripts/planets/distant_expeditions.gd")
|
||
static func build(screen: Control) -> void:
|
||
var progress: Resource = screen.captain.expedition
|
||
var section := MENU.card(screen._content)
|
||
section.name = "DistantExpeditions"
|
||
var art := TextureRect.new()
|
||
art.texture = load("res://assets/planets/expedition_navigation.png")
|
||
art.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
|
||
art.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_COVERED
|
||
art.custom_minimum_size.y = 125
|
||
art.clip_contents = true
|
||
section.add_child(art)
|
||
MENU.label(section, "DALEKIE WYPRAWY / ARCHIWUM MAP", 16, Color("e9b4fc"))
|
||
MENU.label(section, "Sektory poza znanymi szlakami. Podwójna liczba wrogów, jeden boss. Kryształy czasu z każdego wroga. Zwykli wrogowie: mapy i powerbanki po 15%. Boss zawsze zostawia dokładnie 1 mapę i 1 losowy orb.", 12)
|
||
var fuel := MENU.label(section, "", 13, Color("95dce8"))
|
||
fuel.name = "ExpeditionFuel"
|
||
screen._economy_labels["expedition_fuel"] = fuel
|
||
MENU.label(section, "Lot: poziom × 1000 deuteru. Powrót bezpłatny. Mapy pozostają w archiwum i pozwalają wracać do sektora.", 12, MENU.GOLD)
|
||
if progress.distant_maps.is_empty():
|
||
MENU.label(section, "Archiwum jest puste. Szukaj pustelnika na planecie lub map w łupach z wypraw.", 12, MENU.MUTED)
|
||
var maps: Array = progress.distant_maps.values()
|
||
maps.sort_custom(func(a,b): return int(a.level)<int(b.level))
|
||
for map in maps:
|
||
var card := MENU.card(section)
|
||
MENU.label(card, "%s / POZIOM %d" % [map.name,map.level], 14, MENU.GOLD)
|
||
MENU.label(card, "Źródło: %s · poziom %d" % [map.source_planet,map.source_level], 11, MENU.MUTED)
|
||
var cost: int = DATA.fuel_cost(map)
|
||
MENU.label(card, "Paliwo: %d deuteru" % cost, 12, Color("95dce8"))
|
||
var row := MENU.row(card)
|
||
var status := MENU.label(row,"",11)
|
||
status.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||
var map_id := str(map.id)
|
||
var fly := MENU.button(row,"LEĆ",func(): screen._travel_to_distant(map_id),true)
|
||
fly.name = "FlyDistant_"+map_id.md5_text().substr(0,8)
|
||
fly.tooltip_text = "Rozpocznij wyprawę. Pobiera %d deuteru." % cost
|
||
var refresh_status := func():
|
||
var missing := maxf(0.0,cost-progress.deuter)
|
||
status.text = "Paliwo gotowe" if missing <= 0 else "Brakuje %.1f deuteru" % missing
|
||
fly.disabled = missing > 0
|
||
refresh_status.call()
|
||
progress.changed.connect(refresh_status)
|
||
status.tree_exiting.connect(func():
|
||
if progress.changed.is_connected(refresh_status): progress.changed.disconnect(refresh_status)
|
||
, CONNECT_ONE_SHOT)
|