Browse Source

Engine: Switch inferno/io/log.h => ruc/format/log.h

master
Riyyi 2 years ago
parent
commit
8a03d84580
  1. 1
      src/inferno.h
  2. 29
      src/inferno/application.cpp
  3. 54
      src/inferno/component/transformcomponent.cpp
  4. 35
      src/inferno/component/transformcomponent.h
  5. 1
      src/inferno/io/gltffile.cpp
  6. 4
      src/inferno/io/input.cpp
  7. 1
      src/inferno/render/buffer.cpp
  8. 10
      src/inferno/render/context.cpp
  9. 11
      src/inferno/render/font.cpp
  10. 14
      src/inferno/render/font.h
  11. 7
      src/inferno/render/renderer.cpp
  12. 6
      src/inferno/render/shader.cpp
  13. 4
      src/inferno/render/texture.cpp
  14. 11
      src/inferno/scene/scene.cpp
  15. 12
      src/inferno/scene/scene.h
  16. 7
      src/inferno/script/registration.h
  17. 8
      src/inferno/settings.cpp
  18. 4
      src/inferno/system/camerasystem.cpp
  19. 4
      src/inferno/system/rendersystem.cpp
  20. 4
      src/inferno/system/scriptsystem.cpp
  21. 5
      src/inferno/system/textareasystem.cpp
  22. 4
      src/inferno/system/transformsystem.cpp
  23. 5
      src/inferno/util/json.h
  24. 4
      src/inferno/window.cpp

1
src/inferno.h

@ -7,6 +7,5 @@
#include "inferno/core.h" #include "inferno/core.h"
#include "inferno/application.h" #include "inferno/application.h"
#include "inferno/io/log.h"
// ----------------------------------------- // -----------------------------------------

29
src/inferno/application.cpp

