'New' menu
This commit is contained in:
parent
17a173f474
commit
abca1d9c91
@ -69,7 +69,7 @@ local function get_formspec(self)
|
|||||||
string.format("size[%f,%f,%s]",tsize.width,tsize.height,
|
string.format("size[%f,%f,%s]",tsize.width,tsize.height,
|
||||||
dump(self.fixed_size))
|
dump(self.fixed_size))
|
||||||
end
|
end
|
||||||
formspec = formspec .. self:tab_header()
|
--formspec = formspec .. self:tab_header()
|
||||||
formspec = formspec ..
|
formspec = formspec ..
|
||||||
self.tablist[self.last_tab_index].get_formspec(
|
self.tablist[self.last_tab_index].get_formspec(
|
||||||
self,
|
self,
|
||||||
@ -214,60 +214,60 @@ end
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function show_tabview(self)
|
local function show_tabview(self)
|
||||||
self.hidden=false
|
self.hidden=false
|
||||||
|
|
||||||
-- call for tab to enter
|
-- call for tab to enter
|
||||||
if self.tablist[self.last_tab_index].on_change ~= nil then
|
if self.tablist[self.last_tab_index].on_change ~= nil then
|
||||||
self.tablist[self.last_tab_index].on_change("ENTER",
|
self.tablist[self.last_tab_index].on_change("ENTER",
|
||||||
nil,self.current_tab)
|
nil,self.current_tab)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tabview_metatable = {
|
local tabview_metatable = {
|
||||||
add = add_tab,
|
add = add_tab,
|
||||||
handle_buttons = handle_buttons,
|
handle_buttons = handle_buttons,
|
||||||
handle_events = handle_events,
|
handle_events = handle_events,
|
||||||
get_formspec = get_formspec,
|
get_formspec = get_formspec,
|
||||||
show = show_tabview,
|
show = show_tabview,
|
||||||
hide = hide_tabview,
|
hide = hide_tabview,
|
||||||
delete = function(self) ui.delete(self) end,
|
delete = function(self) ui.delete(self) end,
|
||||||
set_parent = function(self,parent) self.parent = parent end,
|
set_parent = function(self,parent) self.parent = parent end,
|
||||||
set_autosave_tab =
|
set_autosave_tab =
|
||||||
function(self,value) self.autosave_tab = value end,
|
function(self,value) self.autosave_tab = value end,
|
||||||
set_tab = set_tab_by_name,
|
set_tab = set_tab_by_name,
|
||||||
set_global_button_handler =
|
set_global_button_handler =
|
||||||
function(self,handler) self.glb_btn_handler = handler end,
|
function(self,handler) self.glb_btn_handler = handler end,
|
||||||
set_global_event_handler =
|
set_global_event_handler =
|
||||||
function(self,handler) self.glb_evt_handler = handler end,
|
function(self,handler) self.glb_evt_handler = handler end,
|
||||||
set_fixed_size =
|
set_fixed_size =
|
||||||
function(self,state) self.fixed_size = state end,
|
function(self,state) self.fixed_size = state end,
|
||||||
tab_header = tab_header,
|
tab_header = tab_header,
|
||||||
handle_tab_buttons = handle_tab_buttons
|
handle_tab_buttons = handle_tab_buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
tabview_metatable.__index = tabview_metatable
|
tabview_metatable.__index = tabview_metatable
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function tabview_create(name, size, tabheaderpos)
|
function tabview_create(name, size, tabheaderpos)
|
||||||
local self = {}
|
local self = {}
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self.type = "toplevel"
|
self.type = "toplevel"
|
||||||
self.width = size.x
|
self.width = size.x
|
||||||
self.height = size.y
|
self.height = size.y
|
||||||
self.header_x = tabheaderpos.x
|
self.header_x = tabheaderpos.x
|
||||||
self.header_y = tabheaderpos.y
|
self.header_y = tabheaderpos.y
|
||||||
|
|
||||||
setmetatable(self, tabview_metatable)
|
setmetatable(self, tabview_metatable)
|
||||||
|
|
||||||
self.fixed_size = true
|
self.fixed_size = true
|
||||||
self.hidden = true
|
self.hidden = true
|
||||||
self.current_tab = nil
|
self.current_tab = nil
|
||||||
self.last_tab_index = 1
|
self.last_tab_index = 1
|
||||||
self.tablist = {}
|
self.tablist = {}
|
||||||
|
|
||||||
self.autosave_tab = false
|
self.autosave_tab = false
|
||||||
|
|
||||||
ui.add(self)
|
ui.add(self)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
@ -809,3 +809,4 @@ core.register_chatcommand("last-login", {
|
|||||||
return false, "Last login time is unknown"
|
return false, "Last login time is unknown"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ local max_supp_proto = core.get_max_supp_proto()
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function render_client_count(n)
|
local function render_client_count(n)
|
||||||
|
n = tonumber(n)
|
||||||
if n > 99 then
|
if n > 99 then
|
||||||
return '99+'
|
return '99+'
|
||||||
elseif n >= 0 then
|
elseif n >= 0 then
|
||||||
@ -66,13 +67,13 @@ function order_favorite_list(list)
|
|||||||
--orders the favorite list after support
|
--orders the favorite list after support
|
||||||
for i=1,#list,1 do
|
for i=1,#list,1 do
|
||||||
local fav = list[i]
|
local fav = list[i]
|
||||||
if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
|
if is_server_protocol_compat(tonumber(fav.proto_min), tonumber(fav.proto_max)) then
|
||||||
table.insert(res, fav)
|
table.insert(res, fav)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i=1,#list,1 do
|
for i=1,#list,1 do
|
||||||
local fav = list[i]
|
local fav = list[i]
|
||||||
if not is_server_protocol_compat(fav.proto_min, fav.proto_max) then
|
if not is_server_protocol_compat(tonumber(fav.proto_min), tonumber(fav.proto_max)) then
|
||||||
table.insert(res, fav)
|
table.insert(res, fav)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -105,7 +106,7 @@ function render_favorite(spec,render_details)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local details = ""
|
local details = ""
|
||||||
local grey_out = not is_server_protocol_compat(spec.proto_max, spec.proto_min)
|
local grey_out = not is_server_protocol_compat(tonumber(spec.proto_max), tonumber(spec.proto_min))
|
||||||
|
|
||||||
if spec.clients ~= nil and spec.clients_max ~= nil then
|
if spec.clients ~= nil and spec.clients_max ~= nil then
|
||||||
local clients_color = ''
|
local clients_color = ''
|
||||||
@ -234,59 +235,59 @@ end
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function asyncOnlineFavourites()
|
function asyncOnlineFavourites()
|
||||||
|
|
||||||
menudata.favorites = {}
|
menudata.favorites = {}
|
||||||
core.handle_async(
|
core.handle_async(
|
||||||
function(param)
|
function(param)
|
||||||
return core.get_favorites("online")
|
return core.get_favorites("online")
|
||||||
end,
|
end,
|
||||||
nil,
|
nil,
|
||||||
function(result)
|
function(result)
|
||||||
if core.setting_getbool("public_serverlist") then
|
if core.setting_getbool("public_serverlist") then
|
||||||
menudata.favorites = order_favorite_list(result)
|
menudata.favorites = order_favorite_list(result)
|
||||||
core.event_handler("Refresh")
|
core.event_handler("Refresh")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
|
function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
|
||||||
local textlines = core.splittext(text,textlen)
|
local textlines = core.splittext(text,textlen)
|
||||||
|
|
||||||
local retval = "textlist[" .. xpos .. "," .. ypos .. ";"
|
local retval = "textlist[" .. xpos .. "," .. ypos .. ";"
|
||||||
.. width .. "," .. height .. ";"
|
.. width .. "," .. height .. ";"
|
||||||
.. tl_name .. ";"
|
.. tl_name .. ";"
|
||||||
|
|
||||||
for i=1, #textlines, 1 do
|
for i=1, #textlines, 1 do
|
||||||
textlines[i] = textlines[i]:gsub("\r","")
|
textlines[i] = textlines[i]:gsub("\r","")
|
||||||
retval = retval .. core.formspec_escape(textlines[i]) .. ","
|
retval = retval .. core.formspec_escape(textlines[i]) .. ","
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval .. ";0;"
|
retval = retval .. ";0;"
|
||||||
|
|
||||||
if transparency then
|
if transparency then
|
||||||
retval = retval .. "true"
|
retval = retval .. "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval .. "]"
|
retval = retval .. "]"
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function is_server_protocol_compat(proto_min, proto_max)
|
function is_server_protocol_compat(proto_min, proto_max)
|
||||||
return not ((min_supp_proto > (proto_max or 24)) or (max_supp_proto < (proto_min or 13)))
|
return not ((min_supp_proto > (proto_max or 24)) or (max_supp_proto < (proto_min or 13)))
|
||||||
end
|
end
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
function is_server_protocol_compat_or_error(proto_min, proto_max)
|
function is_server_protocol_compat_or_error(proto_min, proto_max)
|
||||||
if not is_server_protocol_compat(proto_min, proto_max) then
|
if not is_server_protocol_compat(proto_min, proto_max) then
|
||||||
gamedata.errormessage = fgettext_ne("Protocol version mismatch, server " ..
|
gamedata.errormessage = fgettext_ne("Protocol version mismatch, server " ..
|
||||||
((proto_min ~= proto_max) and "supports protocols between $1 and $2" or "enforces protocol version $1") ..
|
((proto_min ~= proto_max) and "supports protocols between $1 and $2" or "enforces protocol version $1") ..
|
||||||
", we " ..
|
", we " ..
|
||||||
((min_supp_proto ~= max_supp_proto) and "support protocols between version $3 and $4." or "only support protocol version $3"),
|
((min_supp_proto ~= max_supp_proto) and "support protocols between version $3 and $4." or "only support protocol version $3"),
|
||||||
proto_min or 13, proto_max or 24, min_supp_proto, max_supp_proto)
|
proto_min or 13, proto_max or 24, min_supp_proto, max_supp_proto)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -45,14 +45,14 @@ local function get_formspec(data)
|
|||||||
mod = {name=""}
|
mod = {name=""}
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"label[0,0.45;" .. fgettext("Mod:") .. "]" ..
|
"label[0,0.45;" .. fgettext("Mod:") .. "]" ..
|
||||||
"label[0.75,0.45;" .. mod.name .. "]" ..
|
"label[0.75,0.45;" .. mod.name .. "]" ..
|
||||||
"label[0,1;" .. fgettext("Depends:") .. "]" ..
|
"label[0,1;" .. fgettext("Depends:") .. "]" ..
|
||||||
"textlist[0,1.5;5,4.25;world_config_depends;" ..
|
"textlist[0,1.5;5,4.25;world_config_depends;" ..
|
||||||
modmgr.get_dependencies(mod.path) .. ";0]" ..
|
modmgr.get_dependencies(mod.path) .. ";0]" ..
|
||||||
"button[9.25,6.35;2,0.5;btn_config_world_save;" .. fgettext("Save") .. "]" ..
|
"image_button[9.25,6.35;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_save;" .. fgettext("Save") .. "]" ..
|
||||||
"button[7.4,6.35;2,0.5;btn_config_world_cancel;" .. fgettext("Cancel") .. "]"
|
"image_button[7.4,6.35;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_cancel;" .. fgettext("Cancel") .. "]"
|
||||||
|
|
||||||
if mod ~= nil and mod.name ~= "" and mod.typ ~= "game_mod" then
|
if mod ~= nil and mod.name ~= "" and mod.typ ~= "game_mod" then
|
||||||
if mod.is_modpack then
|
if mod.is_modpack then
|
||||||
@ -68,9 +68,9 @@ local function get_formspec(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if all_enabled == false then
|
if all_enabled == false then
|
||||||
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_enable;" .. fgettext("Enable MP") .. "]"
|
retval = retval .. "image_button[5.5,-0.125;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_enable;" .. fgettext("Enable MP") .. "]"
|
||||||
else
|
else
|
||||||
retval = retval .. "button[5.5,-0.125;2,0.5;btn_mp_disable;" .. fgettext("Disable MP") .. "]"
|
retval = retval .. "image_button[5.5,-0.125;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_disable;" .. fgettext("Disable MP") .. "]"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if mod.enabled then
|
if mod.enabled then
|
||||||
@ -82,7 +82,7 @@ local function get_formspec(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[8.5,-0.125;2.5,0.5;btn_all_mods;" .. fgettext("Enable all") .. "]" ..
|
"image_button[8.5,-0.125;2.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_all_mods;" .. fgettext("Enable all") .. "]" ..
|
||||||
"textlist[5.5,0.5;5.5,5.75;world_config_modlist;"
|
"textlist[5.5,0.5;5.5,5.75;world_config_modlist;"
|
||||||
|
|
||||||
retval = retval .. modmgr.render_modlist(data.list)
|
retval = retval .. modmgr.render_modlist(data.list)
|
||||||
|
@ -60,8 +60,8 @@ local function create_world_formspec(dialogdata)
|
|||||||
"textlist[4.2,3;5.8,2.3;games;" .. gamemgr.gamelist() ..
|
"textlist[4.2,3;5.8,2.3;games;" .. gamemgr.gamelist() ..
|
||||||
";" .. gameidx .. ";true]" ..
|
";" .. gameidx .. ";true]" ..
|
||||||
|
|
||||||
"button[5,5.5;2.6,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
|
"image_button[5,5.5;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_confirm;" .. fgettext("Create") .. "]" ..
|
||||||
"button[7.5,5.5;2.8,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
|
"image_button[7.5,5.5;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_cancel;" .. fgettext("Cancel") .. "]"
|
||||||
|
|
||||||
if #gamemgr.games == 0 then
|
if #gamemgr.games == 0 then
|
||||||
retval = retval .. "box[2,4;8,1;#ff8800]label[2.25,4;" ..
|
retval = retval .. "box[2,4;8,1;#ff8800]label[2.25,4;" ..
|
||||||
|
@ -24,8 +24,8 @@ local function delete_mod_formspec(dialogdata)
|
|||||||
local retval =
|
local retval =
|
||||||
"size[12.4,5,true]" ..
|
"size[12.4,5,true]" ..
|
||||||
"field[1.75,1;10,3;;" .. fgettext("Are you sure you want to delete \"$1\"?", dialogdata.mod.name) .. ";]"..
|
"field[1.75,1;10,3;;" .. fgettext("Are you sure you want to delete \"$1\"?", dialogdata.mod.name) .. ";]"..
|
||||||
"button[4,4.2;1,0.5;dlg_delete_mod_confirm;" .. fgettext("Yes") .. "]" ..
|
"image_button[4,4.2;1,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_confirm;" .. fgettext("Yes") .. "]" ..
|
||||||
"button[6.5,4.2;3,0.5;dlg_delete_mod_cancel;" .. fgettext("No of course not!") .. "]"
|
"image_button[6.5,4.2;3,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_cancel;" .. fgettext("No of course not!") .. "]"
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
|
@ -22,8 +22,8 @@ local function delete_world_formspec(dialogdata)
|
|||||||
"size[12,6,true]" ..
|
"size[12,6,true]" ..
|
||||||
"label[2,2;" ..
|
"label[2,2;" ..
|
||||||
fgettext("Delete World \"$1\"?", dialogdata.delete_name) .. "]"..
|
fgettext("Delete World \"$1\"?", dialogdata.delete_name) .. "]"..
|
||||||
"button[3.5,4.2;2.6,0.5;world_delete_confirm;" .. fgettext("Yes").. "]" ..
|
"image_button[3.5,4.2;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_confirm;" .. fgettext("Yes").. "]" ..
|
||||||
"button[6,4.2;2.8,0.5;world_delete_cancel;" .. fgettext("No") .. "]"
|
"image_button[6,4.2;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_cancel;" .. fgettext("No") .. "]"
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ local function rename_modpack_formspec(dialogdata)
|
|||||||
"field[4.5,1.4;6,0.5;te_modpack_name;;" ..
|
"field[4.5,1.4;6,0.5;te_modpack_name;;" ..
|
||||||
dialogdata.mod.name ..
|
dialogdata.mod.name ..
|
||||||
"]" ..
|
"]" ..
|
||||||
"button[5,4.2;2.6,0.5;dlg_rename_modpack_confirm;"..
|
"image_button[5,4.2;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_confirm;"..
|
||||||
fgettext("Accept") .. "]" ..
|
fgettext("Accept") .. "]" ..
|
||||||
"button[7.5,4.2;2.8,0.5;dlg_rename_modpack_cancel;"..
|
"image_button[7.5,4.2;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_cancel;"..
|
||||||
fgettext("Cancel") .. "]"
|
fgettext("Cancel") .. "]"
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
|
@ -41,7 +41,6 @@ dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
|
|||||||
dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
|
dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
|
dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
|
dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
|
||||||
if PLATFORM ~= "Android" then
|
|
||||||
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")
|
||||||
@ -51,9 +50,6 @@ if PLATFORM ~= "Android" then
|
|||||||
dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
|
dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
|
dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
|
||||||
dofile(menupath .. DIR_DELIM .. "textures.lua")
|
dofile(menupath .. DIR_DELIM .. "textures.lua")
|
||||||
else
|
|
||||||
dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function main_event_handler(tabview, event)
|
local function main_event_handler(tabview, event)
|
||||||
@ -63,89 +59,130 @@ local function main_event_handler(tabview, event)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function get_formspec2(tabview, name, tabdata)
|
||||||
|
local retval = ""
|
||||||
|
retval = retval .. "bgcolor[#00000000;false]"
|
||||||
|
retval = retval .. "image_button[2.5,3.4;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir) .. "menu_button.png;btn_show_multiplayer;" .. fgettext("Multiplayer") .. ";true;true;" .. minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
|
||||||
|
retval = retval .. "image_button[2.5,4.8;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_options;".. fgettext("Options") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
|
||||||
|
--retval = retval .. "image_button[8.5,4.8;1,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_help;?;true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
|
||||||
|
retval = retval .. "image_button[2.5,6.2;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_exit;".. fgettext("Exit") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
|
||||||
|
retval = retval .. "image_button[2.5,2.0;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_singleplayer;".. fgettext("Singleplayer") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
|
||||||
|
|
||||||
|
local si = core.get_screen_info()
|
||||||
|
|
||||||
|
local ydiv = si.window_height/5.2
|
||||||
|
local xdiv = si.window_width/12.5
|
||||||
|
local ratio = xdiv/ydiv
|
||||||
|
--print(xdiv..' x '..ydiv..' = '..ratio)
|
||||||
|
|
||||||
|
math.randomseed(os.time())
|
||||||
|
--local rnd = 'image['.. 12*ratio ..','.. 1 .. ';6,0.5;'..minetest.formspec_escape(mm_texture.basetexturedir)..'ad_label'..tostring(math.random(1,14))..'.png]'
|
||||||
|
|
||||||
|
return retval --.. rnd
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local function main_button_handler2(tabview, fields, name, tabdata)
|
||||||
|
local index = ''
|
||||||
|
if fields["btn_show_singleplayer"] then index = "singleplayer" end
|
||||||
|
if fields["btn_show_multiplayer"] then index = "multiplayer" end
|
||||||
|
if fields["btn_show_options"] then index = "settings" end
|
||||||
|
if fields["btn_show_help"] then index = "help" end
|
||||||
|
if fields["btn_exit"] then core.close() end
|
||||||
|
|
||||||
|
if index == '' then return end
|
||||||
|
for name,def in pairs(tabview.tablist) do
|
||||||
|
local fs
|
||||||
|
if index == 'singleplayer' then
|
||||||
|
fs = create_tab_single(true)
|
||||||
|
elseif index == 'multiplayer' then
|
||||||
|
fs = create_tab_multiplayer()
|
||||||
|
elseif index == 'settings' then
|
||||||
|
fs = create_tab_settings(true)
|
||||||
|
end
|
||||||
|
if fs then
|
||||||
|
fs:set_parent(tabview.parent or tabview)
|
||||||
|
tabview:hide()
|
||||||
|
fs:show()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function on_activate2(type,old_tab,new_tab)
|
||||||
|
if type == "LEAVE" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if core.setting_getbool("public_serverlist") then
|
||||||
|
asyncOnlineFavourites()
|
||||||
|
else
|
||||||
|
menudata.favorites = core.get_favorites("local")
|
||||||
|
end
|
||||||
|
mm_texture.clear("header")
|
||||||
|
mm_texture.clear("footer")
|
||||||
|
core.set_clouds(false)
|
||||||
|
core.set_background("background",minetest.formspec_escape(mm_texture.basetexturedir)..'background.png')
|
||||||
|
core.set_background("header",minetest.formspec_escape(mm_texture.basetexturedir)..'header.png')
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
tab_main = {
|
||||||
|
name = "main",
|
||||||
|
caption = fgettext("Main"),
|
||||||
|
cbf_formspec = get_formspec2,
|
||||||
|
cbf_button_handler = main_button_handler2,
|
||||||
|
on_change = on_activate2
|
||||||
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function init_globals()
|
local function init_globals()
|
||||||
-- Init gamedata
|
-- Init gamedata
|
||||||
gamedata.worldindex = 0
|
gamedata.worldindex = 0
|
||||||
|
|
||||||
|
menudata.worldlist = filterlist.create(
|
||||||
|
core.get_worlds,
|
||||||
|
compare_worlds,
|
||||||
|
-- Unique id comparison function
|
||||||
|
function(element, uid)
|
||||||
|
return element.name == uid
|
||||||
|
end,
|
||||||
|
-- Filter function
|
||||||
|
function(element, gameid)
|
||||||
|
return element.gameid == gameid
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
if PLATFORM ~= "Android" then
|
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
||||||
menudata.worldlist = filterlist.create(
|
menudata.worldlist:set_sortmode("alphabetic")
|
||||||
core.get_worlds,
|
|
||||||
compare_worlds,
|
|
||||||
-- Unique id comparison function
|
|
||||||
function(element, uid)
|
|
||||||
return element.name == uid
|
|
||||||
end,
|
|
||||||
-- Filter function
|
|
||||||
function(element, gameid)
|
|
||||||
return element.gameid == gameid
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
if not core.setting_get("menu_last_game") then
|
||||||
menudata.worldlist:set_sortmode("alphabetic")
|
local default_game = core.setting_get("default_game") or "magichet"
|
||||||
|
core.setting_set("menu_last_game", default_game )
|
||||||
|
end
|
||||||
|
|
||||||
if not core.setting_get("menu_last_game") then
|
mm_texture.init()
|
||||||
local default_game = core.setting_get("default_game") or "minetest"
|
|
||||||
core.setting_set("menu_last_game", default_game )
|
|
||||||
end
|
|
||||||
|
|
||||||
mm_texture.init()
|
|
||||||
else
|
|
||||||
local world_list = core.get_worlds()
|
|
||||||
|
|
||||||
local found_singleplayerworld = false
|
|
||||||
|
|
||||||
for i,world in pairs(world_list) do
|
|
||||||
if world.name == "singleplayerworld" then
|
|
||||||
found_singleplayerworld = true
|
|
||||||
gamedata.worldindex = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not found_singleplayerworld then
|
|
||||||
core.create_world("singleplayerworld", 1)
|
|
||||||
|
|
||||||
local world_list = core.get_worlds()
|
|
||||||
|
|
||||||
for i,world in pairs(world_list) do
|
|
||||||
if world.name == "singleplayerworld" then
|
|
||||||
gamedata.worldindex = i
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create main tabview
|
-- Create main tabview
|
||||||
local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=0,y=0})
|
local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=0,y=0})
|
||||||
if PLATFORM ~= "Android" then
|
tv_main:set_autosave_tab(false)
|
||||||
tv_main:set_autosave_tab(true)
|
tv_main:add(tab_main)
|
||||||
end
|
tv_main:add(tab_singleplayer)
|
||||||
if PLATFORM ~= "Android" then
|
tv_main:add(tab_multiplayer)
|
||||||
tv_main:add(tab_singleplayer)
|
tv_main:add(tab_server)
|
||||||
tv_main:add(tab_multiplayer)
|
|
||||||
tv_main:add(tab_server)
|
|
||||||
else
|
|
||||||
tv_main:add(tab_simple_main)
|
|
||||||
end
|
|
||||||
tv_main:add(tab_settings)
|
tv_main:add(tab_settings)
|
||||||
if PLATFORM ~= "Android" then
|
tv_main:add(tab_texturepacks)
|
||||||
tv_main:add(tab_texturepacks)
|
|
||||||
end
|
|
||||||
tv_main:add(tab_mods)
|
tv_main:add(tab_mods)
|
||||||
tv_main:add(tab_credits)
|
tv_main:add(tab_credits)
|
||||||
|
|
||||||
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)
|
||||||
|
ui.set_default("main")
|
||||||
if not (PLATFORM == "Android") then
|
|
||||||
tv_main:set_tab(core.setting_get("maintab_LAST"))
|
|
||||||
end
|
|
||||||
ui.set_default("maintab")
|
|
||||||
tv_main:show()
|
tv_main:show()
|
||||||
|
|
||||||
-- Create modstore ui
|
-- Create modstore ui
|
||||||
@ -158,7 +195,7 @@ local function init_globals()
|
|||||||
ui.update()
|
ui.update()
|
||||||
|
|
||||||
core.sound_play("main_menu", true)
|
core.sound_play("main_menu", true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
init_globals()
|
init_globals()
|
||||||
|
|
||||||
|
164
builtin/mainmenu/init_old.lua
Normal file
164
builtin/mainmenu/init_old.lua
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
--Minetest
|
||||||
|
--Copyright (C) 2014 sapier
|
||||||
|
--
|
||||||
|
--This program is free software; you can redistribute it and/or modify
|
||||||
|
--it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
--the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
--(at your option) any later version.
|
||||||
|
--
|
||||||
|
--This program is distributed in the hope that it will be useful,
|
||||||
|
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
--GNU Lesser General Public License for more details.
|
||||||
|
--
|
||||||
|
--You should have received a copy of the GNU Lesser General Public License along
|
||||||
|
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
mt_color_grey = "#AAAAAA"
|
||||||
|
mt_color_blue = "#0000DD"
|
||||||
|
mt_color_green = "#00DD00"
|
||||||
|
mt_color_dark_green = "#003300"
|
||||||
|
|
||||||
|
--for all other colors ask sfan5 to complete his work!
|
||||||
|
|
||||||
|
local menupath = core.get_mainmenu_path()
|
||||||
|
local basepath = core.get_builtin_path()
|
||||||
|
defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
|
||||||
|
DIR_DELIM .. "pack" .. DIR_DELIM
|
||||||
|
|
||||||
|
dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "async_event.lua")
|
||||||
|
dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "filterlist.lua")
|
||||||
|
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
|
||||||
|
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "dialog.lua")
|
||||||
|
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "tabview.lua")
|
||||||
|
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "common.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "modmgr.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "store.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
|
||||||
|
--if PLATFORM ~= "Android" then
|
||||||
|
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_server.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
|
||||||
|
dofile(menupath .. DIR_DELIM .. "textures.lua")
|
||||||
|
--else
|
||||||
|
-- dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
|
||||||
|
--end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function main_event_handler(tabview, event)
|
||||||
|
if event == "MenuQuit" then
|
||||||
|
core.close()
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
local function init_globals()
|
||||||
|
-- Init gamedata
|
||||||
|
gamedata.worldindex = 0
|
||||||
|
|
||||||
|
|
||||||
|
if PLATFORM ~= "Android" then
|
||||||
|
menudata.worldlist = filterlist.create(
|
||||||
|
core.get_worlds,
|
||||||
|
compare_worlds,
|
||||||
|
-- Unique id comparison function
|
||||||
|
function(element, uid)
|
||||||
|
return element.name == uid
|
||||||
|
end,
|
||||||
|
-- Filter function
|
||||||
|
function(element, gameid)
|
||||||
|
return element.gameid == gameid
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
|
||||||
|
menudata.worldlist:set_sortmode("alphabetic")
|
||||||
|
|
||||||
|
if not core.setting_get("menu_last_game") then
|
||||||
|
local default_game = core.setting_get("default_game") or "minetest"
|
||||||
|
core.setting_set("menu_last_game", default_game )
|
||||||
|
end
|
||||||
|
|
||||||
|
mm_texture.init()
|
||||||
|
else
|
||||||
|
local world_list = core.get_worlds()
|
||||||
|
|
||||||
|
local found_singleplayerworld = false
|
||||||
|
|
||||||
|
for i,world in pairs(world_list) do
|
||||||
|
if world.name == "singleplayerworld" then
|
||||||
|
found_singleplayerworld = true
|
||||||
|
gamedata.worldindex = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not found_singleplayerworld then
|
||||||
|
core.create_world("singleplayerworld", 1)
|
||||||
|
|
||||||
|
local world_list = core.get_worlds()
|
||||||
|
|
||||||
|
for i,world in pairs(world_list) do
|
||||||
|
if world.name == "singleplayerworld" then
|
||||||
|
gamedata.worldindex = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create main tabview
|
||||||
|
local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=0,y=0})
|
||||||
|
if PLATFORM ~= "Android" then
|
||||||
|
tv_main:set_autosave_tab(true)
|
||||||
|
end
|
||||||
|
if PLATFORM ~= "Android" then
|
||||||
|
tv_main:add(tab_singleplayer)
|
||||||
|
tv_main:add(tab_multiplayer)
|
||||||
|
tv_main:add(tab_server)
|
||||||
|
else
|
||||||
|
tv_main:add(tab_simple_main)
|
||||||
|
end
|
||||||
|
tv_main:add(tab_settings)
|
||||||
|
if PLATFORM ~= "Android" then
|
||||||
|
tv_main:add(tab_texturepacks)
|
||||||
|
end
|
||||||
|
tv_main:add(tab_mods)
|
||||||
|
tv_main:add(tab_credits)
|
||||||
|
|
||||||
|
tv_main:set_global_event_handler(main_event_handler)
|
||||||
|
|
||||||
|
tv_main:set_fixed_size(false)
|
||||||
|
|
||||||
|
if not (PLATFORM == "Android") then
|
||||||
|
tv_main:set_tab(core.setting_get("maintab_LAST"))
|
||||||
|
end
|
||||||
|
ui.set_default("maintab")
|
||||||
|
tv_main:show()
|
||||||
|
|
||||||
|
-- Create modstore ui
|
||||||
|
if PLATFORM == "Android" then
|
||||||
|
modstore.init({x=12, y=6}, 3, 2)
|
||||||
|
else
|
||||||
|
modstore.init({x=12, y=8}, 4, 3)
|
||||||
|
end
|
||||||
|
|
||||||
|
ui.update()
|
||||||
|
|
||||||
|
core.sound_play("main_menu", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
init_globals()
|
||||||
|
|
@ -162,7 +162,7 @@ function modstore.successfulldialog(downloading_dlg)
|
|||||||
retval = retval .. "label[0,0.75;" .. fgettext("Shortname:") .. "]"
|
retval = retval .. "label[0,0.75;" .. fgettext("Shortname:") .. "]"
|
||||||
retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]"
|
retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]"
|
||||||
end
|
end
|
||||||
retval = retval .. "button[2.2,1.5;1.5,0.5;btn_confirm_mod_successfull;" .. fgettext("Ok") .. "]"
|
retval = retval .. "image_button[2.2,1.5;1.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_confirm_mod_successfull;" .. fgettext("Ok") .. "]"
|
||||||
return retval
|
return retval
|
||||||
end,
|
end,
|
||||||
function(this,fields)
|
function(this,fields)
|
||||||
@ -491,7 +491,7 @@ function modstore.getshortmodinfo(ypos,listentry,details)
|
|||||||
if details.basename then
|
if details.basename then
|
||||||
--install button
|
--install button
|
||||||
local buttony = ypos + 1.2
|
local buttony = ypos + 1.2
|
||||||
retval = retval .."button[9.1," .. buttony .. ";2.5,0.5;btn_install_mod_" .. details.id .. ";"
|
retval = retval .."image_button[9.1," .. buttony .. ";2.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_install_mod_" .. details.id .. ";"
|
||||||
|
|
||||||
if modmgr.mod_exists(details.basename) then
|
if modmgr.mod_exists(details.basename) then
|
||||||
retval = retval .. fgettext("re-Install") .."]"
|
retval = retval .. fgettext("re-Install") .."]"
|
||||||
@ -514,8 +514,8 @@ function modstore.getmodlist(list,yoffset)
|
|||||||
|
|
||||||
local sb_y_start = 0.2 + yoffset
|
local sb_y_start = 0.2 + yoffset
|
||||||
local sb_y_end = (modstore.modsperpage * 1.75) + ((modstore.modsperpage-1) * 0.15)
|
local sb_y_end = (modstore.modsperpage * 1.75) + ((modstore.modsperpage-1) * 0.15)
|
||||||
local close_button = "button[4," .. (sb_y_end + 0.3 + yoffset) ..
|
local close_button = "image_button[4," .. (sb_y_end + 0.3 + yoffset) ..
|
||||||
";4,0.5;btn_modstore_close;" .. fgettext("Close store") .. "]"
|
";4,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_close;" .. fgettext("Close store") .. "]"
|
||||||
|
|
||||||
if #list.data == 0 then
|
if #list.data == 0 then
|
||||||
return close_button
|
return close_button
|
||||||
@ -528,10 +528,10 @@ function modstore.getmodlist(list,yoffset)
|
|||||||
local scrollbarpos = (sb_y_start + 0.5) +
|
local scrollbarpos = (sb_y_start + 0.5) +
|
||||||
((sb_y_end -1.6)/(list.pagecount-1)) * list.page
|
((sb_y_end -1.6)/(list.pagecount-1)) * list.page
|
||||||
scrollbar = scrollbar .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;#32CD32]"
|
scrollbar = scrollbar .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;#32CD32]"
|
||||||
scrollbar = scrollbar .. "button[11.6," .. (sb_y_start)
|
scrollbar = scrollbar .. "image_button[11.6," .. (sb_y_start)
|
||||||
.. ";0.5,0.5;btn_modstore_page_up;^]"
|
.. ";0.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_up;^]"
|
||||||
scrollbar = scrollbar .. "button[11.6," .. (sb_y_start + sb_y_end - 0.5)
|
scrollbar = scrollbar .. "image_button[11.6," .. (sb_y_start + sb_y_end - 0.5)
|
||||||
.. ";0.5,0.5;btn_modstore_page_down;v]"
|
.. ";0.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_down;v]"
|
||||||
|
|
||||||
local retval = ""
|
local retval = ""
|
||||||
|
|
||||||
@ -577,7 +577,7 @@ function modstore.getsearchpage(tabview, name, tabdata)
|
|||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[9.5,0.2;2.5,0.5;btn_modstore_search;".. fgettext("Search") .. "]" ..
|
"image_button[9.5,0.2;2.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_search;".. fgettext("Search") .. "]" ..
|
||||||
"field[0.5,0.5;9,0.5;te_modstore_search;;" .. search .. "]"
|
"field[0.5,0.5;9,0.5;te_modstore_search;;" .. search .. "]"
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
|
@ -35,8 +35,8 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
retval = retval ..
|
retval = retval ..
|
||||||
-- "label[0.8,4.2;" .. fgettext("Add mod:") .. "]" ..
|
-- "label[0.8,4.2;" .. fgettext("Add mod:") .. "]" ..
|
||||||
-- TODO Disabled due to upcoming release 0.4.8 and irrlicht messing up localization
|
-- TODO Disabled due to upcoming release 0.4.8 and irrlicht messing up localization
|
||||||
-- "button[0.75,4.85;1.8,0.5;btn_mod_mgr_install_local;".. fgettext("Local install") .. "]" ..
|
-- "image_button[0.75,4.85;1.8,0.5;btn_mod_mgr_install_local;".. fgettext("Local install") .. "]" ..
|
||||||
"button[0,4.85;5.25,0.5;btn_modstore;".. fgettext("Online mod repository") .. "]"
|
"image_button[0,4.85;5.25,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore;".. fgettext("Online mod repository") .. "]"
|
||||||
|
|
||||||
local selected_mod = nil
|
local selected_mod = nil
|
||||||
|
|
||||||
@ -89,9 +89,9 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
|
|
||||||
if selected_mod.is_modpack then
|
if selected_mod.is_modpack then
|
||||||
retval = retval .. ";0]" ..
|
retval = retval .. ";0]" ..
|
||||||
"button[10,4.85;2,0.5;btn_mod_mgr_rename_modpack;" ..
|
"image_button[10,4.85;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_rename_modpack;" ..
|
||||||
fgettext("Rename") .. "]"
|
fgettext("Rename") .. "]"
|
||||||
retval = retval .. "button[5.5,4.85;4.5,0.5;btn_mod_mgr_delete_mod;"
|
retval = retval .. "image_button[5.5,4.85;4.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
|
||||||
.. fgettext("Uninstall selected modpack") .. "]"
|
.. fgettext("Uninstall selected modpack") .. "]"
|
||||||
else
|
else
|
||||||
--show dependencies
|
--show dependencies
|
||||||
@ -102,7 +102,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
|
|
||||||
retval = retval .. toadd .. ";0]"
|
retval = retval .. toadd .. ";0]"
|
||||||
|
|
||||||
retval = retval .. "button[5.5,4.85;4.5,0.5;btn_mod_mgr_delete_mod;"
|
retval = retval .. "image_button[5.5,4.85;4.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
|
||||||
.. fgettext("Uninstall selected mod") .. "]"
|
.. fgettext("Uninstall selected mod") .. "]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function get_formspec(tabview, name, tabdata)
|
local function get_formspec(tabview, name, tabdata)
|
||||||
|
if not tabdata then tabdata = {} end
|
||||||
local render_details = core.is_yes(core.setting_getbool("public_serverlist"))
|
local render_details = core.is_yes(core.setting_getbool("public_serverlist"))
|
||||||
|
|
||||||
local retval =
|
local retval =
|
||||||
@ -31,11 +32,11 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
|
|
||||||
if not core.setting_getbool("public_serverlist") then
|
if not core.setting_getbool("public_serverlist") then
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[8,4.9;2,0.5;btn_delete_favorite;" .. fgettext("Delete") .. "]"
|
"image_button[8,4.9;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_delete_favorite;" .. fgettext("Delete") .. "]"
|
||||||
end
|
end
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[10,4.9;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" ..
|
"image_button[10,4.9;2,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_connect;" .. fgettext("Connect") .. "]" ..
|
||||||
"field[8,1.95;2.95,0.5;te_name;;" ..
|
"field[8,1.95;2.95,0.5;te_name;;" ..
|
||||||
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
core.formspec_escape(core.setting_get("name")) .. "]" ..
|
||||||
"pwdfield[10.78,1.95;1.77,0.5;te_pwd;]" ..
|
"pwdfield[10.78,1.95;1.77,0.5;te_pwd;]" ..
|
||||||
@ -84,11 +85,12 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
retval = retval .. ";0]"
|
retval = retval .. ";0]"
|
||||||
end
|
end
|
||||||
|
|
||||||
return retval
|
return 'size[12,5.2]'..retval
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
local function main_button_handler(tabview, fields, name, tabdata)
|
local function main_button_handler(tabview, fields, name, tabdata)
|
||||||
|
if not tabdata then tabdata = {} end
|
||||||
if fields["te_name"] ~= nil then
|
if fields["te_name"] ~= nil then
|
||||||
gamedata.playername = fields["te_name"]
|
gamedata.playername = fields["te_name"]
|
||||||
core.setting_set("name", fields["te_name"])
|
core.setting_set("name", fields["te_name"])
|
||||||
@ -249,6 +251,9 @@ local function on_change(type,old_tab,new_tab)
|
|||||||
else
|
else
|
||||||
menudata.favorites = core.get_favorites("local")
|
menudata.favorites = core.get_favorites("local")
|
||||||
end
|
end
|
||||||
|
if type == "MenuQuit" then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -257,5 +262,14 @@ tab_multiplayer = {
|
|||||||
caption = fgettext("Client"),
|
caption = fgettext("Client"),
|
||||||
cbf_formspec = get_formspec,
|
cbf_formspec = get_formspec,
|
||||||
cbf_button_handler = main_button_handler,
|
cbf_button_handler = main_button_handler,
|
||||||
on_change = on_change
|
--on_change = on_change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_tab_multiplayer()
|
||||||
|
local retval = dialog_create("multiplayer",
|
||||||
|
get_formspec,
|
||||||
|
main_button_handler
|
||||||
|
--on_change
|
||||||
|
)
|
||||||
|
return retval
|
||||||
|
end
|
@ -23,16 +23,19 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
)
|
)
|
||||||
|
|
||||||
local retval =
|
local retval =
|
||||||
"button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" ..
|
"image_button[4,4.15;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;" .. fgettext("Delete") .. "]" ..
|
||||||
"button[6.5,4.15;2.8,0.5;world_create;" .. fgettext("New") .. "]" ..
|
"image_button[6.5,4.15;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;" .. fgettext("New") .. "]" ..
|
||||||
"button[9.2,4.15;2.55,0.5;world_configure;" .. fgettext("Configure") .. "]" ..
|
"image_button[9.2,4.15;2.55,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;" .. fgettext("Configure") .. "]" ..
|
||||||
"button[8.5,4.95;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
|
"image_button[8.5,4.95;3.25,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;start_server;" .. fgettext("Start Game") .. "]" ..
|
||||||
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
|
"label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
|
||||||
"checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" ..
|
"checkbox[0.25,0.15;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" ..
|
||||||
dump(core.setting_getbool("creative_mode")) .. "]" ..
|
dump(core.setting_getbool("creative_mode")) .. "]" ..
|
||||||
"checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" ..
|
"checkbox[0.25,0.6;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" ..
|
||||||
dump(core.setting_getbool("enable_damage")) .. "]" ..
|
dump(core.setting_getbool("enable_damage")) .. "]" ..
|
||||||
"checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" ..
|
"image_button[0.25,1.3;0.58,0.55;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_checkf.png;b_single;;false;false]"..
|
||||||
|
"image_button[0.25,1.3;0.58,0.55;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_check.png;b_single;;false;false]"..
|
||||||
|
"image_button[0.3,1.3;3,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_trans.png;btn_single;Local Server;false;false]"..
|
||||||
|
"checkbox[0.25,1.6;cb_server_announce;" .. fgettext("Public") .. ";" ..
|
||||||
dump(core.setting_getbool("server_announce")) .. "]" ..
|
dump(core.setting_getbool("server_announce")) .. "]" ..
|
||||||
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
|
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
|
||||||
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
|
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
|
||||||
@ -57,7 +60,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
menu_render_worldlist() ..
|
menu_render_worldlist() ..
|
||||||
";" .. index .. "]"
|
";" .. index .. "]"
|
||||||
|
|
||||||
return retval
|
return 'size[12,5.2]'..retval
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -65,6 +68,14 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||||||
|
|
||||||
local world_doubleclick = false
|
local world_doubleclick = false
|
||||||
|
|
||||||
|
if fields["btn_single"]~=nil then
|
||||||
|
local single = create_tab_single(true)
|
||||||
|
single:set_parent(this.parent)
|
||||||
|
single:show()
|
||||||
|
this:hide()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
if fields["srv_worlds"] ~= nil then
|
if fields["srv_worlds"] ~= nil then
|
||||||
local event = core.explode_textlist_event(fields["srv_worlds"])
|
local event = core.explode_textlist_event(fields["srv_worlds"])
|
||||||
|
|
||||||
@ -220,3 +231,11 @@ tab_server = {
|
|||||||
cbf_button_handler = main_button_handler,
|
cbf_button_handler = main_button_handler,
|
||||||
on_change = nil
|
on_change = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_tab_server()
|
||||||
|
local retval = dialog_create("server",
|
||||||
|
get_formspec,
|
||||||
|
main_button_handler,
|
||||||
|
nil)
|
||||||
|
return retval
|
||||||
|
end
|
@ -75,9 +75,9 @@ local function dlg_confirm_reset_formspec(data)
|
|||||||
local retval =
|
local retval =
|
||||||
"size[8,3]" ..
|
"size[8,3]" ..
|
||||||
"label[1,1;".. fgettext("Are you sure to reset your singleplayer world?") .. "]"..
|
"label[1,1;".. fgettext("Are you sure to reset your singleplayer world?") .. "]"..
|
||||||
"button[1,2;2.6,0.5;dlg_reset_singleplayer_confirm;"..
|
"image_button[1,2;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_confirm;"..
|
||||||
fgettext("Yes") .. "]" ..
|
fgettext("Yes") .. "]" ..
|
||||||
"button[4,2;2.8,0.5;dlg_reset_singleplayer_cancel;"..
|
"image_button[4,2;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_cancel;"..
|
||||||
fgettext("No!!!") .. "]"
|
fgettext("No!!!") .. "]"
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
@ -209,10 +209,10 @@ local function formspec(tabview, name, tabdata)
|
|||||||
|
|
||||||
if PLATFORM ~= "Android" then
|
if PLATFORM ~= "Android" then
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"button[8,4.75;3.75,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
|
"image_button[8,4.75;3.75,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_change_keys;".. fgettext("Change keys") .. "]"
|
||||||
else
|
else
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"button[8,4.75;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]"
|
"image_button[8,4.75;3.75,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]"
|
||||||
end
|
end
|
||||||
tab_string = tab_string ..
|
tab_string = tab_string ..
|
||||||
"box[0,4.25;3.5,1.1;#999999]" ..
|
"box[0,4.25;3.5,1.1;#999999]" ..
|
||||||
@ -260,7 +260,7 @@ local function formspec(tabview, name, tabdata)
|
|||||||
"textlist[8.33,2.7;4,1;;#888888" .. fgettext("Waving Leaves") .. ";0;true]" ..
|
"textlist[8.33,2.7;4,1;;#888888" .. fgettext("Waving Leaves") .. ";0;true]" ..
|
||||||
"textlist[8.33,3.2;4,1;;#888888" .. fgettext("Waving Plants") .. ";0;true]"
|
"textlist[8.33,3.2;4,1;;#888888" .. fgettext("Waving Plants") .. ";0;true]"
|
||||||
end
|
end
|
||||||
return tab_string
|
return 'size[12,5.2]'..tab_string
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -399,3 +399,11 @@ tab_settings = {
|
|||||||
cbf_formspec = formspec,
|
cbf_formspec = formspec,
|
||||||
cbf_button_handler = handle_settings_buttons
|
cbf_button_handler = handle_settings_buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_tab_settings()
|
||||||
|
local retval = dialog_create("settings",
|
||||||
|
formspec,
|
||||||
|
handle_settings_buttons,
|
||||||
|
nil)
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
@ -31,7 +31,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
render_details .. "]"
|
render_details .. "]"
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[8,2.5;4,1.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
|
"image_button[8,2.5;4,1.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_connect;".. fgettext("Connect") .. "]" ..
|
||||||
"field[8.75,1.5;3.5,0.5;te_name;;" ..
|
"field[8.75,1.5;3.5,0.5;te_name;;" ..
|
||||||
core.formspec_escape(core.setting_get("name")) .."]" ..
|
core.formspec_escape(core.setting_get("name")) .."]" ..
|
||||||
"pwdfield[8.75,2.3;3.5,0.5;te_pwd;]"
|
"pwdfield[8.75,2.3;3.5,0.5;te_pwd;]"
|
||||||
@ -81,8 +81,8 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
dump(core.setting_getbool("free_move")) .. "]"
|
dump(core.setting_getbool("free_move")) .. "]"
|
||||||
-- buttons
|
-- buttons
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[2.0,4.5;6,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" ..
|
"image_button[2.0,4.5;6,1.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" ..
|
||||||
"button[8.25,4.5;2.5,1.5;btn_config_sp_world;" .. fgettext("Config mods") .. "]"
|
"image_button[8.25,4.5;2.5,1.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_sp_world;" .. fgettext("Config mods") .. "]"
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
|
@ -31,18 +31,18 @@ local function singleplayer_refresh_gamebar()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function game_buttonbar_button_handler(fields)
|
local function game_buttonbar_button_handler(fields)
|
||||||
for key,value in pairs(fields) do
|
for key,value in pairs(fields) do
|
||||||
for j=1,#gamemgr.games,1 do
|
for j=1,#gamemgr.games,1 do
|
||||||
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
|
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
|
||||||
mm_texture.update("singleplayer", gamemgr.games[j])
|
mm_texture.update("singleplayer", gamemgr.games[j])
|
||||||
core.set_topleft_text(gamemgr.games[j].name)
|
core.set_topleft_text(gamemgr.games[j].name)
|
||||||
core.setting_set("menu_last_game",gamemgr.games[j].id)
|
core.setting_set("menu_last_game",gamemgr.games[j].id)
|
||||||
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
|
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local btnbar = buttonbar_create("game_button_bar",
|
local btnbar = buttonbar_create("game_button_bar",
|
||||||
game_buttonbar_button_handler,
|
game_buttonbar_button_handler,
|
||||||
@ -82,27 +82,37 @@ local function get_formspec(tabview, name, tabdata)
|
|||||||
)
|
)
|
||||||
|
|
||||||
retval = retval ..
|
retval = retval ..
|
||||||
"button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
|
"image_button[4,4.15;2.6,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;".. fgettext("Delete") .. "]" ..
|
||||||
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
|
"image_button[6.5,4.15;2.8,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;".. fgettext("New") .. "]" ..
|
||||||
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
|
"image_button[9.2,4.15;2.55,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;".. fgettext("Configure") .. "]" ..
|
||||||
"button[8.5,4.95;3.25,0.5;play;".. fgettext("Play") .. "]" ..
|
"image_button[8.5,4.95;3.25,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;play;".. fgettext("Play") .. "]" ..
|
||||||
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
|
||||||
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
"checkbox[0.25,0.15;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
|
||||||
dump(core.setting_getbool("creative_mode")) .. "]"..
|
dump(core.setting_getbool("creative_mode")) .. "]"..
|
||||||
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
"checkbox[0.25,0.6;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
|
||||||
dump(core.setting_getbool("enable_damage")) .. "]"..
|
dump(core.setting_getbool("enable_damage")) .. "]"..
|
||||||
|
"image_button[0.25,1.3;0.58,0.55;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_checkf.png;b_single;;false;false]"..
|
||||||
|
"image_button[0.3,1.3;3,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_trans.png;btn_server;Local Server;false;false]"..
|
||||||
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
|
||||||
menu_render_worldlist() ..
|
menu_render_worldlist() ..
|
||||||
";" .. index .. "]"
|
";" .. index .. "]"
|
||||||
return retval
|
return 'size[12,5.2]'..retval
|
||||||
end
|
end
|
||||||
|
|
||||||
local function main_button_handler(this, fields, name, tabdata)
|
local function main_button_handler(this, fields, name, tabdata)
|
||||||
|
|
||||||
assert(name == "singleplayer")
|
name = "singleplayer"
|
||||||
|
|
||||||
local world_doubleclick = false
|
local world_doubleclick = false
|
||||||
|
|
||||||
|
if fields["btn_server"]~=nil then
|
||||||
|
local single = create_tab_server(true)
|
||||||
|
single:set_parent(this.parent)
|
||||||
|
single:show()
|
||||||
|
this:hide()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
if fields["sp_worlds"] ~= nil then
|
if fields["sp_worlds"] ~= nil then
|
||||||
local event = core.explode_textlist_event(fields["sp_worlds"])
|
local event = core.explode_textlist_event(fields["sp_worlds"])
|
||||||
|
|
||||||
@ -150,13 +160,19 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||||||
if fields["cb_creative_mode"] then
|
if fields["cb_creative_mode"] then
|
||||||
core.setting_set("creative_mode", fields["cb_creative_mode"])
|
core.setting_set("creative_mode", fields["cb_creative_mode"])
|
||||||
local selected = core.get_textlist_index("sp_worlds")
|
local selected = core.get_textlist_index("sp_worlds")
|
||||||
local filename = menudata.worldlist:get_list()[selected].path ..
|
if selected then
|
||||||
DIR_DELIM .. "world.mt"
|
local filename = menudata.worldlist:get_list()[selected].path ..
|
||||||
|
DIR_DELIM .. "world.mt"
|
||||||
|
|
||||||
local worldfile = Settings(filename)
|
local test = io.open(filename)
|
||||||
worldfile:set("creative_mode", fields["cb_creative_mode"])
|
if test then
|
||||||
if not worldfile:write() then
|
io.close(test)
|
||||||
core.log("error", "Failed to write world config file")
|
local worldfile = Settings(filename)
|
||||||
|
worldfile:set("creative_mode", fields["cb_creative_mode"])
|
||||||
|
-- if not worldfile:write() then
|
||||||
|
-- core.log("error", "Failed to write world config file")
|
||||||
|
-- end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -164,13 +180,17 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||||||
if fields["cb_enable_damage"] then
|
if fields["cb_enable_damage"] then
|
||||||
core.setting_set("enable_damage", fields["cb_enable_damage"])
|
core.setting_set("enable_damage", fields["cb_enable_damage"])
|
||||||
local selected = core.get_textlist_index("sp_worlds")
|
local selected = core.get_textlist_index("sp_worlds")
|
||||||
local filename = menudata.worldlist:get_list()[selected].path ..
|
if selected then
|
||||||
DIR_DELIM .. "world.mt"
|
local filename = menudata.worldlist:get_list()[selected].path ..
|
||||||
|
DIR_DELIM .. "world.mt"
|
||||||
local worldfile = Settings(filename)
|
local test = io.open(filename)
|
||||||
worldfile:set("enable_damage", fields["cb_enable_damage"])
|
if test then
|
||||||
if not worldfile:write() then
|
local worldfile = Settings(filename)
|
||||||
core.log("error", "Failed to write world config file")
|
worldfile:set("enable_damage", fields["cb_enable_damage"])
|
||||||
|
--if not worldfile:write() then
|
||||||
|
--core.log("error", "Failed to write world config file")
|
||||||
|
--end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -270,3 +290,11 @@ tab_singleplayer = {
|
|||||||
cbf_button_handler = main_button_handler,
|
cbf_button_handler = main_button_handler,
|
||||||
on_change = on_change
|
on_change = on_change
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_tab_single()
|
||||||
|
local retval = dialog_create("singleplayer",
|
||||||
|
get_formspec,
|
||||||
|
main_button_handler,
|
||||||
|
nil)
|
||||||
|
return retval
|
||||||
|
end
|
||||||
|
BIN
textures/base/pack/menu_button.png
Normal file
BIN
textures/base/pack/menu_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
textures/base/pack/menu_button_b.png
Normal file
BIN
textures/base/pack/menu_button_b.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
textures/base/pack/menu_check.png
Normal file
BIN
textures/base/pack/menu_check.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 489 B |
BIN
textures/base/pack/menu_checkf.png
Normal file
BIN
textures/base/pack/menu_checkf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 B |
BIN
textures/base/pack/menu_trans.png
Normal file
BIN
textures/base/pack/menu_trans.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 B |
Loading…
x
Reference in New Issue
Block a user