Submit Your Own Code

PSP Lua CodeBase : Browse Files

Description:
Much better filebrowser, I rewrote it so it's much more efficient and has a much better scrolling system. It'll also view images and run other lua scripts.

-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Browse Files
-- SUBMITTED BY: TacticalPenguin

System.currentDirectory("ms0:/")
white = Color.new(255,255,255)
red = Color.new(255,0,0)
fbrowser = {s = 1, fl = System.listDirectory("ms0:/"),ls = 1, sp = 10}

fbrowser.nf = table.getn(fbrowser.fl)
oldpad = Controls.read()

function runfbrowser()

for i = ((fbrowser.ls-1)*fbrowser.sp)+1, fbrowser.ls*fbrowser.sp do
if fbrowser.nf >= i then
screen:print(0,((i-((fbrowser.ls-1)*fbrowser.sp))*10)-10,
fbrowser.fl[i].name,white)
elseif fbrowser.nf < i then break end
end

screen:print(0,((fbrowser.s-((fbrowser.ls-1)*fbrowser.sp))*10)-10,
fbrowser.fl[fbrowser.s].name,red)

if pad:down() and not oldpad:down() then fbrowser.s = fbrowser.s + 1 end
if pad:up() and not oldpad:up() then fbrowser.s = fbrowser.s - 1 end

if fbrowser.s > fbrowser.nf then fbrowser.s = fbrowser.nf elseif fbrowser.s < 1 then fbrowser.s = 1 end
if fbrowser.s > fbrowser.sp*fbrowser.ls then fbrowser.ls = fbrowser.ls + 1
elseif fbrowser.s < ((fbrowser.ls-1) * fbrowser.sp)+1 then fbrowser.ls = fbrowser.ls - 1 fbrowser.s = (fbrowser.ls)*fbrowser.sp end

if pad:cross() and not oldpad:cross() then
if not fbrowser.fl[fbrowser.s].directory then
if string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == (".png" or ".jpg") then
img = Image.load(fbrowser.fl[fbrowser.s].name)
screen:clear()
screen:blit(240-img:width()/2,136-img:height()/2,img)
screen.flip()
viewingimg = true
while viewingimg do
if Controls.read():circle() then viewingimg = false img = nil end
screen.waitVblankStart()
end
elseif string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == ".lua" then
dofile(fbrowser.fl[fbrowser.s].name)
end
elseif fbrowser.fl[fbrowser.s].directory then
System.currentDirectory(fbrowser.fl[fbrowser.s].name)
fbrowser.s = 1
fbrowser.fl=System.listDirectory()
fbrowser.nf=table.getn(fbrowser.fl)
fbrowser.ls = 1
end

elseif pad:triangle() and not oldpad:triangle() then
if System.currentDirectory ~= "ms0:/" then
System.currentDirectory("./..")
fbrowser.s = 1
fbrowser.fl=System.listDirectory()
fbrowser.nf=table.getn(fbrowser.fl)
fbrowser.ls = 1
end
end
end

while true do
pad = Controls.read()
screen:clear()
runfbrowser()
screen.waitVblankStart()
screen.flip()
oldpad = pad
if pad:start() then break end
end

Back to CodeBase
 

Please welcome jramada, our newest member.

Who's Online: 7 Guests, 3 Users
dan369, osgeld, fret669

Total Members: 555
Total Posts: 13057
Total Topics: 1480
Total Categories: 8
Total Boards: 35

Recent Posts:

Re: Lua Loader? by osgeld
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Re: Lua Loader? by acer5050
Re: Lua Loader? by bumuckl
Lua Loader? by acer5050
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by bumuckl
Re: PGELua Help - need term for a special rotation fix (mathematical issue) by tacticalpenguin


Copyright © 2006-2007 www.EvilMana.com All rights reserved.
EvilMana Logo by emcp and Charlie