@ -1,4 +1,5 @@
#include "glm/gtc/type_ptr.hpp" // glm::make_mat4 #include "glm/gtc/type_ptr.hpp" // glm::make_mat4
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/application.h" #include "inferno/application.h"
@ -9,7 +10,6 @@
#include "inferno/event/mouseevent.h" #include "inferno/event/mouseevent.h"
// #include "inferno/io/gltffile.h" // #include "inferno/io/gltffile.h"
#include "inferno/io/input.h" #include "inferno/io/input.h"
#include "inferno/io/log.h"
#include "inferno/keycodes.h" #include "inferno/keycodes.h"
#include "inferno/render/buffer.h" #include "inferno/render/buffer.h"
#include "inferno/render/context.h" #include "inferno/render/context.h"
@ -45,11 +45,11 @@ Application::Application(s)
m_font = FontManager::the().load("assets/fnt/dejavu-sans"); m_font = FontManager::the().load("assets/fnt/dejavu-sans");
// auto bla = GlTFFile::read("assets/gltf/box.glb"); // auto bla = GlTFFile::read("assets/gltf/box.glb");
// success() << "@" << bla.first.get() << "@"; // ruc::success("@{}@", bla.first.get());
// auto bla2 = GlTFFile::read("assets/gltf/boxtextured.glb"); // auto bla2 = GlTFFile::read("assets/gltf/boxtextured.glb");
// info() << "@" << bla2.first.get() << "@"; // ruc::info("@{}@", bla2.first.get());
// auto bla3 = GlTFFile::read("assets/gltf/guinea-pig-cage-fleece.glb"); // auto bla3 = GlTFFile::read("assets/gltf/guinea-pig-cage-fleece.glb");
// warn() << "@" << bla3.first.get() << "@"; // ruc::warn("@{}@", bla3.first.get());
// Gltf model = Gltf("assets/gltf/box.glb"); // Gltf model = Gltf("assets/gltf/box.glb");
@ -76,7 +76,7 @@ Application::~Application()
int Application::run() int Application::run()
{ {
dbg() << "Application startup"; ruc::debug("Application startup");
std::array<CharacterVertex, Renderer::vertexPerQuad> character; std::array<CharacterVertex, Renderer::vertexPerQuad> character;
@ -87,7 +87,7 @@ int Application::run()
auto f = FontManager::the().get("assets/fnt/dejavu-sans"); auto f = FontManager::the().get("assets/fnt/dejavu-sans");
auto c = f->get('5'); auto c = f->get('5');
// dbg() << c->position << " " << c->size; // ruc::debug(c->position << " " << c->size);
uint32_t textureWidth = f->texture()->width(); uint32_t textureWidth = f->texture()->width();
uint32_t textureHeight = f->texture()->height(); uint32_t textureHeight = f->texture()->height();
@ -109,7 +109,7 @@ int Application::run()
(textureHeight - c->position.y - c->size.y) / (float)textureHeight, (textureHeight - c->position.y - c->size.y) / (float)textureHeight,
(textureHeight - c->position.y) / (float)textureHeight (textureHeight - c->position.y) / (float)textureHeight
}; };
// dbg() < y; // ruc::debug(y);
character.at(0).quad.textureCoordinates = { x.x, y.x }; character.at(0).quad.textureCoordinates = { x.x, y.x };
character.at(1).quad.textureCoordinates = { x.y, y.x }; character.at(1).quad.textureCoordinates = { x.y, y.x };
@ -131,7 +131,7 @@ int Application::run()
float time = Time::time(); float time = Time::time();
float deltaTime = time - m_lastFrameTime; float deltaTime = time - m_lastFrameTime;
m_lastFrameTime = time; m_lastFrameTime = time;
// dbg() << "Frametime " << deltaTime * 1000 << "ms"; // ruc::debug("Frametime " << deltaTime * 1000 << "ms");
// Update // Update
@ -156,7 +156,7 @@ int Application::run()
m_window->render(); m_window->render();
} }
dbg() << "Application shutdown"; ruc::debug("Application shutdown");
return m_status; return m_status;
} }
@ -175,8 +175,7 @@ bool Application::onWindowClose(WindowCloseEvent& e)
// Suppress unused warning // Suppress unused warning
(void)e; (void)e;
info() << "WindowCloseEvent triggered"; ruc::info("WindowCloseEvent");
infoln("{}Event triggered", e.toString());
m_window->setShouldClose(true); m_window->setShouldClose(true);
@ -188,7 +187,7 @@ bool Application::onWindowResize(WindowResizeEvent& e)
// Suppress unused warning // Suppress unused warning
(void)e; (void)e;
infoln("WindowResizeEvent {}x{} triggered", e.getWidth(), e.getHeight()); ruc::info("WindowResizeEvent {}x{}", e.getWidth(), e.getHeight());
RenderCommand::setViewport(0, 0, e.getWidth(), e.getHeight()); RenderCommand::setViewport(0, 0, e.getWidth(), e.getHeight());
@ -200,9 +199,7 @@ bool Application::onKeyPress(KeyPressEvent& e)
// Suppress unused warning // Suppress unused warning
(void)e; (void)e;
infoln("KeyPressEvent {} ({}) triggered", ruc::info("KeyPressEvent {} ({})", Input::getKeyName(e.getKey()), e.getKey());
Input::getKeyName(e.getKey()),
e.getKey());
// Stop the main loop on 'Escape' keypress // Stop the main loop on 'Escape' keypress
if (e.getKey() == keyCode("GLFW_KEY_ESCAPE")) { if (e.getKey() == keyCode("GLFW_KEY_ESCAPE")) {
@ -214,6 +211,8 @@ bool Application::onKeyPress(KeyPressEvent& e)
bool Application::onMousePosition(MousePositionEvent& e) bool Application::onMousePosition(MousePositionEvent& e)
{ {
// ruc::info("MousePositionEvent {:.0}x{:.0}", e.getXPos(), e.getYPos());
return Input::onMousePosition(e); return Input::onMousePosition(e);
} }

54
src/inferno/component/transformcomponent.cpp

@ -1,47 +1,39 @@
#include "inferno/component/transformcomponent.h" #include "inferno/component/transformcomponent.h"
namespace Inferno { void ruc::format::Formatter<glm::vec2>::format(Builder& builder, glm::vec2 value) const
const LogStream& operator<<(const LogStream& stream, const glm::vec2& value)
{ {
return stream << "{ " return Formatter<std::vector<float>>::format(builder, { value.x, value.y });
<< (value.x >= 0.0f ? " " : "") << value.x << ", "
<< (value.y >= 0.0f ? " " : "") << value.y
<< " }";
} }
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value) void ruc::format::Formatter<glm::vec3>::format(Builder& builder, glm::vec3 value) const
{ {
return stream << "{ " return Formatter<std::vector<float>>::format(builder, { value.x, value.y, value.z });
<< (value.x >= 0.0f ? " " : "") << value.x << ", "
<< (value.y >= 0.0f ? " " : "") << value.y << ", "
<< (value.z >= 0.0f ? " " : "") << value.z
<< " }";
} }
const LogStream& operator<<(const LogStream& stream, const glm::vec4& value) void ruc::format::Formatter<glm::vec4>::format(Builder& builder, glm::vec4 value) const
{ {
return stream << "{ " return Formatter<std::vector<float>>::format(builder, { value.x, value.y, value.z, value.w });
<< (value.x >= 0.0f ? " " : "") << value.x << ", "
<< (value.y >= 0.0f ? " " : "") << value.y << ", "
<< (value.z >= 0.0f ? " " : "") << value.z << ", "
<< (value.w >= 0.0f ? " " : "") << value.w
<< " }";
} }
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value) void ruc::format::Formatter<glm::mat4>::format(Builder& builder, glm::mat4 value) const
{ {
return stream << "mat4 " builder.putString("mat4 ");
<< value[0] << "\n " << value[1] << "\n " Formatter<glm::vec4>::format(builder, value[0]);
<< value[2] << "\n " << value[3]; builder.putString("\n ");
Formatter<glm::vec4>::format(builder, value[1]);
builder.putString("\n ");
Formatter<glm::vec4>::format(builder, value[2]);
builder.putString("\n ");
return Formatter<glm::vec4>::format(builder, value[3]);
} }
const LogStream& operator<<(const LogStream& stream, const TransformComponent& value) void ruc::format::Formatter<Inferno::TransformComponent>::format(Builder& builder, Inferno::TransformComponent value) const
{ {
return stream << "transform " builder.putString("transform ");
<< value.translate << " t\n " Formatter<glm::vec3>::format(builder, value.translate);
<< value.rotate << " r\n " builder.putString(" t\n ");
<< value.scale << " s"; Formatter<glm::vec3>::format(builder, value.rotate);
builder.putString(" r\n ");
Formatter<glm::vec3>::format(builder, value.scale);
builder.putString(" s");
} }
} // namespace Inferno

