1
0
Fork 0
mirror of https://github.com/ctruLua/uCompat.git synced 2025-10-27 16:49:31 +00:00

Added/Fixed things

This commit is contained in:
Firew0lf 2016-03-26 23:33:55 +01:00
parent f9b2fcb11a
commit eba92fcce8
6 changed files with 85 additions and 28 deletions

View file

@ -1,8 +1,5 @@
--[[
Images related µLua compatibility layer/lib for ctrµLua
Actually doesn't support GIFs, because sfillib doesn't. Use PNGs, these are
better.
]]
-- Local
@ -23,7 +20,9 @@ function Image.load(path, dest)
if not t then return nil end
return { -- Image object
texture = t,
rotation = 0
rotation = 0,
scaleX = 1,
scaleY = 1
}
end
@ -43,23 +42,28 @@ function Image.height(img)
end
function Image.scale(img, w, h)
local iw,ih = img.texture:getSize()
img.scaleX = w/iw
img.scaleY = h/ih
img.texture:scale(img.scaleX, img.scaleY)
end
function Image.rotate(img, angle, cx, cy)
img.rotation = angle*((math.pi*2)/512)
img.rotation = angle*(math.pi/256)
end
function Image.rotateDegree(img, angle, cx, cy)
img.rotation = angle*((math.pi*2)/360)
img.rotation = angle*(math.pi/180)
end
function Image.mirrorH(img, activate)
img.scaleY = (0-img.scaleY)
img.texture:scale(img.scaleX, img.scaleY)
end
function Image.mirrorV(img, activate)
img.scaleX = (0-img.scaleY)
img.textire:scale(img.scaleX, img.scaleY)
end
function Image.setTint(img, color)

View file

@ -9,6 +9,30 @@
local fs = require("ctr.fs")
local gfx = require("ctr.gfx")
-- µ -> ctrµ
local function fixPath(DSpath)
local path
if DSpath:sub(1, 1) == "/" or DSpath:sub(1, 5) == "fat:/" then -- fix root
path = ("sdmc:/"..DSpath:sub(6, -1))
elseif DSpath:sub(1, 5) == "efs:/" then
path = ("romfs:/"..DSpath:sub(6,-1))
end
return path
end
-- ctrµ -> µ
local function unfixPath(path)
local DSpath
if path:sub(1, 6) == "sdmc:/" or path.sub(1, 1) == "/" then
DSpath = ("fat:/"..path:sub(7, -1))
elseif path:sub(1, 7) == "romfs:/" then
DSpath = ("efs:/"..path:sub(8, -1))
end
return DSpath
end
-- Constants
LED_ON = 0
@ -19,12 +43,14 @@ LED_SLEEP = 2
System = {}
System.EFS = false
function System.currentDirectory()
return fs.getDirectory()
return unfixPath(fs.getDirectory())
end
function System.changeDirectory(dir)
fs.setDirectory(dir)
fs.setDirectory(fixPath(dir))
end
function System.remove(path)
@ -40,7 +66,8 @@ function System.makeDirectory(name)
end
function System.listDirectory(path)
local list = fs.list(path)
local list = fs.list(fixPath(path))
local flist = {}
for i=1, #list do
flist[i] = {

View file

@ -13,7 +13,7 @@ local ctr = require("ctr")
Timer = {
new = function()
local t = ctr.time()
local t = ctr.time() -- small patch
local isStarted = false
local tick = 0

View file

@ -4,6 +4,26 @@
Informations are fake ones, until ctrµLua/the ctruLib can deal with it.
]]
-- Local
local cfgu = require("ctr.cfgu")
local language5 = {
[cfgu.LANGUAGE_JP] = 0,
[cfgu.LANGUAGE_EN] = 1,
[cfgu.LANGUAGE_FR] = 2,
[cfgu.LANGUAGE_DE] = 3,
[cfgu.LANGUAGE_IT] = 4,
[cfgu.LANGUAGE_ES] = 5,
-- always english if not in the list above
[cfgu.LANGUAGE_ZH] = 1,
[cfgu.LANGUAGE_KO] = 1,
[cfgu.LANGUAGE_NL] = 1,
[cfgu.LANGUAGE_PT] = 1,
[cfgu.LANGUAGE_RU] = 1,
[cfgu.LANGUAGE_TW] = 1
}
-- Module
dsUser = {}
@ -13,19 +33,21 @@ function dsUser.getColor()
end
function dsUser.getBirthDay()
return 1
local _, day = cfgu.getBirthday()
return day
end
function dsUser.getBirthMonth()
return 1
local month, _ = cfgu.getBirthday()
return month
end
function dsUser.getName()
return "NDS"
return cfgu.getUsername()
end
function dsUser.getNameLength()
return 3
return #(dsUser.getName())
end
function dsUser.getMessage()
@ -33,7 +55,7 @@ function dsUser.getMessage()
end
function dsUser.getMessageLength()
return 0
return #(dsUser.getMessage())
end
function dsUser.getAlarmHour()
@ -45,7 +67,7 @@ function dsUser.getAlarmMinute()
end
function dsUser.getLanguage()
return 0
return language5[cgfu.getLanguage()]
end
function dsUser.getGBAScreen()

View file

@ -4,10 +4,14 @@
The goal is not to provide a full compatibility, but something close.
]]
-- Just something needed
local ctr = require("ctr")
-- Constants
ULUA_VERSION = "4.7.2"
ULUA_DIR = "sdmc:/3ds/ctruLua/"
ULUA_SCRIPTS = (ULUA_DIR.."scripts/") -- Warning: you need to create the folder
ULUA_VERSION = "Microlua 4.7.2"
ULUA_DIR = ctr.root -- you can change it to anything
ULUA_SCRIPTS = (ULUA_DIR.."scripts/") -- Warning: you may need to create the folder
ULUA_LIBS = (ULUA_DIR.."libs/")
ULUA_BOOT_FILE = "main.lua"
ULUA_BOOT_FULLPATH = (ULUA_DIR..ULUA_BOOT_FILE)

View file

@ -112,7 +112,7 @@ function screen.getLayer()
end
function screen.getAlphaLevel()
return ALPHA_RESET
return alpha
end
function screen.setAlpha(level, layer)
@ -137,14 +137,14 @@ function screen.drawPoint(scr, x, y, color)
end
function screen.drawLine(scr, x0, y0, x1, y1, color)
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetX+y0, offsetX+x1, offsetY+y1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetX+y0, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}}
end
function screen.drawRect(scr, x0, y0, x1, y1, color)
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x0, offsetY+y1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x1, offsetY+y0, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y1, offsetX+x1, offsetY+y1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x1, offsetY+y0, offsetX+x1, offsetY+y1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x0, offsetY+y1, 1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y0, offsetX+x1, offsetY+y0, 1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x0, offsetY+y1, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}}
checkBuffer(scr)[#videoStack[scr]+1] = {"line", {offsetX+x1, offsetY+y0, offsetX+x1, offsetY+y1, 1, RGB2RGBA(color)}}
end
function screen.drawFillRect(scr, x0, y0, x1, y1, color)