extends Control signal closed const UI := preload("res://scripts/planets/expedition_ui.gd") const GEAR := preload("res://scripts/planets/captain_equipment.gd") var captain: Resource var inventory: Node var _content: VBoxContainer var _tab := "hangar" func _ready() -> void: set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) var background := ColorRect.new() background.color = Color("#050e18") background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) add_child(background) var margin := MarginContainer.new() margin.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT) for side in ["left","right","top","bottom"]: margin.add_theme_constant_override("margin_"+side, 30) add_child(margin) var rows := VBoxContainer.new() rows.add_theme_constant_override("separation", 18) margin.add_child(rows) var header := HBoxContainer.new() rows.add_child(header) var title := UI.label(header, "FRACHTOWIEC / POKŁAD OPERACYJNY", 27, UI.CYAN) title.size_flags_horizontal = Control.SIZE_EXPAND_FILL UI.button(header, "ODLOT [L / ESC]", func(): closed.emit()) var main := HBoxContainer.new() main.add_theme_constant_override("separation", 25) main.size_flags_vertical = Control.SIZE_EXPAND_FILL rows.add_child(main) var schematic := UI.panel(main, Vector2(300, 0)) schematic.size_flags_horizontal = Control.SIZE_EXPAND_FILL schematic.size_flags_stretch_ratio = 0.8 var left := VBoxContainer.new() left.add_theme_constant_override("separation", 14) schematic.add_child(left) UI.label(left, "TWÓJ MOBILNY PORT", 18, UI.CYAN) var art := TextureRect.new() art.texture = preload("res://assets/planets/freighter.png") art.expand_mode = TextureRect.EXPAND_IGNORE_SIZE art.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED art.size_flags_vertical = Control.SIZE_EXPAND_FILL art.custom_minimum_size = Vector2(260, 200) left.add_child(art) for entry in [["hangar","01 HANGAR"],["workshop","02 WARSZTAT"],["lab","03 LABORATORIUM"]]: var key: String = entry[0] UI.button(left, entry[1], func(): _tab = key; _refresh()) UI.label(left, "Frachtowiec podąża do kolejnego układu.\nZasoby i wyposażenie należą do kapitana.", 13) var right := UI.panel(main, Vector2(530, 0)) right.size_flags_horizontal = Control.SIZE_EXPAND_FILL var scroll := ScrollContainer.new() scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED right.add_child(scroll) _content = VBoxContainer.new() _content.size_flags_horizontal = Control.SIZE_EXPAND_FILL _content.add_theme_constant_override("separation", 14) scroll.add_child(_content) UI.label(rows, "Kosmos czeka na Twój powrót. • Naprawa lądownika: 1 część za 1% HP.", 14) _refresh() func _input(event: InputEvent) -> void: if event is InputEventKey and event.pressed and not event.echo and event.keycode in [KEY_L, KEY_ESCAPE]: closed.emit() get_viewport().set_input_as_handled() func _refresh() -> void: for child in _content.get_children(): _content.remove_child(child) child.queue_free() var progress: Resource = captain.expedition if _tab == "hangar": UI.label(_content, "HANGAR / LĄDOWNIK", 24, UI.CYAN) UI.label(_content, "Kadłub lądownika: %d / 100 HP" % ceili(progress.lander_hp), 19) var bar := ProgressBar.new() bar.value = progress.lander_hp bar.custom_minimum_size.y = 25 _content.add_child(bar) var cost: int = progress.repair_cost() UI.label(_content, "Części: %d · Koszt naprawy: %d" % [captain.parts, cost], 16) var repair := UI.button(_content, "NAPRAW DO 100%% · %d części" % cost, func(): progress.repair(captain) _refresh()) repair.disabled = cost == 0 or captain.parts < cost UI.label(_content, "Lądowanie wymaga 100% sprawności.\nWejście w atmosferę zużywa 5–20 HP.\nZniszczenie lądownika zabiera tylko łup bieżącej wyprawy.", 15) UI.label(_content, "MODUŁY DO ODEBRANIA: %d" % progress.delivered_modules.size(), 18, UI.CYAN) var delivery := UI.button(_content, "Przenieś moduły do ładowni statku", func(): progress.deliver_modules(inventory) _refresh()) delivery.disabled = progress.delivered_modules.is_empty() UI.label(_content, "Jeśli ładownia jest pełna, moduły czekają na odbiór.", 13) elif _tab == "workshop": UI.label(_content, "WARSZTAT / EKWIPUNEK KAPITANA", 23, UI.CYAN) UI.label(_content, "Każdy poziom usuwa 2 pp odpowiedniego zagrożenia.\nL50 neutralizuje je całkowicie. Sprzęt powstaje w warsztacie.", 15) for kind in GEAR.KINDS: var card := UI.panel(_content) var row := HBoxContainer.new() row.add_theme_constant_override("separation", 14) card.add_child(row) var icon := TextureRect.new() icon.texture = GEAR.icon(kind) icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED icon.custom_minimum_size = Vector2(70,70) row.add_child(icon) var column := VBoxContainer.new() column.size_flags_horizontal = Control.SIZE_EXPAND_FILL row.add_child(column) UI.label(column, "%s · POZ. %d" % [GEAR.NAMES[kind], GEAR.next_level(captain,kind)], 18) var recipe := UI.label(column, GEAR.recipe_text(captain,kind), 13) recipe.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART var button := UI.button(column, "WYTWÓRZ I ZAŁÓŻ", _craft.bind(kind)) button.disabled = not GEAR.can_craft(captain,kind) UI.label(_content, "POSIADANE WYPOSAŻENIE", 18, UI.CYAN) for gear in captain.gear_items: var equipped: bool = captain.gear_slots.get(gear.kind,-1) == gear.uid UI.button(_content, "%s · poziom %d%s" % [GEAR.NAMES[gear.kind],gear.level," [ZAŁOŻONE]" if equipped else " — ZAŁÓŻ"], _equip.bind(gear.kind,gear.uid)).disabled = equipped var stock := UI.label(_content, "ZASOBY: " + UI.material_text(captain.minerals) + " · Części: %d" % captain.parts, 13) stock.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART else: UI.label(_content, "LABORATORIUM / ARCHIWUM", 24, UI.CYAN) UI.label(_content, "ZESKANOWANE PLANETY: %d" % progress.scans.size(), 17) for profile in progress.scans.values(): UI.label(_content, "%s · tlen %d%% · %d°C · flora %d" % [profile.name,profile.oxygen,profile.temperature,profile.flora], 15) if progress.scans.is_empty(): UI.label(_content, "Podleć do planety earthlike i wykonaj skan [F].", 15) UI.label(_content, "ODZYSKANE ARCHIWA", 18, UI.CYAN) for key in progress.research_records: UI.label(_content, "%s ×%d" % [key,progress.research_records[key]], 15) UI.label(_content, "Archiwa są przechowywane na przyszłe badania technologii.", 14) func _craft(kind: String) -> void: var gear: Dictionary = GEAR.craft(captain,kind) if not gear.is_empty(): GEAR.equip(captain,kind,int(gear.uid)) _refresh() func _equip(kind: String, uid: int) -> void: GEAR.equip(captain,kind,uid) _refresh()