MainMenu: some changes and fixes (#68)
Co-authored-by: Maksim <Maksym48@pm.me>
This commit is contained in:
parent
17ebe562a3
commit
d31d2387f3
@ -31,7 +31,9 @@ local http = core.get_http_api()
|
||||
|
||||
-- Screenshot
|
||||
local screenshot_dir = core.get_cache_path() .. DIR_DELIM .. "cdb"
|
||||
assert(core.create_dir(screenshot_dir))
|
||||
if not core.create_dir(screenshot_dir) then
|
||||
core.log("warning", "Failed to create ContentDB screenshot cache dir")
|
||||
end
|
||||
local screenshot_downloading = {}
|
||||
local screenshot_downloaded = {}
|
||||
|
||||
@ -169,10 +171,10 @@ local function get_raw_dependencies(package)
|
||||
return package.raw_deps
|
||||
end
|
||||
|
||||
local url_fmt = "/api/packages/%s/dependencies/?only_hard=1&protocol_version=%s&engine_version=%s"
|
||||
local url_fmt = "/api/packages/%s/dependencies/?only_hard=1&protocol_version=%s&engine_version=%s&platform=%s"
|
||||
local version = core.get_version()
|
||||
local base_url = core.settings:get("contentdb_url")
|
||||
local url = base_url .. url_fmt:format(package.id, core.get_max_supp_proto(), version.string)
|
||||
local url = base_url .. url_fmt:format(package.id, core.get_max_supp_proto(), version.string, PLATFORM)
|
||||
|
||||
local response = http.fetch_sync({ url = url })
|
||||
if not response.succeeded then
|
||||
@ -547,7 +549,7 @@ function store.load()
|
||||
local base_url = core.settings:get("contentdb_url")
|
||||
local url = base_url ..
|
||||
"/api/packages/?type=mod&type=game&type=txp&protocol_version=" ..
|
||||
core.get_max_supp_proto() .. "&engine_version=" .. version.string
|
||||
core.get_max_supp_proto() .. "&engine_version=" .. version.string .. "&platform=" .. PLATFORM
|
||||
|
||||
for _, item in pairs(core.settings:get("contentdb_flag_blacklist"):split(",")) do
|
||||
item = item:trim()
|
||||
@ -703,8 +705,8 @@ function store.get_formspec(dlgdata)
|
||||
"formspec_version[3]",
|
||||
"size[15.75,9.5;false]",
|
||||
"bgcolor[#0000]" ..
|
||||
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"bg_common.png") .. ";true;40]",
|
||||
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir ..
|
||||
"bg_common.png"), ";true;40]",
|
||||
|
||||
"style[status,downloading,queued;border=false]",
|
||||
|
||||
@ -718,7 +720,8 @@ function store.get_formspec(dlgdata)
|
||||
|
||||
-- Page nav buttons
|
||||
"container[0,", H - 0.8 - 0.375, "]",
|
||||
"button[0.375,0;5,0.8;back;", "< " .. fgettext("Back to Main Menu"), "]",
|
||||
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]",
|
||||
"image_button[0.375,0;5,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]",
|
||||
|
||||
"container[", W - 0.375 - 0.8*4 - 2, ",0]",
|
||||
"image_button[0,0;0.8,0.8;", core.formspec_escape(defaulttexturedir), "start_icon.png;pstart;]",
|
||||
@ -768,13 +771,14 @@ function store.get_formspec(dlgdata)
|
||||
end
|
||||
else
|
||||
formspec = {
|
||||
"size[12,7;false]",
|
||||
"size[12,6.4;false]",
|
||||
"bgcolor[#0000]" ..
|
||||
"background9[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"bg_common.png") .. ";true;40]",
|
||||
"background9[0,0;0,0;", core.formspec_escape(defaulttexturedir ..
|
||||
"bg_common.png"), ";true;40]",
|
||||
"label[4,3;", fgettext("No packages could be retrieved"), "]",
|
||||
"container[0,", H - 0.8 - 0.375, "]",
|
||||
"button[0,0;4,0.8;back;", fgettext("Back to Main Menu"), "]",
|
||||
"container[0,", H - 0.8 - 0.375 - 2, "]",
|
||||
"style[back;padding=-5;bgimg=", core.formspec_escape(defaulttexturedir .. "select_btn.png"), ";bgimg_middle=10]",
|
||||
"image_button[0,0;4,0.8;;back;", "< ", fgettext("Back to Main Menu"), ";true;false]",
|
||||
"container_end[]",
|
||||
}
|
||||
end
|
||||
@ -982,9 +986,9 @@ function store.handle_submit(this, fields)
|
||||
end
|
||||
|
||||
if fields["view_" .. i] then
|
||||
local url = ("%s/packages/%s/%s?protocol_version=%d"):format(
|
||||
local url = ("%s/packages/%s/%s?protocol_version=%d&platform=%s"):format(
|
||||
core.settings:get("contentdb_url"),
|
||||
package.author, package.name, core.get_max_supp_proto())
|
||||
package.author, package.name, core.get_max_supp_proto(), PLATFORM)
|
||||
core.open_url(url)
|
||||
return true
|
||||
end
|
||||
|
@ -16,6 +16,9 @@
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
local esc = core.formspec_escape
|
||||
local defaulttexturedir = esc(defaulttexturedir)
|
||||
|
||||
local packages_raw
|
||||
local packages
|
||||
|
||||
@ -59,16 +62,16 @@ local function get_formspec(tabview, name, tabdata)
|
||||
|
||||
|
||||
local retval =
|
||||
"label[0.05,-0.25;".. fgettext("Installed Packages:") .. "]" ..
|
||||
"style_type[image_button;padding=-5;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=10]" ..
|
||||
"label[-0.05,-0.25;".. fgettext("Installed Packages:") .. "]" ..
|
||||
"background9[0,0.23;5.3,4.46;" .. defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" ..
|
||||
"tablecolumns[color;tree;text]" ..
|
||||
"tableoptions[background=#0000;border=false]" ..
|
||||
"table[0,0.25;5.1,4.3;pkglist;" ..
|
||||
pkgmgr.render_packagelist(packages) ..
|
||||
";" .. tabdata.selected_pkg .. "]" ..
|
||||
"style[btn_contentdb;padding=-5;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=10]" ..
|
||||
"image_button[-0.11,4.8;5.5,0.92;;btn_contentdb;" .. fgettext("Browse online content") .. ";true;false]"
|
||||
"image_button[-0.11,4.8;5.5,0.9;;btn_contentdb;" .. fgettext("Browse online content") .. ";true;false]"
|
||||
|
||||
|
||||
local selected_pkg
|
||||
@ -98,15 +101,15 @@ local function get_formspec(tabview, name, tabdata)
|
||||
end
|
||||
|
||||
retval = retval ..
|
||||
"image[5.5,0;3,2;" .. core.formspec_escape(modscreenshot) .. "]" ..
|
||||
"label[8.25,0.6;" .. core.formspec_escape(selected_pkg.name) .. "]" ..
|
||||
"box[5.5,2.2;6.2,2.4;#33314B99]"
|
||||
"image[5.5,0;3,2;" .. esc(modscreenshot) .. "]" ..
|
||||
"label[8.25,0.6;" .. esc(selected_pkg.name) .. "]" ..
|
||||
"background9[5.6,2.3;6.2,2.4;" .. defaulttexturedir .. "desc_bg.png" .. ";false;32]"
|
||||
|
||||
if selected_pkg.type == "mod" then
|
||||
if selected_pkg.is_modpack then
|
||||
retval = retval ..
|
||||
"button[8.65,4.65;3.25,1;btn_mod_mgr_rename_modpack;" ..
|
||||
fgettext("Rename") .. "]"
|
||||
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_rename_modpack;" ..
|
||||
fgettext("Rename") .. ";true;false]"
|
||||
else
|
||||
--show dependencies
|
||||
desc = desc .. "\n\n"
|
||||
@ -133,12 +136,12 @@ local function get_formspec(tabview, name, tabdata)
|
||||
if selected_pkg.type == "txp" then
|
||||
if selected_pkg.enabled then
|
||||
retval = retval ..
|
||||
"button[8.65,4.65;3.25,1;btn_mod_mgr_disable_txp;" ..
|
||||
fgettext("Disable Texture Pack") .. "]"
|
||||
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_disable_txp;" ..
|
||||
fgettext("Disable Texture Pack") .. ";true;false]"
|
||||
else
|
||||
retval = retval ..
|
||||
"button[8.65,4.65;3.25,1;btn_mod_mgr_use_txp;" ..
|
||||
fgettext("Use Texture Pack") .. "]"
|
||||
"image_button[8.65,4.8;3.25,0.9;;btn_mod_mgr_use_txp;" ..
|
||||
fgettext("Use Texture Pack") .. ";true;false]"
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -148,8 +151,8 @@ local function get_formspec(tabview, name, tabdata)
|
||||
|
||||
if core.may_modify_path(selected_pkg.path) then
|
||||
retval = retval ..
|
||||
"button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" ..
|
||||
fgettext("Uninstall Package") .. "]"
|
||||
"image_button[5.5,4.8;3.25,0.9;;btn_mod_mgr_delete_mod;" ..
|
||||
fgettext("Uninstall Package") .. ";true;false]"
|
||||
end
|
||||
end
|
||||
return retval
|
||||
|
@ -109,7 +109,11 @@ local function get_formspec(this)
|
||||
|
||||
"background9[0,0;6.5,4.8;" .. defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" ..
|
||||
"tableoptions[background=#0000;border=false]" ..
|
||||
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]"
|
||||
"table[0,0;6.28,4.64;sp_worlds;" .. menu_render_worldlist() .. ";" .. index .. "]" ..
|
||||
|
||||
"style[switch_local;fgimg=" .. defaulttexturedir .. "switch_local.png;fgimg_hovered=" ..
|
||||
defaulttexturedir .. "switch_local_hover.png]" ..
|
||||
"image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]"
|
||||
|
||||
if PLATFORM == "Android" then
|
||||
retval = retval ..
|
||||
@ -118,13 +122,6 @@ local function get_formspec(this)
|
||||
defaulttexturedir .. "gift_btn_pressed.png]"
|
||||
end
|
||||
|
||||
if PLATFORM ~= "iOS" then
|
||||
retval = retval ..
|
||||
"style[switch_local;fgimg=" .. defaulttexturedir .. "switch_local.png;fgimg_hovered=" ..
|
||||
defaulttexturedir .. "switch_local_hover.png]" ..
|
||||
"image_button[10.6,-0.1;1.5,1.5;;switch_local;;true;false]"
|
||||
end
|
||||
|
||||
local enable_server = core.settings:get_bool("enable_server")
|
||||
if enable_server then
|
||||
retval = retval ..
|
||||
|
@ -42,49 +42,59 @@ local function get_formspec(tabview, name, tabdata)
|
||||
local search_panel
|
||||
if mobile then
|
||||
search_panel =
|
||||
"field[0.2,0.1;5.1,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[4.87,-0.13;0.83,0.83;" .. defaulttexturedir ..
|
||||
"formspec_version[3]" ..
|
||||
"image[-0.1,4.9;6.05,0.89;" .. defaulttexturedir .. "desc_bg.png;32]" ..
|
||||
"style[Dte_search;border=false;bgcolor=transparent]" ..
|
||||
"field[0.25,5.2;4.97,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[4.85,4.93;0.83,0.83;" .. defaulttexturedir ..
|
||||
"search.png;btn_mp_search;;true;false]" ..
|
||||
"image_button[5.62,-0.13;0.83,0.83;" .. defaulttexturedir ..
|
||||
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir ..
|
||||
"refresh.png;btn_mp_refresh;;true;false]" ..
|
||||
"image_button[6.37,-0.13;0.83,0.83;" .. defaulttexturedir ..
|
||||
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir ..
|
||||
(serverlistmgr.mobile_only and "online_mobile" or "online_pc") .. ".png" ..
|
||||
";btn_mp_mobile;;true;false]"
|
||||
else
|
||||
search_panel =
|
||||
"field[0.2,0.1;5.8,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[5.62,-0.13;0.83,0.83;" .. defaulttexturedir ..
|
||||
"formspec_version[3]" ..
|
||||
"image[-0.1,4.9;7,0.89;" .. defaulttexturedir .. "desc_bg.png;32]" ..
|
||||
"style[Dte_search;border=false;bgcolor=transparent]" ..
|
||||
"field[0.25,5.2;5.75,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[5.6,4.93;0.83,0.83;" .. defaulttexturedir ..
|
||||
"search.png;btn_mp_search;;true;false]" ..
|
||||
"image_button[6.37,-0.13;0.83,0.83;" .. defaulttexturedir ..
|
||||
"image_button[6.35,4.93;0.83,0.83;" .. defaulttexturedir ..
|
||||
"refresh.png;btn_mp_refresh;;true;false]"
|
||||
end
|
||||
|
||||
local address = core.settings:get("address")
|
||||
local port = tonumber(core.settings:get("remote_port"))
|
||||
if port and port ~= 30000 then
|
||||
address = address .. ":" .. port
|
||||
end
|
||||
|
||||
local retval =
|
||||
-- Search
|
||||
search_panel ..
|
||||
|
||||
-- Address / Port
|
||||
"field[7.4,0.6;3.2,0.5;te_address;" .. fgettext("Address") .. ":" .. ";" ..
|
||||
esc(core.settings:get("address")) .. "]" ..
|
||||
"field[10.45,0.6;1.95,0.5;te_port;" .. fgettext("Port") .. ":" .. ";" ..
|
||||
esc(core.settings:get("remote_port")) .. "]" ..
|
||||
"field[7.4,0.55;5,0.5;te_address;" .. fgettext("Address / Port") .. ":" .. ";" ..
|
||||
esc(address) .. "]" ..
|
||||
|
||||
-- Name
|
||||
"field[7.4,1.75;3.2,0.5;te_name;" .. fgettext("Name") .. ":" .. ";" ..
|
||||
"field[7.4,1.7;3.2,0.5;te_name;" .. fgettext("Name") .. ":" .. ";" ..
|
||||
esc(core.settings:get("name")) .. "]" ..
|
||||
|
||||
-- Description Background
|
||||
"box[7.1,2.1;4.8,2.65;#33314B99]" ..
|
||||
"background9[7.2,2.2;4.8,2.65;" .. defaulttexturedir .. "desc_bg.png" .. ";false;32]" ..
|
||||
|
||||
-- Connect
|
||||
"style[btn_mp_connect;fgimg=" .. defaulttexturedir ..
|
||||
"btn_play.png;fgimg_hovered=" .. defaulttexturedir .. "btn_play_hover.png]" ..
|
||||
"image_button[8.8,4.88;3.3,0.9;;btn_mp_connect;;true;false]" ..
|
||||
"image_button[8.8,4.9;3.3,0.9;;btn_mp_connect;;true;false]" ..
|
||||
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]"
|
||||
|
||||
local pwd = password_save and core.settings:get("password") or password_tmp
|
||||
-- Password
|
||||
retval = retval .. "pwdfield[10.45,1.8;1.95,0.39;te_pwd;" ..
|
||||
retval = retval .. "pwdfield[10.45,1.7;1.95,0.5;te_pwd;" ..
|
||||
fgettext("Password") .. ":" .. ";" .. esc(pwd) .. "]"
|
||||
|
||||
if tabdata.selected and selected then
|
||||
@ -92,7 +102,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
retval = retval ..
|
||||
"style[btn_delete_favorite;fgimg=" .. defaulttexturedir ..
|
||||
"trash.png;fgimg_hovered=" .. defaulttexturedir .. "trash_hover.png]" ..
|
||||
"image_button[7.1,4.91;0.83,0.83;;btn_delete_favorite;;true;false]"
|
||||
"image_button[7.1,4.93;0.83,0.83;;btn_delete_favorite;;true;false]"
|
||||
end
|
||||
if selected.description then
|
||||
retval = retval .. "textarea[7.5,2.2;4.8,3;;" ..
|
||||
@ -102,7 +112,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
|
||||
--favorites
|
||||
retval = retval ..
|
||||
"background9[-0.07,0.7;7.19,5.08;" ..
|
||||
"background9[0,-0.1;7.1,5;" ..
|
||||
defaulttexturedir .. "worldlist_bg.png" .. ";false;40]" ..
|
||||
"tableoptions[background=#0000;border=false]" ..
|
||||
"tablecolumns[" ..
|
||||
@ -115,7 +125,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
image_column(fgettext("Server mode")) .. ",padding=0.5;" ..
|
||||
"color,span=1;" ..
|
||||
"text,padding=0.5]" ..
|
||||
"table[-0.1,0.7;7,4.94;favorites;"
|
||||
"table[-0.02,-0.1;6.91,4.87;favorites;"
|
||||
|
||||
if menudata.search_result then
|
||||
local favs = serverlistmgr.get_favorites()
|
||||
@ -305,7 +315,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
if (fields.Dte_search or fields.btn_mp_search) and not
|
||||
(fields.btn_mp_connect or fields.key_enter) then
|
||||
tabdata.selected = 1
|
||||
local input = lower(fields.Dte_search)
|
||||
local input = lower(fields.Dte_search or "")
|
||||
tabdata.search_for = fields.Dte_search
|
||||
|
||||
if #serverlistmgr.servers < 2 then
|
||||
@ -367,11 +377,15 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
end
|
||||
|
||||
if (fields.btn_mp_connect or fields.key_enter)
|
||||
and fields.te_address ~= "" and fields.te_port then
|
||||
and fields.te_address ~= "" then
|
||||
gamedata.playername = fields.te_name
|
||||
gamedata.password = fields.te_pwd
|
||||
gamedata.address = fields.te_address
|
||||
gamedata.port = tonumber(fields.te_port) or 30000
|
||||
|
||||
-- Allow entering "address:port"
|
||||
local address, port = fields.te_address:match("^(.+):([0-9]+)$")
|
||||
gamedata.address = address or fields.te_address
|
||||
gamedata.port = tonumber(port) or 30000
|
||||
|
||||
gamedata.selected_world = 0
|
||||
local fav_idx = core.get_table_index("favorites")
|
||||
local fav = serverlist[fav_idx]
|
||||
|
BIN
textures/base/pack/desc_bg.png
Normal file
BIN
textures/base/pack/desc_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 154 B |
Loading…
x
Reference in New Issue
Block a user