diff --git a/addons/dialogue_manager/dialogue_label.gd b/addons/dialogue_manager/dialogue_label.gd index da07b45b..f432f68f 100644 --- a/addons/dialogue_manager/dialogue_label.gd +++ b/addons/dialogue_manager/dialogue_label.gd @@ -55,7 +55,7 @@ var dialogue_line: ## Whether the label is currently typing itself out. var is_typing: bool = false: set(value): - var is_finished: bool = is_typing != value and value == false + var is_finished: bool = is_typing and value == false is_typing = value if is_finished: finished_typing.emit() diff --git a/asset/dialogue/item_description.csv b/asset/dialogue/item_description.csv index a84f192b..5ea292b7 100644 --- a/asset/dialogue/item_description.csv +++ b/asset/dialogue/item_description.csv @@ -33,6 +33,8 @@ setting_音效音量,音效音量,,,,,SFX Volume setting_对话音量,对话音量,,,,,Dialogue Volume setting_语言,语言(Lang),,,,,Language setting_字幕,字幕,,,,, +setting_气泡文字自动结束,气泡文字自动结束,,,,, +setting_气泡等待时长,气泡停留,,,,, setting_全屏,全屏游戏,,,,, setting_置顶,窗口置顶,,,,, setting_自动保存,自动保存,,,,,Auto Save diff --git a/asset/dialogue/item_description.dialogue b/asset/dialogue/item_description.dialogue index b720dc57..c0f76854 100644 --- a/asset/dialogue/item_description.dialogue +++ b/asset/dialogue/item_description.dialogue @@ -15,6 +15,8 @@ 对话音量[ID:setting_对话音量] 语言(Lang)[ID:setting_语言] 字幕[ID:setting_字幕] +气泡文字自动结束[ID:setting_气泡文字自动结束] +气泡停留[ID:setting_气泡等待时长] 全屏游戏[ID:setting_全屏] 窗口置顶[ID:setting_置顶] 自动保存[ID:setting_自动保存] diff --git a/config/settings_theme.tres b/config/settings_theme.tres new file mode 100644 index 00000000..1ef1c377 --- /dev/null +++ b/config/settings_theme.tres @@ -0,0 +1,8 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://be5scnhjobkux"] + +[ext_resource type="FontVariation" uid="uid://1ryw42kej6lv" path="res://config/font_ui.tres" id="1_v8hqu"] + +[resource] +default_font = ExtResource("1_v8hqu") +default_font_size = 10 +BoxContainer/constants/separation = 2 diff --git a/manager/config_manager/global_config.gd b/manager/config_manager/global_config.gd index 55ecb038..c123a2de 100644 --- a/manager/config_manager/global_config.gd +++ b/manager/config_manager/global_config.gd @@ -81,3 +81,6 @@ signal auto_save_seconds_changed @export var language := 0 # zh: 0 _SH, 1 _CN; en: [null]; @export var caption := 0 +# 最大范围为 10 秒,精度 0.1 +@export var os_wait_time := 2.0 +@export var os_auto_end := true \ No newline at end of file diff --git a/scene/character/main_player.gd b/scene/character/main_player.gd index 4b1619da..7cdf7634 100644 --- a/scene/character/main_player.gd +++ b/scene/character/main_player.gd @@ -55,16 +55,14 @@ var current_animation_config: Dictionary @onready var footstep_timer = %FootstepTimer as Timer @onready var sprite = %AnimatedSprite2D as AnimatedSprite2D @onready var os_pivot = %OSPivot as Control -@onready var os_contaner = %PanelContainer as PanelContainer -@onready var os_label = %OSLabel as DialogueLabel # # animation -> {frame -> {shadow polygon}} # var animation_shadow_polygons = {} func _ready() -> void: + os_pivot.os_finished.connect(os_finished.emit) sprite.visible = not hide_sprite light.enabled = enable_light - os_contaner.modulate.a = 0.0 _check_character_runtime_status() if not Engine.is_editor_hint(): footstep_timer.timeout.connect(_on_footstep_timer_timeout) @@ -171,9 +169,6 @@ func _play_animation() -> void: if Engine.is_editor_hint(): footstep_timer.stop() sprite.stop() - # 显示 os 效果 - os_contaner.modulate.a = 1.0 - os_label.text = "os 测试文本" func _sprite_play_with_auto_flip_h(left_animation: String, right_animation: String) -> String: @@ -289,6 +284,7 @@ func _on_first_frozen() -> void: current_status = PlayerAnimationConfig.MOVEMENT_IDLE _play_animation() + # duration: the time to lock the player action. 0 means lock forever, thus the player will be locked until release_player is called. func freeze_player(duration: float, action_code: int, auto_quit: bool) -> void: if reenter_lock: @@ -316,53 +312,6 @@ func set_facing_direction(direction: Vector2) -> void: _play_animation() -# func _draw() -> void: -# # 绘制阴影,暂不启用 -# var animation = sprite.animation -# if not animation: -# return -# if not animation_shadow_polygons.has(animation): -# _build_shadow_polygons(animation) -# var animation_polygons = animation_shadow_polygons[animation] -# if animation_polygons.has(sprite.frame): -# draw_polygon(animation_polygons[sprite.frame], [shadow_color]) -# else: -# printerr("No shadow polygon found for frame %d" % sprite.frame) - -# func _build_shadow_polygons(animation): -# var frames = sprite.sprite_frames -# var coords_dict = {} -# for i in frames.get_frame_count(animation): -# var texture = frames.get_frame_texture(animation, i) as Texture2D -# if not texture: -# continue -# var image = texture.get_image() -# var x_min = 10000 -# var x_max = -1 -# for y in range(texture.get_height()): -# for x in range(texture.get_width()): -# var color = image.get_pixel(x, y) -# if color.a > 0.0: -# x_min = min(x_min, x) -# x_max = max(x_max, x) -# if x_min >= x_max: -# continue -# var oval_ab: Vector2 -# oval_ab.x = (x_max - x_min) * 0.5 -# oval_ab.y = max(3.0, oval_ab.x * 0.12) -# var x_offset = (x_max - x_min) * 0.5 + x_min - texture.get_width() * 0.5 -# var coords: PackedVector2Array -# # build shadow oval shape with segments. -# var segments = 16 -# for j in range(segments): -# var angle = PI * 2 / segments * j -# var x = cos(angle) * oval_ab.x + x_offset -# var y = sin(angle) * oval_ab.y + shadow_y -# coords.append(Vector2(x, y)) -# coords_dict[i] = coords -# animation_shadow_polygons[animation] = coords_dict - - func _reset_os_and_light_position(): if sprite and sprite.animation: # reset the os label position @@ -376,75 +325,8 @@ func _reset_os_and_light_position(): # shadow_y = size.y * 0.5 -var os_tween: Tween -# 保证每次 pop_os 后都会有一次 os_finished 信号 -var os_finish_emit_lock := Mutex.new() -var os_finished_not_emitted := false -var os_pausing_timer: SceneTreeTimer - - func pop_os(lines := [], auto_lock := true, auto_unlock := true) -> void: - if os_tween: - os_tween.kill() - os_finish_emit_lock.lock() - if os_finished_not_emitted: - os_finished.emit() - os_finished_not_emitted = true - os_finish_emit_lock.unlock() - if auto_lock: - SceneManager.lock_player() - if auto_unlock: - # os_finished 必然发送,防止 tween 被 kill,保证一定 unlock - if os_finished.is_connected(release_player): - SceneManager.unlock_player() - os_finished.connect(SceneManager.unlock_player, CONNECT_ONE_SHOT) - os_tween = create_tween() - os_label.text = "" - os_tween.tween_property(os_contaner, "modulate:a", 1.0, 0.2) - for line in lines: - var duration = max(min(4.0, line.text.length() * 0.2), 2.0) + 0.2 - # var duration = max(min(4.0, line.text.length() * 0.2), 2.0) - 0.4 - os_tween.tween_callback(_os_load_line.bind(line, duration)) - os_tween.tween_interval(0.1) - os_tween.tween_property(os_contaner, "modulate:a", 0.0, 0.2) - os_tween.tween_callback(func(): - os_finish_emit_lock.lock() - if os_finished_not_emitted: - os_finished_not_emitted = false - os_finished.emit() - os_finish_emit_lock.unlock() - ) - # os 结束 - await os_finished - - -func _os_load_line(line, duration): - os_label.dialogue_line = line - os_label.type_out() - os_tween.pause() - if os_pausing_timer and os_pausing_timer.timeout.is_connected(os_tween.play): - os_pausing_timer.timeout.disconnect(os_tween.play) - Util.timer(duration, _on_os_line_timeout) - - -func _on_os_line_timeout(naturally := true): - if not naturally: - if os_label.is_typing: - os_label.skip_typing() - return - if os_pausing_timer.timeout.is_connected(_on_os_line_timeout): - os_pausing_timer.timeout.disconnect(_on_os_line_timeout) - if os_tween.is_valid(): - # os_label.text = "" - os_tween.play() - os_pausing_timer = null - - -func _unhandled_input(event: InputEvent) -> void: - if event.is_action_pressed("interact"): - if os_pausing_timer and os_pausing_timer.time_left > 0: - _on_os_line_timeout(false) - get_viewport().set_input_as_handled() + await os_pivot.pop_os(lines, auto_lock, auto_unlock) # animation -> offset_y diff --git a/scene/character/main_player.tscn b/scene/character/main_player.tscn index aec9d652..7349b42b 100644 --- a/scene/character/main_player.tscn +++ b/scene/character/main_player.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=10 format=3 uid="uid://cjhw5ecygrqty"] +[gd_scene load_steps=9 format=3 uid="uid://cjhw5ecygrqty"] [ext_resource type="Script" uid="uid://cwfiim4do4vtk" path="res://scene/character/main_player.gd" id="1_3a78y"] [ext_resource type="SpriteFrames" uid="uid://b7fhheih1hbvf" path="res://config/animation/entity_sprite_frames.tres" id="2_3w63u"] -[ext_resource type="FontFile" uid="uid://bjmhscwn1ixj1" path="res://asset/font/字体/ChillJinshuSongMedium.otf" id="3_gk3xo"] -[ext_resource type="Script" uid="uid://g32um0mltv5d" path="res://addons/dialogue_manager/dialogue_label.gd" id="5_tclgd"] +[ext_resource type="PackedScene" uid="uid://dg122jjg5forc" path="res://scene/entity/ux/player_os.tscn" id="2_jgqhw"] [sub_resource type="Gradient" id="Gradient_gk3xo"] interpolation_mode = 2 @@ -71,59 +70,8 @@ wait_time = 0.7 position = Vector2(0, -50) shape = SubResource("RectangleShape2D_jwk3s") -[node name="OSPivot" type="Control" parent="."] +[node name="OSPivot" parent="." instance=ExtResource("2_jgqhw")] unique_name_in_owner = true -layout_mode = 3 -anchors_preset = 0 -offset_top = -120.0 -offset_bottom = -120.0 -scale = Vector2(0.33, 0.33) -mouse_filter = 2 - -[node name="MarginContainer" type="MarginContainer" parent="OSPivot"] -custom_minimum_size = Vector2(235, 30) -layout_mode = 1 -anchors_preset = 7 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -116.0 -offset_top = -158.0 -offset_right = 104.0 -grow_horizontal = 2 -grow_vertical = 0 -size_flags_horizontal = 4 -size_flags_vertical = 8 -mouse_filter = 2 - -[node name="PanelContainer" type="PanelContainer" parent="OSPivot/MarginContainer"] -unique_name_in_owner = true -light_mask = 16 -layout_mode = 2 -size_flags_vertical = 8 -mouse_filter = 2 -theme_type_variation = &"os_panel_container" - -[node name="OSLabel" type="RichTextLabel" parent="OSPivot/MarginContainer/PanelContainer"] -unique_name_in_owner = true -light_mask = 16 -clip_contents = false -layout_mode = 2 -size_flags_vertical = 8 -mouse_filter = 2 -theme_override_constants/line_separation = 2 -theme_override_fonts/normal_font = ExtResource("3_gk3xo") -theme_override_font_sizes/normal_font_size = 23 -bbcode_enabled = true -text = "os 测试文本" -fit_content = true -scroll_following = true -script = ExtResource("5_tclgd") -skip_action = &"" -seconds_per_step = 0.05 -skip_pause_at_abbreviations = PackedStringArray("Mr", "Mrs", "Ms", "Dr", "etc", "eg", "ex") -seconds_per_pause_step = 0.15 [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] unique_name_in_owner = true diff --git a/scene/entity/ux/player_os.gd b/scene/entity/ux/player_os.gd new file mode 100644 index 00000000..c4638dfe --- /dev/null +++ b/scene/entity/ux/player_os.gd @@ -0,0 +1,81 @@ +extends Control + +signal os_finished + +@onready var os_pausing_timer = %OSTimer as Timer +@onready var os_label = %OSLabel as DialogueLabel +@onready var os_contaner = %PanelContainer as PanelContainer + +var os_tween: Tween +# 保证每次 pop_os 后都会有一次 os_finished 信号 +var os_finish_emit_lock := Mutex.new() +var os_finished_not_emitted := false + +func _ready() -> void: + if Engine.is_editor_hint(): + # 显示 os 效果 + os_contaner.modulate.a = 1.0 + os_label.text = "os 测试文本" + return + os_contaner.modulate.a = 0.0 + os_label.text = "" + os_pausing_timer.timeout.connect(_on_os_line_timeout) + + +func pop_os(lines := [], auto_lock := true, auto_unlock := true) -> void: + if os_tween: + os_tween.kill() + os_finish_emit_lock.lock() + if os_finished_not_emitted: + os_finished.emit() + os_finished_not_emitted = true + os_finish_emit_lock.unlock() + if auto_lock: + SceneManager.lock_player() + if auto_unlock: + # os_finished 必然发送,防止 tween 被 kill,保证一定 unlock + if os_finished.is_connected(SceneManager.unlock_player): + SceneManager.unlock_player() + os_finished.connect(SceneManager.unlock_player, CONNECT_ONE_SHOT) + os_tween = create_tween() + os_label.text = "" + os_tween.tween_property(os_contaner, "modulate:a", 1.0, 0.2) + for line in lines: + # os_pausing_timer 启动最小时长 0.01 秒 + var duration = max(GlobalConfigManager.config.os_wait_time, 0.01) + os_tween.tween_callback(_os_load_line.bind(line, duration)) + os_tween.tween_property(os_contaner, "modulate:a", 0.0, 0.2) + os_tween.tween_callback(func(): + os_finish_emit_lock.lock() + if os_finished_not_emitted: + os_finished_not_emitted = false + os_finished.emit() + os_finish_emit_lock.unlock() + ) + # os 结束 + await os_finished + + +func _os_load_line(line: DialogueLine, duration: float): + os_label.dialogue_line = line + os_label.type_out() + if os_label.finished_typing.is_connected(os_pausing_timer.start): + os_label.finished_typing.disconnect(os_pausing_timer.start) + os_label.finished_typing.connect(os_pausing_timer.start.bind(duration), CONNECT_ONE_SHOT) + os_tween.pause() + + +func _on_os_line_timeout(naturally := true): + if not naturally: + if os_label.is_typing: + os_label.skip_typing() + return + if os_tween.is_valid(): + os_tween.play() + + +func _unhandled_input(event: InputEvent) -> void: + if event.is_action_pressed("interact"): + if os_pausing_timer and os_pausing_timer.time_left > 0: + get_viewport().set_input_as_handled() + _on_os_line_timeout(false) diff --git a/scene/entity/ux/player_os.gd.uid b/scene/entity/ux/player_os.gd.uid new file mode 100644 index 00000000..039b9188 --- /dev/null +++ b/scene/entity/ux/player_os.gd.uid @@ -0,0 +1 @@ +uid://b2fp8nwqy6ivc diff --git a/scene/entity/ux/player_os.tscn b/scene/entity/ux/player_os.tscn new file mode 100644 index 00000000..754a1c09 --- /dev/null +++ b/scene/entity/ux/player_os.tscn @@ -0,0 +1,61 @@ +[gd_scene load_steps=4 format=3 uid="uid://dg122jjg5forc"] + +[ext_resource type="Script" uid="uid://b2fp8nwqy6ivc" path="res://scene/entity/ux/player_os.gd" id="1_1bn2y"] +[ext_resource type="FontFile" uid="uid://bjmhscwn1ixj1" path="res://asset/font/字体/ChillJinshuSongMedium.otf" id="1_daqko"] +[ext_resource type="Script" uid="uid://g32um0mltv5d" path="res://addons/dialogue_manager/dialogue_label.gd" id="2_1bn2y"] + +[node name="OSPivot" type="Control"] +layout_mode = 3 +anchors_preset = 0 +scale = Vector2(0.33, 0.33) +mouse_filter = 2 +script = ExtResource("1_1bn2y") + +[node name="MarginContainer" type="MarginContainer" parent="."] +custom_minimum_size = Vector2(235, 30) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -116.0 +offset_top = -158.0 +offset_right = 104.0 +grow_horizontal = 2 +grow_vertical = 0 +size_flags_horizontal = 4 +size_flags_vertical = 8 +mouse_filter = 2 + +[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"] +unique_name_in_owner = true +light_mask = 16 +layout_mode = 2 +size_flags_vertical = 8 +mouse_filter = 2 +theme_type_variation = &"os_panel_container" + +[node name="OSLabel" type="RichTextLabel" parent="MarginContainer/PanelContainer"] +unique_name_in_owner = true +light_mask = 16 +clip_contents = false +layout_mode = 2 +size_flags_vertical = 8 +mouse_filter = 2 +theme_override_constants/line_separation = 2 +theme_override_fonts/normal_font = ExtResource("1_daqko") +theme_override_font_sizes/normal_font_size = 23 +bbcode_enabled = true +text = "os 测试文本" +fit_content = true +scroll_following = true +script = ExtResource("2_1bn2y") +skip_action = &"" +seconds_per_step = 0.05 +skip_pause_at_abbreviations = PackedStringArray("Mr", "Mrs", "Ms", "Dr", "etc", "eg", "ex") +seconds_per_pause_step = 0.15 + +[node name="OSTimer" type="Timer" parent="."] +unique_name_in_owner = true +one_shot = true diff --git a/scene/ground/scene/c01/s11_黄包车演出.gd b/scene/ground/scene/c01/s11_黄包车演出.gd index 67e6fa13..146fedcf 100644 --- a/scene/ground/scene/c01/s11_黄包车演出.gd +++ b/scene/ground/scene/c01/s11_黄包车演出.gd @@ -47,6 +47,11 @@ func _on_ground_ready() -> void: # _on_finished() +func sun_fall(): + var light = $"../DirectionalLight2D" + create_tween().tween_property(light, "energy", 0.7, 3.0) + + func dialog1() -> void: DialogueManager.dialogue_ended.connect(_start_running, CONNECT_ONE_SHOT) # 注意第一段 dialog 在鬼差探头阶段播放 diff --git a/scene/ground/scene/c01/s11_黄包车演出.tscn b/scene/ground/scene/c01/s11_黄包车演出.tscn index fcbadf9b..ca197e4e 100644 --- a/scene/ground/scene/c01/s11_黄包车演出.tscn +++ b/scene/ground/scene/c01/s11_黄包车演出.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=32 format=3 uid="uid://coiumaaenimbc"] +[gd_scene load_steps=33 format=3 uid="uid://coiumaaenimbc"] [ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_1sveo"] [ext_resource type="Script" uid="uid://dcn7u7v3fsscj" path="res://scene/ground/scene/c01/s11_黄包车演出.gd" id="2_espm6"] @@ -22,6 +22,7 @@ [ext_resource type="Texture2D" uid="uid://ghxwejhrp4v7" path="res://asset/art/scene/c01/s09_黄包车长场景/前景/点缀 推车三人组.png" id="15_jd8t2"] [ext_resource type="Texture2D" uid="uid://cuu2fs61ec3qc" path="res://asset/art/scene/c01/s09_黄包车长场景/前景/点缀 黄包车车夫.png" id="16_amglq"] [ext_resource type="Texture2D" uid="uid://dl43m88gcxwf" path="res://asset/art/scene/c01/s09_黄包车长场景/前景/点缀 车夫2.png" id="17_h4di6"] +[ext_resource type="Texture2D" uid="uid://cylsq5cvhlp18" path="res://asset/art/tool/point_light.png" id="17_s11la"] [ext_resource type="Texture2D" uid="uid://ddoicafsbpriq" path="res://asset/art/scene/c01/s09_黄包车长场景/前景/第一段.png" id="18_68ynl"] [ext_resource type="Texture2D" uid="uid://cnftqdbxrxlov" path="res://asset/art/scene/c01/s09_黄包车长场景/前景/第二段.png" id="19_yajus"] @@ -211,7 +212,7 @@ modulate = Color(0, 0, 0, 1) z_index = 4 position = Vector2(460, 69) sprite_frames = ExtResource("3_hnnuc") -animation = &"c00_吕萍_记笔记_right" +animation = &"c01_捡球男孩_关键帧" [node name="ambush_title1" parent="Ground/DeployLayer" index="4" instance=ExtResource("6_3k8jj")] position = Vector2(1365, 4) @@ -270,18 +271,19 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列1/路灯"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列1/路灯"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列1/路灯/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列1/路灯"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯2" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列1"] position = Vector2(333.333, 0) texture = ExtResource("9_u6881") @@ -293,18 +295,19 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列1/路灯2"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列1/路灯2"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列1/路灯2/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列1/路灯2"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯3" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列1"] position = Vector2(666.667, 0) texture = ExtResource("9_u6881") @@ -318,6 +321,7 @@ height = 40.0 [node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列1/路灯3"] position = Vector2(0, -52) +energy = 2.5 shadow_color = Color(0, 0, 0, 1) texture = ExtResource("12_2w2ir") height = 40.0 @@ -329,11 +333,16 @@ position = Vector2(-59, 48) shape = SubResource("RectangleShape2D_jd8t2") [node name="路灯序列2" type="Node2D" parent="Ground/AmbientLayer" index="1"] -position = Vector2(7950, 9) +position = Vector2(7304, 8) script = ExtResource("9_6p5hp") -total_distance = 3000.0 +total_distance = 4000.0 + +[node name="Ambush天黑" parent="Ground/AmbientLayer/路灯序列2" instance=ExtResource("6_3k8jj")] +trigger_mode = "area_enter" +hook_method = "sun_fall" [node name="路灯" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] +position = Vector2(333.333, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -343,20 +352,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯2" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(442, 0) +position = Vector2(666.667, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -366,20 +376,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯2"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯2"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯2/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯2"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯3" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(908, 0) +position = Vector2(1000, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -389,20 +400,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯3"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯3"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯3/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯3"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯4" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(1263, 0) +position = Vector2(1333.33, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -412,20 +424,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯4"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯4"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯4/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯4"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯5" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(1693, 0) +position = Vector2(1666.67, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -435,20 +448,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯5"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯5"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯5/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯5"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯6" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(2117, 0) +position = Vector2(2000, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -458,20 +472,21 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯6"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯6"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯6/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯6"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="路灯7" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(2432, 0) +position = Vector2(2333.33, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -483,8 +498,9 @@ height = 40.0 [node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯7"] position = Vector2(0, -52) +energy = 2.5 shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") +texture = ExtResource("17_s11la") height = 40.0 [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯7"] @@ -494,7 +510,7 @@ position = Vector2(-59, 48) shape = SubResource("RectangleShape2D_jd8t2") [node name="路灯8" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(3006, 0) +position = Vector2(2666.67, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -506,18 +522,19 @@ height = 40.0 [node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯8"] position = Vector2(0, -52) +energy = 2.5 shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") +texture = ExtResource("17_s11la") height = 40.0 [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯8"] -position = Vector2(-132, 56) +position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯8/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") [node name="路灯9" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] -position = Vector2(3384, 0) +position = Vector2(3000, 0) texture = ExtResource("9_u6881") script = ExtResource("11_6p5hp") @@ -527,18 +544,67 @@ shadow_color = Color(0, 0, 0, 1) texture = ExtResource("11_2w2ir") height = 40.0 -[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯9"] -position = Vector2(0, -52) -shadow_color = Color(0, 0, 0, 1) -texture = ExtResource("12_2w2ir") -height = 40.0 - [node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯9"] position = Vector2(-59, 48) [node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯9/Area2D"] shape = SubResource("RectangleShape2D_jd8t2") +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯9"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + +[node name="路灯10" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] +position = Vector2(3333.33, 0) +texture = ExtResource("9_u6881") +script = ExtResource("11_6p5hp") + +[node name="PointLight2D1" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯10"] +energy = 5.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("11_2w2ir") +height = 40.0 + +[node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯10"] +position = Vector2(-59, 48) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯10/Area2D"] +shape = SubResource("RectangleShape2D_jd8t2") + +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯10"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + +[node name="路灯11" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"] +position = Vector2(3666.67, 0) +texture = ExtResource("9_u6881") +script = ExtResource("11_6p5hp") + +[node name="PointLight2D1" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯11"] +energy = 5.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("11_2w2ir") +height = 40.0 + +[node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯11"] +position = Vector2(-159.667, 49) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯11/Area2D"] +shape = SubResource("RectangleShape2D_jd8t2") + +[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯11"] +position = Vector2(0, -52) +energy = 2.5 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("17_s11la") +height = 40.0 + [node name="MainPlayer" parent="Ground" index="5"] visible = false position = Vector2(26, 118) @@ -547,7 +613,7 @@ character = "小小蝶" [node name="CameraFocusMarker" parent="Ground" index="6" node_paths=PackedStringArray("focusing_node")] focusing_node = NodePath("../DeployLayer/车夫与吕萍") -force_offset = Vector2(30, -30) +force_offset = Vector2(40, -30) [node name="点缀 黄包车车夫" type="Sprite2D" parent="Ground/ParallaxForeground/BGParallaxLayer" index="0"] position = Vector2(687, 77) @@ -616,4 +682,8 @@ centered = false [node name="PlayerLine2D" parent="Ground/ParallaxForeground" index="2"] points = PackedVector2Array(37, 150, 11350, 150) +[node name="DirectionalLight2D" parent="Ground" index="8"] +energy = 0.0 +blend_mode = 1 + [editable path="Ground"] diff --git a/scene/ground/scene/c02/s01_公寓门口.tscn b/scene/ground/scene/c02/s01_公寓门口.tscn index 0cd870e0..1d74e5c6 100644 --- a/scene/ground/scene/c02/s01_公寓门口.tscn +++ b/scene/ground/scene/c02/s01_公寓门口.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://bbs7yy5aofw1v"] +[gd_scene load_steps=14 format=3 uid="uid://bbs7yy5aofw1v"] [ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_c4tdi"] [ext_resource type="Script" uid="uid://jkselt4d5q4r" path="res://scene/ground/scene/c02/s01_公寓门口.gd" id="2_jfumy"] @@ -8,6 +8,13 @@ [ext_resource type="PackedScene" uid="uid://ci5anaxsa1apl" path="res://scene/entity/inspectable.tscn" id="7_vc2dw"] [ext_resource type="Texture2D" uid="uid://qls0yc054048" path="res://asset/art/scene/c02/小蝉寻人启事/e_寻人启事残破.png" id="8_j2ctx"] [ext_resource type="Texture2D" uid="uid://cuyfloebe2mht" path="res://asset/art/scene/c02/小蝉寻人启事/ux_寻人启事残破.png" id="9_bhi7l"] +[ext_resource type="Texture2D" uid="uid://cg1ey0l55acvs" path="res://asset/art/scene/c01/s09_黄包车长场景/e_单个路灯.png" id="9_nglqu"] +[ext_resource type="Script" uid="uid://celg5or3mpla0" path="res://scene/ground/script/c01/s11_黄包车路灯.gd" id="10_acjhe"] +[ext_resource type="Texture2D" uid="uid://cgsq1im2q63f8" path="res://asset/art/scene/c01/s09_黄包车长场景/e_路灯灯芯.png" id="11_ev3cr"] +[ext_resource type="Texture2D" uid="uid://cylsq5cvhlp18" path="res://asset/art/tool/point_light.png" id="12_71mn6"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_nglqu"] +size = Vector2(200, 100) [node name="S01" type="Node2D"] @@ -54,6 +61,54 @@ first_interact_os_key = "c02_s01_寻人启事" texture_cover = ExtResource("9_bhi7l") content_key = "c02_寻人启事_残破" +[node name="路灯" type="Sprite2D" parent="Ground/DeployLayer" index="4"] +position = Vector2(218, -10) +texture = ExtResource("9_nglqu") +script = ExtResource("10_acjhe") + +[node name="PointLight2D1" type="PointLight2D" parent="Ground/DeployLayer/路灯"] +energy = 5.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("11_ev3cr") +height = 40.0 + +[node name="Area2D" type="Area2D" parent="Ground/DeployLayer/路灯"] +position = Vector2(0, 49) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/路灯/Area2D"] +shape = SubResource("RectangleShape2D_nglqu") + +[node name="PointLight2D2" type="PointLight2D" parent="Ground/DeployLayer/路灯"] +position = Vector2(0, -52) +energy = 2.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("12_71mn6") +height = 40.0 + +[node name="路灯2" type="Sprite2D" parent="Ground/DeployLayer" index="5"] +position = Vector2(508, -9) +texture = ExtResource("9_nglqu") +script = ExtResource("10_acjhe") + +[node name="PointLight2D1" type="PointLight2D" parent="Ground/DeployLayer/路灯2"] +energy = 5.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("11_ev3cr") +height = 40.0 + +[node name="Area2D" type="Area2D" parent="Ground/DeployLayer/路灯2"] +position = Vector2(0, 49) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/路灯2/Area2D"] +shape = SubResource("RectangleShape2D_nglqu") + +[node name="PointLight2D2" type="PointLight2D" parent="Ground/DeployLayer/路灯2"] +position = Vector2(0, -52) +energy = 2.0 +shadow_color = Color(0, 0, 0, 1) +texture = ExtResource("12_71mn6") +height = 40.0 + [node name="MainPlayer" parent="Ground" index="5"] position = Vector2(78, 98) diff --git a/scene/ground/script/c01/s11_黄包车路灯.gd b/scene/ground/script/c01/s11_黄包车路灯.gd index 64b490ab..071ae16f 100644 --- a/scene/ground/script/c01/s11_黄包车路灯.gd +++ b/scene/ground/script/c01/s11_黄包车路灯.gd @@ -14,6 +14,7 @@ func _ready() -> void: original_energy2 = light2.energy light2.energy = 0.0 area.area_entered.connect(_on_area_entered) + area.body_entered.connect(_on_area_entered) func _on_area_entered(_area) -> void: diff --git a/scene/little_game/书架/书架.gd b/scene/little_game/书架/书架.gd index c1119540..7d1bb6a5 100644 --- a/scene/little_game/书架/书架.gd +++ b/scene/little_game/书架/书架.gd @@ -6,7 +6,6 @@ signal success const NON_SELECTED = [-1, -1] -@export var shuffle_times := 4 @export var debug_relocate := false: set(value): debug_relocate = false @@ -82,22 +81,34 @@ func _measure_width_by_row() -> void: func _shuffle_books() -> void: selected_book = NON_SELECTED - if GlobalConfig.DEBUG: - SceneManager.pop_debug_dialog_info( - "备注", "debug模式每列随机洗牌 1 次,正常模式每列随机洗牌 " + str(shuffle_times) + " 次" - ) - shuffle_times = 4 suffling = true rand_from_seed(Time.get_ticks_usec()) - for row in range(3): - # shuffle each row 20 times - var r_size = current_answer[row].size() - for _i in range(shuffle_times): - var col_1 = randi() % r_size - var col_2 = randi() % r_size - selected_book = [row, col_1] - _interchange_book(row, col_2, false) - _relocate_books(row) + # 猫 4 次 + var shuffle_times = 4 + var r_size = current_answer[0].size() + for _i in range(shuffle_times): + var col_1 = randi() % r_size + var col_2 = randi() % r_size + selected_book = [0, col_1] + _interchange_book(0, col_2, false) + _relocate_books(0) + # 其他 1 次 + shuffle_times = 1 + r_size = current_answer[1].size() + for _i in range(shuffle_times): + var col_1 = randi() % r_size + var col_2 = randi() % r_size + selected_book = [1, col_1] + _interchange_book(1, col_2, false) + _relocate_books(1) + r_size = current_answer[2].size() + for _i in range(shuffle_times): + var col_1 = randi() % r_size + var col_2 = randi() % r_size + selected_book = [2, col_1] + _interchange_book(2, col_2, false) + _relocate_books(2) + # turn off initilazing after shuffle suffling = false diff --git a/scene/settings/settings.gd b/scene/settings/settings.gd index 31c4b8f2..4eb214d7 100644 --- a/scene/settings/settings.gd +++ b/scene/settings/settings.gd @@ -6,6 +6,9 @@ extends CanvasLayer @onready var language_options = %OptionButtonLanguage as OptionButton @onready var caption_box = %"字幕" as BoxContainer @onready var caption_options = %OptionButtonCaption as OptionButton +@onready var os_auto_end = %OSAutoEnd as CheckBox +@onready var os_wait_time_box = %OSWaitTimeBox as BoxContainer +@onready var h_slider_os_wait_time = %HSliderOSWaitTime as HSlider @onready var autosave_box = %AutoSaveCheckBox as CheckBox @onready var autosave_time_edit = %SaveTimeLineEdit as LineEdit @onready var fullscreen_box = %FullscreenBox as CheckBox @@ -50,6 +53,9 @@ func _ready(): dialog_bus_slider.value = db_to_linear( AudioServer.get_bus_volume_db(AudioServer.get_bus_index("dialog")) - dialog_db_offset ) + %MainPercentage.text = str(int(master_bus_slider.value * 100)) + %SfxPercentage.text = str(int(sfx_bus_slider.value * 100)) + %DialogPercentage.text = str(int(dialog_bus_slider.value * 100)) master_bus_slider.value_changed.connect(_on_master_bus_slider_value_changed) sfx_bus_slider.value_changed.connect(_on_sfx_bus_slider_value_changed) dialog_bus_slider.value_changed.connect(_on_dialog_bus_slider_value_changed) @@ -61,6 +67,14 @@ func _ready(): caption_options.item_selected.connect(_on_language_or_caption_options_selected) # setup language _on_language_or_caption_options_selected() + # os auto finish + os_auto_end.button_pressed = GlobalConfigManager.config.os_auto_end + os_auto_end.toggled.connect(_on_os_auto_end_toggled) + # 使它生效 + _on_os_auto_end_toggled(GlobalConfigManager.config.os_auto_end) + # 最大范围为 10 秒,精度 0.1 + h_slider_os_wait_time.value_changed.connect(_on_os_wait_time_slider_value_changed) + h_slider_os_wait_time.value = clampf(GlobalConfigManager.config.os_wait_time / 10.0, 0, 1.0) # auto save autosave_box.button_pressed = GlobalConfigManager.config.auto_save_enabled autosave_time_edit.editable = GlobalConfigManager.config.auto_save_enabled @@ -79,21 +93,26 @@ func _ready(): SceneManager.toggle_pause_counter(true) # open $"Sfx打开".play() + # # resize + # $VBoxContainer.size = Vector2.ZERO func _on_master_bus_slider_value_changed(value: float) -> void: + %MainPercentage.text = str(int(value * 100)) var db_value = linear_to_db(value) GlobalConfigManager.config.db_master = db_value AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), db_value) func _on_sfx_bus_slider_value_changed(value: float) -> void: + %SfxPercentage.text = str(int(value * 100)) var db_value = linear_to_db(value) + sfx_db_offset GlobalConfigManager.config.db_game_sfx = db_value AudioServer.set_bus_volume_db(AudioServer.get_bus_index("game_sfx"), db_value) func _on_dialog_bus_slider_value_changed(value: float) -> void: + %DialogPercentage.text = str(int(value * 100)) var db_value = linear_to_db(value) + dialog_db_offset GlobalConfigManager.config.db_dialog = db_value AudioServer.set_bus_volume_db(AudioServer.get_bus_index("dialog"), db_value) @@ -106,11 +125,32 @@ func _on_language_or_caption_options_selected(_id = null) -> void: var caption_id = caption_options.selected if lang_id != 0: caption_box.hide() + language_options.focus_neighbor_bottom = os_auto_end.get_path() + os_auto_end.focus_neighbor_top = language_options.get_path() else: caption_box.show() + language_options.focus_neighbor_bottom = caption_options.get_path() + os_auto_end.focus_neighbor_top = caption_options.get_path() GlobalConfigManager.update_locale(lang_id, caption_id) +func _on_os_auto_end_toggled(is_pressed: bool) -> void: + GlobalConfigManager.config.os_auto_end = is_pressed + os_wait_time_box.visible = is_pressed + if not is_pressed: + os_auto_end.focus_neighbor_bottom = autosave_box.get_path() + autosave_box.focus_neighbor_top = os_auto_end.get_path() + else: + os_auto_end.focus_neighbor_bottom = h_slider_os_wait_time.get_path() + autosave_box.focus_neighbor_top = h_slider_os_wait_time.get_path() + + +func _on_os_wait_time_slider_value_changed(value: float) -> void: + # 最大范围为 10 秒,精度 0.1 + GlobalConfigManager.config.os_wait_time = int(value * 100.0) * 0.1 + %OSWaitTimePercentage.text = str(GlobalConfigManager.config.os_wait_time) + + func _on_autosave_box_toggled(is_pressed: bool) -> void: GlobalConfigManager.config.auto_save_enabled = is_pressed autosave_time_edit.editable = GlobalConfigManager.config.auto_save_enabled diff --git a/scene/settings/settings.tscn b/scene/settings/settings.tscn index d6ff04d3..7db1bc34 100644 --- a/scene/settings/settings.tscn +++ b/scene/settings/settings.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=8 format=3 uid="uid://beok2r6fgburn"] +[gd_scene load_steps=9 format=3 uid="uid://beok2r6fgburn"] [ext_resource type="Script" uid="uid://ciloxu1k8a1ll" path="res://scene/settings/settings.gd" id="1_7u4nq"] [ext_resource type="AudioStream" uid="uid://dlt4nv6qjhlpy" path="res://asset/audio/sfx/交互/sfx_打开设置.wav" id="2_6hxkf"] [ext_resource type="Script" uid="uid://rq6w1vuhuq1m" path="res://scene/entity/audio/sfx.gd" id="3_kn03d"] [ext_resource type="AudioStream" uid="uid://cmi6fd68s1ukb" path="res://asset/audio/sfx/交互/sfx_关闭设置.wav" id="4_n2b1f"] [ext_resource type="Texture2D" uid="uid://f186lvt5y2ql" path="res://asset/art/ui/inspect/inspect背景遮罩.png" id="5_kn03d"] +[ext_resource type="Theme" uid="uid://be5scnhjobkux" path="res://config/settings_theme.tres" id="6_7e43x"] [ext_resource type="FontVariation" uid="uid://1ryw42kej6lv" path="res://config/font_ui.tres" id="6_n2b1f"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_n2b1f"] @@ -39,110 +40,129 @@ grow_vertical = 2 mouse_filter = 0 texture = ExtResource("5_kn03d") -[node name="VBoxContainer" type="VBoxContainer" parent="."] -custom_minimum_size = Vector2(0, 199) +[node name="MarginContainer" type="MarginContainer" parent="."] anchors_preset = 8 anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -95.0 -offset_top = -109.5 -offset_right = 95.0 -offset_bottom = 109.5 +offset_left = -119.5 +offset_top = -123.5 +offset_right = 119.5 +offset_bottom = 123.5 grow_horizontal = 2 grow_vertical = 2 -size_flags_horizontal = 4 -[node name="总音量" type="HBoxContainer" parent="VBoxContainer"] +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] +custom_minimum_size = Vector2(150, 150) +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 4 +theme = ExtResource("6_7e43x") + +[node name="总音量" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="VBoxContainer/总音量"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/总音量"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_总音量" -[node name="HSliderMasterBus" type="HSlider" parent="VBoxContainer/总音量"] +[node name="HSliderMasterBus" type="HSlider" parent="MarginContainer/VBoxContainer/总音量"] unique_name_in_owner = true -custom_minimum_size = Vector2(100, 5) +custom_minimum_size = Vector2(90, 0) layout_mode = 2 size_flags_horizontal = 10 +size_flags_vertical = 4 focus_neighbor_bottom = NodePath("../../音效音量/HSliderSfxBus") focus_next = NodePath("../../音效音量/HSliderSfxBus") max_value = 1.0 step = 0.01 value = 1.0 -[node name="音效音量" type="HBoxContainer" parent="VBoxContainer"] +[node name="MainPercentage" type="Label" parent="MarginContainer/VBoxContainer/总音量"] +unique_name_in_owner = true +custom_minimum_size = Vector2(19, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "70" + +[node name="音效音量" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="VBoxContainer/音效音量"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/音效音量"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_音效音量" -[node name="HSliderSfxBus" type="HSlider" parent="VBoxContainer/音效音量"] +[node name="HSliderSfxBus" type="HSlider" parent="MarginContainer/VBoxContainer/音效音量"] unique_name_in_owner = true -custom_minimum_size = Vector2(100, 5) +custom_minimum_size = Vector2(90, 0) layout_mode = 2 size_flags_horizontal = 10 +size_flags_vertical = 4 focus_neighbor_top = NodePath("../../总音量/HSliderMasterBus") focus_neighbor_bottom = NodePath("../../对话音量/HSliderDialogBus") max_value = 1.0 step = 0.01 value = 1.0 -[node name="对话音量" type="HBoxContainer" parent="VBoxContainer"] +[node name="SfxPercentage" type="Label" parent="MarginContainer/VBoxContainer/音效音量"] +unique_name_in_owner = true +custom_minimum_size = Vector2(19, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "70" + +[node name="对话音量" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="Label" type="Label" parent="VBoxContainer/对话音量"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/对话音量"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_对话音量" -[node name="HSliderDialogBus" type="HSlider" parent="VBoxContainer/对话音量"] +[node name="HSliderDialogBus" type="HSlider" parent="MarginContainer/VBoxContainer/对话音量"] unique_name_in_owner = true -custom_minimum_size = Vector2(100, 5) +custom_minimum_size = Vector2(90, 0) layout_mode = 2 size_flags_horizontal = 10 +size_flags_vertical = 4 focus_neighbor_top = NodePath("../../音效音量/HSliderSfxBus") focus_neighbor_bottom = NodePath("../../语言/OptionButtonLanguage") max_value = 1.0 step = 0.01 value = 1.0 -[node name="HSeparator" type="HSeparator" parent="VBoxContainer"] +[node name="DialogPercentage" type="Label" parent="MarginContainer/VBoxContainer/对话音量"] +unique_name_in_owner = true +custom_minimum_size = Vector2(19, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "100" + +[node name="HSeparator" type="HSeparator" parent="MarginContainer/VBoxContainer"] layout_mode = 2 -[node name="语言" type="HBoxContainer" parent="VBoxContainer"] +[node name="语言" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] layout_mode = 2 size_flags_horizontal = 4 -[node name="Label" type="Label" parent="VBoxContainer/语言"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/语言"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_语言" -[node name="VSeparator" type="VSeparator" parent="VBoxContainer/语言"] +[node name="VSeparator" type="VSeparator" parent="MarginContainer/VBoxContainer/语言"] layout_mode = 2 theme_override_constants/separation = 31 theme_override_styles/separator = SubResource("StyleBoxEmpty_n2b1f") -[node name="OptionButtonLanguage" type="OptionButton" parent="VBoxContainer/语言"] +[node name="OptionButtonLanguage" type="OptionButton" parent="MarginContainer/VBoxContainer/语言"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_top = NodePath("../../对话音量/HSliderDialogBus") -focus_neighbor_bottom = NodePath("../../自动保存/AutoSaveCheckBox") -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 +focus_neighbor_bottom = NodePath("../../字幕/OptionButtonCaption") selected = 0 allow_reselect = true item_count = 2 @@ -151,30 +171,26 @@ popup/item_0/id = 0 popup/item_1/text = "English" popup/item_1/id = 2 -[node name="字幕" type="HBoxContainer" parent="VBoxContainer"] +[node name="字幕" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 -[node name="Label" type="Label" parent="VBoxContainer/字幕"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/字幕"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_字幕" -[node name="VSeparator" type="VSeparator" parent="VBoxContainer/字幕"] +[node name="VSeparator" type="VSeparator" parent="MarginContainer/VBoxContainer/字幕"] layout_mode = 2 theme_override_constants/separation = 31 theme_override_styles/separator = SubResource("StyleBoxEmpty_n2b1f") -[node name="OptionButtonCaption" type="OptionButton" parent="VBoxContainer/字幕"] +[node name="OptionButtonCaption" type="OptionButton" parent="MarginContainer/VBoxContainer/字幕"] unique_name_in_owner = true layout_mode = 2 -focus_neighbor_top = NodePath("../../对话音量/HSliderDialogBus") -focus_neighbor_bottom = NodePath("../../自动保存/AutoSaveCheckBox") -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 +focus_neighbor_top = NodePath("../../语言/OptionButtonLanguage") +focus_neighbor_bottom = NodePath("../../OSAutoEnd") selected = 0 allow_reselect = true item_count = 2 @@ -183,58 +199,97 @@ popup/item_0/id = 1 popup/item_1/text = "普通话" popup/item_1/id = 0 -[node name="HSeparator4" type="HSeparator" parent="VBoxContainer"] +[node name="HSeparator2" type="HSeparator" parent="MarginContainer/VBoxContainer"] +visible = false layout_mode = 2 -[node name="自动保存" type="HBoxContainer" parent="VBoxContainer"] +[node name="OSAutoEnd" type="CheckBox" parent="MarginContainer/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 4 +focus_neighbor_top = NodePath("../字幕/OptionButtonCaption") +focus_neighbor_bottom = NodePath("../OSWaitTimeBox/HSliderOSWaitTime") +text = "setting_气泡文字自动结束" + +[node name="OSWaitTimeBox" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +unique_name_in_owner = true layout_mode = 2 -[node name="AutoSaveCheckBox" type="CheckBox" parent="VBoxContainer/自动保存"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/OSWaitTimeBox"] +custom_minimum_size = Vector2(50, 0) +layout_mode = 2 +text = "setting_气泡等待时长" + +[node name="HSliderOSWaitTime" type="HSlider" parent="MarginContainer/VBoxContainer/OSWaitTimeBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(90, 0) +layout_mode = 2 +size_flags_horizontal = 10 +size_flags_vertical = 4 +focus_neighbor_top = NodePath("../../OSAutoEnd") +focus_neighbor_bottom = NodePath("../../自动保存/AutoSaveCheckBox") +max_value = 1.0 +step = 0.01 +value = 1.0 + +[node name="OSWaitTimePercentage" type="Label" parent="MarginContainer/VBoxContainer/OSWaitTimeBox"] +unique_name_in_owner = true +custom_minimum_size = Vector2(19, 0) +layout_mode = 2 +size_flags_horizontal = 4 +text = "2" + +[node name="Label2" type="Label" parent="MarginContainer/VBoxContainer/OSWaitTimeBox"] +custom_minimum_size = Vector2(5, 0) +layout_mode = 2 +text = "ui_秒" + +[node name="HSeparator4" type="HSeparator" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="自动保存" type="HBoxContainer" parent="MarginContainer/VBoxContainer"] +layout_mode = 2 + +[node name="AutoSaveCheckBox" type="CheckBox" parent="MarginContainer/VBoxContainer/自动保存"] unique_name_in_owner = true layout_mode = 2 focus_neighbor_top = NodePath("../../语言/OptionButtonLanguage") focus_neighbor_right = NodePath("../SaveTimeLineEdit") focus_neighbor_bottom = NodePath("../../显示方式/FullscreenBox") focus_next = NodePath("../SaveTimeLineEdit") -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_自动保存" -[node name="SaveTimeLineEdit" type="LineEdit" parent="VBoxContainer/自动保存"] +[node name="SaveTimeLineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer/自动保存"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 10 focus_neighbor_left = NodePath("../AutoSaveCheckBox") -focus_neighbor_top = NodePath("../../语言/OptionButtonLanguage") +focus_neighbor_top = NodePath("../../OSAutoEnd") focus_neighbor_bottom = NodePath("../../显示方式/FullscreenBox") focus_next = NodePath("../../显示方式/FullscreenBox") max_length = 5 caret_blink = true -[node name="Label" type="Label" parent="VBoxContainer/自动保存"] +[node name="Label" type="Label" parent="MarginContainer/VBoxContainer/自动保存"] layout_mode = 2 size_flags_horizontal = 8 -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "ui_秒" -[node name="显示方式" type="GridContainer" parent="VBoxContainer"] +[node name="显示方式" type="GridContainer" parent="MarginContainer/VBoxContainer"] custom_minimum_size = Vector2(0, 32) layout_mode = 2 columns = 2 -[node name="FullscreenBox" type="CheckBox" parent="VBoxContainer/显示方式"] +[node name="FullscreenBox" type="CheckBox" parent="MarginContainer/VBoxContainer/显示方式"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 4 focus_neighbor_top = NodePath("../../自动保存/SaveTimeLineEdit") focus_neighbor_right = NodePath("../TopBox") focus_next = NodePath("../TopBox") -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_全屏" -[node name="TopBox" type="CheckBox" parent="VBoxContainer/显示方式"] +[node name="TopBox" type="CheckBox" parent="MarginContainer/VBoxContainer/显示方式"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 10 @@ -242,14 +297,9 @@ focus_neighbor_left = NodePath("../FullscreenBox") focus_neighbor_top = NodePath("../../自动保存/SaveTimeLineEdit") focus_neighbor_bottom = NodePath("../../ReturnBtn") focus_previous = NodePath("../FullscreenBox") -theme_override_fonts/font = ExtResource("6_n2b1f") -theme_override_font_sizes/font_size = 11 text = "setting_置顶" -[node name="HSeparator3" type="HSeparator" parent="VBoxContainer"] -layout_mode = 2 - -[node name="ReturnBtn" type="Button" parent="VBoxContainer"] +[node name="ReturnBtn" type="Button" parent="MarginContainer/VBoxContainer"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 6 diff --git a/util/util.gd b/util/util.gd index 658d03be..9616dcff 100644 --- a/util/util.gd +++ b/util/util.gd @@ -3,6 +3,8 @@ extends Node #### Timer func wait(duration: float) -> void: + if duration <= 0: + return await get_tree().create_timer(duration).timeout