Add centered main menu with bokeh backdrop and Escape navigation
This commit is contained in:
@@ -43,6 +43,8 @@ var voice_enabled := true
|
||||
var master_volume := 0.65
|
||||
var ui: Control
|
||||
var overlay: Control
|
||||
var menu_screen := ""
|
||||
var menu_content: VBoxContainer
|
||||
var command_list: Container
|
||||
var transcript: VBoxContainer
|
||||
var transcript_scroll: ScrollContainer
|
||||
@@ -166,6 +168,9 @@ func clear_children(parent: Node) -> void:
|
||||
child.queue_free()
|
||||
|
||||
func close_overlay() -> void:
|
||||
menu_screen = ""
|
||||
menu_content = null
|
||||
stage.set_menu_mode(false)
|
||||
viewing_messages = false
|
||||
stage.close_inbox()
|
||||
stage.center_region.modulate.a = 1.0
|
||||
@@ -302,24 +307,69 @@ func show_memory() -> void:
|
||||
box.add_child(text)
|
||||
box.add_child(button("Вернуться к звонку","close_memory",close_overlay))
|
||||
|
||||
func show_menu() -> void:
|
||||
var box := modal()
|
||||
box.add_child(label("ДО ОТБОЯ", 17, ACCENT))
|
||||
box.add_child(label("Не клади трубку", 48))
|
||||
box.add_child(label("Девяносто секунд рядом с мамой.\nДесять звонков. Только голос, память и то, что удалось услышать.", 22))
|
||||
box.add_child(label("Ты — Катя. Мама — Нина. Ты далеко от её квартиры.\nВ первом звонке вы просто разговариваете. Потом всё повторится.", 19, MUTED))
|
||||
if running:
|
||||
box.add_child(label("Звонок продолжается, пока открыто меню.", 18, RED))
|
||||
box.add_child(button("Вернуться к звонку", "resume", close_overlay))
|
||||
func menu_page(page: String) -> VBoxContainer:
|
||||
close_overlay()
|
||||
menu_screen = page
|
||||
stage.set_menu_mode(true)
|
||||
var holder := MarginContainer.new()
|
||||
holder.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
for edge in ["left","right","top","bottom"]: holder.add_theme_constant_override("margin_"+edge,32)
|
||||
ui.add_child(holder)
|
||||
overlay = holder
|
||||
var center := CenterContainer.new()
|
||||
holder.add_child(center)
|
||||
var box := column(center)
|
||||
box.custom_minimum_size.x = 620
|
||||
box.add_theme_constant_override("separation",16)
|
||||
menu_content = box
|
||||
return box
|
||||
|
||||
func menu_action(box: VBoxContainer, text: String, id: String, callback: Callable, primary: bool = false) -> void:
|
||||
var control := button(text,id,callback)
|
||||
control.custom_minimum_size.y = 54
|
||||
control.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
control.add_theme_stylebox_override("normal",style(Color("2d2233") if primary else Color(0.065,0.055,0.08,0.85),Color("53405b") if primary else Color("2d2637"),14))
|
||||
box.add_child(control)
|
||||
|
||||
func return_to_call() -> void:
|
||||
close_overlay()
|
||||
if impacted: show_ending()
|
||||
|
||||
func _unhandled_key_input(event: InputEvent) -> void:
|
||||
if not event is InputEventKey or not event.pressed or event.echo or event.keycode != KEY_ESCAPE: return
|
||||
get_viewport().set_input_as_handled()
|
||||
if dialing: return
|
||||
if not menu_screen.is_empty():
|
||||
if menu_screen != "main": show_menu()
|
||||
elif running or impacted: return_to_call()
|
||||
elif viewing_messages:
|
||||
return_to_call()
|
||||
elif is_instance_valid(overlay) and running:
|
||||
close_overlay()
|
||||
else:
|
||||
box.add_child(button("Позвонить маме" if completed == 0 else "Продолжить · звонок %d" % mini(completed + 1, 10), "start", func(): dial_call(mini(completed + 1, 10), false)))
|
||||
box.add_child(button("Проверка сцен · выбрать любой из 10 звонков", "testing", show_test_menu))
|
||||
box.add_child(button("Звук и титры", "settings", show_settings))
|
||||
box.add_child(label("0.2.6 · Катя: Jessica · Мама: Carol · ElevenLabs\nПрогресс сохраняется после находок и законченных звонков.", 16, MUTED))
|
||||
show_menu()
|
||||
|
||||
func show_menu() -> void:
|
||||
var box := menu_page("main")
|
||||
box.add_child(stage.centered("ДО ОТБОЯ",17,ACCENT))
|
||||
box.add_child(stage.centered("Не клади трубку",52,INK))
|
||||
box.add_child(stage.centered("Девяносто секунд рядом с мамой.\nГолос, память и то, что удалось услышать.",19,MUTED))
|
||||
var space := Control.new()
|
||||
space.custom_minimum_size.y = 12
|
||||
box.add_child(space)
|
||||
if running or impacted:
|
||||
menu_action(box,"Вернуться к звонку" if running else "Итоги звонка","resume",return_to_call,true)
|
||||
else:
|
||||
menu_action(box,"Позвонить маме" if completed == 0 else "Продолжить · звонок %d" % mini(completed + 1, 10),"start",func(): dial_call(mini(completed+1,10),false),true)
|
||||
menu_action(box,"Проверка сцен","testing",show_test_menu)
|
||||
menu_action(box,"Звук и титры","settings",show_settings)
|
||||
menu_action(box,"Выйти из игры","quit",func(): get_tree().quit())
|
||||
box.add_child(stage.centered("Esc — вернуться к звонку. Время продолжает идти." if running else "Esc — главное меню во время звонка",14,MUTED))
|
||||
box.add_child(stage.centered("0.2.7 · Катя: Jessica · Мама: Carol",12,Color("71667d")))
|
||||
|
||||
func show_settings() -> void:
|
||||
var box := modal()
|
||||
box.add_child(label("Звук и титры", 34))
|
||||
var box := menu_page("settings")
|
||||
box.add_child(stage.centered("Звук и титры",34,INK))
|
||||
var enabled := CheckButton.new()
|
||||
enabled.text = "Озвучка реплик"
|
||||
enabled.button_pressed = voice_enabled
|
||||
@@ -347,12 +397,12 @@ func show_settings() -> void:
|
||||
background.value_changed.connect(soundscape.set_volume)
|
||||
box.add_child(background)
|
||||
box.add_child(label("Во время речи фон автоматически становится тише.", 16, MUTED))
|
||||
box.add_child(label("Все фразы доступны в субтитрах.\nКатя: Jessica — Playful, Bright, Warm / ElevenLabs, 52 реплики.\nМама: Carol — Relatable, Real, Likeable Grandma / ElevenLabs, 58 реплик.\nВзрыв: Synthesized explosion — qubodup / Iwan Gabovitch, CC0.\nФон и бытовые звуки: ElevenLabs Sound Effects и синтез проекта.\nПолные источники — AUDIO_CREDITS.md рядом с игрой.", 20, MUTED))
|
||||
box.add_child(button("Назад", "back_menu", show_menu))
|
||||
box.add_child(label("Все фразы доступны в субтитрах.\nКатя: Jessica — Playful, Bright, Warm / ElevenLabs, 52 реплики.\nМама: Carol — Relatable, Real, Likeable Grandma / ElevenLabs, 58 реплик.\nВзрыв: Synthesized explosion — qubodup / Iwan Gabovitch, CC0.\nФон и бытовые звуки: ElevenLabs Sound Effects и синтез проекта.\nПолные источники — AUDIO_CREDITS.md рядом с игрой.", 16, MUTED))
|
||||
menu_action(box,"Назад","back_menu",show_menu)
|
||||
|
||||
func show_test_menu() -> void:
|
||||
var box := modal()
|
||||
box.add_child(label("Проверка сцен", 34))
|
||||
var box := menu_page("testing")
|
||||
box.add_child(stage.centered("Проверка сцен",34,INK))
|
||||
box.add_child(label("Отдельная сессия для тестирования. Основное сохранение не меняется.", 20, MUTED))
|
||||
var choices := OptionButton.new()
|
||||
choices.custom_minimum_size.y = 48
|
||||
@@ -367,9 +417,8 @@ func show_test_menu() -> void:
|
||||
knowledge.add_item("Все знания для проверки маршрутов")
|
||||
knowledge.set_meta("test_knowledge", true)
|
||||
box.add_child(knowledge)
|
||||
box.add_child(button("Начать проверку", "test_start", func():
|
||||
dial_call(choices.selected + 1, true, knowledge.selected)))
|
||||
box.add_child(button("Назад", "back_menu", show_menu))
|
||||
menu_action(box,"Начать проверку","test_start",func(): dial_call(choices.selected+1,true,knowledge.selected),true)
|
||||
menu_action(box,"Назад","back_menu",show_menu)
|
||||
|
||||
func dial_call(number: int, testing: bool, knowledge: int = 1, animate_in_qa: bool = false) -> void:
|
||||
if dialing: return
|
||||
@@ -617,6 +666,7 @@ func strike() -> void:
|
||||
status_label.text = "Соединение прервано"
|
||||
refresh_commands()
|
||||
refresh_live()
|
||||
if menu_screen == "main": show_menu()
|
||||
if viewing_messages: show_messages()
|
||||
if qa_mode: return
|
||||
var epoch := start_tick
|
||||
@@ -629,7 +679,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 and not viewing_messages: show_ending()
|
||||
if epoch == start_tick and impacted and not viewing_messages and menu_screen.is_empty(): show_ending()
|
||||
|
||||
func show_ending() -> void:
|
||||
var entry: Dictionary = story.endings[outcome]
|
||||
|
||||
@@ -67,6 +67,17 @@ func render() -> void:
|
||||
if DisplayServer.get_name() != "headless":
|
||||
await RenderingServer.frame_post_draw
|
||||
|
||||
func escape() -> void:
|
||||
var key := InputEventKey.new()
|
||||
key.keycode = KEY_ESCAPE
|
||||
key.physical_keycode = KEY_ESCAPE
|
||||
key.pressed = true
|
||||
game.get_viewport().push_input(key,true)
|
||||
var release := key.duplicate()
|
||||
release.pressed = false
|
||||
game.get_viewport().push_input(release,true)
|
||||
await render()
|
||||
|
||||
func capture(name: String) -> void:
|
||||
if DisplayServer.get_name() != "headless":
|
||||
await game.get_tree().create_timer(0.42).timeout
|
||||
@@ -164,9 +175,19 @@ func run(target: Node) -> void:
|
||||
if float(beat.at) < 45: next_at = minf(next_at, 45)
|
||||
check(float(beat.at) + game.voice_length(beat.line) <= next_at, "Intro line fits before next cue: " + str(beat.line))
|
||||
await capture("phone-menu")
|
||||
check(game.menu_screen == "main" and not game.stage.smartphone.is_visible_in_tree() and not game.stage.mother_phone.is_visible_in_tree(), "Main menu hides the call interface")
|
||||
check(game.menu_content.get_global_rect().get_center().distance_to(game.ui.get_global_rect().get_center()) < 2, "Main menu is centered in the viewport")
|
||||
check(game.stage.menu_mode and game.stage.glow.get_shader_parameter("menu_bokeh") == 1.0, "Main menu uses the bokeh background")
|
||||
check(game.action_button("start") != null and game.action_button("quit") != null, "Main menu offers start and exit")
|
||||
click("settings")
|
||||
check(game.menu_screen == "settings" and not game.stage.call_layout.visible, "Settings stay on the menu background")
|
||||
await capture("phone-credits")
|
||||
click("back_menu")
|
||||
click("testing")
|
||||
check(game.menu_screen == "testing", "Scene selection opens from main menu")
|
||||
await capture("phone-scene-menu")
|
||||
await escape()
|
||||
check(game.menu_screen == "main", "Escape returns from scene selection to main menu")
|
||||
game.dial_call(1,true,0,true)
|
||||
check(game.dialing and not game.running, "Dial animation precedes the 90-second clock")
|
||||
check_clocks("", "hidden before connection")
|
||||
@@ -177,6 +198,7 @@ func run(target: Node) -> void:
|
||||
check(game.running and not game.dialing and game.elapsed < 1.0, "Connection starts a fresh full attempt")
|
||||
check_clocks("00:00", "first connection")
|
||||
check("greeting" in game.heard, "Mother answers after connection")
|
||||
check(game.menu_screen.is_empty() and game.stage.call_layout.visible and not game.stage.menu_mode, "Call restores the gameplay background")
|
||||
game.stage.update(1.0)
|
||||
check(game.stage.purple_level > game.stage.pink_level, "Mother lights the violet background")
|
||||
await capture("phone-mother-voice")
|
||||
@@ -239,7 +261,7 @@ func run(target: Node) -> void:
|
||||
start(2)
|
||||
wait_for_speech()
|
||||
await render()
|
||||
check(game.stage.memory_button.size.x >= 100 and game.stage.menu_button.size.x >= 80, "Header controls stay readable")
|
||||
check(game.stage.memory_button.size.x >= 100 and game.action_button("menu") == null, "Call screen keeps memory without a menu button")
|
||||
if DisplayServer.get_name() != "headless":
|
||||
var original_size := DisplayServer.window_get_size()
|
||||
DisplayServer.window_set_size(Vector2i(1366,768))
|
||||
@@ -248,6 +270,19 @@ func run(target: Node) -> void:
|
||||
check(game.ui.get_global_rect().encloses(game.stage.smartphone.get_global_rect()), "Katya phone fits wide viewport")
|
||||
DisplayServer.window_set_size(original_size)
|
||||
await render()
|
||||
var chapter_before_menu: int = game.chapter
|
||||
var elapsed_before_menu: float = game.elapsed
|
||||
await escape()
|
||||
check(game.menu_screen == "main" and game.action_button("resume") != null, "Escape opens menu during a call")
|
||||
check(not game.stage.call_layout.visible and game.action_button("keys_search") == null, "Menu hides gameplay choices")
|
||||
await capture("phone-menu-during-call")
|
||||
at(elapsed_before_menu + 1.0)
|
||||
check(game.elapsed >= elapsed_before_menu + 1.0 and game.running, "Call clock continues in menu")
|
||||
click("resume")
|
||||
check(game.menu_screen.is_empty() and game.stage.call_layout.visible and game.chapter == chapter_before_menu, "Resume restores the same call")
|
||||
await escape()
|
||||
await escape()
|
||||
check(game.menu_screen.is_empty() and game.running, "Escape also returns directly to the call")
|
||||
var cloud_rect: Rect2 = game.stage.choice_scroll.get_global_rect()
|
||||
check(cloud_rect.position.y > game.transcript_scroll.get_global_rect().position.y, "Answers below central dialogue")
|
||||
for child in game.command_list.get_children():
|
||||
@@ -541,6 +576,16 @@ func run(target: Node) -> void:
|
||||
click("close_messages")
|
||||
check(game.action_button("next") != null, "Inbox returns to production ending")
|
||||
game.qa_mode = true
|
||||
start(2)
|
||||
await escape()
|
||||
game.qa_mode = false
|
||||
at(90.1)
|
||||
await game.get_tree().create_timer(9.0).timeout
|
||||
check(game.impacted and game.menu_screen == "main", "Impact and ending transition preserve the open menu")
|
||||
check(game.action_button("resume").text == "Итоги звонка", "Menu updates its return action after disconnect")
|
||||
click("resume")
|
||||
check(game.menu_screen.is_empty() and game.action_button("next") != null, "Menu returns to the completed call outcome")
|
||||
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)
|
||||
|
||||
@@ -10,7 +10,8 @@ var mother_status: Label
|
||||
var mother_clock: Label
|
||||
var call_direction: Label
|
||||
var memory_button: Button
|
||||
var menu_button: Button
|
||||
var call_layout: Control
|
||||
var menu_mode := false
|
||||
var message_panel: PanelContainer
|
||||
var glow: ShaderMaterial
|
||||
var pink_level := 0.0
|
||||
@@ -45,6 +46,7 @@ func build(target: Node) -> void:
|
||||
background.material = glow
|
||||
add_child(background)
|
||||
var margins := MarginContainer.new()
|
||||
call_layout = margins
|
||||
margins.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
|
||||
for edge in ["left", "right", "top", "bottom"]: margins.add_theme_constant_override("margin_"+edge,32)
|
||||
add_child(margins)
|
||||
@@ -61,11 +63,6 @@ func build(target: Node) -> void:
|
||||
memory_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
memory_button.add_theme_font_size_override("font_size",15)
|
||||
header.add_child(memory_button)
|
||||
menu_button = game.button("Меню", "menu", game.show_menu)
|
||||
menu_button.custom_minimum_size.x = 90
|
||||
menu_button.size_flags_vertical = Control.SIZE_SHRINK_CENTER
|
||||
menu_button.add_theme_font_size_override("font_size",15)
|
||||
header.add_child(menu_button)
|
||||
var body := HBoxContainer.new()
|
||||
body.add_theme_constant_override("separation",28)
|
||||
body.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
@@ -209,6 +206,12 @@ func inbox() -> VBoxContainer:
|
||||
box.add_theme_constant_override("separation",10)
|
||||
return box
|
||||
|
||||
func set_menu_mode(enabled: bool) -> void:
|
||||
menu_mode = enabled
|
||||
call_layout.visible = not enabled
|
||||
game.screen_fade.visible = not enabled
|
||||
glow.set_shader_parameter("menu_bokeh",1.0 if enabled else 0.0)
|
||||
|
||||
func update(delta: float) -> void:
|
||||
var speaking: bool = game.voice_enabled and game.voice.playing
|
||||
var mix := 1.0-exp(-delta/0.8)
|
||||
@@ -218,11 +221,10 @@ func update(delta: float) -> void:
|
||||
if speaking and game.voice_meter != null:
|
||||
magnitude = clampf(game.voice_meter.get_magnitude_for_frequency_range(120,3200).length()*14,0.0,1.0)
|
||||
voice_energy = lerpf(voice_energy,magnitude,1.0-exp(-delta/0.28))
|
||||
glow.set_shader_parameter("katya",pink_level)
|
||||
glow.set_shader_parameter("mother",purple_level)
|
||||
glow.set_shader_parameter("katya",0.65 if menu_mode else pink_level)
|
||||
glow.set_shader_parameter("mother",0.65 if menu_mode else purple_level)
|
||||
glow.set_shader_parameter("energy",voice_energy)
|
||||
smartphone.animate(delta,game.dialing)
|
||||
menu_button.disabled = game.dialing
|
||||
memory_button.disabled = game.dialing
|
||||
memory_button.text = "Память" + (" · %d" % game.facts.size() if not game.facts.is_empty() else "")
|
||||
refresh_call_display()
|
||||
|
||||
@@ -2,6 +2,10 @@ shader_type canvas_item;
|
||||
uniform float katya = 0.0;
|
||||
uniform float mother = 0.0;
|
||||
uniform float energy = 0.0;
|
||||
uniform float menu_bokeh = 0.0;
|
||||
float seed(float n) {
|
||||
return fract(sin(n * 127.1) * 43758.5453);
|
||||
}
|
||||
void fragment() {
|
||||
vec2 uv = UV;
|
||||
vec3 base = vec3(0.004, 0.004, 0.006);
|
||||
@@ -14,7 +18,20 @@ void fragment() {
|
||||
vec3 pink = vec3(0.60,0.16,0.34) * katya;
|
||||
vec3 violet = vec3(0.35,0.17,0.65) * mother;
|
||||
vec3 glow = pink * left + violet * right;
|
||||
base += glow * (0.23 + wave*0.13);
|
||||
base += glow * (0.23 + wave*0.13*(1.0-menu_bokeh));
|
||||
base += vec3(0.004,0.003,0.006)*exp(-length((uv-0.5)*1.5));
|
||||
if (menu_bokeh > 0.0) {
|
||||
float aspect = SCREEN_PIXEL_SIZE.y / SCREEN_PIXEL_SIZE.x;
|
||||
for (int i = 0; i < 18; i++) {
|
||||
float n = float(i) + 1.0;
|
||||
vec2 center = vec2(seed(n),seed(n+21.0));
|
||||
center += vec2(sin(TIME*0.055+n),cos(TIME*0.045+n*1.7))*0.025;
|
||||
float radius = mix(0.025,0.08,seed(n+43.0));
|
||||
float distance = length((uv-center)*vec2(aspect,1.0));
|
||||
float disc = 1.0-smoothstep(radius*0.3,radius*1.65,distance);
|
||||
vec3 tint = mix(vec3(0.58,0.20,0.36),vec3(0.35,0.23,0.62),seed(n+62.0));
|
||||
base += tint*disc*0.20*menu_bokeh;
|
||||
}
|
||||
}
|
||||
COLOR = vec4(base,1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user