Fix builtin formatting
parent
56e6465de2
commit
399f707877
|
@ -14,4 +14,3 @@ function core.job_processor(serialized_func, serialized_param)
|
|||
|
||||
return retval or core.serialize(nil)
|
||||
end
|
||||
|
||||
|
|
|
@ -38,4 +38,4 @@ function core.after(after, func, ...)
|
|||
mod_origin = core.get_last_run_mod()
|
||||
}
|
||||
time_next = math.min(time_next, expire)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
core.async_jobs = {}
|
||||
|
||||
local function handle_job(jobid, serialized_retval)
|
||||
|
@ -37,4 +36,3 @@ function core.handle_async(func, parameter, callback)
|
|||
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
|
||||
assert((raw_fct ~= nil) and (type(raw_fct) == "function"))
|
||||
assert((compare_fct ~= nil) and (type(compare_fct) == "function"))
|
||||
|
||||
|
||||
local self = {}
|
||||
|
||||
|
||||
self.m_raw_list_fct = raw_fct
|
||||
self.m_compare_fct = compare_fct
|
||||
self.m_filter_fct = filter_fct
|
||||
self.m_uid_match_fct = uid_match_fct
|
||||
|
||||
|
||||
self.m_filtercriteria = nil
|
||||
self.m_fetch_param = fetch_param
|
||||
|
||||
|
||||
self.m_sortmode = "none"
|
||||
self.m_sort_list = {}
|
||||
|
||||
|
@ -79,7 +79,7 @@ function filterlist.create(raw_fct,compare_fct,uid_match_fct,filter_fct,fetch_pa
|
|||
self.refresh = filterlist.refresh
|
||||
|
||||
filterlist.process(self)
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -128,49 +128,49 @@ function filterlist.get_raw_element(self,idx)
|
|||
if type(idx) ~= "number" then
|
||||
idx = tonumber(idx)
|
||||
end
|
||||
|
||||
|
||||
if idx ~= nil and idx > 0 and idx <= #self.m_raw_list then
|
||||
return self.m_raw_list[idx]
|
||||
end
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_raw_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_processed_list then
|
||||
local entry = self.m_processed_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_raw_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function filterlist.get_current_index(self,listindex)
|
||||
assert(self.m_processed_list ~= nil)
|
||||
|
||||
|
||||
if listindex ~= nil and listindex > 0 and
|
||||
listindex <= #self.m_raw_list then
|
||||
local entry = self.m_raw_list[listindex]
|
||||
|
||||
|
||||
for i,v in ipairs(self.m_processed_list) do
|
||||
|
||||
|
||||
if self.m_compare_fct(v,entry) then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
|
@ -183,23 +183,23 @@ function filterlist.process(self)
|
|||
self.m_processed_list = self.m_raw_list
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
self.m_processed_list = {}
|
||||
|
||||
|
||||
for k,v in pairs(self.m_raw_list) do
|
||||
if self.m_filtercriteria == nil or
|
||||
self.m_filter_fct(v,self.m_filtercriteria) then
|
||||
self.m_processed_list[#self.m_processed_list + 1] = v
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if self.m_sortmode == "none" then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if self.m_sort_list[self.m_sortmode] ~= nil and
|
||||
type(self.m_sort_list[self.m_sortmode]) == "function" then
|
||||
|
||||
|
||||
self.m_sort_list[self.m_sortmode](self)
|
||||
end
|
||||
end
|
||||
|
@ -209,7 +209,7 @@ function filterlist.size(self)
|
|||
if self.m_processed_list == nil then
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
return #self.m_processed_list
|
||||
end
|
||||
|
||||
|
@ -233,8 +233,8 @@ function filterlist.raw_index_by_uid(self, uid)
|
|||
elementidx = i
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- If there are more elements than one with same name uid can't decide which
|
||||
-- one is meant. self shouldn't be possible but just for sure.
|
||||
if elementcount > 1 then
|
||||
|
@ -254,11 +254,11 @@ function compare_worlds(world1,world2)
|
|||
if world1.path ~= world2.path then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.name ~= world2.name then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
if world1.gameid ~= world2.gameid then
|
||||
return false
|
||||
end
|
||||
|
@ -289,7 +289,7 @@ function sort_mod_list(self)
|
|||
table.sort(self.m_processed_list, function(a, b)
|
||||
-- Show game mods at bottom
|
||||
if a.typ ~= b.typ then
|
||||
if b.typ == "game" then
|
||||
if b.typ == "game" then
|
||||
return a.typ ~= "game_mod"
|
||||
end
|
||||
return b.typ == "game_mod"
|
||||
|
@ -308,7 +308,7 @@ function sort_mod_list(self)
|
|||
elseif b.name == a.modpack then
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local name_a = a.modpack or a.name
|
||||
local name_b = b.modpack or b.name
|
||||
if name_a:lower() == name_b:lower() then
|
||||
|
|
|
@ -218,4 +218,3 @@ test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"}
|
|||
test_out = core.deserialize(core.serialize(test_in))
|
||||
assert(test_in.escape_chars == test_out.escape_chars)
|
||||
assert(test_in.non_european == test_out.non_european)
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
-- Always warn when creating a global variable, even outside of a function.
|
||||
-- This ignores mod namespaces (variables with the same name as the current mod).
|
||||
local WARN_INIT = false
|
||||
|
@ -54,4 +53,3 @@ function meta:__index(name)
|
|||
end
|
||||
|
||||
setmetatable(_G, meta)
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
vector = {}
|
||||
|
||||
function vector.new(a, b, c)
|
||||
|
|
|
@ -17,4 +17,3 @@ function core.create_detached_inventory(name, callbacks, player_name)
|
|||
core.detached_inventories[name] = stuff
|
||||
return core.create_detached_inventory_raw(name, player_name)
|
||||
end
|
||||
|
||||
|
|
|
@ -65,14 +65,14 @@ local function check_modname_prefix(name)
|
|||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"\"" .. expected_prefix .. "\" or \":\" prefix required")
|
||||
end
|
||||
|
||||
|
||||
-- Enforce that the name only contains letters, numbers and underscores.
|
||||
local subname = name:sub(#expected_prefix+1)
|
||||
if subname:find("[^%w_]") then
|
||||
error("Name " .. name .. " does not follow naming conventions: " ..
|
||||
"contains unallowed characters")
|
||||
end
|
||||
|
||||
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
@ -664,4 +664,3 @@ end)
|
|||
--
|
||||
|
||||
core.register_on_mapgen_init = function(func) func(core.get_mapgen_params()) end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ local function create_world_formspec(dialogdata)
|
|||
local retval =
|
||||
"size[11.5,3.75,false]" ..
|
||||
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"bg_dialog.png") .. ";true]" ..
|
||||
"bg_dialog.png") .. ";true]" ..
|
||||
"label[1.5,0;" .. fgettext("World name:") .. "]"..
|
||||
"field[4.5,0.4;6,0.5;te_world_name;;]" ..
|
||||
|
||||
|
@ -69,20 +69,20 @@ end
|
|||
local function create_world_buttonhandler(this, fields)
|
||||
|
||||
if fields["world_create_cancel"] then
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
if fields["world_create_confirm"] or
|
||||
fields["key_enter"] then
|
||||
|
||||
local worldname = fields["te_world_name"]
|
||||
local gameindex
|
||||
for i,item in ipairs(gamemgr.games) do
|
||||
if item.name == fields["games"] then
|
||||
gameindex = i
|
||||
end
|
||||
end
|
||||
for i, item in ipairs(gamemgr.games) do
|
||||
if item.name == fields["games"] then
|
||||
gameindex = i
|
||||
end
|
||||
end
|
||||
|
||||
if gameindex ~= nil and
|
||||
worldname ~= "" then
|
||||
|
@ -121,11 +121,9 @@ local function create_world_buttonhandler(this, fields)
|
|||
return true
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function create_create_world_dlg(update_worldlistfilter)
|
||||
local retval = dialog_create("sp_create_world",
|
||||
create_world_formspec,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
local function delete_mod_formspec(dialogdata)
|
||||
|
||||
|
||||
dialogdata.mod = modmgr.global_mods:get_list()[dialogdata.selected]
|
||||
|
||||
local retval =
|
||||
|
@ -27,7 +27,7 @@ local function delete_mod_formspec(dialogdata)
|
|||
fgettext("Are you sure you want to delete \"$1\"?", dialogdata.mod.name) .. "]"..
|
||||
"button[3.25,3.5;2.5,0.5;dlg_delete_mod_confirm;" .. fgettext("Delete") .. "]" ..
|
||||
"button[5.75,3.5;2.5,0.5;dlg_delete_mod_cancel;" .. fgettext("Cancel") .. "]"
|
||||
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
|
@ -48,7 +48,7 @@ local function delete_mod_buttonhandler(this, fields)
|
|||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
if fields["dlg_delete_mod_cancel"] then
|
||||
this:delete()
|
||||
return true
|
||||
|
|
|
@ -20,7 +20,7 @@ local function delete_world_formspec(dialogdata)
|
|||
local retval =
|
||||
"size[11.5,3.75,false]" ..
|
||||
"background[0,0;11.5,3;" .. core.formspec_escape(defaulttexturedir ..
|
||||
"bg_dialog.png") .. ";true]" ..
|
||||
"bg_dialog.png") .. ";true]" ..
|
||||
"label[5,1.4;" .. fgettext("Delete World") .. "]" ..
|
||||
"label[5,1.8;" .. fgettext("\"$1\"?", dialogdata.delete_name) .. "]" ..
|
||||
"button[3.25,3.4;2.5,0.5;world_delete_confirm;" .. fgettext("Delete") .. "]" ..
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
local function rename_modpack_formspec(dialogdata)
|
||||
|
||||
|
||||
dialogdata.mod = modmgr.global_mods:get_list()[dialogdata.selected]
|
||||
|
||||
local retval =
|
||||
|
@ -29,7 +29,7 @@ local function rename_modpack_formspec(dialogdata)
|
|||
fgettext("Accept") .. "]" ..
|
||||
"button[5.75,3.5;2.5,0.5;dlg_rename_modpack_cancel;"..
|
||||
fgettext("Cancel") .. "]"
|
||||
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
|
@ -42,11 +42,11 @@ local function rename_modpack_buttonhandler(this, fields)
|
|||
modmgr.refresh_globals()
|
||||
modmgr.selected_mod = modmgr.global_mods:get_current_index(
|
||||
modmgr.global_mods:raw_index_by_uid(fields["te_modpack_name"]))
|
||||
|
||||
|
||||
this:delete()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
if fields["dlg_rename_modpack_cancel"] then
|
||||
this:delete()
|
||||
return true
|
||||
|
|
|
@ -96,4 +96,3 @@ file:close()
|
|||
file = assert(io.open("src/settings_translation_file.cpp", "w"))
|
||||
file:write(create_translation_file())
|
||||
file:close()
|
||||
|
||||
|
|
|
@ -611,4 +611,3 @@ function modstore.activate_search_tab(type, old_tab, new_tab)
|
|||
data = filterlist.get_list(modstore.searchlist),
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
local function get_formspec(tabview, name, tabdata)
|
||||
|
||||
|
||||
local index = menudata.worldlist:get_current_index(
|
||||
tonumber(core.setting_get("mainmenu_last_selected_world"))
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ local function get_formspec(tabview, name, tabdata)
|
|||
"checkbox[0.25,1.15;cb_server_announce;" .. fgettext("Public") .. ";"
|
||||
return retval
|
||||
end
|
||||
|
||||
|
||||
local bind_addr = core.setting_get("bind_address")
|
||||
if bind_addr ~= nil and bind_addr ~= "" then
|
||||
retval = retval ..
|
||||
|
@ -56,12 +56,12 @@ local function get_formspec(tabview, name, tabdata)
|
|||
"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 .. ";true]"
|
||||
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
|
@ -136,7 +136,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
local game, index = gamemgr.find_by_gameid(world.gameid)
|
||||
core.settings:set("menu_last_game", game.id)
|
||||
end
|
||||
|
||||
|
||||
core.start()
|
||||
else
|
||||
gamedata.errormessage =
|
||||
|
@ -168,7 +168,7 @@ local function main_button_handler(this, fields, name, tabdata)
|
|||
this:hide()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -178,7 +178,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)
|
||||
configdialog:show()
|
||||
|
|
|
@ -22,9 +22,9 @@ mm_texture = {}
|
|||
function mm_texture.init()
|
||||
mm_texture.defaulttexturedir = core.get_texturepath() .. DIR_DELIM .. "base" .. DIR_DELIM
|
||||
mm_texture.basetexturedir = mm_texture.defaulttexturedir
|
||||
|
||||
|
||||
mm_texture.texturepack = core.settings:get("texture_path")
|
||||
|
||||
|
||||
mm_texture.gameid = nil
|
||||
end
|
||||
|
||||
|
@ -38,27 +38,27 @@ function mm_texture.update(tab,gamedetails)
|
|||
if gamedetails == nil then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
mm_texture.update_game(gamedetails)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function mm_texture.reset()
|
||||
mm_texture.gameid = nil
|
||||
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")
|
||||
core.set_clouds(false)
|
||||
|
||||
|
||||
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)
|
||||
|
@ -73,30 +73,30 @@ function mm_texture.update_game(gamedetails)
|
|||
if mm_texture.gameid == gamedetails.id then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local have_bg = false
|
||||
local have_overlay = mm_texture.set_game("overlay",gamedetails)
|
||||
|
||||
|
||||
if not have_overlay then
|
||||
have_bg = mm_texture.set_game("background",gamedetails)
|
||||
end
|
||||
|
||||
|
||||
mm_texture.clear("header")
|
||||
mm_texture.clear("footer")
|
||||
core.set_clouds(false)
|
||||
|
||||
|
||||
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_game("footer",gamedetails)
|
||||
mm_texture.set_game("header",gamedetails)
|
||||
|
||||
|
||||
mm_texture.gameid = gamedetails.id
|
||||
end
|
||||
|
||||
|
@ -115,7 +115,7 @@ function mm_texture.set_generic(identifier)
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if mm_texture.defaulttexturedir ~= nil then
|
||||
local path = mm_texture.defaulttexturedir .. DIR_DELIM .."menu_" ..
|
||||
identifier .. ".png"
|
||||
|
@ -123,13 +123,13 @@ function mm_texture.set_generic(identifier)
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
function mm_texture.set_game(identifier, gamedetails)
|
||||
|
||||
|
||||
if gamedetails == nil then
|
||||
return false
|
||||
end
|
||||
|
@ -141,7 +141,7 @@ function mm_texture.set_game(identifier, gamedetails)
|
|||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Find out how many randomized textures the subgame provides
|
||||
local n = 0
|
||||
local filename
|
||||
|
@ -166,7 +166,7 @@ function mm_texture.set_game(identifier, gamedetails)
|
|||
if core.set_background(identifier, path) then
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue