Content store: Add setting to filter non-free packages (#7766)
authorrubenwardy <rw@rubenwardy.com>
Thu, 8 Nov 2018 21:59:56 +0000 (21:59 +0000)
committerParamat <paramat@users.noreply.github.com>
Thu, 8 Nov 2018 21:59:56 +0000 (21:59 +0000)
Defaulting to hiding in order to help with Debian/etc distribution.
This could be changed at a later date.

src/defaultsettings.cpp
src/script/lua_api/l_mainmenu.cpp

index e692424e04a7ae20389ce21de393c7a2dc390720..9ae2daa0ba791426ede0090a13323b0e82fb08f3 100644 (file)
@@ -285,6 +285,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("font_size", font_size_str);
        settings->setDefault("mono_font_size", font_size_str);
        settings->setDefault("contentdb_url", "https://content.minetest.net");
+       settings->setDefault("show_nonfree_packages", "false");
 
 
        // Server
index c2f0f6e3aae9c13ecdaee3d9617e9b66e07e7467..39a3f3a626f972123d39371f2b0c055859db1929 100644 (file)
@@ -993,10 +993,12 @@ int ModApiMainMenu::l_get_screen_info(lua_State *L)
 
 int ModApiMainMenu::l_get_package_list(lua_State *L)
 {
-       std::string url = g_settings->get("contentdb_url");
+       std::string url   = g_settings->get("contentdb_url");
+       bool show_nonfree = g_settings->getBool("show_nonfree_packages");
        std::vector<Package> packages = getPackagesFromURL(url +
                        "/api/packages/?type=mod&type=game&type=txp&protocol_version="
-                       LATEST_PROTOCOL_VERSION_STRING);
+                       LATEST_PROTOCOL_VERSION_STRING "&nonfree=" +
+                       (show_nonfree ? "true" : "false"));
 
        // Make table
        lua_newtable(L);