diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-03-28 14:17:47 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-03-28 14:17:47 +0200 |
commit | 6966908022e36df9fb4c5e2233603a6fef18e97d (patch) | |
tree | 1540097e60001636cbe752d8fb1e459f45081e41 /src/common.hpp | |
parent | aa4731d2e1305ea4fb6d59032026bf1ce6f2b65d (diff) |
Pie menu; start redoing shooting mechanics.
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/common.hpp b/src/common.hpp index c45836a..8c2f21b 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -221,6 +221,14 @@ namespace world { namespace interface { class state_t; + + typedef struct { + std::string label; + int action; + + float r0, r1; + float t0, t1; + } pie_item_t; } namespace game { @@ -267,7 +275,8 @@ namespace game { // These are called by the interface. void select(rectf_t rect); - void command(v2f_t x); + bool populate_pie_menu(std::vector<interface::pie_item_t> &items); + void command(v2f_t x, int number); void spawn_soldier(v2f_t x); size_t roll(die_t die); @@ -275,6 +284,24 @@ namespace game { } namespace interface { + class pie_menu_t { + v2f_t x, x_world; + float radius; + pie_item_t *selected = nullptr; + + protected: + friend state_t; + std::vector<pie_item_t> items; + + public: + bool is_open = false; + + void open(v2f_t wmouse, v2f_t mouse); + void close(game::state_t *game); + void update(v2f_t mouse); + void render_to(render::state_t *render); + }; + class state_t { sf::RenderWindow *window; game::state_t *game; @@ -299,6 +326,8 @@ namespace interface { rectf_t rect; } select; + pie_menu_t pie_menu; + typedef struct { double time; std::string text; @@ -389,6 +418,8 @@ namespace render { void render_rect(rectf_t rect, sf::Color color); void render_hlrect(rectf_t rect, sf::Color color); void render_line(v2f_t x0, v2f_t x1, sf::Color color); + void render_circle(v2f_t x, float r, sf::Color color); + void render_ring_sect(v2f_t x, float r0, float r1, float t0, float t1, sf::Color color); void debug_path(v2f_t x, std::list<v2f_t> *path); |