diff options
author | hnOsmium0001 <[email protected]> | 2022-04-09 13:29:41 -0700 |
---|---|---|
committer | hnOsmium0001 <[email protected]> | 2022-04-09 13:29:41 -0700 |
commit | 906557f094e407ce21d429ef647bc75fe3179cf1 (patch) | |
tree | 5e6aaed6537a0328318b6cd6561f6a76bf8aa27d /source/EditorCore.cpp | |
parent | e47a98793e58a5dbbe76bfed27e59408e43538e4 (diff) |
More work on editor
Diffstat (limited to 'source/EditorCore.cpp')
-rw-r--r-- | source/EditorCore.cpp | 79 |
1 files changed, 28 insertions, 51 deletions
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 <GLFW/glfw3.h> #include <ImGuizmo.h> -#include <backends/imgui_impl_glfw.h> -#include <imgui.h> #include <functional> #include <memory> #include <utility> @@ -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> 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<EditorGameObjectAttachment>(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<Player*>(mSelectedGameObject); + auto player = static_cast<Player*>(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<LevelWrapperObject*>(mSelectedGameObject); + auto lwo = static_cast<LevelWrapperObject*>(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(); -} |