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_
|
|
|
|
|
2019-01-05 18:37:59 +01:00
|
|
|
#include <gk/graphics/RectangleShape.hpp>
|
2018-12-29 02:23:23 +01:00
|
|
|
|
2018-06-23 01:32:23 +02:00
|
|
|
#include "MouseItemWidget.hpp"
|
2018-06-21 01:32:55 +02:00
|
|
|
|
2019-04-08 12:59:02 +02:00
|
|
|
class ClientCommandHandler;
|
2019-01-26 20:29:13 +01:00
|
|
|
|
2018-06-21 09:00:53 +02:00
|
|
|
class InventoryWidget : public Widget {
|
2018-06-21 01:32:55 +02:00
|
|
|
public:
|
2019-04-08 12:59:02 +02:00
|
|
|
InventoryWidget(ClientCommandHandler &client, Widget *parent = nullptr)
|
2019-01-26 20:29:13 +01:00
|
|
|
: Widget(parent), m_client(client) {}
|
2018-06-21 09:00:53 +02:00
|
|
|
|
2018-06-29 08:56:59 +02:00
|
|
|
void init(Inventory &inventory, unsigned int offset = 0, unsigned int size = 0);
|
2018-06-21 09:00:53 +02:00
|
|
|
|
2018-12-28 06:19:40 +01: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:
|
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
|
|
|
|
2019-04-07 16:23:48 +02:00
|
|
|
void sendUpdatePacket();
|
|
|
|
|
2019-04-08 12:59:02 +02:00
|
|
|
ClientCommandHandler &m_client;
|
2019-01-26 20:29:13 +01:00
|
|
|
|
|
|
|
Inventory *m_inventory = nullptr;
|
|
|
|
|
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-12-29 02:23:23 +01:00
|
|
|
|
|
|
|
gk::RectangleShape m_selectedItemBackground{16, 16, gk::Color{255, 255, 255, 80}};
|
2018-06-21 01:32:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INVENTORYWIDGET_HPP_
|