Changed egg shadow draw layer so it will no longer appear in front of bonusblocks...
[supertux.git] / src / gui / menu_manager.cpp
index e69aa59..32b6178 100644 (file)
@@ -26,6 +26,7 @@
 #include "supertux/globals.hpp"
 #include "supertux/menu/menu_storage.hpp"
 #include "supertux/timer.hpp"
+#include "util/gettext.hpp"
 #include "util/log.hpp"
 #include "video/drawing_context.hpp"
 
@@ -136,6 +137,8 @@ public:
 
 MenuManager::MenuManager() :
   m_dialog(),
+  m_has_next_dialog(false),
+  m_next_dialog(),
   m_menu_stack(),
   m_transition(new MenuTransition)
 {
@@ -170,19 +173,32 @@ MenuManager::process_input()
 }
 
 void
-MenuManager::event(const SDL_Event& event_)
+MenuManager::event(const SDL_Event& ev)
 {
-  if (current_menu() && !m_transition->is_active())
+  if (!m_transition->is_active())
   {
-    // only pass events when the menu is fully visible and not in a
-    // transition animation
-    current_menu()->event(event_);
+    if (m_dialog)
+    {
+      m_dialog->event(ev);
+    }
+    else if (current_menu())
+    {
+      // only pass events when the menu is fully visible and not in a
+      // transition animation
+      current_menu()->event(ev);
+    }
   }
 }
 
 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();
@@ -192,6 +208,7 @@ MenuManager::draw(DrawingContext& context)
   {
     if (m_dialog)
     {
+      m_dialog->update();
       m_dialog->draw(context);
     }
     else if (current_menu())
@@ -214,7 +231,10 @@ MenuManager::draw(DrawingContext& context)
 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