diff options
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/common.hpp b/src/common.hpp index 2d2af4a..49166d3 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -5,6 +5,7 @@ #include <map> #include <list> #include <unordered_set> +#include <sstream> #include <stack> #include <SFML/Graphics.hpp> #include "math.hpp" @@ -177,6 +178,10 @@ namespace world { }; } +namespace interface { + class state_t; +} + namespace game { bool load_assets(void); @@ -189,6 +194,7 @@ namespace game { public: world::world_t world; + interface::state_t *interface; double now, dt; void start(void); @@ -206,6 +212,8 @@ namespace interface { sf::RenderWindow *window; game::state_t *game; + float em; + struct { sf::Vector2f center; int target_zoom = 3; @@ -219,10 +227,19 @@ namespace interface { rectf_t rect; } select; + typedef struct { + double time; + std::string text; + } log_entry_t; + + std::list<log_entry_t> log; + public: state_t(sf::RenderWindow *window_, game::state_t *game); void tick(double dt); void render_to(render::state_t *render); + + void print(std::string str); }; } @@ -263,6 +280,7 @@ namespace render { }; typedef enum { + ALIGN_LEFT_TOP, ALIGN_CENTER_BOTTOM } text_align_t; @@ -285,7 +303,7 @@ namespace render { void render(animated_texture_t *anim, rectf_t bounds, bool mirror = false); void render(oriented_sprite_t *sprite, rectf_t bounds, float angle); - void render_text(v2f_t x, float height, const wchar_t *wstr, text_align_t align, sf::Color color); + void render_text(v2f_t x, float height, std::string str, text_align_t align, sf::Color color); void render_rect(rectf_t rect, sf::Color color); void render_hlrect(rectf_t rect, sf::Color color); void render_arrow(v2f_t x0, v2f_t x1, sf::Color color); @@ -297,10 +315,27 @@ namespace render { extern render::state_t *debug_render; namespace text { - extern const wchar_t *unit_no_path; - extern const wchar_t *unit_blocked; + typedef enum { + LANG_ENGLISH + } language_t; - void load_strings(std::string lang); + extern language_t language; + + typedef enum { + SAY_NO_PATH, + SAY_BLOCKED, + UNIT_ALIEN, + UNIT_HUMAN, + UNIT_DEATH, + UNIT_ATTACK, + UNIT_MISS, + UNIT_CRITICAL_MISS, + UNIT_HIT, + UNIT_CRITICAL_HIT, + UNIT_DAMAGE + } index_t; + + std::string get(index_t index); } // Divide and round to minus infinity. |