Randoloot/scripts/planets/expedition_ui.gd
2026-10-18 08:43:54 +02:00

54 lines
2.2 KiB
GDScript

extends Control
## Shared, compact visual vocabulary for the expedition screens.
const INK := Color("#08151f")
const CYAN := Color("#81dce4")
static func panel(parent: Node, minimum := Vector2.ZERO) -> PanelContainer:
var node := PanelContainer.new()
node.custom_minimum_size = minimum
var style := StyleBoxFlat.new()
style.bg_color = Color(0.025, 0.065, 0.095, 0.96)
style.border_color = Color("#345763")
style.set_border_width_all(1)
style.set_corner_radius_all(12)
style.content_margin_left = 20
style.content_margin_right = 20
style.content_margin_top = 16
style.content_margin_bottom = 16
node.add_theme_stylebox_override("panel", style)
parent.add_child(node)
return node
static func label(parent: Node, text: String, size := 16, color := Color("#d5e4e8")) -> Label:
var node := Label.new()
node.text = text
node.add_theme_font_size_override("font_size", size)
node.add_theme_color_override("font_color", color)
parent.add_child(node)
return node
static func button(parent: Node, text: String, action: Callable) -> Button:
var node := Button.new()
node.text = text
node.custom_minimum_size.y = 40
node.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
for state in ["normal", "hover", "pressed", "disabled"]:
var style := StyleBoxFlat.new()
style.bg_color = Color("#15303e") if state == "normal" else Color("#235465")
if state == "disabled":
style.bg_color = Color("#101e26")
style.border_color = Color("#426d7d") if state != "hover" else CYAN
style.set_border_width_all(1)
style.set_corner_radius_all(6)
style.content_margin_left = 14
style.content_margin_right = 14
node.add_theme_stylebox_override(state, style)
node.pressed.connect(action)
parent.add_child(node)
return node
static func material_text(materials: Dictionary) -> String:
var names: Dictionary = preload("res://scripts/items/crafting_recipes.gd").NAMES.duplicate()
names.merge(preload("res://scripts/planets/captain_equipment.gd").MATERIAL_NAMES)
names.merge({"parts":"Części", "missile":"Rakiety", "credits":"Kredyty"})
var pieces: PackedStringArray = []
for key in materials:
pieces.append("%s: %d" % [names.get(key, key), materials[key]])
return " · ".join(pieces)