Some smaller fixes
Small fixes to bimg support
This commit is contained in:
@@ -901,8 +901,8 @@ return function(name, parent, pTerm, basalt)
|
|||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:removeFocusedObject()
|
|
||||||
if(yOffset==cache)then return false end
|
if(yOffset==cache)then return false end
|
||||||
|
self:removeFocusedObject()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ local basaltEvent = require("basaltEvent")
|
|||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
local split = utils.splitString
|
local split = utils.splitString
|
||||||
local numberFromString = utils.numberFromString
|
local numberFromString = utils.numberFromString
|
||||||
local xmlValue = utils.getValueFromXML
|
local xmlValue = utils.getValueFromXML
|
||||||
|
|
||||||
return function(name)
|
return function(name)
|
||||||
-- Base object
|
-- Base object
|
||||||
|
|||||||
@@ -80,8 +80,10 @@ local function frame(base, manager)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if(base~=nil)then
|
if(base~=nil)then
|
||||||
|
w = #base[1][1]
|
||||||
|
h = #base
|
||||||
setFrame(base)
|
setFrame(base)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recalculateSize = recalculateSize,
|
recalculateSize = recalculateSize,
|
||||||
@@ -97,7 +99,8 @@ local function frame(base, manager)
|
|||||||
for k,v in pairs(t)do
|
for k,v in pairs(t)do
|
||||||
table.insert(f, {v, fg[k], bg[k]})
|
table.insert(f, {v, fg[k], bg[k]})
|
||||||
end
|
end
|
||||||
return f
|
|
||||||
|
return f, w, h
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getImage = function()
|
getImage = function()
|
||||||
@@ -161,12 +164,14 @@ return function(img)
|
|||||||
local function addFrame(id, data)
|
local function addFrame(id, data)
|
||||||
id = id or #frames+1
|
id = id or #frames+1
|
||||||
frames[id] = frame(data, manager)
|
frames[id] = frame(data, manager)
|
||||||
frames[id].setSize(width, height)
|
if(data==nil)then
|
||||||
|
frames[id].setSize(width, height)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
manager = {
|
manager = {
|
||||||
updateSize = function(w, h)
|
updateSize = function(w, h, force)
|
||||||
local changed = false
|
local changed = force==true and true or false
|
||||||
if(w > width)then changed = true width = w end
|
if(w > width)then changed = true width = w end
|
||||||
if(h > height)then changed = true height = h end
|
if(h > height)then changed = true height = h end
|
||||||
if(changed)then
|
if(changed)then
|
||||||
@@ -224,7 +229,16 @@ return function(img)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
getFrameObjects = function()
|
getFrameObjects = function()
|
||||||
return frames
|
return frames
|
||||||
|
end,
|
||||||
|
|
||||||
|
getFrames = function()
|
||||||
|
local f = {}
|
||||||
|
for k,v in pairs(frames)do
|
||||||
|
local frame = v.getFrame()
|
||||||
|
table.insert(f, frame)
|
||||||
|
end
|
||||||
|
return f
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getFrameObject = function(id)
|
getFrameObject = function(id)
|
||||||
@@ -235,7 +249,7 @@ return function(img)
|
|||||||
local f = frame()
|
local f = frame()
|
||||||
if(#frames<=1)then
|
if(#frames<=1)then
|
||||||
metadata.animated = true
|
metadata.animated = true
|
||||||
metadata.secondsPerFrame = 1
|
metadata.secondsPerFrame = 0.2
|
||||||
end
|
end
|
||||||
addFrame(id)
|
addFrame(id)
|
||||||
return f
|
return f
|
||||||
@@ -262,7 +276,8 @@ return function(img)
|
|||||||
createBimg = function()
|
createBimg = function()
|
||||||
local bimg = {}
|
local bimg = {}
|
||||||
for k,v in pairs(frames)do
|
for k,v in pairs(frames)do
|
||||||
table.insert(bimg, v.getFrame())
|
local f = v.getFrame()
|
||||||
|
table.insert(bimg, f)
|
||||||
end
|
end
|
||||||
for k,v in pairs(metadata)do
|
for k,v in pairs(metadata)do
|
||||||
bimg[k] = v
|
bimg[k] = v
|
||||||
@@ -281,8 +296,16 @@ return function(img)
|
|||||||
addFrame(k, v)
|
addFrame(k, v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if(metadata.width==nil)or(metadata.height==nil)then
|
||||||
|
for k,v in pairs(frames)do
|
||||||
|
local w, h = v.getSize()
|
||||||
|
if(w>width)then w = width end
|
||||||
|
if(h>height)then h = height end
|
||||||
|
end
|
||||||
|
manager.updateSize(width, height, true)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
addFrame(1, manager)
|
addFrame(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
return manager
|
return manager
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ local function loadImageAsBimg(path, f)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function resizeBIMG(source, w, h)
|
local function resizeBIMG(source, w, h)
|
||||||
local oW, oH = #source[1][1][1], #source[1]
|
local oW, oH = source.width or #source[1][1][1], source.height or #source[1]
|
||||||
local newImg = {{}}
|
local newImg = {{}}
|
||||||
for k,v in pairs(source)do if(k~=1)then newImg[k] = v end end
|
for k,v in pairs(source)do if(k~=1)then newImg[k] = v end end
|
||||||
local img = source[1]
|
local img = source[1]
|
||||||
|
|||||||
@@ -55,6 +55,25 @@ return function(name)
|
|||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
addFrame = function(self)
|
||||||
|
local id = #imgData.getFrames()+1
|
||||||
|
if(imgData.getFrameObject(id)==nil)then
|
||||||
|
imgData.addFrame(id)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
getFrame = function(self, id)
|
||||||
|
return imgData.getFrame(id)
|
||||||
|
end,
|
||||||
|
|
||||||
|
getFrames = function(self)
|
||||||
|
return imgData.getFrames()
|
||||||
|
end,
|
||||||
|
|
||||||
|
getFrameCount = function(self)
|
||||||
|
return #imgData.getFrames()
|
||||||
|
end,
|
||||||
|
|
||||||
getSelectedFrame = function(self)
|
getSelectedFrame = function(self)
|
||||||
return selectedFrame
|
return selectedFrame
|
||||||
end,
|
end,
|
||||||
@@ -72,7 +91,7 @@ return function(name)
|
|||||||
x = _x or x
|
x = _x or x
|
||||||
y = _y or y
|
y = _y or y
|
||||||
bimgFrame.text(text, x, y)
|
bimgFrame.text(text, x, y)
|
||||||
bimg = imgData.getFrame()
|
bimg = bimgFrame.getImage()
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local Object = require("Object")
|
local Object = require("Object")
|
||||||
local xmlValue = require("utils").getValueFromXML
|
local xmlValue = require("utils").getValueFromXML
|
||||||
local images = require("images")
|
local images = require("images")
|
||||||
local log = require("basaltLogs")
|
|
||||||
|
|
||||||
local unpack,sub = table.unpack,string.sub
|
local unpack,sub = table.unpack,string.sub
|
||||||
return function(name)
|
return function(name)
|
||||||
@@ -89,6 +88,7 @@ return function(name)
|
|||||||
os.cancelTimer(animTimer)
|
os.cancelTimer(animTimer)
|
||||||
end
|
end
|
||||||
self:updateDraw()
|
self:updateDraw()
|
||||||
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getImageSize = function(self)
|
getImageSize = function(self)
|
||||||
@@ -113,7 +113,6 @@ return function(name)
|
|||||||
local obx, oby = self:getAnchorPosition()
|
local obx, oby = self:getAnchorPosition()
|
||||||
local w,h = self:getSize()
|
local w,h = self:getSize()
|
||||||
for y,v in ipairs(image[curFrame])do
|
for y,v in ipairs(image[curFrame])do
|
||||||
log(unpack(v))
|
|
||||||
local t, f, b = unpack(v)
|
local t, f, b = unpack(v)
|
||||||
t = sub(t, 1,w)
|
t = sub(t, 1,w)
|
||||||
f = sub(f, 1,w)
|
f = sub(f, 1,w)
|
||||||
|
|||||||
Reference in New Issue
Block a user