Main menu server tab mods button
This commit is contained in:
parent
d4ccc8de79
commit
90e4a205fb
@ -14,6 +14,9 @@ https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
Textures by Zughy are under CC BY-SA 4.0
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
Textures by cx384 are under CC BY-SA 4.0
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
Media files by DS are under CC BY-SA 4.0
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
|
||||
@ -65,6 +68,11 @@ Zughy:
|
||||
textures/base/pack/settings_reset.png
|
||||
textures/base/pack/server_url.png
|
||||
textures/base/pack/server_view_clients.png
|
||||
textures/base/pack/server_view_clients_unavailable.png
|
||||
|
||||
cx384:
|
||||
textures/base/pack/server_view_mods.png
|
||||
textures/base/pack/server_view_mods_unavailable.png
|
||||
|
||||
appgurueu:
|
||||
textures/base/pack/server_incompatible.png
|
||||
|
47
builtin/mainmenu/dlg_server_list_mods.lua
Normal file
47
builtin/mainmenu/dlg_server_list_mods.lua
Normal file
@ -0,0 +1,47 @@
|
||||
-- Luanti
|
||||
-- Copyright (C) 2024 cx384
|
||||
-- SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
local function get_formspec(dialogdata)
|
||||
local TOUCH_GUI = core.settings:get_bool("touch_gui")
|
||||
local server = dialogdata.server
|
||||
|
||||
-- A wrongly behaving server may send ill formed mod names
|
||||
local mods = {}
|
||||
table.sort(server.mods)
|
||||
for i, m in ipairs(server.mods) do
|
||||
mods[i] = core.formspec_escape(m)
|
||||
end
|
||||
mods = table.concat(mods, ",")
|
||||
|
||||
local formspec = {
|
||||
"formspec_version[8]",
|
||||
"size[6,9.5]",
|
||||
TOUCH_GUI and "padding[0.01,0.01]" or "",
|
||||
"hypertext[0,0;6,1.5;;<global margin=5 halign=center valign=middle>",
|
||||
fgettext("The $1 server uses " .. (server.gameid and "a game called $2 and " or "") ..
|
||||
"the following mods:",
|
||||
"<b>" .. core.hypertext_escape(server.name) .. "</b>",
|
||||
"<style font=mono>" .. (server.gameid or "") .. "</style>") .. "]",
|
||||
"textlist[0.5,1.5;5,6.8;;" .. mods .. "]",
|
||||
"button[1.5,8.5;3,0.8;quit;OK]"
|
||||
}
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
local function buttonhandler(this, fields)
|
||||
if fields.quit then
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function create_server_list_mods_dialog(server)
|
||||
local retval = dialog_create("dlg_server_list_mods",
|
||||
get_formspec,
|
||||
buttonhandler,
|
||||
nil)
|
||||
retval.data.server = server
|
||||
return retval
|
||||
end
|
@ -56,6 +56,7 @@ dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
|
||||
dofile(menupath .. DIR_DELIM .. "dlg_version_info.lua")
|
||||
dofile(menupath .. DIR_DELIM .. "dlg_reinstall_mtg.lua")
|
||||
dofile(menupath .. DIR_DELIM .. "dlg_clients_list.lua")
|
||||
dofile(menupath .. DIR_DELIM .. "dlg_server_list_mods.lua")
|
||||
|
||||
local tabs = {
|
||||
content = dofile(menupath .. DIR_DELIM .. "tab_content.lua"),
|
||||
|
@ -160,6 +160,26 @@ local function get_formspec(tabview, name, tabdata)
|
||||
core.formspec_escape(gamedata.serverdescription) .. "]"
|
||||
end
|
||||
|
||||
-- Mods button
|
||||
local mods = selected_server.mods
|
||||
if mods and #mods > 0 then
|
||||
local tooltip = ""
|
||||
if selected_server.gameid then
|
||||
tooltip = "Game: " .. selected_server.gameid .. "\n"
|
||||
end
|
||||
tooltip = tooltip .. "Number of mods: " .. #mods
|
||||
|
||||
retval = retval ..
|
||||
"tooltip[btn_view_mods;" .. core.formspec_escape(tooltip) .. "]" ..
|
||||
"style[btn_view_mods;padding=6]" ..
|
||||
"image_button[4,1.3;0.5,0.5;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"server_view_mods.png") .. ";btn_view_mods;]"
|
||||
else
|
||||
retval = retval .. "image[4.1,1.4;0.3,0.3;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"server_view_mods_unavailable.png") .. "]"
|
||||
end
|
||||
|
||||
-- Clients list button
|
||||
local clients_list = selected_server.clients_list
|
||||
local can_view_clients_list = clients_list and #clients_list > 0
|
||||
if can_view_clients_list then
|
||||
@ -177,15 +197,20 @@ local function get_formspec(tabview, name, tabdata)
|
||||
retval = retval .. "style[btn_view_clients;padding=6]"
|
||||
retval = retval .. "image_button[4.5,1.3;0.5,0.5;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"server_view_clients.png") .. ";btn_view_clients;]"
|
||||
else
|
||||
retval = retval .. "image[4.6,1.4;0.3,0.3;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"server_view_clients_unavailable.png") .. "]"
|
||||
end
|
||||
|
||||
-- URL button
|
||||
if selected_server.url then
|
||||
retval = retval .. "tooltip[btn_server_url;" .. fgettext("Open server website") .. "]"
|
||||
retval = retval .. "style[btn_server_url;padding=6]"
|
||||
retval = retval .. "image_button[" .. (can_view_clients_list and "4" or "4.5") .. ",1.3;0.5,0.5;" ..
|
||||
retval = retval .. "image_button[3.5,1.3;0.5,0.5;" ..
|
||||
core.formspec_escape(defaulttexturedir .. "server_url.png") .. ";btn_server_url;]"
|
||||
end
|
||||
|
||||
-- Favorites toggle button
|
||||
if is_selected_fav() then
|
||||
retval = retval .. "tooltip[btn_delete_favorite;" .. fgettext("Remove favorite") .. "]"
|
||||
retval = retval .. "style[btn_delete_favorite;padding=6]"
|
||||
@ -387,6 +412,14 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_view_mods then
|
||||
local dlg = create_server_list_mods_dialog(find_selected_server())
|
||||
dlg:set_parent(tabview)
|
||||
tabview:hide()
|
||||
dlg:show()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_clear then
|
||||
tabdata.search_for = ""
|
||||
menudata.search_result = nil
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 218 B After Width: | Height: | Size: 146 B |
BIN
textures/base/pack/server_view_clients_unavailable.png
Normal file
BIN
textures/base/pack/server_view_clients_unavailable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 B |
BIN
textures/base/pack/server_view_mods.png
Normal file
BIN
textures/base/pack/server_view_mods.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 B |
BIN
textures/base/pack/server_view_mods_unavailable.png
Normal file
BIN
textures/base/pack/server_view_mods_unavailable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 198 B |
Loading…
Reference in New Issue
Block a user