35
src/inferno/component/transformcomponent.h

@ -2,8 +2,7 @@
#include "glm/ext/matrix_float4x4.hpp" // glm::mat4 #include "glm/ext/matrix_float4x4.hpp" // glm::mat4
#include "glm/ext/vector_float3.hpp" // glm::vec3 #include "glm/ext/vector_float3.hpp" // glm::vec3
#include "ruc/format/format.h"
#include "inferno/io/log.h"
namespace Inferno { namespace Inferno {
@ -14,11 +13,29 @@ struct TransformComponent {
glm::mat4 transform { 1.0f }; // Identity matrix glm::mat4 transform { 1.0f }; // Identity matrix
}; };
// -----------------------------------------
const LogStream& operator<<(const LogStream& stream, const glm::vec2& value);
const LogStream& operator<<(const LogStream& stream, const glm::vec3& value);
const LogStream& operator<<(const LogStream& stream, const glm::vec4& value);
const LogStream& operator<<(const LogStream& stream, const glm::mat4& value);
const LogStream& operator<<(const LogStream& stream, const TransformComponent& value);
} // namespace Inferno } // namespace Inferno
template<>
struct ruc::format::Formatter<glm::vec2> : Formatter<std::vector<float>> {
void format(Builder& builder, glm::vec2 value) const;
};
template<>
struct ruc::format::Formatter<glm::vec3> : Formatter<std::vector<float>> {
void format(Builder& builder, glm::vec3 value) const;
};
template<>
struct ruc::format::Formatter<glm::vec4> : Formatter<std::vector<float>> {
void format(Builder& builder, glm::vec4 value) const;
};
template<>
struct ruc::format::Formatter<glm::mat4> : Formatter<glm::vec4> {
void format(Builder& builder, glm::mat4 value) const;
};
template<>
struct ruc::format::Formatter<Inferno::TransformComponent> : Formatter<glm::vec3> {
void format(Builder& builder, Inferno::TransformComponent value) const;
};

