ADD: Background of InventoryContainer
This commit is contained in:
parent
5804ed15ee
commit
10a495c205
BIN
assets/textures/inventory_background.png
Normal file
BIN
assets/textures/inventory_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
@ -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<UiContainer>();
|
||||
@ -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>();
|
||||
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);
|
||||
|
||||
@ -2,4 +2,16 @@
|
||||
// Created by sebastian on 13.02.26.
|
||||
//
|
||||
|
||||
#include "UiInventoryContainer.h"
|
||||
#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<GUITexture>(textureBuilder.Build()));
|
||||
}
|
||||
|
||||
@ -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<RessourceType, UiRessourceWidget*> widgets;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user