MenuManager::MenuManager() :
m_dialog(),
+ m_has_next_dialog(false),
+ m_next_dialog(),
m_menu_stack(),
m_transition(new MenuTransition)
{
void
MenuManager::draw(DrawingContext& context)
{
+ if (m_has_next_dialog)
+ {
+ m_dialog = std::move(m_next_dialog);
+ m_has_next_dialog = false;
+ }
+
if (m_transition->is_active())
{
m_transition->update();
void
MenuManager::set_dialog(std::unique_ptr<Dialog> dialog)
{
- m_dialog = std::move(dialog);
+ // delay reseting m_dialog to a later point, as otherwise the Dialog
+ // can't unset itself without ending up with "delete this" problems
+ m_next_dialog = std::move(dialog);
+ m_has_next_dialog = true;
}
void
#ifndef HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
#define HEADER_SUPERTUX_GUI_MENU_MANAGER_HPP
-#include <vector>
#include <list>
#include <memory>
+#include <vector>
#include "SDL.h"
private:
std::unique_ptr<Dialog> m_dialog;
+ bool m_has_next_dialog;
+ std::unique_ptr<Dialog> m_next_dialog;
+
std::vector<std::unique_ptr<Menu> > m_menu_stack;
std::unique_ptr<MenuTransition> m_transition;