1
src/inferno/io/gltffile.cpp

@ -6,7 +6,6 @@
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/io/gltffile.h" #include "inferno/io/gltffile.h"
#include "inferno/io/log.h"
#include "inferno/util/json.h" #include "inferno/util/json.h"
#include "inferno/util/string.h" #include "inferno/util/string.h"

4
src/inferno/io/input.cpp

@ -1,9 +1,9 @@
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
#include "ruc/format/log.h"
#include "inferno/application.h" #include "inferno/application.h"
#include "inferno/event/mouseevent.h" #include "inferno/event/mouseevent.h"
#include "inferno/io/input.h" #include "inferno/io/input.h"
#include "inferno/io/log.h"
#include "inferno/window.h" #include "inferno/window.h"
namespace Inferno { namespace Inferno {
@ -20,7 +20,7 @@ void Input::initialize()
m_xPosLast = Application::the().getWindow().getWidth() / 2.0f; m_xPosLast = Application::the().getWindow().getWidth() / 2.0f;
m_yPosLast = Application::the().getWindow().getHeight() / 2.0f; m_yPosLast = Application::the().getWindow().getHeight() / 2.0f;
info() << "Input initialized"; ruc::info("Input initialized");
} }
void Input::update() void Input::update()

1
src/inferno/render/buffer.cpp

@ -1,7 +1,6 @@
#include "glad/glad.h" #include "glad/glad.h"
#include "inferno/core.h" #include "inferno/core.h"
#include "inferno/io/log.h"
#include "inferno/render/buffer.h" #include "inferno/render/buffer.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"

10
src/inferno/render/context.cpp

@ -2,10 +2,10 @@
#include "glad/glad.h" // glad needs to come before GLFW #include "glad/glad.h" // glad needs to come before GLFW
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
// clang-format on // clang-format on
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/core.h" #include "inferno/core.h"
#include "inferno/io/log.h"
#include "inferno/render/context.h" #include "inferno/render/context.h"
#include "inferno/window.h" #include "inferno/window.h"
@ -26,10 +26,10 @@ void Context::initialize()
VERIFY(glad, "Failed to initialize glad!"); VERIFY(glad, "Failed to initialize glad!");
// Log OpenGL properties // Log OpenGL properties
comment() << "OpenGL Info:"; ruc::trace("OpenGL Info:");
comment() << " Vendor: " << glGetString(GL_VENDOR); ruc::trace(" Vendor: {}", glGetString(GL_VENDOR));
comment() << " Renderer: " << glGetString(GL_RENDERER); ruc::trace(" Renderer: {}", glGetString(GL_RENDERER));
comment() << " Version: " << glGetString(GL_VERSION); ruc::trace(" Version: {}", glGetString(GL_VERSION));
// Check OpenGL version // Check OpenGL version
VERIFY(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5), VERIFY(GLVersion.major > 4 || (GLVersion.major == 4 && GLVersion.minor >= 5),

11
src/inferno/render/font.cpp

@ -3,6 +3,7 @@
#include <utility> // std::move #include <utility> // std::move
#include "ruc/file.h" #include "ruc/file.h"
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/render/font.h" #include "inferno/render/font.h"
@ -105,7 +106,7 @@ const std::string Font::findValue(const std::string& key, const std::vector<std:
FontManager::FontManager(s) FontManager::FontManager(s)
{ {
info() << "FontManager initialized"; ruc::info("FontManager initialized");
} }
FontManager::~FontManager() FontManager::~FontManager()
@ -153,11 +154,9 @@ void FontManager::remove(std::shared_ptr<Font> font)
} }
} }
// ----------------------------------------- } // namespace Inferno
const LogStream& operator<<(const LogStream& stream, const glm::ivec2& value) void ruc::format::Formatter<glm::ivec2>::format(Builder& builder, glm::ivec2 value) const
{ {
return stream << "{ " << value.x << ", " << value.y << " }"; return Formatter<std::vector<int32_t>>::format(builder, { value.x, value.y });
} }
} // namespace Inferno

