You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB
C++

#ifndef INVENTORYMANAGER_H
#define INVENTORYMANAGER_H
#include <memory>
#include <QGraphicsColorizeEffect>
/* QWInventoryManager
* Controls everything related to inventory slots and their items. */
class QGraphicsWidget;
class QWScene;
class QWTrigger;
class QWInventoryManager final : public QObject
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(QWInventoryManager)
private:
QList<std::shared_ptr<QWTrigger>> list_inventory_icons;
std::shared_ptr<QGraphicsWidget> ptr_panel;
QWScene *ptr_scene;
QRect rect_hidden;
QRect rect_visible;
using Index = QList<std::shared_ptr<QWTrigger>>::size_type;
Index index_freepan;
QGraphicsColorizeEffect *item_selected_effect;
struct metadata
{
// the separator thinkness
int length_wall;
// the cell side
int length_cell;
// the maximum amount of items to hold
int max_amount;
// the left wall of first item slot
int first_wall;
// the color for selected items
QColor clr_sel;
// the color for selected items
qreal clr_sth;
} metadata;
void reorganizeItems(Index i);
public:
explicit QWInventoryManager(QWScene *sc);
void setInventoryPanel(const std::shared_ptr<QGraphicsWidget> &panel) noexcept;
inline int freePanel() const noexcept;
inline void freePanelToRight();
inline void freePanelToLeft();
void addInventoryIcon(std::shared_ptr<QWTrigger> &inventory_icon);
void removeInventoryIcon(std::shared_ptr<QWTrigger> &inventory_icon);
public slots:
void onClicked();
};
#endif // INVENTORYMANAGER_H