Skip to content

Commit 4ccaa6d

Browse files
sapiersapier
sapier
authored and
sapier
committedDec 11, 2013
Implement search tab and version picker
1 parent dfd1f87 commit 4ccaa6d

8 files changed

+463
-187
lines changed
 

‎builtin/filterlist.lua

+17-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717

1818
--------------------------------------------------------------------------------
1919
-- Generic implementation of a filter/sortable list --
20+
-- Usage: --
21+
-- Filterlist needs to be initialized on creation. To achieve this you need to --
22+
-- pass following functions: --
23+
-- raw_fct() (mandatory): --
24+
-- function returning a table containing the elements to be filtered --
25+
-- compare_fct(element1,element2) (mandatory): --
26+
-- function returning true/false if element1 is same element as element2 --
27+
-- uid_match_fct(element1,uid) (optional) --
28+
-- function telling if uid is attached to element1 --
29+
-- filter_fct(element,filtercriteria) (optional) --
30+
-- function returning true/false if filtercriteria met to element --
31+
-- fetch_param (optional) --
32+
-- parameter passed to raw_fct to aquire correct raw data --
33+
-- --
2034
--------------------------------------------------------------------------------
2135
filterlist = {}
2236

@@ -157,7 +171,7 @@ function filterlist.process(this)
157171
this.m_processed_list = {}
158172

159173
for k,v in pairs(this.m_raw_list) do
160-
if this.m_filtercriteria == nil or
174+
if this.m_filtercriteria == nil or
161175
this.m_filter_fct(v,this.m_filtercriteria) then
162176
table.insert(this.m_processed_list,v)
163177
end
@@ -167,7 +181,7 @@ function filterlist.process(this)
167181
return
168182
end
169183

170-
if this.m_sort_list[this.m_sortmode] ~= nil and
184+
if this.m_sort_list[this.m_sortmode] ~= nil and
171185
type(this.m_sort_list[this.m_sortmode]) == "function" then
172186

173187
this.m_sort_list[this.m_sortmode](this)
@@ -237,7 +251,7 @@ function compare_worlds(world1,world2)
237251
end
238252

239253
--------------------------------------------------------------------------------
240-
function sort_worlds_alphabetic(this)
254+
function sort_worlds_alphabetic(this)
241255

242256
table.sort(this.m_processed_list, function(a, b)
243257
--fixes issue #857 (crash due to sorting nil in worldlist)

‎builtin/mainmenu.lua

+27-3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,30 @@ os.tempfolder = function()
119119

120120
end
121121

122+
--------------------------------------------------------------------------------
123+
function text2textlist(xpos,ypos,width,height,tl_name,textlen,text,transparency)
124+
local textlines = engine.splittext(text,textlen)
125+
126+
local retval = "textlist[" .. xpos .. "," .. ypos .. ";"
127+
.. width .. "," .. height .. ";"
128+
.. tl_name .. ";"
129+
130+
for i=1, #textlines, 1 do
131+
textlines[i] = textlines[i]:gsub("\r","")
132+
retval = retval .. engine.formspec_escape(textlines[i]) .. ","
133+
end
134+
135+
retval = retval .. ";0;"
136+
137+
if transparency then
138+
retval = retval .. "true"
139+
end
140+
141+
retval = retval .. "]"
142+
143+
return retval
144+
end
145+
122146
--------------------------------------------------------------------------------
123147
function init_globals()
124148
--init gamedata
@@ -939,9 +963,9 @@ end
939963
function tabbuilder.tab_settings()
940964
tab_string =
941965
"vertlabel[0,0;" .. fgettext("SETTINGS") .. "]" ..
942-
"checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
966+
"checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
943967
.. dump(engine.setting_getbool("new_style_leaves")) .. "]"..
944-
"checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
968+
"checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
945969
.. ";".. dump(engine.setting_getbool("smooth_lighting")) .. "]"..
946970
"checkbox[1,1;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
947971
.. dump(engine.setting_getbool("enable_3d_clouds")) .. "]"..
@@ -979,7 +1003,7 @@ if engine.setting_getbool("enable_shaders") then
9791003
.. dump(engine.setting_getbool("enable_waving_leaves")) .. "]"..
9801004
"checkbox[8,2.5;cb_waving_plants;".. fgettext("Waving Plants") .. ";"
9811005
.. dump(engine.setting_getbool("enable_waving_plants")) .. "]"
982-
else
1006+
else
9831007
tab_string = tab_string ..
9841008
"textlist[8.33,0.7;4,1;;#888888" .. fgettext("Bumpmapping") .. ";0;true]" ..
9851009
"textlist[8.33,1.2;4,1;;#888888" .. fgettext("Parallax Occlusion") .. ";0;true]" ..

‎builtin/modmgr.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ function modmgr.extract(modfile)
5656
if tempfolder ~= nil and
5757
tempfolder ~= "" then
5858
engine.create_dir(tempfolder)
59-
engine.extract_zip(modfile.name,tempfolder)
60-
return tempfolder
59+
if engine.extract_zip(modfile.name,tempfolder) then
60+
return tempfolder
61+
end
6162
end
6263
end
64+
return nil
6365
end
6466

6567
-------------------------------------------------------------------------------
@@ -615,7 +617,7 @@ function modmgr.installmod(modfilename,basename)
615617

616618
if modpath == nil then
617619
gamedata.errormessage = fgettext("Install Mod: file: \"$1\"", modfile.name) ..
618-
fgettext("\nInstall Mod: unsupported filetype \"$1\"", modfile.type)
620+
fgettext("\nInstall Mod: unsupported filetype \"$1\" or broken archive", modfile.type)
619621
return
620622
end
621623

0 commit comments

Comments
 (0)
Please sign in to comment.