diff --git a/src/engine.cpp b/src/engine.cpp index 31db4537..129dc68d 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -206,7 +206,7 @@ void Engine::renderFrame(Batch2D& batch) { Viewport viewport(Window::width, Window::height); DrawContext ctx(nullptr, viewport, &batch); - gui->draw(&ctx, assets.get()); + gui->draw(ctx, *assets); } void Engine::processPostRunnables() { diff --git a/src/frontend/hud.hpp b/src/frontend/hud.hpp index 580ab54d..5594664a 100644 --- a/src/frontend/hud.hpp +++ b/src/frontend/hud.hpp @@ -95,16 +95,16 @@ class Hud : public util::ObjectsKeeper { /// @brief Inventories interaction agent (grabbed item) std::shared_ptr exchangeSlot; /// @brief Exchange slot inventory (1 slot only) - std::shared_ptr exchangeSlotInv = nullptr; + std::shared_ptr exchangeSlotInv; /// @brief List of all controlled hud elements std::vector elements; /// @brief Player inventory view - std::shared_ptr inventoryView = nullptr; + std::shared_ptr inventoryView; /// @brief Block inventory view - std::shared_ptr blockUI = nullptr; + std::shared_ptr blockUI; /// @brief Secondary inventory view - std::shared_ptr secondInvView = nullptr; + std::shared_ptr secondInvView; /// @brief Position of the block open glm::ivec3 blockPos {}; /// @brief Id of the block open (used to detect block destruction or replacement) @@ -114,9 +114,9 @@ class Hud : public util::ObjectsKeeper { /// @brief Provide cheat controllers to the debug panel bool allowDebugCheats = true; /// @brief UI element will be dynamicly positioned near to inventory or in screen center - std::shared_ptr secondUI = nullptr; + std::shared_ptr secondUI; - std::shared_ptr debugMinimap = nullptr; + std::shared_ptr debugMinimap; std::unique_ptr debugImgWorldGen; diff --git a/src/graphics/ui/GUI.cpp b/src/graphics/ui/GUI.cpp index 40b74a4c..38bc2257 100644 --- a/src/graphics/ui/GUI.cpp +++ b/src/graphics/ui/GUI.cpp @@ -197,18 +197,18 @@ void GUI::act(float delta, const Viewport& vp) { } } -void GUI::draw(const DrawContext* pctx, Assets* assets) { - auto& viewport = pctx->getViewport(); +void GUI::draw(const DrawContext& pctx, const Assets& assets) { + auto& viewport = pctx.getViewport(); glm::vec2 wsize = viewport.size(); menu->setPos((wsize - menu->getSize()) / 2.0f); uicamera->setFov(wsize.y); - auto uishader = assets->get("ui"); + auto uishader = assets.get("ui"); uishader->use(); uishader->uniformMatrix("u_projview", uicamera->getProjView()); - pctx->getBatch2D()->begin(); + pctx.getBatch2D()->begin(); container->draw(pctx, assets); } diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp index b2b20bd0..c0dec649 100644 --- a/src/graphics/ui/GUI.hpp +++ b/src/graphics/ui/GUI.hpp @@ -94,7 +94,7 @@ namespace gui { /// @brief Draw all visible elements on main container /// @param pctx parent graphics context /// @param assets active assets storage - void draw(const DrawContext* pctx, Assets* assets); + void draw(const DrawContext& pctx, const Assets& assets); /// @brief Add element to the main container /// @param node UI element diff --git a/src/graphics/ui/elements/Button.cpp b/src/graphics/ui/elements/Button.cpp index b6a11232..dfdf864d 100644 --- a/src/graphics/ui/elements/Button.cpp +++ b/src/graphics/ui/elements/Button.cpp @@ -52,7 +52,7 @@ Button::Button( void Button::setText(std::wstring text) { if (label) { - label->setText(text); + label->setText(std::move(text)); } } @@ -77,9 +77,9 @@ void Button::refresh() { } } -void Button::drawBackground(const DrawContext* pctx, Assets*) { +void Button::drawBackground(const DrawContext& pctx, const Assets&) { glm::vec2 pos = calcPos(); - auto batch = pctx->getBatch2D(); + auto batch = pctx.getBatch2D(); batch->texture(nullptr); batch->setColor(calcColor()); batch->rect(pos.x, pos.y, size.x, size.y); diff --git a/src/graphics/ui/elements/Button.hpp b/src/graphics/ui/elements/Button.hpp index 61bfea03..39b23426 100644 --- a/src/graphics/ui/elements/Button.hpp +++ b/src/graphics/ui/elements/Button.hpp @@ -7,7 +7,7 @@ namespace gui { class Button : public Panel { protected: - std::shared_ptr