Remove request cancellation and protect the final mother dialogue

This commit is contained in:
Codex
2026-10-30 12:49:18 +02:00
parent 2476242d27
commit aa45c6c0bd
9 changed files with 137 additions and 53 deletions
+20 -19
View File
@@ -56,7 +56,6 @@ var task_label: Label
var title_label: Label
var phase_label: Label
var busy_bar: ProgressBar
var cancel_button: Button
var last_caption: Label
var voice: AudioStreamPlayer
var soundscape: Node
@@ -548,21 +547,34 @@ func advance() -> void:
refresh_commands()
"hum":
fired.hum = elapsed
# The final reaction owns the rest of the call. Stop pending requests
# before speaking, so neither a late reply nor a click can replace it.
events.clear()
busy = {}
soundscape.cancel_task()
hum.play()
say("hum")
refresh_commands()
"dialogue":
var event: Dictionary = events.pop_front()
if busy.is_empty() and not fired.has("hum"): say(event.line)
"reply":
replied = true
say(busy.response)
# Leave a clean breath before the fixed final line. Katya may be cut
# short by that line, but do not begin a mother reply that cannot fit.
if elapsed + voice_length(busy.response) + 0.2 <= float(story.timeline.hum):
say(busy.response)
else:
# An unheard answer must not grant knowledge or items just before
# the final reaction. That reaction will interrupt the request.
busy_end = maxf(busy_end,float(story.timeline.hum))
"finish": finish_task()
elapsed = target
soundscape.advance(elapsed, place)
refresh_live()
func command_allowed(action: Dictionary) -> bool:
if not running or chapter == 1 or elapsed >= float(story.timeline.impact) or not busy.is_empty(): return false
if not running or chapter == 1 or fired.has("hum") or elapsed >= float(story.timeline.hum) or not busy.is_empty(): return false
if action.get("once", false) and done.has(action.id): return false
if action.has("places") and place not in action.places: return false
if action.get("power", false) and elapsed >= float(story.timeline.power): return false
@@ -601,7 +613,7 @@ func choose_action(id: String) -> void:
busy = selected.duplicate(true)
busy_start = elapsed
busy_end = elapsed + action_duration(selected)
reply_at = maxf(elapsed + voice_length(selected.request) + 0.15, busy_end - voice_length(selected.response))
reply_at = maxf(elapsed + voice_length(selected.request) + 0.2, busy_end - voice_length(selected.response))
replied = false
soundscape.schedule_task(id, elapsed + voice_length(selected.request) + 0.12, reply_at)
say(selected.request)
@@ -626,16 +638,6 @@ func finish_task() -> void:
save_progress()
refresh()
func cancel_task() -> void:
if not running or busy.is_empty(): return
if not speech_finished(): return
busy = {}
soundscape.cancel_task()
voice.stop()
say("cancel")
system_caption("Мама остановилась. Потраченное время не вернуть.")
refresh_commands()
func save_progress() -> void:
if qa_mode or test_mode: return
var result := Profile.write_profile(SAVE_PATH, facts, endings, completed)
@@ -727,13 +729,12 @@ func refresh() -> void:
func refresh_commands() -> void:
if not is_instance_valid(command_list): return
clear_children(command_list)
cancel_button.visible = running and not busy.is_empty()
cancel_button.disabled = not speech_finished()
if not running:
var silence: Label = stage.centered("Линия молчит.",20,MUTED)
silence.custom_minimum_size = Vector2(300,60)
command_list.add_child(silence)
return
if fired.has("hum"): return
if chapter == 1:
var note: Label = stage.centered("Вы просто разговариваете.\nКажется, на всё ещё есть время.",19,Color("91839f"))
note.custom_minimum_size = Vector2(400,85)
@@ -756,12 +757,11 @@ func speech_finished() -> bool:
return elapsed >= speech_until and (not voice_enabled or not voice.playing)
func can_respond() -> bool:
return running and chapter != 1 and events.is_empty() and speech_finished()
return running and chapter != 1 and not fired.has("hum") and busy.is_empty() and events.is_empty() and speech_finished()
func update_choice_state() -> void:
for child in command_list.get_children():
if child is Button: child.disabled = not can_respond()
cancel_button.disabled = not speech_finished()
func refresh_live() -> void:
if running and fired.has("alarm"):
@@ -775,7 +775,7 @@ func refresh_live() -> void:
held.append({"keys": "ключи", "lamp": "фонарь", "spare": "запасной ключ", "connected": "телефон на полке"}[key])
objects_label.text = "У мамы: " + (", ".join(held) if not held.is_empty() else "телефон")
task_label.text = str(busy.label) if not busy.is_empty() else ("Дождись окончания реплики" if not can_respond() else "Что сказать маме?")
if not running: task_label.text = ""
if not running or fired.has("hum"): task_label.text = ""
if chapter == 1: task_label.text = ""
update_choice_state()
busy_bar.visible = not busy.is_empty()
@@ -803,6 +803,7 @@ func voice_length(id: String) -> float:
return stream.get_length() if stream != null else maxf(2.0, str(story.lines[id].text).length() / 13.0)
func say(id: String) -> void:
if running and fired.has("hum") and id != "hum": return
var entry: Dictionary = story.lines[id]
heard.append(id)
stage.speaker = entry.speaker