Builtin: MainMenu update, other minor fixes
Update dlg_create_world_default.lua
This commit is contained in:
parent
b3e81ae06d
commit
11abe53d2b
@ -4,6 +4,7 @@ local COLOR_GRAY = "#BBB"
|
||||
|
||||
local LIST_FORMSPEC = [[
|
||||
size[13,6.5]
|
||||
background9[0,0;14,8;bg_common.png;true;40]
|
||||
label[0,-0.1;%s]
|
||||
tablecolumns[color;tree;text;text]
|
||||
table[0,0.5;12.8,5.5;list;%s;0]
|
||||
@ -12,14 +13,14 @@ local LIST_FORMSPEC = [[
|
||||
|
||||
local LIST_FORMSPEC_DESCRIPTION = [[
|
||||
size[13,7.5]
|
||||
background9[0,0;14,8;bg_common.png;true;40]
|
||||
label[0,-0.1;%s]
|
||||
tablecolumns[color;tree;text;text]
|
||||
table[0,0.5;12.8,4.8;list;%s;%i]
|
||||
box[0,5.5;12.8,1.5;#000]
|
||||
label[0.3,5.5;%s]
|
||||
textarea[0.3,5.5;13.05,1.9;;%s;]
|
||||
button_exit[5,7;3,1;quit;%s]
|
||||
]]
|
||||
-- textarea[0.3,5.5;13.05,1.9;;;%s] -- label for compatibility with 0.4
|
||||
|
||||
local formspec_escape = core.formspec_escape
|
||||
local check_player_privs = core.check_player_privs
|
||||
|
@ -250,11 +250,11 @@ end
|
||||
|
||||
function core.formspec_escape(text)
|
||||
if text ~= nil then
|
||||
text = string.gsub(text,"\\","\\\\")
|
||||
text = string.gsub(text,"%]","\\]")
|
||||
text = string.gsub(text,"%[","\\[")
|
||||
text = string.gsub(text,";","\\;")
|
||||
text = string.gsub(text,",","\\,")
|
||||
text = text:gsub("\\", "\\\\")
|
||||
text = text:gsub("%]", "\\]")
|
||||
text = text:gsub("%[", "\\[")
|
||||
text = text:gsub(";", "\\;")
|
||||
text = text:gsub(",", "\\,")
|
||||
end
|
||||
return text
|
||||
end
|
||||
|
@ -94,8 +94,20 @@ local function create_world_buttonhandler(this, fields)
|
||||
end
|
||||
|
||||
if gameindex ~= 0 then
|
||||
-- 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.
|
||||
if worldname == "" then
|
||||
worldname = "World " .. math.random(1000, 9999)
|
||||
menudata.worldlist:set_filtercriteria(nil) -- to count all existing worlds
|
||||
local worldnum_max = 0
|
||||
for _, world in ipairs(menudata.worldlist:get_list()) do
|
||||
-- Match "World 1" and "World 1 a" (but not "World 1a")
|
||||
local worldnum = world.name:match("^World (%d+)$") or world.name:match("^World (%d+) ")
|
||||
if worldnum then
|
||||
worldnum_max = math.max(worldnum_max, tonumber(worldnum))
|
||||
end
|
||||
end
|
||||
worldname = "World " .. worldnum_max + 1
|
||||
end
|
||||
|
||||
core.settings:set("fixed_map_seed", fields["te_seed"])
|
||||
|
@ -157,6 +157,7 @@ local function get_formspec()
|
||||
|
||||
"image_button[7.2,3.09;4,0.83;" ..
|
||||
esc(defaulttexturedir) .. creative_bg .. ";;;true;false]" ..
|
||||
"style[cb_creative_mode;content_offset=0]" ..
|
||||
"image_button[7.2,3.09;4,0.83;" ..
|
||||
esc(defaulttexturedir) .. creative_checkbox .. ";cb_creative_mode;;true;false]" ..
|
||||
|
||||
@ -166,8 +167,7 @@ local function get_formspec()
|
||||
"table[0,0;6.28,4.64;sp_worlds;" ..
|
||||
menu_render_worldlist() .. ";" .. index .. "]"
|
||||
|
||||
|
||||
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
|
||||
if not mobile then
|
||||
retval = retval ..
|
||||
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
|
||||
dump(core.settings:get_bool("enable_server")) .. "]"
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
local lang = core.settings:get("language")
|
||||
if not lang or lang == "" then lang = os.getenv("LANG") end
|
||||
local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
|
||||
|
||||
local esc = core.formspec_escape
|
||||
|
||||
@ -105,6 +106,7 @@ local function get_formspec()
|
||||
|
||||
"image_button[7.2,3.09;4,0.83;" ..
|
||||
esc(defaulttexturedir) .. creative_bg .. ";;;true;false]" ..
|
||||
"style[cb_creative_mode;content_offset=0]" ..
|
||||
"image_button[7.2,3.09;4,0.83;" ..
|
||||
esc(defaulttexturedir) .. creative_checkbox .. ";cb_creative_mode;;true;false]" ..
|
||||
|
||||
@ -121,7 +123,7 @@ local function get_formspec()
|
||||
esc(defaulttexturedir) .. "gift_btn_pressed.png]"
|
||||
end
|
||||
|
||||
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
|
||||
if not mobile then
|
||||
retval = retval ..
|
||||
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
|
||||
dump(core.settings:get_bool("enable_server")) .. "]"
|
||||
|
@ -19,6 +19,10 @@
|
||||
local password_save = core.settings:get_bool("password_save")
|
||||
local password_tmp = ""
|
||||
|
||||
local esc = core.formspec_escape
|
||||
local lower = utf8.lower
|
||||
local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
|
||||
|
||||
local function get_formspec(tabview, name, tabdata)
|
||||
-- Update the cached supported proto info,
|
||||
-- it may have changed after a change by the settings menu.
|
||||
@ -34,27 +38,23 @@ local function get_formspec(tabview, name, tabdata)
|
||||
tabdata.search_for = ""
|
||||
end
|
||||
|
||||
local esc = core.formspec_escape
|
||||
|
||||
local search_panel
|
||||
if PLATFORM == "Android" or PLATFORM == "iOS" then
|
||||
if mobile then
|
||||
search_panel =
|
||||
"field[0.2,0.1;5.19,1;te_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"style[btn_mp_search;content_offset=0]" ..
|
||||
"image_button[4.89,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "search.png") ..
|
||||
"field[0.2,0.1;5.1,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[4.87,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "search.png") ..
|
||||
";btn_mp_search;;true;false]" ..
|
||||
"image_button[5.59,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "refresh.png") ..
|
||||
"image_button[5.62,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "refresh.png") ..
|
||||
";btn_mp_refresh;;true;false]" ..
|
||||
"image_button[6.29,-0.13;0.83,0.83;" .. esc(defaulttexturedir ..
|
||||
"image_button[6.37,-0.13;0.83,0.83;" .. esc(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;te_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"style[btn_mp_search;content_offset=0]" ..
|
||||
"image_button[5.5,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "search.png") ..
|
||||
"field[0.2,0.1;5.8,1;Dte_search;;" .. esc(tabdata.search_for) .. "]" ..
|
||||
"image_button[5.62,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "search.png") ..
|
||||
";btn_mp_search;;true;false]" ..
|
||||
"image_button[6.26,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "refresh.png") ..
|
||||
"image_button[6.37,-0.13;0.83,0.83;" .. esc(defaulttexturedir .. "refresh.png") ..
|
||||
";btn_mp_refresh;;true;false]"
|
||||
end
|
||||
|
||||
@ -280,16 +280,19 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_clear then
|
||||
tabdata.search_for = ""
|
||||
menudata.search_result = nil
|
||||
if fields.btn_mp_refresh or fields.btn_mp_mobile then
|
||||
if fields.btn_mp_mobile then
|
||||
serverlistmgr.mobile_only = not serverlistmgr.mobile_only
|
||||
end
|
||||
serverlistmgr.sync()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_search or fields.key_enter_field == "te_search" then
|
||||
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 = fields.te_search:lower()
|
||||
tabdata.search_for = fields.te_search
|
||||
local input = lower(fields.Dte_search)
|
||||
tabdata.search_for = fields.Dte_search
|
||||
|
||||
if #serverlistmgr.servers < 2 then
|
||||
return true
|
||||
@ -317,13 +320,13 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
for k = 1, #keywords do
|
||||
local keyword = keywords[k]
|
||||
if server.name then
|
||||
local sername = server.name:lower()
|
||||
local sername = lower(server.name)
|
||||
local _, count = sername:gsub(keyword, keyword)
|
||||
found = found + count * 4
|
||||
end
|
||||
|
||||
if server.description then
|
||||
local desc = server.description:lower()
|
||||
local desc = lower(server.description)
|
||||
local _, count = desc:gsub(keyword, keyword)
|
||||
found = found + count * 2
|
||||
end
|
||||
@ -347,17 +350,6 @@ local function main_button_handler(tabview, fields, name, tabdata)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_refresh then
|
||||
serverlistmgr.sync()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.btn_mp_mobile then
|
||||
serverlistmgr.mobile_only = not serverlistmgr.mobile_only
|
||||
serverlistmgr.sync()
|
||||
return true
|
||||
end
|
||||
|
||||
if (fields.btn_mp_connect or fields.key_enter)
|
||||
and fields.te_address ~= "" and fields.te_port then
|
||||
gamedata.playername = fields.te_name
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 273 B |
Loading…
x
Reference in New Issue
Block a user