14
src/inferno/render/font.h

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <cstdint> // uint32_t #include <cstdint> // int32_t, uint32_t
#include <memory> // std::shared_ptr #include <memory> // std::shared_ptr
#include <string> // std::string #include <string> // std::string
#include <unordered_map> // std::unordered_map #include <unordered_map> // std::unordered_map
@ -8,10 +8,9 @@
#include "glm/ext/vector_int2.hpp" // glm::ivec2 #include "glm/ext/vector_int2.hpp" // glm::ivec2
#include "glm/ext/vector_uint2.hpp" // glm::uvec2 #include "glm/ext/vector_uint2.hpp" // glm::uvec2
#include "ruc/format/format.h"
#include "ruc/singleton.h" #include "ruc/singleton.h"
#include "inferno/io/log.h"
namespace Inferno { namespace Inferno {
class Texture; class Texture;
@ -68,12 +67,13 @@ private:
std::unordered_map<std::string, std::shared_ptr<Font>> m_fontList; std::unordered_map<std::string, std::shared_ptr<Font>> m_fontList;
}; };
// -------------------------------------
const LogStream& operator<<(const LogStream& stream, const glm::ivec2& value);
} // namespace Inferno } // namespace Inferno
template<>
struct ruc::format::Formatter<glm::ivec2> : Formatter<std::vector<int32_t>> {
void format(Builder& builder, glm::ivec2 value) const;
};
// FontManager fm; // FontManager fm;
// Font f = fm.load("path/to/font"); // Font f = fm.load("path/to/font");
// Font f2("path/to/font"); // Font f2("path/to/font");

7
src/inferno/render/renderer.cpp

@ -2,6 +2,7 @@
#include <utility> // std::move #include <utility> // std::move
#include "glad/glad.h" #include "glad/glad.h"
#include "ruc/format/log.h"
#include "inferno/render/buffer.h" #include "inferno/render/buffer.h"
#include "inferno/render/renderer.h" #include "inferno/render/renderer.h"
@ -18,7 +19,7 @@ void RenderCommand::initialize()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
info() << "RenderCommand initialized"; ruc::info("RenderCommand initialized");
} }
void RenderCommand::destroy() void RenderCommand::destroy()
@ -201,7 +202,7 @@ Renderer2D::Renderer2D(s)
m_vertexArray->setIndexBuffer(indexBuffer); m_vertexArray->setIndexBuffer(indexBuffer);
delete[] indices; delete[] indices;
info() << "Renderer2D initialized"; ruc::info("Renderer2D initialized");
} }
Renderer2D::~Renderer2D() Renderer2D::~Renderer2D()
@ -355,7 +356,7 @@ RendererCharacter::RendererCharacter(s)
m_vertexArray->setIndexBuffer(indexBuffer); m_vertexArray->setIndexBuffer(indexBuffer);
delete[] indices; delete[] indices;
info() << "RendererCharacter initialized"; ruc::info("RendererCharacter initialized");
} }
RendererCharacter::~RendererCharacter() RendererCharacter::~RendererCharacter()

6
src/inferno/render/shader.cpp

@ -4,10 +4,10 @@
#include "glad/glad.h" #include "glad/glad.h"
#include "glm/gtc/type_ptr.hpp" // glm::value_ptr #include "glm/gtc/type_ptr.hpp" // glm::value_ptr
#include "ruc/file.h" #include "ruc/file.h"
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/core.h" #include "inferno/core.h"
#include "inferno/io/log.h"
#include "inferno/render/shader.h" #include "inferno/render/shader.h"
namespace Inferno { namespace Inferno {
@ -185,7 +185,7 @@ int32_t Shader::checkStatus(uint32_t check, bool isProgram) const
? glGetShaderInfoLog(check, maxLength, nullptr, &infoLog[0]) ? glGetShaderInfoLog(check, maxLength, nullptr, &infoLog[0])
: glGetProgramInfoLog(check, maxLength, nullptr, &infoLog[0]); : glGetProgramInfoLog(check, maxLength, nullptr, &infoLog[0]);
warn() << "Shader " << infoLog.data(); ruc::warn("Shader {}", infoLog.data());
} }
VERIFY(success == GL_TRUE, "Shader program creation failed!"); VERIFY(success == GL_TRUE, "Shader program creation failed!");
@ -197,7 +197,7 @@ int32_t Shader::checkStatus(uint32_t check, bool isProgram) const
ShaderManager::ShaderManager(s) ShaderManager::ShaderManager(s)
{ {
info() << "ShaderManager initialized"; ruc::info("ShaderManager initialized");
} }
ShaderManager::~ShaderManager() ShaderManager::~ShaderManager()

