improve ui and bug fix

This commit is contained in:
2026-06-02 23:03:30 +02:00
parent 1f645129c9
commit 34ffced619
5 changed files with 144 additions and 22 deletions

View File

@@ -11,13 +11,15 @@ signal on_enable_photo_mode_request
@warning_ignore("unused_signal")
signal on_disable_photo_mode_request
@warning_ignore("unused_signal")
signal on_photo_taken_prepare
@warning_ignore("unused_signal")
signal on_photo_taken_started
@warning_ignore("unused_signal")
signal on_photo_taken_making
@warning_ignore("unused_signal")
signal on_photo_taken_finished
@warning_ignore("unused_signal")
signal on_photo_taken_prepare
signal on_photo_mode_black_screen_disappeared
const SAVE_PATH: String = "user://savegame.json"

View File

@@ -13,10 +13,12 @@ enum Weather {RAIN, SNOW}
@onready var photo_mode_texture_panel: Panel = $%PhotoModeTexturePanel
@onready var photo_mode_texture_mask: TextureRect = $%PhotoModeTextureMask
@onready var photo_mode_black_screen: ColorRect = $%PhotoModeBlackScreen
@onready var collection_options: VBoxContainer = $%CollectionOptions
@onready var audio_player: Control = $%AudioPlayer
var cycle = false
var _photo_mode_mat_tween: Tween
var _photo_mode_alpha_tween: Tween
var _photo_mode_fold_tween: Tween
func _ready() -> void:
GameState.on_enable_photo_mode_request.connect(_on_enable_photo_mode)
@@ -50,6 +52,7 @@ func _on_resume_button_pressed() -> void:
await tween.finished
game_menu_panel.hide()
GameState.resume_game()
GameState.on_game_menu_closed.emit()
func _on_time_of_day_row_on_option_changed(data: String) -> void:
match data:
@@ -99,26 +102,41 @@ func _on_enable_photo_mode() -> void:
var mat = photo_mode_texture_panel.material as ShaderMaterial
if mat:
mat.set_shader_parameter("hole_size", Vector2(0.72, 0.0))
var tween = create_tween()
tween.tween_property(mat, "shader_parameter/hole_size", Vector2(0.72, 0.806), 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
if _photo_mode_mat_tween:
_photo_mode_mat_tween.kill()
_photo_mode_mat_tween = create_tween()
_photo_mode_mat_tween.tween_property(mat, "shader_parameter/hole_size", Vector2(0.72, 0.806), 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_OUT)
var alpha_tween = create_tween()
alpha_tween.tween_property(photo_mode_texture_mask, "modulate:a", 1.0, 0.3).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
if _photo_mode_alpha_tween:
_photo_mode_alpha_tween.kill()
_photo_mode_alpha_tween = create_tween()
_photo_mode_alpha_tween.tween_property(photo_mode_texture_mask, "modulate:a", 1.0, 0.3).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
TweenFX.fold_in(photo_mode_texture_mask)
if _photo_mode_fold_tween:
_photo_mode_fold_tween.kill()
_photo_mode_fold_tween = TweenFX.fold_in(photo_mode_texture_mask)
func _on_disable_photo_mode() -> void:
show_ui_for_photo_mode()
var mat = photo_mode_texture_panel.material as ShaderMaterial
if mat:
var mat_tween = create_tween()
mat_tween.tween_property(mat, "shader_parameter/hole_size", Vector2(0.72, 0.0), 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN)
if _photo_mode_mat_tween:
_photo_mode_mat_tween.kill()
_photo_mode_mat_tween = create_tween()
_photo_mode_mat_tween.tween_property(mat, "shader_parameter/hole_size", Vector2(0.72, 0.0), 0.3).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN)
var alpha_tween = create_tween()
alpha_tween.tween_property(photo_mode_texture_mask, "modulate:a", 0.0, 0.3).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
if _photo_mode_alpha_tween:
_photo_mode_alpha_tween.kill()
_photo_mode_alpha_tween = create_tween()
_photo_mode_alpha_tween.tween_property(photo_mode_texture_mask, "modulate:a", 0.0, 0.3).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
var tween = TweenFX.fold_out(photo_mode_texture_mask)
await tween.finished
if _photo_mode_fold_tween:
_photo_mode_fold_tween.kill()
_photo_mode_fold_tween = TweenFX.fold_out(photo_mode_texture_mask)
if _photo_mode_fold_tween:
await _photo_mode_fold_tween.finished
photo_mode_texture_panel.hide()
func _on_photo_capture_prepare() -> void:
@@ -140,22 +158,26 @@ func _on_photo_taken_finished() -> void:
var tween = TweenFX.fold_out(photo_mode_black_screen)
await tween.finished
photo_mode_black_screen.hide()
GameState.on_photo_mode_black_screen_disappeared.emit()
func hide_ui_for_photo_mode() -> void:
TweenFX.fade_out(weather_row, 0.25)
TweenFX.fade_out(time_of_day_row, 0.25)
TweenFX.fade_out(menu_icon_button, 0.25)
TweenFX.fade_out(collection_options, 0.25)
TweenFX.fade_out(photo_icon_button, 0.25)
TweenFX.fade_out(collectible_icon_button, 0.25)
TweenFX.fade_out(audio_player, 0.25)
func show_ui_for_photo_mode() -> void:
weather_row.show()
time_of_day_row.show()
menu_icon_button.show()
collection_options.show()
photo_icon_button.show()
collectible_icon_button.show()
audio_player.show()
TweenFX.fade_in(weather_row, 0.25)
TweenFX.fade_in(time_of_day_row, 0.25)
TweenFX.fade_in(menu_icon_button, 0.25)
TweenFX.fade_in(collection_options, 0.25)
TweenFX.fade_in(photo_icon_button, 0.25)
TweenFX.fade_in(collectible_icon_button, 0.25)
TweenFX.fade_in(audio_player, 0.25)

