Menu: Fix starting a server if the server address is an empty string. (#5742)
[oweals/minetest.git] / builtin / mainmenu / tab_mods.lua
index e00f580bb241cb2e89bde26e8e66e3407ce595ec..29afd8a4e31dd4cfd3792d174198caca462e2707 100644 (file)
@@ -28,7 +28,8 @@ local function get_formspec(tabview, name, tabdata)
 
        local retval =
                "label[0.05,-0.25;".. fgettext("Installed Mods:") .. "]" ..
-               "textlist[0,0.25;5.1,4.35;modlist;" ..
+               "tablecolumns[color;tree;text]" ..
+               "table[0,0.25;5.1,5;modlist;" ..
                modmgr.render_modlist(modmgr.global_mods) ..
                ";" .. tabdata.selected_mod .. "]"
 
@@ -36,7 +37,10 @@ local function get_formspec(tabview, name, tabdata)
 --             "label[0.8,4.2;" .. fgettext("Add mod:") .. "]" ..
 --             TODO Disabled due to upcoming release 0.4.8 and irrlicht messing up localization
 --             "button[0.75,4.85;1.8,0.5;btn_mod_mgr_install_local;".. fgettext("Local install") .. "]" ..
-               "button[0,4.85;5.25,0.5;btn_modstore;".. fgettext("Online mod repository") .. "]"
+
+--             TODO Disabled due to service being offline, and not likely to come online again, in this form
+--             "button[0,4.85;5.25,0.5;btn_modstore;".. fgettext("Online mod repository") .. "]"
+               ""
 
        local selected_mod = nil
 
@@ -75,7 +79,7 @@ local function get_formspec(tabview, name, tabdata)
                        descriptionfile:close()
                else
                        descriptionlines = {}
-                       table.insert(descriptionlines,fgettext("No mod description available"))
+                       descriptionlines[#descriptionlines + 1] = fgettext("No mod description available")
                end
 
                retval = retval ..
@@ -95,12 +99,24 @@ local function get_formspec(tabview, name, tabdata)
                                .. fgettext("Uninstall selected modpack") .. "]"
                else
                        --show dependencies
-
-                       retval = retval .. ",Depends:,"
-
-                       local toadd = modmgr.get_dependencies(selected_mod.path)
-
-                       retval = retval .. toadd .. ";0]"
+                       local toadd_hard, toadd_soft = modmgr.get_dependencies(selected_mod.path)
+                       if toadd_hard == "" and toadd_soft == "" then
+                               retval = retval .. "," .. fgettext("No dependencies.")
+                       else
+                               if toadd_hard ~= "" then
+                                       retval = retval .. "," .. fgettext("Dependencies:") .. ","
+                                       retval = retval .. toadd_hard
+                               end
+                               if toadd_soft ~= "" then
+                                       if toadd_hard ~= "" then
+                                               retval = retval .. ","
+                                       end
+                                       retval = retval .. "," .. fgettext("Optional dependencies:") .. ","
+                                       retval = retval .. toadd_soft
+                               end
+                       end
+
+                       retval = retval .. ";0]"
 
                        retval = retval .. "button[5.5,4.85;4.5,0.5;btn_mod_mgr_delete_mod;"
                                .. fgettext("Uninstall selected mod") .. "]"
@@ -112,8 +128,8 @@ end
 --------------------------------------------------------------------------------
 local function handle_buttons(tabview, fields, tabname, tabdata)
        if fields["modlist"] ~= nil then
-               local event = core.explode_textlist_event(fields["modlist"])
-               tabdata.selected_mod = event.index
+               local event = core.explode_table_event(fields["modlist"])
+               tabdata.selected_mod = event.row
                return true
        end
 
@@ -160,7 +176,7 @@ local function handle_buttons(tabview, fields, tabname, tabdata)
 end
 
 --------------------------------------------------------------------------------
-tab_mods = {
+return {
        name = "mods",
        caption = fgettext("Mods"),
        cbf_formspec = get_formspec,