4
src/inferno/render/texture.cpp

@ -3,11 +3,11 @@
#include <utility> // std::move #include <utility> // std::move
#include "glad/glad.h" #include "glad/glad.h"
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "stb/stb_image.h" #include "stb/stb_image.h"
#include "inferno/io/log.h"
#include "inferno/render/texture.h" #include "inferno/render/texture.h"
namespace Inferno { namespace Inferno {
@ -106,7 +106,7 @@ void Texture::create(unsigned char* data)
TextureManager::TextureManager(s) TextureManager::TextureManager(s)
{ {
info() << "TextureManager initialized"; ruc::info("TextureManager initialized");
} }
TextureManager::~TextureManager() TextureManager::~TextureManager()

11
src/inferno/scene/scene.cpp

@ -1,3 +1,4 @@
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/component/cameracomponent.h" #include "inferno/component/cameracomponent.h"
@ -67,7 +68,7 @@ void Scene::initialize()
addComponent<TextAreaComponent>(text, "HelloWorld!", "assets/fnt/dejavu-sans", 0, 150, 3); addComponent<TextAreaComponent>(text, "HelloWorld!", "assets/fnt/dejavu-sans", 0, 150, 3);
// addComponent<TextAreaComponent>(text, "@#$%^&*()qygij!", "assets/fnt/dejavu-sans-test", 0, 150, 3); // addComponent<TextAreaComponent>(text, "@#$%^&*()qygij!", "assets/fnt/dejavu-sans-test", 0, 150, 3);
info() << "Scene initialized"; ruc::info("Scene initialized");
} }
void Scene::update(float deltaTime) void Scene::update(float deltaTime)
@ -117,11 +118,9 @@ void Scene::validEntity(uint32_t entity) const
VERIFY(m_registry->valid(entt::entity { entity }), "Entity is not valid"); VERIFY(m_registry->valid(entt::entity { entity }), "Entity is not valid");
} }
// ------------------------------------- } // namespace Inferno
const LogStream& operator<<(const LogStream& stream, entt::entity entity) void ruc::format::Formatter<entt::entity>::format(Builder& builder, entt::entity value) const
{ {
return stream << static_cast<uint32_t>(entity); return Formatter<uint32_t>::format(builder, static_cast<uint32_t>(value));
} }
} // namespace Inferno

12
src/inferno/scene/scene.h

@ -5,8 +5,7 @@
#include "entt/entity/registry.hpp" // entt::entity, entt::registry #include "entt/entity/registry.hpp" // entt::entity, entt::registry
#include "glm/ext/matrix_float4x4.hpp" // glm::mat4 #include "glm/ext/matrix_float4x4.hpp" // glm::mat4
#include "ruc/format/format.h"
#include "inferno/io/log.h"
namespace Inferno { namespace Inferno {
@ -74,12 +73,13 @@ private:
std::shared_ptr<entt::registry> m_registry; std::shared_ptr<entt::registry> m_registry;
}; };
// -----------------------------------------
const LogStream& operator<<(const LogStream& stream, entt::entity handle);
} // namespace Inferno } // namespace Inferno
template<>
struct ruc::format::Formatter<entt::entity> : Formatter<uint32_t> {
void format(Builder& builder, entt::entity value) const;
};
// @Todo // @Todo
// - Convert registry to stack variable // - Convert registry to stack variable
// - Convert registry to scene pointer in systems // - Convert registry to scene pointer in systems

7
src/inferno/script/registration.h

