Skip to content
Permalink
Browse files

Implement search tab and version picker

  • Loading branch information...
sapier sapier
sapier authored and sapier committed Dec 11, 2013
1 parent dfd1f87 commit 4ccaa6d0af852d0aada01f341a61290a3760cffa
Showing with 463 additions and 187 deletions.
  1. +17 −3 builtin/filterlist.lua
  2. +27 −3 builtin/mainmenu.lua
  3. +5 −3 builtin/modmgr.lua
  4. +378 −168 builtin/modstore.lua
  5. +1 −1 src/convert_json.cpp
  6. +1 −1 src/guiEngine.cpp
  7. +10 −7 src/guiFormSpecMenu.cpp
  8. +24 −1 src/script/lua_api/l_mainmenu.cpp
@@ -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 = {}

@@ -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
@@ -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)
@@ -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)
@@ -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
@@ -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")) .. "]"..
@@ -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]" ..
@@ -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

-------------------------------------------------------------------------------
@@ -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

0 comments on commit 4ccaa6d

Please sign in to comment.
You can’t perform that action at this time.