diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 3d15e8d1..c0e165f4 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -163,7 +163,7 @@ int main(int argc, char* argv[]) } catch (std::exception exception) { - Logger::Log("Error loading project: " + projectPath, CRITICAL); + Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); Logger::Log(exception.what()); } } diff --git a/Editor/src/NewEditor.cpp b/Editor/src/NewEditor.cpp index 857aba47..0dbc2f2d 100644 --- a/Editor/src/NewEditor.cpp +++ b/Editor/src/NewEditor.cpp @@ -45,7 +45,7 @@ namespace Nuake Ref project = Project::New(); if (!project->Deserialize(FileSystem::ReadFile(projectPath, true))) { - Logger::Log("Error loading project: " + projectPath, CRITICAL); + Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); return; } diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 81af2da4..830a0bf9 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -77,9 +77,8 @@ namespace Nuake { ImVec2 LastSize = ImVec2(); void EditorInterface::DrawViewport() { - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); - std::string name = ICON_FA_GAMEPAD + std::string(" Scene"); - + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(4, 4)); + std::string name = ICON_FA_GAMEPAD + std::string(" Scene"); if (ImGui::Begin(name.c_str())) { ImGui::PopStyleVar(); @@ -94,7 +93,7 @@ namespace Nuake { float half = windowWidth / 2.0; float needed = half - used; - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 2)); if (ImGui::Button(ICON_FA_PLAY, ImVec2(30, 30)) || (Input::IsKeyPressed(GLFW_KEY_F5) && !Engine::IsPlayMode())) { SceneSnapshot = Engine::GetCurrentScene()->Copy(); @@ -159,8 +158,10 @@ namespace Nuake { Ref texture = framebuffer->GetTexture(); ImVec2 imagePos = ImGui::GetCursorPos(); + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); m_ViewportPos = { imagePos.x, imagePos.y }; ImGui::Image((void*)texture->GetID(), regionAvail, ImVec2(0, 1), ImVec2(1, 0)); + ImGui::PopStyleVar(); const Vector2& mousePos = Input::GetMousePosition(); const ImVec2& windowPos = ImGui::GetWindowPos() + ImVec2(0, 30.0); @@ -1118,6 +1119,7 @@ namespace Nuake { bool LogErrors = true; bool LogWarnings = true; bool LogDebug = true; + bool AutoScroll = true; void EditorInterface::DrawLogger() { if (ImGui::Begin("Logger")) @@ -1127,21 +1129,20 @@ namespace Nuake { ImGui::Checkbox("Warning", &LogWarnings); ImGui::SameLine(); ImGui::Checkbox("Debug", &LogDebug); - + ImGui::SameLine(); + ImGui::Checkbox("Autoscroll", &AutoScroll); //ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); //if (ImGui::BeginChild("Log window", ImGui::GetContentRegionAvail(), false)) //{ //ImGui::PopStyleVar(); - ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; - + ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_Hideable; if (ImGui::BeginTable("LogTable", 3, flags)) { - ImGui::TableSetupScrollFreeze(0, 1); - ImGui::TableSetupColumn("Severity", 0, 0.15f); - ImGui::TableSetupColumn("Time", 0.15f); - ImGui::TableSetupColumn("Message", 0.7f); - ImGui::TableHeadersRow(); + ImGui::TableSetupColumn("Severity", ImGuiTableColumnFlags_WidthFixed, 64.0f); + ImGui::TableSetupColumn("Time", ImGuiTableColumnFlags_WidthFixed, 64.0f); + ImGui::TableSetupColumn("Message", ImGuiTableColumnFlags_WidthStretch, 1.0f); ImGui::TableNextColumn(); + ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(4, 4)); for (auto& l : Logger::GetLogs()) { if (l.type == LOG_TYPE::VERBOSE && !LogDebug) @@ -1153,31 +1154,46 @@ namespace Nuake { std::string severityText = ""; if (l.type == LOG_TYPE::VERBOSE) - severityText = "Verbose"; + severityText = "verbose"; else if (l.type == LOG_TYPE::WARNING) - severityText = "Warning"; + severityText = "warning"; else - severityText = "Critical"; + severityText = "critical"; + + ImVec4 colorGreen = ImVec4(0.59, 0.76, 0.47, 1.0); + ImGui::PushStyleColor(ImGuiCol_Text, colorGreen); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImVec4(0.59, 0.76, 0.47, 0.2)), -1); + const std::string timeString = " [" + l.time + "]"; + ImGui::Text(timeString.c_str()); + ImGui::PopStyleColor(); - ImGui::Text(severityText.c_str()); ImGui::TableNextColumn(); - ImGui::Text(l.time.c_str()); + + ImVec4 colorBlue = ImVec4(98 / 255.0, 174 / 255.0, 239 / 255.0, 1.); + ImGui::PushStyleColor(ImGuiCol_Text, colorBlue); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImVec4(98 / 255.0, 174 / 255.0, 239 / 255.0, 0.2)), -1); + ImGui::Text(l.logger.c_str()); + ImGui::PopStyleColor(); + ImGui::TableNextColumn(); + + ImVec4 color = ImVec4(1, 1, 1, 1.0); + ImGui::PushStyleColor(ImGuiCol_Text, color); + ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ImGui::GetColorU32(ImVec4(1, 1, 1, 0.0)), -1); ImGui::TextWrapped(l.message.c_str()); + ImGui::PopStyleColor(); ImGui::TableNextColumn(); } - if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) - ImGui::SetScrollHereY(1.0f); + ImGui::PopStyleVar(); + + if (AutoScroll) + { + ImGui::SetScrollY(ImGui::GetScrollMaxY()); + } ImGui::EndTable(); } - - - //ImGui::EndChild(); - //} - - } ImGui::End(); } @@ -1308,7 +1324,7 @@ namespace Nuake { Ref project = Project::New(); if (!project->Deserialize(FileSystem::ReadFile(projectPath, true))) { - Logger::Log("Error loading project: " + projectPath, CRITICAL); + Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); return; } @@ -1328,7 +1344,7 @@ namespace Nuake { Ref scene = Scene::New(); if (!scene->Deserialize(FileSystem::ReadFile(projectPath, true))) { - Logger::Log("Error failed loading scene: " + projectPath, CRITICAL); + Logger::Log("Error failed loading scene: " + projectPath, "editor", CRITICAL); return; } diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index d75531c3..d6744c49 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -197,7 +197,7 @@ namespace Nuake { if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) { - Logger::Log("Failed to remove file: " + file->GetRelativePath(), CRITICAL); + Logger::Log("Failed to remove file: " + file->GetRelativePath(), "editor", CRITICAL); } RefreshFileBrowser(); } @@ -289,7 +289,7 @@ namespace Nuake } else { - Logger::Log("[FileSystem] Cannot create script files that starts with a number.", CRITICAL); + Logger::Log("[FileSystem] Cannot create script files that starts with a number.", "editor", CRITICAL); } } } @@ -437,6 +437,8 @@ namespace Nuake ImGui::EndChild(); ImGui::PopStyleVar(); + + ImGui::PopStyleVar(); ImGui::PopStyleColor(); @@ -444,7 +446,7 @@ namespace Nuake if (ImGui::Button((std::string(ICON_FA_FOLDER_OPEN)).c_str(), buttonSize)) { - OS::ShowInFileExplorer(m_CurrentDirectory->fullPath); + OS::OpenIn(m_CurrentDirectory->fullPath); } ImGui::SameLine(); diff --git a/Editor/src/Windows/WelcomeWindow.cpp b/Editor/src/Windows/WelcomeWindow.cpp index 3cd1a42d..87ca1f16 100644 --- a/Editor/src/Windows/WelcomeWindow.cpp +++ b/Editor/src/Windows/WelcomeWindow.cpp @@ -269,7 +269,7 @@ namespace Nuake } catch (std::exception exception) { - Logger::Log("Error loading project: " + projectPath, CRITICAL); + Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); Logger::Log(exception.what()); } diff --git a/Nuake/Engine.cpp b/Nuake/Engine.cpp index 9fed2815..fa4ff072 100644 --- a/Nuake/Engine.cpp +++ b/Nuake/Engine.cpp @@ -28,26 +28,15 @@ namespace Nuake void Engine::Init() { - Logger::Log("Nuake initializing"); - AudioManager::Get().Initialize(); - Logger::Log("Audio engine initialized"); - - AudioManager::Get().PlayTTS("Nuake Engine debug"); - PhysicsManager::Get().Init(); - Logger::Log("Physics initialized"); // Creates the window s_CurrentWindow = Window::Get(); - Logger::Log("Window initialized"); Input::Init(); - Renderer2D::Init(); - Logger::Log("2D renderer initialized"); - - Logger::Log("Engine initialized successfully!"); + Logger::Log("Engine initialized"); } void Engine::Tick() @@ -56,7 +45,7 @@ namespace Nuake s_TimeStep = s_Time - s_LastFrameTime; s_LastFrameTime = s_Time; - s_TimeStep = std::min((float)s_TimeStep, 0.5f); + //s_TimeStep = std::min((float)s_TimeStep, 0f); // Dont update if no scene is loaded. if (s_CurrentWindow->GetScene()) @@ -90,7 +79,7 @@ namespace Nuake // Dont trigger init if already in player mode. if (IsPlayMode()) { - Logger::Log("Cannot enter play mode if is already in play mode.", WARNING); + Logger::Log("Cannot enter play mode if is already in play mode.", "engine", WARNING); return; } @@ -100,7 +89,7 @@ namespace Nuake } else { - Logger::Log("Cannot enter play mode. Scene OnInit failed", CRITICAL); + Logger::Log("Cannot enter play mode. Scene OnInit failed", "engine", CRITICAL); GetCurrentScene()->OnExit(); } } diff --git a/Nuake/src/Core/Logger.cpp b/Nuake/src/Core/Logger.cpp index 7af7089c..3ab41527 100644 --- a/Nuake/src/Core/Logger.cpp +++ b/Nuake/src/Core/Logger.cpp @@ -9,7 +9,7 @@ namespace Nuake { std::vector Logger::m_Logs = std::vector(); - void Logger::Log(const std::string& log, LOG_TYPE type) + void Logger::Log(const std::string& log, const std::string& logger ,LOG_TYPE type) { char buff[100]; time_t now = time(0); @@ -20,10 +20,24 @@ namespace Nuake LogEntry newLog = { type, buff, - log + log, + logger }; - std::string msg = "[" + std::string(buff) + "]" + std::string(" - ") + log; + switch (type) + { + case WARNING: + // TODO: Add color + break; + case CRITICAL: + + break; + case VERBOSE: + + break; + } + + std::string msg = "[" + std::string(buff) + "] " + logger + " - " + log; std::cout << msg << std::endl; if (m_Logs.size() >= MAX_LOG) diff --git a/Nuake/src/Core/Logger.h b/Nuake/src/Core/Logger.h index 6c41a49c..52659ac2 100644 --- a/Nuake/src/Core/Logger.h +++ b/Nuake/src/Core/Logger.h @@ -16,6 +16,7 @@ namespace Nuake LOG_TYPE type; std::string time; std::string message; + std::string logger; }; class Logger @@ -25,7 +26,7 @@ namespace Nuake static std::vector m_Logs; public: - static void Log(const std::string& log, LOG_TYPE type = VERBOSE); + static void Log(const std::string& log, const std::string& logger = "main", LOG_TYPE type = VERBOSE); static std::vector GetLogs(); }; } diff --git a/Nuake/src/Core/Physics/PhysicsManager.cpp b/Nuake/src/Core/Physics/PhysicsManager.cpp index 26aa6bac..ae3e9ce2 100644 --- a/Nuake/src/Core/Physics/PhysicsManager.cpp +++ b/Nuake/src/Core/Physics/PhysicsManager.cpp @@ -50,10 +50,8 @@ namespace Nuake void PhysicsManager::Init() { - Logger::Log("Initializing Jolt physics."); JPH::RegisterDefaultAllocator(); - Logger::Log("Creating factory & registering types."); JPH::Factory::sInstance = new JPH::Factory(); JPH::RegisterTypes(); diff --git a/Nuake/src/Rendering/Mesh/Mesh.cpp b/Nuake/src/Rendering/Mesh/Mesh.cpp index fce1fcd5..660dc9cd 100644 --- a/Nuake/src/Rendering/Mesh/Mesh.cpp +++ b/Nuake/src/Rendering/Mesh/Mesh.cpp @@ -157,12 +157,11 @@ namespace Nuake m_Material = CreateRef(); m_Material->Deserialize(j["Material"].dump()); - std::vector indices; + m_Indices.reserve(j["Indices"].size()); for (auto& i : j["Indices"]) { - indices.push_back(i); + m_Indices.push_back(i); } - m_Indices = indices; std::vector vertices; for (auto& v : j["Vertices"]) diff --git a/Nuake/src/Rendering/Shaders/ShaderManager.cpp b/Nuake/src/Rendering/Shaders/ShaderManager.cpp index bd2f2b24..29d1cef2 100644 --- a/Nuake/src/Rendering/Shaders/ShaderManager.cpp +++ b/Nuake/src/Rendering/Shaders/ShaderManager.cpp @@ -22,7 +22,7 @@ namespace Nuake { if (!s.second->Rebuild()) { - Logger::Log("Failed to rebuild shader: " + s.first, Nuake::CRITICAL); + Logger::Log("Failed to rebuild shader: " + s.first, "shader", Nuake::CRITICAL); } } } diff --git a/Nuake/src/Rendering/Textures/MaterialManager.cpp b/Nuake/src/Rendering/Textures/MaterialManager.cpp index cb5a627b..e7c4c1cb 100644 --- a/Nuake/src/Rendering/Textures/MaterialManager.cpp +++ b/Nuake/src/Rendering/Textures/MaterialManager.cpp @@ -57,9 +57,6 @@ namespace Nuake std::string matName; if (!j.contains("name")) { - std::string msg = "Error: Cannot load material file: " + materialPath + - " - Material file must have a name. \n"; - printf(msg.c_str()); return nullptr; } else diff --git a/Nuake/src/Rendering/Textures/Texture.cpp b/Nuake/src/Rendering/Textures/Texture.cpp index 346c8a8c..3a793c42 100644 --- a/Nuake/src/Rendering/Textures/Texture.cpp +++ b/Nuake/src/Rendering/Textures/Texture.cpp @@ -31,9 +31,14 @@ namespace Nuake glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_LocalBuffer); glGenerateMipmap(GL_TEXTURE_2D); if (m_LocalBuffer) + { stbi_image_free(m_LocalBuffer); + } else - std::cout << "Error: failed to load texture: " << path << std::endl; + { + const std::string& msg = "Failed to load texture: " + path; + Logger::Log(msg, "texture", WARNING); + } } Texture::Texture(glm::vec2 size, GLenum format, GLenum format2, GLenum format3, void* data) @@ -83,9 +88,14 @@ namespace Nuake glGenerateMipmap(GL_TEXTURE_2D); if (m_LocalBuffer) + { stbi_image_free(m_LocalBuffer); + } else - std::cout << "Error: failed to load texture buffer " << std::endl; + { + const std::string msg = "failed to load texture buffer"; + Logger::Log(msg, "texture", WARNING); + } } Texture::Texture(glm::vec2 size, msdfgen::BitmapConstRef& bitmap, bool t) diff --git a/Nuake/src/Rendering/Vertex.h b/Nuake/src/Rendering/Vertex.h index 4bc3d41b..ea35612c 100644 --- a/Nuake/src/Rendering/Vertex.h +++ b/Nuake/src/Rendering/Vertex.h @@ -3,8 +3,9 @@ namespace Nuake { - struct Vertex + class Vertex { + public: Vector3 position; Vector2 uv; Vector3 normal; diff --git a/Nuake/src/Resource/ModelLoader.cpp b/Nuake/src/Resource/ModelLoader.cpp index 90105261..c62fab92 100644 --- a/Nuake/src/Resource/ModelLoader.cpp +++ b/Nuake/src/Resource/ModelLoader.cpp @@ -34,7 +34,7 @@ namespace Nuake { std::string assimpErrorMsg = std::string(import.GetErrorString()); std::string logMsg = "[Failed to load model] - " + assimpErrorMsg; - Logger::Log(logMsg, WARNING); + Logger::Log(logMsg, "model", WARNING); return model; } @@ -219,7 +219,7 @@ namespace Nuake if (!FileSystem::FileExists(texturePath, true)) { std::string textureNotFoundmsg = "Texture file couldn't be found: " + texturePath; - Logger::Log(textureNotFoundmsg, Nuake::LOG_TYPE::WARNING); + Logger::Log(textureNotFoundmsg, "model", Nuake::LOG_TYPE::WARNING); texturePath = "resources/Textures/default/Default.png"; } diff --git a/Nuake/src/Resource/Project.cpp b/Nuake/src/Resource/Project.cpp index 78c0b8f3..45a9e6be 100644 --- a/Nuake/src/Resource/Project.cpp +++ b/Nuake/src/Resource/Project.cpp @@ -142,11 +142,11 @@ namespace Nuake std::string sceneContent = FileSystem::ReadFile(scenePath, false); if (!DefaultScene->Deserialize(sceneContent)) { - Logger::Log("Error loading scene: " + scenePath, CRITICAL); + Logger::Log("Error loading scene: " + scenePath, "project", CRITICAL); } DefaultScene->Path = scenePath; - Logger::Log("Successfully loaded scene: " + scenePath); + Logger::Log("Loaded scene: " + scenePath); return true; // Success } diff --git a/Nuake/src/Resource/ResourceLoader.h b/Nuake/src/Resource/ResourceLoader.h index 95a28101..0f7c2df0 100644 --- a/Nuake/src/Resource/ResourceLoader.h +++ b/Nuake/src/Resource/ResourceLoader.h @@ -25,14 +25,14 @@ namespace Nuake const std::string MATERIAL_EXT = ".material"; if (!FileSystem::FileExists(path)) { - Logger::Log(FILE_NOT_FOUND + path, LOG_TYPE::WARNING); + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); return nullptr; } if (!String::EndsWith(path, MATERIAL_EXT)) { std::string message = WRONG_EXTENSION + MATERIAL_EXT + " actual: " + path; - Logger::Log(message, LOG_TYPE::WARNING); + Logger::Log(message, "resource", LOG_TYPE::WARNING); } std::string content = FileSystem::ReadFile(path); diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 575d8781..fa164531 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -201,7 +201,7 @@ namespace Nuake { { if (name.empty()) { - Logger::Log("[Scene] Failed to create entity. Entity name cannot be empty."); + Logger::Log("Failed to create entity. Entity name cannot be empty."); return Entity(); } @@ -213,7 +213,7 @@ namespace Nuake { else { // Try to generate a unique name - for (uint32_t i = 1; i < 2048; i++) + for (uint32_t i = 1; i < 4096; i++) { const std::string& entityEnumName = name + std::to_string(i); const auto& entityId = GetEntity(entityEnumName).GetHandle(); @@ -226,7 +226,7 @@ namespace Nuake { if (entityName.empty()) // We ran out of names!!! { - Logger::Log("[Scene] Failed to create entity. Limit reached with name: " + name, CRITICAL); + Logger::Log("Failed to create entity. Limit reached with name: " + name, "scene", CRITICAL); return Entity(); } } @@ -242,7 +242,7 @@ namespace Nuake { nameComponent.Name = entityName; nameComponent.ID = id; - Logger::Log("[Scene] Entity created with name: " + nameComponent.Name, LOG_TYPE::VERBOSE); + Logger::Log("Entity created with name: " + nameComponent.Name, "scene", LOG_TYPE::VERBOSE); return entity; } diff --git a/Nuake/src/Scene/Systems/PhysicsSystem.cpp b/Nuake/src/Scene/Systems/PhysicsSystem.cpp index 2f5e0ff7..3f28533d 100644 --- a/Nuake/src/Scene/Systems/PhysicsSystem.cpp +++ b/Nuake/src/Scene/Systems/PhysicsSystem.cpp @@ -197,7 +197,7 @@ namespace Nuake Entity entity { e, m_Scene }; if (!entity.HasComponent()) { - Logger::Log("Cannot use mesh collider without model component", WARNING); + Logger::Log("Cannot use mesh collider without model component", "physics", WARNING); } auto meshColliderComponent = meshColliderView.get(e); @@ -209,7 +209,7 @@ namespace Nuake const std::vector>& submeshes = modelComponent.ModelResource->GetMeshes(); if (subMeshId >= submeshes.size()) { - Logger::Log("Cannot create mesh collider, invalid submesh ID", WARNING); + Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); } Ref mesh = submeshes[subMeshId]; @@ -274,7 +274,7 @@ namespace Nuake { if (!ent.HasComponent()) { - Logger::Log("Cannot use mesh collider without model component", WARNING); + Logger::Log("Cannot use mesh collider without model component", "physics", WARNING); } const auto& modelComponent = ent.GetComponent(); const auto& component = ent.GetComponent(); @@ -285,7 +285,7 @@ namespace Nuake const std::vector>& submeshes = modelComponent.ModelResource->GetMeshes(); if (subMeshId >= submeshes.size()) { - Logger::Log("Cannot create mesh collider, invalid submesh ID", WARNING); + Logger::Log("Cannot create mesh collider, invalid submesh ID", "physics", WARNING); } Ref mesh = submeshes[subMeshId]; auto shape = CreateRef(mesh); diff --git a/Nuake/src/Scripting/Modules/SceneModule.h b/Nuake/src/Scripting/Modules/SceneModule.h index 96976c34..954126bd 100644 --- a/Nuake/src/Scripting/Modules/SceneModule.h +++ b/Nuake/src/Scripting/Modules/SceneModule.h @@ -83,7 +83,7 @@ namespace Nuake { const std::string& prefabPath = wrenGetSlotString(vm, 1); if (prefabPath.empty()) { - Logger::Log("[Scripting] Cannot add prefab with an empty path.", CRITICAL); + Logger::Log("Cannot add prefab with an empty path.", "script", CRITICAL); wrenSetSlotDouble(vm, 0, -1); // -1 is an empty entity. return; } @@ -91,14 +91,14 @@ namespace Nuake { const std::string& prefabName = wrenGetSlotString(vm, 1); if (prefabName.empty()) { - Logger::Log("[Scripting] Cannot add prefab with an empty name.", CRITICAL); + Logger::Log("Cannot add prefab with an empty name.", "script", CRITICAL); wrenSetSlotDouble(vm, 0, -1); // -1 is an empty entity. return; } if (!FileSystem::FileExists(prefabPath)) { - Logger::Log("[Scripting] Cannot add prefab. File not found: " + prefabPath, CRITICAL); + Logger::Log("Cannot add prefab. File not found: " + prefabPath, "script", CRITICAL); return; } diff --git a/Nuake/src/Scripting/ScriptingEngine.cpp b/Nuake/src/Scripting/ScriptingEngine.cpp index 7bac7069..ed10d7ed 100644 --- a/Nuake/src/Scripting/ScriptingEngine.cpp +++ b/Nuake/src/Scripting/ScriptingEngine.cpp @@ -25,23 +25,23 @@ namespace Nuake { case WREN_ERROR_COMPILE: { std::string t = std::string(module) + " line " + std::to_string(line) + ": " + msg; - Logger::Log(t, CRITICAL); + Logger::Log(t, "script", CRITICAL); Engine::ExitPlayMode(); } break; case WREN_ERROR_STACK_TRACE: { std::string t = "Stack trace: " + std::string(module) + " line " + std::to_string(line) + ": " + msg; - Logger::Log(t, CRITICAL); + Logger::Log(t, "script", CRITICAL); } break; case WREN_ERROR_RUNTIME: { std::string t = "Script Runtime Error: " + std::string(msg); - Logger::Log(t, WARNING); + Logger::Log(t, "script", WARNING); } break; default: { std::string t = "Script Runtime Error: " + std::string(msg); - Logger::Log(t, CRITICAL); + Logger::Log(t, "script", CRITICAL); } break; } diff --git a/Nuake/src/UI/Font/FontLoader.h b/Nuake/src/UI/Font/FontLoader.h index cd561d17..94066d88 100644 --- a/Nuake/src/UI/Font/FontLoader.h +++ b/Nuake/src/UI/Font/FontLoader.h @@ -91,7 +91,7 @@ namespace Nuake // Load file if (!font->load(path.c_str())) - Logger::Log("Failed to load font", CRITICAL); + Logger::Log("Failed to load font", "font", CRITICAL); // Load charset ASCII std::vector glyphs; @@ -107,7 +107,7 @@ namespace Nuake fonts.push_back(fontGeometry); if (glyphs.empty()) - Logger::Log("No glyphs loaded.", CRITICAL); + Logger::Log("No glyphs loaded.", "font", CRITICAL); // Create atlas params msdf_atlas::TightAtlasPacker::DimensionsConstraint atlasSizeConstraint = msdf_atlas::TightAtlasPacker::DimensionsConstraint::MULTIPLE_OF_FOUR_SQUARE; @@ -124,7 +124,7 @@ namespace Nuake { if (remaining < 0) { - Logger::Log("Failed to pack atlas.", CRITICAL); + Logger::Log("Failed to pack atlas.", "font", CRITICAL); } else { diff --git a/Nuake/src/UI/Font/FontManager.cpp b/Nuake/src/UI/Font/FontManager.cpp index 3d4b94f4..8a33e732 100644 --- a/Nuake/src/UI/Font/FontManager.cpp +++ b/Nuake/src/UI/Font/FontManager.cpp @@ -16,7 +16,7 @@ namespace Nuake { if (newFont) return newFont; - Logger::Log("Error: failed to load font " + font, CRITICAL); + Logger::Log("Error: failed to load font " + font, "font", CRITICAL); return nullptr; } } diff --git a/Nuake/src/UI/InterfaceParser.cpp b/Nuake/src/UI/InterfaceParser.cpp index a2e17640..3e2985c5 100644 --- a/Nuake/src/UI/InterfaceParser.cpp +++ b/Nuake/src/UI/InterfaceParser.cpp @@ -12,7 +12,7 @@ namespace Nuake std::string name = doc.first_child().name(); if (name != "Canvas") { - Logger::Log("InterfaceParser error: First child should be a canvas - " + path, CRITICAL); + Logger::Log("InterfaceParser error: First child should be a canvas - " + path, "ui", CRITICAL); return nullptr; } diff --git a/Nuake/src/UI/UserInterface.cpp b/Nuake/src/UI/UserInterface.cpp index 88ca054b..5262c6d4 100644 --- a/Nuake/src/UI/UserInterface.cpp +++ b/Nuake/src/UI/UserInterface.cpp @@ -19,7 +19,7 @@ namespace Nuake { if (!Root) { - Logger::Log("Failed to generate interface structure", CRITICAL); + Logger::Log("Failed to generate interface structure", "ui", CRITICAL); } yoga_config = YGConfigNew(); @@ -40,7 +40,7 @@ namespace Nuake { Root = InterfaceParser::Parse(FileSystem::Root + this->m_Path); if (!Root) { - Logger::Log("Failed to generate interface structure", CRITICAL); + Logger::Log("Failed to generate interface structure", "ui", CRITICAL); } yoga_config = YGConfigNew(); diff --git a/Nuake/src/Window.cpp b/Nuake/src/Window.cpp index 62ce9665..2cbf8180 100644 --- a/Nuake/src/Window.cpp +++ b/Nuake/src/Window.cpp @@ -53,30 +53,33 @@ namespace Nuake { if (!glfwInit()) { - Logger::Log("glfw initialization failed.", CRITICAL); + Logger::Log("GLFW initialization failed", "window", CRITICAL); return -1; } m_Window = glfwCreateWindow(m_Width, m_Height, m_Title.c_str(), NULL, NULL); if (!m_Window) { - Logger::Log("Window creation failed.", CRITICAL); + Logger::Log("Window creation failed", "window", CRITICAL); return -1; } SetWindowIcon("resources/Images/nuake-logo.png"); glfwMakeContextCurrent(m_Window); - SetVSync(0); + //SetVSync(true) - Logger::Log((char*)glGetString(GL_VERSION)); + Logger::Log("Driver detected " + std::string(((char*)glGetString(GL_VERSION))), "renderer"); if (glewInit() != GLEW_OK) { - Logger::Log("GLEW initialization failed!", CRITICAL); + Logger::Log("GLEW initialization failed!", "window", CRITICAL); return -1; } + if (glfwRawMouseMotionSupported()) + glfwSetInputMode(m_Window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE); + // TODO: Move this to renderer init. The window shouldnt have to do gl calls. glfwWindowHint(GLFW_SAMPLES, 4); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);