aboutsummaryrefslogtreecommitdiffstats
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 0177bd7..9644010 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -28,7 +28,7 @@ Game::loop()
{
while(m_running)
{
- render();
+ Boxii::refresh();
update();
}
}
@@ -50,33 +50,19 @@ Game::update()
locked->update();
}
-void
-Game::render()
-{
- for(auto it = m_order.cbegin(); it != m_order.cend(); it++){
- auto lock = it->lock();
- if(!lock) continue;
-
- if(m_dirty){
- lock->setRedraw();
- }
- lock->render();
- }
- m_dirty = false;
-}
-
void
Game::addScreen(const std::string &key, std::shared_ptr<Screen> value)
{
m_screens.emplace(key, value);
}
+
bool
Game::pushScreen(const std::string &key)
{
auto it = m_screens.find(key);
if(it != m_screens.end()){
m_order.push_back(it->second);
- m_dirty = true;
+ it->second->activate();
return true;
}
return false;
@@ -85,6 +71,9 @@ Game::pushScreen(const std::string &key)
bool
Game::popScreen()
{
+ if(auto lock = m_order.back().lock()){
+ lock->deactivate();
+ }
m_order.pop_back();
m_dirty = true;
return m_order.empty();
@@ -106,6 +95,7 @@ Game::popUpto(const std::string &key)
}
if(lock == find->second) break;
+ lock->deactivate();
m_order.pop_back();
}
m_dirty = true;
@@ -118,6 +108,8 @@ Game::popUptoIncluding(const std::string &key)
bool r = popUpto(key);
if(!r) return r;
+ auto lock = m_order.back().lock();
+ if(lock != nullptr) lock->deactivate();
m_order.pop_back();
return true;
}