diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 07bc3b97..5d1dc1ca 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -2044,6 +2044,13 @@ namespace Nuake { { if (ImGui::Begin("Logger")) { + if (ImGui::Button("Clear Logs")) + { + Logger::ClearLogs(); + SetStatusMessage("Logs cleared."); + } + + ImGui::SameLine(); ImGui::Checkbox("Errors", &LogErrors); ImGui::SameLine(); ImGui::Checkbox("Warning", &LogWarnings); @@ -2104,7 +2111,7 @@ namespace Nuake { std::string displayMessage = l.message; if (l.count > 0) { - displayMessage + "(" + std::to_string(l.count) + ")"; + displayMessage += "(" + std::to_string(l.count) + ")"; } ImGui::TextWrapped(displayMessage.c_str()); @@ -2546,6 +2553,14 @@ namespace Nuake { DrawMenuBar(); DrawMenuBars(); + + int i = 0; + if (Logger::GetLogCount() > 0 && Logger::GetLogs()[Logger::GetLogCount() - 1].type == COMPILATION) + { + SetStatusMessage(std::string(ICON_FA_EXCLAMATION_TRIANGLE) + " An unhandled exception occured in your script. See logs for more details.", Color(1.0f, 0.1f, 0.1f, 1.0f)); + } + + DrawStatusBar(); pInterface.DrawEntitySettings(); diff --git a/Nuake/src/Core/Logger.cpp b/Nuake/src/Core/Logger.cpp index 8e1d75c3..3cd77bf6 100644 --- a/Nuake/src/Core/Logger.cpp +++ b/Nuake/src/Core/Logger.cpp @@ -66,4 +66,9 @@ namespace Nuake { return m_Logs; } + + void Logger::ClearLogs() + { + m_Logs.clear(); + } } diff --git a/Nuake/src/Core/Logger.h b/Nuake/src/Core/Logger.h index 470a7cfe..89260e08 100644 --- a/Nuake/src/Core/Logger.h +++ b/Nuake/src/Core/Logger.h @@ -8,7 +8,8 @@ namespace Nuake { VERBOSE, WARNING, - CRITICAL + CRITICAL, + COMPILATION }; struct LogEntry @@ -29,5 +30,7 @@ namespace Nuake public: static void Log(const std::string& log, const std::string& logger = "main", LOG_TYPE type = VERBOSE); static std::vector GetLogs(); + static void ClearLogs(); + static size_t GetLogCount() { return m_Logs.size(); } }; } diff --git a/Nuake/src/Scripting/ScriptingEngineNet.cpp b/Nuake/src/Scripting/ScriptingEngineNet.cpp index 0e3fd449..d92c0595 100644 --- a/Nuake/src/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/src/Scripting/ScriptingEngineNet.cpp @@ -21,10 +21,9 @@ void ExceptionCallback(std::string_view InMessage) { const std::string message = std::string("Unhandled native exception: ") + std::string(InMessage); - Nuake::Logger::Log(message, ".net", Nuake::CRITICAL); + Nuake::Logger::Log(message, ".net", Nuake::COMPILATION); } - namespace Nuake { ScriptingEngineNet::ScriptingEngineNet() @@ -484,40 +483,6 @@ EndGlobal FileSystem::WriteLine(slnFileContent); FileSystem::EndWriteFile(); -// // Generate premake5 templates -// // ---------------------------------------- -// const std::string cleanProjectName = String::Sanitize(projectName); -// const std::string premakeScript = R"( -//workspace ")" + cleanProjectName + R"(" -//configurations { "Debug", "Release" } -// project ")" + cleanProjectName + R"(" -// language "C#" -// dotnetframework "net8.0" -// kind "SharedLib" -// clr "Unsafe" -// -// -- Don't specify architecture here. (see https://github.com/premake/premake-core/issues/1758) -// -// files -// { -// "**.cs" -// } -// -// links -// { -// ".net/NuakeNet" -// } -//)"; -// -// // Writting premake5 templates in project's directory -// // ---------------------------------------- -// FileSystem::BeginWriteFile("premake5.lua"); -// FileSystem::WriteLine(premakeScript); -// FileSystem::EndWriteFile(); -// -// // Execute premake script, generating .sln -// OS::ExecuteCommand("cd " + path + " && premake5 vs2022"); - // Open solution file in visual studio OS::OpenIn(path + cleanProjectName + ".sln");