2018-06-21 01:32:55 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: InventoryWidget.hpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 21/06/2018 01:08:40
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef INVENTORYWIDGET_HPP_
|
|
|
|
#define INVENTORYWIDGET_HPP_
|
|
|
|
|
2018-06-23 01:32:23 +02:00
|
|
|
#include "MouseItemWidget.hpp"
|
2018-06-25 23:37:24 +02:00
|
|
|
#include "RectangleShape.hpp"
|
2018-06-21 09:00:53 +02:00
|
|
|
#include "SDLHeaders.hpp"
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2018-06-21 09:00:53 +02:00
|
|
|
class InventoryWidget : public Widget {
|
2018-06-21 01:32:55 +02:00
|
|
|
public:
|
2018-06-21 09:00:53 +02:00
|
|
|
InventoryWidget(Widget *parent = nullptr) : Widget(parent) {}
|
|
|
|
|
2018-06-23 03:26:34 +02:00
|
|
|
void init(Inventory &inventory);
|
2018-06-21 09:00:53 +02:00
|
|
|
|
2018-06-27 05:39:56 +02:00
|
|
|
void onMouseEvent(const SDL_Event &event, MouseItemWidget &mouseItemWidget, bool isReadOnly = false);
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2018-06-25 22:30:38 +02:00
|
|
|
const ItemWidget *currentItemWidget() const { return m_currentItemWidget; }
|
|
|
|
|
2018-06-21 01:32:55 +02:00
|
|
|
private:
|
|
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
|
2018-06-21 12:55:31 +02:00
|
|
|
u16 m_inventoryWidth = 0;
|
|
|
|
u16 m_inventoryHeight = 0;
|
|
|
|
|
2018-06-21 01:32:55 +02:00
|
|
|
std::vector<ItemWidget> m_itemWidgets;
|
2018-06-25 22:30:38 +02:00
|
|
|
ItemWidget *m_currentItemWidget = nullptr;
|
2018-06-25 23:37:24 +02:00
|
|
|
RectangleShape m_selectedItemBackground{16, 16, Color{255, 255, 255, 80}};
|
2018-06-21 01:32:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INVENTORYWIDGET_HPP_
|