improve ui and bug fix

This commit was merged in pull request #30.
This commit is contained in:
2026-06-06 14:19:27 +00:00
parent f049c538bd
commit d80aa93bb9
87 changed files with 1777 additions and 209 deletions

View File

@@ -18,12 +18,24 @@ 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
var is_making_photo = false
var captured_image: Image
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
@@ -46,17 +58,42 @@ 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 get_tree().paused:
return
if not is_active:
enable_photo_mode()
GameState.on_enable_photo_mode_request.emit()
else:
disable_photo_mode()
if not is_making_photo:
GameState.on_disable_photo_mode_request.emit()
if event is InputEventMouseMotion and is_active:
total_yaw -= event.relative.x * rotation_speed
if event.is_action_pressed("take_photo"):
take_photo_async()
if !is_active or is_making_photo:
return
is_making_photo = true
GameState.on_photo_taken_prepare.emit()
await RenderingServer.frame_post_draw
captured_image = get_viewport().get_texture().get_image()
GameState.on_photo_taken_started.emit()
func _process(delta: float) -> void:
if not is_active:
@@ -81,13 +118,10 @@ func _process(delta: float) -> void:
basis = rotated_basis.orthonormalized()
func take_photo_async() -> void:
if !is_active:
return
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()
CollectionManager.save_photo_to_disk_async(captured_image)
for target in targets:
if not target.collectible_data:
@@ -104,3 +138,7 @@ func take_photo_async() -> void:
CollectionManager.unlock_collectible(target.collectible_data.id)
GameState.save_game()
GameState.on_photo_taken_finished.emit()
func _on_photo_mode_black_screen_disappeared() -> void:
is_making_photo = false