From 1115118a13f9003c81ac058c0e012b55f4ff0c99 Mon Sep 17 00:00:00 2001
From: GuillaumeBft <54895740+GuillaumeBft@users.noreply.github.com>
Date: Tue, 10 Dec 2019 17:12:45 +0100
Subject: [PATCH] Show only possessed checkbox in addons screen #3376 (#4162)
* Show only possessed checkbox in addons screen
* add var w_show_possessed
* Update addons_screen.stkgui
---
data/gui/screens/addons_screen.stkgui | 4 ++++
src/states_screens/addons_screen.cpp | 12 +++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/data/gui/screens/addons_screen.stkgui b/data/gui/screens/addons_screen.stkgui
index c033a1e4e..8267a95cb 100644
--- a/data/gui/screens/addons_screen.stkgui
+++ b/data/gui/screens/addons_screen.stkgui
@@ -37,6 +37,10 @@
+
+
+
+
diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp
index 080d03ba2..1e155a880 100644
--- a/src/states_screens/addons_screen.cpp
+++ b/src/states_screens/addons_screen.cpp
@@ -167,6 +167,10 @@ void AddonsScreen::init()
getWidget("filter_rating");
w_filter_rating->setValue(0);
+ GUIEngine::CheckBoxWidget* w_show_possessed =
+ getWidget("show_possessed");
+ w_show_possessed->setState(false);
+
// Set the default sort order
Addon::setSortOrder(Addon::SO_DEFAULT);
loadList();
@@ -212,12 +216,18 @@ void AddonsScreen::loadList()
GUIEngine::SpinnerWidget* w_filter_rating =
getWidget("filter_rating");
float rating = w_filter_rating->getValue() / 2.0f;
+
+ GUIEngine::CheckBoxWidget* w_show_possessed =
+ getWidget("show_possessed");
// First create a list of sorted entries
PtrVector sorted_list;
for(unsigned int i=0; igetNumAddons(); i++)
{
const Addon & addon = addons_manager->getAddon(i);
+ // Ignore not installed addons if the checkbox is enabled
+ if(w_show_possessed->getState() && !addon.isInstalled())
+ continue;
// Ignore addons of a different type
if(addon.getType()!=m_type) continue;
// Ignore invisible addons
@@ -453,7 +463,7 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
loadList();
}
}
- else if (name == "filter_search")
+ else if (name == "filter_search" || name == "show_possessed")
{
loadList();
}