From e81f3857ddee29b0d4616785449eb2e9cf6a3923 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Wed, 17 Apr 2024 18:51:45 +0100 Subject: [PATCH] ContentDB redesign: Move links to hypertext --- builtin/mainmenu/content/dlg_package.lua | 78 ++++++++++-------------- 1 file changed, 33 insertions(+), 45 deletions(-) diff --git a/builtin/mainmenu/content/dlg_package.lua b/builtin/mainmenu/content/dlg_package.lua index ed1ab97ff..0ea7db617 100644 --- a/builtin/mainmenu/content/dlg_package.lua +++ b/builtin/mainmenu/content/dlg_package.lua @@ -44,7 +44,14 @@ local function get_formspec(data) if info == nil then data.loading_error = true ui.update() - elseif data.package.name == info.name then + return + end + + if info.forums then + info.forums = "https://forum.minetest.net/viewtopic.php?t=" .. info.forums + end + + if data.package.name == info.name then data.info = info ui.update() end @@ -86,21 +93,6 @@ local function get_formspec(data) "label[0.375,1.4;", core.formspec_escape(info_line), "]", } - local x = size.x - 3.375 - local function add_link_button(label, name) - if info[name] then - x = x - 3.25 - table.insert_all(formspec, { - "button[", x, ",", bottom_buttons_y, ";3,0.8;open_", name, ";", label, "]", - }) - end - end - add_link_button(fgettext("Translate"), "translation_url") - add_link_button(fgettext("Issue Tracker"), "issue_tracker") - add_link_button(fgettext("Forums"), "forums") - add_link_button(fgettext("Source"), "repo") - add_link_button(fgettext("Website"), "website") - table.insert_all(formspec, { "container[", size.x - 6.375, ",0.375]" }) @@ -158,6 +150,7 @@ local function get_formspec(data) "container[0,2.8]", }) + local safezone_right = PLATFORM == "Android" and 0.375 or 0 if current_tab == 1 then -- Screenshots and description local hypertext = "" .. core.hypertext_escape(info.short_description) .. "\n" @@ -173,15 +166,35 @@ local function get_formspec(data) " height=" .. (2.25 * fs_to_px).. ">" end end - hypertext = hypertext .. "\n" .. info.long_description.head .. - info.long_description.body + hypertext = hypertext .. "\n" .. info.long_description.head + + local first = true + local function add_link_button(label, name) + if info[name] then + if not first then + hypertext = hypertext .. " | " + end + hypertext = hypertext .. "" .. core.hypertext_escape(label) .. "" + info.long_description.links["link_" .. name] = info[name] + first = false + end + end + + add_link_button(fgettext("Donate"), "donate_url") + add_link_button(fgettext("Website"), "website") + add_link_button(fgettext("Source"), "repo") + add_link_button(fgettext("Issue Tracker"), "issue_tracker") + add_link_button(fgettext("Translate"), "translation_url") + add_link_button(fgettext("Forum Topic"), "forums") + + hypertext = hypertext .. "\n\n" .. info.long_description.body hypertext = hypertext:gsub("