Add MultiCraft MainMenu

master
MoNTE48 2020-08-06 20:33:21 +02:00
parent af540c389e
commit 6227f9c72c
52 changed files with 1002 additions and 707 deletions

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -34,7 +34,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.05)
btn_pos.x = self.pos.x + (self.btn_size * 0.1)
end
if self.orientation == "vertical" then
@ -187,7 +187,7 @@ function buttonbar_create(name, cbf_buttonhandler, pos, orientation, size)
local self = {}
self.name = name
self.type = "addon"
self.bgcolor = "#000000"
self.bgcolor = "#8fb9de"
self.pos = pos
self.size = size
self.orientation = orientation

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--this program is distributed in the hope that it will be useful,
@ -69,14 +69,15 @@ function dialog_create(name,get_formspec,buttonhandler,eventhandler)
end
function messagebox(name, message)
local bg = core.formspec_escape(defaulttexturedir .. "bg_common.png")
return dialog_create(name,
function()
return ([[
formspec_version[3]
size[8,3]
textarea[0.375,0.375;7.25,1.2;;;%s]
button[3,1.825;2,0.8;ok;%s]
]]):format(message, fgettext("OK"))
size[12,6,false]
background[0,0;0,0;%s;true;32]
textarea[1,1;10,4;;;%s]
button[5,4.5;2,0.8;ok;%s]
]]):format(bg, message, fgettext("OK"))
end,
function(this, fields)
if fields.ok then

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -56,24 +56,42 @@ local function add_tab(self,tab)
end
end
local function get_bg(tsize, tabname)
local bg =
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]"
if tabname then
bg = bg ..
"background[0,0;" .. tsize.width .. "," .. tsize.height .. ";" ..
core.formspec_escape(defaulttexturedir ..
"bg_" .. tabname .. ".png") .. ";true]"
end
return bg
end
--------------------------------------------------------------------------------
local function get_formspec(self)
local formspec = ""
if not self.hidden and (self.parent == nil or not self.parent.hidden) then
local name = self.tablist[self.last_tab_index].name
local tabname = (name == "local" or name == "online") and name
or (name == "local_default" and "local")
if self.parent == nil then
local tsize = self.tablist[self.last_tab_index].tabsize or
{width=self.width, height=self.height}
formspec = formspec ..
string.format("size[%f,%f,%s]",tsize.width,tsize.height,
dump(self.fixed_size))
dump(self.fixed_size)) .. get_bg(tsize, tabname)
end
formspec = formspec .. self:tab_header()
formspec = formspec ..
self.tablist[self.last_tab_index].get_formspec(
self,
self.tablist[self.last_tab_index].name,
name,
self.tablist[self.last_tab_index].tabdata,
self.tablist[self.last_tab_index].tabsize
)

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -54,38 +54,70 @@ end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local maintab = core.settings:get("maintab_LAST")
local connect_time = tonumber(core.settings:get("connect_time"))
function ui.update()
local formspec = {}
-- attempt auto restart
--[[if gamedata ~= nil and gamedata.errormessage ~= nil and
core.settings:get_bool("auto_connect") == true and
connect_time and connect_time < os.time() - 30 and
not gamedata.errormessage:find("Kicked") then
if maintab == "local" or maintab == "local_default" then
gamedata.singleplayer = true
gamedata.selected_world =
tonumber(core.settings:get("mainmenu_last_selected_world"))
end
core.settings:set("connect_time", os.time())
gamedata.reconnect_requested = false
gamedata.errormessage = nil
gamedata.do_reconnect = true
core.start()
return
end]]
-- handle errors
if gamedata ~= nil and gamedata.reconnect_requested then
local error_message = core.formspec_escape(
gamedata.errormessage or "<none available>")
formspec = {
"size[14,8]",
"real_coordinates[true]",
"formspec_version[3]",
"size[14,8.25]",
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]",
"box[0.5,1.2;13,5;#000]",
("textarea[0.5,1.2;13,5;;%s;%s]"):format(
fgettext("The server has requested a reconnect:"), error_message),
"button[2,6.6;4,1;btn_reconnect_yes;" .. fgettext("Reconnect") .. "]",
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Main menu") .. "]"
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Close") .. "]"
}
elseif gamedata ~= nil and gamedata.errormessage ~= nil then
local error_message = core.formspec_escape(gamedata.errormessage)
local error_title
if string.find(gamedata.errormessage, "ModError") then
if gamedata.errormessage:find("ModError") then
error_title = fgettext("An error occurred in a Lua script:")
else
error_title = fgettext("An error occurred:")
end
local restart_btn = "button[5,6.6;4,1;btn_reconnect_no;" .. fgettext("Close") .. "]"
if maintab == "local" or maintab == "local_default" and
connect_time and connect_time < os.time() - 30 then
restart_btn =
"button[2,6.6;4,1;btn_reconnect_yes;" .. fgettext("Restart") .. "]" ..
"button[8,6.6;4,1;btn_reconnect_no;" .. fgettext("Close") .. "]"
end
formspec = {
"size[14,8]",
"real_coordinates[true]",
"formspec_version[3]",
"size[14,8.25]",
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]",
"box[0.5,1.2;13,5;#000]",
("textarea[0.5,1.2;13,5;;%s;%s]"):format(
error_title, error_message),
"button[5,6.6;4,1;btn_error_confirm;" .. fgettext("OK") .. "]"
restart_btn
}
else
local active_toplevel_ui_elements = 0
@ -164,12 +196,18 @@ end
--------------------------------------------------------------------------------
core.button_handler = function(fields)
if fields["btn_reconnect_yes"] then
if maintab == "local" or maintab == "local_default" then
gamedata.singleplayer = true
gamedata.selected_world =
tonumber(core.settings:get("mainmenu_last_selected_world"))
end
core.settings:set("connect_time", os.time())
gamedata.reconnect_requested = false
gamedata.errormessage = nil
gamedata.do_reconnect = true
core.start()
return
elseif fields["btn_reconnect_no"] or fields["btn_error_confirm"] then
elseif fields["btn_reconnect_no"] then
gamedata.errormessage = nil
gamedata.reconnect_requested = false
ui.update()

View File

