mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
refactor(debug): add d_rep template and remove widget ID
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "Cubed/ui/label.hpp"
|
||||
#include "Cubed/ui/widget.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Cubed {
|
||||
@@ -23,4 +24,11 @@ private:
|
||||
std::unordered_map<std::string, Label*> m_component;
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
void d_rep(const std::string& key, std::format_string<Args...> fmt,
|
||||
Args&&... args) {
|
||||
std::string msg = std::vformat(fmt.get(), std::make_format_args(args...));
|
||||
DebugCollector::get().report(key, msg);
|
||||
}
|
||||
|
||||
} // namespace Cubed
|
||||
@@ -157,6 +157,36 @@ inline std::string get_cpu_info() {
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::string get_compiler_info() {
|
||||
std::string result;
|
||||
|
||||
#if defined(__clang__)
|
||||
result = "Clang ";
|
||||
result += __clang_version__;
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
result = "GCC ";
|
||||
result += std::to_string(__GNUC__);
|
||||
result += ".";
|
||||
result += std::to_string(__GNUC_MINOR__);
|
||||
result += ".";
|
||||
result += std::to_string(__GNUC_PATCHLEVEL__);
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
result = "MSVC ";
|
||||
result += std::to_string(_MSC_VER);
|
||||
|
||||
#else
|
||||
result = "Unknown Compiler";
|
||||
#endif
|
||||
|
||||
result += " (C++";
|
||||
result += std::to_string(__cplusplus);
|
||||
result += ")";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
} // namespace Cubed
|
||||
|
||||
@@ -10,7 +10,6 @@ public:
|
||||
Label& operator=(const Label&) = delete;
|
||||
Label& operator=(Label&&) = delete;
|
||||
|
||||
Label(const std::string& id, Widget* parent);
|
||||
Label(Widget* parent);
|
||||
virtual ~Label() = default;
|
||||
|
||||
|
||||
@@ -25,12 +25,10 @@ public:
|
||||
Widget& operator=(const Widget&) = delete;
|
||||
Widget& operator=(Widget&&) = delete;
|
||||
|
||||
Widget(const std::string& id, Widget* parent);
|
||||
Widget(Widget* parent);
|
||||
virtual ~Widget() = default;
|
||||
virtual void update(float dt);
|
||||
virtual void render(Renderer& renderer);
|
||||
virtual const std::string& id() const;
|
||||
virtual Widget& set_anchor(Anchor anchor);
|
||||
virtual Widget& set_offset(glm::ivec2 offset);
|
||||
virtual Widget& set_window_size(int width, int height);
|
||||
@@ -58,7 +56,6 @@ public:
|
||||
|
||||
protected:
|
||||
Widget* m_parent = nullptr;
|
||||
std::string m_id;
|
||||
float m_window_height = 0;
|
||||
float m_window_width = 0;
|
||||
// Center is at the top-left corner, position is at the top-left corner
|
||||
|
||||
Reference in New Issue
Block a user