diff --git a/assets/textures/inventory_background.png b/assets/textures/inventory_background.png new file mode 100644 index 0000000..9195971 Binary files /dev/null and b/assets/textures/inventory_background.png differ diff --git a/src/game/UILayer.cpp b/src/game/UILayer.cpp index 238a916..a65d0c7 100644 --- a/src/game/UILayer.cpp +++ b/src/game/UILayer.cpp @@ -31,6 +31,7 @@ void UILayer::onAttach() { Layer::onAttach(); AssetManager::loadTexture("background", "assets/textures/texture.png", Loader::instance()); + AssetManager::loadTexture("inventory_background", "assets/textures/inventory_background.png", Loader::instance()); rootContainer = std::make_unique(); @@ -52,7 +53,15 @@ void UILayer::onAttach() { inventoryContainer->addRessource("assets/ui/ressource-icons/bread.png","background", 89, RessourceType::FOOD); inventoryContainer->addRessource("assets/ui/ressource-icons/swords.png", "background",45, RessourceType::SOLDIERS); - inventoryContainerID = rootContainer->addChild(std::move(inventoryContainer)); + auto uiContainer = std::make_unique(); + uiContainer->getLayoutStyle().width = SizeValue(1.f, SizeUnit::Percent); + uiContainer->getLayoutStyle().height = SizeValue(0.1, SizeUnit::Percent); + uiContainer->getLayoutStyle().flexDirection = FlexDirection::Row; + uiContainer->getLayoutStyle().alignItems = AlignItems::Center; + uiContainer->getLayoutStyle().justifyContent = JustifyContent::Center; + + inventoryContainerID = uiContainer->addChild(std::move(inventoryContainer)); + rootContainer->addChild(std::move(uiContainer)); LayoutStyle turnStyle; turnStyle.width = SizeValue(200.f, SizeUnit::Pixels); diff --git a/src/game/ui/components/UiInventoryContainer.cpp b/src/game/ui/components/UiInventoryContainer.cpp index c7f4049..2a01da1 100644 --- a/src/game/ui/components/UiInventoryContainer.cpp +++ b/src/game/ui/components/UiInventoryContainer.cpp @@ -2,4 +2,16 @@ // Created by sebastian on 13.02.26. // -#include "UiInventoryContainer.h" \ No newline at end of file +#include "UiInventoryContainer.h" + +#include "../../../engine/renderer/loader/AssetManager.h" + +void UiInventoryContainer::onCollectRenderData(UiRenderBundle &uiRenderBundle) { + UiComponent::onCollectRenderData(uiRenderBundle); + + GUITextureBuilder textureBuilder; + textureBuilder = textureBuilder.Foreground(AssetManager::getTexture("inventory_background")->getTextureID()); + textureBuilder = textureBuilder.Position(glm::vec2(uiPositioner.screenSpace.x, uiPositioner.screenSpace.y)); + textureBuilder = textureBuilder.Scale(glm::vec2(uiPositioner.screenSpace.width, uiPositioner.screenSpace.height)); + uiRenderBundle.addGUITexture(std::make_shared(textureBuilder.Build())); +} diff --git a/src/game/ui/components/UiInventoryContainer.h b/src/game/ui/components/UiInventoryContainer.h index e7e081f..71f1346 100644 --- a/src/game/ui/components/UiInventoryContainer.h +++ b/src/game/ui/components/UiInventoryContainer.h @@ -15,7 +15,7 @@ class UiInventoryContainer : public UiComponent { public: UiInventoryContainer(Font& font) : font(font) { LayoutStyle containerStyle; - containerStyle.width = SizeValue(1.f, SizeUnit::Percent); + containerStyle.width = SizeValue(0.3f, SizeUnit::Percent); containerStyle.height = SizeValue(80.f, SizeUnit::Pixels); containerStyle.flexDirection = FlexDirection::Row; containerStyle.justifyContent = JustifyContent::Center; @@ -37,6 +37,9 @@ public: } } +protected: + void onCollectRenderData(UiRenderBundle &uiRenderBundle) override; + private: Font& font; std::unordered_map widgets;