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