Added clear logs button + showing exception in status bar

This commit is contained in:
Antoine Pilote
2024-08-14 20:29:50 -04:00
parent 6032d40aa2
commit 1eb81041fb
4 changed files with 26 additions and 38 deletions
+16 -1
View File
@@ -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();
+5
View File
@@ -66,4 +66,9 @@ namespace Nuake
{
return m_Logs;
}
void Logger::ClearLogs()
{
m_Logs.clear();
}
}
+4 -1
View File
@@ -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<LogEntry> GetLogs();
static void ClearLogs();
static size_t GetLogCount() { return m_Logs.size(); }
};
}
+1 -36
View File
@@ -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");