From 3d0279d6d41895bc43970d0e5952e601050730dd Mon Sep 17 00:00:00 2001 From: betalars Date: Thu, 29 May 2025 23:54:11 +0200 Subject: [PATCH] copy pause menu into demo main, likely fixes #182 --- src/demo-main.tscn | 186 ++++++++++++++++++++++++-- src/logic-scenes/misc/skip_control.gd | 8 +- 2 files changed, 177 insertions(+), 17 deletions(-) diff --git a/src/demo-main.tscn b/src/demo-main.tscn index f8d177f..9ac1de9 100644 --- a/src/demo-main.tscn +++ b/src/demo-main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=3 uid="uid://cd63barv73rfx"] +[gd_scene load_steps=29 format=3 uid="uid://cd63barv73rfx"] [ext_resource type="Texture2D" uid="uid://d3ewjumh0b0g6" path="res://logic-scenes/main menu/logo.png" id="1_61qpo"] [ext_resource type="Texture2D" uid="uid://ds1n0xhxqlp4b" path="res://base-environments/youth_room/shaders/universe_noise.png" id="1_t34p3"] @@ -9,6 +9,8 @@ [ext_resource type="Texture2D" uid="uid://yakqusko3p3h" path="res://addons/input_prompts/icons/keyboard/a.png" id="7_g425y"] [ext_resource type="Texture2D" uid="uid://b0kuadlp4jw6j" path="res://addons/input_prompts/icons/keyboard/d.png" id="8_kj67n"] [ext_resource type="Texture2D" uid="uid://bwhf0tx67yj7a" path="res://addons/input_prompts/icons/keyboard/s.png" id="9_xo70c"] +[ext_resource type="Script" uid="uid://0h0lrkntx0uh" path="res://logic-scenes/main menu/pause_menu.gd" id="10_g425y"] +[ext_resource type="Script" uid="uid://sa15wakvpj2e" path="res://dev-util/bug_button.gd" id="11_kj67n"] [sub_resource type="GDScript" id="GDScript_t34p3"] script/source = "extends Node3D @@ -31,7 +33,9 @@ func load_room(): loaded_room = room.instantiate() %Room.add_child(loaded_room) +var in_game: bool func _on_start_button_pressed(): + in_game = true var new_save = SaveGame.new() if DirAccess.dir_exists_absolute( State.user_saves_path ): var usr_dir = DirAccess.open(State.user_saves_path) @@ -73,6 +77,23 @@ func _on_option_button_item_selected(index: int) -> void: State.text_language = 1 1: State.text_language = 2 + +func _unhandled_input(event: InputEvent) -> void: + if event is InputEvent and in_game: + if event.is_action_pressed(\"ui_menu\"): + toggle_pause_menu() + +func toggle_pause_menu(): + if not get_tree().paused: + get_tree().paused = true + %PauseContainer.show() + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + else: + get_tree().paused = false + %PauseContainer.hide() + + if State.stage_list[0] is Player: + Input.mouse_mode = Input.MOUSE_MODE_CAPTURED " [sub_resource type="Shader" id="Shader_duh8f"] @@ -139,45 +160,110 @@ fill = 1 fill_from = Vector2(0.538462, 0.491453) fill_to = Vector2(1.3, -0.3) -[sub_resource type="InputEventKey" id="InputEventKey_t34p3"] +[sub_resource type="InputEventKey" id="InputEventKey_xo70c"] device = -1 physical_keycode = 87 unicode = 119 -[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_s1yf2"] +[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_k41g6"] device = -1 axis = 1 axis_value = -1.0 -[sub_resource type="InputEventKey" id="InputEventKey_g425y"] +[sub_resource type="InputEventKey" id="InputEventKey_jirkf"] device = -1 physical_keycode = 65 unicode = 97 -[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_kj67n"] +[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_kt5p7"] device = -1 axis_value = -1.0 -[sub_resource type="InputEventKey" id="InputEventKey_xo70c"] +[sub_resource type="InputEventKey" id="InputEventKey_mivr6"] device = -1 physical_keycode = 68 unicode = 100 -[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_k41g6"] +[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_52c3j"] device = -1 axis_value = 1.0 -[sub_resource type="InputEventKey" id="InputEventKey_jirkf"] +[sub_resource type="InputEventKey" id="InputEventKey_b7q2n"] device = -1 physical_keycode = 83 unicode = 115 -[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_kt5p7"] +[sub_resource type="InputEventJoypadMotion" id="InputEventJoypadMotion_qhf78"] device = -1 axis = 1 axis_value = 1.0 +[sub_resource type="Shader" id="Shader_gatj6"] +code = "shader_type canvas_item; +render_mode blend_premul_alpha; + +uniform float nebula_brightness = 4; +uniform vec2 nebula_scale = vec2(1.5); +uniform sampler2D starlight_noise: repeat_enable; +uniform sampler2D starlight_textures; +uniform float rotation_speed = 0.02; +uniform vec2 rotation_pivot = vec2(.8); +uniform vec2 drift_compensation = vec2(0.1, -0.2); +uniform float noise_strength = 0.2; + +// https://gist.github.com/ayamflow/c06bc0c8a64f985dd431bd0ac5b557cd +vec2 rotateUV(vec2 uv, vec2 pivot, float rotation) +{ + return vec2( + cos(rotation) * (uv.x - pivot.x) + sin(rotation) * (uv.y - pivot.y) + pivot.x, + cos(rotation) * (uv.y - pivot.y) - sin(rotation) * (uv.x - pivot.x) + pivot.y + ); +} + +//clamp(, .0, 1.0 + +void fragment() { + COLOR *= vec4(.0, + texture(starlight_textures,fract(UV*2.0)).x * 2.0*pow(max(sin(TIME + 10.0 * texture(starlight_textures,UV).y), .0), 5.0), + texture(starlight_textures, + clamp( + UV / nebula_scale + drift_compensation + 1.0 * + texture(starlight_noise, rotateUV( + UV / nebula_scale + noise_strength * texture(starlight_noise, rotateUV(UV, -rotation_pivot, TIME*rotation_speed)).yz, + rotation_pivot, TIME*rotation_speed) + ).xz, + .0, 1.0)) + .z * nebula_brightness, + clamp(pow(COLOR.x * 2.5 - (texture(starlight_noise, UV*2.0+TIME*.02).x + 0.8), 1.5), .0, 1.0) + ) * COLOR.w; +} +" + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ol51q"] +shader = SubResource("Shader_gatj6") +shader_parameter/nebula_brightness = 2.4 +shader_parameter/nebula_scale = Vector2(1.3, 1.6) +shader_parameter/starlight_noise = ExtResource("1_t34p3") +shader_parameter/starlight_textures = ExtResource("2_s1yf2") +shader_parameter/rotation_speed = 0.02 +shader_parameter/rotation_pivot = Vector2(0.8, 0.8) +shader_parameter/drift_compensation = Vector2(0.1, -0.2) +shader_parameter/noise_strength = 0.2 + +[sub_resource type="Gradient" id="Gradient_2rqk2"] +interpolation_color_space = 2 +colors = PackedColorArray(1, 1, 1, 1, 0, 0, 0, 0) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_w8m28"] +gradient = SubResource("Gradient_2rqk2") +width = 2048 +height = 1536 +fill = 1 +fill_from = Vector2(0.538462, 0.491453) +fill_to = Vector2(1.3, -0.3) + [node name="DemoMain" type="Node3D"] +process_mode = 3 script = SubResource("GDScript_t34p3") [node name="Room" type="Node3D" parent="."] @@ -334,7 +420,7 @@ stretch_mode = 5 script = ExtResource("5_6w5b4") action = "player_forwards" icon = 4 -events = Array[InputEvent]([SubResource("InputEventKey_t34p3"), SubResource("InputEventJoypadMotion_s1yf2")]) +events = Array[InputEvent]([SubResource("InputEventKey_xo70c"), SubResource("InputEventJoypadMotion_k41g6")]) metadata/_custom_type_script = "uid://bbs1u7ojno7xo" [node name="ActionPrompt2" type="TextureRect" parent="Menu/Control"] @@ -349,7 +435,7 @@ stretch_mode = 5 script = ExtResource("5_6w5b4") action = "player_left" icon = 4 -events = Array[InputEvent]([SubResource("InputEventKey_g425y"), SubResource("InputEventJoypadMotion_kj67n")]) +events = Array[InputEvent]([SubResource("InputEventKey_jirkf"), SubResource("InputEventJoypadMotion_kt5p7")]) metadata/_custom_type_script = "uid://bbs1u7ojno7xo" [node name="ActionPrompt4" type="TextureRect" parent="Menu/Control"] @@ -364,7 +450,7 @@ stretch_mode = 5 script = ExtResource("5_6w5b4") action = "player_right" icon = 4 -events = Array[InputEvent]([SubResource("InputEventKey_xo70c"), SubResource("InputEventJoypadMotion_k41g6")]) +events = Array[InputEvent]([SubResource("InputEventKey_mivr6"), SubResource("InputEventJoypadMotion_52c3j")]) metadata/_custom_type_script = "uid://bbs1u7ojno7xo" [node name="ActionPrompt3" type="TextureRect" parent="Menu/Control"] @@ -379,7 +465,7 @@ stretch_mode = 5 script = ExtResource("5_6w5b4") action = "player_backwards" icon = 4 -events = Array[InputEvent]([SubResource("InputEventKey_jirkf"), SubResource("InputEventJoypadMotion_kt5p7")]) +events = Array[InputEvent]([SubResource("InputEventKey_b7q2n"), SubResource("InputEventJoypadMotion_qhf78")]) metadata/_custom_type_script = "uid://bbs1u7ojno7xo" [node name="Label" type="Label" parent="Menu/Control"] @@ -391,6 +477,80 @@ offset_bottom = -40.0 theme_type_variation = &"HeaderMedium" text = "Move trough the room" +[node name="PauseContainer" type="CenterContainer" parent="."] +unique_name_in_owner = true +visible = false +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="PauseContainer"] +material = SubResource("ShaderMaterial_ol51q") +layout_mode = 2 +texture = SubResource("GradientTexture2D_w8m28") + +[node name="PauseMenu" type="PanelContainer" parent="PauseContainer"] +unique_name_in_owner = true +layout_mode = 2 +script = ExtResource("10_g425y") + +[node name="VBoxContainer" type="VBoxContainer" parent="PauseContainer/PauseMenu"] +layout_mode = 2 + +[node name="Label" type="Label" parent="PauseContainer/PauseMenu/VBoxContainer"] +layout_mode = 2 +theme_type_variation = &"HeaderLarge" +text = "Game Paused" + +[node name="ResumeButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "Resume" + +[node name="BugButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +layout_mode = 2 +script = ExtResource("11_kj67n") +metadata/_custom_type_script = "uid://sa15wakvpj2e" + +[node name="ToMenuButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +text = "Return to Menu" + +[node name="ToSettingsButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +text = "Open Settings" + +[node name="ToDesktopButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "Quit to Desktop" + +[node name="HSeparator" type="HSeparator" parent="PauseContainer/PauseMenu/VBoxContainer"] +custom_minimum_size = Vector2(0, 20) +layout_mode = 2 + +[node name="FindHelplineButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +text = "Find Help-Lines" + +[node name="Label2" type="Label" parent="PauseContainer/PauseMenu/VBoxContainer"] +layout_mode = 2 +text = "opens findahelpline.com" +horizontal_alignment = 1 + +[node name="SkipStoryButton" type="Button" parent="PauseContainer/PauseMenu/VBoxContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +text = "Skip this Story" + [connection signal="pressed" from="Menu/VBoxContainer2/PressStart" to="." method="_on_start_button_pressed"] [connection signal="toggled" from="Menu/VBoxContainer/CNBox" to="." method="_on_cn_box_toggled"] [connection signal="toggled" from="Menu/VBoxContainer/MotionBox" to="." method="_on_motion_box_toggled"] diff --git a/src/logic-scenes/misc/skip_control.gd b/src/logic-scenes/misc/skip_control.gd index 929e5b6..a3e730f 100644 --- a/src/logic-scenes/misc/skip_control.gd +++ b/src/logic-scenes/misc/skip_control.gd @@ -107,10 +107,10 @@ func _input(event: InputEvent) -> void: get_viewport().set_input_as_handled() reset() elif event.is_action_pressed("ui_cancel"): - # FIXME this right now would be consumed by the pause menu. - is_auto_proceeding = false - aborted = true - get_viewport().set_input_as_handled() + if not aborted and is_auto_proceeding: + is_auto_proceeding = false + aborted = true + get_viewport().set_input_as_handled() func _on_skip_button_toggled(button_pressed): if button_pressed: