summaryrefslogtreecommitdiff
path: root/builtin/mainmenu
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r--builtin/mainmenu/common.lua40
-rw-r--r--builtin/mainmenu/dlg_config_world.lua134
-rw-r--r--builtin/mainmenu/dlg_create_world.lua14
-rw-r--r--builtin/mainmenu/dlg_settings_advanced.lua162
-rw-r--r--builtin/mainmenu/gamemgr.lua4
-rw-r--r--builtin/mainmenu/init.lua27
-rw-r--r--builtin/mainmenu/modmgr.lua60
-rw-r--r--builtin/mainmenu/store.lua6
-rw-r--r--builtin/mainmenu/tab_credits.lua85
-rw-r--r--builtin/mainmenu/tab_local.lua (renamed from builtin/mainmenu/tab_singleplayer.lua)137
-rw-r--r--builtin/mainmenu/tab_mods.lua9
-rw-r--r--builtin/mainmenu/tab_online.lua (renamed from builtin/mainmenu/tab_multiplayer.lua)179
-rw-r--r--builtin/mainmenu/tab_server.lua195
-rw-r--r--builtin/mainmenu/tab_settings.lua134
-rw-r--r--builtin/mainmenu/tab_simple_main.lua39
-rw-r--r--builtin/mainmenu/tab_texturepacks.lua8
-rw-r--r--builtin/mainmenu/textures.lua6
17 files changed, 649 insertions, 590 deletions
diff --git a/builtin/mainmenu/common.lua b/builtin/mainmenu/common.lua
index da3667828..fa7ae583b 100644
--- a/builtin/mainmenu/common.lua
+++ b/builtin/mainmenu/common.lua
@@ -43,10 +43,10 @@ end
local function configure_selected_world_params(idx)
local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
- core.setting_set("creative_mode", worldconfig.creative_mode)
+ core.settings:set("creative_mode", worldconfig.creative_mode)
end
if worldconfig.enable_damage then
- core.setting_set("enable_damage", worldconfig.enable_damage)
+ core.settings:set("enable_damage", worldconfig.enable_damage)
end
end
@@ -54,7 +54,12 @@ end
function image_column(tooltip, flagname)
return "image,tooltip=" .. core.formspec_escape(tooltip) .. "," ..
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
- "1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".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")
end
--------------------------------------------------------------------------------
@@ -77,7 +82,7 @@ function order_favorite_list(list)
end
--------------------------------------------------------------------------------
-function render_favorite(spec, is_favorite)
+function render_serverlist_row(spec, is_favorite)
local text = ""
if spec.name then
text = text .. core.formspec_escape(spec.name:trim())
@@ -97,6 +102,21 @@ function render_favorite(spec, is_favorite)
details = "0,"
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,"
+ else
+ details = details .. "5,"
+ end
+ else
+ details = details .. "0,"
+ end
+
if spec.clients and spec.clients_max then
local clients_color = ''
local clients_percent = 100 * spec.clients / spec.clients_max
@@ -144,8 +164,8 @@ end
--------------------------------------------------------------------------------
os.tempfolder = function()
- if core.setting_get("TMPFolder") then
- return core.setting_get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
+ if core.settings:get("TMPFolder") then
+ return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
end
local filetocheck = os.tmpname()
@@ -186,7 +206,7 @@ function menu_handle_key_up_down(fields, textlist, settingname)
oldidx < menudata.worldlist:size() then
newidx = oldidx + 1
end
- core.setting_set(settingname, menudata.worldlist:get_raw_index(newidx))
+ core.settings:set(settingname, menudata.worldlist:get_raw_index(newidx))
configure_selected_world_params(newidx)
return true
end
@@ -230,7 +250,7 @@ end
--------------------------------------------------------------------------------
function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency)
- local textlines = core.splittext(text, textlen)
+ local textlines = core.wrap_text(text, textlen)
local retval = "textlist[" .. xpos .. "," .. ypos .. ";" .. width ..
"," .. height .. ";" .. tl_name .. ";"
@@ -308,9 +328,9 @@ function menu_worldmt_legacy(selected)
for _, mode_name in pairs(modes_names) do
local mode_val = menu_worldmt(selected, mode_name)
if mode_val then
- core.setting_set(mode_name, mode_val)
+ core.settings:set(mode_name, mode_val)
else
- menu_worldmt(selected, mode_name, core.setting_get(mode_name))
+ menu_worldmt(selected, mode_name, core.settings:get(mode_name))
end
end
end
diff --git a/builtin/mainmenu/dlg_config_world.lua b/builtin/mainmenu/dlg_config_world.lua
index 7b3ab9852..fcedadea8 100644
--- a/builtin/mainmenu/dlg_config_world.lua
+++ b/builtin/mainmenu/dlg_config_world.lua
@@ -17,14 +17,13 @@
--------------------------------------------------------------------------------
-local enabled_all = false
+local enabled_all = false
local function modname_valid(name)
return not name:find("[^a-z0-9_]")
end
local function get_formspec(data)
-
local mod = data.list:get_list()[data.selected_mod]
local retval =
@@ -32,24 +31,12 @@ local function get_formspec(data)
"label[0.5,0;" .. fgettext("World:") .. "]" ..
"label[1.75,0;" .. data.worldspec.name .. "]"
- if data.hide_gamemods then
- retval = retval .. "checkbox[1,6;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";true]"
- else
- retval = retval .. "checkbox[1,6;cb_hide_gamemods;" .. fgettext("Hide Game") .. ";false]"
- end
-
- if data.hide_modpackcontents then
- retval = retval .. "checkbox[6,6;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";true]"
- else
- retval = retval .. "checkbox[6,6;cb_hide_mpcontent;" .. fgettext("Hide mp content") .. ";false]"
- end
-
if mod == nil then
mod = {name=""}
end
local hard_deps, soft_deps = modmgr.get_dependencies(mod.path)
-
+
retval = retval ..
"label[0,0.7;" .. fgettext("Mod:") .. "]" ..
"label[0.75,0.7;" .. mod.name .. "]" ..
@@ -62,41 +49,45 @@ local function get_formspec(data)
"button[3.25,7;2.5,0.5;btn_config_world_save;" .. fgettext("Save") .. "]" ..
"button[5.75,7;2.5,0.5;btn_config_world_cancel;" .. fgettext("Cancel") .. "]"
- if mod ~= nil and mod.name ~= "" and mod.typ ~= "game_mod" then
+ if mod and mod.name ~= "" and not mod.is_game_content then
if mod.is_modpack then
local rawlist = data.list:get_raw_list()
local all_enabled = true
- for j=1,#rawlist,1 do
- if rawlist[j].modpack == mod.name and
- rawlist[j].enabled ~= true then
- all_enabled = false
- break
+ for j = 1, #rawlist, 1 do
+ if rawlist[j].modpack == mod.name and not rawlist[j].enabled then
+ all_enabled = false
+ break
end
end
- if all_enabled == false then
- retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_enable;" .. fgettext("Enable MP") .. "]"
+ if all_enabled then
+ retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_disable;" ..
+ fgettext("Disable MP") .. "]"
else
- retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_disable;" .. fgettext("Disable MP") .. "]"
+ retval = retval .. "button[5.5,0.125;2.5,0.5;btn_mp_enable;" ..
+ fgettext("Enable MP") .. "]"
end
else
if mod.enabled then
- retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("enabled") .. ";true]"
+ retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" ..
+ fgettext("enabled") .. ";true]"
else
- retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" .. fgettext("enabled") .. ";false]"
+ retval = retval .. "checkbox[5.5,-0.125;cb_mod_enable;" ..
+ fgettext("enabled") .. ";false]"
end
end
end
- if enabled_all then
+ if enabled_all then
retval = retval ..
- "button[8.75,0.125;2.5,0.5;btn_disable_all_mods;" .. fgettext("Disable all") .. "]" ..
- "textlist[5.5,0.75;5.75,5.4;world_config_modlist;"
+ "button[8.75,0.125;2.5,0.5;btn_disable_all_mods;" .. fgettext("Disable all") .. "]"
else
retval = retval ..
- "button[8.75,0.125;2.5,0.5;btn_enable_all_mods;" .. fgettext("Enable all") .. "]" ..
- "textlist[5.5,0.75;5.75,5.4;world_config_modlist;"
+ "button[8.75,0.125;2.5,0.5;btn_enable_all_mods;" .. fgettext("Enable all") .. "]"
end
+ retval = retval ..
+ "tablecolumns[color;tree;text]" ..
+ "table[5.5,0.75;5.75,6;world_config_modlist;"
retval = retval .. modmgr.render_modlist(data.list)
retval = retval .. ";" .. data.selected_mod .."]"
@@ -106,7 +97,7 @@ end
local function enable_mod(this, toset)
local mod = this.data.list:get_list()[this.data.selected_mod]
- if mod.typ == "game_mod" then
+ if mod.is_game_content then
-- game mods can't be enabled or disabled
elseif not mod.is_modpack then
if toset == nil then
@@ -129,16 +120,15 @@ end
local function handle_buttons(this, fields)
-
if fields["world_config_modlist"] ~= nil then
- local event = core.explode_textlist_event(fields["world_config_modlist"])
- this.data.selected_mod = event.index
- core.setting_set("world_config_selected_mod", event.index)
+ local event = core.explode_table_event(fields["world_config_modlist"])
+ this.data.selected_mod = event.row
+ core.settings:set("world_config_selected_mod", event.row)
if event.type == "DCL" then
enable_mod(this)
end
-
+
return true
end
@@ -160,44 +150,7 @@ local function handle_buttons(this, fields)
return true
end
- if fields["cb_hide_gamemods"] ~= nil or
- fields["cb_hide_mpcontent"] ~= nil then
- local current = this.data.list:get_filtercriteria()
-
- if current == nil then
- current = {}
- end
-
- if fields["cb_hide_gamemods"] ~= nil then
- if core.is_yes(fields["cb_hide_gamemods"]) then
- current.hide_game = true
- this.data.hide_gamemods = true
- core.setting_set("world_config_hide_gamemods", "true")
- else
- current.hide_game = false
- this.data.hide_gamemods = false
- core.setting_set("world_config_hide_gamemods", "false")
- end
- end
-
- if fields["cb_hide_mpcontent"] ~= nil then
- if core.is_yes(fields["cb_hide_mpcontent"]) then
- current.hide_modpackcontents = true
- this.data.hide_modpackcontents = true
- core.setting_set("world_config_hide_modpackcontents", "true")
- else
- current.hide_modpackcontents = false
- this.data.hide_modpackcontents = false
- core.setting_set("world_config_hide_modpackcontents", "false")
- end
- end
-
- this.data.list:set_filtercriteria(current)
- return true
- end
-
if fields["btn_config_world_save"] then
-
local filename = this.data.worldspec.path ..
DIR_DELIM .. "world.mt"
@@ -209,7 +162,7 @@ local function handle_buttons(this, fields)
local i,mod
for i,mod in ipairs(rawlist) do
if not mod.is_modpack and
- mod.typ ~= "game_mod" then
+ not mod.is_game_content then
if modname_valid(mod.name) then
worldfile:set("load_mod_"..mod.name, tostring(mod.enabled))
else
@@ -231,7 +184,7 @@ local function handle_buttons(this, fields)
if not worldfile:write() then
core.log("error", "Failed to write world config file")
end
-
+
this:delete()
return true
end
@@ -245,19 +198,21 @@ local function handle_buttons(this, fields)
local list = this.data.list:get_raw_list()
for i = 1, #list do
- if list[i].typ ~= "game_mod" and not list[i].is_modpack then
+ if not list[i].is_game_content
+ and not list[i].is_modpack then
list[i].enabled = true
end
end
enabled_all = true
return true
end
-
+
if fields.btn_disable_all_mods then
local list = this.data.list:get_raw_list()
for i = 1, #list do
- if list[i].typ ~= "game_mod" and not list[i].is_modpack then
+ if not list[i].is_game_content
+ and not list[i].is_modpack then
list[i].enabled = false
end
end
@@ -269,15 +224,12 @@ local function handle_buttons(this, fields)
end
function create_configure_world_dlg(worldidx)
-
local dlg = dialog_create("sp_config_world",
get_formspec,
handle_buttons,
nil)
- dlg.data.hide_gamemods = core.setting_getbool("world_config_hide_gamemods")
- dlg.data.hide_modpackcontents = core.setting_getbool("world_config_hide_modpackcontents")
- dlg.data.selected_mod = tonumber(core.setting_get("world_config_selected_mod"))
+ dlg.data.selected_mod = tonumber(core.settings:get("world_config_selected_mod"))
if dlg.data.selected_mod == nil then
dlg.data.selected_mod = 0
end
@@ -286,14 +238,14 @@ function create_configure_world_dlg(worldidx)
if dlg.data.worldspec == nil then dlg:delete() return nil end
dlg.data.worldconfig = modmgr.get_worldconfig(dlg.data.worldspec.path)
-
+
if dlg.data.worldconfig == nil or dlg.data.worldconfig.id == nil or
dlg.data.worldconfig.id == "" then
dlg:delete()
return nil
end
-
+
dlg.data.list = filterlist.create(
modmgr.preparemodlist, --refresh
modmgr.comparemod, --compare
@@ -302,16 +254,16 @@ function create_configure_world_dlg(worldidx)
return true
end
end,
- function(element,criteria)
+ function(element, criteria)
if criteria.hide_game and
- element.typ == "game_mod" then
- return false
+ element.is_game_content then
+ return false
end
if criteria.hide_modpackcontents and
- element.modpack ~= nil then
- return false
- end
+ element.modpack ~= nil then
+ return false
+ end
return true
end, --filter
{ worldpath= dlg.data.worldspec.path,
diff --git a/builtin/mainmenu/dlg_create_world.lua b/builtin/mainmenu/dlg_create_world.lua
index 477b8bcb9..e9ca7799f 100644
--- a/builtin/mainmenu/dlg_create_world.lua
+++ b/builtin/mainmenu/dlg_create_world.lua
@@ -18,8 +18,8 @@
local function create_world_formspec(dialogdata)
local mapgens = core.get_mapgen_names()
- local current_seed = core.setting_get("fixed_map_seed") or ""
- local current_mg = core.setting_get("mg_name")
+ local current_seed = core.settings:get("fixed_map_seed") or ""
+ local current_mg = core.settings:get("mg_name")
local mglist = ""
local selindex = 1
@@ -33,7 +33,7 @@ local function create_world_formspec(dialogdata)
end
mglist = mglist:sub(1, -2)
- local gameid = core.setting_get("menu_last_game")
+ local gameid = core.settings:get("menu_last_game")
local game, gameidx = nil , 0
if gameid ~= nil then
@@ -90,10 +90,10 @@ local function create_world_buttonhandler(this, fields)
local message = nil
- core.setting_set("fixed_map_seed", fields["te_seed"])
+ core.settings:set("fixed_map_seed", fields["te_seed"])
if not menudata.worldlist:uid_exists_raw(worldname) then
- core.setting_set("mg_name",fields["dd_mapgen"])
+ core.settings:set("mg_name",fields["dd_mapgen"])
message = core.create_world(worldname,gameindex)
else
message = fgettext("A world named \"$1\" already exists", worldname)
@@ -102,13 +102,13 @@ local function create_world_buttonhandler(this, fields)
if message ~= nil then
gamedata.errormessage = message
else
- core.setting_set("menu_last_game",gamemgr.games[gameindex].id)
+ core.settings:set("menu_last_game",gamemgr.games[gameindex].id)
if this.data.update_worldlist_filter then
menudata.worldlist:set_filtercriteria(gamemgr.games[gameindex].id)
mm_texture.update("singleplayer", gamemgr.games[gameindex].id)
end
menudata.worldlist:refresh()
- core.setting_set("mainmenu_last_selected_world",
+ core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:raw_index_by_uid(worldname))
end
else
diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua
index b0d923768..206ce1620 100644
--- a/builtin/mainmenu/dlg_settings_advanced.lua
+++ b/builtin/mainmenu/dlg_settings_advanced.lua
@@ -344,11 +344,86 @@ local function parse_config_file(read_all, parse_mods)
return settings
end
-local settings = parse_config_file(false, true)
+local function filter_settings(settings, searchstring)
+ if not searchstring or searchstring == "" then
+ return settings, -1
+ end
+
+ -- Setup the keyword list
+ local keywords = {}
+ for word in searchstring:lower():gmatch("%S+") do
+ table.insert(keywords, word)
+ end
+
+ local result = {}
+ local category_stack = {}
+ local current_level = 0
+ local best_setting = nil
+ for _, entry in pairs(settings) do
+ if entry.type == "category" then
+ -- Remove all settingless categories
+ while #category_stack > 0 and entry.level <= current_level do
+ table.remove(category_stack, #category_stack)
+ if #category_stack > 0 then
+ current_level = category_stack[#category_stack].level
+ else
+ current_level = 0
+ end
+ end
+
+ -- Push category onto stack
+ category_stack[#category_stack + 1] = entry
+ current_level = entry.level
+ else
+ -- See if setting matches keywords
+ local setting_score = 0
+ for k = 1, #keywords do
+ local keyword = keywords[k]
+
+ if string.find(entry.name:lower(), keyword, 1, true) then
+ setting_score = setting_score + 1
+ end
+
+ if entry.readable_name and
+ string.find(fgettext(entry.readable_name):lower(), keyword, 1, true) then
+ setting_score = setting_score + 1
+ end
+
+ if entry.comment and
+ string.find(fgettext_ne(entry.comment):lower(), keyword, 1, true) then
+ setting_score = setting_score + 1
+ end
+ end
+
+ -- Add setting to results if match
+ if setting_score > 0 then
+ -- Add parent categories
+ for _, category in pairs(category_stack) do
+ result[#result + 1] = category
+ end
+ category_stack = {}
+
+ -- Add setting
+ result[#result + 1] = entry
+ entry.score = setting_score
+
+ if not best_setting or
+ setting_score > result[best_setting].score then
+ best_setting = #result
+ end
+ end
+ end
+ end
+ return result, best_setting or -1
+end
+
+local full_settings = parse_config_file(false, true)
+local search_string = ""
+local settings = full_settings
local selected_setting = 1
local function get_current_value(setting)
- local value = core.setting_get(setting.name)
+ local value = core.settings:get(setting.name)
if value == nil then
value = setting.default
end
@@ -464,11 +539,11 @@ local function handle_change_setting_buttons(this, fields)
if setting.type == "bool" then
local new_value = fields["dd_setting_value"]
-- Note: new_value is the actual (translated) value shown in the dropdown
- core.setting_setbool(setting.name, new_value == fgettext("Enabled"))
+ core.settings:set_bool(setting.name, new_value == fgettext("Enabled"))
elseif setting.type == "enum" then
local new_value = fields["dd_setting_value"]
- core.setting_set(setting.name, new_value)
+ core.settings:set(setting.name, new_value)
elseif setting.type == "int" then
local new_value = tonumber(fields["te_setting_value"])
@@ -490,7 +565,7 @@ local function handle_change_setting_buttons(this, fields)
core.update_formspec(this:get_formspec())
return true
end
- core.setting_set(setting.name, new_value)
+ core.settings:set(setting.name, new_value)
elseif setting.type == "float" then
local new_value = tonumber(fields["te_setting_value"])
@@ -500,7 +575,7 @@ local function handle_change_setting_buttons(this, fields)
core.update_formspec(this:get_formspec())
return true
end
- core.setting_set(setting.name, new_value)
+ core.settings:set(setting.name, new_value)
elseif setting.type == "flags" then
local new_value = fields["te_setting_value"]
@@ -514,13 +589,13 @@ local function handle_change_setting_buttons(this, fields)
return true
end
end
- core.setting_set(setting.name, new_value)
+ core.settings:set(setting.name, new_value)
else
local new_value = fields["te_setting_value"]
- core.setting_set(setting.name, new_value)
+ core.settings:set(setting.name, new_value)
end
- core.setting_save()
+ core.settings:write()
this:delete()
return true
end
@@ -544,14 +619,17 @@ end
local function create_settings_formspec(tabview, name, tabdata)
local formspec = "size[12,6.5;true]" ..
- "tablecolumns[color;tree;text;text]" ..
+ "tablecolumns[color;tree;text,width=32;text]" ..
"tableoptions[background=#00000000;border=false]" ..
- "table[0,0;12,5.5;list_settings;"
+ "field[0.3,0.1;10.2,1;search_string;;" .. core.formspec_escape(search_string) .. "]" ..
+ "field_close_on_enter[search_string;false]" ..
+ "button[10.2,-0.2;2,1;search;" .. fgettext("Search") .. "]" ..
+ "table[0,0.8;12,4.5;list_settings;"
local current_level = 0
for _, entry in ipairs(settings) do
local name
- if not core.setting_getbool("main_menu_technical_settings") and entry.readable_name then
+ if not core.settings:get_bool("main_menu_technical_settings") and entry.readable_name then
name = fgettext_ne(entry.readable_name)
else
name = entry.name
@@ -588,7 +666,7 @@ local function create_settings_formspec(tabview, name, tabdata)
"button[10,6;2,1;btn_edit;" .. fgettext("Edit") .. "]" ..
"button[7,6;3,1;btn_restore;" .. fgettext("Restore Default") .. "]" ..
"checkbox[0,5.3;cb_tech_settings;" .. fgettext("Show technical names") .. ";"
- .. dump(core.setting_getbool("main_menu_technical_settings")) .. "]"
+ .. dump(core.settings:get_bool("main_menu_technical_settings")) .. "]"
return formspec
end
@@ -597,13 +675,13 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
local list_enter = false
if fields["list_settings"] then
selected_setting = core.get_table_index("list_settings")
- if core.explode_table_event(fields["list_settings"]).type == "DCL" then
+ if core.explode_table_event(fields["list_settings"]).type == "DCL" then
-- Directly toggle booleans
local setting = settings[selected_setting]
- if setting.type == "bool" then
+ if setting and setting.type == "bool" then
local current_value = get_current_value(setting)
- core.setting_setbool(setting.name, not core.is_yes(current_value))
- core.setting_save()
+ core.settings:set_bool(setting.name, not core.is_yes(current_value))
+ core.settings:write()
return true
else
list_enter = true
@@ -613,9 +691,39 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
end
end
+ if fields.search or fields.key_enter_field == "search_string" then
+ if search_string == fields.search_string then
+ if selected_setting > 0 then
+ -- Go to next result on enter press
+ local i = selected_setting + 1
+ local looped = false
+ while i > #settings or settings[i].type == "category" do
+ i = i + 1
+ if i > #settings then
+ -- Stop infinte looping
+ if looped then
+ return false
+ end
+ i = 1
+ looped = true
+ end
+ end
+ selected_setting = i
+ core.update_formspec(this:get_formspec())
+ return true
+ end
+ else
+ -- Search for setting
+ search_string = fields.search_string
+ settings, selected_setting = filter_settings(full_settings, search_string)
+ core.update_formspec(this:get_formspec())
+ end
+ return true
+ end
+
if fields["btn_edit"] or list_enter then
local setting = settings[selected_setting]
- if setting.type ~= "category" then
+ if setting and setting.type ~= "category" then
local edit_dialog = dialog_create("change_setting", create_change_setting_formspec,
handle_change_setting_buttons)
edit_dialog:set_parent(this)
@@ -627,9 +735,9 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
if fields["btn_restore"] then
local setting = settings[selected_setting]
- if setting.type ~= "category" then
- core.setting_set(setting.name, setting.default)
- core.setting_save()
+ if setting and setting.type ~= "category" then
+ core.settings:set(setting.name, setting.default)
+ core.settings:write()
core.update_formspec(this:get_formspec())
end
return true
@@ -641,8 +749,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
end
if fields["cb_tech_settings"] then
- core.setting_set("main_menu_technical_settings", fields["cb_tech_settings"])
- core.setting_save()
+ core.settings:set("main_menu_technical_settings", fields["cb_tech_settings"])
+ core.settings:write()
core.update_formspec(this:get_formspec())
return true
end
@@ -661,10 +769,4 @@ end
-- Generate minetest.conf.example and settings_translation_file.cpp
--- *** Please note ***
--- There is text in minetest.conf.example that will not be generated from
--- settingtypes.txt but must be preserved:
--- The documentation of mapgen noise parameter formats (title plus 16 lines)
--- Noise parameter 'mgv5_np_ground' in group format (13 lines)
-
---assert(loadfile(core.get_mainmenu_path()..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false))
+--assert(loadfile(core.get_builtin_path()..DIR_DELIM.."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false))
diff --git a/builtin/mainmenu/gamemgr.lua b/builtin/mainmenu/gamemgr.lua
index b6faa71d9..fd6025fcd 100644
--- a/builtin/mainmenu/gamemgr.lua
+++ b/builtin/mainmenu/gamemgr.lua
@@ -68,10 +68,10 @@ end
function gamemgr.gamelist()
local retval = ""
if #gamemgr.games > 0 then
- retval = retval .. gamemgr.games[1].name
+ retval = retval .. core.formspec_escape(gamemgr.games[1].name)
for i=2,#gamemgr.games,1 do
- retval = retval .. "," .. gamemgr.games[i].name
+ retval = retval .. "," .. core.formspec_escape(gamemgr.games[i].name)
end
end
return retval
diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua
index 7f0c1e386..7c6af7d27 100644
--- a/builtin/mainmenu/init.lua
+++ b/builtin/mainmenu/init.lua
@@ -16,9 +16,9 @@
--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"
+mt_color_blue = "#6389FF"
+mt_color_green = "#72FF63"
+mt_color_dark_green = "#25C191"
--for all other colors ask sfan5 to complete his work!
@@ -56,9 +56,8 @@ tabs.credits = dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
if PLATFORM == "Android" then
tabs.simple_main = dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
else
- tabs.singleplayer = dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
- tabs.multiplayer = dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua")
- tabs.server = dofile(menupath .. DIR_DELIM .. "tab_server.lua")
+ tabs.local_game = dofile(menupath .. DIR_DELIM .. "tab_local.lua")
+ tabs.play_online = dofile(menupath .. DIR_DELIM .. "tab_online.lua")
tabs.texturepacks = dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
end
@@ -119,25 +118,24 @@ local function init_globals()
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)
+ 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
- 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.4}, {x = 0, y = 0})
if PLATFORM == "Android" then
tv_main:add(tabs.simple_main)
tv_main:add(tabs.settings)
else
tv_main:set_autosave_tab(true)
- tv_main:add(tabs.singleplayer)
- tv_main:add(tabs.multiplayer)
- tv_main:add(tabs.server)
+ tv_main:add(tabs.local_game)
+ tv_main:add(tabs.play_online)
tv_main:add(tabs.settings)
tv_main:add(tabs.texturepacks)
end
@@ -149,7 +147,7 @@ local function init_globals()
tv_main:set_fixed_size(false)
if PLATFORM ~= "Android" then
- tv_main:set_tab(core.setting_get("maintab_LAST"))
+ tv_main:set_tab(core.settings:get("maintab_LAST"))
end
ui.set_default("maintab")
tv_main:show()
@@ -167,4 +165,3 @@ local function init_globals()
end
init_globals()
-
diff --git a/builtin/mainmenu/modmgr.lua b/builtin/mainmenu/modmgr.lua
index 2b7b371bf..dee048982 100644
--- a/builtin/mainmenu/modmgr.lua
+++ b/builtin/mainmenu/modmgr.lua
@@ -18,7 +18,7 @@
--------------------------------------------------------------------------------
function get_mods(path,retval,modpack)
local mods = core.get_dir_list(path, true)
-
+
for _, name in ipairs(mods) do
if name:sub(1, 1) ~= "." then
local prefix = path .. DIR_DELIM .. name .. DIR_DELIM
@@ -237,49 +237,37 @@ function modmgr.render_modlist(render_list)
local list = render_list:get_list()
local last_modpack = nil
-
- for i,v in ipairs(list) do
- if retval ~= "" then
- retval = retval ..","
- end
-
+ local retval = {}
+ for i, v in ipairs(list) do
local color = ""
-
if v.is_modpack then
local rawlist = render_list:get_raw_list()
+ color = mt_color_dark_green
- local all_enabled = true
- for j=1,#rawlist,1 do
+ for j = 1, #rawlist, 1 do
if rawlist[j].modpack == list[i].name and
- rawlist[j].enabled ~= true then
- all_enabled = false
- break
+ rawlist[j].enabled ~= true then
+ -- Modpack not entirely enabled so showing as grey
+ color = mt_color_grey
+ break
end
end
-
- if all_enabled == false then
- color = mt_color_grey
- else
- color = mt_color_dark_green
- end
- end
-
- if v.typ == "game_mod" then
+ elseif v.is_game_content then
color = mt_color_blue
- else
- if v.enabled then
- color = mt_color_green
- end
+ elseif v.enabled then
+ color = mt_color_green
end
- retval = retval .. color
- if v.modpack ~= nil then
- retval = retval .. " "
+ retval[#retval + 1] = color
+ if v.modpack ~= nil or v.typ == "game_mod" then
+ retval[#retval + 1] = "1"
+ else
+ retval[#retval + 1] = "0"
end
- retval = retval .. v.name
+ retval[#retval + 1] = core.formspec_escape(v.name)
end
- return retval
+ return table.concat(retval, ",")
end
--------------------------------------------------------------------------------
@@ -425,8 +413,18 @@ function modmgr.preparemodlist(data)
local gamespec = gamemgr.find_by_gameid(data.gameid)
gamemgr.get_game_mods(gamespec, game_mods)
+ if #game_mods > 0 then
+ -- Add title
+ retval[#retval + 1] = {
+ typ = "game",
+ is_game_content = true,
+ name = fgettext("Subgame Mods")
+ }
+ end
+
for i=1,#game_mods,1 do
game_mods[i].typ = "game_mod"
+ game_mods[i].is_game_content = true
retval[#retval + 1] = game_mods[i]
end
diff --git a/builtin/mainmenu/store.lua b/builtin/mainmenu/store.lua
index ad861082d..59391f8bc 100644
--- a/builtin/mainmenu/store.lua
+++ b/builtin/mainmenu/store.lua
@@ -233,14 +233,14 @@ function modstore.handle_buttons(parent, fields, name, data)
if not core.handle_async(
function(param)
- local fullurl = core.setting_get("modstore_download_url") ..
+ local fullurl = core.settings:get("modstore_download_url") ..
param.moddetails.download_url
if param.version ~= nil then
local found = false
for i=1,#param.moddetails.versions, 1 do
if param.moddetails.versions[i].date:sub(1,10) == param.version then
- fullurl = core.setting_get("modstore_download_url") ..
+ fullurl = core.settings:get("modstore_download_url") ..
param.moddetails.versions[i].download_url
found = true
end
@@ -400,7 +400,7 @@ function modstore.getscreenshot(ypos,listentry)
listentry.texturename = "in progress"
--prepare url and filename
- local fullurl = core.setting_get("modstore_download_url") ..
+ local fullurl = core.settings:get("modstore_download_url") ..
listentry.details.screenshot_url
local filename = os.tempfolder() .. "_MID_" .. listentry.id
diff --git a/builtin/mainmenu/tab_credits.lua b/builtin/mainmenu/tab_credits.lua
index c2ad19183..0774433b6 100644
--- a/builtin/mainmenu/tab_credits.lua
+++ b/builtin/mainmenu/tab_credits.lua
@@ -19,61 +19,68 @@
local core_developers = {
"Perttu Ahola (celeron55) <celeron55@gmail.com>",
- "Ryan Kwolek (kwolekr) <kwolekr@minetest.net>",
- "PilzAdam <pilzadam@minetest.net>",
"sfan5 <sfan5@live.de>",
- "kahrl <kahrl@gmx.net>",
- "sapier",
"ShadowNinja <shadowninja@minetest.net>",
"Nathanaël Courant (Nore/Ekdohibs) <nore@mesecons.net>",
"Loic Blot (nerzhul/nrz) <loic.blot@unix-experience.fr>",
- "Matt Gregory (paramat)",
- "est31 <MTest31@outlook.com>",
+ "paramat",
"Craig Robbins (Zeno) <craig.d.robbins@gmail.com>",
"Auke Kok (sofar) <sofar@foo-projects.org>",
- "Andrew Ward (rubenwardy) <rubenwardy@gmail.com>",
+ "rubenwardy <rw@rubenwardy.com>",
+ "Krock/SmallJoker <mk939@ymail.com>",
}
local active_contributors = {
- "Duane Robertson <duane@duanerobertson.com>",
- "SmallJoker <mk939@ymail.com>",
- "Lars Hofhansl <larsh@apache.org>",
- "Jeija <jeija@mesecons.net>",
- "Gregory Currie (gregorycu)",
- "Sokomine <wegwerf@anarres.dyndns.org>",
- "TeTpaAka",
- "Jean-Patrick G (kilbith) <jeanpatrick.guerrero@gmail.com>",
- "Diego Martínez (kaeza) <kaeza@users.sf.net>",
- "Dániel Juhász (juhdanad) <juhdanad@gmail.com>",
- "Rogier <rogier777@gmail.com>",
+ "red-001 <red-001@outlook.ie> [CSM & Menu fixes]",
+ "Dániel Juhász (juhdanad) <juhdanad@gmail.com> [Audiovisuals: lighting]",
+ "numberZero [Audiovisuals: meshgen]",
+ "Lars Hofhansl <larsh@apache.org> [Occulusion culling, fixes]",
+ "Jean-Patrick G (kilbith) <jeanpatrick.guerrero@gmail.com> [Audiovisuals]",
+ "Vincent Glize (Dumbeldor) <vincent.glize@live.fr> [CSM]",
+ "bigfoot547 [CSM]",
+ "Rogier <rogier777@gmail.com> [Fixes]",
+ "Wuzzy [Audiovisuals]",
+ "Shara/Ezhh [Settings]",
}
local previous_core_developers = {
"BlockMen",
- "Maciej Kasatkin (RealBadAngel) <maciej.kasatkin@o2.pl>",
+ "Maciej Kasatkin (RealBadAngel) [RIP]",
"Lisa Milne (darkrose) <lisa@ltmnet.com>",
"proller",
"Ilya Zhuravlev (xyz) <xyz@minetest.net>",
+ "PilzAdam <pilzadam@minetest.net>",
+ "est31 <MTest31@outlook.com>",
+ "kahrl <kahrl@gmx.net>",
+ "Ryan Kwolek (kwolekr) <kwolekr@minetest.net>",
+ "sapier",
}
local previous_contributors = {
- "Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>",
- "Jurgen Doser (doserj) <jurgen.doser@gmail.com>",
- "MirceaKitsune <mirceakitsune@gmail.com>",
- "dannydark <the_skeleton_of_a_child@yahoo.co.uk>",
- "0gb.us <0gb.us@0gb.us>",
- "Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>",
- "Jonathan Neuschafer <j.neuschaefer@gmx.net>",
- "Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>",
- "Břetislav Štec (t0suj4/TBC_x)",
- "Aaron Suen <warr1024@gmail.com>",
- "Constantin Wenger (SpeedProg) <constantin.wenger@googlemail.com>",
- "matttpt <matttpt@gmail.com>",
- "JacobF <queatz@gmail.com>",
- "TriBlade9 <triblade9@mail.com>",
- "Zefram <zefram@fysh.org>",
+ "Gregory Currie (gregorycu) [optimisation]",
+ "Diego Martínez (kaeza) <kaeza@users.sf.net>",
+ "T4im [Profiler]",
+ "TeTpaAka [Hand overriding, nametag colors]",
+ "HybridDog [Fixes]",
+ "Duane Robertson <duane@duanerobertson.com> [MGValleys]",
+ "neoascetic [OS X Fixes]",
+ "TriBlade9 <triblade9@mail.com> [Audiovisuals]",
+ "Jurgen Doser (doserj) <jurgen.doser@gmail.com> [Fixes]",
+ "MirceaKitsune <mirceakitsune@gmail.com> [Audiovisuals]",
+ "Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com> [Fixes]",
+ "matttpt <matttpt@gmail.com> [Fixes]",
+ "Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net> [Minetest Logo]",
+ "Jeija <jeija@mesecons.net> [HTTP, particles]",
}
+local function buildCreditList(source)
+ ret = {}
+ for i = 1, #source do
+ ret[i] = core.formspec_escape(source[i])
+ end
+ return table.concat(ret, ",,")
+end
+
return {
name = "credits",
caption = fgettext("Credits"),
@@ -85,15 +92,15 @@ return {
"label[0.5,3.5;http://minetest.net]" ..
"tablecolumns[color;text]" ..
"tableoptions[background=#00000000;highlight=#00000000;border=false]" ..
- "table[3.5,-0.25;8.5,5.8;list_credits;" ..
+ "table[3.5,-0.25;8.5,6.05;list_credits;" ..
"#FFFF00," .. fgettext("Core Developers") .. ",," ..
- table.concat(core_developers, ",,") .. ",,," ..
+ buildCreditList(core_developers) .. ",,," ..
"#FFFF00," .. fgettext("Active Contributors") .. ",," ..
- table.concat(active_contributors, ",,") .. ",,," ..
+ buildCreditList(active_contributors) .. ",,," ..
"#FFFF00," .. fgettext("Previous Core Developers") ..",," ..
- table.concat(previous_core_developers, ",,") .. ",,," ..
+ buildCreditList(previous_core_developers) .. ",,," ..
"#FFFF00," .. fgettext("Previous Contributors") .. ",," ..
- table.concat(previous_contributors, ",,") .. "," ..
+ buildCreditList(previous_contributors) .. "," ..
";1]"
end
}
diff --git a/builtin/mainmenu/tab_singleplayer.lua b/builtin/mainmenu/tab_local.lua
index 05060cbc6..3e62078ce 100644
--- a/builtin/mainmenu/tab_singleplayer.lua
+++ b/builtin/mainmenu/tab_local.lua
@@ -16,9 +16,9 @@
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
local function current_game()
- local last_game_id = core.setting_get("menu_last_game")
+ local last_game_id = core.settings:get("menu_last_game")
local game, index = gamemgr.find_by_gameid(last_game_id)
-
+
return game
end
@@ -36,10 +36,10 @@ local function singleplayer_refresh_gamebar()
if ("game_btnbar_" .. gamemgr.games[j].id == key) then
mm_texture.update("singleplayer", gamemgr.games[j])
core.set_topleft_text(gamemgr.games[j].name)
- core.setting_set("menu_last_game",gamemgr.games[j].id)
+ core.settings:set("menu_last_game",gamemgr.games[j].id)
menudata.worldlist:set_filtercriteria(gamemgr.games[j].id)
local index = filterlist.get_current_index(menudata.worldlist,
- tonumber(core.setting_get("mainmenu_last_selected_world")))
+ 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
@@ -57,24 +57,24 @@ local function singleplayer_refresh_gamebar()
local btnbar = buttonbar_create("game_button_bar",
game_buttonbar_button_handler,
- {x=-0.3,y=5.65}, "horizontal", {x=12.4,y=1.15})
+ {x=-0.3,y=5.9}, "horizontal", {x=12.4,y=1.15})
for i=1,#gamemgr.games,1 do
local btn_name = "game_btnbar_" .. gamemgr.games[i].id
-
+
local image = nil
local text = nil
local tooltip = core.formspec_escape(gamemgr.games[i].name)
-
+
if gamemgr.games[i].menuicon_path ~= nil and
gamemgr.games[i].menuicon_path ~= "" then
image = core.formspec_escape(gamemgr.games[i].menuicon_path)
else
-
+
local part1 = gamemgr.games[i].id:sub(1,5)
local part2 = gamemgr.games[i].id:sub(6,10)
local part3 = gamemgr.games[i].id:sub(11)
-
+
text = part1 .. "\n" .. part2
if part3 ~= nil and
part3 ~= "" then
@@ -89,28 +89,57 @@ local function get_formspec(tabview, name, tabdata)
local retval = ""
local index = filterlist.get_current_index(menudata.worldlist,
- tonumber(core.setting_get("mainmenu_last_selected_world"))
+ tonumber(core.settings:get("mainmenu_last_selected_world"))
)
retval = retval ..
"button[4,4.15;2.6,0.5;world_delete;".. fgettext("Delete") .. "]" ..
"button[6.5,4.15;2.8,0.5;world_create;".. fgettext("New") .. "]" ..
"button[9.2,4.15;2.55,0.5;world_configure;".. fgettext("Configure") .. "]" ..
- "button[8.5,4.95;3.25,0.5;play;".. fgettext("Play") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
- dump(core.setting_getbool("creative_mode")) .. "]"..
+ dump(core.settings:get_bool("creative_mode")) .. "]"..
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
- dump(core.setting_getbool("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;" ..
menu_render_worldlist() ..
";" .. index .. "]"
+
+ if core.settings:get_bool("enable_server") then
+ retval = retval ..
+ "button[8.5,5;3.25,0.5;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;]"
+
+ 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,5;3.25,0.5;play;".. fgettext("Play Game") .. "]"
+ end
+
return retval
end
local function main_button_handler(this, fields, name, tabdata)
- assert(name == "singleplayer")
+ assert(name == "local")
local world_doubleclick = false
@@ -125,7 +154,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
if event.type == "CHG" and selected ~= nil then
- core.setting_set("mainmenu_last_selected_world",
+ core.settings:set("mainmenu_last_selected_world",
menudata.worldlist:get_raw_index(selected))
return true
end
@@ -136,7 +165,7 @@ local function main_button_handler(this, fields, name, tabdata)
end
if fields["cb_creative_mode"] then
- core.setting_set("creative_mode", fields["cb_creative_mode"])
+ 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"])
@@ -144,27 +173,65 @@ local function main_button_handler(this, fields, name, tabdata)
end
if fields["cb_enable_damage"] then
- core.setting_set("enable_damage", fields["cb_enable_damage"])
+ 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"])
return true
end
- if fields["play"] ~= nil or
- world_doubleclick or
- fields["key_enter"] then
+ 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_textlist_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")
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
-
- if selected ~= nil and gamedata.selected_world ~= 0 then
- gamedata.singleplayer = true
- core.start()
+
+ 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("port",gamedata.port)
+ 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
+ local game, index = gamemgr.find_by_gameid(world.gameid)
+ core.settings:set("menu_last_game", game.id)
+ end
+
+ core.start()
+ else
+ gamedata.errormessage =
+ fgettext("No world created or selected!")
+ end
else
- gamedata.errormessage =
- fgettext("No world created or selected!")
+ if selected ~= nil and gamedata.selected_world ~= 0 then
+ gamedata.singleplayer = true
+ core.start()
+ else
+ gamedata.errormessage =
+ fgettext("No world created or selected!")
+ end
+ return true
end
- return true
end
if fields["world_create"] ~= nil then
@@ -192,7 +259,7 @@ local function main_button_handler(this, fields, name, tabdata)
mm_texture.update("singleplayer",current_game())
end
end
-
+
return true
end
@@ -202,7 +269,7 @@ local function main_button_handler(this, fields, name, tabdata)
local configdialog =
create_configure_world_dlg(
menudata.worldlist:get_raw_index(selected))
-
+
if (configdialog ~= nil) then
configdialog:set_parent(this)
this:hide()
@@ -210,22 +277,22 @@ local function main_button_handler(this, fields, name, tabdata)
mm_texture.update("singleplayer",current_game())
end
end
-
+
return true
end
end
local function on_change(type, old_tab, new_tab)
local buttonbar = ui.find_by_name("game_button_bar")
-
+
if ( buttonbar == nil ) then
singleplayer_refresh_gamebar()
buttonbar = ui.find_by_name("game_button_bar")
end
-
+
if (type == "ENTER") then
local game = current_game()
-
+
if game then
menudata.worldlist:set_filtercriteria(game.id)
core.set_topleft_text(game.name)
@@ -242,8 +309,8 @@ end
--------------------------------------------------------------------------------
return {
- name = "singleplayer",
- caption = fgettext("Singleplayer"),
+ name = "local",
+ caption = fgettext("Local Game"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_change
diff --git a/builtin/mainmenu/tab_mods.lua b/builtin/mainmenu/tab_mods.lua
index 4a5b6c041..9510a9e18 100644
--- a/builtin/mainmenu/tab_mods.lua
+++ b/builtin/mainmenu/tab_mods.lua
@@ -28,7 +28,8 @@ local function get_formspec(tabview, name, tabdata)
local retval =
"label[0.05,-0.25;".. fgettext("Installed Mods:") .. "]" ..
- "textlist[0,0.25;5.1,5;modlist;" ..
+ "tablecolumns[color;tree;text]" ..
+ "table[0,0.25;5.1,5;modlist;" ..
modmgr.render_modlist(modmgr.global_mods) ..
";" .. tabdata.selected_mod .. "]"
@@ -74,7 +75,7 @@ local function get_formspec(tabview, name, tabdata)
if error == nil then
local descriptiontext = descriptionfile:read("*all")
- descriptionlines = core.splittext(descriptiontext,42)
+ descriptionlines = core.wrap_text(descriptiontext, 42)
descriptionfile:close()
else
descriptionlines = {}
@@ -127,8 +128,8 @@ end
--------------------------------------------------------------------------------
local function handle_buttons(tabview, fields, tabname, tabdata)
if fields["modlist"] ~= nil then
- local event = core.explode_textlist_event(fields["modlist"])
- tabdata.selected_mod = event.index
+ local event = core.explode_table_event(fields["modlist"])
+ tabdata.selected_mod = event.row
return true
end
diff --git a/builtin/mainmenu/tab_multiplayer.lua b/builtin/mainmenu/tab_online.lua
index 00150f26d..ab23a4b7c 100644
--- a/builtin/mainmenu/tab_multiplayer.lua
+++ b/builtin/mainmenu/tab_online.lua
@@ -20,28 +20,48 @@ 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 fav_selected = nil
+ if menudata.search_result then
+ fav_selected = menudata.search_result[tabdata.fav_selected]
+ else
+ fav_selected = menudata.favorites[tabdata.fav_selected]
+ end
+
+ if not tabdata.search_for then
+ tabdata.search_for = ""
+ end
local retval =
- "label[7.75,-0.15;" .. fgettext("Address / Port") .. "]" ..
- "label[7.75,1.05;" .. fgettext("Name / Password") .. "]" ..
- "field[8,0.75;3.3,0.5;te_address;;" ..
- core.formspec_escape(core.setting_get("address")) .. "]" ..
- "field[11.15,0.75;1.4,0.5;te_port;;" ..
- core.formspec_escape(core.setting_get("remote_port")) .. "]" ..
- "button[10.1,4.9;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]" ..
- "field[8,1.95;2.95,0.5;te_name;;" ..
- core.formspec_escape(core.setting_get("name")) .. "]" ..
- "pwdfield[10.78,1.95;1.77,0.5;te_pwd;]" ..
- "box[7.73,2.35;4.3,2.28;#999999]"
+ -- Search
+ "field[0.15,0.35;6.05,0.27;te_search;;"..core.formspec_escape(tabdata.search_for).."]"..
+ "button[5.8,0.1;2,0.1;btn_mp_search;" .. fgettext("Search") .. "]" ..
+
+ -- 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")) .. "]" ..
+
+ -- 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;]" ..
+
+ -- Description Background
+ "box[7.73,2.25;4.25,2.6;#999999]"..
+
+ -- Connect
+ "button[10.1,5.15;2,0.5;btn_mp_connect;" .. fgettext("Connect") .. "]"
if tabdata.fav_selected and fav_selected then
if gamedata.fav then
- retval = retval .. "button[7.85,4.9;2.3,0.5;btn_delete_favorite;" ..
+ retval = retval .. "button[7.75,5.15;2.3,0.5;btn_delete_favorite;" ..
fgettext("Del. Favorite") .. "]"
end
if fav_selected.description then
- retval = retval .. "textarea[8.1,2.4;4.26,2.6;;" ..
+ retval = retval .. "textarea[8.1,2.3;4.23,2.9;;" ..
core.formspec_escape((gamedata.serverdescription or ""), true) .. ";]"
end
end
@@ -49,6 +69,7 @@ local function get_formspec(tabview, name, tabdata)
--favourites
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;" .. -- "/"
@@ -58,9 +79,27 @@ local function get_formspec(tabview, name, tabdata)
image_column(fgettext("PvP enabled"), "pvp") .. ",padding=0.25;" ..
"color,span=1;" ..
"text,padding=1]" ..
- "table[-0.15,-0.1;7.75,5.5;favourites;"
+ "table[-0.15,0.6;7.75,5.15;favourites;"
- if #menudata.favorites > 0 then
+ if menudata.search_result then
+ for i = 1, #menudata.search_result do
+ local favs = core.get_favorites("local")
+ local server = menudata.search_result[i]
+
+ for fav_id = 1, #favs do
+ if server.address == favs[fav_id].address and
+ server.port == favs[fav_id].port then
+ server.is_favorite = true
+ end
+ end
+
+ if i ~= 1 then
+ retval = retval .. ","
+ end
+
+ retval = retval .. render_serverlist_row(server, server.is_favorite)
+ end
+ elseif #menudata.favorites > 0 then
local favs = core.get_favorites("local")
if #favs > 0 then
for i = 1, #favs do
@@ -75,9 +114,9 @@ local function get_formspec(tabview, name, tabdata)
end
end
end
- retval = retval .. render_favorite(menudata.favorites[1], (#favs > 0))
+ retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0))
for i = 2, #menudata.favorites do
- retval = retval .. "," .. render_favorite(menudata.favorites[i], (i <= #favs))
+ retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs))
end
end
@@ -92,17 +131,19 @@ end
--------------------------------------------------------------------------------
local function main_button_handler(tabview, fields, name, tabdata)
+ local serverlist = menudata.search_result or menudata.favorites
+
if fields.te_name then
gamedata.playername = fields.te_name
- core.setting_set("name", fields.te_name)
+ core.settings:set("name", fields.te_name)
end
if fields.favourites then
local event = core.explode_table_event(fields.favourites)
- local fav = menudata.favorites[event.row]
+ local fav = serverlist[event.row]
if event.type == "DCL" then
- if event.row <= #menudata.favorites then
+ if event.row <= #serverlist then
if menudata.favorites_is_public and
not is_server_protocol_compat_or_error(
fav.proto_min, fav.proto_max) then
@@ -122,8 +163,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = fav.description
if gamedata.address and gamedata.port then
- core.setting_set("address", gamedata.address)
- core.setting_set("remote_port", gamedata.port)
+ core.settings:set("address", gamedata.address)
+ core.settings:set("remote_port", gamedata.port)
core.start()
end
end
@@ -131,7 +172,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if event.type == "CHG" then
- if event.row <= #menudata.favorites then
+ if event.row <= #serverlist then
gamedata.fav = false
local favs = core.get_favorites("local")
local address = fav.address
@@ -146,8 +187,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if address and port then
- core.setting_set("address", address)
- core.setting_set("remote_port", port)
+ core.settings:set("address", address)
+ core.settings:set("remote_port", port)
end
tabdata.fav_selected = event.row
end
@@ -157,7 +198,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
if fields.key_up or fields.key_down then
local fav_idx = core.get_table_index("favourites")
- local fav = menudata.favorites[fav_idx]
+ local fav = serverlist[fav_idx]
if fav_idx then
if fields.key_up and fav_idx > 1 then
@@ -176,10 +217,10 @@ local function main_button_handler(tabview, fields, name, tabdata)
local address = fav.address
local port = fav.port
-
+ gamedata.serverdescription = fav.description
if address and port then
- core.setting_set("address", address)
- core.setting_set("remote_port", port)
+ core.settings:set("address", address)
+ core.settings:set("remote_port", port)
end
tabdata.fav_selected = fav_idx
@@ -194,21 +235,81 @@ local function main_button_handler(tabview, fields, name, tabdata)
asyncOnlineFavourites()
tabdata.fav_selected = nil
- core.setting_set("address", "")
- core.setting_set("remote_port", "30000")
+ core.settings:set("address", "")
+ core.settings:set("remote_port", "30000")
+ return true
+ end
+
+ if fields.btn_mp_search or fields.key_enter_field == "te_search" then
+ tabdata.fav_selected = 1
+ local input = fields.te_search:lower()
+ tabdata.search_for = fields.te_search
+
+ if #menudata.favorites < 2 then
+ return true
+ end
+
+ menudata.search_result = {}
+
+ -- setup the keyword list
+ local keywords = {}
+ for word in input:gmatch("%S+") do
+ table.insert(keywords, word)
+ end
+
+ if #keywords == 0 then
+ menudata.search_result = nil
+ return true
+ end
+
+ -- Search the serverlist
+ local search_result = {}
+ for i = 1, #menudata.favorites do
+ local server = menudata.favorites[i]
+ local found = 0
+ for k = 1, #keywords do
+ local keyword = keywords[k]
+ if server.name then
+ local name = server.name:lower()
+ local _, count = name:gsub(keyword, keyword)
+ found = found + count * 4
+ end
+
+ if server.description then
+ local desc = server.description:lower()
+ local _, count = desc:gsub(keyword, keyword)
+ found = found + count * 2
+ end
+ end
+ if found > 0 then
+ local points = (#menudata.favorites - i) / 5 + found
+ server.points = points
+ table.insert(search_result, server)
+ end
+ end
+ if #search_result > 0 then
+ table.sort(search_result, function(a, b)
+ return a.points > b.points
+ end)
+ menudata.search_result = search_result
+ local first_server = search_result[1]
+ core.settings:set("address", first_server.address)
+ core.settings:set("remote_port", first_server.port)
+ end
return true
end
- if (fields.btn_mp_connect or fields.key_enter) and fields.te_address and fields.te_port then
+ if (fields.btn_mp_connect or fields.key_enter)
+ and fields.te_address ~= "" and fields.te_port then
gamedata.playername = fields.te_name
gamedata.password = fields.te_pwd
gamedata.address = fields.te_address
gamedata.port = fields.te_port
gamedata.selected_world = 0
local fav_idx = core.get_table_index("favourites")
- local fav = menudata.favorites[fav_idx]
+ local fav = serverlist[fav_idx]
- if fav_idx and fav_idx <= #menudata.favorites and
+ if fav_idx and fav_idx <= #serverlist and
fav.address == fields.te_address and
fav.port == fields.te_port then
@@ -225,8 +326,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.serverdescription = ""
end
- core.setting_set("address", fields.te_address)
- core.setting_set("remote_port", fields.te_port)
+ core.settings:set("address", fields.te_address)
+ core.settings:set("remote_port", fields.te_port)
core.start()
return true
@@ -241,8 +342,8 @@ end
--------------------------------------------------------------------------------
return {
- name = "multiplayer",
- caption = fgettext("Client"),
+ name = "online",
+ caption = fgettext("Play Online"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_change
diff --git a/builtin/mainmenu/tab_server.lua b/builtin/mainmenu/tab_server.lua
deleted file mode 100644
index 6b96825a0..000000000
--- a/builtin/mainmenu/tab_server.lua
+++ /dev/null
@@ -1,195 +0,0 @@
---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.
-
---------------------------------------------------------------------------------
-local function get_formspec(tabview, name, tabdata)
-
- local index = menudata.worldlist:get_current_index(
- tonumber(core.setting_get("mainmenu_last_selected_world"))
- )
-
- local retval =
- "button[4,4.15;2.6,0.5;world_delete;" .. fgettext("Delete") .. "]" ..
- "button[6.5,4.15;2.8,0.5;world_create;" .. fgettext("New") .. "]" ..
- "button[9.2,4.15;2.55,0.5;world_configure;" .. fgettext("Configure") .. "]" ..
- "button[8.5,4.95;3.25,0.5;start_server;" .. fgettext("Start Game") .. "]" ..
- "label[4,-0.25;" .. fgettext("Select World:") .. "]" ..
- "checkbox[0.25,0.25;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" ..
- dump(core.setting_getbool("creative_mode")) .. "]" ..
- "checkbox[0.25,0.7;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" ..
- dump(core.setting_getbool("enable_damage")) .. "]" ..
- "checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";" ..
- dump(core.setting_getbool("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.setting_get("name")) .. "]" ..
- "pwdfield[0.55,4;3.5,0.5;te_passwd;]"
-
- local bind_addr = core.setting_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.setting_get("bind_address")) .. "]" ..
- "field[2.8,5.2;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
- core.formspec_escape(core.setting_get("port")) .. "]"
- else
- retval = retval ..
- "field[0.55,5.2;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
- core.formspec_escape(core.setting_get("port")) .. "]"
- end
-
- retval = retval ..
- "textlist[4,0.25;7.5,3.7;srv_worlds;" ..
- menu_render_worldlist() ..
- ";" .. index .. "]"
-
- return retval
-end
-
---------------------------------------------------------------------------------
-local function main_button_handler(this, fields, name, tabdata)
-
- local world_doubleclick = false
-
- if fields["srv_worlds"] ~= nil then
- local event = core.explode_textlist_event(fields["srv_worlds"])
- local selected = core.get_textlist_index("srv_worlds")
-
- menu_worldmt_legacy(selected)
-
- if event.type == "DCL" then
- world_doubleclick = true
- end
- if event.type == "CHG" then
- core.setting_set("mainmenu_last_selected_world",
- menudata.worldlist:get_raw_index(core.get_textlist_index("srv_worlds")))
- return true
- end
- end
-
- if menu_handle_key_up_down(fields,"srv_worlds","mainmenu_last_selected_world") then
- return true
- end
-
- if fields["cb_creative_mode"] then
- core.setting_set("creative_mode", fields["cb_creative_mode"])
- local selected = core.get_textlist_index("srv_worlds")
- menu_worldmt(selected, "creative_mode", fields["cb_creative_mode"])
-
- return true
- end
-
- if fields["cb_enable_damage"] then
- core.setting_set("enable_damage", fields["cb_enable_damage"])
- local selected = core.get_textlist_index("srv_worlds")
- menu_worldmt(selected, "enable_damage", fields["cb_enable_damage"])
-
- return true
- end
-
- if fields["cb_server_announce"] then
- core.setting_set("server_announce", fields["cb_server_announce"])
- local selected = core.get_textlist_index("srv_worlds")
- menu_worldmt(selected, "server_announce", fields["cb_server_announce"])
-
- return true
- end
-
- if fields["start_server"] ~= nil or
- world_doubleclick or
- fields["key_enter"] then
- local selected = core.get_textlist_index("srv_worlds")
- gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
- 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.setting_set("port",gamedata.port)
- if fields["te_serveraddr"] ~= nil then
- core.setting_set("bind_address",fields["te_serveraddr"])
- end
-
- --update last game
- local world = menudata.worldlist:get_raw_element(gamedata.selected_world)
- if world then
- local game, index = gamemgr.find_by_gameid(world.gameid)
- core.setting_set("menu_last_game", game.id)
- end
-
- core.start()
- else
- gamedata.errormessage =
- fgettext("No world created or selected!")
- end
- return true
- end
-
- if fields["world_create"] ~= nil then
- local create_world_dlg = create_create_world_dlg(true)
- create_world_dlg:set_parent(this)
- create_world_dlg:show()
- this:hide()
- return true
- end
-
- if fields["world_delete"] ~= nil then
- local selected = core.get_textlist_index("srv_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)
- delete_world_dlg:show()
- this:hide()
- end
- end
-
- return true
- end
-
- if fields["world_configure"] ~= nil then
- local selected = core.get_textlist_index("srv_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)
- configdialog:show()
- this:hide()
- end
- end
- return true
- end
- return false
-end
-
---------------------------------------------------------------------------------
-return {
- name = "server",
- caption = fgettext("Server"),
- cbf_formspec = get_formspec,
- cbf_button_handler = main_button_handler,
- on_change = nil
-}
diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua
index af8df0ccb..5a8cc19b8 100644
--- a/builtin/mainmenu/tab_settings.lua
+++ b/builtin/mainmenu/tab_settings.lua
@@ -25,7 +25,8 @@ local labels = {
},
node_highlighting = {
fgettext("Node Outlining"),
- fgettext("Node Highlighting")
+ fgettext("Node Highlighting"),
+ fgettext("None")
},
filters = {
fgettext("No Filter"),
@@ -52,7 +53,7 @@ local dd_options = {
},
node_highlighting = {
table.concat(labels.node_highlighting, ","),
- {"box", "halo"}
+ {"box", "halo", "none"}
},
filters = {
table.concat(labels.filters, ","),
@@ -70,39 +71,39 @@ local dd_options = {
local getSettingIndex = {
Leaves = function()
- local style = core.setting_get("leaves_style")
+ local style = core.settings:get("leaves_style")
for idx, name in pairs(dd_options.leaves[2]) do
if style == name then return idx end
end
return 1
end,
NodeHighlighting = function()
- local style = core.setting_get("node_highlighting")
+ local style = core.settings:get("node_highlighting")
for idx, name in pairs(dd_options.node_highlighting[2]) do
if style == name then return idx end
end
return 1
end,
Filter = function()
- if core.setting_get(dd_options.filters[2][3]) == "true" then
+ if core.settings:get(dd_options.filters[2][3]) == "true" then
return 3
- elseif core.setting_get(dd_options.filters[2][3]) == "false" and
- core.setting_get(dd_options.filters[2][2]) == "true" then
+ elseif core.settings:get(dd_options.filters[2][3]) == "false" and
+ core.settings:get(dd_options.filters[2][2]) == "true" then
return 2
end
return 1
end,
Mipmap = function()
- if core.setting_get(dd_options.mipmap[2][3]) == "true" then
+ if core.settings:get(dd_options.mipmap[2][3]) == "true" then
return 3
- elseif core.setting_get(dd_options.mipmap[2][3]) == "false" and
- core.setting_get(dd_options.mipmap[2][2]) == "true" then
+ elseif core.settings:get(dd_options.mipmap[2][3]) == "false" and
+ core.settings:get(dd_options.mipmap[2][2]) == "true" then
return 2
end
return 1
end,
Antialiasing = function()
- local antialiasing_setting = core.setting_get("fsaa")
+ local antialiasing_setting = core.settings:get("fsaa")
for i = 1, #dd_options.antialiasing[2] do
if antialiasing_setting == dd_options.antialiasing[2][i] then
return i
@@ -177,20 +178,20 @@ local function formspec(tabview, name, tabdata)
local tab_string =
"box[0,0;3.5,4.5;#999999]" ..
"checkbox[0.25,0;cb_smooth_lighting;" .. fgettext("Smooth Lighting") .. ";"
- .. dump(core.setting_getbool("smooth_lighting")) .. "]" ..
+ .. dump(core.settings:get_bool("smooth_lighting")) .. "]" ..
"checkbox[0.25,0.5;cb_particles;" .. fgettext("Particles") .. ";"
- .. dump(core.setting_getbool("enable_particles")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_particles")) .. "]" ..
"checkbox[0.25,1;cb_3d_clouds;" .. fgettext("3D Clouds") .. ";"
- .. dump(core.setting_getbool("enable_3d_clouds")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_3d_clouds")) .. "]" ..
"checkbox[0.25,1.5;cb_opaque_water;" .. fgettext("Opaque Water") .. ";"
- .. dump(core.setting_getbool("opaque_water")) .. "]" ..
+ .. dump(core.settings:get_bool("opaque_water")) .. "]" ..
"checkbox[0.25,2.0;cb_connected_glass;" .. fgettext("Connected Glass") .. ";"
- .. dump(core.setting_getbool("connected_glass")) .. "]" ..
+ .. dump(core.settings:get_bool("connected_glass")) .. "]" ..
"dropdown[0.25,2.8;3.3;dd_node_highlighting;" .. dd_options.node_highlighting[1] .. ";"
.. getSettingIndex.NodeHighlighting() .. "]" ..
"dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";"
.. getSettingIndex.Leaves() .. "]" ..
- "box[3.75,0;3.75,3.45;#999999]" ..
+ "box[3.75,0;3.75,4.45;#999999]" ..
"label[3.85,0.1;" .. fgettext("Texturing:") .. "]" ..
"dropdown[3.85,0.55;3.85;dd_filters;" .. dd_options.filters[1] .. ";"
.. getSettingIndex.Filter() .. "]" ..
@@ -199,9 +200,12 @@ local function formspec(tabview, name, tabdata)
"label[3.85,2.15;" .. fgettext("Antialiasing:") .. "]" ..
"dropdown[3.85,2.6;3.85;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";"
.. getSettingIndex.Antialiasing() .. "]" ..
+ "label[3.85,3.45;" .. fgettext("Screen:") .. "]" ..
+ "checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";"
+ .. dump(core.settings:get_bool("autosave_screensize")) .. "]" ..
"box[7.75,0;4,4.4;#999999]" ..
"checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";"
- .. dump(core.setting_getbool("enable_shaders")) .. "]"
+ .. dump(core.settings:get_bool("enable_shaders")) .. "]"
if PLATFORM == "Android" then
tab_string = tab_string ..
@@ -209,38 +213,38 @@ local function formspec(tabview, name, tabdata)
.. fgettext("Reset singleplayer world") .. "]"
else
tab_string = tab_string ..
- "button[8,4.75;3.75,0.5;btn_change_keys;"
+ "button[8,4.85;3.75,0.5;btn_change_keys;"
.. fgettext("Change keys") .. "]"
end
tab_string = tab_string ..
- "button[0,4.75;3.75,0.5;btn_advanced_settings;"
+ "button[0,4.85;3.75,0.5;btn_advanced_settings;"
.. fgettext("Advanced Settings") .. "]"
- if core.setting_get("touchscreen_threshold") ~= nil then
+ if core.settings:get("touchscreen_threshold") ~= nil then
tab_string = tab_string ..
"label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" ..
"dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" ..
- ((tonumber(core.setting_get("touchscreen_threshold")) / 10) + 1) .. "]"
+ ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) .. "]"
end
- if core.setting_getbool("enable_shaders") then
+ if core.settings:get_bool("enable_shaders") then
tab_string = tab_string ..
"checkbox[8,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";"
- .. dump(core.setting_getbool("enable_bumpmapping")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" ..
"checkbox[8,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";"
- .. dump(core.setting_getbool("tone_mapping")) .. "]" ..
+ .. dump(core.settings:get_bool("tone_mapping")) .. "]" ..
"checkbox[8,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";"
- .. dump(core.setting_getbool("generate_normalmaps")) .. "]" ..
+ .. dump(core.settings:get_bool("generate_normalmaps")) .. "]" ..
"checkbox[8,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";"
- .. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" ..
"checkbox[8,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";"
- .. dump(core.setting_getbool("enable_waving_water")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_waving_water")) .. "]" ..
"checkbox[8,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";"
- .. dump(core.setting_getbool("enable_waving_leaves")) .. "]" ..
+ .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
"checkbox[8,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";"
- .. dump(core.setting_getbool("enable_waving_plants")) .. "]"
+ .. dump(core.settings:get_bool("enable_waving_plants")) .. "]"
else
tab_string = tab_string ..
"tablecolumns[color;text]" ..
@@ -271,60 +275,64 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true
end
if fields["cb_smooth_lighting"] then
- core.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
+ core.settings:set("smooth_lighting", fields["cb_smooth_lighting"])
return true
end
if fields["cb_particles"] then
- core.setting_set("enable_particles", fields["cb_particles"])
+ core.settings:set("enable_particles", fields["cb_particles"])
return true
end
if fields["cb_3d_clouds"] then
- core.setting_set("enable_3d_clouds", fields["cb_3d_clouds"])
+ core.settings:set("enable_3d_clouds", fields["cb_3d_clouds"])
return true
end
if fields["cb_opaque_water"] then
- core.setting_set("opaque_water", fields["cb_opaque_water"])
+ core.settings:set("opaque_water", fields["cb_opaque_water"])
return true
end
if fields["cb_connected_glass"] then
- core.setting_set("connected_glass", fields["cb_connected_glass"])
+ core.settings:set("connected_glass", fields["cb_connected_glass"])
+ return true
+ end
+ if fields["cb_autosave_screensize"] then
+ core.settings:set("autosave_screensize", fields["cb_autosave_screensize"])
return true
end
if fields["cb_shaders"] then
- if (core.setting_get("video_driver") == "direct3d8" or
- core.setting_get("video_driver") == "direct3d9") then
- core.setting_set("enable_shaders", "false")
+ if (core.settings:get("video_driver") == "direct3d8" or
+ core.settings:get("video_driver") == "direct3d9") then
+ core.settings:set("enable_shaders", "false")
gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
else
- core.setting_set("enable_shaders", fields["cb_shaders"])
+ core.settings:set("enable_shaders", fields["cb_shaders"])
end
return true
end
if fields["cb_bumpmapping"] then
- core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
+ core.settings:set("enable_bumpmapping", fields["cb_bumpmapping"])
return true
end
if fields["cb_tonemapping"] then
- core.setting_set("tone_mapping", fields["cb_tonemapping"])
+ core.settings:set("tone_mapping", fields["cb_tonemapping"])
return true
end
if fields["cb_generate_normalmaps"] then
- core.setting_set("generate_normalmaps", fields["cb_generate_normalmaps"])
+ core.settings:set("generate_normalmaps", fields["cb_generate_normalmaps"])
return true
end
if fields["cb_parallax"] then
- core.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
+ core.settings:set("enable_parallax_occlusion", fields["cb_parallax"])
return true
end
if fields["cb_waving_water"] then
- core.setting_set("enable_waving_water", fields["cb_waving_water"])
+ core.settings:set("enable_waving_water", fields["cb_waving_water"])
return true
end
if fields["cb_waving_leaves"] then
- core.setting_set("enable_waving_leaves", fields["cb_waving_leaves"])
+ core.settings:set("enable_waving_leaves", fields["cb_waving_leaves"])
end
if fields["cb_waving_plants"] then
- core.setting_set("enable_waving_plants", fields["cb_waving_plants"])
+ core.settings:set("enable_waving_plants", fields["cb_waving_plants"])
return true
end
if fields["btn_change_keys"] then
@@ -332,7 +340,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
return true
end
if fields["cb_touchscreen_target"] then
- core.setting_set("touchtarget", fields["cb_touchscreen_target"])
+ core.settings:set("touchtarget", fields["cb_touchscreen_target"])
return true
end
if fields["btn_reset_singleplayer"] then
@@ -345,49 +353,49 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
for i = 1, #labels.leaves do
if fields["dd_leaves_style"] == labels.leaves[i] then
- core.setting_set("leaves_style", dd_options.leaves[2][i])
+ core.settings:set("leaves_style", dd_options.leaves[2][i])
ddhandled = true
end
end
for i = 1, #labels.node_highlighting do
if fields["dd_node_highlighting"] == labels.node_highlighting[i] then
- core.setting_set("node_highlighting", dd_options.node_highlighting[2][i])
+ core.settings:set("node_highlighting", dd_options.node_highlighting[2][i])
ddhandled = true
end
end
if fields["dd_filters"] == labels.filters[1] then
- core.setting_set("bilinear_filter", "false")
- core.setting_set("trilinear_filter", "false")
+ core.settings:set("bilinear_filter", "false")
+ core.settings:set("trilinear_filter", "false")
ddhandled = true
elseif fields["dd_filters"] == labels.filters[2] then
- core.setting_set("bilinear_filter", "true")
- core.setting_set("trilinear_filter", "false")
+ core.settings:set("bilinear_filter", "true")
+ core.settings:set("trilinear_filter", "false")
ddhandled = true
elseif fields["dd_filters"] == labels.filters[3] then
- core.setting_set("bilinear_filter", "false")
- core.setting_set("trilinear_filter", "true")
+ core.settings:set("bilinear_filter", "false")
+ core.settings:set("trilinear_filter", "true")
ddhandled = true
end
if fields["dd_mipmap"] == labels.mipmap[1] then
- core.setting_set("mip_map", "false")
- core.setting_set("anisotropic_filter", "false")
+ core.settings:set("mip_map", "false")
+ core.settings:set("anisotropic_filter", "false")
ddhandled = true
elseif fields["dd_mipmap"] == labels.mipmap[2] then
- core.setting_set("mip_map", "true")
- core.setting_set("anisotropic_filter", "false")
+ core.settings:set("mip_map", "true")
+ core.settings:set("anisotropic_filter", "false")
ddhandled = true
elseif fields["dd_mipmap"] == labels.mipmap[3] then
- core.setting_set("mip_map", "true")
- core.setting_set("anisotropic_filter", "true")
+ core.settings:set("mip_map", "true")
+ core.settings:set("anisotropic_filter", "true")
ddhandled = true
end
if fields["dd_antialiasing"] then
- core.setting_set("fsaa",
+ core.settings:set("fsaa",
antialiasing_fname_to_name(fields["dd_antialiasing"]))
ddhandled = true
end
if fields["dd_touchthreshold"] then
- core.setting_set("touchscreen_threshold", fields["dd_touchthreshold"])
+ core.settings:set("touchscreen_threshold", fields["dd_touchthreshold"])
ddhandled = true
end
diff --git a/builtin/mainmenu/tab_simple_main.lua b/builtin/mainmenu/tab_simple_main.lua
index 3818f321f..de4ae1751 100644
--- a/builtin/mainmenu/tab_simple_main.lua
+++ b/builtin/mainmenu/tab_simple_main.lua
@@ -25,12 +25,12 @@ local function get_formspec(tabview, name, tabdata)
local retval =
"label[9.5,0;".. fgettext("Name / Password") .. "]" ..
"field[0.25,3.35;5.5,0.5;te_address;;" ..
- core.formspec_escape(core.setting_get("address")) .."]" ..
+ core.formspec_escape(core.settings:get("address")) .."]" ..
"field[5.75,3.35;2.25,0.5;te_port;;" ..
- core.formspec_escape(core.setting_get("remote_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.setting_get("name")) .."]" ..
+ core.formspec_escape(core.settings:get("name")) .."]" ..
"pwdfield[9.8,2;2.6,0.5;te_pwd;]"
@@ -43,6 +43,7 @@ local function get_formspec(tabview, name, tabdata)
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;" .. -- "/"
@@ -70,9 +71,9 @@ local function get_formspec(tabview, name, tabdata)
end
end
end
- retval = retval .. render_favorite(menudata.favorites[1], (#favs > 0))
+ retval = retval .. render_serverlist_row(menudata.favorites[1], (#favs > 0))
for i = 2, #menudata.favorites do
- retval = retval .. "," .. render_favorite(menudata.favorites[i], (i <= #favs))
+ retval = retval .. "," .. render_serverlist_row(menudata.favorites[i], (i <= #favs))
end
end
@@ -88,9 +89,9 @@ local function get_formspec(tabview, name, tabdata)
-- checkboxes
retval = retval ..
"checkbox[8.0,3.9;cb_creative;".. fgettext("Creative Mode") .. ";" ..
- dump(core.setting_getbool("creative_mode")) .. "]"..
+ dump(core.settings:get_bool("creative_mode")) .. "]"..
"checkbox[8.0,4.4;cb_damage;".. fgettext("Enable Damage") .. ";" ..
- dump(core.setting_getbool("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") .. "]" ..
@@ -127,8 +128,8 @@ local function main_button_handler(tabview, fields, name, tabdata)
end
if address and port then
- core.setting_set("address", address)
- core.setting_set("remote_port", port)
+ core.settings:set("address", address)
+ core.settings:set("remote_port", port)
end
tabdata.fav_selected = event.row
end
@@ -144,18 +145,18 @@ local function main_button_handler(tabview, fields, name, tabdata)
asyncOnlineFavourites()
tabdata.fav_selected = nil
- core.setting_set("address", "")
- core.setting_set("remote_port", "30000")
+ core.settings:set("address", "")
+ core.settings:set("remote_port", "30000")
return true
end
if fields.cb_creative then
- core.setting_set("creative_mode", fields.cb_creative)
+ core.settings:set("creative_mode", fields.cb_creative)
return true
end
if fields.cb_damage then
- core.setting_set("enable_damage", fields.cb_damage)
+ core.settings:set("enable_damage", fields.cb_damage)
return true
end
@@ -185,12 +186,12 @@ local function main_button_handler(tabview, fields, name, tabdata)
gamedata.selected_world = 0
- core.setting_set("address", fields.te_address)
- core.setting_set("remote_port", fields.te_port)
-
- core.start()
- return true
- end
+ 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)
diff --git a/builtin/mainmenu/tab_texturepacks.lua b/builtin/mainmenu/tab_texturepacks.lua
index 4638beaa1..2957481cf 100644
--- a/builtin/mainmenu/tab_texturepacks.lua
+++ b/builtin/mainmenu/tab_texturepacks.lua
@@ -54,9 +54,9 @@ local function get_formspec(tabview, name, tabdata)
local retval = "label[4,-0.25;" .. fgettext("Select texture pack:") .. "]" ..
"textlist[4,0.25;7.5,5.0;TPs;"
- local current_texture_path = core.setting_get("texture_path")
+ local current_texture_path = core.settings:get("texture_path")
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
- local index = tonumber(core.setting_get("mainmenu_last_selected_TP"))
+ local index = tonumber(core.settings:get("mainmenu_last_selected_TP"))
if not index then index = 1 end
@@ -106,7 +106,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
local event = core.explode_textlist_event(fields["TPs"])
if event.type == "CHG" or event.type == "DCL" then
local index = core.get_textlist_index("TPs")
- core.setting_set("mainmenu_last_selected_TP", index)
+ core.settings:set("mainmenu_last_selected_TP", index)
local list = filter_texture_pack_list(core.get_dir_list(core.get_texturepath(), true))
local current_index = core.get_textlist_index("TPs")
if current_index and #list >= current_index then
@@ -114,7 +114,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
if list[current_index] == fgettext("None") then
new_path = ""
end
- core.setting_set("texture_path", new_path)
+ core.settings:set("texture_path", new_path)
end
end
return true
diff --git a/builtin/mainmenu/textures.lua b/builtin/mainmenu/textures.lua
index dadbb093e..9ba4ade7e 100644
--- a/builtin/mainmenu/textures.lua
+++ b/builtin/mainmenu/textures.lua
@@ -24,7 +24,7 @@ function mm_texture.init()
DIR_DELIM .. "pack" .. DIR_DELIM
mm_texture.basetexturedir = mm_texture.defaulttexturedir
- mm_texture.texturepack = core.setting_get("texture_path")
+ mm_texture.texturepack = core.settings:get("texture_path")
mm_texture.gameid = nil
end
@@ -61,7 +61,7 @@ function mm_texture.reset()
mm_texture.set_generic("header")
if not have_bg then
- if core.setting_getbool("menu_clouds") then
+ if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()
@@ -88,7 +88,7 @@ function mm_texture.update_game(gamedetails)
if not have_bg then
- if core.setting_getbool("menu_clouds") then
+ if core.settings:get_bool("menu_clouds") then
core.set_clouds(true)
else
mm_texture.set_dirt_bg()