fixes
This commit is contained in:
parent
af24cdd1f8
commit
d81485974c
16
GuiManager/Image-Animation/SetImage.int
Normal file
16
GuiManager/Image-Animation/SetImage.int
Normal file
@ -0,0 +1,16 @@
|
||||
function gui:SetImage(i)
|
||||
if not i then return end
|
||||
if type(i) == "userdata" and i:type() == "Image" then
|
||||
self.Image=i
|
||||
self.ImageHeigth=self.Image:getHeight()
|
||||
self.ImageWidth=self.Image:getWidth()
|
||||
self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
elseif type(i)=="string" then
|
||||
gui.loadImageData(i,nil,function(imagedata)
|
||||
self.Image = love.graphics.newImage(imagedata)
|
||||
self.ImageHeigth=self.Image:getHeight()
|
||||
self.ImageWidth=self.Image:getWidth()
|
||||
self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
end)
|
||||
end
|
||||
end
|
||||
60
GuiManager/Image-Animation/SetThreadedImage.int
Normal file
60
GuiManager/Image-Animation/SetThreadedImage.int
Normal file
@ -0,0 +1,60 @@
|
||||
-- local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
-- local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
-- local code = [[
|
||||
-- require("love.image")
|
||||
-- local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
-- local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
-- local clock = os.clock
|
||||
-- local idle = clock
|
||||
-- while true do
|
||||
-- if not idle then
|
||||
-- love.timer.sleep(.001)
|
||||
-- elseif clock()-idle>=15 then
|
||||
-- love.timer.sleep(.01)
|
||||
-- end
|
||||
-- local data = queue:pop()
|
||||
-- if data then
|
||||
-- idle = clock()
|
||||
-- print(data[1],data[2])
|
||||
-- end
|
||||
-- end
|
||||
-- ]]
|
||||
-- local t = love.thread.newThread(code)
|
||||
-- t:start()
|
||||
|
||||
|
||||
-- _GuiPro.jobqueue:registerJob("LoadImage",function(path)
|
||||
-- local dat = love.image.newImageData(path)
|
||||
-- return dat
|
||||
-- end)
|
||||
-- local cache = {}
|
||||
-- _GuiPro.jobqueue.OnJobCompleted(function(JOBID,n)
|
||||
-- cache[JOBID].Image=love.graphics.newImage(n)
|
||||
-- cache[JOBID].ImageHeigth=cache[JOBID].Image:getHeight()
|
||||
-- cache[JOBID].ImageWidth=cache[JOBID].Image:getWidth()
|
||||
-- cache[JOBID].Quad=love.graphics.newQuad(0,0,cache[JOBID].width,cache[JOBID].height,cache[JOBID].ImageWidth,cache[JOBID].ImageHeigth)
|
||||
-- end)
|
||||
-- function gui:ThreadedSetImage(i)
|
||||
-- local temp = self.Image
|
||||
-- if _GuiPro.imagecache[i] then
|
||||
-- self.Image=_GuiPro.imagecache[i]
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- else
|
||||
-- if type(i)=="string" then
|
||||
-- local ii = _GuiPro.jobqueue:pushJob("LoadImage",i)
|
||||
-- cache[ii] = self
|
||||
-- elseif tostring(i):find("ImageData") then
|
||||
-- self.Image=love.graphics.newImage(i)
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- elseif i then
|
||||
-- self.Image=i
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
44
GuiManager/Image-Animation/imageThreadHandler.int
Normal file
44
GuiManager/Image-Animation/imageThreadHandler.int
Normal file
@ -0,0 +1,44 @@
|
||||
local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
local code = [[
|
||||
require("love.image")
|
||||
require("love.timer")
|
||||
local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
while true do
|
||||
love.timer.sleep(.001)
|
||||
local data = queueUpload:pop()
|
||||
if data then
|
||||
queueDownload:push{data[1],love.image.newImageData(data[2])}
|
||||
end
|
||||
end
|
||||
]]
|
||||
local count = 0
|
||||
local conn = multi:newConnection()
|
||||
function gui.loadImageData(path,tag,callback)
|
||||
local c = count
|
||||
count = count + 1
|
||||
queueUpload:push{c,path}
|
||||
if not callback then
|
||||
return conn
|
||||
else
|
||||
local cd
|
||||
cd = conn(function(id,data)
|
||||
if id == c then
|
||||
callback(data,tag,id)
|
||||
cd:Destroy()
|
||||
end
|
||||
end)
|
||||
end
|
||||
return c
|
||||
end
|
||||
multi:newLoop(function()
|
||||
local dat = queueDownload:pop()
|
||||
if dat then
|
||||
conn:Fire(dat[1],dat[2])
|
||||
end
|
||||
end)
|
||||
for i = 1,love.system.getProcessorCount() do
|
||||
local t = love.thread.newThread(code)
|
||||
t:start()
|
||||
end
|
||||
@ -1,19 +1,28 @@
|
||||
function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local _files=alphanumsort(love.filesystem.getDirectoryItems(file))
|
||||
local x,y,w,h,sx,sy,sw,sh=filter(file, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
if not w and not h then
|
||||
local w,h = love.graphics.newImage(file.."/".._files[1]):getDimensions()
|
||||
c:setDualDim(nil,nil,w,h)
|
||||
end
|
||||
c.Visibility=0
|
||||
c.ImageVisibility=1
|
||||
c.delay=delay or .05
|
||||
c.files={}
|
||||
c.AnimStart={}
|
||||
c.AnimEnd={}
|
||||
local _files=alphanumsort(love.filesystem.getDirectoryItems(file))
|
||||
local count = 0
|
||||
local max
|
||||
for i=1,#_files do
|
||||
if string.sub(_files[i],-1,-1)~="b" then
|
||||
table.insert(c.files,love.graphics.newImage(file.."/".._files[i]))
|
||||
count = count + 1
|
||||
gui.loadImageData(file.."/".._files[i],count,function(imagedata,id)
|
||||
c.files[id] = love.graphics.newImage(imagedata)
|
||||
end)
|
||||
end
|
||||
end
|
||||
c.step=multi:newTStep(1,#c.files,1,c.delay)
|
||||
c.step=multi:newTStep(1,count,1,c.delay)
|
||||
c.step.parent=c
|
||||
c.rotation=0
|
||||
c.step:OnStart(function(step)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
if not name then name = "Imagelabel" end
|
||||
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local c=self:newBase("ImageLabel",name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c:SetImage(i)
|
||||
|
||||
8
GuiManager/Misc/SquareX.int
Normal file
8
GuiManager/Misc/SquareX.int
Normal file
@ -0,0 +1,8 @@
|
||||
function gui:SquareX(n)
|
||||
local n = n or 0
|
||||
local w = self.Parent.width
|
||||
local rw = w*n
|
||||
local s = (w-rw)/2
|
||||
self:setDualDim(self.x+s,self.y+s,rw,rw,sx,sy)
|
||||
return self.Parent.width
|
||||
end
|
||||
8
GuiManager/Misc/SquareY.int
Normal file
8
GuiManager/Misc/SquareY.int
Normal file
@ -0,0 +1,8 @@
|
||||
function gui:SquareY(n)
|
||||
local n = n or 0
|
||||
local w = self.Parent.height
|
||||
local rw = w*n
|
||||
local s = (w-rw)/2
|
||||
self:setDualDim(self.x+s,self.y+s,rw,rw)
|
||||
return self.Parent.height
|
||||
end
|
||||
@ -1,4 +1,4 @@
|
||||
function gui:fitFont()
|
||||
function gui:fitFont(n)
|
||||
local font
|
||||
if self.FontFile then
|
||||
if self.FontFile:match("ttf") then
|
||||
@ -22,7 +22,8 @@ function gui:fitFont()
|
||||
s = s + 1
|
||||
Font = font(s)
|
||||
end
|
||||
Font = font(s - 2)
|
||||
Font = font(s - (2+(n or 0)))
|
||||
Font:setFilter("linear","nearest",4)
|
||||
self.Font = Font
|
||||
return s - (2+(n or 0))
|
||||
end
|
||||
@ -1,5 +1,7 @@
|
||||
local multi = require("multi")
|
||||
local GLOBAL,THREAD=require("multi.integration.loveManager").init()
|
||||
local p = print
|
||||
print = multi.print
|
||||
-- automatic resource loading will be added soonish
|
||||
utf8 = require("utf8")
|
||||
gui = {}
|
||||
@ -9,7 +11,7 @@ gui.Version="VERSION" -- Is it really ready for release?
|
||||
_GuiPro={
|
||||
GLOBAL = GLOBAL,
|
||||
THREAD = THREAD,
|
||||
jobqueue = multi:newSystemThreadedJobQueue(4),
|
||||
jobqueue = multi:newSystemThreadedJobQueue("ImageJobQueue"),
|
||||
imagecache = {},
|
||||
GBoost=true,
|
||||
hasDrag=false,
|
||||
@ -25,10 +27,6 @@ _GuiPro={
|
||||
return self.Children
|
||||
end
|
||||
}
|
||||
_GuiPro.jobqueue:registerJob("LoadImage",function(path,t)
|
||||
local dat = love.image.newImageData(path)
|
||||
return dat,path,t
|
||||
end)
|
||||
_GuiPro.Clips={}
|
||||
_GuiPro.rotate=0
|
||||
_defaultfont = love.graphics.setNewFont(12)
|
||||
@ -69,7 +67,7 @@ gui.LoadAll("GuiManager/Drawing")
|
||||
-- End of Load
|
||||
gui:respectHierarchy()
|
||||
_GuiPro.width,_GuiPro.height=love.graphics.getDimensions()
|
||||
multi:newLoop(function() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() end)
|
||||
multi:newLoop(function() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() end):setName("gui.mainUpdater")
|
||||
multi:onDraw(function()
|
||||
local items=GetAllChildren(_GuiPro)
|
||||
for i=1,#items do
|
||||
@ -81,3 +79,4 @@ gui.ff.Color={0,0,0}
|
||||
gui.ff:OnUpdate(function(self)
|
||||
self:BottomStack()
|
||||
end)
|
||||
print = p
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user