Skip to content

Commit 9eb1e2e

Browse files
committed
updates
1 parent c71b4c1 commit 9eb1e2e

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/SceneManagement/SceneReader.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ module SceneReaderModule
8686
if haskey(childParentDict, string(entity.id))
8787
parentId = childParentDict[string(entity.id)]
8888
for e in entities
89-
println("Checking if $(e.id) == $parentId")
9089
if string(e.id) == string(parentId)
91-
println("setting parent of $(entity.name) to $(e.name)")
9290
entity.parent = e
9391
end
9492
end

src/editor/JulGameEditor/Editor.jl

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,23 +223,8 @@ module Editor
223223
end
224224
end
225225

226-
# our entities are both drag sources and drag targets here!
227-
if CImGui.BeginDragDropSource(CImGui.ImGuiDragDropFlags_None)
228-
@c CImGui.SetDragDropPayload("Entity", &n, sizeof(Cint)) # set payload to carry the index of our item (could be anything)
229-
CImGui.Text("Move $(filteredEntities[n].name)")
230-
CImGui.EndDragDropSource()
231-
end
232-
if CImGui.BeginDragDropTarget()
233-
payload = CImGui.AcceptDragDropPayload("Entity")
234-
if payload != C_NULL
235-
payload = unsafe_load(payload)
236-
origin = unsafe_load(Ptr{Cint}(payload.Data))
237-
destination = n
238-
filteredEntities[origin].parent = filteredEntities[destination]
239-
@assert payload.DataSize == sizeof(Cint)
240-
end
241-
CImGui.EndDragDropTarget()
242-
end
226+
handle_drag_and_drop(filteredEntities, n)
227+
243228

244229
# Reorder entities: We can only reorder entities if the entiities are not being filtered
245230
if length(filteredEntities) == length(currentSceneMain.scene.entities)
@@ -611,6 +596,7 @@ module Editor
611596
# We only need to do this in the case where the origin index is less than the destination index, because the other way around, the destination index is already "adjusted" because the items before it are not shifted
612597
destination -= 1
613598
end
599+
originEntity.parent = C_NULL
614600
updatedEntities = [entities[destination], originEntity]
615601

616602
splice!(entities, destination : destination, updatedEntities)
@@ -627,4 +613,24 @@ module Editor
627613
@warn "Error in renderloop!" exception=e
628614
end
629615
end
616+
617+
function handle_drag_and_drop(filteredEntities, n)
618+
# our entities are both drag sources and drag targets here!
619+
if CImGui.BeginDragDropSource(CImGui.ImGuiDragDropFlags_None)
620+
@c CImGui.SetDragDropPayload("Entity", &n, sizeof(Cint)) # set payload to carry the index of our item (could be anything)
621+
CImGui.Text("Move $(filteredEntities[n].name)")
622+
CImGui.EndDragDropSource()
623+
end
624+
if CImGui.BeginDragDropTarget()
625+
payload = CImGui.AcceptDragDropPayload("Entity")
626+
if payload != C_NULL
627+
payload = unsafe_load(payload)
628+
origin = unsafe_load(Ptr{Cint}(payload.Data))
629+
destination = n
630+
filteredEntities[origin].parent = filteredEntities[destination]
631+
@assert payload.DataSize == sizeof(Cint)
632+
end
633+
CImGui.EndDragDropTarget()
634+
end
635+
end
630636
end

0 commit comments

Comments
 (0)