2026-10-29 17:27:47 +02:00
extends CanvasLayer
signal chosen ( action : String )
const INK := Color ( " e4e7df " )
const MUTED := Color ( " a1b0ac " )
const AMBER := Color ( " e1bb7f " )
const BG := Color ( 0.035 , 0.060 , 0.069 , 0.97 )
var root : Control
var time_label : Label
var date_label : Label
var loop_label : Label
var progress : ProgressBar
var objective : Label
var subtitle : Label
var hint : Label
var memory_label : Label
var dialog : PanelContainer
var dialog_title : Label
var dialog_body : Label
var options : VBoxContainer
var dialog_scroll : ScrollContainer
var splash : ColorRect
var splash_box : VBoxContainer
var flash : ColorRect
var dialog_open := false
func _ready ( ) - > void :
root = Control . new ( )
root . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
root . mouse_filter = Control . MOUSE_FILTER_IGNORE
add_child ( root )
var theme := Theme . new ( )
theme . default_font_size = 18
var normal := style ( Color ( " 172b31 " ) , 10 )
normal . border_color = Color ( " 34494c " )
normal . set_border_width_all ( 1 )
theme . set_stylebox ( " normal " , " Button " , normal )
var hover := style ( Color ( " 2e4548 " ) , 10 )
hover . border_color = AMBER
hover . set_border_width_all ( 1 )
theme . set_stylebox ( " hover " , " Button " , hover )
theme . set_stylebox ( " pressed " , " Button " , style ( Color ( " 475447 " ) , 10 ) )
theme . set_stylebox ( " focus " , " Button " , hover )
theme . set_color ( " font_color " , " Button " , INK )
root . theme = theme
build_hud ( )
build_dialog ( )
flash = ColorRect . new ( )
flash . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
flash . color = Color ( 1 , 0.93 , 0.78 , 0 )
flash . mouse_filter = Control . MOUSE_FILTER_IGNORE
root . add_child ( flash )
show_start ( )
func style ( color : Color , radius : int = 0 ) - > StyleBoxFlat :
var s := StyleBoxFlat . new ( )
s . bg_color = color
s . set_corner_radius_all ( radius )
s . content_margin_left = 22
s . content_margin_right = 22
s . content_margin_top = 18
s . content_margin_bottom = 18
return s
func label ( text : String , size : int = 18 , color : Color = INK ) - > Label :
var item := Label . new ( )
item . text = text
item . add_theme_font_size_override ( " font_size " , size )
item . add_theme_color_override ( " font_color " , color )
return item
func button ( text : String , action : String , parent : Node = null ) - > Button :
var b := Button . new ( )
b . text = text
2026-10-29 21:36:20 +02:00
b . set_meta ( " action " , action )
2026-10-29 17:27:47 +02:00
b . alignment = HORIZONTAL_ALIGNMENT_LEFT
b . custom_minimum_size . y = 48
b . mouse_default_cursor_shape = Control . CURSOR_POINTING_HAND
b . pressed . connect ( func ( ) : chosen . emit ( action ) )
if parent == null :
options . add_child ( b )
else :
parent . add_child ( b )
return b
2026-10-29 21:36:20 +02:00
func action_button ( id : String , node : Node = null ) - > Button :
if node == null :
node = root
for child in node . get_children ( ) :
if child is Button and child . is_visible_in_tree ( ) and child . get_meta ( " action " , " " ) == id :
return child
var found := action_button ( id , child )
if found != null :
return found
return null
2026-10-29 17:27:47 +02:00
func build_hud ( ) - > void :
var top := PanelContainer . new ( )
root . add_child ( top )
top . set_anchors_and_offsets_preset ( Control . PRESET_TOP_WIDE )
top . offset_left = 28
top . offset_right = - 28
top . offset_top = 24
top . offset_bottom = 122
top . add_theme_stylebox_override ( " panel " , style ( Color ( 0.025 , 0.045 , 0.052 , 0.91 ) , 8 ) )
var row := HBoxContainer . new ( )
row . add_theme_constant_override ( " separation " , 28 )
top . add_child ( row )
var brand := VBoxContainer . new ( )
brand . size_flags_horizontal = Control . SIZE_EXPAND_FILL
row . add_child ( brand )
brand . add_child ( label ( " ДО ОТБОЯ " , 26 , INK ) )
loop_label = label ( " ПЕТЛЯ 01 / КВАРТИРА № 17 " , 13 , MUTED )
brand . add_child ( loop_label )
var memory_box := VBoxContainer . new ( )
row . add_child ( memory_box )
memory_label = label ( " ПАМЯТЬ 0 / 10 " , 14 , AMBER )
memory_box . add_child ( memory_label )
button ( " Дневник · J " , " journal " , memory_box ) . custom_minimum_size . y = 36
var clock_box := VBoxContainer . new ( )
row . add_child ( clock_box )
time_label = label ( " 07:00 " , 34 , AMBER )
time_label . horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
clock_box . add_child ( time_label )
date_label = label ( " 21:42 / ДО УДАРА " , 12 , MUTED )
clock_box . add_child ( date_label )
progress = ProgressBar . new ( )
progress . set_anchors_and_offsets_preset ( Control . PRESET_TOP_WIDE )
progress . offset_top = 131
progress . offset_bottom = 134
progress . offset_left = 30
progress . offset_right = - 30
progress . max_value = 420
progress . value = 420
progress . show_percentage = false
progress . mouse_filter = Control . MOUSE_FILTER_IGNORE
var track := StyleBoxFlat . new ( )
track . bg_color = Color ( " 23383d " )
var fill := StyleBoxFlat . new ( )
fill . bg_color = AMBER
progress . add_theme_stylebox_override ( " background " , track )
progress . add_theme_stylebox_override ( " fill " , fill )
root . add_child ( progress )
var bottom := PanelContainer . new ( )
root . add_child ( bottom )
bottom . set_anchors_and_offsets_preset ( Control . PRESET_BOTTOM_WIDE )
bottom . offset_left = 28
bottom . offset_right = - 28
bottom . offset_top = - 119
bottom . offset_bottom = - 22
bottom . add_theme_stylebox_override ( " panel " , style ( Color ( 0.025 , 0.045 , 0.052 , 0.94 ) , 8 ) )
bottom . mouse_filter = Control . MOUSE_FILTER_IGNORE
var stack := VBoxContainer . new ( )
stack . mouse_filter = Control . MOUSE_FILTER_IGNORE
bottom . add_child ( stack )
2026-10-29 21:36:20 +02:00
objective = label ( " Найдите телефон. Катя ждёт ответа. " , 19 )
2026-10-29 17:27:47 +02:00
stack . add_child ( objective )
stack . add_child ( label ( " ЛКМ — идти / предмет WASD — движение E — взаимодействие J — память R — новая петля M — звук " , 13 , MUTED ) )
hint = label ( " " , 17 , AMBER )
root . add_child ( hint )
hint . set_anchors_and_offsets_preset ( Control . PRESET_BOTTOM_WIDE )
hint . offset_top = - 155
hint . offset_bottom = - 125
hint . horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
hint . mouse_filter = Control . MOUSE_FILTER_IGNORE
subtitle = label ( " " , 18 , INK )
root . add_child ( subtitle )
subtitle . set_anchors_and_offsets_preset ( Control . PRESET_TOP_WIDE )
subtitle . offset_top = 154
subtitle . offset_bottom = 218
subtitle . offset_left = 40
subtitle . offset_right = - 550
subtitle . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
subtitle . add_theme_color_override ( " font_outline_color " , Color ( " 0c151b " ) )
subtitle . add_theme_constant_override ( " outline_size " , 5 )
subtitle . mouse_filter = Control . MOUSE_FILTER_IGNORE
func build_dialog ( ) - > void :
dialog = PanelContainer . new ( )
root . add_child ( dialog )
dialog . set_anchors_and_offsets_preset ( Control . PRESET_RIGHT_WIDE )
dialog . offset_left = - 500
dialog . offset_right = - 28
dialog . offset_top = 155
dialog . offset_bottom = - 145
var s := style ( BG , 10 )
s . border_color = Color ( " 4b625e " )
s . set_border_width_all ( 1 )
dialog . add_theme_stylebox_override ( " panel " , s )
var column := VBoxContainer . new ( )
column . add_theme_constant_override ( " separation " , 16 )
dialog . add_child ( column )
var heading := HBoxContainer . new ( )
column . add_child ( heading )
dialog_title = label ( " " , 23 , AMBER )
dialog_title . size_flags_horizontal = Control . SIZE_EXPAND_FILL
dialog_title . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
heading . add_child ( dialog_title )
button ( " × " , " close " , heading ) . custom_minimum_size = Vector2 ( 44 , 44 )
dialog_scroll = ScrollContainer . new ( )
dialog_scroll . size_flags_vertical = Control . SIZE_EXPAND_FILL
dialog_scroll . horizontal_scroll_mode = ScrollContainer . SCROLL_MODE_DISABLED
column . add_child ( dialog_scroll )
var content := VBoxContainer . new ( )
content . size_flags_horizontal = Control . SIZE_EXPAND_FILL
content . add_theme_constant_override ( " separation " , 18 )
dialog_scroll . add_child ( content )
dialog_body = label ( " " , 17 , INK )
dialog_body . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
dialog_body . size_flags_horizontal = Control . SIZE_EXPAND_FILL
content . add_child ( dialog_body )
options = VBoxContainer . new ( )
options . add_theme_constant_override ( " separation " , 8 )
content . add_child ( options )
column . add_child ( label ( " Время идёт во время разговора. Esc — закрыть " , 12 , MUTED ) )
dialog . hide ( )
func show_dialog ( title : String , body : String , choices : Array ) - > void :
dialog_open = true
dialog_title . text = title
dialog_body . text = body
for child in options . get_children ( ) :
options . remove_child ( child )
child . queue_free ( )
for choice in choices :
button ( choice [ 0 ] , choice [ 1 ] )
dialog_scroll . scroll_vertical = 0
dialog . show ( )
func close_dialog ( ) - > void :
dialog_open = false
dialog . hide ( )
func show_start ( ) - > void :
splash = ColorRect . new ( )
splash . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
splash . color = Color ( 0.025 , 0.045 , 0.052 , 0.82 )
root . add_child ( splash )
var margin := MarginContainer . new ( )
splash . add_child ( margin )
margin . set_anchors_and_offsets_preset ( Control . PRESET_CENTER_LEFT )
margin . offset_left = 100
margin . offset_right = 740
margin . offset_top = - 270
margin . offset_bottom = 270
splash_box = VBoxContainer . new ( )
splash_box . add_theme_constant_override ( " separation " , 20 )
margin . add_child ( splash_box )
splash_box . add_child ( label ( " ИНТЕРАКТИВНЫЙ ПРОТОТИП / GODOT 4 " , 13 , AMBER ) )
splash_box . add_child ( label ( " ДО ОТБОЯ " , 60 ) )
2026-10-29 21:36:20 +02:00
var intro := label ( " 21:42. Катя везёт вашего сына домой. \n По телефону она спрашивает, почему вы отправили их к школе. Вы ничего такого не помните. \n \n До удара — семь реальных минут. Квартира вернётся в начало. Всё, что вы узнаете, останется с вами. " , 21 )
2026-10-29 17:27:47 +02:00
intro . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
splash_box . add_child ( intro )
button ( " Начать вечер → " , " start " , splash_box )
splash_box . add_child ( label ( " Мышь или WASD · E — предметы · J — память \n Диалоги не останавливают таймер. 10 мрачных исходов. " , 14 , MUTED ) )
func hide_splash ( ) - > void :
if is_instance_valid ( splash ) :
splash . queue_free ( )
func show_ending ( title : String , body : String , number : int , discovered : int ) - > void :
close_dialog ( )
hide_splash ( )
splash = ColorRect . new ( )
splash . set_anchors_and_offsets_preset ( Control . PRESET_FULL_RECT )
splash . color = Color ( 0.018 , 0.029 , 0.034 , 0.97 )
root . add_child ( splash )
var margin := MarginContainer . new ( )
splash . add_child ( margin )
margin . set_anchors_and_offsets_preset ( Control . PRESET_CENTER )
margin . offset_left = - 440
margin . offset_right = 440
margin . offset_top = - 310
margin . offset_bottom = 310
splash_box = VBoxContainer . new ( )
splash_box . add_theme_constant_override ( " separation " , 20 )
margin . add_child ( splash_box )
var caption := " ИСХОД %02d / 10 · ОТКРЫТО %d / 10 " % [ number , discovered ]
if number == 0 :
caption = " НОВАЯ ПЕТЛЯ · ПАМЯТЬ СОХРАНЕНА "
splash_box . add_child ( label ( caption , 14 , AMBER ) )
splash_box . add_child ( label ( title , 42 ) )
var text := label ( body , 22 )
text . autowrap_mode = TextServer . AUTOWRAP_WORD_SMART
splash_box . add_child ( text )
var row := HBoxContainer . new ( )
row . add_theme_constant_override ( " separation " , 16 )
splash_box . add_child ( row )
button ( " Ещё одна петля → " , " restart " , row )
button ( " Выйти " , " quit " , row )
func update_clock ( remaining : float , loop_count : int , fact_count : int ) - > void :
var seconds := int ( ceil ( maxf ( 0 , remaining ) ) )
time_label . text = " %02d : %02d " % [ seconds / 60 , seconds % 60 ]
time_label . add_theme_color_override ( " font_color " , Color ( " e18c77 " ) if remaining < = 60 else AMBER )
var elapsed := 420 - int ( remaining )
date_label . text = " 21: %02d / ДО УДАРА " % ( 42 + elapsed / 60 )
loop_label . text = " ПЕТЛЯ %02d / КВАРТИРА № 17 " % loop_count
memory_label . text = " ПАМЯТЬ %d / 10 " % fact_count
progress . value = remaining