diff --git a/CMakeLists.txt b/CMakeLists.txt index b1bb158..13a3cc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,6 @@ FetchContent_Declare( GIT_REPOSITORY "https://github.com/marovira/lua" GIT_TAG "5.4.4" ) - FetchContent_MakeAvailable(lua) set(LUA_BUILD_INTERPRETER ON CACHE BOOL "Build the Lua interpreter" FORCE) @@ -144,8 +143,6 @@ if (NOT raylib_FOUND) # If there's none, fetch and build raylib endif() endif() -put_targets_into_folder(FOLDER "raylib" TARGETS raylib uninstall) - target_link_libraries(${GUI_TARGET_NAME} PRIVATE raylib) # Checks if OSX and links appropriate frameworks (Only required on MacOS) @@ -157,11 +154,50 @@ endif() set_common_properties(${GUI_TARGET_NAME}) +# ============= +# spdlog +# ============= +set(SPDLOG_NO_EXCEPTIONS ON CACHE BOOL "" FORCE) + +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.15.0 +) +FetchContent_MakeAvailable(spdlog) +target_link_libraries(${GUI_TARGET_NAME} PRIVATE spdlog) + +put_targets_into_folder( + FOLDER "ThirdParty/spdlog" + TARGETS + spdlog +) + +put_targets_into_folder( + FOLDER "ThirdParty/raylib" + TARGETS + raylib uninstall +) + +put_targets_into_folder( + FOLDER "ThirdParty/lua" + TARGETS + lua lua_lib +) + +put_targets_into_folder( + FOLDER "ThirdParty/glfw" + TARGETS + glfw update_mappings +) + + + # Option to create an includes target set(SVA_CREATE_INCLUDES_TARGET ON CACHE BOOL "Create an includes target") if(${SVA_CREATE_INCLUDES_TARGET}) - set(INCLUDES_TARGET_NAME "${GUI_TARGET_NAME}_includes") + set(INCLUDES_TARGET_NAME "includes") set(INCLUDE_FILES) find_files( INCLUDE_FILES @@ -173,11 +209,4 @@ if(${SVA_CREATE_INCLUDES_TARGET}) SOURCES ${INCLUDE_FILES} ) - set_target_properties(${INCLUDES_TARGET_NAME} PROPERTIES FOLDER "sva") endif() - -put_targets_into_folder( - FOLDER "sva" - TARGETS - ${TEST_TARGET_NAME} -) diff --git a/include/logger.hpp b/include/logger.hpp deleted file mode 100644 index 7f56393..0000000 --- a/include/logger.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace sva -{ - class Logging - { - std::unordered_map m_Level_Names; - size_t m_Active_Level; - std::ostream& m_Stream; - public: - Logging(std::ostream& stream); - - template requires std::is_enum_v - std::string& levelName(const T lvl) - { - return m_Level_Names[static_cast(lvl)]; - } - - template - Logging& logln(Args&& ...args) - { - m_Stream << " [" << m_Level_Names[m_Active_Level] << "] " << (std::forward(args) << ...) << std::endl; - return *this; - } - - template requires std::is_enum_v - Logging& operator()(const T lvl) - { - try - { - std::string& lvn = m_Level_Names.at(static_cast(lvl)); - } - catch (...) - { - return *this; - } - m_Active_Level = static_cast(lvl); - return *this; - } - }; -} - - - -#ifdef SVA_LOGGING_IMPLEMENTATION -#undef SVA_LOGGING_IMPLEMENTATION - -sva::Logging::Logging(std::ostream& stream) : m_Active_Level(0), m_Stream(stream) -{ - m_Level_Names[0] = "General"; -} -#endif \ No newline at end of file diff --git a/src/libimpl.cpp b/src/libimpl.cpp index c0767ff..3052e1a 100644 --- a/src/libimpl.cpp +++ b/src/libimpl.cpp @@ -1,5 +1,2 @@ #define RAYGUI_IMPLEMENTATION -#include - -#define SVA_LOGGING_IMPLEMENTATION -#include \ No newline at end of file +#include \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index f2562ae..cc98140 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,15 +15,16 @@ #include -// sva logger -#include /* raylib includes */ #include +#include #include "gui/ComponentStack.hpp" #include "gui/CoreComponents.hpp" +#include + constexpr int window_width = 800; constexpr int window_height = 650; constexpr char window_title[] = "Sortiva"; @@ -39,14 +40,12 @@ enum class logerr_level int main(void) { - std::cout << "Darling, I'm Home!\n"; - - sva::Logging logerr = sva::Logging(std::cerr); - logerr.levelName(logerr_level::Debug) = "Debug"; - logerr.levelName(logerr_level::Window) = "Window"; - logerr.levelName(logerr_level::SVA) = "SVA"; - - logerr(logerr_level::Debug); +#ifdef _DEBUG + spdlog::set_level(spdlog::level::debug); + spdlog::set_pattern("\n\t%^%v%$\n"); +#endif + spdlog::debug("Darling, I'm Home"); + spdlog::set_pattern("[%T %z] [%^%l%$] [thread %t] %v"); /* Window and rendering */ @@ -54,7 +53,7 @@ int main(void) if (!IsWindowReady()) { - logerr(logerr_level::Window).logln("Window could not be created..."); + spdlog::critical("Window could not be created..."); return 0; } @@ -63,9 +62,11 @@ int main(void) SetWindowFocused(); + spdlog::debug("Window created successfully."); - bool m_Running = true; - ComponentStack::s_WndRunning = &m_Running; + + bool is_running = true; + ComponentStack::s_WndRunning = &is_running; ComponentStack::s_WndWidth = GetRenderWidth(); ComponentStack::s_WndHeight = GetRenderHeight(); @@ -76,11 +77,11 @@ int main(void) // always on top... SafeClosePopup safe_close_popup; - safe_close_popup.attach(&m_Running); + safe_close_popup.attach(&is_running); safe_close_popup.wndrsize(ComponentStack::s_WndWidth, ComponentStack::s_WndHeight); - while (m_Running) { + while (is_running) { if (IsWindowResized()) @@ -113,7 +114,7 @@ int main(void) switch (run_result) { case 2: - logerr(logerr_level::SVA).logln("Program exiting abnormally."); + spdlog::warn("Program exiting abnormally."); break; default: break;