|
|
|
@ -82,10 +82,37 @@ namespace lunarium { namespace editor
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Drop onto panel itself?
|
|
|
|
|
|
|
|
// TODO: Nope this does not work for dropping onto the panel
|
|
|
|
|
|
|
|
// if (ImGui::BeginDragDropTarget())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("Entity"))
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Entity *pDroppedEnt = *((Entity **)payload->Data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (pDroppedEnt->HasParent())
|
|
|
|
|
|
|
|
// mpWorld->GetEntity(pDroppedEnt->GetParent())->RemoveChild(pDroppedEnt->GetUUID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ImGui::EndDragDropTarget();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::SetNextItemOpen(true);
|
|
|
|
ImGui::SetNextItemOpen(true);
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::TreeNode("World Root"))
|
|
|
|
if (ImGui::TreeNode("World Root"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("Entity"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Entity *pDroppedEnt = *((Entity **)payload->Data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pDroppedEnt->HasParent())
|
|
|
|
|
|
|
|
mpWorld->GetEntity(pDroppedEnt->GetParent())->RemoveChild(pDroppedEnt->GetUUID());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// List all world entities
|
|
|
|
// List all world entities
|
|
|
|
int idx = 0;
|
|
|
|
int idx = 0;
|
|
|
|
for (auto iter = mpWorld->EntitiesBegin(); !mpWorld->EntitiesIsEnd(iter); iter++, idx++)
|
|
|
|
for (auto iter = mpWorld->EntitiesBegin(); !mpWorld->EntitiesIsEnd(iter); iter++, idx++)
|
|
|
|
@ -113,18 +140,19 @@ namespace lunarium { namespace editor
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool was_clicked = false;
|
|
|
|
bool was_clicked = false;
|
|
|
|
bool was_right_clicked = false;
|
|
|
|
bool was_right_clicked = false;
|
|
|
|
if (ImGui::TreeNode(pEnt->GetName().c_str()))
|
|
|
|
|
|
|
|
{
|
|
|
|
bool node_open = ImGui::TreeNode(pEnt->GetName().c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handle drag and drop even if the node is closed
|
|
|
|
if (ImGui::BeginDragDropSource())
|
|
|
|
if (ImGui::BeginDragDropSource())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Need to pass a pointer to the payload data. This means we need to pass a
|
|
|
|
// Need to pass a pointer to the payload data. This means we need to pass a
|
|
|
|
// pointer to the Entity pointer (Entity**) which &(*pEnt) becomes
|
|
|
|
// pointer to the Entity pointer (Entity**) which &pEnt becomes
|
|
|
|
ImGui::SetDragDropPayload("Entity", (void *)&(*pEnt), sizeof(Entity *));
|
|
|
|
ImGui::SetDragDropPayload("Entity", (void *)&pEnt, sizeof(Entity *));
|
|
|
|
ImGui::Text("%s", pEnt->GetName().c_str());
|
|
|
|
ImGui::Text("%s", pEnt->GetName().c_str());
|
|
|
|
ImGui::EndDragDropSource();
|
|
|
|
ImGui::EndDragDropSource();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("Entity"))
|
|
|
|
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload("Entity"))
|
|
|
|
@ -135,15 +163,29 @@ namespace lunarium { namespace editor
|
|
|
|
if (pDroppedEnt != pEnt)
|
|
|
|
if (pDroppedEnt != pEnt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If the dropped ent is the parent of pEnt then we need to swap the relationship
|
|
|
|
// If the dropped ent is the parent of pEnt then we need to swap the relationship
|
|
|
|
|
|
|
|
if (pEnt->HasParent() && pEnt->GetParent() == pDroppedEnt->GetUUID())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// TODO: Finish Entity Drop Logic
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If the dropped ent is already a child of pEnt then we do nothing
|
|
|
|
// If the dropped ent is already a child of pEnt then we do nothing
|
|
|
|
|
|
|
|
|
|
|
|
// Else add dropped ent as a child of pEnt
|
|
|
|
// Else add dropped ent as a child of pEnt
|
|
|
|
|
|
|
|
else if (!pDroppedEnt->HasParent() || (pDroppedEnt->GetParent() != pEnt->GetUUID()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pDroppedEnt->HasParent())
|
|
|
|
|
|
|
|
mpWorld->GetEntity(pDroppedEnt->GetParent())->RemoveChild(pDroppedEnt->GetUUID());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pEnt->AddChild(pDroppedEnt->GetUUID());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now handle the node if it's open
|
|
|
|
|
|
|
|
if (node_open)
|
|
|
|
|
|
|
|
{
|
|
|
|
was_clicked = ImGui::IsItemClicked(ImGuiMouseButton_Left);
|
|
|
|
was_clicked = ImGui::IsItemClicked(ImGuiMouseButton_Left);
|
|
|
|
was_right_clicked = ImGui::IsItemClicked(ImGuiMouseButton_Right);
|
|
|
|
was_right_clicked = ImGui::IsItemClicked(ImGuiMouseButton_Right);
|
|
|
|
|
|
|
|
|
|
|
|
|