OpenMiner/client/source/states/InventoryState.cpp

66 lines
1.5 KiB
C++
Raw Normal View History

/*
* =====================================================================================
*
* Filename: InventoryState.cpp
*
* Description:
*
* Created: 20/06/2018 23:13:50
*
* Author: Quentin Bazin, <quent42340@gmail.com>
*
* =====================================================================================
*/
2019-01-20 01:31:44 +01:00
#include <glm/gtc/matrix_transform.hpp>
2018-12-29 02:23:23 +01:00
#include <gk/core/ApplicationStateStack.hpp>
#include <gk/core/Mouse.hpp>
#include "InventoryState.hpp"
InventoryState::InventoryState(gk::ApplicationState *parent) : InterfaceState(parent) {
2018-12-29 02:23:23 +01:00
gk::Mouse::setCursorGrabbed(false);
gk::Mouse::setCursorVisible(true);
gk::Mouse::resetToWindowCenter();
2019-04-13 15:06:52 +02:00
m_background.setFillColor(gk::Color{0, 0, 0, 127});
m_background.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
}
void InventoryState::onEvent(const SDL_Event &event) {
// if (m_parent)
// m_parent->onEvent(event);
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) {
2018-12-29 02:23:23 +01:00
gk::Mouse::setCursorGrabbed(true);
gk::Mouse::setCursorVisible(false);
gk::Mouse::resetToWindowCenter();
m_stateStack->pop();
}
if (m_widget)
m_widget->onEvent(event);
}
void InventoryState::update() {
if (m_parent)
m_parent->update();
2018-06-25 03:49:53 +02:00
if (m_widget)
m_widget->update();
}
2018-12-29 02:23:23 +01:00
void InventoryState::draw(gk::RenderTarget &target, gk::RenderStates states) const {
if (m_parent)
target.draw(*m_parent, states);
prepareDraw(target, states);
target.draw(m_background, states);
if (m_widget)
target.draw(*m_widget, states);
}