From 154004ae6ac3747769648511cdc77e7171c684d8 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 14 Dec 2017 14:09:07 +0100 Subject: The gamelog, being reworking combat. --- src/game/interface.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/game/interface.cpp') diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 854b620..a367607 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -131,4 +131,35 @@ void state_t::tick(double dt) select.rect[1] = wmouse; } +void state_t::print(std::string str) +{ + log.push_back((log_entry_t){game->now, str}); + std::cout << str << std::endl; +} + +void state_t::render_to(render::state_t *render) +{ + size_t w = window->getSize().x, h = window->getSize().y; + v2f_t x; + + window->setView(sf::View(sf::FloatRect(0, 0, w, h))); + em = std::min(w, h) * 0.04; + + if (select.selecting) + render->render_hlrect(select.rect, sf::Color(200, 100, 50)); + + for (auto i = log.begin(); i != log.end(); ) { + if (i->time + 3 < game->now) + i = log.erase(i); + else + i++; + } + + x = v2f_t(0.0f, 0.0f); + for (log_entry_t &entry : log) { + render->render_text(x, em, entry.text, render::ALIGN_LEFT_TOP, sf::Color::White); + x[1] += em; + } +} + } // namespace interface -- cgit