Fix some main menu bugs and improve UI (#63)
Co-authored-by: Maksim <Maksym48@pm.me>
@ -24,8 +24,8 @@ local function buttonbar_formspec(self)
|
||||
return ""
|
||||
end
|
||||
|
||||
local formspec = string.format("box[%f,%f;%f,%f;%s]",
|
||||
self.pos.x,self.pos.y ,self.size.x,self.size.y,self.bgcolor)
|
||||
local formspec = string.format("background9[%f,%f;%f,%f;%sside_menu_left.png;false;30]",
|
||||
self.pos.x, self.pos.y - 0.1, self.size.x + 0.025, self.size.y + 0.35, defaulttexturedir)
|
||||
|
||||
for i=self.startbutton,#self.buttons,1 do
|
||||
local btn_name = self.buttons[i].name
|
||||
@ -36,7 +36,7 @@ local function buttonbar_formspec(self)
|
||||
(i - self.startbutton) * self.btn_size + --button offset
|
||||
self.btn_initial_offset
|
||||
else
|
||||
btn_pos.x = self.pos.x + (self.btn_size * 0.1)
|
||||
btn_pos.x = self.pos.x + (self.btn_size * 0.05)
|
||||
end
|
||||
|
||||
if self.orientation == "vertical" then
|
||||
@ -99,10 +99,10 @@ local function buttonbar_formspec(self)
|
||||
else
|
||||
btn_size.x = self.btn_size
|
||||
btn_size.y = self.btn_size * 0.5
|
||||
btn_dec_pos.x = self.pos.x + (self.btn_size * 0.1)
|
||||
btn_dec_pos.x = self.pos.x + (self.btn_size * 0.05)
|
||||
btn_dec_pos.y = self.pos.y + (self.btn_size * 0.05)
|
||||
btn_inc_pos.x = self.pos.x + (self.btn_size * 0.1)
|
||||
btn_inc_pos.y = self.size.y - (self.btn_size * 0.75)
|
||||
btn_inc_pos.x = self.pos.x + (self.btn_size * 0.05)
|
||||
btn_inc_pos.y = self.pos.y + self.size.y - (self.btn_size * 0.45)
|
||||
end
|
||||
|
||||
if self.orientation == "horizontal" then
|
||||
@ -141,7 +141,7 @@ end
|
||||
local function buttonbar_buttonhandler(self, fields)
|
||||
|
||||
if fields["btnbar_inc_" .. self.name] ~= nil and
|
||||
self.startbutton < #self.buttons - 5 then
|
||||
self.startbutton < #self.buttons - 4 then
|
||||
|
||||
self.startbutton = self.startbutton + 1
|
||||
return true
|
||||
|
@ -85,6 +85,7 @@ function messagebox(name, message)
|
||||
return dialog_create(name,
|
||||
function()
|
||||
return ([[
|
||||
set_focus[ok;true]
|
||||
textarea[1,1;10,4;;;%s]
|
||||
button[5,4.5;2,0.8;ok;%s]
|
||||
]]):format(message, fgettext("OK"))
|
||||
|
@ -26,6 +26,8 @@
|
||||
-- element.getFormspec() returns formspec of tabview --
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function add_tab(self,tab)
|
||||
assert(tab.size == nil or (type(tab.size) == table and
|
||||
@ -49,6 +51,7 @@ local function add_tab(self,tab)
|
||||
-- Hidden tabs have a negative index
|
||||
local i
|
||||
if tab.hidden then
|
||||
newtab.tabdata.hidden = true
|
||||
i = -1
|
||||
while self.tablist[i] do
|
||||
i = i - 1
|
||||
@ -67,6 +70,21 @@ local function add_tab(self,tab)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
local function make_side_pane_tab(y, tab_name, tooltip, selected)
|
||||
local formspec = "style[" .. tab_name .. "_tab;bgimg=" ..
|
||||
defaulttexturedir .. tab_name
|
||||
if selected then
|
||||
formspec = formspec .. "_menu_selected.png]"
|
||||
else
|
||||
formspec = formspec .. "_menu.png;bgimg_hovered=" ..
|
||||
defaulttexturedir .. tab_name .. "_menu_hover.png]"
|
||||
end
|
||||
|
||||
return formspec ..
|
||||
"image_button[12.1," .. y .. ";1,1.5;;" .. tab_name .. "_tab;;true;false]" ..
|
||||
"tooltip[" .. tab_name .. "_tab;" .. tooltip .. "]"
|
||||
end
|
||||
|
||||
local function get_formspec(self)
|
||||
local formspec = ""
|
||||
|
||||
@ -76,7 +94,6 @@ local function get_formspec(self)
|
||||
if self.parent == nil then
|
||||
local tsize = self.tablist[self.last_tab_index].tabsize or
|
||||
{width=self.width, height=self.height}
|
||||
local defaulttexturedir = core.formspec_escape(defaulttexturedir)
|
||||
formspec = formspec ..
|
||||
string.format("size[%f,%f,%s]",tsize.width + 2,tsize.height + 1,
|
||||
dump(self.fixed_size)) ..
|
||||
@ -85,19 +102,15 @@ local function get_formspec(self)
|
||||
"background9[-0.2,-1.26;" .. tsize.width + 0.4 .. "," ..
|
||||
tsize.height + 1.75 .. ";" .. defaulttexturedir ..
|
||||
"bg_common.png;false;40]" ..
|
||||
"style[settings_tab;content_offset=0]" ..
|
||||
"image_button[12.02,1.3;1,1.55;" ..
|
||||
defaulttexturedir .. "settings_menu.png;settings_tab;;true;false;" ..
|
||||
defaulttexturedir .. "settings_menu_pressed.png]" ..
|
||||
"style[authors_tab;content_offset=0]" ..
|
||||
"image_button[12.02,2.7;1,1.55;" ..
|
||||
defaulttexturedir .. "authors_menu.png;authors_tab;;true;false;" ..
|
||||
defaulttexturedir .. "authors_menu_pressed.png]"
|
||||
|
||||
"background9[12.13,1.05;0.9,2.6;" .. defaulttexturedir .. "side_menu.png;false;30]" ..
|
||||
make_side_pane_tab(0.9, "settings", fgettext("Settings"), name == "settings") ..
|
||||
"image[12.15,2.26;0.9,0.06;" .. defaulttexturedir .. "side_menu_divider.png]" ..
|
||||
make_side_pane_tab(2.3, "authors", fgettext("Credits"), name == "credits")
|
||||
end
|
||||
|
||||
-- formspec = formspec .. self:tab_header()
|
||||
formspec = formspec .. self:button_header()
|
||||
formspec = formspec ..
|
||||
formspec = formspec .. self:button_header() ..
|
||||
self.tablist[self.last_tab_index].get_formspec(
|
||||
self,
|
||||
name,
|
||||
@ -269,17 +282,18 @@ end
|
||||
--------------------------------------------------------------------------------
|
||||
local function handle_tab_buttons(self,fields)
|
||||
--save tab selection to config file
|
||||
if fields[self.name] then
|
||||
--[[if fields[self.name] then
|
||||
local index = tonumber(fields[self.name])
|
||||
switch_to_tab(self, index)
|
||||
return true
|
||||
end
|
||||
end]]
|
||||
|
||||
local name_prefix = self.name .. "_"
|
||||
local name_prefix_len = #name_prefix
|
||||
for field in pairs(fields) do
|
||||
if field:sub(1, name_prefix_len) == name_prefix then
|
||||
local index = tonumber(field:sub(name_prefix_len + 1))
|
||||
if self.last_tab_index == index then return false end
|
||||
switch_to_tab(self, index)
|
||||
return true
|
||||
end
|
||||
|
@ -59,6 +59,10 @@ end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function render_serverlist_row(spec, is_favorite)
|
||||
if not spec then
|
||||
spec = {}
|
||||
end
|
||||
|
||||
-- Get information from non_mobile_servers.
|
||||
if is_favorite and not spec.proto_min and spec.address and spec.port and
|
||||
serverlistmgr.non_mobile_servers then
|
||||
|
@ -1004,6 +1004,11 @@ function create_store_dlg(type)
|
||||
search_string = ""
|
||||
cur_page = 1
|
||||
|
||||
-- ToDo: delete me when MultiCraft ContentDB is ready
|
||||
if type and type ~= "game" then
|
||||
type = "game"
|
||||
end
|
||||
|
||||
if type then
|
||||
-- table.indexof does not work on tables that contain `nil`
|
||||
for i, v in pairs(filter_types_type) do
|
||||
|
@ -388,6 +388,12 @@ local function create_world_buttonhandler(this, fields)
|
||||
gameindex = gameindex + 1
|
||||
end
|
||||
|
||||
if not pkgmgr.games[gameindex] then
|
||||
gamedata.errormessage = fgettext("No game selected")
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
-- For unnamed worlds use the generated name 'World <number>',
|
||||
-- where the number increments: it is set to 1 larger than the largest
|
||||
-- generated name number found.
|
||||
@ -457,7 +463,9 @@ local function create_world_buttonhandler(this, fields)
|
||||
if gameindex >= pkgmgr.default_game_idx then
|
||||
gameindex = gameindex + 1
|
||||
end
|
||||
core.settings:set("menu_last_game", pkgmgr.games[gameindex].id)
|
||||
local game = pkgmgr.games[gameindex]
|
||||
if not game then return end
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -70,6 +70,16 @@ end
|
||||
function create_delete_content_dlg(content)
|
||||
assert(content.name)
|
||||
|
||||
if content.type == "game" then
|
||||
for _, world in ipairs(menudata.worldlist:get_raw_list()) do
|
||||
if world.gameid == content.id then
|
||||
return messagebox("dlg_delete_content",
|
||||
fgettext("You cannot delete this game!") .. "\n" ..
|
||||
fgettext("You have worlds that use it."))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local retval = dialog_create("dlg_delete_content",
|
||||
delete_content_formspec,
|
||||
delete_content_buttonhandler,
|
||||
|
@ -109,6 +109,7 @@ function menudata.init_tabs()
|
||||
for i = 1, #pkgmgr.games do
|
||||
if pkgmgr.games[i].id == "default" then
|
||||
tv_main:add(tabs.local_default_game)
|
||||
tabs.local_game.hidden = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
@ -66,7 +66,9 @@ local function get_formspec(tabview, name, tabdata)
|
||||
"table[0,0.25;5.1,4.3;pkglist;" ..
|
||||
pkgmgr.render_packagelist(packages) ..
|
||||
";" .. tabdata.selected_pkg .. "]" ..
|
||||
"button[0,4.85;5.25,0.5;btn_contentdb;".. fgettext("Browse online content") .. "]"
|
||||
"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]"
|
||||
|
||||
|
||||
local selected_pkg
|
||||
@ -144,8 +146,7 @@ local function get_formspec(tabview, name, tabdata)
|
||||
retval = retval .. "textarea[5.85,2.2;6.35,2.9;;" ..
|
||||
fgettext("Information:") .. ";" .. desc .. "]"
|
||||
|
||||
if core.may_modify_path(selected_pkg.path) and not
|
||||
(selected_pkg.type == "game" and selected_pkg.name == "default") then
|
||||
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") .. "]"
|
||||
|
@ -118,17 +118,19 @@ return {
|
||||
caption = "", -- fgettext("Credits"),
|
||||
cbf_formspec = function(tabview, name, tabdata)
|
||||
local version = core.get_version()
|
||||
local fs = "label[0.05,-0.2;" ..
|
||||
local logofile = defaulttexturedir .. "logo.png"
|
||||
local fs = "image[-0.1,-0.3;2,2;" .. logofile .. "]" ..
|
||||
"label[1.4,-0.25;" ..
|
||||
"MultiCraft Open Source, ver. " .. version.string .. "\n" ..
|
||||
"Copyright (C) 2014-2022 MultiCraft Development Team\n" ..
|
||||
"License: GNU LGPLv3.0+ and CC BY-SA 4.0\n" ..
|
||||
"Created and Powered by Minetest Engine, ver. 5.4.1]" ..
|
||||
|
||||
"style[homepage;padding=-10;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=20]" ..
|
||||
"style[homepage;padding=-5;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=10]" ..
|
||||
"image_button[9.5,-0.25;2.5,0.9;;homepage;Home Page;true;false]" ..
|
||||
"style[privacy;padding=-10;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=20]" ..
|
||||
"style[privacy;padding=-5;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=10]" ..
|
||||
"image_button[9.5,0.6;2.5,0.9;;privacy;Privacy Policy;true;false]" ..
|
||||
|
||||
"background9[0.1,1.5;11.85,4.15;" .. defaulttexturedir ..
|
||||
@ -136,9 +138,9 @@ return {
|
||||
"tablecolumns[color;text]" ..
|
||||
"tableoptions[background=#0000;highlight=#00000000;border=false]" ..
|
||||
"table[0.1,1.5;11.65,4;list_credits;" ..
|
||||
"#FFFF00," .. fgettext("MultiCraft Developers") .. ",," ..
|
||||
"#FFFF00," .. fgettext("Core Developers") .. " (MultiCraft)" .. ",," ..
|
||||
buildCreditList(multicraft_developers) .. ",,," ..
|
||||
"#FFFF00," .. fgettext("Minetest Developers") .. ",," ..
|
||||
"#FFFF00," .. fgettext("Core Developers") .. " (Minetest Engine)" .. ",," ..
|
||||
buildCreditList(core_developers) .. ",,," ..
|
||||
"#FFFF00," .. fgettext("Active Contributors") .. ",," ..
|
||||
buildCreditList(active_contributors) .. ",,," ..
|
||||
|
@ -71,7 +71,7 @@ local function singleplayer_refresh_gamebar()
|
||||
|
||||
local btnbar = buttonbar_create("game_button_bar",
|
||||
game_buttonbar_button_handler,
|
||||
{x=-0.35, y=-0.32}, "vertical", {x=1, y=7.14})
|
||||
{x=-0.15, y=0.18}, "vertical", {x=1, y=6.14})
|
||||
|
||||
for i=1, #pkgmgr.games do
|
||||
if pkgmgr.games[i].id ~= "default" then
|
||||
@ -103,7 +103,7 @@ local function singleplayer_refresh_gamebar()
|
||||
btnbar:add_button("game_open_cdb", "", "", fgettext("Install games from ContentDB"), true)
|
||||
end
|
||||
|
||||
local function get_formspec()
|
||||
local function get_formspec(_, _, tab_data)
|
||||
local index = filterlist.get_current_index(menudata.worldlist,
|
||||
tonumber(core.settings:get("mainmenu_last_selected_world")))
|
||||
|
||||
@ -141,16 +141,19 @@ local function get_formspec()
|
||||
|
||||
"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 .. "]"
|
||||
|
||||
if tab_data.hidden then
|
||||
retval = retval ..
|
||||
"style[switch_local_default;fgimg=" .. defaulttexturedir .. "switch_local_default.png;fgimg_hovered=" ..
|
||||
defaulttexturedir .. "switch_local_default_hover.png]" ..
|
||||
"image_button[10.6,-0.1;1.5,1.5;;switch_local_default;;true;false]"
|
||||
end
|
||||
|
||||
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
|
||||
retval = retval ..
|
||||
"style[world_configure;padding=-10;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=20]" ..
|
||||
"style[world_configure;padding=-5;bgimg=" .. defaulttexturedir ..
|
||||
"select_btn.png;bgimg_middle=10]" ..
|
||||
"image_button[9.3,4.84;2.7,0.92;;world_configure;" .. fgettext("Select Mods") .. ";true;false]"
|
||||
end
|
||||
|
||||
@ -239,7 +242,7 @@ local function main_button_handler(this, fields, name)
|
||||
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
|
||||
if world then
|
||||
local game = pkgmgr.find_by_gameid(world.gameid)
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
core.settings:set("menu_last_game", (game and game.id or ""))
|
||||
end
|
||||
|
||||
if core.settings:get_bool("enable_server") then
|
||||
@ -321,7 +324,14 @@ local function main_button_handler(this, fields, name)
|
||||
end
|
||||
|
||||
if fields["game_open_cdb"] then
|
||||
this:set_tab("content")
|
||||
if #pkgmgr.games > 1 or (pkgmgr.games[1] and pkgmgr.games[1].id ~= "default") then
|
||||
this:set_tab("content")
|
||||
else
|
||||
local dlg = create_store_dlg()
|
||||
dlg:set_parent(this)
|
||||
this:hide()
|
||||
dlg:show()
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
@ -347,7 +357,7 @@ local function on_change(type, old_tab, new_tab)
|
||||
|
||||
local game = current_game()
|
||||
|
||||
if game then
|
||||
if game and game.id ~= "default" then
|
||||
menudata.worldlist:set_filtercriteria(game.id)
|
||||
mm_texture.update("singleplayer",game)
|
||||
end
|
||||
@ -371,7 +381,6 @@ end
|
||||
return {
|
||||
name = "local",
|
||||
caption = fgettext("Singleplayer"),
|
||||
hidden = true,
|
||||
cbf_formspec = get_formspec,
|
||||
cbf_button_handler = main_button_handler,
|
||||
on_change = on_change
|
||||
|
@ -118,7 +118,7 @@ local function get_formspec(this)
|
||||
defaulttexturedir .. "gift_btn_pressed.png]"
|
||||
end
|
||||
|
||||
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
|
||||
if PLATFORM ~= "iOS" then
|
||||
retval = retval ..
|
||||
"style[switch_local;fgimg=" .. defaulttexturedir .. "switch_local.png;fgimg_hovered=" ..
|
||||
defaulttexturedir .. "switch_local_hover.png]" ..
|
||||
|
@ -371,7 +371,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
gamedata.playername = fields.te_name
|
||||
gamedata.password = fields.te_pwd
|
||||
gamedata.address = fields.te_address
|
||||
gamedata.port = tonumber(fields.te_port)
|
||||
gamedata.port = tonumber(fields.te_port) or 30000
|
||||
gamedata.selected_world = 0
|
||||
local fav_idx = core.get_table_index("favorites")
|
||||
local fav = serverlist[fav_idx]
|
||||
|
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 279 B |
BIN
textures/base/pack/authors_menu_hover.png
Normal file
After Width: | Height: | Size: 277 B |
Before Width: | Height: | Size: 354 B |
BIN
textures/base/pack/authors_menu_selected.png
Normal file
After Width: | Height: | Size: 280 B |
BIN
textures/base/pack/logo.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 647 B After Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 328 B After Width: | Height: | Size: 279 B |
BIN
textures/base/pack/settings_menu_hover.png
Normal file
After Width: | Height: | Size: 279 B |
Before Width: | Height: | Size: 337 B |
BIN
textures/base/pack/settings_menu_selected.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
textures/base/pack/side_menu.png
Normal file
After Width: | Height: | Size: 193 B |
BIN
textures/base/pack/side_menu_divider.png
Normal file
After Width: | Height: | Size: 570 B |
BIN
textures/base/pack/side_menu_left.png
Normal file
After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |