From 6ef952105927b3f99e2ace6c1178176deb7bc8d8 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Fri, 27 Oct 2023 01:32:17 -0400 Subject: [PATCH] Cleaned up UI and added a way to build .net project from the editor --- Editor/src/Windows/EditorInterface.cpp | 48 ++++++++++++++++++++- Nuake/src/Audio/AudioManager.cpp | 1 - Nuake/src/Core/OS.cpp | 10 +++++ Nuake/src/Core/OS.h | 1 + Nuake/src/Core/String.cpp | 2 +- Nuake/src/Scene/Systems/AudioSystem.cpp | 2 +- Nuake/src/Scene/Systems/ScriptingSystem.cpp | 1 - Nuake/src/Scripting/ScriptingEngineNet.cpp | 12 ++++++ Nuake/src/Scripting/ScriptingEngineNet.h | 1 + Nuake/src/Window.cpp | 5 ++- 10 files changed, 76 insertions(+), 7 deletions(-) diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index aca5b9db..83e19b36 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -128,12 +128,26 @@ namespace Nuake { if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5))) { SceneSnapshot = Engine::GetCurrentScene()->Copy(); + + ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject()); Engine::EnterPlayMode(); } + + if (ImGui::BeginItemTooltip()) + { + ImGui::Text("Build & Play"); + ImGui::EndTooltip(); + } } ImGui::SameLine(); + const bool wasPlayMode = Engine::IsPlayMode(); + if (!wasPlayMode) + { + ImGui::BeginDisabled(); + } + if ((ImGui::Button(ICON_FA_STOP, ImVec2(30, 30)) || Input::IsKeyPressed(GLFW_KEY_F8)) && Engine::IsPlayMode()) { Engine::ExitPlayMode(); @@ -142,6 +156,19 @@ namespace Nuake { Selection = EditorSelection(); } + if(!wasPlayMode) + { + ImGui::EndDisabled(); + + } + else + { + if (ImGui::BeginItemTooltip()) + { + ImGui::Text("Exit play mode"); + ImGui::EndTooltip(); + } + } //if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5) && !Engine::IsPlayMode())) //{ @@ -173,7 +200,7 @@ namespace Nuake { ImGui::SameLine(); - const int sizeofRightPart = 160; + const int sizeofRightPart = 156; ImGui::Dummy(ImVec2(ImGui::GetContentRegionAvail().x - sizeofRightPart, 30)); @@ -206,6 +233,25 @@ namespace Nuake { ImGui::EndChild(); + ImGui::SameLine(); + + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2)); + ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0, 0, 0, 0)); + + if (ImGui::Button(ICON_FA_HAMMER, ImVec2(30, 30))) + { + Nuake::ScriptingEngineNet::Get().BuildProjectAssembly(Engine::GetProject()); + } + + if (ImGui::BeginItemTooltip()) + { + ImGui::Text("Built .Net project"); + ImGui::EndTooltip(); + } + + ImGui::PopStyleColor(); + ImGui::PopStyleVar(); + ImGui::PopStyleColor(); ImGui::PopStyleVar(); diff --git a/Nuake/src/Audio/AudioManager.cpp b/Nuake/src/Audio/AudioManager.cpp index 37cd287e..862319bc 100644 --- a/Nuake/src/Audio/AudioManager.cpp +++ b/Nuake/src/Audio/AudioManager.cpp @@ -63,7 +63,6 @@ namespace Nuake { m_ListenerPosition = position; m_ListenerDirection = direction; m_ListenerUp = up; - m_Soloud->set3dListenerParameters(m_ListenerPosition.x, m_ListenerPosition.y, m_ListenerPosition.z, m_ListenerDirection.x, m_ListenerDirection.y, m_ListenerDirection.z, m_ListenerUp.x, m_ListenerUp.y, m_ListenerUp.z diff --git a/Nuake/src/Core/OS.cpp b/Nuake/src/Core/OS.cpp index e8c5ab83..cff1e73e 100644 --- a/Nuake/src/Core/OS.cpp +++ b/Nuake/src/Core/OS.cpp @@ -139,6 +139,16 @@ namespace Nuake { return path; } + void OS::CompileSln(const std::string& slnPath) + { + int result = system(std::string("dotnet build " + slnPath).c_str()); + + if (result != 0) + { + Logger::Log("Failed to execute `dotnet build` command.", "OS", CRITICAL); + } + } + void OS::OpenURL(const std::string& url) { #ifdef NK_WIN diff --git a/Nuake/src/Core/OS.h b/Nuake/src/Core/OS.h index 340ac2e4..dc77ea82 100644 --- a/Nuake/src/Core/OS.h +++ b/Nuake/src/Core/OS.h @@ -19,5 +19,6 @@ namespace Nuake static void OpenTrenchbroomMap(const std::string& filePath); static void OpenURL(const std::string& url); static std::string GetConfigFolderPath(); + static void CompileSln(const std::string& slnPath); }; } diff --git a/Nuake/src/Core/String.cpp b/Nuake/src/Core/String.cpp index 90c183a1..48630c94 100644 --- a/Nuake/src/Core/String.cpp +++ b/Nuake/src/Core/String.cpp @@ -47,7 +47,7 @@ namespace Nuake sanitizedKeyword = std::regex_replace(sanitizedKeyword, std::regex("[ _-]+"), ""); // Convert to lowercase - std::transform(sanitizedKeyword.begin(), sanitizedKeyword.end(), sanitizedKeyword.begin(), ::tolower); + //std::transform(sanitizedKeyword.begin(), sanitizedKeyword.end(), sanitizedKeyword.begin(), ::tolower); return sanitizedKeyword; } diff --git a/Nuake/src/Scene/Systems/AudioSystem.cpp b/Nuake/src/Scene/Systems/AudioSystem.cpp index 888e9868..e761e6f1 100644 --- a/Nuake/src/Scene/Systems/AudioSystem.cpp +++ b/Nuake/src/Scene/Systems/AudioSystem.cpp @@ -34,7 +34,7 @@ namespace Nuake Vector3 direction = currentCamera->GetDirection(); if (Engine::IsPlayMode()) { - direction *= Vector3(-1, -1, -1); + direction *= -1.0f; } audioManager.SetListenerPosition(currentCamera->GetTranslation(), std::move(direction), currentCamera->GetUp()); diff --git a/Nuake/src/Scene/Systems/ScriptingSystem.cpp b/Nuake/src/Scene/Systems/ScriptingSystem.cpp index 4a217b2d..cb0b9487 100644 --- a/Nuake/src/Scene/Systems/ScriptingSystem.cpp +++ b/Nuake/src/Scene/Systems/ScriptingSystem.cpp @@ -137,7 +137,6 @@ namespace Nuake catch (std::exception* e) { } - } auto& scriptingEngineNet = ScriptingEngineNet::Get(); diff --git a/Nuake/src/Scripting/ScriptingEngineNet.cpp b/Nuake/src/Scripting/ScriptingEngineNet.cpp index c55dcb95..13bd272b 100644 --- a/Nuake/src/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/src/Scripting/ScriptingEngineNet.cpp @@ -101,6 +101,18 @@ namespace Nuake m_EntityToManagedObjects.clear(); } + void ScriptingEngineNet::BuildProjectAssembly(Ref project) + { + const std::string sanitizedProjectName = String::Sanitize(project->Name); + if (!FileSystem::FileExists(sanitizedProjectName + ".sln")) + { + Logger::Log("Couldn't find .net solution. Have you created a solution?", ".net", CRITICAL); + return; + } + + OS::CompileSln(FileSystem::Root + sanitizedProjectName + ".sln"); + } + void ScriptingEngineNet::LoadProjectAssembly(Ref project) { const std::string sanitizedProjectName = String::Sanitize(project->Name); diff --git a/Nuake/src/Scripting/ScriptingEngineNet.h b/Nuake/src/Scripting/ScriptingEngineNet.h index a7954692..d4a5c816 100644 --- a/Nuake/src/Scripting/ScriptingEngineNet.h +++ b/Nuake/src/Scripting/ScriptingEngineNet.h @@ -49,6 +49,7 @@ namespace Nuake { void Initialize(); void Uninitialize(); + void BuildProjectAssembly(Ref project); void LoadProjectAssembly(Ref project); void RegisterEntityScript(Entity& entity); diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 902e6e6e..be282bec 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -308,7 +308,7 @@ namespace Nuake ImVec4* colors = ImGui::GetStyle().Colors; colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.148f, 0.148f, 0.148f, 1.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); colors[ImGuiCol_Border] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); @@ -317,7 +317,7 @@ namespace Nuake colors[ImGuiCol_FrameBgHovered] = ImVec4(0.09f, 0.09f, 0.09f, 1.00f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.13f, 0.13f, 0.13f, 1.00f); colors[ImGuiCol_TitleBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.078, 0.078, 0.078, 1.00f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.08f, 0.08f, 0.08f, 1.00f); colors[ImGuiCol_ScrollbarBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.00f); @@ -350,6 +350,7 @@ namespace Nuake colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_Border] = ImVec4(0.078f, 0.078f, 0.078f, 1.00f); colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.19f, 1.00f); colors[ImGuiCol_TableBorderStrong] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f); colors[ImGuiCol_TableBorderLight] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);