Skip to content

Commit

Permalink
Implement search tab and version picker
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and sapier committed Dec 11, 2013
1 parent dfd1f87 commit 4ccaa6d
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 187 deletions.
20 changes: 17 additions & 3 deletions builtin/filterlist.lua
Expand Up @@ -17,6 +17,20 @@

--------------------------------------------------------------------------------
-- Generic implementation of a filter/sortable list --
-- Usage: --
-- Filterlist needs to be initialized on creation. To achieve this you need to --
-- pass following functions: --
-- raw_fct() (mandatory): --
-- function returning a table containing the elements to be filtered --
-- compare_fct(element1,element2) (mandatory): --
-- function returning true/false if element1 is same element as element2 --
-- uid_match_fct(element1,uid) (optional) --
-- function telling if uid is attached to element1 --
-- filter_fct(element,filtercriteria) (optional) --
-- function returning true/false if filtercriteria met to element --
-- fetch_param (optional) --
-- parameter passed to raw_fct to aquire correct raw data --
-- --
--------------------------------------------------------------------------------
filterlist = {}

Expand Down Expand Up @@ -157,7 +171,7 @@ function filterlist.process(this)
this.m_processed_list = {}

for k,v in pairs(this.m_raw_list) do
if this.m_filtercriteria == nil or
if this.m_filtercriteria == nil or
this.m_filter_fct(v,this.m_filtercriteria) then
table.insert(this.m_processed_list,v)
end
Expand All @@ -167,7 +181,7 @@ function filterlist.process(this)
return
end

if this.m_sort_list[this.m_sortmode] ~= nil and
if this.m_sort_list[this.m_sortmode] ~= nil and
type(this.m_sort_list[this.m_sortmode]) == "function" then

this.m_sort_list[this.m_sortmode](this)
Expand Down Expand Up @@ -237,7 +251,7 @@ function compare_worlds(world1,world2)
end

--------------------------------------------------------------------------------
function sort_worlds_alphabetic(this)
function sort_worlds_alphabetic(this)

table.sort(this.m_processed_list, function(a, b)
--fixes issue #857 (crash due to sorting nil in worldlist)
Expand Down
30 changes: 27 additions & 3 deletions builtin/mainmenu.lua
Expand Up @@ -119,6 +119,30 @@ os.tempfolder = function()

end

--------------------------------------------------------------------------------
function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
local textlines = engine.splittext(text,textlen)

local retval = "textlist[" .. xpos .. "," .. ypos .. ";"
.. width .. "," .. height .. ";"
.. tl_name .. ";"

for i=1, #textlines, 1 do
textlines[i] = textlines[i]:gsub("\r","")
retval = retval .. engine.formspec_escape(textlines[i]) .. ","
end

retval = retval .. ";0;"

if transparency then
retval = retval .. "true"
end

retval = retval .. "]"

return retval
end

--------------------------------------------------------------------------------
function init_globals()
--init gamedata
Expand Down Expand Up @@ -939,9 +963,9 @@ end
function tabbuilder.tab_settings()
tab_string =
"vertlabel[0,0;" .. fgettext("SETTINGS") .. "]" ..
"checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
"checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
.. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
"checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
"checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
.. ";".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
"checkbox[1,1;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
.. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
Expand Down Expand Up @@ -979,7 +1003,7 @@ if engine.setting_getbool("enable_shaders") then
.. dump(engine.setting_getbool("enable_waving_leaves")) .. "]"..
"checkbox[8,2.5;cb_waving_plants;".. fgettext("Waving Plants") .. ";"
.. dump(engine.setting_getbool("enable_waving_plants")) .. "]"
else
else
tab_string = tab_string ..
"textlist[8.33,0.7;4,1;;#888888" .. fgettext("Bumpmapping") .. ";0;true]" ..
"textlist[8.33,1.2;4,1;;#888888" .. fgettext("Parallax Occlusion") .. ";0;true]" ..
Expand Down
8 changes: 5 additions & 3 deletions builtin/modmgr.lua
Expand Up @@ -56,10 +56,12 @@ function modmgr.extract(modfile)
if tempfolder ~= nil and
tempfolder ~= "" then
engine.create_dir(tempfolder)
engine.extract_zip(modfile.name,tempfolder)
return tempfolder
if engine.extract_zip(modfile.name,tempfolder) then
return tempfolder
end
end
end
return nil
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -615,7 +617,7 @@ function modmgr.installmod(modfilename,basename)

if modpath == nil then
gamedata.errormessage = fgettext("Install Mod: file: \"$1\"", modfile.name) ..
fgettext("\nInstall Mod: unsupported filetype \"$1\"", modfile.type)
fgettext("\nInstall Mod: unsupported filetype \"$1\" or broken archive", modfile.type)
return
end

Expand Down

0 comments on commit 4ccaa6d

Please sign in to comment.