OpenMiner/include/hud/Hotbar.hpp

47 lines
989 B
C++
Raw Normal View History

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_
#include <vector>
#include "Inventory.hpp"
#include "ItemWidget.hpp"
2018-06-20 05:43:52 +02:00
class Hotbar : public Widget {
2018-06-20 05:43:52 +02:00
public:
Hotbar(Inventory &inventory, Widget *parent = nullptr);
void onEvent(const SDL_Event &event);
void update();
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 05:43:52 +02:00
private:
void draw(RenderTarget &target, RenderStates states) const override;
Image m_background;
Image m_cursor;
int m_cursorPos = 0;
Inventory &m_inventory;
std::vector<ItemWidget> m_items;
2018-06-20 05:43:52 +02:00
};
#endif // HOTBAR_HPP_