diff --git a/include/blt/std/time.h b/include/blt/std/time.h index 247bedb..9601159 100644 --- a/include/blt/std/time.h +++ b/include/blt/std/time.h @@ -14,9 +14,9 @@ namespace blt::system { #ifdef WIN32 - #define TIME_FUNC tm now{}; localtime_s(&now, &t) + #define BLT_TIME_FUNC(name) auto t = std::time(nullptr); tm name{}; localtime_s(&name, &t) #else - #define TIME_FUNC auto now_ptr = std::localtime(&t); auto& now = *now_ptr + #define BLT_TIME_FUNC(name) auto t = std::time(nullptr); auto ptr_##name = std::localtime(&t); auto& name = *ptr_##name #endif static inline std::string ensureHasDigits(int current, int digits) @@ -90,9 +90,7 @@ namespace blt::system */ static inline std::string getTimeString() { - auto t = std::time(nullptr); - TIME_FUNC; - //auto now = std::localtime(&t); + BLT_TIME_FUNC(now); std::stringstream timeString; timeString << (1900 + now.tm_year); timeString << "-"; @@ -115,9 +113,7 @@ namespace blt::system */ static inline std::string getTimeStringLog() { - auto t = std::time(nullptr); - TIME_FUNC; - //auto now = std::localtime(&t); + BLT_TIME_FUNC(now); std::string timeString = "["; timeString += ensureHasDigits(now.tm_hour, 2); timeString += ":"; @@ -133,9 +129,7 @@ namespace blt::system */ static inline std::string getTimeStringFS() { - auto t = std::time(nullptr); - TIME_FUNC; - //auto now = std::localtime(&t); + BLT_TIME_FUNC(now); std::stringstream timeString; timeString << (1900 + now.tm_year); timeString << "-"; diff --git a/include/blt/window/window.h b/include/blt/window/window.h deleted file mode 100644 index 1ade406..0000000 --- a/include/blt/window/window.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Created by Brett on 16/01/23. - * Licensed under GNU General Public License V3.0 - * See LICENSE file for license detail - */ - -#ifndef BLT_WINDOW_H -#define BLT_WINDOW_H - -#include -#include - -#ifndef BLT_MAP_FUNC - #include - #define BLT_MAP_FUNC std::unordered_map -#endif - -#define KEY_MAP BLT_MAP_FUNC - -namespace blt { - -class window { - protected: - bool m_windowOpen = true; - int m_width = 800, m_height = 600; - - std::vector> renderFunctions{}; - std::vector> keyListeners{}; - std::vector> mouseListeners{}; - - KEY_MAP keysDown{}; - KEY_MAP mouseDown{}; - public: - window() = default; - window(int width_, int height_) { - m_width = width_; - m_height = height_; - } - virtual void createWindow() = 0; - virtual void startMainLoop() = 0; - virtual void destroyWindow() = 0; - virtual ~window() = 0; - - virtual inline bool setResizeable(bool resizeEnabled) = 0; - virtual inline bool setWindowSize(int width_, int height_) = 0; - [[nodiscard]] inline int getWidth() const {return m_width;}; - [[nodiscard]] inline int getHeight() const {return m_height;}; - - [[nodiscard]] virtual inline bool isWindowOpen() const {return m_windowOpen;}; - virtual inline void closeWindow(){ - m_windowOpen = false; - } - virtual inline void registerLoopFunction(const std::function& func) { - renderFunctions.push_back(func); - } - - virtual inline bool isKeyDown(int key) const { return keysDown.at(key); } - virtual inline bool isMouseDown(int button) const {return mouseDown.at(button);}; - // Function signature is window pointer to this, key press, pressed/released (true/false) - virtual inline void registerKeyListener(const std::function& listener) { - keyListeners.push_back(listener); - } - // Function signature is window pointer to this, mouse button press, pressed/released (true/false) - virtual inline void registerMouseListener(const std::function& listener) { - mouseListeners.push_back(listener); - } -}; - -} - -#endif \ No newline at end of file