1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 03:12:36 +01:00
openrw/rwgame/State.hpp

70 lines
1.2 KiB
C++
Raw Normal View History

#ifndef RWGAME_STATE_HPP
#define RWGAME_STATE_HPP
2013-12-27 00:18:55 +01:00
#include "MenuSystem.hpp"
#include <SDL_events.h>
2013-12-27 00:18:55 +01:00
2018-12-09 22:43:42 +01:00
#include <memory>
#include <optional>
#include <utility>
class RWGame;
class GameWorld;
2018-12-09 22:43:42 +01:00
class GameRenderer;
class GameWindow;
class Menu;
class StateManager;
2018-12-09 22:43:42 +01:00
class ViewCamera;
class State {
public:
2016-09-09 22:13:20 +02:00
RWGame* game;
2018-12-26 21:48:16 +01:00
State(RWGame* game);
2016-09-09 22:13:20 +02:00
virtual void enter() = 0;
virtual void exit() = 0;
virtual void tick(float dt) = 0;
2018-12-01 18:57:06 +01:00
virtual void draw(GameRenderer& r);
2016-09-09 22:13:20 +02:00
2018-02-18 01:06:39 +01:00
virtual ~State() = default;
2016-09-09 22:13:20 +02:00
template<typename T>
2018-12-26 21:48:16 +01:00
void setNextMenu(T&& menu) {
nextMenu = std::forward<T>(menu);
2016-09-09 22:13:20 +02:00
}
2018-12-26 21:48:16 +01:00
std::optional<Menu>& getCurrentMenu();
2016-09-09 22:13:20 +02:00
virtual void handleEvent(const SDL_Event& e);
virtual const ViewCamera& getCamera(float alpha);
2016-09-09 22:13:20 +02:00
/**
* Returns false if the game world should not should
* not update while this state is active
*/
virtual bool shouldWorldUpdate();
GameWorld* getWorld() const;
2016-09-09 22:13:20 +02:00
GameWindow& getWindow();
2018-12-26 21:48:16 +01:00
bool hasExited() const;
2016-09-09 22:13:20 +02:00
private:
2018-12-26 21:48:16 +01:00
bool hasExited_ = false;
void refreshMenu();
2016-10-18 23:00:53 +02:00
protected:
2018-12-26 21:48:16 +01:00
std::optional<Menu> menu;
std::optional<Menu> nextMenu;
void done();
2013-12-27 00:18:55 +01:00
};
2014-05-25 23:30:50 +02:00
#endif