diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 5cc16119..6ddc6744 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -192,7 +192,7 @@ Hud::Hud(Engine& engine, LevelFrontend& frontend, Player& player) gui.add(contentAccessPanel); auto dplotter = std::make_shared(gui, 350, 250, 2000, 16); - dplotter->setGravity(Gravity::bottom_right); + dplotter->setGravity(Gravity::BOTTOM_RIGHT); dplotter->setInteractive(false); add(HudElement(HudElementMode::PERMANENT, nullptr, dplotter, true)); diff --git a/src/graphics/core/ImageData.cpp b/src/graphics/core/ImageData.cpp index bd243832..218428e7 100644 --- a/src/graphics/core/ImageData.cpp +++ b/src/graphics/core/ImageData.cpp @@ -470,6 +470,32 @@ void ImageData::addColor(const ImageData& other, int multiplier) { } } +void ImageData::extend(int newWidth, int newHeight) { + size_t comps; + switch (format) { + case ImageFormat::rgb888: comps = 3; break; + case ImageFormat::rgba8888: comps = 4; break; + default: + throw std::runtime_error("only unsigned byte formats supported"); + } + auto newData = std::make_unique(newWidth * newHeight * comps); + for (uint y = 0; y < newHeight; y++) { + for (uint x = 0; x < newWidth; x++) { + for (size_t c = 0; c < comps; c++) { + if (x < width && y < height) { + newData[(y * newWidth + x) * comps + c] = + data[(y * width + x) * comps + c]; + } else { + newData[(y * newWidth + x) * comps + c] = 0; + } + } + } + } + data = std::move(newData); + width = newWidth; + height = newHeight; +} + void ImageData::addColor(const glm::ivec4& color, int multiplier) { uint comps; switch (format) { diff --git a/src/graphics/core/ImageData.hpp b/src/graphics/core/ImageData.hpp index a1597a98..94987886 100644 --- a/src/graphics/core/ImageData.hpp +++ b/src/graphics/core/ImageData.hpp @@ -36,6 +36,7 @@ public: void mulColor(const ImageData& other); void addColor(const glm::ivec4& color, int multiplier); void addColor(const ImageData& other, int multiplier); + void extend(int newWidth, int newHeight); std::unique_ptr cropped(int x, int y, int width, int height) const; diff --git a/src/graphics/core/Texture.cpp b/src/graphics/core/Texture.cpp index 04285aa8..dcd29e37 100644 --- a/src/graphics/core/Texture.cpp +++ b/src/graphics/core/Texture.cpp @@ -44,10 +44,10 @@ void Texture::unbind() const { void Texture::reload(const ImageData& image) { width = image.getWidth(); height = image.getHeight(); - reload(image.getData()); + reload(image.getData(), width, height); } -void Texture::reload(const ubyte* data) { +void Texture::reload(const ubyte* data, uint width, uint height) { glBindTexture(GL_TEXTURE_2D, id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, static_cast(data)); diff --git a/src/graphics/core/Texture.hpp b/src/graphics/core/Texture.hpp index 5e67890c..3c8f1b4c 100644 --- a/src/graphics/core/Texture.hpp +++ b/src/graphics/core/Texture.hpp @@ -18,7 +18,7 @@ public: virtual void bind() const; virtual void unbind() const; - void reload(const ubyte* data); + void reload(const ubyte* data, uint w, uint h); void reloadPartial(const ImageData& image, uint x, uint y, uint w, uint h); void setNearestFilter(); diff --git a/src/graphics/ui/elements/BasePanel.hpp b/src/graphics/ui/elements/BasePanel.hpp index 08761050..168776a9 100644 --- a/src/graphics/ui/elements/BasePanel.hpp +++ b/src/graphics/ui/elements/BasePanel.hpp @@ -30,14 +30,14 @@ namespace gui { glm::vec2 size, glm::vec4 padding = glm::vec4(0.0f), float interval = 2.0f, - Orientation orientation = Orientation::vertical + Orientation orientation = Orientation::VERTICAL ) : Container(gui, std::move(size)), padding(std::move(padding)), interval(interval) { } - Orientation orientation = Orientation::vertical; + Orientation orientation = Orientation::VERTICAL; glm::vec4 padding; float interval = 2.0f; }; diff --git a/src/graphics/ui/elements/Button.cpp b/src/graphics/ui/elements/Button.cpp index ef2142ea..2fe6fc6a 100644 --- a/src/graphics/ui/elements/Button.cpp +++ b/src/graphics/ui/elements/Button.cpp @@ -31,7 +31,7 @@ Button::Button( GUI& gui, const std::wstring& text, glm::vec4 padding, - const onaction& action, + const OnAction& action, glm::vec2 size ) : Panel(gui, size, padding, 0.0f) { @@ -42,12 +42,12 @@ Button::Button( } if (action) { - listenAction(action); + listenClick(action); } setScrollable(false); label = std::make_shared