Removed some obsolete stuff from supertux/globals.hpp
[supertux.git] / src / supertux / menu / addon_menu.cpp
index 05f3e57..13f8e0a 100644 (file)
@@ -25,7 +25,7 @@
 #include "gui/menu.hpp"
 #include "gui/menu_item.hpp"
 #include "gui/menu_manager.hpp"
-#include "supertux/menu/addon_dialog.hpp"
+#include "supertux/menu/download_dialog.hpp"
 #include "util/gettext.hpp"
 
 namespace {
@@ -185,11 +185,15 @@ AddonMenu::menu_action(MenuItem* item)
     try
     {
       TransferStatusPtr status = m_addon_manager.request_check_online();
-      status->then([this]{
-          MenuManager::instance().set_dialog({});
-          refresh();
+      status->then(
+        [this](bool success)
+        {
+          if (success)
+          {
+            refresh();
+          }
         });
-      std::unique_ptr<AddonDialog> dialog(new AddonDialog(status));
+      std::unique_ptr<DownloadDialog> dialog(new DownloadDialog(status));
       dialog->set_title("Downloading Add-On Repository Index");
       MenuManager::instance().set_dialog(std::move(dialog));
     }
@@ -227,20 +231,24 @@ AddonMenu::menu_action(MenuItem* item)
         auto addon_id = addon.get_id();
         TransferStatusPtr status = m_addon_manager.request_install_addon(addon_id);
 
-        status->then([this, addon_id]{
-            try
+        status->then(
+          [this, addon_id](bool success)
+          {
+            if (success)
             {
-              m_addon_manager.enable_addon(addon_id);
+              try
+              {
+                m_addon_manager.enable_addon(addon_id);
+              }
+              catch(const std::exception& err)
+              {
+                log_warning << "Enabling addon failed: " << err.what() << std::endl;
+              }
+              refresh();
             }
-            catch(const std::exception& err)
-            {
-              log_warning << "Enabling addon failed: " << err.what() << std::endl;
-            }
-            MenuManager::instance().set_dialog({});
-            refresh();
           });
 
-        std::unique_ptr<AddonDialog> dialog(new AddonDialog(status));
+        std::unique_ptr<DownloadDialog> dialog(new DownloadDialog(status));
         dialog->set_title("Downloading " + generate_menu_item_text(addon));
         MenuManager::instance().set_dialog(std::move(dialog));
       }