diff --git a/src/coders/yaml.cpp b/src/coders/yaml.cpp index a9944ea3..b10d5ce2 100644 --- a/src/coders/yaml.cpp +++ b/src/coders/yaml.cpp @@ -308,7 +308,7 @@ dv::value Parser::parseObject(dv::value&& object, int indent) { object[std::string(name)] = parseFullValue(indent); skipEmptyLines(); } - return object; + return std::move(object); } dv::value yaml::parse(std::string_view filename, std::string_view source) { diff --git a/src/debug/Logger.cpp b/src/debug/Logger.cpp index 970b2102..12d8975a 100644 --- a/src/debug/Logger.cpp +++ b/src/debug/Logger.cpp @@ -2,25 +2,24 @@ #include #include +#include #include #include +#include #include using namespace debug; -std::ofstream Logger::file; -std::mutex Logger::mutex; -std::string Logger::utcOffset = ""; -unsigned Logger::moduleLen = 20; +static std::ofstream file; +static std::mutex mutex; +static std::string utcOffset = ""; +constexpr unsigned int moduleLen = 20; LogMessage::~LogMessage() { logger->log(level, ss.str()); } -Logger::Logger(std::string name) : name(std::move(name)) { -} - -void Logger::log( +static void write( LogLevel level, const std::string& name, const std::string& message ) { if (level == LogLevel::print) { @@ -84,5 +83,5 @@ void Logger::flush() { } void Logger::log(LogLevel level, std::string message) { - log(level, name, std::move(message)); + write(level, name, std::move(message)); } diff --git a/src/debug/Logger.hpp b/src/debug/Logger.hpp index 9505affd..598dc4ef 100644 --- a/src/debug/Logger.hpp +++ b/src/debug/Logger.hpp @@ -1,7 +1,5 @@ #pragma once -#include -#include #include namespace debug { @@ -27,24 +25,16 @@ namespace debug { }; class Logger { - static std::mutex mutex; - static std::string utcOffset; - static std::ofstream file; - static unsigned moduleLen; - std::string name; - - static void log( - LogLevel level, const std::string& name, const std::string& message - ); public: static void init(const std::string& filename); static void flush(); - Logger(std::string name); + Logger(const std::string& name) : name(name) { + } void log(LogLevel level, std::string message); - + LogMessage debug() { return LogMessage(this, LogLevel::debug); } @@ -60,7 +50,7 @@ namespace debug { LogMessage warning() { return LogMessage(this, LogLevel::warning); } - + /// @brief Print-debugging tool (printed without header) LogMessage print() { return LogMessage(this, LogLevel::print); diff --git a/src/graphics/core/Batch2D.cpp b/src/graphics/core/Batch2D.cpp index 0db15c4b..b39866ce 100644 --- a/src/graphics/core/Batch2D.cpp +++ b/src/graphics/core/Batch2D.cpp @@ -333,6 +333,15 @@ void Batch2D::rect( vertex(v1, glm::vec2(0, 0), r2,g2,b2,1.0f); } +void Batch2D::triangle(float x1, float y1, float x2, float y2, float x3, float y3) { + if (index + 3 >= capacity) { + flush(); + } + vertex({x1, y1}, {x1, y1}, color.r, color.g, color.b, color.a); + vertex({x2, y2}, {x2, y2}, color.r, color.g, color.b, color.a); + vertex({x3, y3}, {x3, y3}, color.r, color.g, color.b, color.a); +} + void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint){ rect(x, y, w, h, region.u1, region.v1, region.u2-region.u1, region.v2-region.v1, tint.r, tint.g, tint.b, tint.a); } diff --git a/src/graphics/core/Batch2D.hpp b/src/graphics/core/Batch2D.hpp index 6f29a1df..ec181a6f 100644 --- a/src/graphics/core/Batch2D.hpp +++ b/src/graphics/core/Batch2D.hpp @@ -117,6 +117,8 @@ public: float r4, float g4, float b4, int sh ); + void triangle(float x1, float y1, float x2, float y2, float x3, float y3); + void flush() override; void lineWidth(float width); diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp index c8bb20e2..92e58db5 100644 --- a/src/graphics/ui/GUI.hpp +++ b/src/graphics/ui/GUI.hpp @@ -89,6 +89,8 @@ namespace gui { void updateTooltip(float delta); void resetTooltip(); public: + static constexpr int CONTEXT_MENU_ZINDEX = 999; + GUI(Engine& engine); ~GUI(); diff --git a/src/graphics/ui/elements/Button.cpp b/src/graphics/ui/elements/Button.cpp index bb531889..ef2142ea 100644 --- a/src/graphics/ui/elements/Button.cpp +++ b/src/graphics/ui/elements/Button.cpp @@ -34,14 +34,12 @@ Button::Button( const onaction& action, glm::vec2 size ) - : Panel(gui, size, padding, 0) { - if (size.y < 0.0f) { - size = glm::vec2( - glm::max(padding.x + padding.z + text.length() * 8, size.x), - glm::max(padding.y + padding.w + 16, size.y) - ); + : Panel(gui, size, padding, 0.0f) { + if (size.x < 0.0f || size.y < 0.0f) { + setContentSize({text.length() * 8, 16}); + } else { + setSize(size); } - setSize(size); if (action) { listenAction(action); @@ -50,13 +48,12 @@ Button::Button( label = std::make_shared