Skip to content

Commit 8105d6b

Browse files
committed
Fixed animation windows and backup scene before saving
1 parent 0b0ffba commit 8105d6b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/editor/JulGameEditor/Components/ComponentInputs.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,17 @@ function show_animator_properties(animator, animation_window_dict, animator_prev
251251
# put these in a ref dictionary
252252
window_info = Ref(Dict("points" => points, "scrolling" => scrolling, "adding_line" => adding_line, "zoom_level" => zoom_level, "grid_step" => grid_step))
253253
# check if animation_window_dict has the key "frame $(k)"
254-
if haskey(animation_window_dict[], "frame $(k)")
254+
key = "animation-$(animator.parent.id)-$(i)-frame-$(k)"
255+
256+
if haskey(animation_window_dict[], key)
255257
# animation_window_dict[]["frame $(k)"][]["points"] = points
256-
window_info[] = animation_window_dict[]["frame $(k)"][]
258+
window_info[] = animation_window_dict[][key][]
257259
else
258-
animation_window_dict[]["frame $(k)"] = window_info
260+
animation_window_dict[][key] = window_info
259261
end
260262

261263
sprite = animator.parent.sprite
262-
anim_x, anim_y, anim_w, anim_h = show_animation_window("frame $(k)", window_info, sprite.texture, sprite.size.x, sprite.size.y)
264+
anim_x, anim_y, anim_w, anim_h = show_animation_window(key, window_info, sprite.texture, sprite.size.x, sprite.size.y)
263265
if anim_x == -1 && anim_y == -1 && anim_w == -1 && anim_h == -1
264266
# TODO: fix this anim_x, anim_y, anim_w, anim_h = vec.x, vec.y, vec.z, vec.t
265267
continue

src/engine/SceneManagement/SceneWriter.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,16 @@ module SceneWriterModule
6969
"Camera" => Dict("position" => Dict("x" => camera.position.x, "y" => camera.position.y), "backgroundColor" => Dict("r" => camera.backgroundColor[1], "g" => camera.backgroundColor[2], "b" => camera.backgroundColor[3], "a" => camera.backgroundColor[4]), "size" => Dict("x" => camera.size.x, "y" => camera.size.y), "offset" => Dict("x" => camera.offset.x, "y" => camera.offset.y), "startingCoordinates" => Dict("x" => camera.startingCoordinates.x, "y" => camera.startingCoordinates.y))
7070
)
7171
try
72-
println("writing to $(joinpath(projectPath, "scenes", "$(sceneName)"))")
73-
open(joinpath(projectPath, "scenes", "$(sceneName)"), "w") do io
72+
name = split(sceneName,".")[1]
73+
@info "writing to $(joinpath(projectPath, "scenes", "$(sceneName)"))"
74+
75+
open(joinpath(projectPath, "scenes", "$(name)-saving"), "w") do io
7476
JSON3.pretty(io, entitiesJson)
7577
end
78+
if isfile(joinpath(projectPath, "scenes", "$(sceneName)"))
79+
mv(joinpath(projectPath, "scenes", "$(sceneName)"), joinpath(projectPath, "scenes", "$(name)-backup.json"); force=true)
80+
end
81+
mv(joinpath(projectPath, "scenes", "$(name)-saving"), joinpath(projectPath, "scenes", "$(sceneName)"); force=true)
7682
catch e
7783
@error string(e)
7884
Base.show_backtrace(stdout, catch_backtrace())

0 commit comments

Comments
 (0)