extends RefCounted const MENU := preload("res://scripts/planets/freighter_menu.gd") const ORBS := preload("res://scripts/items/special_orbs.gd") static func build(screen: Control) -> void: var progress: Resource = screen.captain.expedition MENU.label(screen._content,"ORBY / SPECJALNE ULEPSZENIA",15,Color("d9b5ff")) MENU.label(screen._content,"Każdy orb jest jednorazowy i znika po użyciu. Kolejny awans wymaga kolejnej sztuki. Efekty tego samego orba nie sumują się. Orby typu obrażeń zastępują się. Replika trafia do magazynu.",12,MENU.MUTED) for id in ORBS.IDS: var card := MENU.card(screen._content) var header := MENU.row(card) MENU.icon(header,ORBS.icon(id),48) var title := MENU.label(header,"%s · %d szt." % [ORBS.NAMES[id],ORBS.count(progress,screen.inventory,id)],14,MENU.GOLD) title.size_flags_horizontal = Control.SIZE_EXPAND_FILL title.custom_minimum_size.x = 180 MENU.label(card,ORBS.DESCRIPTIONS[id],12) var choices := OptionButton.new() choices.size_flags_horizontal = Control.SIZE_EXPAND_FILL choices.fit_to_longest_item = false choices.add_theme_font_override("font",ThemeDB.fallback_font) choices.add_theme_font_size_override("font_size",12) card.add_child(choices) if is_instance_valid(screen.inventory): for kind in ["weapon","module","extension","cargo"]: var items: Array = screen.inventory._get_slots(kind) for index in items.size(): if not screen.inventory.is_slot_unlocked(kind,index): continue _add_item(choices,items[index],id,{"weapon":"Broń","module":"Moduł","cargo":"Ładownia","extension":"Rozszerzenie"}[kind]) for item in progress.freighter_storage: _add_item(choices,item,id,"Magazyn fregaty") if choices.item_count == 0: choices.add_item("Brak odpowiedniego przedmiotu") var apply := MENU.button(card,"AWANSUJ +1 POZIOM" if id == "advancement" else ("REPLIKUJ" if id == "replication" else "NAŁÓŻ ORB"),func(): var target: ItemInstance = choices.get_selected_metadata() if ORBS.apply(progress,screen.inventory,target,id): screen._audio.service_completed(-0.48) screen._refresh() ,true) apply.name = "ApplyOrb_"+id apply.disabled = ORBS.count(progress,screen.inventory,id) <= 0 or choices.get_selected_metadata() == null static func _add_item(choices: OptionButton, item: ItemInstance, orb: String, location: String) -> void: if not ORBS.accepts(item,orb): return choices.add_item("%s · poz. %d · %s" % [item.definition.display_name,item.item_level,location]) choices.set_item_metadata(choices.item_count-1,item)