@ -1,10 +1,9 @@
#pragma once #pragma once
#include "ruc/format/format.h"
#include "sol/overload.hpp" // sol::overload #include "sol/overload.hpp" // sol::overload
#include "sol/state_view.hpp" // sol::state_view #include "sol/state_view.hpp" // sol::state_view
#include "inferno/io/log.h"
namespace Inferno { namespace Inferno {
class Registration final { class Registration final {
@ -55,9 +54,7 @@ private:
template<typename T> template<typename T>
static std::string string(const T& t) static std::string string(const T& t)
{ {
std::string result; return format("{}", t);
str(&result) << t;
return result;
} }
}; };

8
src/inferno/settings.cpp

@ -2,9 +2,9 @@
#include <string> // std::string #include <string> // std::string
#include "ruc/file.h" #include "ruc/file.h"
#include "ruc/format/log.h"
#include "ruc/json/json.h" #include "ruc/json/json.h"
#include "inferno/io/log.h"
#include "inferno/settings.h" #include "inferno/settings.h"
#include "inferno/window.h" #include "inferno/window.h"
@ -17,7 +17,7 @@ void Settings::initialize()
{ {
Settings::load(); Settings::load();
info() << "Settings initialized"; ruc::info("Settings initialized");
Settings::save(); Settings::save();
} }
@ -31,7 +31,7 @@ bool Settings::load()
auto object = ruc::Json::parse(ruc::File(m_path).data()); auto object = ruc::Json::parse(ruc::File(m_path).data());
if (object.type() != ruc::Json::Type::Object) { if (object.type() != ruc::Json::Type::Object) {
warn() << "Settings invalid formatting, using default values"; ruc::warn("Settings invalid formatting, using default values");
return false; return false;
} }
@ -50,7 +50,7 @@ bool Settings::save()
file.append("\n"); file.append("\n");
file.flush(); file.flush();
info() << "Settings saved"; ruc::info("Settings saved");
return true; return true;
} }

4
src/inferno/system/camerasystem.cpp