View File

@@ -100,7 +100,6 @@ offset_left = -160.0
grow_horizontal = 0
[node name="CollectionOptions" type="VBoxContainer" parent="." unique_id=542153805]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 6
anchor_left = 1.0

View File

@@ -1,11 +1,20 @@
extends Control
@onready var photo_texture: TextureRect = $%PhotoTexture
@onready var collectible_button: Control = get_parent().get_node_or_null("%CollectibleIconButton")
var initial_pos_saved := false
var initial_pos: Vector2
var move_tween: Tween
var is_photo_mode_enable = false
var current_execution: int = 0
func _ready() -> void:
GameState.on_photo_taken_prepare.connect(_hide_photo_taken)
GameState.on_photo_taken_finished.connect(_show_photo_taken)
CollectionManager.on_photo_saved.connect(_set_photo_taken)
GameState.on_enable_photo_mode_request.connect(_on_enable_photo_mode)
GameState.on_disable_photo_mode_request.connect(_on_disable_photo_mode)
GameState.on_photo_taken_finished.connect(_show_photo_taken)
GameState.on_photo_taken_prepare.connect(_hide_photo_taken)
func _hide_photo_taken() -> void:
hide()
@@ -17,10 +26,77 @@ func _set_photo_taken(file_path) -> void:
photo_texture.texture = texture
func _show_photo_taken() -> void:
current_execution += 1
var my_execution = current_execution
reset()
if not initial_pos_saved:
initial_pos = global_position
initial_pos_saved = true
global_position = initial_pos
scale = Vector2(1,1)
modulate.a = 1.0
rotation_degrees = 0.0
show()
var tween = TweenFX.explode(self, 5, 3)
await tween.finished
var explode_tween_duration = 5.5
var move_tween_duration = 1.0
var explode_tween = TweenFX.explode(self, explode_tween_duration, 3)
await get_tree().create_timer(explode_tween_duration / 2).timeout
if my_execution != current_execution:
return
if not is_photo_mode_enable:
return
collectible_button.scale = Vector2(1,1)
collectible_button.show()
collectible_button.modulate.a = 1
TweenFX.fold_in(collectible_button, 1)
move_tween = create_tween()
var target_pos = collectible_button.global_position
move_tween.tween_property(self, "global_position:x", target_pos.x, move_tween_duration).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
move_tween.parallel().tween_property(self, "global_position:y", target_pos.y, move_tween_duration).set_trans(Tween.TRANS_BACK).set_ease(Tween.EASE_IN)
await explode_tween.finished
if my_execution != current_execution:
return
var fold_out_tween = TweenFX.fold_out(collectible_button)
if fold_out_tween:
await fold_out_tween.finished
if my_execution != current_execution:
return
hide()
collectible_button.scale = Vector2(1,1)
collectible_button.modulate.a = 1
collectible_button.hide()
func _on_enable_photo_mode() -> void:
is_photo_mode_enable = true
func _on_disable_photo_mode() -> void:
is_photo_mode_enable = false
reset()
func reset() -> void:
TweenFX.stop_all(self)
if move_tween:
move_tween.kill()
hide()
if collectible_button:
TweenFX.stop_all(collectible_button)
collectible_button.scale = Vector2(1,1)
if is_photo_mode_enable:
collectible_button.modulate.a = 1
collectible_button.hide()

View File

@@ -18,6 +18,13 @@ var current_pan: Vector2 = Vector2.ZERO
var is_active: bool = false
var previous_camera: Camera3D
@export_group("Isometric Zoom")
@export var normal_size : float = 35.0
@export var zoom_size : float = 60.0
@export var zoom_time : float = 1.2
var is_zoomed : bool = false
var zoom_tween : Tween
var initial_local_pos: Vector3
var initial_local_basis: Basis
@@ -28,6 +35,7 @@ func _ready() -> void:
GameState.on_enable_photo_mode_request.connect(enable_photo_mode)
GameState.on_disable_photo_mode_request.connect(disable_photo_mode)
GameState.on_photo_taken_making.connect(take_photo_async)
GameState.on_photo_mode_black_screen_disappeared.connect(_on_photo_mode_black_screen_disappeared)
initial_local_pos = position
initial_local_basis = basis
@@ -50,6 +58,19 @@ func disable_photo_mode() -> void:
previous_camera.make_current()
func _input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_Z and camera:
is_zoomed = !is_zoomed
var target_size = zoom_size if is_zoomed else normal_size
if zoom_tween and zoom_tween.is_valid():
zoom_tween.kill()
zoom_tween = create_tween()
zoom_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
zoom_tween.tween_property(camera, "size", target_size, zoom_time)
zoom_tween.parallel().tween_property(camera, "fov", target_size, zoom_time)
if event.is_action_pressed("toggle_photo_mode"):
if not is_active:
GameState.on_enable_photo_mode_request.emit()
@@ -98,7 +119,7 @@ func take_photo_async() -> void:
var targets = get_tree().get_nodes_in_group("collectible")
var space_state = get_world_3d().direct_space_state
await CollectionManager.save_photo_to_disk_async(captured_image)
CollectionManager.save_photo_to_disk_async(captured_image)
for target in targets:
if not target.collectible_data:
@@ -116,4 +137,6 @@ func take_photo_async() -> void:
GameState.save_game()
GameState.on_photo_taken_finished.emit()
func _on_photo_mode_black_screen_disappeared() -> void:
is_making_photo = false