diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-11-07 13:50:52 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-11-07 13:52:04 +0100 |
commit | d0be87d32929c42502fb842aa2b0ab0233313b93 (patch) | |
tree | c88b88f63d08cbeaec100eff876676f60ddf78ba /src/render.cpp | |
parent | e28a62894f368cccc64932fe83c91f32d7cb7288 (diff) |
Refactoring, introduce text.cpp, closer to an actual game.
Diffstat (limited to 'src/render.cpp')
-rw-r--r-- | src/render.cpp | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/src/render.cpp b/src/render.cpp index 41bcd4b..80ed2b6 100644 --- a/src/render.cpp +++ b/src/render.cpp @@ -23,7 +23,7 @@ static void draw_tile(sf::RenderWindow *window, v2f_t x, world::tile_t *tile, break; } - wot_rect.setTexture(texture); + wot_rect.setTexture(texture, true); wot_rect.setSize(sf::Vector2f(1.0f, 1.0f)); wot_rect.setPosition(x); wot_rect.setFillColor(sf::Color::White); @@ -50,16 +50,10 @@ static void draw_sector(sf::RenderWindow *window, world::sector_t *sector) world::tile_index_t(x, y)); } -void interface::state_t::render() +void interface::state_t::render_to(render::state_t *render) { - if (select.selecting) { - wot_rect.setSize(select.rect.dims()); - wot_rect.setPosition(select.rect[0]); - wot_rect.setFillColor(sf::Color(200, 100, 50, 100)); - wot_rect.setOutlineThickness(0.02f); - wot_rect.setOutlineColor(sf::Color(200, 100, 50, 255)); - window->draw(wot_rect); - } + if (select.selecting) + render->render_hlrect(select.rect, sf::Color(200, 100, 50)); } namespace render { @@ -82,21 +76,6 @@ void state_t::end_frame(void) window->display(); } -void state_t::drender_rect(rectf_t rect, sf::Color color) -{ - sf::Color fill; - - - fill = sf::Color(color.r, color.g, color.b, 50); - - wot_rect.setSize(rect.dims()); - wot_rect.setPosition(rect[0]); - wot_rect.setFillColor(fill); - wot_rect.setOutlineThickness(0.01); - wot_rect.setOutlineColor(color); - window->draw(wot_rect); -} - void state_t::drender_text(rectf_t rect, std::string str) { sf::Text text(str, font, 20); @@ -121,8 +100,8 @@ void state_t::drender_entity(world::entity_t *ent) { std::stringstream ss; - drender_rect(ent->render_bounds, sf::Color::Red); - drender_rect(ent->cmodel.bounds, sf::Color::Yellow); + render_hlrect(ent->render_bounds, sf::Color::Red); + render_hlrect(ent->cmodel.bounds, sf::Color::Yellow); ss << (void*)ent << "\n"; ss << "CF=" << ent->cmodel.cflags; @@ -202,6 +181,20 @@ void state_t::render(oriented_sprite_t *sprite, rectf_t bounds, float angle) render(sprite->textures + index, bounds, mirror); } +void state_t::render_hlrect(rectf_t rect, sf::Color color) +{ + sf::Color fill; + + fill = sf::Color(color.r, color.g, color.b, 50); + wot_rect.setSize(rect.dims()); + wot_rect.setPosition(rect[0]); + wot_rect.setFillColor(fill); + wot_rect.setOutlineThickness(0.01); + wot_rect.setOutlineColor(color); + window->draw(wot_rect); + wot_rect.setOutlineColor(sf::Color::Transparent); +} + void state_t::debug_path(std::list<v2f_t> *path) { bool first = true; |