From 7124036c70cf7e99e67518f3527934672811442d Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 24 Aug 2014 03:48:41 +0200 Subject: [PATCH] Added "Nothing New" indicator after check for new packages with no new results --- src/addon/addon_manager.cpp | 10 +++++++++- src/addon/addon_manager.hpp | 3 +++ src/supertux/menu/addon_menu.cpp | 34 +++++++++++++++++++++++----------- src/supertux/menu/addon_menu.hpp | 1 + 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/addon/addon_manager.cpp b/src/addon/addon_manager.cpp index acd983fa2..50e0032d5 100644 --- a/src/addon/addon_manager.cpp +++ b/src/addon/addon_manager.cpp @@ -79,7 +79,8 @@ AddonManager::AddonManager(const std::string& addon_directory, m_repository_url("http://localhost:8000/index-0_4_0.nfo"), m_ignored_addon_ids(ignored_addon_ids), m_installed_addons(), - m_repository_addons() + m_repository_addons(), + m_has_been_updated(false) { PHYSFS_mkdir(m_addon_directory.c_str()); @@ -171,11 +172,18 @@ AddonManager::has_online_support() const return true; } +bool +AddonManager::has_been_updated() const +{ + return m_has_been_updated; +} + void AddonManager::check_online() { std::string addoninfos = m_downloader.download(m_repository_url); m_repository_addons = parse_addon_infos(addoninfos); + m_has_been_updated = true; } void diff --git a/src/addon/addon_manager.hpp b/src/addon/addon_manager.hpp index 68e1953c4..419c401bb 100644 --- a/src/addon/addon_manager.hpp +++ b/src/addon/addon_manager.hpp @@ -46,12 +46,15 @@ private: AddonList m_installed_addons; AddonList m_repository_addons; + bool m_has_been_updated; + public: AddonManager(const std::string& addon_directory, std::vector& enabled_addons_); ~AddonManager(); bool has_online_support() const; + bool has_been_updated() const; void check_online(); std::vector get_repository_addons() const; diff --git a/src/supertux/menu/addon_menu.cpp b/src/supertux/menu/addon_menu.cpp index 7de316ea5..91636f235 100644 --- a/src/supertux/menu/addon_menu.cpp +++ b/src/supertux/menu/addon_menu.cpp @@ -110,7 +110,11 @@ AddonMenu::rebuild_menu() add_hl(); - if (!m_installed_addons.empty()) + if (m_installed_addons.empty()) + { + add_inactive(MNID_NOTHING_NEW, _("No Addons installed")); + } + else { int idx = 0; for (const auto& addon_id : m_installed_addons) @@ -120,20 +124,12 @@ AddonMenu::rebuild_menu() add_toggle(MAKE_INSTALLED_MENU_ID(idx), text, addon.is_enabled()); idx += 1; } - - add_hl(); } - if (!m_addon_manager.has_online_support()) - { - add_inactive(MNID_CHECK_ONLINE, std::string(_("Check Online (disabled)"))); - } - else - { - add_entry(MNID_CHECK_ONLINE, std::string(_("Check Online"))); - } + add_hl(); { + bool have_new_stuff = false; int idx = 0; for (const auto& addon_id : m_repository_addons) { @@ -155,6 +151,7 @@ AddonMenu::rebuild_menu() << std::endl; std::string text = generate_menu_item_text(addon); add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text + " *NEW*"); + have_new_stuff = true; } } catch(const std::exception& err) @@ -162,9 +159,24 @@ AddonMenu::rebuild_menu() // addon is not installed std::string text = generate_menu_item_text(addon); add_entry(MAKE_REPOSITORY_MENU_ID(idx), "Install " + text); + have_new_stuff = true; } idx += 1; } + + if (!have_new_stuff && m_addon_manager.has_been_updated()) + { + add_inactive(MNID_NOTHING_NEW, _("No new Addons found")); + } + } + + if (!m_addon_manager.has_online_support()) + { + add_inactive(MNID_CHECK_ONLINE, std::string(_("Check Online (disabled)"))); + } + else + { + add_entry(MNID_CHECK_ONLINE, std::string(_("Check Online"))); } add_hl(); diff --git a/src/supertux/menu/addon_menu.hpp b/src/supertux/menu/addon_menu.hpp index 715bad64e..741ad67be 100644 --- a/src/supertux/menu/addon_menu.hpp +++ b/src/supertux/menu/addon_menu.hpp @@ -27,6 +27,7 @@ class AddonMenu : public Menu private: enum { MNID_CHECK_ONLINE, + MNID_NOTHING_NEW, MNID_ADDON_LIST_START = 10 }; -- 2.11.0