51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
/*
|
|
* =====================================================================================
|
|
*
|
|
* 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"
|
|
#include "SDLHeaders.hpp"
|
|
#include "Shader.hpp"
|
|
|
|
class Hotbar : public Widget {
|
|
public:
|
|
Hotbar(Inventory &inventory);
|
|
|
|
void onEvent(const SDL_Event &event);
|
|
|
|
void update();
|
|
|
|
int cursorPos() const { return m_cursorPos; }
|
|
u16 currentItem() const { return m_inventory.getStack(m_cursorPos, 0).item().id(); }
|
|
|
|
private:
|
|
void draw(RenderTarget &target, RenderStates states) const override;
|
|
|
|
Shader m_shader;
|
|
|
|
Image m_background;
|
|
|
|
Image m_cursor;
|
|
int m_cursorPos = 0;
|
|
|
|
Inventory &m_inventory;
|
|
|
|
std::vector<ItemWidget> m_items;
|
|
};
|
|
|
|
#endif // HOTBAR_HPP_
|