63 lines
2.2 KiB
GDScript
63 lines
2.2 KiB
GDScript
extends CanvasLayer
|
|
|
|
var ship: CharacterBody2D
|
|
var _retrying := false
|
|
|
|
func _ready() -> void:
|
|
layer = preload("res://scripts/ui/render_layers.gd").DEFEAT
|
|
name = "DefeatOverlay"
|
|
var root := Control.new()
|
|
add_child(root)
|
|
root.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
var shade := ColorRect.new()
|
|
shade.color = Color(0.015, 0.025, 0.045, 0.55)
|
|
root.add_child(shade)
|
|
shade.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
var center := CenterContainer.new()
|
|
root.add_child(center)
|
|
center.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
|
var panel := PanelContainer.new()
|
|
panel.custom_minimum_size.x = 390
|
|
var style := StyleBoxFlat.new()
|
|
style.bg_color = Color("0b1520f5")
|
|
style.border_color = Color("bf604d")
|
|
style.set_border_width_all(1)
|
|
style.border_width_top = 3
|
|
style.set_content_margin_all(24)
|
|
style.set_corner_radius_all(5)
|
|
panel.add_theme_stylebox_override("panel", style)
|
|
center.add_child(panel)
|
|
var contents := VBoxContainer.new()
|
|
contents.add_theme_constant_override("separation", 14)
|
|
panel.add_child(contents)
|
|
var title := Label.new()
|
|
title.text = "STATEK ZNISZCZONY"
|
|
title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
title.add_theme_font_size_override("font_size", 20)
|
|
title.add_theme_color_override("font_color", Color("ffae8c"))
|
|
contents.add_child(title)
|
|
var note := Label.new()
|
|
note.text = "Układ %d\nWyposażenie i zapasy zostają zachowane." % GameState.system_level
|
|
note.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
note.add_theme_font_size_override("font_size", 11)
|
|
note.add_theme_color_override("font_color", Color("a6bdce"))
|
|
contents.add_child(note)
|
|
var retry := Button.new()
|
|
retry.name = "RetryButton"
|
|
retry.text = "SPRÓBUJ PONOWNIE [R]"
|
|
preload("res://scripts/ui/hud_button_style.gd").apply(retry)
|
|
var key := InputEventKey.new()
|
|
key.physical_keycode = KEY_R
|
|
retry.shortcut = Shortcut.new()
|
|
retry.shortcut.events = [key]
|
|
retry.pressed.connect(_retry)
|
|
contents.add_child(retry)
|
|
root.modulate.a = 0
|
|
create_tween().tween_property(root, "modulate:a", 1.0, 0.3)
|
|
|
|
func _retry() -> void:
|
|
if _retrying or not is_instance_valid(ship):
|
|
return
|
|
_retrying = true
|
|
ship.call("_restart_level_after_destruction")
|