improve ui and bug fix
This commit was merged in pull request #30.
This commit is contained in:
BIN
core/photo_mode/assets/reticolo.png
Normal file
BIN
core/photo_mode/assets/reticolo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
40
core/photo_mode/assets/reticolo.png.import
Normal file
40
core/photo_mode/assets/reticolo.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dcsy5yawnlxhq"
|
||||
path="res://.godot/imported/reticolo.png-dba8a0c9eb8601e74902df2dc1fc51e5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://core/photo_mode/assets/reticolo.png"
|
||||
dest_files=["res://.godot/imported/reticolo.png-dba8a0c9eb8601e74902df2dc1fc51e5.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
@@ -31,9 +31,10 @@ func get_all_collectibles() -> Array[CollectibleResource]:
|
||||
func get_unlocked_collectible_ids() -> Array[StringName]:
|
||||
return unlocked_collectibles_ids
|
||||
|
||||
func save_photo_to_disk_async() -> void:
|
||||
await RenderingServer.frame_post_draw
|
||||
var image = get_viewport().get_texture().get_image()
|
||||
func save_photo_to_disk_async(image: Image) -> void:
|
||||
if not image:
|
||||
return
|
||||
|
||||
|
||||
if not DirAccess.dir_exists_absolute("user://photos"):
|
||||
DirAccess.make_dir_absolute("user://photos")
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user