@ -1,12 +1,12 @@
#include "glm/ext/matrix_clip_space.hpp" // glm::perspective, glm::ortho #include "glm/ext/matrix_clip_space.hpp" // glm::perspective, glm::ortho
#include "glm/ext/matrix_transform.hpp" // glm::radians, glm::lookAt #include "glm/ext/matrix_transform.hpp" // glm::radians, glm::lookAt
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/application.h" #include "inferno/application.h"
#include "inferno/component/cameracomponent.h" #include "inferno/component/cameracomponent.h"
#include "inferno/component/transformcomponent.h" #include "inferno/component/transformcomponent.h"
#include "inferno/io/input.h" #include "inferno/io/input.h"
#include "inferno/io/log.h"
#include "inferno/system/camerasystem.h" #include "inferno/system/camerasystem.h"
#include "inferno/window.h" #include "inferno/window.h"
@ -14,7 +14,7 @@ namespace Inferno {
CameraSystem::CameraSystem(s) CameraSystem::CameraSystem(s)
{ {
info() << "CameraSystem initialized"; ruc::info("CameraSystem initialized");
} }
CameraSystem::~CameraSystem() CameraSystem::~CameraSystem()

4
src/inferno/system/rendersystem.cpp

@ -1,8 +1,8 @@
#include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians #include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians
#include "ruc/format/log.h"
#include "inferno/component/spritecomponent.h" #include "inferno/component/spritecomponent.h"
#include "inferno/component/transformcomponent.h" #include "inferno/component/transformcomponent.h"
#include "inferno/io/log.h"
#include "inferno/render/renderer.h" #include "inferno/render/renderer.h"
#include "inferno/system/rendersystem.h" #include "inferno/system/rendersystem.h"
@ -10,7 +10,7 @@ namespace Inferno {
RenderSystem::RenderSystem(s) RenderSystem::RenderSystem(s)
{ {
info() << "RenderSystem initialized"; ruc::info("RenderSystem initialized");
} }
RenderSystem::~RenderSystem() RenderSystem::~RenderSystem()

4
src/inferno/system/scriptsystem.cpp

@ -1,9 +1,9 @@
#include "entt/entity/registry.hpp" // entt::entity, entt::registry #include "entt/entity/registry.hpp" // entt::entity, entt::registry
#include "ruc/format/log.h"
#include "inferno/component/luascriptcomponent.h" #include "inferno/component/luascriptcomponent.h"
#include "inferno/component/nativescriptcomponent.h" #include "inferno/component/nativescriptcomponent.h"
#include "inferno/component/transformcomponent.h" #include "inferno/component/transformcomponent.h"
#include "inferno/io/log.h"
#include "inferno/scene/scene.h" #include "inferno/scene/scene.h"
#include "inferno/script/luascript.h" #include "inferno/script/luascript.h"
#include "inferno/script/nativescript.h" #include "inferno/script/nativescript.h"
@ -13,7 +13,7 @@ namespace Inferno {
ScriptSystem::ScriptSystem(s) ScriptSystem::ScriptSystem(s)
{ {
info() << "ScriptSystem initialized"; ruc::info("ScriptSystem initialized");
} }
ScriptSystem::~ScriptSystem() ScriptSystem::~ScriptSystem()

5
src/inferno/system/textareasystem.cpp

@ -1,3 +1,4 @@
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/application.h" #include "inferno/application.h"
@ -13,7 +14,7 @@ namespace Inferno {
TextAreaSystem::TextAreaSystem(s) TextAreaSystem::TextAreaSystem(s)
{ {
info() << "TextAreaSystem initialized"; ruc::info("TextAreaSystem initialized");
} }
TextAreaSystem::~TextAreaSystem() TextAreaSystem::~TextAreaSystem()
@ -89,7 +90,7 @@ std::optional<CharacterQuad> TextAreaSystem::calculateCharacterQuad(unsigned cha
quad.quad.position.x += advance; quad.quad.position.x += advance;
} }
// dbgln("character: {} ({}) width: {} height: {} advance: {} x: {}", // ruc::debug("character: {} ({}) width: {} height: {} advance: {} x: {}",
// character, (int)character, quadWidth, quadHeight, advance, characterQuad.at(0).quad.position.x); // character, (int)character, quadWidth, quadHeight, advance, characterQuad.at(0).quad.position.x);
// Jump to the next glyph // Jump to the next glyph

4
src/inferno/system/transformsystem.cpp

@ -1,14 +1,14 @@
#include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians #include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians
#include "ruc/format/log.h"
#include "inferno/component/transformcomponent.h" #include "inferno/component/transformcomponent.h"
#include "inferno/io/log.h"
#include "inferno/system/transformsystem.h" #include "inferno/system/transformsystem.h"
namespace Inferno { namespace Inferno {
TransformSystem::TransformSystem(s) TransformSystem::TransformSystem(s)
{ {
info() << "TransformSystem initialized"; ruc::info("TransformSystem initialized");
} }
TransformSystem::~TransformSystem() TransformSystem::~TransformSystem()

5
src/inferno/util/json.h

@ -7,6 +7,7 @@
#include "nlohmann/json.hpp" #include "nlohmann/json.hpp"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "ruc/format/log.h"
namespace Inferno { namespace Inferno {
@ -121,7 +122,7 @@ namespace Inferno {
values.emplace_back(typedValue.value()); values.emplace_back(typedValue.value());
} }
else { else {
warnln("Json array property '{}' has type inconsistency", property); ruc::warn("Json array property '{}' has type inconsistency", property);
} }
} }
@ -160,7 +161,7 @@ namespace Inferno {
values.emplace(std::move(key), typedValue.value()); values.emplace(std::move(key), typedValue.value());
} }
else { else {
warnln("Json array property '{}' has type inconsistency", property); ruc::warn("Json array property '{}' has type inconsistency", property);
} }
} }

4
src/inferno/window.cpp

@ -1,6 +1,7 @@
#include <csignal> // signal #include <csignal> // signal
#include "GLFW/glfw3.h" #include "GLFW/glfw3.h"
#include "ruc/format/log.h"
#include "ruc/meta/assert.h" #include "ruc/meta/assert.h"
#include "inferno/application.h" #include "inferno/application.h"
@ -9,7 +10,6 @@
#include "inferno/event/keyevent.h" #include "inferno/event/keyevent.h"
#include "inferno/event/mouseevent.h" #include "inferno/event/mouseevent.h"
#include "inferno/io/input.h" #include "inferno/io/input.h"
#include "inferno/io/log.h"
#include "inferno/keycodes.h" #include "inferno/keycodes.h"
#include "inferno/render/context.h" #include "inferno/render/context.h"
#include "inferno/render/renderer.h" #include "inferno/render/renderer.h"
@ -83,7 +83,7 @@ void Window::initialize()
// Error callback // Error callback
glfwSetErrorCallback([](int error, const char* description) { glfwSetErrorCallback([](int error, const char* description) {
dbgln("GLFW Error {}: {}", error, description); ruc::error("GLFW Error: {}: {}", error, description);
}); });
// Window close callback // Window close callback

Loading…
Cancel
Save