VERSIÓ 1.3.15
- [NEW] mouse.dblclick() - [FIX] de vegades no pillava be la rodeta del ratolí - [NEW] sys.dir() torna el contingut del directori primer les carpetes, i tot ordenat alfabèticament - [WIP] Treballant en ferramentes
This commit is contained in:
5
tools/fonted/data/game.ini
Normal file
5
tools/fonted/data/game.ini
Normal file
@@ -0,0 +1,5 @@
|
||||
title=NEW MINI PROJECT
|
||||
config=newminiproject
|
||||
width=320
|
||||
height=240
|
||||
zoom=2
|
||||
138
tools/fonted/data/main.lua
Normal file
138
tools/fonted/data/main.lua
Normal file
@@ -0,0 +1,138 @@
|
||||
function loadDir(path)
|
||||
files = sys.dir(path)
|
||||
if #files > 0 then
|
||||
dir = files[1].name:match("(.+)/[^/]+$")
|
||||
else
|
||||
dir = path
|
||||
end
|
||||
table.insert(files, 1, { dir=true, name=".." })
|
||||
selected = 0
|
||||
offset = 0
|
||||
lift_height=-1
|
||||
lift_top=0
|
||||
if #files>23 then
|
||||
lift_height=23*161/#files
|
||||
end
|
||||
end
|
||||
|
||||
function goBack()
|
||||
dir = dir:match("(.+)/[^/]+$")
|
||||
loadDir(dir)
|
||||
end
|
||||
|
||||
function mini.init()
|
||||
surf.cls(0)
|
||||
folder = surf.new(5,4)
|
||||
surf.target(folder)
|
||||
for i=0,4 do for j=0,3 do surf.pixel(i,j,0) end end
|
||||
for i=2,4 do surf.pixel(i,0,255) end
|
||||
surf.target(0)
|
||||
loadDir(".")
|
||||
end
|
||||
|
||||
function mini.update()
|
||||
|
||||
local mx,my=mouse.pos()
|
||||
|
||||
view.origin(0,0)
|
||||
for i=0,15 do
|
||||
draw.rectf(i*8, 0, 8, 8, i)
|
||||
end
|
||||
pal.trans(255)
|
||||
view.origin(20, 20)
|
||||
draw.rrectf(0,0,280,200,3,15)
|
||||
draw.rrectf(4,4,272,9,2,12)
|
||||
draw.rrectf(4,17,272,163,2,12)
|
||||
if lift_height>0 then draw.rrectf(271,18+lift_top,4,lift_height,2,14) end
|
||||
|
||||
draw.rrectf(192,185,40,11,2,9)
|
||||
draw.rrectf(192,184,40,11,2,10)
|
||||
draw.text("OK",209,187,9)
|
||||
|
||||
draw.rrectf(236,185,40,11,2,1)
|
||||
draw.rrectf(236,184,40,11,2,2)
|
||||
draw.text("CANCEL",245,187,1)
|
||||
|
||||
local y = 19
|
||||
draw.text(dir, 6, 6, 0)
|
||||
|
||||
surf.source(folder)
|
||||
|
||||
-- if mx>4 and mx<268 and my>=y-1 and my<y+6 then
|
||||
-- draw.rectf(4,y-1,272,7,13)
|
||||
-- if mouse.dblclick() then
|
||||
-- goBack();
|
||||
-- end
|
||||
-- end
|
||||
-- draw.surf(0,0,5,4,7,y+1,5,4)
|
||||
-- pal.subpal(0,3)
|
||||
-- draw.surf(0,0,5,4,6,y,5,4)
|
||||
-- pal.subpal(0)
|
||||
-- draw.text("..", 13, y, 0) y=y+7
|
||||
local count = 0
|
||||
for k,file in ipairs(files) do
|
||||
local filename = file.name:match("([^/]+)$")
|
||||
if count < offset then goto continue end
|
||||
--if v:match("%.gif$") then
|
||||
if mx>4 and mx<268 and my>=y-1 and my<y+6 then
|
||||
draw.rectf(4,y-1,272,7,13)
|
||||
if mouse.dblclick() then
|
||||
if file.dir then
|
||||
if k==1 then
|
||||
goBack()
|
||||
else
|
||||
loadDir(dir.."/"..filename)
|
||||
end
|
||||
else
|
||||
--selected = k
|
||||
end
|
||||
elseif mouse.press(mouse.LEFT) then
|
||||
selected = k
|
||||
end
|
||||
end
|
||||
|
||||
if selected == k then
|
||||
draw.rectf(4,y-1,272,7,10)
|
||||
end
|
||||
|
||||
if file.dir then
|
||||
draw.surf(0,0,5,4,7,y+1,5,4)
|
||||
pal.subpal(0,3)
|
||||
draw.surf(0,0,5,4,6,y,5,4)
|
||||
pal.subpal(0)
|
||||
draw.text(filename, 13, y, 0)
|
||||
else
|
||||
draw.text(filename, 6, y, 0)
|
||||
end
|
||||
y=y+7
|
||||
::continue::
|
||||
count=count+1
|
||||
if count-offset>=23 then break end
|
||||
end
|
||||
|
||||
if key.press(key.RETURN) and selected~=-1 then
|
||||
if files[selected].dir then
|
||||
local filename = files[selected].name:match("([^/]+)$")
|
||||
loadDir(dir.."/"..filename)
|
||||
else
|
||||
-- do nothing for now
|
||||
end
|
||||
elseif key.press(key.DOWN) and selected<#files then
|
||||
selected=selected+1
|
||||
elseif key.press(key.UP) then
|
||||
if selected>1 then
|
||||
selected=selected-1
|
||||
else
|
||||
selected = 1
|
||||
end
|
||||
end
|
||||
|
||||
local scroll = -mouse.wheel()
|
||||
if scroll~=0 then
|
||||
offset=offset+scroll
|
||||
if offset<0 then offset=0 end
|
||||
if offset+23 > #files then offset = #files-23 end
|
||||
lift_top=offset*161/#files
|
||||
end
|
||||
|
||||
end
|
||||
BIN
tools/fonted/data/subatomic.gif
Normal file
BIN
tools/fonted/data/subatomic.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 540 B |
Reference in New Issue
Block a user