Add timed friend messages before and after the call breaks

This commit is contained in:
Codex
2026-10-29 22:36:22 +02:00
parent 2b2cc8686a
commit 39f9af7b53
8 changed files with 264 additions and 9 deletions
+24 -1
View File
@@ -891,5 +891,28 @@
"title": "Катя?..",
"text": "После удара мама успела ответить. Через несколько секунд сеть исчезла. Она была жива в эту секунду. Что будет дальше, игра не знает."
}
}
},
"friend": "Аня",
"notifications": [
{
"at": 17,
"text": "Кать, у вас тоже тревога?"
},
{
"at": 34,
"text": "Я сижу в коридоре. Ты как?"
},
{
"at": 56,
"text": "Сообщения еле уходят. Напиши, когда сможешь."
},
{
"at": 76,
"text": "Ты читала новости? Там переговоры, походу скоро все закончится"
},
{
"at": 92,
"text": "Кать в твой дом походу попали..."
}
]
}
+118 -5
View File
@@ -58,6 +58,14 @@ var room: AudioStreamPlayer
var siren: AudioStreamPlayer
var effect: AudioStreamPlayer
var hum: AudioStreamPlayer
var notification_sound: AudioStreamPlayer
var notification_card: PanelContainer
var inbox_button: Button
var notifications: Array = []
var notification_cursor := 0
var unread := 0
var toast_until := 0.0
var viewing_messages := false
var wave_bars: Array[ColorRect] = []
var screen_fade: ColorRect
@@ -155,6 +163,10 @@ func make_ui() -> void:
var brand := label("ДО ОТБОЯ / НЕ КЛАДИ ТРУБКУ", 22, ACCENT)
brand.size_flags_horizontal = Control.SIZE_EXPAND_FILL
top.add_child(brand)
inbox_button = button("Сообщения", "messages", show_messages)
inbox_button.custom_minimum_size.x = 185
inbox_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
top.add_child(inbox_button)
var menu_button := button("Меню", "menu", func(): show_menu())
menu_button.custom_minimum_size.x = 120
menu_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
@@ -231,6 +243,15 @@ func make_ui() -> void:
screen_fade.mouse_filter = Control.MOUSE_FILTER_IGNORE
screen_fade.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
ui.add_child(screen_fade)
notification_card = PanelContainer.new()
notification_card.set_anchors_and_offsets_preset(Control.PRESET_TOP_RIGHT)
notification_card.offset_left = -500
notification_card.offset_right = -24
notification_card.offset_top = 82
notification_card.add_theme_stylebox_override("panel", style(Color("35434a"), ACCENT, 16))
notification_card.z_index = 100
notification_card.visible = false
ui.add_child(notification_card)
refresh()
func clear_children(parent: Node) -> void:
@@ -239,11 +260,89 @@ func clear_children(parent: Node) -> void:
child.queue_free()
func close_overlay() -> void:
viewing_messages = false
if is_instance_valid(overlay):
ui.remove_child(overlay)
overlay.queue_free()
overlay = null
func show_messages() -> void:
var box := modal()
viewing_messages = true
unread = 0
refresh_inbox_button()
notification_card.visible = false
box.add_child(label(str(story.friend) + " · подруга", 34))
box.add_child(label("Звонок с мамой продолжается. Время идёт." if running else "Сообщения за последний звонок", 18, ACCENT))
var scroll := ScrollContainer.new()
scroll.custom_minimum_size = Vector2(780, 430)
scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
box.add_child(scroll)
var messages := column(scroll)
messages.size_flags_horizontal = Control.SIZE_EXPAND_FILL
if notifications.is_empty():
messages.add_child(label("Пока нет новых сообщений.", 22, MUTED))
for entry in notifications:
var card := PanelContainer.new()
card.add_theme_stylebox_override("panel", style(Color("26343c")))
messages.add_child(card)
var content := column(card)
content.add_child(label("Аня · %02d:%02d" % [int(entry.at) / 60, int(entry.at) % 60], 16, ACCENT))
content.add_child(label(entry.text, 23))
box.add_child(button("Вернуться к маме" if running else "Назад", "close_messages", func():
close_overlay()
if impacted: show_ending()))
scroll_inbox_to_latest.call_deferred(scroll)
func scroll_inbox_to_latest(scroll: ScrollContainer) -> void:
await get_tree().process_frame
if is_instance_valid(scroll):
scroll.scroll_vertical = int(scroll.get_v_scroll_bar().max_value)
func refresh_inbox_button() -> void:
inbox_button.text = "Сообщения" + (" · %d" % unread if unread > 0 else "")
func update_notifications(second: float) -> void:
if not running and not impacted: return
while notification_cursor < story.notifications.size():
var entry: Dictionary = story.notifications[notification_cursor]
if second < float(entry.at): break
notifications.append(entry.duplicate())
notification_cursor += 1
unread += 1
notification_sound.play()
refresh_inbox_button()
if viewing_messages:
show_messages()
else:
show_notification(entry, second)
if notification_card.visible and second >= toast_until:
notification_card.visible = false
func show_notification(entry: Dictionary, second: float) -> void:
clear_children(notification_card)
var content := column(notification_card)
var heading := HBoxContainer.new()
content.add_child(heading)
var sender := label(str(story.friend) + " · СООБЩЕНИЕ", 16, ACCENT)
sender.size_flags_horizontal = Control.SIZE_EXPAND_FILL
heading.add_child(sender)
var dismiss := button("×", "dismiss_push", func(): notification_card.visible = false)
dismiss.autowrap_mode = TextServer.AUTOWRAP_OFF
dismiss.custom_minimum_size = Vector2(52, 36)
heading.add_child(dismiss)
var message := button(entry.text, "open_push", show_messages)
message.custom_minimum_size.y = 76
content.add_child(message)
content.add_child(label("Открыть переписку · время звонка идёт" if running else "Открыть переписку", 14, MUTED))
notification_card.visible = true
notification_card.size = Vector2(476, 0)
fit_notification.call_deferred()
toast_until = second + (12.0 if notification_cursor == 5 else 7.0)
func fit_notification() -> void:
notification_card.size = Vector2(476, notification_card.get_combined_minimum_size().y)
func modal() -> VBoxContainer:
close_overlay()
var shade := PanelContainer.new()
@@ -335,6 +434,12 @@ func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
voice.stop()
effect.stop()
hum.stop()
notification_sound.stop()
notification_card.visible = false
notifications.clear()
notification_cursor = 0
unread = 0
refresh_inbox_button()
siren.stop()
room.play()
room.volume_db = -28
@@ -364,9 +469,12 @@ func begin_call(number: int, testing: bool, knowledge: int = 1) -> void:
refresh()
func _process(_delta: float) -> void:
if not running: return
elapsed = maxf(0, (Time.get_ticks_msec() - start_tick) / 1000.0)
advance()
if not running and not impacted: return
var second := maxf(0, (Time.get_ticks_msec() - start_tick) / 1000.0)
if running:
elapsed = second
advance()
update_notifications(second)
func advance() -> void:
if not running: return
@@ -519,6 +627,7 @@ func strike() -> void:
screen_fade.color = Color(0, 0, 0, 0.94)
status_label.text = "Соединение прервано"
refresh_commands()
if viewing_messages: show_messages()
if qa_mode: return
var epoch := start_tick
await get_tree().create_timer(2.0).timeout
@@ -530,7 +639,7 @@ func strike() -> void:
else:
say("after_call")
await get_tree().create_timer(voice_length("after_call") + 0.8).timeout
if epoch == start_tick and impacted: show_ending()
if epoch == start_tick and impacted and not viewing_messages: show_ending()
func show_ending() -> void:
var entry: Dictionary = story.endings[outcome]
@@ -544,6 +653,7 @@ func show_ending() -> void:
box.add_child(button("Перезвонить · следующая итерация" if chapter < 10 else "Ещё один звонок", "next", func(): continue_call()))
box.add_child(button("Повторить этот звонок", "retry", func(): continue_call(true)))
box.add_child(button("Прочитать разговор", "transcript", show_transcript))
box.add_child(button("Сообщения от подруги", "ending_messages", show_messages))
box.add_child(button("В меню", "end_menu", show_menu))
func continue_call(retry: bool = false) -> void:
@@ -676,7 +786,8 @@ func make_audio() -> void:
siren = AudioStreamPlayer.new()
effect = AudioStreamPlayer.new()
hum = AudioStreamPlayer.new()
for player in [voice, room, siren, effect, hum]: add_child(player)
notification_sound = AudioStreamPlayer.new()
for player in [voice, room, siren, effect, hum, notification_sound]: add_child(player)
AudioServer.add_bus()
var bus := AudioServer.bus_count - 1
AudioServer.set_bus_name(bus, "Phone")
@@ -698,4 +809,6 @@ func make_audio() -> void:
effect.volume_db = -12
hum.stream = load("res://assets/audio/approach.wav")
hum.volume_db = -25
notification_sound.stream = load("res://assets/audio/click.wav")
notification_sound.volume_db = -16
AudioServer.set_bus_volume_db(0, linear_to_db(master_volume))
+57 -1
View File
@@ -240,6 +240,62 @@ func run(target: Node) -> void:
cfg.save(save_file)
saved = game.Profile.read_profile(save_file, game.story.facts, game.story.endings)
check(saved.facts == {"lamp": true} and saved.loops == 0, "Invalid save data filtered")
# Notifications are an independent clock: four during the call, the fifth
# two seconds after the strike. Reading never pauses or cancels mom's task.
start(2)
at(16.9)
check(game.notifications.is_empty(), "No early push")
at(17)
check(game.notifications.size() == 1 and game.unread == 1, "First push at 17 seconds")
check(game.notification_card.visible, "Push is visible")
click("dismiss_push")
check(not game.notification_card.visible and game.unread == 1, "Dismiss keeps message unread")
click("keys_search")
at(34)
check(game.notifications.size() == 2 and not game.busy.is_empty(), "Second push during mom task")
click("open_push")
check(game.viewing_messages and game.unread == 0, "Open push reads inbox")
at(40)
check(game.items.has("keys") and game.elapsed >= 40, "Mom task and clock continue while reading")
click("close_messages")
check(not game.viewing_messages and game.overlay == null, "Return to call")
at(56)
check(game.notifications.size() == 3, "Third push")
at(76)
check(game.notifications.size() == 4, "Fourth push")
check(game.notifications[3].text == "Ты читала новости? Там переговоры, походу скоро все закончится", "Exact fourth text")
await capture("phone-fourth-push")
at(90)
check(game.impacted and game.notifications.size() == 4, "No fifth message before impact")
at(91.9)
check(game.notifications.size() == 4, "Fifth push waits until after impact")
game.show_ending()
at(92)
check(game.notifications.size() == 5 and game.notification_card.visible, "Fifth push over ending screen")
check(game.notifications[4].text == "Кать в твой дом походу попали...", "Exact fifth text")
await capture("phone-after-impact-push")
check(game.notification_card.size.y < 300, "Toast stays compact across all five pushes")
click("open_push")
check(game.viewing_messages and game.notifications.size() == 5, "All messages readable after impact")
await capture("phone-inbox")
at(96)
check(game.notifications.size() == 5, "No duplicate messages")
click("close_messages")
click("next")
check(game.notifications.is_empty() and game.unread == 0 and not game.notification_card.visible, "Redial resets message history")
# Use the production delayed transition once: a reader who opens the final
# push must not have the inbox closed by the ending coroutine a moment later.
start(2)
game.qa_mode = false
at(90)
await game.get_tree().create_timer(2.2).timeout
check(game.notifications.size() == 5 and game.notification_card.visible, "Production post-impact push arrives")
click("open_push")
await game.get_tree().create_timer(8.0).timeout
check(game.viewing_messages and game.action_button("close_messages") != null, "Ending transition preserves open inbox")
click("close_messages")
check(game.action_button("next") != null, "Inbox returns to production ending")
game.qa_mode = true
if "--phone-real-time" in OS.get_cmdline_user_args():
await realtime_check()
var file := FileAccess.open(directory().path_join("phone-result.json"), FileAccess.WRITE)
@@ -247,7 +303,7 @@ func run(target: Node) -> void:
file.close()
print("PHONE_QA ", "PASS" if errors.is_empty() else "FAIL", " checks=", checks, " route=", route_time, " errors=", errors)
await render()
for player in [game.voice, game.room, game.siren, game.effect, game.hum]:
for player in [game.voice, game.room, game.siren, game.effect, game.hum, game.notification_sound]:
player.stop()
player.stream = null
await game.get_tree().create_timer(0.1).timeout