Randoloot/scripts/ui/mission_objectives.gd
2026-10-17 14:28:20 +02:00

51 lines
1.9 KiB
GDScript

extends PanelContainer
var game: Node2D
var _objective: Label
func _ready() -> void:
mouse_filter = Control.MOUSE_FILTER_IGNORE
var style := StyleBoxFlat.new()
style.bg_color = Color(0.025, 0.041, 0.063, 0.72)
style.border_color = Color("376779")
style.set_border_width_all(1)
style.set_corner_radius_all(6)
style.set_content_margin_all(12)
add_theme_stylebox_override("panel", style)
var contents := VBoxContainer.new()
contents.mouse_filter = Control.MOUSE_FILTER_IGNORE
contents.add_theme_constant_override("separation", 6)
add_child(contents)
var title := Label.new()
title.text = "CELE"
title.mouse_filter = Control.MOUSE_FILTER_IGNORE
title.add_theme_font_size_override("font_size", 12)
title.add_theme_color_override("font_color", Color("91dbea"))
contents.add_child(title)
_objective = Label.new()
_objective.name = "CurrentObjective"
_objective.mouse_filter = Control.MOUSE_FILTER_IGNORE
_objective.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
_objective.add_theme_font_size_override("font_size", 11)
_objective.add_theme_color_override("font_color", Color("efb568"))
contents.add_child(_objective)
func _process(_delta: float) -> void:
if not is_instance_valid(game):
return
if bool(game.get("system_cleared")):
_objective.text = "Znajdź zamieszkaną planetę"
elif bool(game.get("_boss_spawned")):
_objective.text = "Pokonaj bossa"
else:
_objective.text = "Pokonaj wszystkich wrogów"
var cockpit := get_parent().get_node_or_null("Cockpit") as Control
var available_width := cockpit.position.x - 24.0 if is_instance_valid(cockpit) else 260.0
var panel_width := clampf(available_width, 180.0, 260.0)
size.x = panel_width
size.y = get_combined_minimum_size().y
var bottom: float = (get_parent() as Control).size.y - 12.0
if available_width < 180.0 and is_instance_valid(cockpit):
bottom = cockpit.position.y - 64.0
position = Vector2(12.0, bottom - size.y)