From 6966908022e36df9fb4c5e2233603a6fef18e97d Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 28 Mar 2018 14:17:47 +0200 Subject: Pie menu; start redoing shooting mechanics. --- src/common.hpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src/common.hpp') 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 &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 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 *path); -- cgit