Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
view.h
Go to the documentation of this file.
1#ifndef VIEW_H
2#define VIEW_H
3
4#ifndef LOGIC_ONLY
5
6#include "delta_t.h"
7#include "program_state.h"
8
9#include <SFML/Window/Event.hpp>
10
11#include <optional>
12
25class view
26{
27public:
28 view();
29 virtual ~view();
30
32 void clear_next_state();
33
35 void draw();
36
38 const auto& get_next_state() const noexcept { return m_next_state; }
39
43 bool is_active() const noexcept { return m_is_active; }
44
46 bool process_event(sf::Event& e);
47
49 void process_resize_event(sf::Event& event);
50
52 void set_is_active(const bool is_active);
53
57 void set_next_state(const program_state next_state);
58
60 void start();
61
63 void stop();
64
66 void tick(const delta_t dt);
67
68private:
69
70 bool m_is_active{false};
71
73 std::optional<program_state> m_next_state;
74
76 virtual void draw_impl() = 0;
77
79 virtual bool process_event_impl(sf::Event& e) = 0;
80
82 virtual void process_resize_event_impl(sf::Event& event) = 0;
83
85 virtual void start_impl() = 0;
86
88 virtual void stop_impl() = 0;
89
91 virtual void tick_impl(const delta_t dt) = 0;
92
93};
94
95#endif // LOGIC_ONLY
96
97#endif // VIEW_H
A change of in_game_time}.
Definition delta_t.h:12
The abstract base class of all other views.
Definition view.h:26
void set_is_active(const bool is_active)
Set if this window is active.
Definition view.cpp:48
view()
Definition view.cpp:10
void stop()
Clean up after this window has been shown.
Definition view.cpp:76
void draw()
Draw the menu on the main window.
Definition view.cpp:32
virtual ~view()
Definition view.cpp:15
void clear_next_state()
Clear the next state.
Definition view.cpp:21
void set_next_state(const program_state next_state)
Set the next state to go to.
Definition view.cpp:54
void tick(const delta_t dt)
Run the game, until the user quits.
Definition view.cpp:82
void process_resize_event(sf::Event &event)
Process a resize event.
Definition view.cpp:42
bool process_event(sf::Event &e)
Process an event.
Definition view.cpp:37
const auto & get_next_state() const noexcept
The next state to go to, if any.
Definition view.h:38
bool is_active() const noexcept
Is this window active?
Definition view.h:43
void start()
Prepare this window for being shown.
Definition view.cpp:70
program_state
Definition program_state.h:7