From a849c199d970e153580c312a24cfdfa099bc7b69 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 9 Apr 2022 13:29:41 -0700 Subject: Changeset: 4 More work on editor --- source/EditorCore.cpp | 79 ++++++++++++++++++--------------------------------- 1 file changed, 28 insertions(+), 51 deletions(-) (limited to 'source/EditorCore.cpp') diff --git a/source/EditorCore.cpp b/source/EditorCore.cpp index 3bf9ecb..7744793 100644 --- a/source/EditorCore.cpp +++ b/source/EditorCore.cpp @@ -1,12 +1,12 @@ #include "EditorCore.hpp" -#include "EditorCoreAPI.hpp" #include "App.hpp" #include "AppConfig.hpp" #include "CpuMesh.hpp" #include "EditorAccessories.hpp" -#include "EditorCore_Egoa.hpp" +#include "EditorAttachmentImpl.hpp" #include "EditorNotification.hpp" +#include "EditorUtils.hpp" #include "GameObjectTypeTag.hpp" #include "Level.hpp" #include "Mesh.hpp" @@ -16,8 +16,6 @@ #include #include -#include -#include #include #include #include @@ -40,23 +38,13 @@ void PushKeyCodeRecorder(App* app, int* writeKey, bool* writeKeyStatus) { } } // namespace ProjectBrussel_UNITY_ID -const char* ImGui::GetKeyNameGlfw(int key) { - return GetKeyName(ImGui_ImplGlfw_KeyToImGuiKey(key)); -} - -std::unique_ptr EditorGameObjectAttachment::Create(GameObject* object) { - EditorGameObjectAttachment* result; - - using namespace Tags; - switch (object->GetTypeTag()) { - case GOT_Player: result = new EgoaPlayer(); break; - case GOT_LevelWrapper: result = new EgoaLevelWrapper(); break; - - default: result = new EditorGameObjectAttachment(); break; - } +EditorInstance::EditorInstance(App* app, GameWorld* world) + : mApp{ app } + , mWorld{ world } + , mEdInspector() + , mEdContentBrowser(&mEdInspector) {} - result->name = NameOf(object->GetTypeTag()); - return std::unique_ptr(result); +EditorInstance::~EditorInstance() { } void EditorInstance::Show() { @@ -71,26 +59,26 @@ void EditorInstance::Show() { ImGui::End(); ImGui::Begin("Inspector"); - ShowInspector(); + if (mSelectedGameObject) { + ShowInspector(mSelectedGameObject); + } ImGui::End(); } void EditorInstance::ShowWorldProperties() { } -void EditorInstance::ShowInspector() { +void EditorInstance::ShowInspector(GameObject* object) { using namespace Tags; using namespace ProjectBrussel_UNITY_ID; - if (!mSelectedGameObject) return; - - auto type = mSelectedGameObject->GetTypeTag(); + auto type = object->GetTypeTag(); switch (type) { case Tags::GOT_Player: { - ShowGameObjecetFields(mSelectedGameObject); + ShowGameObjecetFields(object); ImGui::Separator(); - auto player = static_cast(mSelectedGameObject); + auto player = static_cast(object); auto& kb = player->keybinds; ImGui::Text("Player #%d", player->GetId()); @@ -135,26 +123,35 @@ void EditorInstance::ShowInspector() { } break; case Tags::GOT_LevelWrapper: { - ShowGameObjecetFields(mSelectedGameObject); + ShowGameObjecetFields(object); ImGui::Separator(); - auto lwo = static_cast(mSelectedGameObject); + auto lwo = static_cast(object); // TODO } break; default: - ShowGameObjecetFields(mSelectedGameObject); + ShowGameObjecetFields(object); break; } } void EditorInstance::ShowGameObjecetFields(GameObject* object) { + auto pos = object->GetPos(); + if (ImGui::InputFloat3("Position", &pos.x)) { + object->SetPos(pos); + } + + auto quat = object->GetRotation(); + if (ImGui::InputFloat4("Rotation", &quat.x)) { + object->SetRotation(quat); + } } void EditorInstance::ShowGameObjectInTree(GameObject* object) { auto attachment = object->GetEditorAttachment(); if (!attachment) { - attachment = EditorGameObjectAttachment::Create(object).release(); + attachment = EaGameObject::Create(object).release(); object->SetEditorAttachment(attachment); // NOTE: takes ownership } @@ -178,23 +175,3 @@ void EditorInstance::ShowGameObjectInTree(GameObject* object) { ImGui::TreePop(); } } - -// ======================== // -// EditorCoreAPI.hpp things // -// ======================== // - -void EditorGameObjectAttachmentDeleter::operator()(EditorGameObjectAttachment* obj) { - delete obj; -} - -EditorInstance* EditorInstance_Alloc(App* app, GameWorld* world) { - return new EditorInstance(app, world); -} - -void EditorInstance_Free(EditorInstance* editor) { - delete editor; -} - -void EditorInstance_Show(EditorInstance* editor) { - editor->Show(); -} -- cgit v1.2.3-70-g09d2