1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 18:32:44 +01:00
openrw/rwgame/State.cpp

59 lines
927 B
C++
Raw Normal View History

#include "State.hpp"
#include "RWGame.hpp"
// This serves as the "initial" camera position.
ViewCamera defaultView({-250.f, -550.f, 75.f}, glm::angleAxis(glm::radians(5.f), glm::vec3(0.f, 1.f, 0.f)));
void State::handleEvent(const SDL_Event& e)
{
auto m = getCurrentMenu();
if(!m) return;
switch(e.type) {
case SDL_MOUSEBUTTONUP:
if (e.button.button == SDL_BUTTON_LEFT)
m->click(e.button.x, e.button.y);
break;
case SDL_MOUSEMOTION:
m->hover(e.motion.x, e.motion.y);
break;
case SDL_KEYDOWN:
switch (e.key.keysym.sym) {
case SDLK_UP:
m->move(-1);
break;
case SDLK_DOWN:
m->move(1);
break;
case SDLK_RETURN:
m->activate();
break;
}
}
}
const ViewCamera& State::getCamera()
{
return defaultView;
}
bool State::shouldWorldUpdate()
{
return false;
}
GameWorld* State::getWorld()
{
return game->getWorld();
}
GameWindow& State::getWindow()
{
return game->getWindow();
}