@ -1,4 +1,3 @@
core.async_jobs = {}
local function handle_job(jobid, serialized_retval)
@ -29,4 +28,3 @@ function core.handle_async(func, parameter, callback)
return true
end

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -35,54 +35,59 @@ common_update_cached_supp_proto()
--------------------------------------------------------------------------------
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)
else return '?' end
end
local function configure_selected_world_params(idx)
local worldconfig = pkgmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
core.settings:set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage then
core.settings:set("enable_damage", worldconfig.enable_damage)
end
end
--------------------------------------------------------------------------------
function image_column(tooltip, flagname)
function image_column(tooltip)
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
"1=" .. core.formspec_escape(defaulttexturedir ..
(flagname and "server_flags_" .. flagname .. ".png" or "blank.png")) .. "," ..
"2=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.png") .. "," ..
"3=" .. core.formspec_escape(defaulttexturedir .. "server_ping_3.png") .. "," ..
"4=" .. core.formspec_escape(defaulttexturedir .. "server_ping_2.png") .. "," ..
"5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png")
"1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_favorite.png") .. "," ..
"2=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mc.png") .. "," ..
"3=" .. core.formspec_escape(defaulttexturedir .. "server_flags_mt.png") .. "," ..
"4=" .. core.formspec_escape(defaulttexturedir .. "server_flags_damage.png") .. "," ..
"5=" .. core.formspec_escape(defaulttexturedir .. "server_flags_creative.png") .. "," ..
"6=" .. core.formspec_escape(defaulttexturedir .. "server_flags_pvp.png") .. "," ..
"14=" .. core.formspec_escape(defaulttexturedir .. "server_ping_4.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
--------------------------------------------------------------------------------
function order_favorite_list(list)
function order_favorite_list(list, mobile)
local res = {}
--orders the favorite list after support
local non_mobile_servers = {}
-- orders the multicraft list before support
for i = 1, #list do
local fav = list[i]
if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
if mobile and not fav.mobile_friendly then
non_mobile_servers[("%s:%s"):format(fav.address, fav.port)] = fav
elseif fav.server_id == "multicraft" then
res[#res + 1] = fav
end
end
for i = 1, #list do
local fav = list[i]
if not is_server_protocol_compat(fav.proto_min, fav.proto_max) then
if (mobile and fav.mobile_friendly or not mobile) and
is_server_protocol_compat(fav.proto_min, fav.proto_max) and
fav.server_id ~= "multicraft" then
res[#res + 1] = fav
end
end
return res
return res, non_mobile_servers
end
--------------------------------------------------------------------------------
function render_serverlist_row(spec, is_favorite)
function render_serverlist_row(spec, is_favorite, is_approved)
-- Get information from non_mobile_servers.
if is_favorite and not spec.proto_min and menudata.non_mobile_servers then
local id = ("%s:%s"):format(spec.address, spec.port)
spec = menudata.non_mobile_servers[id] or spec
end
local text = ""
if spec.name then
text = text .. core.formspec_escape(spec.name:trim())
@ -99,19 +104,23 @@ function render_serverlist_row(spec, is_favorite)
if is_favorite then
details = "1,"
else
details = "0,"
if is_approved then
details = "2,"
else
details = "3,"
end
end
if spec.ping then
local ping = spec.ping * 1000
if ping <= 50 then
details = details .. "2,"
elseif ping <= 100 then
details = details .. "3,"
elseif ping <= 250 then
details = details .. "4,"
if spec.lag then
local lag = spec.lag * 1000
if lag <= 100 then
details = details .. "14,"
elseif lag <= 150 then
details = details .. "13,"
elseif lag <= 250 then
details = details .. "12,"
else
details = details .. "5,"
details = details .. "11,"
end
else
details = details .. "0,"
@ -123,12 +132,12 @@ function render_serverlist_row(spec, is_favorite)
-- Choose a color depending on how many clients are connected
-- (relatively to clients_max)
local clients_color
if grey_out then clients_color = '#aaaaaa'
elseif spec.clients == 0 then clients_color = '' -- 0 players: default/white
if grey_out then clients_color = '#aaaaaa'
elseif spec.clients == 0 then clients_color = '' -- 0 players: default/white
elseif clients_percent <= 60 then clients_color = '#a1e587' -- 0-60%: green
elseif clients_percent <= 90 then clients_color = '#ffdc97' -- 60-90%: yellow
elseif clients_percent == 100 then clients_color = '#dd5b5b' -- full server: red (darker)
else clients_color = '#ffba97' -- 90-100%: orange
else clients_color = '#ffba97' -- 90-100%: orange
end
details = details .. clients_color .. ',' ..
@ -142,19 +151,11 @@ function render_serverlist_row(spec, is_favorite)
end
if spec.creative then
details = details .. "1,"
else
details = details .. "0,"
end
if spec.damage then
details = details .. "1,"
else
details = details .. "0,"
end
if spec.pvp then
details = details .. "1,"
details = details .. "5,"
elseif spec.pvp then
details = details .. "6,"
elseif spec.damage then
details = details .. "4,"
else
details = details .. "0,"
end
@ -200,10 +201,9 @@ function menu_render_worldlist()
local retval = ""
local current_worldlist = menudata.worldlist:get_list()
for i, v in ipairs(current_worldlist) do
for _, v in ipairs(current_worldlist) do
if retval ~= "" then retval = retval .. "," end
retval = retval .. core.formspec_escape(v.name) ..
" \\[" .. core.formspec_escape(v.gameid) .. "\\]"
retval = retval .. core.formspec_escape(v.name)
end
return retval
@ -220,14 +220,13 @@ function menu_handle_key_up_down(fields, textlist, settingname)
newidx = oldidx + 1
end
core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx))
configure_selected_world_params(newidx)
return true
end
return false
end
--------------------------------------------------------------------------------
function asyncOnlineFavourites()
function asyncOnlineFavourites(mobile)
if not menudata.public_known then
menudata.public_known = {{
name = fgettext("Loading..."),
@ -250,11 +249,12 @@ function asyncOnlineFavourites()
nil,
function(result)
menudata.public_downloading = nil
local favs = order_favorite_list(result)
local favs, non_mobile = order_favorite_list(result, mobile)
if favs[1] then
menudata.public_known = favs
menudata.favorites = menudata.public_known
menudata.favorites_is_public = true
menudata.non_mobile_servers = non_mobile
end
core.event_handler("Refresh")
end
@ -335,15 +335,3 @@ function menu_worldmt(selected, setting, value)
return nil
end
end
function menu_worldmt_legacy(selected)
local modes_names = {"creative_mode", "enable_damage", "server_announce"}
for _, mode_name in pairs(modes_names) do
local mode_val = menu_worldmt(selected, mode_name)
if mode_val then
core.settings:set(mode_name, mode_val)
else
menu_worldmt(selected, mode_name, core.settings:get(mode_name))
end
end
end

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -69,7 +69,9 @@ local function get_formspec(data)
local mod = data.list:get_list()[data.selected_mod] or {name = ""}
local retval =
"size[11.5,7.5,true]" ..
"size[11.5,7.5,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"label[0.5,0;" .. fgettext("World:") .. "]" ..
"label[1.75,0;" .. data.worldspec.name .. "]"

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -95,6 +95,9 @@ local function start_install(calling_dialog, package)
elseif package.type == "game" then
conf_path = path .. DIR_DELIM .. "game.conf"
name_is_title = true
ui.childlist = {}
menudata.init_tabs()
elseif package.type == "txp" then
conf_path = path .. DIR_DELIM .. "texture_pack.conf"
end
@ -319,7 +322,9 @@ function store.get_formspec(dlgdata)
if #store.packages_full > 0 then
formspec = {
"formspec_version[3]",
"size[15.75,9.5]",
"size[15.75,9.5;false]",
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]",
"position[0.5,0.55]",
"container[0.375,0.375]",
"field[0,0;10.225,0.8;search_string;;", core.formspec_escape(search_string), "]",
@ -351,7 +356,9 @@ function store.get_formspec(dlgdata)
end
else
formspec = {
"size[12,7]",
"size[12,7;false]",
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]",
"position[0.5,0.55]",
"label[4,3;", fgettext("No packages could be retrieved"), "]",
"container[0,", H - 0.8 - 0.375, "]",

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -96,7 +96,9 @@ local function create_world_formspec(dialogdata)
-- Error out when no games found
if #pkgmgr.games == 0 then
return "size[12.25,3,true]" ..
return "size[12.25,3,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"box[0,0;12,2;#ff8800]" ..
"textarea[0.3,0;11.7,2;;;"..
fgettext("You have no games installed.") .. "\n" ..
@ -131,7 +133,7 @@ local function create_world_formspec(dialogdata)
end
end
local game_by_gameidx = core.get_game(gameidx)
local game_by_gameidx = pkgmgr.get_game_no_default(gameidx)
local disallowed_mapgen_settings = {}
if game_by_gameidx ~= nil then
local gamepath = game_by_gameidx.path
@ -316,7 +318,9 @@ local function create_world_formspec(dialogdata)
end
local retval =
"size[12.25,7,true]" ..
"size[12.25,7,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
-- Left side
"container[0,0]"..
@ -363,9 +367,7 @@ local function create_world_buttonhandler(this, fields)
if gameindex ~= nil then
if worldname == "" then
local random_number = math.random(10000, 99999)
local random_world_name = "Unnamed" .. random_number
worldname = random_world_name
worldname = "World " .. math.random(1000, 9999)
end
core.settings:set("fixed_map_seed", fields["te_seed"])
@ -373,7 +375,7 @@ local function create_world_buttonhandler(this, fields)
local message
if not menudata.worldlist:uid_exists_raw(worldname) then
core.settings:set("mg_name",fields["dd_mapgen"])
message = core.create_world(worldname,gameindex)
message = pkgmgr.create_world_no_default(worldname,gameindex)
else
message = fgettext("A world named \"$1\" already exists", worldname)
end

View File

@ -0,0 +1,151 @@
--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 3.0 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.
local function create_world_formspec()
local mapgens = core.get_mapgen_names()
local current_seed = core.settings:get("fixed_map_seed") or ""
local current_mg = core.settings:get("mg_name")
local gameid = core.settings:get("menu_last_game")
local gameidx = 0
if gameid ~= nil then
local _
_, gameidx = pkgmgr.find_by_gameid(gameid)
if gameidx == nil then
gameidx = 0
end
end
local game_by_gameidx = core.get_game(gameidx)
if game_by_gameidx ~= nil then
local allowed_mapgens = {"v7p", "flat", "valleys"}
for key, value in pairs(allowed_mapgens) do
allowed_mapgens[key] = value:trim()
end
if #allowed_mapgens > 0 then
for i = #mapgens, 1, -1 do
if table.indexof(allowed_mapgens, mapgens[i]) == -1 then
table.remove(mapgens, i)
end
end
end
end
local mglist = ""
local selindex = 1
local i = 1
for _, v in pairs(mapgens) do
if current_mg == v then
selindex = i
end
i = i + 1
mglist = mglist .. v .. ","
end
mglist = mglist:sub(1, -2)
local retval =
"size[12,6,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"label[1.5,1.2;" .. fgettext("World name") .. ":" .. "]"..
"field[4.5,1.5;6,0.5;te_world_name;;]" ..
"label[1.5,2.2;" .. fgettext("Seed") .. ":" .. "]"..
"field[4.5,2.5;6,0.5;te_seed;;".. current_seed .. "]" ..
"label[1.5,3.2;" .. fgettext("Mapgen") .. ":" .. "]"..
"dropdown[4.2,3.05;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"style[world_create_confirm;bgcolor=#00d12b]" ..
"button[3.5,4.8;2.5,0.5;world_create_confirm;" .. fgettext("Create") .. "]" ..
"button[6,4.8;2.5,0.5;world_create_cancel;" .. fgettext("Cancel") .. "]"
return retval
end
local function create_world_buttonhandler(this, fields)
if fields["world_create_confirm"] or
fields["key_enter"] then
local worldname = fields["te_world_name"]
local gameid = core.settings:get("menu_last_game")
local gameindex = 0
if gameid ~= nil then
local _
_, gameindex = pkgmgr.find_by_gameid(gameid)
if gameindex == nil then
gameindex = 0
end
end
if gameindex ~= 0 then
if worldname == "" then
worldname = "World " .. math.random(1000, 9999)
end
core.settings:set("fixed_map_seed", fields["te_seed"])
local message
if not menudata.worldlist:uid_exists_raw(worldname) then
core.settings:set("mg_name",fields["dd_mapgen"])
message = core.create_world(worldname,gameindex)
else
message = fgettext("A world named \"$1\" already exists", worldname)
end
if message ~= nil then
gamedata.errormessage = message
else
if this.data.update_worldlist_filter then
menudata.worldlist:set_filtercriteria(pkgmgr.games[gameindex].id)
mm_texture.update("singleplayer", pkgmgr.games[gameindex].id)
end
menudata.worldlist:refresh()
core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:raw_index_by_uid(worldname))
end
else
gamedata.errormessage = fgettext("No game selected")
end
this:delete()
return true
end
if fields["world_create_cancel"] then
this:delete()
return true
end
return false
end
function create_create_world_default_dlg(update_worldlistfilter)
local retval = dialog_create("sp_create_world",
create_world_formspec,
create_world_buttonhandler,
nil)
retval.update_worldlist_filter = update_worldlistfilter
return retval
end

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -19,7 +19,9 @@
local function delete_content_formspec(dialogdata)
local retval =
"size[11.5,4.5,true]" ..
"size[11.5,4.5,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"label[2,2;" ..
fgettext("Are you sure you want to delete \"$1\"?", dialogdata.content.name) .. "]"..
"style[dlg_delete_content_confirm;bgcolor=red]" ..
@ -44,6 +46,9 @@ local function delete_content_buttonhandler(this, fields)
if this.data.content.type == "game" then
pkgmgr.update_gamelist()
ui.childlist = {}
menudata.init_tabs()
else
pkgmgr.refresh_globals()
end

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -16,19 +16,35 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local b = core.formspec_escape(defaulttexturedir .. "blank.png")
local function delete_world_formspec(dialogdata)
local game_name = dialogdata.delete_game
local delete_game = (game_name and " [" .. game_name .. "]") or ""
local retval =
"size[10,2.5,true]" ..
"label[0.5,0.5;" ..
fgettext("Delete World \"$1\"?", dialogdata.delete_name) .. "]" ..
"size[12,4,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"image_button[3,0.4;6,0.6;" .. b .. ";;" .. fgettext("Delete World") ..
";true;false;]" ..
"image_button[3,1;6,0.6;" .. b .. ";;" ..
fgettext("\"$1$2", dialogdata.delete_name, delete_game) ..
"\"?;true;false;]" ..
"image_button[3,0.4;6,1.25;" .. b .. ";;;true;false;]" ..
"style[world_delete_confirm;bgcolor=red]" ..
"button[0.5,1.5;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
"button[7.0,1.5;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
"button[3.5,2.8;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
"button[6,2.8;2.5,0.5;world_delete_cancel;" .. fgettext("Cancel") .. "]"
return retval
end
local function delete_world_buttonhandler(this, fields)
if fields["world_delete_confirm"] then
if this.data.callback then
this:delete()
this.data.callback()
return true
end
if this.data.delete_index > 0 and
this.data.delete_index <= #menudata.worldlist:get_raw_list() then
core.delete_world(this.data.delete_index)
@ -47,7 +63,7 @@ local function delete_world_buttonhandler(this, fields)
end
function create_delete_world_dlg(name_to_del, index_to_del)
function create_delete_world_dlg(name_to_del, index_to_del, game_to_del)
assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "")
assert(index_to_del ~= nil and type(index_to_del) == "number")
@ -56,7 +72,18 @@ function create_delete_world_dlg(name_to_del, index_to_del)
delete_world_buttonhandler,
nil)
retval.data.delete_name = name_to_del
retval.data.delete_game = game_to_del
retval.data.delete_index = index_to_del
return retval
end
function create_custom_delete_dlg(name_to_del, callback)
assert(name_to_del ~= nil and type(name_to_del) == "string" and name_to_del ~= "")
assert(type(callback) == "function")
local retval = create_delete_world_dlg(name_to_del, -1, nil)
retval.data.callback = callback
return retval
end

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -19,7 +19,9 @@
local function rename_modpack_formspec(dialogdata)
local retval =
"size[11.5,4.5,true]" ..
"size[11.5,4.5,false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"button[3.25,3.5;2.5,0.5;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. "]" ..
"button[5.75,3.5;2.5,0.5;dlg_rename_modpack_cancel;"..

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -783,7 +783,9 @@ local function create_change_setting_formspec(dialogdata)
end
return (
"size[" .. width .. "," .. height + 0.25 .. ",true]" ..
"size[" .. width .. "," .. height + 0.25 .. ",false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
create_textfield(description_box, setting_name, comment_text) ..
formspec ..
"button[" .. width / 2 - 2.5 .. "," .. height - 0.4 .. ";2.5,1;btn_done;" ..
@ -945,7 +947,9 @@ local function handle_change_setting_buttons(this, fields)
end
local function create_settings_formspec(tabview, _, tabdata)
local formspec = "size[12,5.4;true]" ..
local formspec = "size[12,5.4;false]" ..
"background[0,0;0,0;" .. core.formspec_escape(defaulttexturedir ..
"bg_common.png") .. ";true;32]" ..
"tablecolumns[color;tree;text,width=28;text]" ..
"tableoptions[background=#00000000;border=false]" ..
"field[0.3,0.1;10.2,1;search_string;;" .. core.formspec_escape(search_string) .. "]" ..

View File

@ -126,4 +126,3 @@ file = assert(io.open("src/settings_translation_file.cpp", "w"))
--file = assert(io.open("settings_translation_file.cpp", "w"))
file:write(create_translation_file())
file:close()

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -22,7 +22,7 @@ mt_color_dark_green = "#25C191"
local menupath = core.get_mainmenu_path()
local basepath = core.get_builtin_path()
local menustyle = core.settings:get("main_menu_style")
local mobile = PLATFORM == "Android" or PLATFORM == "iOS"
defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
DIR_DELIM .. "pack" .. DIR_DELIM
@ -36,26 +36,36 @@ dofile(menupath .. DIR_DELIM .. "common.lua")
dofile(menupath .. DIR_DELIM .. "pkgmgr.lua")
dofile(menupath .. DIR_DELIM .. "textures.lua")
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua")
if menustyle ~= "simple" then
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_create_world_default.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
if not mobile then
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_content.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_contentstore.lua")
dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
dofile(menupath .. DIR_DELIM .. "dlg_settings_advanced.lua")
end
local tabs = {}
tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
if not mobile then
tabs.settings = dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
tabs.content = dofile(menupath .. DIR_DELIM .. "tab_content.lua")
end
tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
if menustyle == "simple" then
tabs.simple_main = dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
else
tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
tabs.local_default_game = dofile(menupath .. DIR_DELIM .. "tab_local_default.lua")
tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
local htabs = {}
local hpath = menupath .. DIR_DELIM .. "hosting" .. DIR_DELIM .. "init.lua"
local hosting = io.open(hpath, "r")
if hosting then
htabs = dofile(hpath)
io.close(hosting)
end
--------------------------------------------------------------------------------
@ -67,92 +77,77 @@ local function main_event_handler(tabview, event)
end
--------------------------------------------------------------------------------
local function init_globals()
-- Init gamedata
gamedata.worldindex = 0
if menustyle == "simple" then
local world_list = core.get_worlds()
local world_index
local found_singleplayerworld = false
for i, world in ipairs(world_list) do
if world.name == "singleplayerworld" then
found_singleplayerworld = true
world_index = i
break
end
end
if not found_singleplayerworld then
core.create_world("singleplayerworld", 1)
world_list = core.get_worlds()
for i, world in ipairs(world_list) do
if world.name == "singleplayerworld" then
world_index = i
break
end
end
end
gamedata.worldindex = world_index
else
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.settings:get("menu_last_game") then
local default_game = core.settings:get("default_game") or "minetest"
core.settings:set("menu_last_game", default_game)
end
mm_texture.init()
end
-- Create main tabview
function menudata.init_tabs()
local tv_main = tabview_create("maintab", {x = 12, y = 5.4}, {x = 0, y = 0})
if menustyle == "simple" then
tv_main:add(tabs.simple_main)
else
tv_main:set_autosave_tab(true)
tv_main:add(tabs.local_game)
tv_main:add(tabs.play_online)
for i = 1, #pkgmgr.games do
if pkgmgr.games[i].id == "default" then
tv_main:add(tabs.local_default_game)
break
end
end
tv_main:add(tabs.content)
tv_main:add(tabs.settings)
for i = 1, #pkgmgr.games do
if pkgmgr.games[i].id ~= "default" then
tv_main:add(tabs.local_game)
break
end
end
for _, page in pairs(htabs) do
tv_main:add(page)
end
tv_main:add(tabs.play_online)
if not mobile then
tv_main:set_autosave_tab(true)
tv_main:add(tabs.content)
tv_main:add(tabs.settings)
end
tv_main:add(tabs.credits)
tv_main:set_global_event_handler(main_event_handler)
tv_main:set_fixed_size(false)
if menustyle ~= "simple" then
if not mobile then
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
end
ui.set_default("maintab")
tv_main:show()
ui.update()
end
core.sound_play("main_menu", true)
--------------------------------------------------------------------------------
local function init_globals()
-- Init gamedata
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
)
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
menudata.worldlist:set_sortmode("alphabetic")
-- Create main tabview
core.set_clouds(false)
mm_texture.set_dirt_bg()
menudata.init_tabs()
-- core.sound_play("main_menu", true)
end
init_globals()

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -896,19 +896,44 @@ function pkgmgr.get_game(index)
return nil
end
--------------------------------------------------------------------------------
local default_game_idx
function pkgmgr.get_game_no_default(index)
if default_game_idx and index >= default_game_idx then
index = index + 1
end
return pkgmgr.get_game(index)
end
function pkgmgr.create_world_no_default(worldname, gameindex)
if default_game_idx and gameindex >= default_game_idx then
gameindex = gameindex + 1
end
return core.create_world(worldname, gameindex)
end
--------------------------------------------------------------------------------
function pkgmgr.update_gamelist()
pkgmgr.games = core.get_games()
-- Update default_game_idx
for i, game in ipairs(pkgmgr.games) do
if game.id == "default" then
default_game_idx = i
break
end
end
end
--------------------------------------------------------------------------------
function pkgmgr.gamelist()
local retval = ""
if #pkgmgr.games > 0 then
retval = retval .. core.formspec_escape(pkgmgr.games[1].name)
for i=2,#pkgmgr.games,1 do
retval = retval .. "," .. core.formspec_escape(pkgmgr.games[i].name)
for i = 1, #pkgmgr.games do
if retval ~= "" then retval = retval .. "," end
if pkgmgr.games[i].id ~= "default" then
retval = retval .. core.formspec_escape(pkgmgr.games[i].name)
end
end
end
return retval

View File

@ -4,7 +4,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -30,7 +30,13 @@ local function get_formspec(tabview, name, tabdata)
if packages == nil then
packages_raw = {}
table.insert_all(packages_raw, pkgmgr.games)
local i = 0
for _, game in ipairs(pkgmgr.games) do
if game.id ~= "default" then
i = i + 1
packages_raw[i] = game
end
end
table.insert_all(packages_raw, pkgmgr.get_texture_packs())
table.insert_all(packages_raw, pkgmgr.global_mods:get_list())
@ -136,7 +142,8 @@ 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) then
if core.may_modify_path(selected_pkg.path) and not
(selected_pkg.type == "game" and selected_pkg.name == "default") then
retval = retval ..
"button[5.5,4.65;3.25,1;btn_mod_mgr_delete_mod;" ..
fgettext("Uninstall Package") .. "]"

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -17,6 +17,19 @@
--------------------------------------------------------------------------------
local multicraft_developers = {
"Maksim Gamarnik (MoNTE48) <MoNTE48@mail.ua>",
"Bektur Mambetov (ubulem) <berkut87@gmail.com>",
"Alexander Zavrin (Ransom.00)",
"luk3yx",
"An0n3m0us",
"Jean-Patrick Guerrero (kilbith) <jeanpatrick.guerrero@gmail.com>",
"Vitaliy Lobachevskiy (numberZero) <numzer0@yandex.ru>",
"sfan5 <sfan5@live.de>",
"Stuart Jones (stujones11) <stujones111@gmail.com>",
"And other people who helped make the world better!"
}
local core_developers = {
"Perttu Ahola (celeron55) <celeron55@gmail.com>",
"sfan5 <sfan5@live.de>",
@ -98,15 +111,19 @@ return {
name = "credits",
caption = fgettext("Credits"),
cbf_formspec = function(tabview, name, tabdata)
local logofile = defaulttexturedir .. "logo.png"
local version = core.get_version()
return "image[0.5,1;" .. core.formspec_escape(logofile) .. "]" ..
"label[0.5,2.8;" .. version.project .. " " .. version.string .. "]" ..
"button[0.5,3;2,2;homepage;minetest.net]" ..
return "label[0.1,-0.1;" ..
"MultiCraft Open Source Project, ver. " .. version.string .. "\n" ..
"Copyright (C) 2014-2021 MultiCraft Development Team\n" ..
"Licence: LGPLv3.0+ and CC-BY-SA 4.0, Home page: http://multicraft.world\n" ..
"Created and Powered by Minetest Engine, ver. 5.3.0]" ..
-- "button[10,-0.5;2,2;homepage;multicraft.world]" ..
"tablecolumns[color;text]" ..
"tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
"table[3.5,-0.25;8.5,6.05;list_credits;" ..
"#FFFF00," .. fgettext("Core Developers") .. ",," ..
"tableoptions[background=#999999;highlight=#00000000;border=true]" ..
"table[0,1.6;11.8,3.8;list_credits;" ..
"#FFFF00," .. fgettext("MultiCraft Developers") .. ",," ..
buildCreditList(multicraft_developers) .. ",,," ..
"#FFFF00," .. fgettext("Minetest Developers") .. ",," ..
buildCreditList(core_developers) .. ",,," ..
"#FFFF00," .. fgettext("Active Contributors") .. ",," ..
buildCreditList(active_contributors) .. ",,," ..
@ -118,7 +135,7 @@ return {
end,
cbf_button_handler = function(this, fields, name, tabdata)
if fields.homepage then
core.open_url("https://www.minetest.net")
core.open_url("http://multicraft.world")
end
end,
}

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -15,64 +15,64 @@
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 enable_gamebar = PLATFORM ~= "Android"
local current_game, singleplayer_refresh_gamebar
if enable_gamebar then
function current_game()
local last_game_id = core.settings:get("menu_last_game")
local game = pkgmgr.find_by_gameid(last_game_id)
local function current_game()
local last_game_id = core.settings:get("menu_last_game")
local game = pkgmgr.find_by_gameid(last_game_id)
return game
return game
end
local function singleplayer_refresh_gamebar()
local old_bar = ui.find_by_name("game_button_bar")
if old_bar ~= nil then
old_bar:delete()
end
function singleplayer_refresh_gamebar()
local old_bar = ui.find_by_name("game_button_bar")
if old_bar ~= nil then
old_bar:delete()
local function game_buttonbar_button_handler(fields)
if fields.game_open_cdb then
local maintab = ui.find_by_name("maintab")
local dlg = create_store_dlg("game")
dlg:set_parent(maintab)
maintab:hide()
dlg:show()
return true
end
local function game_buttonbar_button_handler(fields)
if fields.game_open_cdb then
local maintab = ui.find_by_name("maintab")
local dlg = create_store_dlg("game")
dlg:set_parent(maintab)
maintab:hide()
dlg:show()
return true
end
for key,value in pairs(fields) do
for j=1,#pkgmgr.games,1 do
if ("game_btnbar_" .. pkgmgr.games[j].id == key) then
mm_texture.update("singleplayer", pkgmgr.games[j])
core.set_topleft_text(pkgmgr.games[j].name)
core.settings:set("menu_last_game",pkgmgr.games[j].id)
menudata.worldlist:set_filtercriteria(pkgmgr.games[j].id)
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world")))
if not index or index < 1 then
local selected = core.get_textlist_index("sp_worlds")
if selected ~= nil and selected < #menudata.worldlist:get_list() then
index = selected
else
index = #menudata.worldlist:get_list()
end
for key, value in pairs(fields) do
for j=1, #pkgmgr.games do
if ("game_btnbar_" .. pkgmgr.games[j].id == key) then
mm_texture.update("singleplayer", pkgmgr.games[j])
-- core.set_topleft_text(pkgmgr.games[j].name)
core.settings:set("menu_last_game",pkgmgr.games[j].id)
menudata.worldlist:set_filtercriteria(pkgmgr.games[j].id)
--[[local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world")))
if not index or index < 1 then
local selected = core.get_table_index("sp_worlds")
if selected ~= nil and selected < #menudata.worldlist:get_list() then
index = selected
else
index = #menudata.worldlist:get_list()
end
menu_worldmt_legacy(index)
return true
end
end]]
return true
end
end
end
end
local btnbar = buttonbar_create("game_button_bar",
game_buttonbar_button_handler,
{x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})
local btnbar = buttonbar_create("game_button_bar",
game_buttonbar_button_handler,
{x=-1.35, y=-0.32}, "vertical", {x=1, y=6.14})
for i=1,#pkgmgr.games,1 do
for i=1, #pkgmgr.games do
if pkgmgr.games[i].id ~= "default" then
local btn_name = "game_btnbar_" .. pkgmgr.games[i].id
local image = nil
@ -83,7 +83,6 @@ if enable_gamebar then
pkgmgr.games[i].menuicon_path ~= "" then
image = core.formspec_escape(pkgmgr.games[i].menuicon_path)
else
local part1 = pkgmgr.games[i].id:sub(1,5)
local part2 = pkgmgr.games[i].id:sub(6,10)
local part3 = pkgmgr.games[i].id:sub(11)
@ -94,81 +93,104 @@ if enable_gamebar then
text = text .. "\n" .. part3
end
end
btnbar:add_button(btn_name, text, image, tooltip)
end
end
if not mobile then
local plus_image = core.formspec_escape(defaulttexturedir .. "plus.png")
btnbar:add_button("game_open_cdb", "", plus_image, fgettext("Install games from ContentDB"))
end
else
function current_game()
return nil
end
local function filter_default()
local gameid = core.settings:get("menu_last_game")
if not gameid or gameid == "" or gameid == "default" then
for j=1, #pkgmgr.games do
local name = pkgmgr.games[j].id
if name and name ~= "default" then
menudata.worldlist:set_filtercriteria(name)
core.settings:set("menu_last_game", name)
mm_texture.update("singleplayer", current_game())
return
end
end
end
end
local function get_formspec(tabview, name, tabdata)
local retval = ""
local function get_formspec()
filter_default()
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world"))
)
tonumber(core.settings:get("mainmenu_last_selected_world")))
retval = retval ..
"button[4,3.95;2.6,1;world_delete;".. fgettext("Delete") .. "]" ..
"button[6.5,3.95;2.8,1;world_configure;".. fgettext("Configure") .. "]" ..
"button[9.2,3.95;2.5,1;world_create;".. fgettext("New") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
dump(core.settings:get_bool("creative_mode")) .. "]"..
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
dump(core.settings:get_bool("enable_damage")) .. "]"..
"checkbox[0.25,1.15;cb_server;".. fgettext("Host Server") ..";" ..
dump(core.settings:get_bool("enable_server")) .. "]" ..
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
local creative_checkbox = core.settings:get_bool("creative_mode") and
"creative_checkbox" or "blank"
local creative_bg = "creative_bg.png"
if lang and lang == "ru" then
creative_bg = "creative_bg_" .. lang .. ".png"
end
local retval =
"image_button[0,4.84;3.31,0.92;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";world_delete;;true;false]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"image_button[3.14,4.84;3.3,0.92;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";world_create;;true;false]" ..
"tooltip[world_create;".. fgettext("New") .. "]" ..
"button[9.5,4.8;2.5,1;world_configure;".. fgettext("Configure") .. "]" ..
"image_button[6.72,1.43;4.96,1.41;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";play;;true;false]" ..
"tooltip[play;".. fgettext("Play Game") .. "]" ..
"image_button[7.2,3.09;4,0.83;" ..
core.formspec_escape(defaulttexturedir) .. creative_bg ..
";;;true;false]" ..
"image_button[7.2,3.09;4,0.83;" ..
core.formspec_escape(defaulttexturedir) .. creative_checkbox ..
".png;cb_creative_mode;;true;false]" ..
"tableoptions[background=#27233F;border=false]" ..
"table[-0.01,0;6.28,4.64;sp_worlds;" ..
menu_render_worldlist() ..
";" .. index .. "]"
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
retval = retval ..
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
dump(core.settings:get_bool("enable_server")) .. "]"
end
if core.settings:get_bool("enable_server") then
retval = retval ..
"button[8.5,4.8;3.2,1;play;".. fgettext("Host Game") .. "]" ..
"checkbox[0.25,1.6;cb_server_announce;" .. fgettext("Announce Server") .. ";" ..
dump(core.settings:get_bool("server_announce")) .. "]" ..
"label[0.25,2.2;" .. fgettext("Name/Password") .. "]" ..
"field[0.55,3.2;3.5,0.5;te_playername;;" ..
core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[0.55,4;3.5,0.5;te_passwd;]"
"checkbox[6.6,0.65;cb_server_announce;" .. fgettext("Announce Server") .. ";" ..
dump(core.settings:get_bool("server_announce")) .. "]" ..
local bind_addr = core.settings:get("bind_address")
if bind_addr ~= nil and bind_addr ~= "" then
retval = retval ..
"field[0.55,5.2;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
core.formspec_escape(core.settings:get("bind_address")) .. "]" ..
"field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
core.formspec_escape(core.settings:get("port")) .. "]"
else
retval = retval ..
"field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
core.formspec_escape(core.settings:get("port")) .. "]"
end
else
retval = retval ..
"button[8.5,4.8;3.2,1;play;".. fgettext("Play Game") .. "]"
-- Name / Password
"label[6.6,-0.3;" .. fgettext("Name") .. ":" .. "]" ..
"label[9.3,-0.3;" .. fgettext("Password") .. ":" .. "]" ..
"field[6.9,0.6;2.8,0.5;te_playername;;" ..
core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[9.6,0.6;2.8,0.5;te_passwd;]"
end
return retval
end
local function main_button_handler(this, fields, name, tabdata)
local function main_button_handler(this, fields, name)
assert(name == "local")
local world_doubleclick = false
if fields["sp_worlds"] ~= nil then
local event = core.explode_textlist_event(fields["sp_worlds"])
local selected = core.get_textlist_index("sp_worlds")
menu_worldmt_legacy(selected)
local event = core.explode_table_event(fields["sp_worlds"])
local selected = core.get_table_index("sp_worlds")
if event.type == "DCL" then
world_doubleclick = true
@ -186,17 +208,9 @@ local function main_button_handler(this, fields, name, tabdata)
end
if fields["cb_creative_mode"] then
core.settings:set("creative_mode", fields["cb_creative_mode"])
local selected = core.get_textlist_index("sp_worlds")
menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
return true
end
if fields["cb_enable_damage"] then
core.settings:set("enable_damage", fields["cb_enable_damage"])
local selected = core.get_textlist_index("sp_worlds")
menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
local creative_mode = core.settings:get_bool("creative_mode")
core.settings:set("creative_mode", tostring(not creative_mode))
core.settings:set("enable_damage", tostring(creative_mode))
return true
end
@ -209,15 +223,17 @@ local function main_button_handler(this, fields, name, tabdata)
if fields["cb_server_announce"] then
core.settings:set("server_announce", fields["cb_server_announce"])
local selected = core.get_textlist_index("srv_worlds")
local selected = core.get_table_index("srv_worlds")
menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
return true
end
if fields["play"] ~= nil or world_doubleclick or fields["key_enter"] then
local selected = core.get_textlist_index("sp_worlds")
local selected = core.get_table_index("sp_worlds")
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
core.settings:set("maintab_LAST", "local")
core.settings:set("mainmenu_last_selected_world", gamedata.selected_world)
if selected == nil or gamedata.selected_world == 0 then
gamedata.errormessage =
@ -238,12 +254,18 @@ local function main_button_handler(this, fields, name, tabdata)
gamedata.port = fields["te_serverport"]
gamedata.address = ""
core.settings:set("port",gamedata.port)
core.settings:set_bool("auto_connect", false)
if fields["port"] ~= nil then
core.settings:set("port",fields["port"])
end
if fields["te_serveraddr"] ~= nil then
core.settings:set("bind_address",fields["te_serveraddr"])
end
else
gamedata.singleplayer = true
core.settings:set_bool("auto_connect", true)
core.settings:set("connect_time", os.time())
core.start()
end
core.start()
@ -260,7 +282,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
if fields["world_delete"] ~= nil then
local selected = core.get_textlist_index("sp_worlds")
local selected = core.get_table_index("sp_worlds")
if selected ~= nil and
selected <= menudata.worldlist:size() then
local world = menudata.worldlist:get_list()[selected]
@ -268,7 +290,7 @@ local function main_button_handler(this, fields, name, tabdata)
world.name ~= nil and
world.name ~= "" then
local index = menudata.worldlist:get_raw_index(selected)
local delete_world_dlg = create_delete_world_dlg(world.name,index)
local delete_world_dlg = create_delete_world_dlg(world.name, index, world.gameid)
delete_world_dlg:set_parent(this)
this:hide()
delete_world_dlg:show()
@ -280,7 +302,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
if fields["world_configure"] ~= nil then
local selected = core.get_textlist_index("sp_worlds")
local selected = core.get_table_index("sp_worlds")
if selected ~= nil then
local configdialog =
create_configure_world_dlg(
@ -298,36 +320,33 @@ local function main_button_handler(this, fields, name, tabdata)
end
end
local on_change
if enable_gamebar then
function on_change(type, old_tab, new_tab)
if (type == "ENTER") then
local game = current_game()
local function on_change(type, old_tab, new_tab)
if (type == "ENTER") then
local game = current_game()
if game then
menudata.worldlist:set_filtercriteria(game.id)
core.set_topleft_text(game.name)
mm_texture.update("singleplayer",game)
end
singleplayer_refresh_gamebar()
ui.find_by_name("game_button_bar"):show()
else
menudata.worldlist:set_filtercriteria(nil)
local gamebar = ui.find_by_name("game_button_bar")
if gamebar then
gamebar:hide()
end
core.set_topleft_text("")
mm_texture.update(new_tab,nil)
if game then
menudata.worldlist:set_filtercriteria(game.id)
core.set_topleft_text("Powered by Minetest Engine")
mm_texture.update("singleplayer",game)
end
singleplayer_refresh_gamebar()
ui.find_by_name("game_button_bar"):show()
else
menudata.worldlist:set_filtercriteria(nil)
local gamebar = ui.find_by_name("game_button_bar")
if gamebar then
gamebar:hide()
end
core.set_topleft_text("")
mm_texture.update(new_tab,nil)
end
end
--------------------------------------------------------------------------------
return {
name = "local",
caption = fgettext("Start Game"),
caption = fgettext("Other games"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_change

View File

@ -0,0 +1,237 @@
--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 3.0 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.
local lang = core.settings:get("language")
if not lang or lang == "" then lang = os.getenv("LANG") end
local function get_formspec()
menudata.worldlist:set_filtercriteria("default")
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.settings:get("mainmenu_last_selected_world")))
if not index or index < 1 then
local selected = core.get_table_index("sp_worlds")
if selected ~= nil and selected < #menudata.worldlist:get_list() then
index = selected
else
index = #menudata.worldlist:get_list()
end
end
local creative_checkbox = core.settings:get_bool("creative_mode") and
"creative_checkbox" or "blank"
local creative_bg = "creative_bg.png"
if lang and lang == "ru" then
creative_bg = "creative_bg_" .. lang .. ".png"
end
local retval =
"image_button[0,4.84;3.31,0.92;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";world_delete;;true;false]" ..
"tooltip[world_delete;".. fgettext("Delete") .. "]" ..
"image_button[3.14,4.84;3.3,0.92;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";world_create;;true;false]" ..
"tooltip[world_create;".. fgettext("New") .. "]" ..
"image_button[6.72,1.43;4.96,1.41;" ..
core.formspec_escape(defaulttexturedir ..
"blank.png") .. ";play;;true;false]" ..
"tooltip[play;".. fgettext("Play Game") .. "]" ..
"image_button[7.2,3.09;4,0.83;" ..
core.formspec_escape(defaulttexturedir) .. creative_bg ..
";;;true;false]" ..
"image_button[7.2,3.09;4,0.83;" ..
core.formspec_escape(defaulttexturedir) .. creative_checkbox ..
".png;cb_creative_mode;;true;false]" ..
"tableoptions[background=#27233F;border=false]" ..
"table[-0.01,0;6.28,4.64;sp_worlds;" ..
menu_render_worldlist() ..
";" .. index .. "]"
if PLATFORM ~= "Android" and PLATFORM ~= "iOS" then
retval = retval ..
"checkbox[6.6,5;cb_server;".. fgettext("Create Server") ..";" ..
dump(core.settings:get_bool("enable_server")) .. "]"
end
if core.settings:get_bool("enable_server") then
retval = retval ..
"checkbox[6.6,0.65;cb_server_announce;" .. fgettext("Announce Server") .. ";" ..
dump(core.settings:get_bool("server_announce")) .. "]" ..
-- Name / Password
"label[6.6,-0.3;" .. fgettext("Name") .. ":" .. "]" ..
"label[9.3,-0.3;" .. fgettext("Password") .. ":" .. "]" ..
"field[6.9,0.6;2.8,0.5;te_playername;;" ..
core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[9.6,0.6;2.8,0.5;te_passwd;]"
end
return retval
end
local function main_button_handler(this, fields, name)
assert(name == "local_default")
local world_doubleclick = false
if fields["sp_worlds"] ~= nil then
local event = core.explode_table_event(fields["sp_worlds"])
local selected = core.get_table_index("sp_worlds")
if event.type == "DCL" then
world_doubleclick = true
end
if event.type == "CHG" and selected ~= nil then
core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:get_raw_index(selected))
return true
end
end
if menu_handle_key_up_down(fields,"sp_worlds","mainmenu_last_selected_world") then
return true
end
if fields["cb_creative_mode"] then
local creative_mode = core.settings:get_bool("creative_mode")
core.settings:set("creative_mode", tostring(not creative_mode))
core.settings:set("enable_damage", tostring(creative_mode))
return true
end
if fields["cb_server"] then
core.settings:set("enable_server", fields["cb_server"])
return true
end
if fields["cb_server_announce"] then
core.settings:set("server_announce", fields["cb_server_announce"])
local selected = core.get_table_index("srv_worlds")
menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
return true
end
if fields["play"] ~= nil or world_doubleclick or fields["key_enter"] then
local selected = core.get_table_index("sp_worlds")
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
core.settings:set("maintab_LAST", "local_default")
core.settings:set("mainmenu_last_selected_world", gamedata.selected_world)
if core.settings:get_bool("enable_server") then
if selected ~= nil and gamedata.selected_world ~= 0 then
gamedata.playername = fields["te_playername"]
gamedata.password = fields["te_passwd"]
gamedata.port = fields["te_serverport"]
gamedata.address = ""
core.settings:set_bool("auto_connect", false)
if fields["port"] ~= nil then
core.settings:set("port",fields["port"])
end
if fields["te_serveraddr"] ~= nil then
core.settings:set("bind_address",fields["te_serveraddr"])
end
--update last game
local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
if world then
core.settings:set("menu_last_game", "default")
end
core.start()
else
gamedata.errormessage =
fgettext("No world created or selected!")
end
else
if selected ~= nil and gamedata.selected_world ~= 0 then
gamedata.singleplayer = true
core.settings:set_bool("auto_connect", true)
core.settings:set("connect_time", os.time())
core.start()
else
gamedata.errormessage =
fgettext("No world created or selected!")
end
return true
end
end
if fields["world_create"] ~= nil then
core.settings:set("menu_last_game", "default")
local create_world_dlg = create_create_world_default_dlg(true)
create_world_dlg:set_parent(this)
this:hide()
create_world_dlg:show()
return true
end
if fields["world_delete"] ~= nil then
local selected = core.get_table_index("sp_worlds")
if selected ~= nil and
selected <= menudata.worldlist:size() then
local world = menudata.worldlist:get_list()[selected]
if world ~= nil and
world.name ~= nil and
world.name ~= "" then
local index = menudata.worldlist:get_raw_index(selected)
local delete_world_dlg = create_delete_world_dlg(world.name,index)
delete_world_dlg:set_parent(this)
this:hide()
delete_world_dlg:show()
end
end
return true
end
--[[if fields["world_configure"] ~= nil then
local selected = core.get_table_index("sp_worlds")
if selected ~= nil then
local configdialog =
create_configure_world_dlg(
menudata.worldlist:get_raw_index(selected))
if (configdialog ~= nil) then
configdialog:set_parent(this)
this:hide()
configdialog:show()
end
end
return true
end]]
end
--------------------------------------------------------------------------------
return {
name = "local_default",
caption = fgettext("Singleplayer"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler
}

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -16,6 +16,10 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
local password_save = core.settings:get_bool("password_save")
local password_tmp = ""
local mobile_only = 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.
@ -31,58 +35,84 @@ 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
search_panel =
"field[0.2,0.1;5.19,1;te_search;;" .. esc(tabdata.search_for) .. "]" ..
"image_button[4.89,-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")
.. ";btn_mp_refresh;;true;false]" ..
"image_button[6.29,-0.13;0.83,0.83;" .. esc(defaulttexturedir ..
(not mobile_only and "online_pc" or "online_mobile") .. ".png")
.. ";btn_mp_mobile;;true;false]"
else
search_panel =
"field[0.2,0.1;5.8,1;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" ..
"image_button[5.5,-0.13;0.83,0.83;" .. core.formspec_escape(defaulttexturedir .. "search.png")
.. ";btn_mp_search;;true;false]" ..
"image_button[6.26,-0.13;0.83,0.83;" .. core.formspec_escape(defaulttexturedir .. "refresh.png")
.. ";btn_mp_refresh;;true;false]"
end
local retval =
-- Search
"field[0.15,0.075;5.91,1;te_search;;" .. core.formspec_escape(tabdata.search_for) .. "]" ..
"button[5.62,-0.25;1.5,1;btn_mp_search;" .. fgettext("Search") .. "]" ..
"image_button[6.97,-.165;.83,.83;" .. core.formspec_escape(defaulttexturedir .. "refresh.png")
.. ";btn_mp_refresh;]" ..
search_panel..
-- Address / Port
"label[7.75,-0.25;" .. fgettext("Address / Port") .. "]" ..
"field[8,0.65;3.25,0.5;te_address;;" ..
core.formspec_escape(core.settings:get("address")) .. "]" ..
"field[11.1,0.65;1.4,0.5;te_port;;" ..
core.formspec_escape(core.settings:get("remote_port")) .. "]" ..
"label[7.1,-0.3;" .. fgettext("Address") .. ":" .. "]" ..
"label[10.15,-0.3;" .. fgettext("Port") .. ":" .. "]" ..
"field[7.4,0.6;3.2,0.5;te_address;;" ..
esc(core.settings:get("address")) .. "]" ..
"field[10.45,0.6;1.95,0.5;te_port;;" ..
esc(core.settings:get("remote_port")) .. "]" ..
-- Name / Password
"label[7.75,0.95;" .. fgettext("Name / Password") .. "]" ..
"field[8,1.85;2.9,0.5;te_name;;" ..
core.formspec_escape(core.settings:get("name")) .. "]" ..
"pwdfield[10.73,1.85;1.77,0.5;te_pwd;]" ..
-- Name
"label[7.1,0.85;" .. fgettext("Name") .. ":" .. "]" ..
"label[10.15,0.85;" .. fgettext("Password") .. ":" .. "]" ..
"field[7.4,1.75;3.2,0.5;te_name;;" ..
esc(core.settings:get("name")) .. "]" ..
-- Description Background
"box[7.73,2.25;4.25,2.6;#999999]"..
"box[7.1,2.1;4.8,2.65;#999999]" ..
-- Connect
"button[9.88,4.9;2.3,1;btn_mp_connect;" .. fgettext("Connect") .. "]"
"image_button[8.8,4.88;3.3,0.9;" ..
esc(defaulttexturedir .. "blank.png")
.. ";btn_mp_connect;;true;false]" ..
"tooltip[btn_mp_connect;".. fgettext("Connect") .. "]"
local pwd = password_save and esc(core.settings:get("password")) or password_tmp
-- Password
retval = retval .. "pwdfield[10.45,1.8;1.95,0.39;te_pwd;;" .. pwd .. "]"
if tabdata.fav_selected and fav_selected then
if gamedata.fav then
retval = retval .. "button[7.73,4.9;2.3,1;btn_delete_favorite;" ..
fgettext("Del. Favorite") .. "]"
retval = retval .. "image_button[7.1,4.91;0.83,0.83;" .. esc(defaulttexturedir .. "trash.png")
.. ";btn_delete_favorite;;true;false]"
end
if fav_selected.description then
retval = retval .. "textarea[8.1,2.3;4.23,2.9;;;" ..
core.formspec_escape((gamedata.serverdescription or ""), true) .. "]"
retval = retval .. "textarea[7.5,2.2;4.8,3;;" ..
esc((gamedata.serverdescription or ""), true) .. ";]"
end
end
--favourites
retval = retval .. "tablecolumns[" ..
image_column(fgettext("Favorite"), "favorite") .. ";" ..
image_column(fgettext("Ping")) .. ",padding=0.25;" ..
retval = retval ..
"tableoptions[background=#27233F;border=false]" ..
"tablecolumns[" ..
image_column(fgettext("Favorite")) .. ",align=center;" ..
image_column(fgettext("Lag")) .. ",padding=0.25;" ..
"color,span=3;" ..
"text,align=right;" .. -- clients
"text,align=center,padding=0.25;" .. -- "/"
"text,align=right,padding=0.25;" .. -- clients_max
image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" ..
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
--~ PvP = Player versus Player
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
"text,align=right;" .. -- clients
"text,align=center,padding=0.25;" .. -- "/"
"text,align=right,padding=0.25;" .. -- clients_max
image_column(fgettext("Server mode")) .. ",padding=0.5;" ..
"color,span=1;" ..
"text,padding=1]" ..
"table[-0.15,0.6;7.75,5.15;favourites;"
"text,padding=0.5]" ..
"table[-0.09,0.7;6.99,4.93;favourites;"
if menudata.search_result then
for i = 1, #menudata.search_result do
@ -100,7 +130,8 @@ local function get_formspec(tabview, name, tabdata)
retval = retval .. ","
end
retval = retval .. render_serverlist_row(server, server.is_favorite)
retval = retval .. render_serverlist_row(server, server.is_favorite,
server.server_id == "multicraft")
end
elseif #menudata.favorites > 0 then
local favs = core.get_favorites("local")
@ -117,9 +148,11 @@ local function get_formspec(tabview, name, tabdata)
end
end
end
retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0))
retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0),
menudata.favorites[1].server_id == "multicraft")
for i = 2, #menudata.favorites do
retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs))
retval = retval .. "," .. render_serverlist_row(menudata.favorites[i],
(i <= #favs), menudata.favorites[i].server_id == "multicraft")
end
end
@ -141,6 +174,14 @@ local function main_button_handler(tabview, fields, name, tabdata)
core.settings:set("name", fields.te_name)
end
if fields.te_pwd then
if password_save then
core.settings:set("password", fields.te_pwd)
else
password_tmp = fields.te_pwd
end
end
if fields.favourites then
local event = core.explode_table_event(fields.favourites)
local fav = serverlist[event.row]
@ -235,11 +276,9 @@ local function main_button_handler(tabview, fields, name, tabdata)
if not current_favourite then return end
core.delete_favorite(current_favourite)
asyncOnlineFavourites()
asyncOnlineFavourites(mobile_only)
tabdata.fav_selected = nil
core.settings:set("address", "")
core.settings:set("remote_port", "30000")
return true
end
@ -305,7 +344,13 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if fields.btn_mp_refresh then
asyncOnlineFavourites()
asyncOnlineFavourites(mobile_only)
return true
end
if fields.btn_mp_mobile then
mobile_only = not mobile_only
asyncOnlineFavourites(mobile_only)
return true
end
@ -336,6 +381,17 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = ""
end
local auto_connect = false
for _, server in pairs(serverlist) do
if server.server_id == "multicraft" and server.address == gamedata.address then
auto_connect = true
break
end
end
core.settings:set_bool("auto_connect", auto_connect)
core.settings:set("connect_time", os.time())
core.settings:set("maintab_LAST", "online")
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)
@ -347,13 +403,13 @@ end
local function on_change(type, old_tab, new_tab)
if type == "LEAVE" then return end
asyncOnlineFavourites()
asyncOnlineFavourites(mobile_only)
end
--------------------------------------------------------------------------------
return {
name = "online",
caption = fgettext("Join Game"),
caption = fgettext("Multiplayer"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_change

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -122,56 +122,6 @@ local function antialiasing_fname_to_name(fname)
return 0
end
local function dlg_confirm_reset_formspec(data)
return "size[8,3]" ..
"label[1,1;" .. fgettext("Are you sure to reset your singleplayer world?") .. "]" ..
"button[1,2;2.6,0.5;dlg_reset_singleplayer_confirm;" .. fgettext("Yes") .. "]" ..
"button[4,2;2.8,0.5;dlg_reset_singleplayer_cancel;" .. fgettext("No") .. "]"
end
local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
if fields["dlg_reset_singleplayer_confirm"] ~= nil then
local worldlist = core.get_worlds()
local found_singleplayerworld = false
for i = 1, #worldlist do
if worldlist[i].name == "singleplayerworld" then
found_singleplayerworld = true
gamedata.worldindex = i
end
end
if found_singleplayerworld then
core.delete_world(gamedata.worldindex)
end
core.create_world("singleplayerworld", 1)
worldlist = core.get_worlds()
for i = 1, #worldlist do
if worldlist[i].name == "singleplayerworld" then
gamedata.worldindex = i
end
end
end
this.parent:show()
this:hide()
this:delete()
return true
end
local function showconfirm_reset(tabview)
local new_dlg = dialog_create("reset_spworld",
dlg_confirm_reset_formspec,
dlg_confirm_reset_btnhandler,
nil)
new_dlg:set_parent(tabview)
tabview:hide()
new_dlg:show()
end
local function formspec(tabview, name, tabdata)
local tab_string =
"box[0,0;3.75,4.5;#999999]" ..
@ -218,16 +168,9 @@ local function formspec(tabview, name, tabdata)
fgettext("Shaders (unavailable)")) .. "]"
end
if core.settings:get("main_menu_style") == "simple" then
-- 'Reset singleplayer world' only functions with simple menu
tab_string = tab_string ..
"button[8,4.75;3.95,1;btn_reset_singleplayer;"
.. fgettext("Reset singleplayer world") .. "]"
else
tab_string = tab_string ..
tab_string = tab_string ..
"button[8,4.75;3.95,1;btn_change_keys;"
.. fgettext("Change Keys") .. "]"
end
tab_string = tab_string ..
"button[0,4.75;3.95,1;btn_advanced_settings;"
@ -359,10 +302,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
core.settings:set("touchtarget", fields["cb_touchscreen_target"])
return true
end
if fields["btn_reset_singleplayer"] then
showconfirm_reset(this)
return true
end
--Note dropdowns have to be handled LAST!
local ddhandled = false

View File

@ -1,220 +0,0 @@
--Minetest
--Copyright (C) 2013 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.
--------------------------------------------------------------------------------
local function get_formspec(tabview, name, tabdata)
-- Update the cached supported proto info,
-- it may have changed after a change by the settings menu.
common_update_cached_supp_proto()
local fav_selected = menudata.favorites[tabdata.fav_selected]
local retval =
"label[9.5,0;".. fgettext("Name / Password") .. "]" ..
"field[0.25,3.35;5.5,0.5;te_address;;" ..
core.formspec_escape(core.settings:get("address")) .."]" ..
"field[5.75,3.35;2.25,0.5;te_port;;" ..
core.formspec_escape(core.settings:get("remote_port")) .."]" ..
"button[10,2.6;2,1.5;btn_mp_connect;".. fgettext("Connect") .. "]" ..
"field[9.8,1;2.6,0.5;te_name;;" ..
core.formspec_escape(core.settings:get("name")) .."]" ..
"pwdfield[9.8,2;2.6,0.5;te_pwd;]"
if tabdata.fav_selected and fav_selected then
if gamedata.fav then
retval = retval .. "button[7.7,2.6;2.3,1.5;btn_delete_favorite;" ..
fgettext("Del. Favorite") .. "]"
end
end
retval = retval .. "tablecolumns[" ..
image_column(fgettext("Favorite"), "favorite") .. ";" ..
image_column(fgettext("Ping"), "") .. ",padding=0.25;" ..
"color,span=3;" ..
"text,align=right;" .. -- clients
"text,align=center,padding=0.25;" .. -- "/"
"text,align=right,padding=0.25;" .. -- clients_max
image_column(fgettext("Creative mode"), "creative") .. ",padding=1;" ..
image_column(fgettext("Damage enabled"), "damage") .. ",padding=0.25;" ..
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
"color,span=1;" ..
"text,padding=1]" .. -- name
"table[-0.05,0;9.2,2.75;favourites;"
if #menudata.favorites > 0 then
local favs = core.get_favorites("local")
if #favs > 0 then
for i = 1, #favs do
for j = 1, #menudata.favorites do
if menudata.favorites[j].address == favs[i].address and
menudata.favorites[j].port == favs[i].port then
table.insert(menudata.favorites, i,
table.remove(menudata.favorites, j))
end
end
if favs[i].address ~= menudata.favorites[i].address then
table.insert(menudata.favorites, i, favs[i])
end
end
end
retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0))
for i = 2, #menudata.favorites do
retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs))
end
end
if tabdata.fav_selected then
retval = retval .. ";" .. tabdata.fav_selected .. "]"
else
retval = retval .. ";0]"
end
-- separator
retval = retval .. "box[-0.28,3.75;12.4,0.1;#FFFFFF]"
-- checkboxes
retval = retval ..
"checkbox[8.0,3.9;cb_creative;".. fgettext("Creative Mode") .. ";" ..
dump(core.settings:get_bool("creative_mode")) .. "]"..
"checkbox[8.0,4.4;cb_damage;".. fgettext("Enable Damage") .. ";" ..
dump(core.settings:get_bool("enable_damage")) .. "]"
-- buttons
retval = retval ..
"button[0,3.7;8,1.5;btn_start_singleplayer;" .. fgettext("Start Singleplayer") .. "]" ..
"button[0,4.5;8,1.5;btn_config_sp_world;" .. fgettext("Config mods") .. "]"
return retval
end
--------------------------------------------------------------------------------
local function main_button_handler(tabview, fields, name, tabdata)
if fields.btn_start_singleplayer then
gamedata.selected_world = gamedata.worldindex
gamedata.singleplayer = true
core.start()
return true
end
if fields.favourites then
local event = core.explode_table_event(fields.favourites)
if event.type == "CHG" then
if event.row <= #menudata.favorites then
gamedata.fav = false
local favs = core.get_favorites("local")
local fav = menudata.favorites[event.row]
local address = fav.address
local port = fav.port
gamedata.serverdescription = fav.description
for i = 1, #favs do
if fav.address == favs[i].address and
fav.port == favs[i].port then
gamedata.fav = true
end
end
if address and port then
core.settings:set("address", address)
core.settings:set("remote_port", port)
end
tabdata.fav_selected = event.row
end
return true
end
end
if fields.btn_delete_favorite then
local current_favourite = core.get_table_index("favourites")
if not current_favourite then return end
core.delete_favorite(current_favourite)
asyncOnlineFavourites()
tabdata.fav_selected = nil
core.settings:set("address", "")
core.settings:set("remote_port", "30000")
return true
end
if fields.cb_creative then
core.settings:set("creative_mode", fields.cb_creative)
return true
end
if fields.cb_damage then
core.settings:set("enable_damage", fields.cb_damage)
return true
end
if fields.btn_mp_connect or fields.key_enter then
gamedata.playername = fields.te_name
gamedata.password = fields.te_pwd
gamedata.address = fields.te_address
gamedata.port = fields.te_port
local fav_idx = core.get_textlist_index("favourites")
if fav_idx and fav_idx <= #menudata.favorites and
menudata.favorites[fav_idx].address == fields.te_address and
menudata.favorites[fav_idx].port == fields.te_port then
local fav = menudata.favorites[fav_idx]
gamedata.servername = fav.name
gamedata.serverdescription = fav.description
if menudata.favorites_is_public and
not is_server_protocol_compat_or_error(
fav.proto_min, fav.proto_max) then
return true
end
else
gamedata.servername = ""
gamedata.serverdescription = ""
end
gamedata.selected_world = 0
core.settings:set("address", fields.te_address)
core.settings:set("remote_port", fields.te_port)
core.start()
return true
end
if fields.btn_config_sp_world then
local configdialog = create_configure_world_dlg(1)
if configdialog then
configdialog:set_parent(tabview)
tabview:hide()
configdialog:show()
end
return true
end
end
--------------------------------------------------------------------------------
local function on_activate(type,old_tab,new_tab)
if type == "LEAVE" then return end
asyncOnlineFavourites()
end
--------------------------------------------------------------------------------
return {
name = "main",
caption = fgettext("Main"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_activate
}

View File

@ -3,7 +3,7 @@
--
--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
--the Free Software Foundation; either version 3.0 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
@ -46,12 +46,6 @@ end
--------------------------------------------------------------------------------
function mm_texture.reset()
mm_texture.gameid = nil
local have_bg = false
local have_overlay = mm_texture.set_generic("overlay")
if not have_overlay then
have_bg = mm_texture.set_generic("background")
end
mm_texture.clear("header")
mm_texture.clear("footer")
@ -60,13 +54,7 @@ function mm_texture.reset()
mm_texture.set_generic("footer")
mm_texture.set_generic("header")
if not have_bg then
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()
end
end
mm_texture.set_dirt_bg()
end
--------------------------------------------------------------------------------
@ -87,7 +75,6 @@ function mm_texture.update_game(gamedetails)
core.set_clouds(false)
if not have_bg then
if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
@ -172,14 +159,5 @@ function mm_texture.set_game(identifier, gamedetails)
end
function mm_texture.set_dirt_bg()
if mm_texture.texturepack ~= nil then
local path = mm_texture.texturepack .. DIR_DELIM .."default_dirt.png"
if core.set_background("background", path, true, 128) then
return true
end
end
-- Use universal fallback texture in textures/base/pack
local minimalpath = defaulttexturedir .. "menu_bg.png"
core.set_background("background", minimalpath, true, 128)
core.set_background("background", defaulttexturedir .. "bg.png", true, 256)
end

View File

@ -975,7 +975,7 @@ enable_remote_media_server (Connect to external media server) bool true
# Enable Lua modding support on client.
# This support is experimental and API can change.
enable_client_modding (Client modding) bool true
enable_client_modding (Client modding) bool false
# URL to the server list displayed in the Multiplayer Tab.
serverlist_url (Serverlist URL) string servers.minetest.net
@ -1124,7 +1124,7 @@ player_transfer_distance (Player transfer distance) int 0
enable_pvp (Player versus player) bool true
# Enable mod channels support.
enable_mod_channels (Mod channels) bool true
enable_mod_channels (Mod channels) bool false
# If this is set, players will always (re)spawn at the given position.
static_spawnpoint (Static spawnpoint) string
@ -1315,7 +1315,7 @@ server_side_occlusion_culling (Server side occlusion culling) bool true
# LOOKUP_NODES_LIMIT: 16 (limits get_node call client-side to
# csm_restriction_noderange)
# READ_PLAYERINFO: 32 (disable get_player_names call client-side)
csm_restriction_flags (Client side modding restrictions) int 60
csm_restriction_flags (Client side modding restrictions) int 62
# If the CSM restriction for node range is enabled, get_node calls are limited
# to this distance from the player to the node.

BIN
textures/base/pack/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 916 B

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

After

Width:  |  Height:  |  Size: 118 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B