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?)
49 lines
1023 B
C++
49 lines
1023 B
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 <SFML/Window/Event.hpp>
|
|
|
|
#include "Inventory.hpp"
|
|
#include "ItemWidget.hpp"
|
|
|
|
class Hotbar : public Widget {
|
|
public:
|
|
Hotbar(Inventory &inventory, Widget *parent = nullptr);
|
|
|
|
void onEvent(const sf::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;
|
|
|
|
Image m_background;
|
|
|
|
Image m_cursor;
|
|
int m_cursorPos = 0;
|
|
|
|
Inventory &m_inventory;
|
|
|
|
std::vector<ItemWidget> m_items;
|
|
};
|
|
|
|
#endif // HOTBAR_HPP_
|