2018-06-20 05:43:52 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: Hotbar.hpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 20/06/2018 05:40:05
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef HOTBAR_HPP_
|
|
|
|
#define HOTBAR_HPP_
|
|
|
|
|
2018-06-20 07:47:40 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2018-06-23 03:26:34 +02:00
|
|
|
#include "Inventory.hpp"
|
2018-06-21 06:08:31 +02:00
|
|
|
#include "ItemWidget.hpp"
|
2018-06-20 05:43:52 +02:00
|
|
|
|
2018-06-26 23:33:01 +02:00
|
|
|
class Hotbar : public Widget {
|
2018-06-20 05:43:52 +02:00
|
|
|
public:
|
2018-07-06 15:08:13 +02:00
|
|
|
Hotbar(Inventory &inventory, Widget *parent = nullptr);
|
2018-06-23 03:26:34 +02:00
|
|
|
|
2018-12-28 06:19:40 +01:00
|
|
|
void onEvent(const SDL_Event &event);
|
2018-06-20 07:47:40 +02:00
|
|
|
|
2018-06-26 23:33:01 +02:00
|
|
|
void update();
|
|
|
|
|
2018-06-24 21:01:12 +02:00
|
|
|
int cursorPos() const { return m_cursorPos; }
|
2018-06-24 01:42:06 +02:00
|
|
|
u16 currentItem() const { return m_inventory.getStack(m_cursorPos, 0).item().id(); }
|
2018-06-20 07:47:40 +02:00
|
|
|
|
2018-06-20 05:43:52 +02:00
|
|
|
private:
|
|
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
|
|
|
|
Image m_background;
|
2018-06-20 07:47:40 +02:00
|
|
|
|
|
|
|
Image m_cursor;
|
|
|
|
int m_cursorPos = 0;
|
|
|
|
|
2018-06-23 03:26:34 +02:00
|
|
|
Inventory &m_inventory;
|
|
|
|
|
2018-06-21 06:08:31 +02:00
|
|
|
std::vector<ItemWidget> m_items;
|
2018-06-20 05:43:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // HOTBAR_HPP_
|