1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-28 00:39:30 +00:00

Support for special characters in gfx.text; added scrolling to the default shell; updated sftdlib.

There is a known bug with different text size in sftdlib.
This commit is contained in:
Reuh 2015-08-22 16:45:32 +02:00
parent 56b47153b7
commit 2a5513473d
10 changed files with 516 additions and 39 deletions

View file

@ -44,8 +44,7 @@ while ctr.run() do
if keys.held.up then y = y - 1 end
if keys.held.down then y = y + 1 end
if keys.held.r then dMul = dMul + 0.05 end
if keys.held.l then dMul = dMul - 0.05 end
dMul = hid.pos3d()
gfx.startFrame(gfx.GFX_TOP, gfx.GFX_LEFT)
@ -61,10 +60,10 @@ while ctr.run() do
gfx.startFrame(gfx.GFX_BOTTOM)
gfx.color.setDefault(0, 0, 0)
gfx.text(5, 7, "FPS: "..math.ceil(gfx.getFPS()))
gfx.text(5, 20, "Hello world, from Lua !", 20)
gfx.text(5, 30, "Time: "..os.date())
gfx.color.setDefault(gfx.color.RGBA8(0, 0, 0))
gfx.text(5, 5, "FPS: "..math.ceil(gfx.getFPS()))
gfx.text(5, 17, "Hello world, from Lua ! éàçù", 20, gfx.color.RGBA8(0, 0, 0))
gfx.text(5, 50, "Time: "..os.date())
texture1:draw(240, 10, angle);

View file

@ -2,6 +2,7 @@ local ctr = require("ctr")
local gfx = require("ctr.gfx")
local sel = 1
local scroll = 0
local curdir = "/"
local files = ctr.fs.list(curdir)
@ -10,8 +11,13 @@ while ctr.run() do
local keys = ctr.hid.keys()
if keys.down.start then break end
if keys.down.down and sel < #files then sel = sel + 1
elseif keys.down.up and sel > 1 then sel = sel - 1 end
if keys.down.down and sel < #files then
sel = sel + 1
if sel > scroll + 14 then scroll = scroll + 1 end
elseif keys.down.up and sel > 1 then
sel = sel - 1
if sel <= scroll then scroll = scroll - 1 end
end
if keys.down.a then
local f = files[sel]
@ -21,6 +27,7 @@ while ctr.run() do
else curdir = curdir..f.name.."/" end
sel = 1
scroll = 0
files = ctr.fs.list(curdir)
if curdir ~= "/" then
@ -29,20 +36,26 @@ while ctr.run() do
else
if f.name:match("%..+$") == ".lua" then
dofile(curdir..f.name)
-- reset things the script could have changed
gfx.color.setDefault(0xFFFFFFFF)
gfx.color.setBackground(0x000000FF)
end
end
end
gfx.startFrame(gfx.GFX_TOP)
gfx.text(3, 9, curdir)
gfx.rectangle(0, 10+(sel-scroll)*15, gfx.TOP_WIDTH, 15, 0, gfx.color.RGBA8(0, 0, 200))
for i,f in pairs(files) do
for i = scroll+1, scroll+14, 1 do
local f = files[i]
if not f then break end
local name = f.isDirectory and "["..f.name.."]" or f.name.." ("..f.fileSize.."b)"
if not f.isHidden then gfx.text(5, 9+i*9, name) end
if not f.isHidden then gfx.text(5, 12+(i-scroll)*15, name) end
end
gfx.text(0, 9+sel*9, ">")
gfx.rectangle(0, 0, gfx.TOP_WIDTH, 25, 0, gfx.color.RGBA8(200, 200, 200))
gfx.text(3, 3, curdir, 13, gfx.color.RGBA8(0, 0, 0))
gfx.endFrame()