Randoloot/scripts/ui/navigation_button.gd
2026-10-17 16:51:07 +02:00

58 lines
2.3 KiB
GDScript

extends "res://scripts/ui/captain_skill_button.gd"
var _skill_notification := false
var _pulse_time := 0.0
var _pulse_frames: Dictionary = {}
func _process(delta: float) -> void:
if name != "OpenCaptainSkills":
return
var available := GameState.captain.learning_points > 0
if available and _pulse_frames.is_empty():
for state in ["normal", "hover", "pressed"]:
_pulse_frames[state] = get_theme_stylebox(state).duplicate()
if available:
_pulse_time += delta
var pulse := 0.5 + 0.5 * sin(_pulse_time * TAU / 1.6)
for state in _pulse_frames:
var frame := get_theme_stylebox(state) as StyleBoxFlat
frame.border_color = Color("b9a0ef").lerp(Color("ffe2a1"), pulse)
frame.shadow_color = Color(0.72, 0.5, 1.0, 0.25 + pulse * 0.4)
frame.shadow_size = int(7 + pulse * 9)
tooltip_text = "Umiejętności kapitana · punkty do wydania: %d" % GameState.captain.learning_points
elif _skill_notification:
for state in _pulse_frames:
add_theme_stylebox_override(state, _pulse_frames[state].duplicate())
_pulse_frames.clear()
_pulse_time = 0.0
tooltip_text = "Umiejętności kapitana"
_skill_notification = available
func configure_navigation(artwork: Texture2D, accent: Color, caption: String) -> void:
configure(artwork, accent)
custom_minimum_size = Vector2(64, 80)
for state in ["normal", "hover", "pressed"]:
var frame := get_theme_stylebox(state).duplicate() as StyleBoxFlat
frame.set_corner_radius_all(9)
frame.border_color = accent if state == "hover" else accent.darkened(0.45)
frame.shadow_color = Color(accent, 0.12 if state == "hover" else 0.04)
frame.shadow_size = 5 if state == "hover" else 3
add_theme_stylebox_override(state, frame)
var picture := get_node_or_null("RoundedArtwork") as TextureRect
if picture != null:
picture.offset_left = 5
picture.offset_right = -5
picture.offset_top = 5
picture.offset_bottom = -21
var label := Label.new()
label.text = caption
label.mouse_filter = Control.MOUSE_FILTER_IGNORE
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
label.add_theme_font_size_override("font_size", 9)
label.add_theme_color_override("font_color", accent.lightened(0.25))
add_child(label)
label.set_anchors_and_offsets_preset(Control.PRESET_BOTTOM_WIDE)
label.offset_top = -21
label.offset_bottom = -2