57 lines
2.5 KiB
GDScript
57 lines
2.5 KiB
GDScript
extends Control
|
|
## Shared, compact visual vocabulary for the expedition screens.
|
|
const COMPACT := preload("res://scripts/ui/compact_interface.gd")
|
|
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, COMPACT.WINDOW_ALPHA)
|
|
style.border_color = Color("#345763")
|
|
style.set_border_width_all(1)
|
|
style.set_corner_radius_all(COMPACT.CORNER_RADIUS)
|
|
style.content_margin_left = 10
|
|
style.content_margin_right = 10
|
|
style.content_margin_top = 8
|
|
style.content_margin_bottom = 8
|
|
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", COMPACT.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.add_theme_font_size_override("font_size", COMPACT.BODY_SIZE)
|
|
node.custom_minimum_size.y = 30
|
|
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.bg_color.a = 0.48 if state == "normal" else 0.64
|
|
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", "experience":"EXP", "samples":"Próbki do analizy", "ammunition":"Amunicja", "irradiated_ammunition":"Amunicja radiacyjna"})
|
|
var pieces: PackedStringArray = []
|
|
for key in materials:
|
|
pieces.append("%s: %d" % [names.get(key, key), materials[key]])
|
|
return " · ".join(pieces)
|