diff --git a/.gitignore b/.gitignore index 5d998cfd..06ae45fd 100644 --- a/.gitignore +++ b/.gitignore @@ -364,3 +364,7 @@ MigrationBackup/ *.filters Assets/Editor/Layouts/UserLayout.ini + +JSON/Schemas/Catalog/ + +Assets/Editor/Editor.SHConfig diff --git a/Assets/Application.SHConfig b/Assets/Application.SHConfig index 370665d2..ee5e42a8 100644 --- a/Assets/Application.SHConfig +++ b/Assets/Application.SHConfig @@ -1,4 +1,4 @@ Start in Fullscreen: false -Starting Scene ID: 86098106 +Starting Scene ID: 87244611 Window Size: {x: 1920, y: 1080} Window Title: SHADE Engine \ No newline at end of file diff --git a/Assets/Bindings.SHConfig b/Assets/Bindings.SHConfig new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/Assets/Bindings.SHConfig @@ -0,0 +1 @@ +0 diff --git a/Assets/Editor/Editor.SHConfig b/Assets/Editor/Editor.SHConfig new file mode 100644 index 00000000..51425027 --- /dev/null +++ b/Assets/Editor/Editor.SHConfig @@ -0,0 +1,4 @@ +Start Maximized: true +Working Scene ID: 97161771 +Window Size: {x: 1920, y: 1080} +Style: 0 \ No newline at end of file diff --git a/Assets/Scenes/UI_Test.shade b/Assets/Scenes/UI_Test.shade index e8ee4df2..0026a48b 100644 --- a/Assets/Scenes/UI_Test.shade +++ b/Assets/Scenes/UI_Test.shade @@ -1,7 +1,7 @@ - EID: 0 Name: Canvas IsActive: true - NumberOfChildren: 1 + NumberOfChildren: 2 Components: Canvas Component: Canvas Width: 10 @@ -28,6 +28,26 @@ Clicked Texture: 0 IsActive: true Scripts: ~ +- EID: 5 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Transform Component: + Translate: {x: 0, y: -3.9000001, z: 0} + Rotate: {x: 0, y: 0, z: 0} + Scale: {x: 1, y: 1, z: 1} + IsActive: true + Renderable Component: + Mesh: 141771688 + Material: 129340704 + IsActive: true + Toggle Button Component: + Non Toggled Texture: 0 + Toggled Texture: 0 + Value: true + IsActive: true + Scripts: ~ - EID: 1 Name: Camera IsActive: true diff --git a/Assets/Scenes/UI_Test.shade.shmeta b/Assets/Scenes/UI_Test.shade.shmeta index 8b8d6f22..77355480 100644 --- a/Assets/Scenes/UI_Test.shade.shmeta +++ b/Assets/Scenes/UI_Test.shade.shmeta @@ -1,3 +1,3 @@ Name: UI_Test -ID: 87707373 +ID: 87244611 Type: 5 diff --git a/Dependencies.bat b/Dependencies.bat index ba411815..460a1d87 100644 --- a/Dependencies.bat +++ b/Dependencies.bat @@ -20,10 +20,11 @@ echo "M - SDL" echo "N - dotnet" echo "O - tinyddsloader" echo "P - fmod" +echo "Q - vswhere" echo --------------------------------------------------- echo. -choice /C ABCDEFGHIJKLMNOP /T 10 /D A +choice /C ABCDEFGHIJKLMNOPQ /T 10 /D A set _e=%ERRORLEVEL% if %_e%==1 goto VMA @@ -42,6 +43,7 @@ if %_e%==13 goto SDL if %_e%==14 goto dotnet if %_e%==15 goto tinyddsloader if %_e%==16 goto fmod +if %_e%==17 goto vswhere :VMA echo -----------------------VMA---------------------------- @@ -155,6 +157,13 @@ if %_e%==15 (goto :done) else (goto :fmod) echo --------------------fmod------------------------- rmdir "Dependencies/fmod" /S /Q git clone https://github.com/SHADE-DP/FMOD.git "Dependencies/fmod" +if %_e%==16 (goto :done) else (goto :vswhere) + +:vswhere +echo -----------------------vswhere---------------------------- +rmdir "Dependencies/vswhere" /S /Q +mkdir "Dependencies/vswhere" +powershell -Command "& {wget https://github.com/microsoft/vswhere/releases/download/3.1.1/vswhere.exe -OutFile "Dependencies/vswhere/vswhere.exe"}" :done echo DONE! diff --git a/Dependencies.lua b/Dependencies.lua index fe75c3f4..2694fe35 100644 --- a/Dependencies.lua +++ b/Dependencies.lua @@ -16,4 +16,5 @@ IncludeDir["SDL"] = "%{wks.location}\\Dependencies\\SDL" IncludeDir["VULKAN"] = "$(VULKAN_SDK)" IncludeDir["dotnet"] = "%{wks.location}\\Dependencies\\dotnet" IncludeDir["tinyddsloader"] = "%{wks.location}\\Dependencies\\tinyddsloader" -IncludeDir["fmod"] = "%{wks.location}\\Dependencies\\fmod" \ No newline at end of file +IncludeDir["fmod"] = "%{wks.location}\\Dependencies\\fmod" +IncludeDir["vswhere"] = "%{wks.location}\\Dependencies\\vswhere" \ No newline at end of file diff --git a/SHADE_Application/src/Application/SBApplication.cpp b/SHADE_Application/src/Application/SBApplication.cpp index 5aa1eb00..fcceacab 100644 --- a/SHADE_Application/src/Application/SBApplication.cpp +++ b/SHADE_Application/src/Application/SBApplication.cpp @@ -67,6 +67,9 @@ namespace Sandbox SHFileUtilities::SetWorkDirToExecDir(); WindowData wndData{}; auto& appConfig = SHConfigurationManager::LoadApplicationConfig(&wndData); +#if SHEDITOR + auto& editorConfig = SHConfigurationManager::LoadEditorConfig(&wndData); +#endif window.Create(hInstance, hPrevInstance, lpCmdLine, nCmdShow, wndData); // Create Systems @@ -158,8 +161,11 @@ namespace Sandbox SHSystemManager::Init(); +#if SHEDITOR + SHSceneManager::InitSceneManager(editorConfig.workingSceneID); +#else SHSceneManager::InitSceneManager(appConfig.startingSceneID); - +#endif SHFrameRateController::UpdateFRC(); // Link up SHDebugDraw diff --git a/SHADE_Engine/premake5.lua b/SHADE_Engine/premake5.lua index 7fb7291d..17ca5be8 100644 --- a/SHADE_Engine/premake5.lua +++ b/SHADE_Engine/premake5.lua @@ -124,7 +124,8 @@ project "SHADE_Engine" "xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Debug\\ModelCompiler.exe\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Debug\\FontCompiler.exe\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodL.dll\" \"$(OutDir)\"", - "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\"" + "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudioL.dll\" \"$(OutDir)\"", + "xcopy /r /y /q \"%{IncludeDir.vswhere}\\vswhere.exe\" \"$(OutDir)\"" } filter "configurations:Release" @@ -134,7 +135,8 @@ project "SHADE_Engine" "xcopy /r /y /q \"%{IncludeDir.ModelCompiler}\\bin\\Release\\ModelCompiler.exe\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.FontCompiler}\\bin\\Release\\FontCompiler.exe\" \"$(OutDir)\"", "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmod.dll\" \"$(OutDir)\"", - "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\"" + "xcopy /r /y /q \"%{IncludeDir.fmod}\\lib\\fmodstudio.dll\" \"$(OutDir)\"", + "xcopy /r /y /q \"%{IncludeDir.vswhere}\\vswhere.exe\" \"$(OutDir)\"" } filter "configurations:Publish" diff --git a/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h index 8921fbce..9fcbf6f8 100644 --- a/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h +++ b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h @@ -23,7 +23,7 @@ #include "SH_API.h" #include "Events/SHEventManager.hpp" - +#include #include namespace SHADE @@ -151,6 +151,32 @@ namespace SHADE return (componentSet.GetSparseSet()->GetElement_s(EntityHandleGenerator::GetIndex(entityID))); } + /*!************************************************************************* + * \brief + * Gets the Component of the entity with the specified entityID + * + * This is the safe version of GetComponent_s which does a HasComponent to make + * sure that the entity has such a component and returns nullptr if it doesn't + * + * This safe version also checks if the sparse set of this component type + * has been created in SHComponentManager and creates one if it doesn't + * + * @tparam T... + * Pack of Types for all the Components to get. + * \param entityID + * EntityID of the entity that we are trying to get the component of. + * \return + * A tuple of pointers to all the components specified. + * Returns nullptr if the entity does not contain such a component. + ***************************************************************************/ + + template + static std::enable_if_t<(... && std::is_base_of_v), std::tuple> GetComponents(EntityID entityID) noexcept + { + return std::make_tuple(GetComponent_s(entityID)...); + } + + /*!************************************************************************* * \brief * Gets the Component of the entity with the specified entityID diff --git a/SHADE_Engine/src/Editor/Command/SHCommandManager.cpp b/SHADE_Engine/src/Editor/Command/SHCommandManager.cpp index b86f9247..fec30142 100644 --- a/SHADE_Engine/src/Editor/Command/SHCommandManager.cpp +++ b/SHADE_Engine/src/Editor/Command/SHCommandManager.cpp @@ -18,11 +18,17 @@ namespace SHADE SHCommandManager::CommandStackPtr SHCommandManager::pCurrUndoStack(&undoStack); SHCommandManager::CommandStackPtr SHCommandManager::pCurrRedoStack(&redoStack); + bool SHCommandManager::failedExecution(false); void SHCommandManager::PerformCommand(BaseCommandPtr commandPtr, bool const& overrideValue) { - *pCurrRedoStack = CommandStack(defaultStackSize); commandPtr->Execute(); + if(failedExecution) + { + failedExecution = false; + return; + } + *pCurrRedoStack = CommandStack(defaultStackSize); if (overrideValue && !pCurrUndoStack->Empty()) { pCurrUndoStack->Top()->Merge(commandPtr); @@ -68,12 +74,14 @@ namespace SHADE void SHCommandManager::PopLatestCommandFromRedoStack() { - pCurrRedoStack->Pop(); + if(!pCurrRedoStack->Empty()) + pCurrRedoStack->Pop(); } void SHCommandManager::PopLatestCommandFromUndoStack() { - pCurrUndoStack->Pop(); + if(!pCurrUndoStack->Empty()) + pCurrUndoStack->Pop(); } void SHCommandManager::SwapStacks() diff --git a/SHADE_Engine/src/Editor/Command/SHCommandManager.h b/SHADE_Engine/src/Editor/Command/SHCommandManager.h index 178347b5..f3574030 100644 --- a/SHADE_Engine/src/Editor/Command/SHCommandManager.h +++ b/SHADE_Engine/src/Editor/Command/SHCommandManager.h @@ -38,7 +38,8 @@ namespace SHADE static void SwapStacks(); static void ClearAll(); - + + static bool failedExecution; static constexpr CommandStack::SizeType defaultStackSize = 100; private: static CommandStackPtr pCurrUndoStack; diff --git a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp index 66b3c962..bd39b38e 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/AssetBrowser/SHAssetBrowser.cpp @@ -14,6 +14,8 @@ #include "Editor/DragDrop/SHDragDrop.hpp" #include "Editor/EditorWindow/MaterialInspector/SHMaterialInspector.h" #include "Editor/EditorWindow/SHEditorWindowManager.h" +#include "Scripting/SHVSUtilities.h" +#include "Scripting/SHScriptEngine.h" namespace SHADE { @@ -249,6 +251,12 @@ namespace SHADE matInspector->OpenMaterial(asset->id); } break; + case AssetType::SCRIPT: + if(auto scriptEngine = SHSystemManager::GetSystem()) + { + scriptEngine->OpenFile(asset->path); + } + break; case AssetType::MAX_COUNT: break; default:; } diff --git a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp index 2235f831..6ac5933c 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/HierarchyPanel/SHHierarchyPanel.cpp @@ -84,34 +84,32 @@ namespace SHADE editor->selectedEntities.clear(); } ImGui::SeparatorEx(ImGuiSeparatorFlags_Horizontal); - if (ImGui::IsWindowFocused()) + + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A)) { - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_A)) + SelectAllEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C)) + { + CopySelectedEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) + { + PasteEntities(); + } + if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) + { + const auto editor = SHSystemManager::GetSystem(); + if (editor->selectedEntities.size() == 1) { - SelectAllEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyReleased(ImGuiKey_C)) - { - CopySelectedEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && !ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) - { - PasteEntities(); - } - if (ImGui::IsKeyDown(ImGuiKey_LeftCtrl) && ImGui::IsKeyDown(ImGuiKey_LeftShift) && ImGui::IsKeyReleased(ImGuiKey_V)) - { - const auto editor = SHSystemManager::GetSystem(); - if (editor->selectedEntities.size() == 1) - { - PasteEntities(editor->selectedEntities.back()); - } - } - if(ImGui::IsKeyReleased(ImGuiKey_Delete)) - { - DeleteSelectedEntities(); + PasteEntities(editor->selectedEntities.back()); } } - + if (ImGui::IsKeyReleased(ImGuiKey_Delete)) + { + DeleteSelectedEntities(); + } + } if(ImGui::IsWindowHovered() && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) { diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp index e4ec8d58..45964930 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorComponentView.hpp @@ -19,6 +19,9 @@ #include "Reflection/SHReflectionMetadata.h" #include "Resource/SHResourceManager.h" #include "Physics/Collision/SHCollisionTagMatrix.h" +#include "Serialization/SHSerializationHelper.hpp" +#include "Tools/Utilities/SHClipboardUtilities.h" +#include "SHInspectorCommands.h" namespace SHADE { template @@ -46,11 +49,12 @@ namespace SHADE if (ImGui::Selectable(std::format("{} Copy {}", ICON_MD_CONTENT_COPY, componentName.data()).data())) { - //SHClipboardUtil::WriteStringToClipboard(SHClipboardUtil::CFNAME::CFCOMPONENT, SHComponentToString(component)); + SHClipboardUtilities::WriteToClipboard(SHSerializationHelper::SerializeComponentToString(component->GetEID())); } if (ImGui::Selectable(std::format("{} Paste {}", ICON_MD_CONTENT_PASTE, componentName.data()).data())) { - //SHStringToComponent(component, SHClipboardUtil::ReadStringFromClipboard(SHClipboardUtil::CFNAME::CFCOMPONENT)); + //SHSerializationHelper::DeserializeComponentFromString(SHClipboardUtilities::GetDataFromClipboard(), component->GetEID()); + SHCommandManager::PerformCommand(std::reinterpret_pointer_cast( std::make_shared>(component->GetEID(), SHClipboardUtilities::GetDataFromClipboard()))); } if (ImGui::Selectable(std::format("{} Delete {}", ICON_MD_DELETE, componentName.data()).data())) { diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp index 83647da7..ed6ea6bb 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHEditorInspector.cpp @@ -21,6 +21,7 @@ #include "UI/SHUIComponent.h" #include "UI/SHCanvasComponent.h" #include "UI/SHButtonComponent.h" +#include "UI/SHToggleButtonComponent.h" #include "SHEditorComponentView.h" #include "AudioSystem/SHAudioListenerComponent.h" #include "Graphics/MiddleEnd/TextRendering/SHTextRenderableComponent.h" @@ -154,6 +155,10 @@ namespace SHADE { DrawComponent(buttonComponent); } + if (auto toggleButton = SHComponentManager::GetComponent_s(eid)) + { + DrawComponent(toggleButton); + } ImGui::Separator(); // Render Scripts SHScriptEngine* scriptEngine = static_cast(SHSystemManager::GetSystem()); @@ -167,6 +172,7 @@ namespace SHADE DrawAddComponentButton(eid); DrawAddComponentButton(eid); DrawAddComponentButton(eid); + DrawAddComponentButton(eid); // Components that require Transforms diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.h b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.h new file mode 100644 index 00000000..72e2a2e3 --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.h @@ -0,0 +1,27 @@ +#pragma once +#include "Editor/Command/SHCommand.hpp" + +namespace SHADE +{ + template + class SHPasteComponentCommand final : SHBaseCommand + { + public: + struct Data + { + EntityID eid; + std::string oldComponentData; + std::string newComponentData; + }; + + SHPasteComponentCommand(EntityID eid, std::string const& newComponentData); + + void Execute() override; + void Undo() override; + + private: + Data data; + }; +} + +#include "SHInspectorCommands.hpp" \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.hpp b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.hpp new file mode 100644 index 00000000..da006218 --- /dev/null +++ b/SHADE_Engine/src/Editor/EditorWindow/Inspector/SHInspectorCommands.hpp @@ -0,0 +1,26 @@ +#pragma once +#include "SHInspectorCommands.h" + +namespace SHADE +{ + template + SHPasteComponentCommand::SHPasteComponentCommand(EntityID eid, std::string const& newComponentData) + :data(eid, {}, newComponentData) + { + data.oldComponentData = SHSerializationHelper::SerializeComponentToString(eid); + } + + template + void SHPasteComponentCommand::Execute() + { + bool result = SHSerializationHelper::DeserializeComponentFromString(data.newComponentData, data.eid); + if(!result) + SHCommandManager::failedExecution = true; + } + + template + void SHPasteComponentCommand::Undo() + { + SHSerializationHelper::DeserializeComponentFromString(data.oldComponentData, data.eid); + } +} \ No newline at end of file diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp index a1335e19..5014dbdd 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.cpp @@ -81,126 +81,18 @@ namespace SHADE if (ImGui::BeginMainMenuBar()) { - if (ImGui::BeginMenu("File")) - { - if(ImGui::Selectable("New Scene")) - { - SHSystemManager::GetSystem()->NewScene(); - } - if(ImGui::Selectable("Save")) - { - SHSystemManager::GetSystem()->SaveScene(); - } - if(ImGui::Selectable("Load")) - { - //SHSystemManager::GetSystem()->LoadScene() - } - ImGui::EndMenu(); - } - if(ImGui::BeginMenu("Edit")) - { - ImGui::BeginDisabled(!SHCommandManager::GetUndoStackSize()); - if(ImGui::Button(std::format("{} Undo", ICON_MD_UNDO).data())) - { - SHCommandManager::UndoCommand(); - } - ImGui::EndDisabled(); - ImGui::BeginDisabled(!SHCommandManager::GetRedoStackSize()); - if(ImGui::Button(std::format("{} Redo", ICON_MD_REDO).data())) - { - SHCommandManager::RedoCommand(); - } - ImGui::EndDisabled(); - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Scripts")) - { - if (ImGui::Selectable("Generate Visual Studio Project")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - scriptEngine->GenerateScriptsCsProjFile(); - } - ImGui::BeginDisabled(SHSystemManager::GetSystem()->editorState != SHEditor::State::STOP); - if (ImGui::Selectable("Build Scripts - Debug")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); - scriptEngine->BuildScriptAssembly(true, true); - SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); - } - if (ImGui::Selectable("Build Scripts - Release")) - { - auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); - SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); - scriptEngine->BuildScriptAssembly(false, true); - SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); - } - ImGui::EndDisabled(); - ImGui::EndMenu(); - } + DrawFileMenu(); + DrawEditMenu(); + DrawScriptsMenu(); + DrawWindowMenu(); + DrawThemeMenu(); + DrawLayoutMenu(); + DrawApplicationConfig(); - if (ImGui::BeginMenu("Window")) - { - for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) - { - if (window.get() != this) - ImGui::Checkbox(window->windowName.data(), &window->isOpen); - } - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Theme")) - { - const auto styles = rttr::type::get().get_enumeration(); - auto values = styles.get_values(); - for (auto style : values) - { - if (ImGui::Selectable(style.to_string().c_str())) - { - if (auto editor = SHSystemManager::GetSystem()) - editor->SetStyle(style.convert()); - } - } - ImGui::EndMenu(); - } - if(ImGui::BeginMenu("Layout")) - { - for(auto const& entry : layoutPaths) - { - if(ImGui::Selectable(entry.stem().string().c_str())) - { - ImGui::LoadIniSettingsFromDisk(entry.string().c_str()); - } - } - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Application Config")) - { - auto& appConfig = SHConfigurationManager::applicationConfig; - ImGui::InputText("Window Title", &appConfig.windowTitle); - ImGui::Checkbox("Start in Fullscreen", &appConfig.startInFullScreen); - SHEditorWidgets::DragN("Window Size", { "Width", "Height" }, { &appConfig.windowSize.x, &appConfig.windowSize.y }); - //ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID); - auto sceneAsset = SHAssetManager::GetData(appConfig.startingSceneID); - - if(ImGui::BeginCombo("Starting Scne", sceneAsset ? sceneAsset->name.data() : "")) - { - auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE); - for(auto const& scene : scenes) - { - if(ImGui::Selectable(scene.name.data())) - { - appConfig.startingSceneID = scene.id; - } - } - ImGui::EndCombo(); - } - if (ImGui::Button("Save")) - { - SHConfigurationManager::SaveApplicationConfig(); - } - ImGui::EndMenu(); - } + std::string const sceneName{std::format("Current Scene: {}",SHSceneManager::GetSceneName().data())}; + auto const size = ImGui::CalcTextSize(sceneName.data()); + ImGui::SetCursorPosX(ImGui::GetWindowWidth() - size.x - ImGui::GetStyle().FramePadding.x); + ImGui::Text("%s", sceneName.data()); ImGui::EndMainMenuBar(); } @@ -267,4 +159,148 @@ namespace SHADE ImGui::PopStyleVar(3); } + void SHEditorMenuBar::DrawFileMenu() noexcept + { + if (ImGui::BeginMenu("File")) + { + if (ImGui::Selectable("New Scene")) + { + SHSystemManager::GetSystem()->NewScene(); + } + if (ImGui::Selectable("Save")) + { + SHSystemManager::GetSystem()->SaveScene(); + } + if (ImGui::Selectable("Load")) + { + //SHSystemManager::GetSystem()->LoadScene() + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawEditMenu() noexcept + { + if (ImGui::BeginMenu("Edit")) + { + ImGui::BeginDisabled(!SHCommandManager::GetUndoStackSize()); + if (ImGui::Button(std::format("{} Undo", ICON_MD_UNDO).data())) + { + SHCommandManager::UndoCommand(); + } + ImGui::EndDisabled(); + ImGui::BeginDisabled(!SHCommandManager::GetRedoStackSize()); + if (ImGui::Button(std::format("{} Redo", ICON_MD_REDO).data())) + { + SHCommandManager::RedoCommand(); + } + ImGui::EndDisabled(); + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawScriptsMenu() noexcept + { + if (ImGui::BeginMenu("Scripts")) + { + if (ImGui::Selectable("Generate Visual Studio Project")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + scriptEngine->GenerateScriptsCsProjFile(); + } + if (ImGui::Selectable("Open Visual Studio Project")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + scriptEngine->OpenSolution(); + } + ImGui::BeginDisabled(SHSystemManager::GetSystem()->editorState != SHEditor::State::STOP); + if (ImGui::Selectable("Build Scripts - Debug")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); + scriptEngine->BuildScriptAssembly(true, true); + SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); + } + if (ImGui::Selectable("Build Scripts - Release")) + { + auto* scriptEngine = static_cast(SHSystemManager::GetSystem()); + SHSerialization::SerializeSceneToFile(SHSceneManager::GetCurrentSceneAssetID()); + scriptEngine->BuildScriptAssembly(false, true); + SHSceneManager::RestartScene(SHSceneManager::GetCurrentSceneAssetID()); + } + ImGui::EndDisabled(); + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawWindowMenu() noexcept + { + if (ImGui::BeginMenu("Window")) + { + for (const auto& window : SHEditorWindowManager::editorWindows | std::views::values) + { + if (window.get() != this) + ImGui::Checkbox(window->windowName.data(), &window->isOpen); + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawThemeMenu() noexcept + { + if (ImGui::BeginMenu("Theme")) + { + const auto styles = rttr::type::get().get_enumeration(); + auto values = styles.get_values(); + for (auto style : values) + { + if (ImGui::Selectable(style.to_string().c_str())) + { + if (auto editor = SHSystemManager::GetSystem()) + editor->SetStyle(style.convert()); + } + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawLayoutMenu() noexcept + { + if (ImGui::BeginMenu("Layout")) + { + for (auto const& entry : layoutPaths) + { + if (ImGui::Selectable(entry.stem().string().c_str())) + { + ImGui::LoadIniSettingsFromDisk(entry.string().c_str()); + } + } + ImGui::EndMenu(); + } + } + void SHEditorMenuBar::DrawApplicationConfig() noexcept + { + if (ImGui::BeginMenu("Application Config")) + { + auto& appConfig = SHConfigurationManager::applicationConfig; + ImGui::InputText("Window Title", &appConfig.windowTitle); + ImGui::Checkbox("Start in Fullscreen", &appConfig.startInFullScreen); + SHEditorWidgets::DragN("Window Size", { "Width", "Height" }, { &appConfig.windowSize.x, &appConfig.windowSize.y }); + //ImGui::InputScalar("Starting Scene", ImGuiDataType_U32, &appConfig.startingSceneID); + auto sceneAsset = SHAssetManager::GetData(appConfig.startingSceneID); + + if (ImGui::BeginCombo("Starting Scene", sceneAsset ? sceneAsset->name.data() : "")) + { + auto scenes = SHAssetManager::GetAllRecordOfType(AssetType::SCENE); + for (auto const& scene : scenes) + { + if (ImGui::Selectable(scene.name.data())) + { + appConfig.startingSceneID = scene.id; + } + } + ImGui::EndCombo(); + } + if (ImGui::Button("Save")) + { + SHConfigurationManager::SaveApplicationConfig(); + } + ImGui::EndMenu(); + } + } }//namespace SHADE diff --git a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h index e4f1d20b..77ebcf55 100644 --- a/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h +++ b/SHADE_Engine/src/Editor/EditorWindow/MenuBar/SHEditorMenuBar.h @@ -17,6 +17,15 @@ namespace SHADE void DrawMainMenuBar() noexcept; void DrawSecondaryBar() const noexcept; void DrawStatusBar() const noexcept; + + void DrawFileMenu() noexcept; + void DrawEditMenu() noexcept; + void DrawScriptsMenu() noexcept; + void DrawWindowMenu() noexcept; + void DrawThemeMenu() noexcept; + void DrawLayoutMenu() noexcept; + void DrawApplicationConfig() noexcept; + float menuBarHeight = 20.0f; std::vector layoutPaths; };//class SHEditorMenuBar diff --git a/SHADE_Engine/src/Editor/SHEditor.cpp b/SHADE_Engine/src/Editor/SHEditor.cpp index 9e7ffcc6..14b37263 100644 --- a/SHADE_Engine/src/Editor/SHEditor.cpp +++ b/SHADE_Engine/src/Editor/SHEditor.cpp @@ -93,6 +93,8 @@ namespace SHADE SHLOG_CRITICAL("Failed to create ImGui Context") } } + + editorConfig = &SHConfigurationManager::LoadEditorConfig(); //Add editor windows SHEditorWindowManager::CreateEditorWindow(); @@ -122,7 +124,7 @@ namespace SHADE InitBackend(); - SetStyle(Style::SHADE); + SetStyle(static_cast