dc8d781393
* Add SFML support besides SDL. Choose with global macro USE_SDL / USE_SFML. + Small fixes to make it compile on MinGW (with Glad instead of GLEW -> option NO_GLEW) * Add SFML support besides SDL (Part 3). Cleaned up some macros. * Add SFML support besides SDL (Part 4). Small SFML fixes. Changed Spaces->Tabs * Add SFML support besides SDL (Part 5). Cleaning up more macros + small fixes. * Port to SFML. Removed all SDL code. * Small changes * Conversion functions to/from SFML types for Vector2/3 and Color. * Removed unused SDL files * Changes for SFML port * Changes for SFML port * Fixed line endings (probably?)
42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
/*
|
|
* =====================================================================================
|
|
*
|
|
* Filename: InventoryWidget.hpp
|
|
*
|
|
* Description:
|
|
*
|
|
* Created: 21/06/2018 01:08:40
|
|
*
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
*
|
|
* =====================================================================================
|
|
*/
|
|
#ifndef INVENTORYWIDGET_HPP_
|
|
#define INVENTORYWIDGET_HPP_
|
|
|
|
#include "MouseItemWidget.hpp"
|
|
#include "RectangleShape.hpp"
|
|
|
|
class InventoryWidget : public Widget {
|
|
public:
|
|
InventoryWidget(Widget *parent = nullptr) : Widget(parent) {}
|
|
|
|
void init(Inventory &inventory, unsigned int offset = 0, unsigned int size = 0);
|
|
|
|
void onMouseEvent(const sf::Event &event, MouseItemWidget &mouseItemWidget, bool isReadOnly = false);
|
|
|
|
const ItemWidget *currentItemWidget() const { return m_currentItemWidget; }
|
|
|
|
private:
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
u16 m_inventoryWidth = 0;
|
|
u16 m_inventoryHeight = 0;
|
|
|
|
std::vector<ItemWidget> m_itemWidgets;
|
|
ItemWidget *m_currentItemWidget = nullptr;
|
|
RectangleShape m_selectedItemBackground{16, 16, Color{255, 255, 255, 80}};
|
|
};
|
|
|
|
#endif // INVENTORYWIDGET_HPP_
|