diff options
Diffstat (limited to 'src/port/ui/Properties.cpp')
| -rw-r--r-- | src/port/ui/Properties.cpp | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/src/port/ui/Properties.cpp b/src/port/ui/Properties.cpp index 0368231d9..86d32fd43 100644 --- a/src/port/ui/Properties.cpp +++ b/src/port/ui/Properties.cpp @@ -17,91 +17,89 @@ namespace Editor { - PropertiesWindow::~PropertiesWindow() { - SPDLOG_TRACE("destruct properties window"); +PropertiesWindow::~PropertiesWindow() { + SPDLOG_TRACE("destruct properties window"); +} + +void PropertiesWindow::DrawElement() { + GameObject* selected = gEditor.eObjectPicker.eGizmo._selected; + + if (nullptr == selected) { + return; } - void PropertiesWindow::DrawElement() { - GameObject* selected = gEditor.eObjectPicker.eGizmo._selected; + ImGui::Begin("Properties"); + + if (selected->Pos) { + ImGui::Text("Location"); + ImGui::SameLine(); + + bool positionChanged = ImGui::DragFloat3("##Location", &selected->Pos->x, 0.1f); - if (nullptr == selected) { - return; + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetPos")) { + selected->Pos->x = 0.0f; + selected->Pos->y = 0.0f; + selected->Pos->z = 0.0f; + positionChanged = true; // also counts as a change } - ImGui::Begin("Properties"); + if (positionChanged) { + gEditor.eObjectPicker.eGizmo.Pos = *selected->Pos; + } + } - if (selected->Pos) { - ImGui::Text("Location"); - ImGui::SameLine(); + if (selected->Rot) { + ImGui::Text("Rotation"); + ImGui::SameLine(); - bool positionChanged = ImGui::DragFloat3("##Location", &selected->Pos->x, 0.1f); + // Convert to temporary int values (to prevent writing 32bit values to 16bit variables) + int rot[3] = { selected->Rot->pitch, selected->Rot->yaw, selected->Rot->roll }; - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_UNDO "##ResetPos")) { - selected->Pos->x = 0.0f; - selected->Pos->y = 0.0f; - selected->Pos->z = 0.0f; - positionChanged = true; // also counts as a change + if (ImGui::DragInt3("##Rotation", rot, 5.0f)) { + for (int i = 0; i < 3; i++) { + // Wrap around 0–65535 + rot[i] = (rot[i] % 65536 + 65536) % 65536; } - if (positionChanged) { - gEditor.eObjectPicker.eGizmo.Pos = *selected->Pos; - } + selected->Rot->pitch = static_cast<uint16_t>(rot[0]); + selected->Rot->yaw = static_cast<uint16_t>(rot[1]); + selected->Rot->roll = static_cast<uint16_t>(rot[2]); } - if (selected->Rot) { - ImGui::Text("Rotation"); - ImGui::SameLine(); - - // Convert to temporary int values (to prevent writing 32bit values to 16bit variables) - int rot[3] = { - selected->Rot->pitch, - selected->Rot->yaw, - selected->Rot->roll - }; - - if (ImGui::DragInt3("##Rotation", rot, 5.0f)) { - for (int i = 0; i < 3; i++) { - // Wrap around 0–65535 - rot[i] = (rot[i] % 65536 + 65536) % 65536; - } - - selected->Rot->pitch = static_cast<uint16_t>(rot[0]); - selected->Rot->yaw = static_cast<uint16_t>(rot[1]); - selected->Rot->roll = static_cast<uint16_t>(rot[2]); - } - - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_UNDO "##ResetRot")) { - selected->Rot->pitch = 0; - selected->Rot->yaw = 0; - selected->Rot->roll = 0; - } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetRot")) { + selected->Rot->pitch = 0; + selected->Rot->yaw = 0; + selected->Rot->roll = 0; } + } - if (selected->Scale) { - ImGui::Text("Scale "); - ImGui::SameLine(); + if (selected->Scale) { + ImGui::Text("Scale "); + ImGui::SameLine(); - ImGui::DragFloat3("##Scale", &selected->Scale->x, 0.1f); - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_UNDO "##ResetScale")) { - selected->Scale->x = 1.0f; - selected->Scale->y = 1.0f; - selected->Scale->z = 1.0f; - } + ImGui::DragFloat3("##Scale", &selected->Scale->x, 0.1f); + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO "##ResetScale")) { + selected->Scale->x = 1.0f; + selected->Scale->y = 1.0f; + selected->Scale->z = 1.0f; } + } - if (selected->Collision == GameObject::CollisionType::BOUNDING_BOX) { - ImGui::Separator(); - ImGui::Text("Editor Bounding Box Size:"); - ImGui::PushID("BoundingBoxSize"); - ImGui::DragFloat("##BoundingBoxSize", &selected->BoundingBoxSize, 0.1f); - ImGui::SameLine(); - if (ImGui::Button(ICON_FA_UNDO)) { selected->BoundingBoxSize = 2.0f; } - ImGui::PopID(); + if (selected->Collision == GameObject::CollisionType::BOUNDING_BOX) { + ImGui::Separator(); + ImGui::Text("Editor Bounding Box Size:"); + ImGui::PushID("BoundingBoxSize"); + ImGui::DragFloat("##BoundingBoxSize", &selected->BoundingBoxSize, 0.1f); + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_UNDO)) { + selected->BoundingBoxSize = 2.0f; } - - ImGui::End(); + ImGui::PopID(); } -}
\ No newline at end of file + + ImGui::End(); +} +} // namespace Editor |
