2018-06-21 01:32:55 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: ItemWidget.hpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 21/06/2018 01:10:13
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef ITEMWIDGET_HPP_
|
|
|
|
#define ITEMWIDGET_HPP_
|
|
|
|
|
2019-01-05 18:37:59 +01:00
|
|
|
#include <gk/graphics/Image.hpp>
|
2018-12-29 02:23:23 +01:00
|
|
|
|
2018-06-26 01:35:19 +02:00
|
|
|
#include "Cube.hpp"
|
2018-06-23 03:26:34 +02:00
|
|
|
#include "Inventory.hpp"
|
2018-06-24 03:17:06 +02:00
|
|
|
#include "Text.hpp"
|
2018-06-21 09:00:53 +02:00
|
|
|
#include "Widget.hpp"
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2018-06-21 09:00:53 +02:00
|
|
|
class ItemWidget : public Widget {
|
2018-06-21 01:32:55 +02:00
|
|
|
public:
|
2018-06-23 03:26:34 +02:00
|
|
|
ItemWidget(Inventory &inventory, u16 x, u16 y, Widget *parent = nullptr);
|
2018-06-21 09:00:53 +02:00
|
|
|
|
2018-06-27 05:39:56 +02:00
|
|
|
void update() override;
|
2018-06-23 03:26:34 +02:00
|
|
|
|
2018-06-24 03:17:06 +02:00
|
|
|
const ItemStack &stack() const { return m_inventory.getStack(m_x, m_y); }
|
2018-12-28 21:23:26 +01:00
|
|
|
void setStack(const std::string &name, unsigned int amount = 1);
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2018-06-25 22:30:38 +02:00
|
|
|
protected:
|
2018-12-29 02:23:23 +01:00
|
|
|
void draw(gk::RenderTarget &target, gk::RenderStates states) const override;
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2018-06-25 22:30:38 +02:00
|
|
|
private:
|
2018-06-23 03:26:34 +02:00
|
|
|
Inventory &m_inventory;
|
|
|
|
|
|
|
|
unsigned int m_x = 0;
|
|
|
|
unsigned int m_y = 0;
|
2018-06-21 12:55:31 +02:00
|
|
|
|
2020-01-30 15:31:49 +09:00
|
|
|
TextureAtlas &m_textureAtlas;
|
|
|
|
|
2018-12-29 02:23:23 +01:00
|
|
|
gk::Image m_image;
|
2018-06-24 03:17:06 +02:00
|
|
|
Text m_text;
|
2018-06-26 01:35:19 +02:00
|
|
|
|
2018-06-26 23:33:01 +02:00
|
|
|
Cube m_cube{10};
|
2018-06-21 01:32:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ITEMWIDGET_HPP_
|