Small update mainmenu. Cleanup and fixes
This commit is contained in:
parent
19ae178657
commit
b79a1fd5e5
@ -514,6 +514,9 @@ function core.item_drop(itemstack, dropper, pos)
|
|||||||
local dropper_is_player = dropper and dropper:is_player()
|
local dropper_is_player = dropper and dropper:is_player()
|
||||||
local p = table.copy(pos)
|
local p = table.copy(pos)
|
||||||
local cnt = itemstack:get_count()
|
local cnt = itemstack:get_count()
|
||||||
|
if not core.is_valid_pos(p) then
|
||||||
|
return
|
||||||
|
end
|
||||||
if dropper_is_player then
|
if dropper_is_player then
|
||||||
p.y = p.y + 1.2
|
p.y = p.y + 1.2
|
||||||
if dropper:get_player_control().sneak then
|
if dropper:get_player_control().sneak then
|
||||||
|
@ -162,7 +162,7 @@ end
|
|||||||
-- Checks if specified volume intersects a protected volume
|
-- Checks if specified volume intersects a protected volume
|
||||||
-- Backport from Minetest 5.0
|
-- Backport from Minetest 5.0
|
||||||
|
|
||||||
function core.intersects_protection(minp, maxp, player_name, interval)
|
function core.is_area_protected(minp, maxp, player_name, interval)
|
||||||
-- 'interval' is the largest allowed interval for the 3D lattice of checks.
|
-- 'interval' is the largest allowed interval for the 3D lattice of checks.
|
||||||
|
|
||||||
-- Compute the optimal float step 'd' for each axis so that all corners and
|
-- Compute the optimal float step 'd' for each axis so that all corners and
|
||||||
@ -175,14 +175,18 @@ function core.intersects_protection(minp, maxp, player_name, interval)
|
|||||||
local d = {}
|
local d = {}
|
||||||
|
|
||||||
for _, c in pairs({"x", "y", "z"}) do
|
for _, c in pairs({"x", "y", "z"}) do
|
||||||
|
if minp[c] > maxp[c] then
|
||||||
|
-- Repair positions: 'minp' > 'maxp'
|
||||||
|
local tmp = maxp[c]
|
||||||
|
maxp[c] = minp[c]
|
||||||
|
minp[c] = tmp
|
||||||
|
end
|
||||||
|
|
||||||
if maxp[c] > minp[c] then
|
if maxp[c] > minp[c] then
|
||||||
d[c] = (maxp[c] - minp[c]) /
|
d[c] = (maxp[c] - minp[c]) /
|
||||||
math.ceil((maxp[c] - minp[c]) / interval) - 1e-4
|
math.ceil((maxp[c] - minp[c]) / interval) - 1e-4
|
||||||
elseif maxp[c] == minp[c] then
|
else
|
||||||
d[c] = 1 -- Any value larger than 0 to avoid division by zero
|
d[c] = 1 -- Any value larger than 0 to avoid division by zero
|
||||||
else -- maxp[c] < minp[c], print error and treat as protection intersected
|
|
||||||
core.log("error", "maxp < minp in 'minetest.intersects_protection()'")
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -192,13 +196,13 @@ function core.intersects_protection(minp, maxp, player_name, interval)
|
|||||||
local y = math.floor(yf + 0.5)
|
local y = math.floor(yf + 0.5)
|
||||||
for xf = minp.x, maxp.x, d.x do
|
for xf = minp.x, maxp.x, d.x do
|
||||||
local x = math.floor(xf + 0.5)
|
local x = math.floor(xf + 0.5)
|
||||||
if core.is_protected({x = x, y = y, z = z}, player_name) then
|
local pos = {x = x, y = y, z = z}
|
||||||
return true
|
if core.is_protected(pos, player_name) then
|
||||||
|
return pos
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ local breath_bar_definition =
|
|||||||
hud_elem_type = "statbar",
|
hud_elem_type = "statbar",
|
||||||
position = {x = 0.5, y = 1},
|
position = {x = 0.5, y = 1},
|
||||||
alignment = {x = -1, y = -1},
|
alignment = {x = -1, y = -1},
|
||||||
offset = {x = 10, y = -134},
|
offset = {x = 8, y = -134},
|
||||||
size = {x = 24, y = 24},
|
size = {x = 24, y = 24},
|
||||||
text = "bubble.png",
|
text = "bubble.png",
|
||||||
number = 20,
|
number = 20,
|
||||||
|
@ -35,7 +35,7 @@ common_update_cached_supp_proto()
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function render_client_count(n)
|
local function render_client_count(n)
|
||||||
if n > 99 then return '99+'
|
if n > 999 then return '999'
|
||||||
elseif n >= 0 then return tostring(n)
|
elseif n >= 0 then return tostring(n)
|
||||||
else return '?' end
|
else return '?' end
|
||||||
end
|
end
|
||||||
@ -54,14 +54,16 @@ end
|
|||||||
function image_column(tooltip, flagname)
|
function image_column(tooltip, flagname)
|
||||||
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
|
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
|
||||||
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
|
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
|
||||||
"1=" .. core.formspec_escape(defaulttexturedir ..
|
"1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_favorite.png") .. "," ..
|
||||||
(flagname and "server_flags_" .. flagname .. ".png" or "blank.png")) .. "," ..
|
"2=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mc.png") .. "," ..
|
||||||
"2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," ..
|
"3=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mt.png") .. "," ..
|
||||||
"3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," ..
|
"4=" .. core.formspec_escape(defaulttexturedir .. "server_flags_damage.png") .. "," ..
|
||||||
"4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," ..
|
"5=" .. core.formspec_escape(defaulttexturedir .. "server_flags_creative.png") .. "," ..
|
||||||
"5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png") .. "," ..
|
"6=" .. core.formspec_escape(defaulttexturedir .. "server_flags_pvp.png") .. "," ..
|
||||||
"6=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mc.png") .. "," ..
|
"14=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," ..
|
||||||
"7=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mt.png")
|
"13=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," ..
|
||||||
|
"12=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," ..
|
||||||
|
"11=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png")
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -102,22 +104,22 @@ function render_serverlist_row(spec, is_favorite, is_approved)
|
|||||||
details = "1,"
|
details = "1,"
|
||||||
else
|
else
|
||||||
if is_approved then
|
if is_approved then
|
||||||
details = "6,"
|
details = "2,"
|
||||||
else
|
else
|
||||||
details = "7,"
|
details = "3,"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if spec.ping then
|
if spec.ping then
|
||||||
local ping = spec.ping * 1000
|
local ping = spec.ping * 1000
|
||||||
if ping <= 50 then
|
if ping <= 50 then
|
||||||
details = details .. "2,"
|
details = details .. "14,"
|
||||||
elseif ping <= 100 then
|
elseif ping <= 100 then
|
||||||
details = details .. "3,"
|
details = details .. "13,"
|
||||||
elseif ping <= 250 then
|
elseif ping <= 250 then
|
||||||
details = details .. "4,"
|
details = details .. "12,"
|
||||||
else
|
else
|
||||||
details = details .. "5,"
|
details = details .. "11,"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
details = details .. "0,"
|
details = details .. "0,"
|
||||||
@ -147,20 +149,14 @@ function render_serverlist_row(spec, is_favorite, is_approved)
|
|||||||
details = details .. ',?,/,?,'
|
details = details .. ',?,/,?,'
|
||||||
end
|
end
|
||||||
|
|
||||||
if spec.creative then
|
|
||||||
details = details .. "1,"
|
|
||||||
else
|
|
||||||
details = details .. "0,"
|
|
||||||
end
|
|
||||||
|
|
||||||
if spec.damage then
|
if spec.damage then
|
||||||
details = details .. "1,"
|
details = details .. "4,"
|
||||||
else
|
else
|
||||||
details = details .. "0,"
|
details = details .. "5,"
|
||||||
end
|
end
|
||||||
|
|
||||||
if spec.pvp then
|
if spec.pvp then
|
||||||
details = details .. "1,"
|
details = details .. "6,"
|
||||||
else
|
else
|
||||||
details = details .. "0,"
|
details = details .. "0,"
|
||||||
end
|
end
|
||||||
|
@ -56,13 +56,13 @@ local function create_world_formspec(dialogdata)
|
|||||||
"size[11.5,3.75,false]" ..
|
"size[11.5,3.75,false]" ..
|
||||||
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
||||||
"bg_dialog.png") .. ";true]" ..
|
"bg_dialog.png") .. ";true]" ..
|
||||||
"label[2,0;" .. fgettext("World name") .. "]"..
|
"label[1.5,0;" .. fgettext("World name:") .. "]"..
|
||||||
"field[4.5,0.4;6,0.5;te_world_name;;]" ..
|
"field[4.5,0.4;6,0.5;te_world_name;;]" ..
|
||||||
|
|
||||||
"label[2,1;" .. fgettext("Seed") .. "]"..
|
"label[1.5,1;" .. fgettext("Seed:") .. "]"..
|
||||||
"field[4.5,1.4;6,0.5;te_seed;;".. current_seed .. "]" ..
|
"field[4.5,1.4;6,0.5;te_seed;;".. current_seed .. "]" ..
|
||||||
|
|
||||||
"label[2,2;" .. fgettext("Mapgen") .. "]"..
|
"label[1.5,2;" .. fgettext("Mapgen:") .. "]"..
|
||||||
"dropdown[4.2,2;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
|
"dropdown[4.2,2;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
|
||||||
|
|
||||||
"dropdown[600.2,6;6.3;games;" .. gamemgr.gamelist() .. ";1]" ..
|
"dropdown[600.2,6;6.3;games;" .. gamemgr.gamelist() .. ";1]" ..
|
||||||
|
@ -21,8 +21,7 @@ local function delete_world_formspec(dialogdata)
|
|||||||
"size[11.5,3.75,false]" ..
|
"size[11.5,3.75,false]" ..
|
||||||
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
||||||
"bg_dialog.png") .. ";true]" ..
|
"bg_dialog.png") .. ";true]" ..
|
||||||
"label[5,1.4;" ..
|
"label[5,1.4;" .. fgettext("Delete World") .. "]" ..
|
||||||
fgettext("Delete World") .. "]" ..
|
|
||||||
"label[5,1.8;" .. fgettext("\"$1\"?", dialogdata.delete_name) .. "]" ..
|
"label[5,1.8;" .. fgettext("\"$1\"?", dialogdata.delete_name) .. "]" ..
|
||||||
"button[3.25,3.4;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
|
"button[3.25,3.4;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
|
||||||
"button[5.75,3.4;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
|
"button[5.75,3.4;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
|
||||||
|
@ -36,11 +36,13 @@ dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua")
|
|||||||
dofile(menupath .. DIR_DELIM .. "common.lua")
|
dofile(menupath .. DIR_DELIM .. "common.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
|
dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "textures.lua")
|
dofile(menupath .. DIR_DELIM .. "textures.lua")
|
||||||
|
|
||||||
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
|
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
|
||||||
--dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
|
--dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
|
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
|
||||||
--dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
|
--dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
|
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
|
||||||
|
|
||||||
if not use_simple_menu then
|
if not use_simple_menu then
|
||||||
dofile(menupath .. DIR_DELIM .. "modmgr.lua")
|
dofile(menupath .. DIR_DELIM .. "modmgr.lua")
|
||||||
-- dofile(menupath .. DIR_DELIM .. "store.lua")
|
-- dofile(menupath .. DIR_DELIM .. "store.lua")
|
||||||
@ -88,14 +90,11 @@ local function init_globals()
|
|||||||
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
||||||
menudata.worldlist:set_sortmode("alphabetic")
|
menudata.worldlist:set_sortmode("alphabetic")
|
||||||
|
|
||||||
local default_game = "default"
|
|
||||||
|
|
||||||
mm_texture.init()
|
mm_texture.init()
|
||||||
|
|
||||||
-- Create main tabview
|
-- Create main tabview
|
||||||
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
|
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
|
||||||
|
|
||||||
tv_main:set_autosave_tab(true)
|
|
||||||
tv_main:add(tabs.local_game)
|
tv_main:add(tabs.local_game)
|
||||||
tv_main:add(tabs.play_online)
|
tv_main:add(tabs.play_online)
|
||||||
|
|
||||||
@ -107,15 +106,19 @@ local function init_globals()
|
|||||||
--tv_main:add(tabs.mods)
|
--tv_main:add(tabs.mods)
|
||||||
tv_main:add(tabs.credits)
|
tv_main:add(tabs.credits)
|
||||||
|
|
||||||
|
tv_main:set_autosave_tab(true)
|
||||||
tv_main:set_global_event_handler(main_event_handler)
|
tv_main:set_global_event_handler(main_event_handler)
|
||||||
tv_main:set_fixed_size(false)
|
tv_main:set_fixed_size(false)
|
||||||
|
|
||||||
tv_main:set_tab(core.settings:get("maintab_LAST"))
|
local last_tab = core.settings:get("maintab_LAST")
|
||||||
|
if last_tab and tv_main.current_tab ~= last_tab then
|
||||||
|
tv_main:set_tab(last_tab)
|
||||||
|
end
|
||||||
ui.set_default("maintab")
|
ui.set_default("maintab")
|
||||||
tv_main:show()
|
tv_main:show()
|
||||||
|
|
||||||
-- Create modstore ui
|
-- Create modstore ui
|
||||||
--if PLATFORM == "Android" then
|
--if use_simple_menu then
|
||||||
-- modstore.init({x = 12, y = 6}, 3, 2)
|
-- modstore.init({x = 12, y = 6}, 3, 2)
|
||||||
--else
|
--else
|
||||||
-- modstore.init({x = 12, y = 8}, 4, 3)
|
-- modstore.init({x = 12, y = 8}, 4, 3)
|
||||||
|
@ -81,8 +81,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
"text,align=right;" .. -- clients
|
"text,align=right;" .. -- clients
|
||||||
"text,align=center,padding=0.25;" .. -- "/"
|
"text,align=center,padding=0.25;" .. -- "/"
|
||||||
"text,align=right,padding=0.25;" .. -- clients_max
|
"text,align=right,padding=0.25;" .. -- clients_max
|
||||||
image_column(fgettext("Creative mode"), "creative") .. ",padding=0.25;" ..
|
image_column(fgettext("Server mode"), "damage") .. ",padding=0.25;" ..
|
||||||
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
|
|
||||||
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
|
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
|
||||||
"color,span=1;" ..
|
"color,span=1;" ..
|
||||||
"text,padding=0.25]" ..
|
"text,padding=0.25]" ..
|
||||||
|
@ -73,7 +73,7 @@ local Formatter = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local widths = { 55, 9, 9, 9, 5, 5, 5 }
|
local widths = { 50, 8, 8, 8, 5, 5, 5 }
|
||||||
local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths))
|
local txt_row_format = sprintf(" %%-%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds | %%%ds", unpack(widths))
|
||||||
|
|
||||||
local HR = {}
|
local HR = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user