From: Ingo Ruhnke Date: Tue, 26 Aug 2014 19:51:34 +0000 (+0200) Subject: Renamed AddonDialog to DownloadDialog, as it isn't AddonManager specific any more X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e9df7ac74e53d818c21b4a67e9ef0e83d9c89dd4;p=supertux.git Renamed AddonDialog to DownloadDialog, as it isn't AddonManager specific any more --- diff --git a/src/supertux/menu/addon_dialog.cpp b/src/supertux/menu/addon_dialog.cpp deleted file mode 100644 index 188e8aad2..000000000 --- a/src/supertux/menu/addon_dialog.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// SuperTux -// Copyright (C) 2014 Ingo Ruhnke -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "supertux/menu/addon_dialog.hpp" - -#include - -#include "gui/menu_manager.hpp" -#include "util/gettext.hpp" - -AddonDialog::AddonDialog(TransferStatusPtr status) : - m_status(status), - m_title() -{ - add_button(_("Abort Download"), [this]{ - on_abort(); - }); - - update_text(); -} - -void -AddonDialog::update() -{ - AddonManager::current()->update(); - update_text(); -} - -void -AddonDialog::set_title(const std::string& title) -{ - m_title = title; -} - -void -AddonDialog::update_text() -{ - std::ostringstream out; - out << m_title << "\n"; - - if (m_status->dltotal == 0) - { - out << "---\n---"; - } - else - { - int percent = 100 * m_status->dlnow / m_status->dltotal; - out << m_status->dlnow/1000 << "/" << m_status->dltotal/1000 << " kB\n" << percent << "%"; - } - - set_text(out.str()); -} - -void -AddonDialog::on_abort() -{ - AddonManager::current()->abort_install(); -} - -/* EOF */ diff --git a/src/supertux/menu/addon_dialog.hpp b/src/supertux/menu/addon_dialog.hpp deleted file mode 100644 index 1b9ee1279..000000000 --- a/src/supertux/menu/addon_dialog.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// SuperTux -// Copyright (C) 2014 Ingo Ruhnke -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_ADDON_DIALOG_HPP -#define HEADER_SUPERTUX_SUPERTUX_MENU_ADDON_DIALOG_HPP - -#include "addon/addon_manager.hpp" -#include "addon/addon_manager.hpp" -#include "gui/dialog.hpp" - -class TransferStatus; -using TransferStatusPtr = std::shared_ptr; - -class AddonDialog : public Dialog -{ -private: - TransferStatusPtr m_status; - std::string m_title; - -public: - AddonDialog(TransferStatusPtr status); - - void set_title(const std::string& title); - void update() override; - -private: - void on_abort(); - - void update_text(); - -private: - AddonDialog(const AddonDialog&) = delete; - AddonDialog& operator=(const AddonDialog&) = delete; -}; - -#endif - -/* EOF */ diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp index 05f3e5771..76f64f886 100644 --- a/src/supertux/menu/addon_menu.cpp +++ b/src/supertux/menu/addon_menu.cpp @@ -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 { @@ -189,7 +189,7 @@ AddonMenu::menu_action(MenuItem* item) MenuManager::instance().set_dialog({}); refresh(); }); - std::unique_ptr dialog(new AddonDialog(status)); + std::unique_ptr dialog(new DownloadDialog(status)); dialog->set_title("Downloading Add-On Repository Index"); MenuManager::instance().set_dialog(std::move(dialog)); } @@ -240,7 +240,7 @@ AddonMenu::menu_action(MenuItem* item) refresh(); }); - std::unique_ptr dialog(new AddonDialog(status)); + std::unique_ptr dialog(new DownloadDialog(status)); dialog->set_title("Downloading " + generate_menu_item_text(addon)); MenuManager::instance().set_dialog(std::move(dialog)); } diff --git a/src/supertux/menu/download_dialog.cpp b/src/supertux/menu/download_dialog.cpp new file mode 100644 index 000000000..8ba7fc288 --- /dev/null +++ b/src/supertux/menu/download_dialog.cpp @@ -0,0 +1,73 @@ +// SuperTux +// Copyright (C) 2014 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "supertux/menu/download_dialog.hpp" + +#include + +#include "gui/menu_manager.hpp" +#include "util/gettext.hpp" + +DownloadDialog::DownloadDialog(TransferStatusPtr status) : + m_status(status), + m_title() +{ + add_button(_("Abort Download"), [this]{ + on_abort(); + }); + + update_text(); +} + +void +DownloadDialog::update() +{ + AddonManager::current()->update(); + update_text(); +} + +void +DownloadDialog::set_title(const std::string& title) +{ + m_title = title; +} + +void +DownloadDialog::update_text() +{ + std::ostringstream out; + out << m_title << "\n"; + + if (m_status->dltotal == 0) + { + out << "---\n---"; + } + else + { + int percent = 100 * m_status->dlnow / m_status->dltotal; + out << m_status->dlnow/1000 << "/" << m_status->dltotal/1000 << " kB\n" << percent << "%"; + } + + set_text(out.str()); +} + +void +DownloadDialog::on_abort() +{ + AddonManager::current()->abort_install(); +} + +/* EOF */ diff --git a/src/supertux/menu/download_dialog.hpp b/src/supertux/menu/download_dialog.hpp new file mode 100644 index 000000000..1853ae930 --- /dev/null +++ b/src/supertux/menu/download_dialog.hpp @@ -0,0 +1,51 @@ +// SuperTux +// Copyright (C) 2014 Ingo Ruhnke +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_SUPERTUX_MENU_DOWNLOAD_DIALOG_HPP +#define HEADER_SUPERTUX_SUPERTUX_MENU_DOWNLOAD_DIALOG_HPP + +#include "addon/addon_manager.hpp" +#include "addon/addon_manager.hpp" +#include "gui/dialog.hpp" + +class TransferStatus; +using TransferStatusPtr = std::shared_ptr; + +class DownloadDialog : public Dialog +{ +private: + TransferStatusPtr m_status; + std::string m_title; + +public: + DownloadDialog(TransferStatusPtr status); + + void set_title(const std::string& title); + void update() override; + +private: + void on_abort(); + + void update_text(); + +private: + DownloadDialog(const DownloadDialog&) = delete; + DownloadDialog& operator=(const DownloadDialog&) = delete; +}; + +#endif + +/* EOF */