Modified setImage to handle parts of a larger image, implemented image_cache for faster loading
This commit is contained in:
parent
cdf8246933
commit
cf596551ba
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,5 +3,5 @@ conf.lua
|
|||||||
*.ttf
|
*.ttf
|
||||||
*.png
|
*.png
|
||||||
*.ogv
|
*.ogv
|
||||||
multi/*
|
|
||||||
moonshine/*
|
moonshine/*
|
||||||
|
deck/*
|
||||||
377
gui/init.lua
377
gui/init.lua
@ -9,7 +9,8 @@ local bit = require("bit")
|
|||||||
local band, bor = bit.band, bit.bor
|
local band, bor = bit.band, bit.bor
|
||||||
local cursor_hand = love.mouse.getSystemCursor("hand")
|
local cursor_hand = love.mouse.getSystemCursor("hand")
|
||||||
local clips = {}
|
local clips = {}
|
||||||
local max, min, abs, rad, floor, ceil = math.max, math.min, math.abs, math.rad, math.floor,math.ceil
|
local max, min, abs, rad, floor, ceil = math.max, math.min, math.abs, math.rad,
|
||||||
|
math.floor, math.ceil
|
||||||
local frame, image, text, box, video, button, anim = 0, 1, 2, 4, 8, 16, 32
|
local frame, image, text, box, video, button, anim = 0, 1, 2, 4, 8, 16, 32
|
||||||
local global_drag
|
local global_drag
|
||||||
local object_focus = gui
|
local object_focus = gui
|
||||||
@ -145,7 +146,8 @@ end)
|
|||||||
function gui:setHotKey(keys, conn)
|
function gui:setHotKey(keys, conn)
|
||||||
has_hotkey = true
|
has_hotkey = true
|
||||||
local conn = conn or multi:newConnection()
|
local conn = conn or multi:newConnection()
|
||||||
table.insert(hot_keys, {Ref=self, Connection = conn, Keys = {unpack(keys)}})
|
table.insert(hot_keys,
|
||||||
|
{Ref = self, Connection = conn, Keys = {unpack(keys)}})
|
||||||
return conn
|
return conn
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -153,37 +155,33 @@ end
|
|||||||
gui.HotKeys = {}
|
gui.HotKeys = {}
|
||||||
|
|
||||||
-- Connections can be added together to create an OR logic to them, they can be multiplied together to create an AND logic to them
|
-- Connections can be added together to create an OR logic to them, they can be multiplied together to create an AND logic to them
|
||||||
gui.HotKeys.OnSelectAll = gui:setHotKey({"lctrl","a"})
|
gui.HotKeys.OnSelectAll = gui:setHotKey({"lctrl", "a"}) +
|
||||||
+ gui:setHotKey({"rctrl","a"})
|
gui:setHotKey({"rctrl", "a"})
|
||||||
|
|
||||||
gui.HotKeys.OnCopy = gui:setHotKey({"lctrl","c"})
|
gui.HotKeys.OnCopy = gui:setHotKey({"lctrl", "c"}) +
|
||||||
+ gui:setHotKey({"rctrl","c"})
|
gui:setHotKey({"rctrl", "c"})
|
||||||
|
|
||||||
gui.HotKeys.OnPaste = gui:setHotKey({"lctrl","v"})
|
gui.HotKeys.OnPaste = gui:setHotKey({"lctrl", "v"}) +
|
||||||
+ gui:setHotKey({"rctrl","v"})
|
gui:setHotKey({"rctrl", "v"})
|
||||||
|
|
||||||
gui.HotKeys.OnCut = gui:setHotKey({"lctrl","x"})
|
gui.HotKeys.OnCut = gui:setHotKey({"lctrl", "x"}) +
|
||||||
+ gui:setHotKey({"rctrl","x"})
|
gui:setHotKey({"rctrl", "x"})
|
||||||
|
|
||||||
gui.HotKeys.OnUndo = gui:setHotKey({"lctrl","z"})
|
gui.HotKeys.OnUndo = gui:setHotKey({"lctrl", "z"}) +
|
||||||
+ gui:setHotKey({"rctrl","z"})
|
gui:setHotKey({"rctrl", "z"})
|
||||||
|
|
||||||
gui.HotKeys.OnRedo = gui:setHotKey({"lctrl","y"})
|
gui.HotKeys.OnRedo = gui:setHotKey({"lctrl", "y"}) +
|
||||||
+ gui:setHotKey({"rctrl","y"})
|
gui:setHotKey({"rctrl", "y"}) +
|
||||||
+ gui:setHotKey({"lctrl", "lshift", "z"})
|
gui:setHotKey({"lctrl", "lshift", "z"}) +
|
||||||
+ gui:setHotKey({"rctrl", "lshift", "z"})
|
gui:setHotKey({"rctrl", "lshift", "z"}) +
|
||||||
+ gui:setHotKey({"lctrl", "rshift", "z"})
|
gui:setHotKey({"lctrl", "rshift", "z"}) +
|
||||||
+ gui:setHotKey({"rctrl", "rshift", "z"})
|
gui:setHotKey({"rctrl", "rshift", "z"})
|
||||||
|
|
||||||
-- Utils
|
-- Utils
|
||||||
|
|
||||||
function gui:getObjectFocus()
|
function gui:getObjectFocus() return object_focus end
|
||||||
return object_focus
|
|
||||||
end
|
|
||||||
|
|
||||||
function gui:hasType(t)
|
function gui:hasType(t) return band(self.type, t) == t end
|
||||||
return band(self.type, t) == t
|
|
||||||
end
|
|
||||||
|
|
||||||
function gui:move(x, y)
|
function gui:move(x, y)
|
||||||
self.dualDim.offset.pos.x = self.dualDim.offset.pos.x + x
|
self.dualDim.offset.pos.x = self.dualDim.offset.pos.x + x
|
||||||
@ -193,7 +191,8 @@ end
|
|||||||
function gui:moveInBounds(dx, dy)
|
function gui:moveInBounds(dx, dy)
|
||||||
local x, y, w, h = self:getAbsolutes()
|
local x, y, w, h = self:getAbsolutes()
|
||||||
local x1, y1, w1, h1 = self.parent:getAbsolutes()
|
local x1, y1, w1, h1 = self.parent:getAbsolutes()
|
||||||
if (x + dx >= x1 or dx > 0) and (x + w + dx <= x1 + w1 or dx < 0) and (y + dy >= y1 or dy > 0) and (y + h + dy <= y1 + h1 or dy < 0) then
|
if (x + dx >= x1 or dx > 0) and (x + w + dx <= x1 + w1 or dx < 0) and
|
||||||
|
(y + dy >= y1 or dy > 0) and (y + h + dy <= y1 + h1 or dy < 0) then
|
||||||
self:move(dx, dy)
|
self:move(dx, dy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -218,9 +217,7 @@ local function intersecpt(x1,y1,x2,y2,x3,y3,x4,y4)
|
|||||||
return x7, y7, abs(x7 - x8), abs(y7 - y8)
|
return x7, y7, abs(x7 - x8), abs(y7 - y8)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function toCoordPoints(x, y, w, h)
|
local function toCoordPoints(x, y, w, h) return x, y, x + w, y + h end
|
||||||
return x,y,x+w,y+h
|
|
||||||
end
|
|
||||||
|
|
||||||
function gui:intersecpt(x, y, w, h)
|
function gui:intersecpt(x, y, w, h)
|
||||||
local x1, y1, x2, y2 = toCoordPoints(self:getAbsolutes())
|
local x1, y1, x2, y2 = toCoordPoints(self:getAbsolutes())
|
||||||
@ -232,23 +229,22 @@ end
|
|||||||
function gui:isDescendantOf(obj)
|
function gui:isDescendantOf(obj)
|
||||||
local parent = self.parent
|
local parent = self.parent
|
||||||
while parent ~= gui do
|
while parent ~= gui do
|
||||||
if parent==obj then
|
if parent == obj then return true end
|
||||||
return true
|
|
||||||
end
|
|
||||||
parent = parent.parent
|
parent = parent.parent
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function gui:getChildren()
|
function gui:getChildren() return self.children end
|
||||||
return self.children
|
|
||||||
end
|
|
||||||
|
|
||||||
function gui:getAbsolutes() -- returns x, y, w, h
|
function gui:getAbsolutes() -- returns x, y, w, h
|
||||||
return (self.parent.w*self.dualDim.scale.pos.x)+self.dualDim.offset.pos.x+self.parent.x,
|
return (self.parent.w * self.dualDim.scale.pos.x) +
|
||||||
(self.parent.h*self.dualDim.scale.pos.y)+self.dualDim.offset.pos.y+self.parent.y,
|
self.dualDim.offset.pos.x + self.parent.x,
|
||||||
(self.parent.w*self.dualDim.scale.size.x)+self.dualDim.offset.size.x,
|
(self.parent.h * self.dualDim.scale.pos.y) +
|
||||||
(self.parent.h*self.dualDim.scale.size.y)+self.dualDim.offset.size.y
|
self.dualDim.offset.pos.y + self.parent.y, (self.parent.w *
|
||||||
|
self.dualDim.scale.size.x) + self.dualDim.offset.size.x,
|
||||||
|
(self.parent.h * self.dualDim.scale.size.y) +
|
||||||
|
self.dualDim.offset.size.y
|
||||||
end
|
end
|
||||||
|
|
||||||
function gui:getAllChildren(vis)
|
function gui:getAllChildren(vis)
|
||||||
@ -267,38 +263,49 @@ function gui:getAllChildren(vis)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gui:newThread(func)
|
function gui:newThread(func)
|
||||||
return updater:newThread("ThreadHandler<"..self.type..">", func, self, thread)
|
return updater:newThread("ThreadHandler<" .. self.type .. ">", func, self,
|
||||||
|
thread)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gui:setDualDim(x, y, w, h, sx, sy, sw, sh)
|
function gui:setDualDim(x, y, w, h, sx, sy, sw, sh)
|
||||||
self.dualDim.offset = {
|
self.dualDim.offset = {
|
||||||
pos={x=x or self.dualDim.offset.pos.x,y=y or self.dualDim.offset.pos.y},
|
pos = {
|
||||||
size={x=w or self.dualDim.offset.size.x,y=h or self.dualDim.offset.size.y}
|
x = x or self.dualDim.offset.pos.x,
|
||||||
|
y = y or self.dualDim.offset.pos.y
|
||||||
|
},
|
||||||
|
size = {
|
||||||
|
x = w or self.dualDim.offset.size.x,
|
||||||
|
y = h or self.dualDim.offset.size.y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.dualDim.scale = {
|
self.dualDim.scale = {
|
||||||
pos={x=sx or self.dualDim.scale.pos.x,y=sy or self.dualDim.scale.pos.y},
|
pos = {
|
||||||
size={x=sw or self.dualDim.scale.size.x,y=sh or self.dualDim.scale.size.y}
|
x = sx or self.dualDim.scale.pos.x,
|
||||||
|
y = sy or self.dualDim.scale.pos.y
|
||||||
|
},
|
||||||
|
size = {
|
||||||
|
x = sw or self.dualDim.scale.size.x,
|
||||||
|
y = sh or self.dualDim.scale.size.y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local image_cache = {}
|
||||||
function gui:getTile(i, x, y, w, h) -- returns imagedata
|
function gui:getTile(i, x, y, w, h) -- returns imagedata
|
||||||
|
local tw, wh
|
||||||
|
if i == nil then return end
|
||||||
|
if type(i) == "string" then i = image_cache[i] or i end
|
||||||
if type(i) == "string" then
|
if type(i) == "string" then
|
||||||
i=love.graphics.newImage(i)
|
i = love.image.newImageData(i)
|
||||||
|
image_cache[i] = i
|
||||||
elseif type(i) == "userdata" then
|
elseif type(i) == "userdata" then
|
||||||
-- do nothing
|
-- do nothing
|
||||||
elseif string.find(self.Type,"Image",1,true) then
|
elseif self:hasType(image) then
|
||||||
local i,x,y,w,h=self.Image,i,x,y,w
|
i, x, y, w, h = self.image, i, x, y, w
|
||||||
else
|
else
|
||||||
error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)")
|
error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)")
|
||||||
end
|
end
|
||||||
local iw,ih=i:getDimensions()
|
return i, love.graphics.newQuad(x, y, w, h, i:getWidth(), i:getHeight())
|
||||||
local id,_id=i:getData(),love.image.newImageData(w,h)
|
|
||||||
for _x=x,w+x-1 do
|
|
||||||
for _y=y,h+y-1 do
|
|
||||||
_id:setPixel(_x-x,_y-y,id:getPixel(_x,_y))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return love.graphics.newImage(_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function gui:topStack()
|
function gui:topStack()
|
||||||
@ -331,7 +338,8 @@ function gui:isBeingCovered(mx,my)
|
|||||||
for i = #children, 1, -1 do
|
for i = #children, 1, -1 do
|
||||||
if children[i] == self then
|
if children[i] == self then
|
||||||
return false
|
return false
|
||||||
elseif children[i]:canPress(mx,my) and not(children[i] == self) and not(children[i].ignore) then
|
elseif children[i]:canPress(mx, my) and not (children[i] == self) and
|
||||||
|
not (children[i].ignore) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -357,9 +365,7 @@ function gui:setParent(parent)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function processDo(ref)
|
local function processDo(ref) ref.Do[1]() end
|
||||||
ref.Do[1]()
|
|
||||||
end
|
|
||||||
|
|
||||||
function gui:clone(opt)
|
function gui:clone(opt)
|
||||||
--[[
|
--[[
|
||||||
@ -388,9 +394,7 @@ function gui:clone(opt)
|
|||||||
temp = processDo(u)
|
temp = processDo(u)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, v in pairs(u) do
|
for i, v in pairs(u) do temp[i] = v end
|
||||||
temp[i] = v
|
|
||||||
end
|
|
||||||
|
|
||||||
local conn
|
local conn
|
||||||
if opt then
|
if opt then
|
||||||
@ -430,14 +434,10 @@ function gui:getUniques(tab)
|
|||||||
visibility = self.visibility,
|
visibility = self.visibility,
|
||||||
color = self.color,
|
color = self.color,
|
||||||
borderColor = self.borderColor,
|
borderColor = self.borderColor,
|
||||||
rotation = self.rotation,
|
rotation = self.rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
if tab then
|
if tab then for i, v in pairs(tab) do base[i] = tab[i] end end
|
||||||
for i, v in pairs(tab) do
|
|
||||||
base[i] = tab[i]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return base
|
return base
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -460,9 +460,7 @@ function gui:newBase(typ,x, y, w, h, sx, sy, sw, sh, virtual)
|
|||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(c, gui)
|
setmetatable(c, gui)
|
||||||
c.__variables = {
|
c.__variables = {clip = {false, 0, 0, 0, 0}}
|
||||||
clip = {false,0,0,0,0}
|
|
||||||
}
|
|
||||||
c.active = true
|
c.active = true
|
||||||
c.type = typ
|
c.type = typ
|
||||||
c.dualDim = self:newDualDim(x, y, w, h, sx, sy, sw, sh)
|
c.dualDim = self:newDualDim(x, y, w, h, sx, sy, sw, sh)
|
||||||
@ -539,7 +537,8 @@ function gui:newBase(typ,x, y, w, h, sx, sy, sw, sh, virtual)
|
|||||||
object_focus = c
|
object_focus = c
|
||||||
end
|
end
|
||||||
|
|
||||||
if draggable and button == dragbutton and not c:isBeingCovered(x, y) and not global_drag then
|
if draggable and button == dragbutton and not c:isBeingCovered(x, y) and
|
||||||
|
not global_drag then
|
||||||
dragging = true
|
dragging = true
|
||||||
global_drag = true
|
global_drag = true
|
||||||
c.OnDragStart:Fire(c, dx, dy, x, y, istouch)
|
c.OnDragStart:Fire(c, dx, dy, x, y, istouch)
|
||||||
@ -559,15 +558,11 @@ function gui:newBase(typ,x, y, w, h, sx, sy, sw, sh, virtual)
|
|||||||
self.__rvert = vert
|
self.__rvert = vert
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:respectHierarchy(bool)
|
function c:respectHierarchy(bool) hierarchy = bool end
|
||||||
hierarchy = bool
|
|
||||||
end
|
|
||||||
|
|
||||||
function c:OnUpdate(func) -- Not crazy about this approach, will probably rework this
|
function c:OnUpdate(func) -- Not crazy about this approach, will probably rework this
|
||||||
if type(self) == "function" then func = self end
|
if type(self) == "function" then func = self end
|
||||||
mainupdater(function()
|
mainupdater(function() func(c) end)
|
||||||
func(c)
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function centerthread()
|
local function centerthread()
|
||||||
@ -626,28 +621,17 @@ function gui:newDualDim(x, y, w, h, sx, sy, sw, sh)
|
|||||||
local dd = {}
|
local dd = {}
|
||||||
dd.offset = {}
|
dd.offset = {}
|
||||||
dd.scale = {}
|
dd.scale = {}
|
||||||
dd.offset.pos = {
|
dd.offset.pos = {x = x or 0, y = y or 0}
|
||||||
x = x or 0,
|
dd.offset.size = {x = w or 0, y = h or 0}
|
||||||
y = y or 0
|
dd.scale.pos = {x = sx or 0, y = sy or 0}
|
||||||
}
|
dd.scale.size = {x = sw or 0, y = sh or 0}
|
||||||
dd.offset.size = {
|
|
||||||
x = w or 0,
|
|
||||||
y = h or 0
|
|
||||||
}
|
|
||||||
dd.scale.pos = {
|
|
||||||
x = sx or 0,
|
|
||||||
y = sy or 0
|
|
||||||
}
|
|
||||||
dd.scale.size = {
|
|
||||||
x = sw or 0,
|
|
||||||
y = sh or 0
|
|
||||||
}
|
|
||||||
return dd
|
return dd
|
||||||
end
|
end
|
||||||
|
|
||||||
function gui:getDualDim()
|
function gui:getDualDim()
|
||||||
local dd = self.dualDim
|
local dd = self.dualDim
|
||||||
return dd.offset.pos.x, dd.offset.pos.y, dd.offset.size.x, dd.offset.size.y, dd.scale.pos.x, dd.scale.pos.y, dd.scale.size.x, dd.scale.size.y
|
return dd.offset.pos.x, dd.offset.pos.y, dd.offset.size.x, dd.offset.size.y,
|
||||||
|
dd.scale.pos.x, dd.scale.pos.y, dd.scale.size.x, dd.scale.size.y
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Frames
|
-- Frames
|
||||||
@ -686,7 +670,10 @@ function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
love.graphics.clear(0, 0, 0, .5, false, false)
|
love.graphics.clear(0, 0, 0, .5, false, false)
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
love.graphics.setFont(font)
|
love.graphics.setFont(font)
|
||||||
love.graphics.printf(self.text, 0, adjust/2, width, "left", self.rotation, self.textScaleX, self.textScaleY, 0, 0, self.textShearingFactorX, self.textShearingFactorY)
|
love.graphics.printf(self.text, 0, adjust / 2, width, "left",
|
||||||
|
self.rotation, self.textScaleX, self.textScaleY, 0,
|
||||||
|
0, self.textShearingFactorX,
|
||||||
|
self.textShearingFactorY)
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
local data = canvas:newImageData()
|
local data = canvas:newImageData()
|
||||||
local f_top, f_bot = false, false
|
local f_top, f_bot = false, false
|
||||||
@ -694,7 +681,11 @@ function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
for xx = 0, width - 1 do
|
for xx = 0, width - 1 do
|
||||||
local r, g, b, a = data:getPixel(xx, yy)
|
local r, g, b, a = data:getPixel(xx, yy)
|
||||||
if r ~= 0 or g ~= 0 or b ~= 0 then
|
if r ~= 0 or g ~= 0 or b ~= 0 then
|
||||||
if yy<top and not f_top then top = yy f_top = true break end
|
if yy < top and not f_top then
|
||||||
|
top = yy
|
||||||
|
f_top = true
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -702,7 +693,11 @@ function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
for xx = 0, width - 1 do
|
for xx = 0, width - 1 do
|
||||||
local r, g, b, a = data:getPixel(xx, yy)
|
local r, g, b, a = data:getPixel(xx, yy)
|
||||||
if r ~= 0 or g ~= 0 or b ~= 0 then
|
if r ~= 0 or g ~= 0 or b ~= 0 then
|
||||||
if yy>bottom and not f_bot then bottom = yy f_bot = false break end
|
if yy > bottom and not f_bot then
|
||||||
|
bottom = yy
|
||||||
|
f_bot = false
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -735,15 +730,14 @@ function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
isdefault = true
|
isdefault = true
|
||||||
font = function(n)
|
font = function(n) return love.graphics.setNewFont(n) end
|
||||||
return love.graphics.setNewFont(n)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local x, y, width, height = self:getAbsolutes()
|
local x, y, width, height = self:getAbsolutes()
|
||||||
local Font, text = self.Font, self.text
|
local Font, text = self.Font, self.text
|
||||||
local s = 3
|
local s = 3
|
||||||
Font = font(s)
|
Font = font(s)
|
||||||
while height < max and Font:getHeight()<height and Font:getWidth(text)<width do
|
while height < max and Font:getHeight() < height and Font:getWidth(text) <
|
||||||
|
width do
|
||||||
s = s + 1
|
s = s + 1
|
||||||
Font = font(s)
|
Font = font(s)
|
||||||
end
|
end
|
||||||
@ -770,7 +764,7 @@ function gui:newTextBase(typ, txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
textShearingFactorY = c.textShearingFactorY,
|
textShearingFactorY = c.textShearingFactorY,
|
||||||
textVisibility = c.textVisibility,
|
textVisibility = c.textVisibility,
|
||||||
font = c.font,
|
font = c.font,
|
||||||
textColor = c.textColor,
|
textColor = c.textColor
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
return c
|
return c
|
||||||
@ -784,9 +778,7 @@ function gui:newTextButton(txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
love.mouse.setCursor(cursor_hand)
|
love.mouse.setCursor(cursor_hand)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
c.OnExit(function(c, x, y, dx, dy, istouch)
|
c.OnExit(function(c, x, y, dx, dy, istouch) love.mouse.setCursor() end)
|
||||||
love.mouse.setCursor()
|
|
||||||
end)
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -807,12 +799,16 @@ local function getTextPosition(text, self, mx, my, exact)
|
|||||||
for i = 1, #text do
|
for i = 1, #text do
|
||||||
|
|
||||||
local _w = font:getWidth(text:sub(i, i))
|
local _w = font:getWidth(text:sub(i, i))
|
||||||
local x, y, w, h = math.floor(width + self.adjust + self.textOffsetX), 0, _w, height
|
local x, y, w, h = math.floor(width + self.adjust + self.textOffsetX),
|
||||||
|
0, _w, height
|
||||||
|
|
||||||
width = width + _w
|
width = width + _w
|
||||||
|
|
||||||
if not (mx > x + w or mx < x or my > y + h or my < y) then
|
if not (mx > x + w or mx < x or my > y + h or my < y) then
|
||||||
if not(exact) and (_w - (width - (mx - math.floor(self.adjust + self.textOffsetX))) < _w/2 and i >= 1) then
|
if not (exact) and
|
||||||
|
(_w -
|
||||||
|
(width - (mx - math.floor(self.adjust + self.textOffsetX))) <
|
||||||
|
_w / 2 and i >= 1) then
|
||||||
return i - 1
|
return i - 1
|
||||||
else
|
else
|
||||||
return i
|
return i
|
||||||
@ -839,7 +835,7 @@ function gui:newTextBox(txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
return gui.getUniques(c, {
|
return gui.getUniques(c, {
|
||||||
doSelection = c.doSelection,
|
doSelection = c.doSelection,
|
||||||
cur_pos = c.cur_pos,
|
cur_pos = c.cur_pos,
|
||||||
adjust = c.adjust,
|
adjust = c.adjust
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -849,9 +845,7 @@ function gui:newTextBox(txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
|
|
||||||
function c:GetSelection()
|
function c:GetSelection()
|
||||||
local start, stop = c.selection[1], c.selection[2]
|
local start, stop = c.selection[1], c.selection[2]
|
||||||
if start > stop then
|
if start > stop then start, stop = stop, start end
|
||||||
start, stop = stop, start
|
|
||||||
end
|
|
||||||
return start, stop
|
return start, stop
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -871,9 +865,7 @@ function gui:newTextBox(txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
love.mouse.setCursor(love.mouse.getSystemCursor("ibeam"))
|
love.mouse.setCursor(love.mouse.getSystemCursor("ibeam"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
c.OnExit(function(c, x, y, dx, dy, istouch)
|
c.OnExit(function(c, x, y, dx, dy, istouch) love.mouse.setCursor(cur) end)
|
||||||
love.mouse.setCursor(cur)
|
|
||||||
end)
|
|
||||||
|
|
||||||
c.OnPressed(function(c, x, y, dx, dy, istouch)
|
c.OnPressed(function(c, x, y, dx, dy, istouch)
|
||||||
object_focus.bar_show = true
|
object_focus.bar_show = true
|
||||||
@ -900,9 +892,7 @@ function gui:newTextBox(txt, x, y, w, h, sx, sy, sw, sh)
|
|||||||
c.selection = {0, 0}
|
c.selection = {0, 0}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
c.OnPressedOuter(function()
|
c.OnPressedOuter(function() c.bar_show = false end)
|
||||||
c.bar_show = false
|
|
||||||
end)
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -922,18 +912,16 @@ end)
|
|||||||
local function insert(obj, n_text)
|
local function insert(obj, n_text)
|
||||||
if obj:HasSelection() then
|
if obj:HasSelection() then
|
||||||
local start, stop = obj:GetSelection()
|
local start, stop = obj:GetSelection()
|
||||||
obj.text = obj.text:sub(1, start - 1) .. n_text .. obj.text:sub(stop + 1, -1)
|
obj.text = obj.text:sub(1, start - 1) .. n_text ..
|
||||||
|
obj.text:sub(stop + 1, -1)
|
||||||
obj:ClearSelection()
|
obj:ClearSelection()
|
||||||
obj.cur_pos = start
|
obj.cur_pos = start
|
||||||
if #n_text > 1 then
|
if #n_text > 1 then obj.cur_pos = start + #n_text end
|
||||||
obj.cur_pos = start + #n_text
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
obj.text = obj.text:sub(1, obj.cur_pos) .. n_text .. obj.text:sub(obj.cur_pos + 1,-1)
|
obj.text = obj.text:sub(1, obj.cur_pos) .. n_text ..
|
||||||
|
obj.text:sub(obj.cur_pos + 1, -1)
|
||||||
obj.cur_pos = obj.cur_pos + 1
|
obj.cur_pos = obj.cur_pos + 1
|
||||||
if #n_text > 1 then
|
if #n_text > 1 then obj.cur_pos = obj.cur_pos + #n_text end
|
||||||
obj.cur_pos = obj.cur_pos + #n_text
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -945,11 +933,15 @@ local function delete(obj, cmd)
|
|||||||
obj.cur_pos = start - 1
|
obj.cur_pos = start - 1
|
||||||
else
|
else
|
||||||
if cmd == "delete" then
|
if cmd == "delete" then
|
||||||
obj.text = obj.text:sub(1, obj.cur_pos) .. obj.text:sub(obj.cur_pos + 2, -1)
|
obj.text = obj.text:sub(1, obj.cur_pos) ..
|
||||||
|
obj.text:sub(obj.cur_pos + 2, -1)
|
||||||
else
|
else
|
||||||
obj.text = obj.text:sub(1, obj.cur_pos - 1) .. obj.text:sub(obj.cur_pos + 1, -1)
|
obj.text = obj.text:sub(1, obj.cur_pos - 1) ..
|
||||||
|
obj.text:sub(obj.cur_pos + 1, -1)
|
||||||
object_focus.cur_pos = object_focus.cur_pos - 1
|
object_focus.cur_pos = object_focus.cur_pos - 1
|
||||||
if object_focus.cur_pos == 0 then object_focus.cur_pos = 1 end
|
if object_focus.cur_pos == 0 then
|
||||||
|
object_focus.cur_pos = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -965,9 +957,7 @@ gui.HotKeys.OnSelectAll(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
gui.Events.OnTextInputed(function(text)
|
gui.Events.OnTextInputed(function(text)
|
||||||
if object_focus:hasType(box) then
|
if object_focus:hasType(box) then insert(object_focus, text) end
|
||||||
insert(object_focus, text)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
gui.HotKeys.OnCopy(function()
|
gui.HotKeys.OnCopy(function()
|
||||||
@ -1019,9 +1009,25 @@ function gui:newImageBase(typ,x, y, w, h, sx, sy, sw, sh)
|
|||||||
DO = {[[setImage]], c.image or IMAGE}
|
DO = {[[setImage]], c.image or IMAGE}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
function c:setImage(i)
|
function c:setImage(i, x, y, w, h)
|
||||||
if i == nil then return end
|
if i == nil then return end
|
||||||
IMAGE = i
|
IMAGE = i
|
||||||
|
if type(i) == "string" then i = image_cache[i] or i end
|
||||||
|
if i and x then
|
||||||
|
self.imageHeigth = h
|
||||||
|
self.imageWidth = w
|
||||||
|
if type(i) == "string" then
|
||||||
|
image_cache[i] = love.graphics.newImage(i)
|
||||||
|
i = image_cache[i]
|
||||||
|
end
|
||||||
|
self.image = i
|
||||||
|
self.image:setWrap("repeat","repeat")
|
||||||
|
self.imageColor = color.white
|
||||||
|
self.quad = love.graphics.newQuad(x, y, w, h, self.image:getWidth(), self.image:getHeight())
|
||||||
|
self.imageVisibility = 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if not first_loop then
|
if not first_loop then
|
||||||
-- Wait one cycle for things to load up
|
-- Wait one cycle for things to load up
|
||||||
drawer:newThread(function()
|
drawer:newThread(function()
|
||||||
@ -1033,6 +1039,7 @@ function gui:newImageBase(typ,x, y, w, h, sx, sy, sw, sh)
|
|||||||
img = love.graphics.newImage(i)
|
img = love.graphics.newImage(i)
|
||||||
else
|
else
|
||||||
img = love.graphics.newImage(i)
|
img = love.graphics.newImage(i)
|
||||||
|
image_cache[i] = love.image.newImageData(i)
|
||||||
end
|
end
|
||||||
local x, y, w, h = self:getAbsolutes()
|
local x, y, w, h = self:getAbsolutes()
|
||||||
self.imageColor = color.white
|
self.imageColor = color.white
|
||||||
@ -1040,7 +1047,8 @@ function gui:newImageBase(typ,x, y, w, h, sx, sy, sw, sh)
|
|||||||
self.image = img
|
self.image = img
|
||||||
self.imageHeigth = img:getHeight()
|
self.imageHeigth = img:getHeight()
|
||||||
self.imageWidth = img:getWidth()
|
self.imageWidth = img:getWidth()
|
||||||
self.quad = love.graphics.newQuad(0, 0, w, h, self.imageWidth, self.imageHeigth)
|
self.quad = love.graphics.newQuad(0, 0, w, h, self.imageWidth,
|
||||||
|
self.imageHeigth)
|
||||||
end)
|
end)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1056,7 +1064,8 @@ function gui:newImageBase(typ,x, y, w, h, sx, sy, sw, sh)
|
|||||||
self.image = img
|
self.image = img
|
||||||
self.imageHeigth = img:getHeight()
|
self.imageHeigth = img:getHeight()
|
||||||
self.imageWidth = img:getWidth()
|
self.imageWidth = img:getWidth()
|
||||||
self.quad = love.graphics.newQuad(0, 0, w, h, self.imageWidth, self.imageHeigth)
|
self.quad = love.graphics.newQuad(0, 0, w, h, self.imageWidth,
|
||||||
|
self.imageHeigth)
|
||||||
end
|
end
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -1076,9 +1085,7 @@ function gui:newImageButton(source, x, y, w, h, sx, sy, sw, sh)
|
|||||||
love.mouse.setCursor(cursor_hand)
|
love.mouse.setCursor(cursor_hand)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
c.OnExit(function(c, x, y, dx, dy, istouch)
|
c.OnExit(function(c, x, y, dx, dy, istouch) love.mouse.setCursor() end)
|
||||||
love.mouse.setCursor()
|
|
||||||
end)
|
|
||||||
|
|
||||||
return c
|
return c
|
||||||
end
|
end
|
||||||
@ -1096,21 +1103,15 @@ function gui:newVideo(source, x, y, w, h, sx, sy, sw, sh)
|
|||||||
c.video = v
|
c.video = v
|
||||||
end
|
end
|
||||||
c.audiosource = c.video:getSource()
|
c.audiosource = c.video:getSource()
|
||||||
if c.audiosource then
|
if c.audiosource then c.audioLength = c.audiosource:getDuration() end
|
||||||
c.audioLength = c.audiosource:getDuration()
|
|
||||||
end
|
|
||||||
c.videoHeigth = c.video:getHeight()
|
c.videoHeigth = c.video:getHeight()
|
||||||
c.videoWidth = c.video:getWidth()
|
c.videoWidth = c.video:getWidth()
|
||||||
c.quad = love.graphics.newQuad(0, 0, w, h, c.videoWidth, c.videoHeigth)
|
c.quad = love.graphics.newQuad(0, 0, w, h, c.videoWidth, c.videoHeigth)
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:getVideo()
|
function c:getVideo() return self.video end
|
||||||
return self.video
|
|
||||||
end
|
|
||||||
|
|
||||||
if type(source)=="string" then
|
if type(source) == "string" then c:setVideo(source) end
|
||||||
c:setVideo(source)
|
|
||||||
end
|
|
||||||
|
|
||||||
function c:play()
|
function c:play()
|
||||||
c.playing = true
|
c.playing = true
|
||||||
@ -1118,14 +1119,10 @@ function gui:newVideo(source, x, y, w, h, sx, sy, sw, sh)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function c:setVolume(vol)
|
function c:setVolume(vol)
|
||||||
if self.audiosource then
|
if self.audiosource then self.audiosource:setVolume(vol) end
|
||||||
self.audiosource:setVolume(vol)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:pause()
|
function c:pause() c.video:pause() end
|
||||||
c.video:pause()
|
|
||||||
end
|
|
||||||
|
|
||||||
function c:stop()
|
function c:stop()
|
||||||
c.playing = false
|
c.playing = false
|
||||||
@ -1133,17 +1130,11 @@ function gui:newVideo(source, x, y, w, h, sx, sy, sw, sh)
|
|||||||
c.video:rewind()
|
c.video:rewind()
|
||||||
end
|
end
|
||||||
|
|
||||||
function c:rewind()
|
function c:rewind() c.video:rewind() end
|
||||||
c.video:rewind()
|
|
||||||
end
|
|
||||||
|
|
||||||
function c:seek(n)
|
function c:seek(n) c.video:seek(n) end
|
||||||
c.video:seek(n)
|
|
||||||
end
|
|
||||||
|
|
||||||
function c:tell()
|
function c:tell() return c.video:tell() end
|
||||||
return c.video:tell()
|
|
||||||
end
|
|
||||||
|
|
||||||
c:newThread(function(self)
|
c:newThread(function(self)
|
||||||
|
|
||||||
@ -1158,9 +1149,7 @@ function gui:newVideo(source, x, y, w, h, sx, sy, sw, sh)
|
|||||||
return self.video:isPlaying()
|
return self.video:isPlaying()
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do thread.chain(isplaying, testCompletion) end
|
||||||
thread.chain(isplaying, testCompletion)
|
|
||||||
end
|
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -1177,16 +1166,14 @@ local drawtypes = {
|
|||||||
[0] = function(child, x, y, w, h) end,
|
[0] = function(child, x, y, w, h) end,
|
||||||
[1] = function(child, x, y, w, h)
|
[1] = function(child, x, y, w, h)
|
||||||
if child.image then
|
if child.image then
|
||||||
love.graphics.setColor(child.imageColor[1],child.imageColor[2],child.imageColor[3],child.imageVisibility)
|
love.graphics.setColor(child.imageColor[1], child.imageColor[2],
|
||||||
if w~=child.imageWidth and h~=child.imageHeigth then
|
child.imageColor[3], child.imageVisibility)
|
||||||
love.graphics.draw(child.image,x,y,rad(child.rotation),w/child.imageWidth,h/child.imageHeigth)
|
|
||||||
else
|
|
||||||
love.graphics.draw(child.image, child.quad, x, y, rad(child.rotation), w / child.imageWidth, h / child.imageHeigth)
|
love.graphics.draw(child.image, child.quad, x, y, rad(child.rotation), w / child.imageWidth, h / child.imageHeigth)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
[2] = function(child, x, y, w, h)
|
[2] = function(child, x, y, w, h)
|
||||||
love.graphics.setColor(child.textColor[1],child.textColor[2],child.textColor[3],child.textVisibility)
|
love.graphics.setColor(child.textColor[1], child.textColor[2],
|
||||||
|
child.textColor[3], child.textVisibility)
|
||||||
love.graphics.setFont(child.font)
|
love.graphics.setFont(child.font)
|
||||||
if child.align == gui.ALIGN_LEFT then
|
if child.align == gui.ALIGN_LEFT then
|
||||||
child.adjust = 0
|
child.adjust = 0
|
||||||
@ -1197,40 +1184,49 @@ local drawtypes = {
|
|||||||
local fw = child.font:getWidth(child.text)
|
local fw = child.font:getWidth(child.text)
|
||||||
child.adjust = w - fw - 4
|
child.adjust = w - fw - 4
|
||||||
end
|
end
|
||||||
love.graphics.printf(child.text, child.adjust + x + child.textOffsetX, y + child.textOffsetY, w, "left", child.rotation, child.textScaleX, child.textScaleY, 0, 0, child.textShearingFactorX, child.textShearingFactorY)
|
love.graphics.printf(child.text, child.adjust + x + child.textOffsetX,
|
||||||
|
y + child.textOffsetY, w, "left", child.rotation,
|
||||||
|
child.textScaleX, child.textScaleY, 0, 0,
|
||||||
|
child.textShearingFactorX,
|
||||||
|
child.textShearingFactorY)
|
||||||
end,
|
end,
|
||||||
[4] = function(child, x, y, w, h)
|
[4] = function(child, x, y, w, h)
|
||||||
if child.bar_show then
|
if child.bar_show then
|
||||||
local font = child.font
|
local font = child.font
|
||||||
local fh = font:getHeight()
|
local fh = font:getHeight()
|
||||||
local fw = font:getWidth(child.text:sub(1, child.cur_pos))
|
local fw = font:getWidth(child.text:sub(1, child.cur_pos))
|
||||||
love.graphics.line(child.textOffsetX + child.adjust + x + fw, y + 4, child.textOffsetX + child.adjust + x + fw, y + fh - 2)
|
love.graphics.line(child.textOffsetX + child.adjust + x + fw, y + 4,
|
||||||
|
child.textOffsetX + child.adjust + x + fw,
|
||||||
|
y + fh - 2)
|
||||||
end
|
end
|
||||||
if child:HasSelection() then
|
if child:HasSelection() then
|
||||||
local blue = color.highlighter_blue
|
local blue = color.highlighter_blue
|
||||||
local start, stop = child.selection[1], child.selection[2]
|
local start, stop = child.selection[1], child.selection[2]
|
||||||
if start > stop then
|
if start > stop then start, stop = stop, start end
|
||||||
start, stop = stop, start
|
|
||||||
end
|
|
||||||
local x1, y1 = child.font:getWidth(child.text:sub(1, start - 1)), 0
|
local x1, y1 = child.font:getWidth(child.text:sub(1, start - 1)), 0
|
||||||
local x2, y2 = child.font:getWidth(child.text:sub(1, stop)), h
|
local x2, y2 = child.font:getWidth(child.text:sub(1, stop)), h
|
||||||
love.graphics.setColor(blue[1], blue[2], blue[3], .5)
|
love.graphics.setColor(blue[1], blue[2], blue[3], .5)
|
||||||
love.graphics.rectangle("fill", x + x1 + child.adjust, y + y1, x2 - x1, y2 - y1)
|
love.graphics.rectangle("fill", x + x1 + child.adjust, y + y1,
|
||||||
|
x2 - x1, y2 - y1)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
[8] = function(child, x, y, w, h)
|
[8] = function(child, x, y, w, h)
|
||||||
if child.video and child.playing then
|
if child.video and child.playing then
|
||||||
love.graphics.setColor(child.videoColor[1],child.videoColor[2],child.videoColor[3],child.videoVisibility)
|
love.graphics.setColor(child.videoColor[1], child.videoColor[2],
|
||||||
|
child.videoColor[3], child.videoVisibility)
|
||||||
if w ~= child.imageWidth and h ~= child.imageHeigth then
|
if w ~= child.imageWidth and h ~= child.imageHeigth then
|
||||||
love.graphics.draw(child.video,x,y,rad(child.rotation),w/child.videoWidth,h/child.videoHeigth)
|
love.graphics.draw(child.video, x, y, rad(child.rotation),
|
||||||
|
w / child.videoWidth, h / child.videoHeigth)
|
||||||
else
|
else
|
||||||
love.graphics.draw(child.video,child.quad,x,y,rad(child.rotation),w/child.videoWidth,h/child.videoHeigth)
|
love.graphics.draw(child.video, child.quad, x, y,
|
||||||
|
rad(child.rotation), w / child.videoWidth,
|
||||||
|
h / child.videoHeigth)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
[16] = function(child, x, y, w, h)
|
[16] = function(child, x, y, w, h)
|
||||||
--
|
--
|
||||||
end,
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
local draw_handler = function(child)
|
local draw_handler = function(child)
|
||||||
@ -1240,7 +1236,8 @@ local draw_handler = function(child)
|
|||||||
local vis = child.visibility
|
local vis = child.visibility
|
||||||
local x, y, w, h = child:getAbsolutes()
|
local x, y, w, h = child:getAbsolutes()
|
||||||
local roundness = child.roundness
|
local roundness = child.roundness
|
||||||
local rx, ry, segments = child.__rx or 0, child.__ry or 0, child.__segments or 0
|
local rx, ry, segments = child.__rx or 0, child.__ry or 0,
|
||||||
|
child.__segments or 0
|
||||||
child.x = x
|
child.x = x
|
||||||
child.y = y
|
child.y = y
|
||||||
child.w = w
|
child.w = w
|
||||||
@ -1262,7 +1259,7 @@ local draw_handler = function(child)
|
|||||||
local clip = child.__variables.clip
|
local clip = child.__variables.clip
|
||||||
love.graphics.setScissor(clip[2], clip[3], clip[4], clip[5])
|
love.graphics.setScissor(clip[2], clip[3], clip[4], clip[5])
|
||||||
elseif type(roundness) == "string" then
|
elseif type(roundness) == "string" then
|
||||||
love.graphics.setScissor(x - 1, y, w + 2, h + 3)
|
love.graphics.setScissor(x - 1, y - 2, w + 2, h + 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set color
|
-- Set color
|
||||||
@ -1278,9 +1275,7 @@ local draw_handler = function(child)
|
|||||||
|
|
||||||
love.graphics.setColor(bbg[1], bbg[2], bbg[3], 1)
|
love.graphics.setColor(bbg[1], bbg[2], bbg[3], 1)
|
||||||
love.graphics.setLineWidth(1)
|
love.graphics.setLineWidth(1)
|
||||||
love.graphics.line( x, y + ry,
|
love.graphics.line(x, y + ry, x, y + h + 1, x + 1 + w, y + h + 1,
|
||||||
x, y + h +1,
|
|
||||||
x + 1 + w, y + h+1,
|
|
||||||
x + 1 + w, y + ry)
|
x + 1 + w, y + ry)
|
||||||
love.graphics.line(x, y + h, x + 1 + w, y + h)
|
love.graphics.line(x, y + h, x + 1 + w, y + h)
|
||||||
love.graphics.setScissor()
|
love.graphics.setScissor()
|
||||||
@ -1292,9 +1287,7 @@ local draw_handler = function(child)
|
|||||||
love.graphics.setLineStyle("rough")
|
love.graphics.setLineStyle("rough")
|
||||||
love.graphics.setColor(bbg[1], bbg[2], bbg[3], 1)
|
love.graphics.setColor(bbg[1], bbg[2], bbg[3], 1)
|
||||||
love.graphics.setLineWidth(2)
|
love.graphics.setLineWidth(2)
|
||||||
love.graphics.line( x-1, y + ry + 1,
|
love.graphics.line(x - 1, y + ry + 1, x - 1, y - 1, x + w + 1, y - 1,
|
||||||
x-1, y - 1,
|
|
||||||
x + w + 1, y - 1,
|
|
||||||
x + w + 1, y + ry + 1)
|
x + w + 1, y + ry + 1)
|
||||||
love.graphics.setScissor()
|
love.graphics.setScissor()
|
||||||
love.graphics.line(x - 1, y - 1, x + w + 1, y - 1)
|
love.graphics.line(x - 1, y - 1, x + w + 1, y - 1)
|
||||||
@ -1310,9 +1303,7 @@ local draw_handler = function(child)
|
|||||||
drawtypes[band(ctype, image)](child, x, y, w, h)
|
drawtypes[band(ctype, image)](child, x, y, w, h)
|
||||||
drawtypes[band(ctype, text)](child, x, y, w, h)
|
drawtypes[band(ctype, text)](child, x, y, w, h)
|
||||||
drawtypes[band(ctype, box)](child, x, y, w, h)
|
drawtypes[band(ctype, box)](child, x, y, w, h)
|
||||||
if child.post then
|
if child.post then child:post() end
|
||||||
child:post()
|
|
||||||
end
|
|
||||||
if child.__variables.clip[1] then
|
if child.__variables.clip[1] then
|
||||||
love.graphics.setScissor() -- Remove the scissor
|
love.graphics.setScissor() -- Remove the scissor
|
||||||
end
|
end
|
||||||
@ -1323,9 +1314,7 @@ drawer:newLoop(function()
|
|||||||
for i = 1, #children do
|
for i = 1, #children do
|
||||||
local child = children[i]
|
local child = children[i]
|
||||||
if child.effect then
|
if child.effect then
|
||||||
child.effect(function()
|
child.effect(function() draw_handler(child) end)
|
||||||
draw_handler(child)
|
|
||||||
end)
|
|
||||||
else
|
else
|
||||||
draw_handler(child)
|
draw_handler(child)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user