Skip to content

Commit

Permalink
refs #37: moving stuff in a desperate attempt to make this working in…
Browse files Browse the repository at this point in the history
… a predictable way.
  • Loading branch information
stickgrinder committed Oct 22, 2023
1 parent 4e97d13 commit 2f3942c
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ func _on_import_pressed():
# In case the prop is there, use the one we already have
prop = props_container.get_node_or_null(prop_name)
if prop == null:
# TODO: Add "prop visibility" parameter to the create method in the factory
# currently all props are created visible.
prop = await _create_prop(prop_name, tag.prop_clickable, tag.prop_visible)

# Wait for the filesystem to update
await get_tree().create_timer(0.1).timeout
await get_tree().create_timer(0.3).timeout

# TODO: check if animation player exists in prop, if not add it
# same for Sprite2D even if it should be there...
Expand All @@ -53,11 +51,12 @@ func _on_import_pressed():

# Save the prop
result = _save_prop(prop)

# TODO: maybe check if this is better done with signals
_importing = false

# Save the room scene
# Save the room scene to hopefully solve a strange behavior
# NOTE: didn't work
#main_dock.ei.save_scene()

if typeof(result) == TYPE_INT and result != RESULT_CODE.SUCCESS:
Expand All @@ -74,16 +73,14 @@ func _customize_tag_ui(tag_row: AnimationTagRow):

func _create_prop(name: String, clickable: bool = true, visible: bool = true):
var factory = PopochiuPropFactory.new(main_dock)

# TODO: Add "prop visibility" parameter to the create method in the factory
# currently all props are created visible.
if factory.create(name, _root_node, clickable) != ResultCodes.SUCCESS:
return

return factory.get_obj_scene()

func _save_prop(prop: PopochiuProp):
var new_prop := prop.duplicate()
for c in new_prop.get_children():
c.owner = new_prop
var packed_scene: PackedScene = PackedScene.new()
packed_scene.pack(prop)
if ResourceSaver.save(packed_scene, prop.scene_file_path) != OK:
Expand Down

0 comments on commit 2f3942c

Please sign in to comment.