diff --git a/SHADE_Engine/src/Animation/SHAnimationController.cpp b/SHADE_Engine/src/Animation/SHAnimationController.cpp index 3a1f581e..557bedb3 100644 --- a/SHADE_Engine/src/Animation/SHAnimationController.cpp +++ b/SHADE_Engine/src/Animation/SHAnimationController.cpp @@ -3,7 +3,7 @@ \author Tng Kah Wei, kahwei.tng, 390009620 \par email: kahwei.tng\@digipen.edu \date Feb 22, 2023 -\brief Contains the definition of SHAnimationController's functions. +\brief Contains the definition of SHAnimationController's functions. Copyright (C) 2023 DigiPen Institute of Technology. diff --git a/SHADE_Engine/src/Animation/SHAnimationController.h b/SHADE_Engine/src/Animation/SHAnimationController.h index 90162422..ca6fbf70 100644 --- a/SHADE_Engine/src/Animation/SHAnimationController.h +++ b/SHADE_Engine/src/Animation/SHAnimationController.h @@ -131,6 +131,7 @@ namespace SHADE /// struct Node { + std::string Name = "Unnamed Node"; Handle Clip; std::vector Transitions; }; diff --git a/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.cpp b/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.cpp new file mode 100644 index 00000000..c829c985 --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.cpp @@ -0,0 +1,107 @@ +/************************************************************************************//*! +\file SHAnimationControllerEditor.cpp +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Mar 1, 2023 +\brief Contains the definition of SHAnimationControllerEditor's functions. + + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#include "SHpch.h" +#include "SHAnimationControllerEditor.h" + +// STL Includes +#include +// External Dependencies +#include +#include +// Project Includes +#include "Editor/IconsMaterialDesign.h" +#include "Animation/SHAnimationController.h" +#include "../../SHEditorUI.h" + +namespace SHADE +{ + /*-----------------------------------------------------------------------------------*/ + /* Cosntructors/Destructors */ + /*-----------------------------------------------------------------------------------*/ + SHAnimationControllerEditor::SHAnimationControllerEditor() + : SHEditorWindow("Animation Controller Editor", ImGuiWindowFlags_MenuBar) + {} + + /*-----------------------------------------------------------------------------------*/ + /* Lifecycle Functions */ + /*-----------------------------------------------------------------------------------*/ + void SHAnimationControllerEditor::Init() + { + SHEditorWindow::Init(); + } + + void SHAnimationControllerEditor::Update() + { + SHEditorWindow::Update(); + + if (Begin()) + { + drawMenuBar(); + + ImNodes::BeginNodeEditor(); + { + /* Draw Nodes */ + int id = 0; + for (auto node : controller.GetNodes()) + { + ImNodes::BeginNode(id); + { + // Title + ImNodes::BeginNodeTitleBar(); + { + ImGui::TextUnformatted(node->Name.c_str()); + ImGui::SameLine(); + ImGui::Button(ICON_MD_EDIT); + } + ImNodes::EndNodeTitleBar(); + + // Body + ImGui::Text("Clip"); + ImGui::SameLine(); + std::array buffer = { '\0' }; + ImGui::PushItemWidth(80.0f); + ImGui::InputText("", buffer.data(), buffer.size()); + ImGui::PopItemWidth(); + } + ImNodes::EndNode(); + ++id; + } + } + + ImNodes::MiniMap(0.2f, ImNodesMiniMapLocation_BottomRight); + ImNodes::EndNodeEditor(); + } + ImGui::End(); + } + + void SHAnimationControllerEditor::Exit() + { + SHEditorWindow::Exit(); + } + + /*-----------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*-----------------------------------------------------------------------------------*/ + void SHAnimationControllerEditor::drawMenuBar() + { + if (ImGui::BeginMenuBar()) + { + if (ImGui::Button(std::format("{} Add", ICON_MD_ADD).data())) + { + controller.CreateNode(); + } + + ImGui::EndMenuBar(); + } + } +} \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.h b/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.h new file mode 100644 index 00000000..7ac7432e --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/Animation/SHAnimationControllerEditor.h @@ -0,0 +1,49 @@ +/************************************************************************************//*! +\file SHAnimationControllerEditor.h +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Mar 1, 2023 +\brief Contains the definition of SHAnimationControllerEditor. + +Copyright (C) 2023 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +// STL Includes +// Project Includes +#include "Resource/SHHandle.h" +#include "Editor/EditorWindow/SHEditorWindow.h" +#include "Animation/SHAnimationController.h" + +namespace SHADE +{ + class SHAnimationControllerEditor final : public SHEditorWindow + { + public: + /*---------------------------------------------------------------------------------*/ + /* Constructors/Destructors */ + /*---------------------------------------------------------------------------------*/ + SHAnimationControllerEditor(); + ~SHAnimationControllerEditor() = default; + + /*---------------------------------------------------------------------------------*/ + /* Lifecycle Functions */ + /*---------------------------------------------------------------------------------*/ + void Init() override; + void Update() override; + void Exit() override; + + private: + /*---------------------------------------------------------------------------------*/ + /* Data Members */ + /*---------------------------------------------------------------------------------*/ + SHAnimationController controller; + + /*---------------------------------------------------------------------------------*/ + /* Helper Functions */ + /*---------------------------------------------------------------------------------*/ + void drawMenuBar(); + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h b/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h index 290ed622..829a1871 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h +++ b/SHADE_Engine/src/Editor/EditorWindow/SHEditorWindowIncludes.h @@ -1,10 +1,11 @@ #pragma once -#include "MenuBar/SHEditorMenuBar.h" //Menu Bar -#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel -#include "Inspector/SHEditorInspector.h" //Inspector -#include "Profiling/SHEditorProfiler.h" //Profiler -#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport -#include "AssetBrowser/SHAssetBrowser.h" //Asset Browser -#include "MaterialInspector/SHMaterialInspector.h" //Material Inspector -#include "ColliderTagPanel/SHColliderTagPanel.h" //Collider Tag Panel -#include "InputBindings/SHInputBindingsPanel.h" //Input Bindings \ No newline at end of file +#include "MenuBar/SHEditorMenuBar.h" // Menu Bar +#include "HierarchyPanel/SHHierarchyPanel.h" // Hierarchy Panel +#include "Inspector/SHEditorInspector.h" // Inspector +#include "Profiling/SHEditorProfiler.h" // Profiler +#include "ViewportWindow/SHEditorViewport.h" // Editor Viewport +#include "AssetBrowser/SHAssetBrowser.h" // Asset Browser +#include "MaterialInspector/SHMaterialInspector.h" // Material Inspector +#include "ColliderTagPanel/SHColliderTagPanel.h" // Collider Tag Panel +#include "InputBindings/SHInputBindingsPanel.h" // Input Bindings +#include "EditorWindow/Animation/SHAnimationControllerEditor.h" // Animation Controller Editor \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 346bfbed..904a239b 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -39,6 +39,7 @@ //|| Library Includes || //#==============================================================# #include +#include #include #include #include @@ -96,6 +97,10 @@ namespace SHADE SHLOG_CRITICAL("Failed to create ImGui Context") } } + if (ImNodes::CreateContext() == nullptr) + { + SHLOG_CRITICAL("Failed to create ImNodes Context") + } #ifdef SHEDITOR editorConfig = &SHConfigurationManager::LoadEditorConfig(); @@ -112,6 +117,7 @@ namespace SHADE SHEditorWindowManager::CreateEditorWindow(); SHEditorWindowManager::CreateEditorWindow(); + SHEditorWindowManager::CreateEditorWindow(); //Add popup windows SHEditorWindowManager::CreatePopupWindow(); @@ -339,6 +345,7 @@ namespace SHADE { window->Init(); } + ImNodes::DestroyContext(); ImGui_ImplVulkan_Shutdown(); ImGui_ImplSDL2_Shutdown(); ImGui::DestroyContext(); diff --git a/SHADE_Engine/src/Editor/SHEditorUI.h b/SHADE_Engine/src/Editor/SHEditorUI.h index 23cc2d1a..94804bb9 100644 --- a/SHADE_Engine/src/Editor/SHEditorUI.h +++ b/SHADE_Engine/src/Editor/SHEditorUI.h @@ -90,7 +90,7 @@ namespace SHADE /// True if the header is open, false otherwise. static bool CollapsingHeader(const std::string& title, bool* isHovered = nullptr); static void SameLine(); - static void Separator(); + static void Separator(); /*-----------------------------------------------------------------------------*/ /* ImGui Wrapper Functions - Queries */ @@ -98,9 +98,9 @@ namespace SHADE static bool IsItemHovered(); /*-----------------------------------------------------------------------------*/ - /* ImGui Wrapper Functions - Menu */ - /*-----------------------------------------------------------------------------*/ - static bool BeginMenu(const std::string& label); + /* ImGui Wrapper Functions - Menu */ + /*-----------------------------------------------------------------------------*/ + static bool BeginMenu(const std::string& label); static bool BeginMenu(const std::string& label, const char* icon); static void EndMenu(); static void BeginTooltip(); @@ -164,8 +164,8 @@ namespace SHADE /// /// Text to display. /// True if button was pressed. - static bool Button(const std::string& title); - static bool Selectable(const std::string& label); + static bool Button(const std::string& title); + static bool Selectable(const std::string& label); static bool Selectable(const std::string& label, const char* icon); /// /// Creates a checkbox widget for boolean input.