Initial start of the refactoring of gui.cpp into two classes, the gui::FSM will be used to controll all of the other UIs in the game, and evetnually will be pretty dumb.
This commit is contained in:
parent
4a1a8a7d65
commit
a7a60ad35c
6 changed files with 78 additions and 58 deletions
90
gui_fsm.hpp
Normal file
90
gui_fsm.hpp
Normal file
|
@ -0,0 +1,90 @@
|
|||
#pragma once
|
||||
#include "raycaster.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "stats.hpp"
|
||||
#include "levelmanager.hpp"
|
||||
#include "camera.hpp"
|
||||
#include "fsm.hpp"
|
||||
#include "render.hpp"
|
||||
#include "map_view.hpp"
|
||||
#include "main_ui.hpp"
|
||||
#include "combat_ui.hpp"
|
||||
#include "status_ui.hpp"
|
||||
#include "overlay_ui.hpp"
|
||||
|
||||
namespace gui {
|
||||
enum class State {
|
||||
START,
|
||||
MOVING,
|
||||
IN_COMBAT,
|
||||
COMBAT_ROTATE,
|
||||
ATTACKING,
|
||||
MAPPING,
|
||||
ROTATING,
|
||||
IDLE,
|
||||
END
|
||||
};
|
||||
|
||||
enum class Event {
|
||||
STARTED,
|
||||
TICK,
|
||||
MOVE_FORWARD,
|
||||
MOVE_BACK,
|
||||
MOVE_LEFT,
|
||||
MOVE_RIGHT,
|
||||
MAP_OPEN,
|
||||
CLOSE,
|
||||
ROTATE_LEFT,
|
||||
ROTATE_RIGHT,
|
||||
ATTACK,
|
||||
START_COMBAT,
|
||||
STOP_COMBAT,
|
||||
QUIT
|
||||
};
|
||||
|
||||
class FSM : public DeadSimpleFSM<State, Event> {
|
||||
public:
|
||||
bool $draw_stats = false;
|
||||
Point $player{0,0};
|
||||
LevelManager $levels;
|
||||
MainUI $main_ui;
|
||||
SFMLRender $renderer;
|
||||
GameLevel $level;
|
||||
MapViewUI $map_ui;
|
||||
CombatUI $combat_ui;
|
||||
StatusUI $status_ui;
|
||||
OverlayUI $overlay_ui;
|
||||
CameraLOL $camera;
|
||||
sf::Font $font;
|
||||
Stats $stats;
|
||||
TexturePack $textures;
|
||||
Raycaster $rayview;
|
||||
|
||||
FSM();
|
||||
|
||||
void event(Event ev);
|
||||
|
||||
void START(Event );
|
||||
void MOVING(Event );
|
||||
void ATTACKING(Event );
|
||||
void MAPPING(Event);
|
||||
void ROTATING(Event );
|
||||
void IDLE(Event ev);
|
||||
void IN_COMBAT(Event ev);
|
||||
void COMBAT_ROTATE(Event ev);
|
||||
void END(Event ev);
|
||||
|
||||
void try_move(int dir, bool strafe);
|
||||
void keyboard();
|
||||
void draw_stats();
|
||||
void draw_gui();
|
||||
void draw_blood();
|
||||
void debug();
|
||||
void render();
|
||||
void mouse();
|
||||
void generate_map();
|
||||
bool active();
|
||||
void run_systems();
|
||||
void handle_world_events();
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue