ContextManager.cpp 525 bytes
1234567891011121314151617181920
#include <States/GameState/Context/ContextManager.h> void ContextManager::reset(GameContext&& context) { while (!m_contexts.empty()) m_contexts.pop(); m_initial_context = std::move(context); m_contexts.emplace(m_initial_context.clone()); } void ContextManager::save_context() { m_contexts.emplace(m_contexts.top().clone()); } void ContextManager::restore_previous_context() { if (m_contexts.size() > 1) m_contexts.pop(); else m_contexts.top() = m_initial_context.clone(); }