diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-11 11:13:15 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2024-01-11 11:13:15 -0500 |
| commit | cce568a7f56861d6249d7445f51d0ed27c560a5c (patch) | |
| tree | dc16d597f2b5ba37935993add262bff28dc2ca44 /editor | |
| parent | f07294ca65143fac8b1b426d1854212403721226 (diff) | |
checkpoint - mostly working condition after changes
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/editor.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/editor/editor.cpp b/editor/editor.cpp index 2f7e804..33f1c49 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -179,9 +179,6 @@ void PkeEditor_Tick(double delta) { if (selectedEntity && EntitiesToBeRemoved.Has(ECS_GetEntity(selectedEntity->entHandle))) { selectedEntity = nullptr; } - if (hoveredEntity && EntitiesToBeRemoved.Has(ECS_GetEntity(hoveredEntity->entHandle))) { - hoveredEntity = nullptr; - } bool imGuiHovered = ImGui::GetIO().WantCaptureMouse; @@ -218,7 +215,7 @@ void PkeEditor_Tick(double delta) { BtDynamicsWorld->rayTest(rayOrigin, rayDestination, rayResult); if (rayResult.hasHit()) { - hoveredEntity = reinterpret_cast<CompInstance *>(rayResult.m_collisionObject->getUserPointer());; + hoveredEntity = reinterpret_cast<CompInstance *>(rayResult.m_collisionObject->getUserPointer()); } } @@ -281,7 +278,7 @@ void PkeEditor_Tick(double delta) { if (et->createInstanceCallback.func) { reinterpret_cast<void(*)()>(et->createInstanceCallback.func)(); } else { - EntityType_CreateGenericInstance(et, nullptr); + EntityType_CreateGenericInstance(et, nullptr, nullptr); } } @@ -814,13 +811,17 @@ void RecordImGuiModalCreateEntityType() { memcpy(createInstanceSig, PkePlugin_GetSortedSignatures(x)[index], CallbackSignatureLength); } - ImGui::BeginDisabled(); ImGui::InputScalar("Sub-Types", ImGuiDataType_S64, &entityTypeToCreate.detailsCount); ImGui::SameLine(); - if (ImGui::Button("-")) entityTypeToCreate.detailsCount -= 1; + if (ImGui::Button("-")) { + entityTypeToCreate.detailsCount -= 1; + } + entityTypeToCreate.detailsCount = entityTypeToCreate.detailsCount < 1 ? 1 : entityTypeToCreate.detailsCount; ImGui::SameLine(); - if (ImGui::Button("+")) entityTypeToCreate.detailsCount += 1; - ImGui::EndDisabled(); + if (ImGui::Button("+")) { + entityTypeToCreate.detailsCount += 1; + entityTypeToCreate.detailsCount = entityTypeToCreate.detailsCount > EntityTypeDetails_MAX ? EntityTypeDetails_MAX : entityTypeToCreate.detailsCount; + } for (int64_t i = 0; i < entityTypeToCreate.detailsCount; ++i) { auto &etd = entityTypeToCreate.details[i]; @@ -1172,11 +1173,6 @@ void RecordImGuiSceneEditor() { ImGui::Spacing(); if (selectedEntity != nullptr) { - Entity_Base *entity = ECS_GetEntity(selectedEntity->entHandle); - auto *entityType = static_cast<EntityType *>(entity); - if (ImGui::Button("Create Instance")) { - entityInstancesToCreate.Push(entityType); - } static PkeArray<CompGrBinds *> entGrBinds; static PkeArray<CompInstance *> entInstances; bool reset = false; @@ -1193,8 +1189,17 @@ void RecordImGuiSceneEditor() { PkeArray_SoftReset(&entGrBinds); PkeArray_SoftReset(&entInstances); } - ECS_GetGrBinds(ECS_GetEntity(selectedEntity->entHandle), entGrBinds); - ECS_GetInstances(ECS_GetEntity(selectedEntity->entHandle), entInstances); + if (entGrBinds.next == 0) + ECS_GetGrBinds(ECS_GetEntity(selectedEntity->entHandle), entGrBinds); + if (entInstances.next == 0) + ECS_GetInstances(ECS_GetEntity(selectedEntity->entHandle), entInstances); + if (entGrBinds.next > 0) { + if (ImGui::Button("Create Instance")) { + Entity_Base *entity = ECS_GetEntity(selectedEntity->entHandle); + auto *entityType = static_cast<EntityType *>(entity); + entityInstancesToCreate.Push(entityType); + } + } for (int64_t i = 0; i < entGrBinds.next; ++i) { RecordImGui_CompGrBinds(true, entGrBinds.data[i]); } |
