Reformatted library

This commit is contained in:
Ryan Ward 2023-01-17 22:21:53 -05:00
parent c4b4ab3bd2
commit 80e678ce35
111 changed files with 1 additions and 9750 deletions

2
.gitattributes vendored
View File

@ -1,2 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto

6
.gitignore vendored
View File

@ -1,6 +0,0 @@
main.lua
conf.lua
*.ttf
*.png
*.ogv
*deck

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "multi"]
path = multi
url = https://github.com/rayaman/multi

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +0,0 @@
local buttonConv = {"l","r","m","x1","x2"} -- For the old stuff
function gui:OnClicked(func)
if not self.clickEvnt then
self.clickEvnt = true
self._connClicked = multi:newConnection()
self._connClicked(func)
multi:newThread(self.Name.."_Updater",function()
while true do
thread.hold(function() return self.Active or self.Destroyed end)
if love.mouse.isDown(1) and self:canPress() then
self._connClicked:Fire("1",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y)
end
if love.mouse.isDown(2) and self:canPress() then
self._connClicked:Fire("r",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y)
end
if love.mouse.isDown(3) and self:canPress() then
self._connClicked:Fire("m",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y)
end
if love.mouse.isDown(4) and self:canPress() then
self._connClicked:Fire("x1",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y)
end
if love.mouse.isDown(5) and self:canPress() then
self._connClicked:Fire("x2",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y)
end
if self.Destroyed then
thread.kill()
end
end
end)
else
self._connClicked(func)
end
end
function gui:OnPressed(func)
multi.OnMousePressed(function(x,y,b)
if self:canPress() then
func(buttonConv[b],self,x,y)
end
end)
end
function gui:OnPressedOuter(func)
multi.OnMousePressed(function(x,y,b)
if not(self:canPress()) then
func(buttonConv[b],self)
end
end,nil,1)
end
function gui:OnReleased(func)
multi.OnMouseReleased(function(x,y,b)
if self:canPress() then
func(buttonConv[b],self,x,y)
end
end)
end
function gui:OnReleasedOuter(func)
multi.OnMouseReleased(function(x,y,b)
if not(self:canPress()) then
func(buttonConv[b],self)
end
end,nil,1)
end
function gui:OnUpdate(func)
if not self.updateEvnt then
self._connUpdate = multi:newConnection()
self._connUpdate(func)
self.updateEvnt = true
multi:newThread(self.Name.."_Updater",function()
while true do
thread.hold(function() return self.Active end)
self._connUpdate:Fire(self)
end
end)
else
self._connUpdate(func)
end
end
function gui:OnMouseMoved(func)
multi.OnMouseMoved(function(x,y,dx,dy)
if self:canPress() then
func(self,x-self.x,y-self.y,dx,dy)
end
end,nil,1)
end
gui.WhileHovering=gui.OnMouseMoved -- To keep older features working
local mbenter = multi:newConnection()
function gui:OnMouseEnter(func)
self.HE=false
mbenter(func)
self:OnMouseMoved(function()
if self.HE == false then
self.HE=true
self._HE = true
mbenter:Fire(self)
end
end)
end
function gui:OnMouseExit(func)
if not self.exitEvnt then
self._connExit = multi:newConnection()
self._connExit(func)
self.exitEvnt = true
self.HE=false
multi:newThread(self.Name.."_OnExit",function()
while true do
thread.hold(function() return self.HE or self.Destroyed end)
if not(self:canPress()) then
self.HE=false
self._connExit:Fire(self)
end
if self.Destroyed then
thread.kill()
end
end
end)
else
self._connExit(func)
end
end
--[[
x=(love.mouse.getX()-self.x)
y=(love.mouse.getY()-self.y)
self:Move(x,y)
]]
function gui:OnMouseWheelMoved(func)
multi.OnMouseWheelMoved(function(...)
if self:canPress() then
func(self,...)
end
end)
end
function gui:enableDragging(bool)
self.draggable = bool
if self.dragEvnt then
return
end
self.dragEvnt = true
self._connDragStart = multi:newConnection()
self._connDragging = multi:newConnection()
self._connDragEnd = multi:newConnection()
self.hasDrag = false
local startX
local startY
self:OnPressed(function(b,self,x,y)
if b~=self.dragbut or not(self.draggable) then return end
self._connDragStart:Fire(self)
self.hasDrag = true
startX = x
startY = y
end)
multi.OnMouseMoved(function(x,y,dx,dy)
if self.hasDrag and self.draggable then
self:Move(dx,dy)
self._connDragging:Fire(self)
end
end)
multi.OnMouseReleased(function(x,y,b)
if buttonConv[b]~=self.dragbut or not(self.draggable) or not(self.hasDrag) then return end
self.hasDrag = false
startX = nil
startY = nil
self._connDragEnd:Fire(self)
end)
end
function gui:OnDragStart(func)
if not self.dragEvnt then
self:enableDragging(true)
self._connDragStart(func)
else
self._connDragStart(func)
end
end
function gui:OnDragging(func)
if not self.dragEvnt then
self:enableDragging(true)
self._connDragging(func)
else
self._connDragging(func)
end
end
function gui:OnDragEnd(func)
if not self.dragEvnt then
self:enableDragging(true)
self._connDragEnd(func)
else
self._connDragEnd(func)
end
end
function gui:OnHotKey(key,func)
local tab=key:split("+")
multi.OnKeyPressed(function()
for i=1,#tab do
if not(love.keyboard.isDown(tab[i])) then
return
end
end
func(self)
end)
end
gui.addHotKey=gui.OnHotKey
gui.setHotKey=gui.OnHotKey

View File

@ -1,25 +0,0 @@
function GetAllChildren(Object)
local Stuff = {}
function Seek(Items)
for i=1,#Items do
if Items[i].Visible==true then
table.insert(Stuff,Items[i])
local NItems = Items[i]:getChildren()
if NItems ~= nil then
Seek(NItems)
end
end
end
end
local Objs = Object:getChildren()
for i=1,#Objs do
if Objs[i].Visible==true then
table.insert(Stuff,Objs[i])
local Items = Objs[i]:getChildren()
if Items ~= nil then
Seek(Items)
end
end
end
return Stuff
end

View File

@ -1,21 +0,0 @@
function GetAllChildren2(Object)
local Stuff = {}
function Seek(Items)
for i=1,#Items do
table.insert(Stuff,Items[i])
local NItems = Items[i]:getChildren()
if NItems ~= nil then
Seek(NItems)
end
end
end
local Objs = Object:getChildren()
for i=1,#Objs do
table.insert(Stuff,Objs[i])
local Items = Objs[i]:getChildren()
if Items ~= nil then
Seek(Items)
end
end
return Stuff
end

View File

@ -1,72 +0,0 @@
function gui:getParents()
local c,me = {}, self.Parent
while me.Parent~=nil do
c[#c+1]=me
me = me.Parent
end
return c
end
function gui:eventable()
if self.important then
return true
end
if _GuiPro.Hierarchy then
if _GuiPro.TopHovered~=nil then
return self:isDescendant(_GuiPro.TopHovered) or _GuiPro.TopHovered==self
else
return true
end
else
return true
end
end
function gui:parentVisible()
local c = self:getParents()
for i=#c,1,-1 do
if not c[i].Visible then return false end
end
return true
end
function gui:isBeingCovering()
return false
-- if self.allowOverlapping then return false end
-- local ref = self.FrameRef or gui
-- local x,y = love.mouse.getX(),love.mouse.getY()
-- for i = 1,#_GuiPro.Frames do
-- if _GuiPro.Frames[i]~=ref then
-- if (ref.depth or 0)<(_GuiPro.Frames[i].depth or math.huge) then
-- local pos = (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height) and (x > _GuiPro.Frames[i].x and x < _GuiPro.Frames[i].x+_GuiPro.Frames[i].width and y > _GuiPro.Frames[i].y and y < _GuiPro.Frames[i].y+_GuiPro.Frames[i].height) and (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height )
-- if not pos then return true end
-- end
-- end
-- end
end
function gui:Clickable()
local x,y,w,h=love.graphics.getScissor()
local mx=love.mouse.getX()
local my=love.mouse.getY()
if _GuiPro.HasStencel then
local obj=_GuiPro.StencelHolder
if self:isDescendant(obj) then
return math.sqrt((mx-obj.x)^2+(my-obj.y)^2)<=(obj.offset.size.x or 0)
end
end
if not(x) then
return true
end
return not(mx>x+w or mx<x or my>y+h or my<y)
end
function gui:canPress()
local ref = self
if self.ClipReference then ref = self.ClipReference end
if self.Visible==true and self:parentVisible() and not(self:isBeingCovering()) then
local x,y = love.mouse.getX(),love.mouse.getY()
if (x > ref.x and x < ref.x+ref.width and y > ref.y and y < ref.y+ref.height) and (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height and self:Clickable() and (self:eventable() or self:touchable())) then
return true
else
return false
end
else
return false
end
end

View File

@ -1,3 +0,0 @@
function gui:full()
self:SetDualDim(nil,nil,nil,nil,nil,nil,1,1)
end

View File

@ -1,167 +0,0 @@
_GuiPro.Frames = {}
_GuiPro.Type = "Window"
_GuiPro.depth = 0
function gui.enableAutoWindowScaling(b)
_GuiPro.DPI_ENABLED=b or true
_defaultfont=love.graphics.newFont(12*love.window.getPixelScale())
end
function filter(name, x, y, w, h, sx ,sy ,sw ,sh)
if type(name)~="string" then
sh=sw
sw=sy
sy=sx
sx=h
h=w
w=y
y=x
x=name
end
return x,y,w,h,sx,sy,sw,sh
end
function gui:getChildren()
return self.Children
end
function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
_GuiPro.count=_GuiPro.count+1
local c = {}
setmetatable(c, gui)
if self==gui then
c.Parent=_GuiPro
else
c.Parent=self
end
if tp:match("Frame") then
_GuiPro.Frames[#_GuiPro.Frames+1] = c
end
if self.Type and self.Type:match("Frame") then
c.FrameRef = self
else
c.FrameRef = self.FrameRef
end
c.segments=nil
c.ry=nil
c.rx=nil
c.DPI=1
c.isLeaf = true
c.Parent.isLeaf = false
if _GuiPro.DPI_ENABLED then
c.DPI=love.window.getPixelScale()
x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
end
c.centerFontY=true
c.FormFactor="rectangle"
c.Type=tp
c.Active=true
c.form="rectangle"
c.Draggable=false
c.Name=name or "Gui"..tp
c:SetName(name)
c.BorderSize=1
c.BorderColor={0,0,0}
c.VIS=true
c.Visible=true
c.oV=true
c.Children={}
c.hovering=false
c.rclicked=false
c.lclicked=false
c.mclicked=false
c.clicked=false
c.Visibility=1
c.TextWrap=true
c.scale={}
c.scale.size={}
c.scale.size.x=sw or 0
c.scale.size.y=sh or 0
c.offset={}
c.offset.size={}
c.offset.size.x=w or 0
c.offset.size.y=h or 0
c.scale.pos={}
c.scale.pos.x=sx or 0
c.scale.pos.y=sy or 0
c.offset.pos={}
c.offset.pos.x=x or 0
c.offset.pos.y=y or 0
c.width = 0
c.height = 0
c.LRE=false
c.RRE=false
c.MRE=false
c.Color = {255, 255, 255}
function c:setRoundness(rx,ry,segments)
self.segments=segments
self.ry=ry
self.rx=rx
end
function c.stfunc()
love.graphics.rectangle("fill", c.x, c.y, c.width, c.height,c.rx,c.ry,c.segments)
end
function c:hasRoundness()
return (self.ry or self.rx)
end
c.tid={}
c.touchcount=0
c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x
c.y=(c.Parent.height*c.scale.pos.y)+c.offset.pos.y+c.Parent.y
c.width=(c.Parent.width*c.scale.size.x)+c.offset.size.x
c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y
function c:ImageRule()
if self.Image then
local sx=self.width/self.ImageWidth
local sy=self.height/self.ImageHeigth
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255)
if self.width~=self.ImageWidth and self.height~=self.ImageHeigth then
love.graphics.draw(self.Image,self.x,self.y,math.rad(self.rotation),sx,sy)
else
love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy)
end
end
end
function c:VideoRule()
if self.Video then
local sx=self.width/self.VideoWidth
local sy=self.height/self.VideoHeigth
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.VideoVisibility*255)
if self.width~=self.VideoWidth and self.height~=self.VideoHeigth then
love.graphics.draw(self.Video,self.x,self.y,math.rad(self.rotation),sx,sy)
else
love.graphics.draw(self.Video,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy)
end
end
end
function c:repeatImage(b,b2)
if b then
self.Image:setWrap(b,b2 or "repeat")
function self:ImageRule()
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255)
love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation))
end
else
sx=self.width/self.ImageWidth
sy=self.height/self.ImageHeigth
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255)
love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy)
end
end
function c:Mutate(t)
for i,v in pairs(t) do
_GuiPro.self=self
if type(i)=="number" then
loadstring("_GuiPro.self:"..v)()
elseif i:match"__self__" then
local ind=i:match"__self__(.+)"
if not self[ind] then self[ind]={} end
loadstring("_GuiPro.self."..ind.."=_GuiPro.self:"..v)()
elseif i:match"__child__" then
local ind,child = i:match"__child__(%S-)_(.+)"
self[ind][child]=v
else
self[i]=v
end
end
return self
end
table.insert(c.Parent.Children,c)
return c
end

View File

@ -1,7 +0,0 @@
_GuiPro.mousedownfunc=love.mouse.isDown
function love.mouse.isDown(b)
if not(b) then
return false
end
return _GuiPro.mousedownfunc(({["l"]=1,["r"]=2,["m"]=3})[b] or b)
end

View File

@ -1,40 +0,0 @@
function gui:toString() -- oh boy this is gonna be painful lol
multi:newThread("saving data: ",function()
local dat=bin.stream("test.dat",false)
function GetAllChildren2(Object)
local Stuff = {}
function Seek(Items)
for i=1,#Items do
--table.insert(Stuff,Items[i])
for a,v in pairs(Items[i]) do
-- dat:tackE(a.."|"..tostring(v))
print(a.."|"..tostring(v))
-- dat.workingfile:flush()
end
thread.skip()
local NItems = Items[i]:getChildren()
if NItems ~= nil then
Seek(NItems)
end
end
end
local Objs = Object:getChildren()
for i=1,#Objs do
-- table.insert(Stuff,Objs[i])
for a,v in pairs(Objs[i]) do
-- dat:tackE(a.."|"..tostring(v))
print(Objs[i].Type..":"..a.."|"..tostring(v))
-- dat.workingfile:flush()
end
thread.skip()
local Items = Objs[i]:getChildren()
if Items ~= nil then
Seek(Items)
end
end
-- dat:tofile("test.dat")
return Stuff
end
GetAllChildren2(self)
end)
end

View File

@ -1,204 +0,0 @@
--[[WORKING ON
doubleTap - UnFinished!
touchRendering - Broken
]]
function gui:TClickable(mx,my)
local x,y,w,h=love.graphics.getScissor()
if _GuiPro.HasStencel then
local obj=_GuiPro.StencelHolder
if self:isDescendant(obj) then
return math.sqrt((mx-obj.x)^2+(my-obj.y)^2)<=(obj.offset.size.x or 0)
end
end
if not(x) then
return true
end
return not(mx>x+w or mx<x or my>y+h or my<y)
end
function gui:touchable(t)
local touches = love.touch.getTouches()
local x,y=0,0
for i, id in ipairs(touches) do
if self.id==id then
x, y = love.touch.getPosition(id)
return (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height and self:TClickable(x,y) and self:eventable())
end
end
self.id=-1
end
--multi:newTask(function() -- A bit of post-loading haha
gui.touchpressed=multi:newConnection()
gui.touchreleased=multi:newConnection()
gui.touchmoved=multi:newConnection()
love.touchpressed=Library.convert(love.touchpressed or function() end)
love.touchreleased=Library.convert(love.touchreleased or function() end)
love.touchmoved=Library.convert(love.touchmoved or function() end)
love.touchpressed:inject(function(id, x, y, dx, dy, pressure) gui.touchpressed:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1)
love.touchreleased:inject(function(id, x, y, dx, dy, pressure) gui.touchreleased:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1)
love.touchmoved:inject(function(id, x, y, dx, dy, pressure) gui.touchmoved:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1)
_GuiPro.TouchReady=true
_GuiPro.TouchRegister={}
gui.touchpressed:connect(function(id, x, y, dx, dy, pressure)
for i,v in pairs(_GuiPro.TouchRegister) do
if #v.tid==0 then
if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then
v:addTID(id)
v.touchcount=1
for i=1,#v.ToFuncP do
v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1)
end
end
elseif not(v:hasTID(id)) then
if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then
v:addTID(id)
v.touchcount=v.touchcount+1
for i=1,#v.ToFuncP do
v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1)
end
end
end
end
end)
gui.touchreleased:connect(function(id, x, y, dx, dy, pressure)
for i,v in pairs(_GuiPro.TouchRegister) do
if v:hasTID(id) then
v:removeTID(id)
for i=1,#v.ToFuncR do
v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1)
end
end
end
end)
gui.touchmoved:connect(function(id, x, y, dx, dy, pressure)
for i,v in pairs(_GuiPro.TouchRegister) do
if v:hasTID(id) and (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then
for i=1,#v.ToFuncM do
v.ToFuncM[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1)
end
elseif v:hasTID(id) and not((x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable())) then
v:removeTID(id)
for i=1,#v.ToFuncR do
v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1)
end
end
end
end)
--end)
-- now that that is done lets set up some more post loading checks
_GuiPro.int=multi:newProcessor()
_GuiPro.int:Start()
_GuiPro.int:setJobSpeed(.001)
_GuiPro.EXACT=0
_GuiPro.LAX=.01
_GuiPro.LAZY=.05
-- now lets define the reg function
function gui.Compare(a,b,v,tp)
if tp==">" then
if (a+v>b or a-v>b) then
return true
end
elseif tp=="<" then
if (a+v<b or a-v<b) then
return true
end
elseif tp=="<=" then
if (a+v<=b or a-v<=b) then
return true
end
elseif tp==">=" then
if (a+v>=b or a-v>=b) then
return true
end
elseif tp=="==" then -- this one is gonna be tricky
if (a>=b-v and a<=b+v) or (b>=a-v and b<=a+v) then
return true
end
end
return false
end
function gui:regesterTouch()
local obj=self
obj.ToFuncP={}
obj.ToFuncM={}
obj.ToFuncR={}
obj.To2Func={}
obj.ToDTFunc={}
obj.touchRendering =_GuiPro.EXACT -- exact(0), lax(), #
function obj:removeTID(id)
for i=1,#self.tid do
if self.tid[i]==id then
table.remove(self.tid,i)
self.touchcount=self.touchcount-1
return
end
end
end
function obj:hasTID(id)
for i=1,#self.tid do
if self.tid[i]==id then
return true
end
end
return false
end
obj.txl1=0
obj.tyl1=0
obj.txl2=0
obj.tyl2=0
obj.LS=0
obj:OnUpdate(function(self)
if self.touchcount==2 then
local x1,y1=love.touch.getPosition( self.tid[1] )
local x2,y2=love.touch.getPosition( self.tid[2] )
local CS=math.sqrt((x2-x1)^2+(y2-y1)^2)
if gui.Compare(CS,self.LS,self.touchRendering,">") then
for i=1,#self.To2Func do
self.To2Func[i](self,CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y)
end
elseif gui.Compare(CS,self.LS,self.touchRendering,"<") then
for i=1,#self.To2Func do
self.To2Func[i](self,-CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y)
end
elseif gui.Compare(CS,self.LS,self.touchRendering,"==") then
for i=1,#self.To2Func do
self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y)
end
end
-- if self.txl1~=x1 or self.txl2~=x2 or self.tyl1~=y1 or self.tyl2~=y2 then
-- for i=1,#self.To2Func do
-- self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y)
-- end
-- end
self.LS=CS
self.txl1=x1
self.txl2=x2
self.tyl1=y1
self.tyl2=y2
end
end)
function obj:OnDoubleTap(func)
table.insert(self.ToDTFunc,func)
end
function obj:On2TouchMoved(func)
table.insert(self.To2Func,func)
end
function obj:addTID(id)
table.insert(self.tid,id)
end
function obj:OnTouchPressed(func)
table.insert(self.ToFuncP,func) -- event for touches
end
function obj:OnTouchReleased(func) -- event for touches
table.insert(self.ToFuncR,func)
end
function obj:OnTouchMoved(func) -- event for touches
table.insert(self.ToFuncM,func)
end
if _GuiPro.TouchReady then -- my sneaky test
print("Registred: "..tostring(obj))
table.insert(_GuiPro.TouchRegister,obj)
else
print("Attempting to register: "..tostring(obj))
_GuiPro.int:newJob(function() table.insert(_GuiPro.TouchRegister,obj) end) -- a sneaky way to ensure that your object gets registered eventually, even if you call the method before the touch patch was activated.
end
end

View File

@ -1,4 +0,0 @@
function gui:AddDrawRuleB(rule)
if not(self.DrawRulesB) then self.DrawRulesB={} end
table.insert(self.DrawRulesB,rule)
end

View File

@ -1,4 +0,0 @@
function gui:AddDrawRuleE(rule)
if not(self.DrawRulesE) then self.DrawRulesE={} end
table.insert(self.DrawRulesE,rule)
end

View File

@ -1,12 +0,0 @@
function gui:draw()
if _GuiPro.rotate~=0 then
love.graphics.rotate(math.rad(_GuiPro.rotate))
end
if self.FormFactor:lower()=="rectangle" then
self:drawR()
elseif self.FormFactor:lower()=="circle" then
self:drawC()
else
error("Unsupported FormFactor: "..self.FormFactor.."!")
end
end

View File

@ -1,89 +0,0 @@
function gui:drawC()
if love.mouse.isDown("l")==false and love.mouse.isDown("m")==false and love.mouse.isDown("r")==false then
_GuiPro.DragItem={}
_GuiPro.hasDrag=false
end
if self.Visible==true and self.VIS==true then
local b=true
for i,v in pairs(_GuiPro.Clips) do
if self:isDescendant(v)==true then
b=false
end
end
if b then
love.graphics.setStencilTest( )
_GuiPro.HasStencel=false
_GuiPro.StencelHolder=nil
end
local x,y,r,s=(self.offset.pos.x or 0)+self.Parent.x,(self.offset.pos.y or 0)+self.Parent.y,self.offset.size.x or 0,self.offset.size.y or 360
if self.CC then
x,y=x+r,y+r
end
self.x,self.y=x,y
_GuiPro.circleStencilFunction = function()
love.graphics.circle("fill",x,y,r,s)
end
if math.sqrt((love.mouse.getX()-x)^2+(love.mouse.getY()-y)^2)<=r and self:eventable() and self:Clickable() and self.Active==true then
self.hovering=true
if love.mouse.isDown("l") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") then
love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
end
self.lclicked=true
elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") then
love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
end
self.rclicked=true
elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") then
love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
end
self.mclicked=true
else
if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then
love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
end
self.rclicked=false
self.lclicked=false
self.mclicked=false
end
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
self.hovering=false
self.rclicked=false
self.lclicked=false
self.mclicked=false
end
if self.ClipDescendants==true then
_GuiPro.Clips[tostring(self)]=self
_GuiPro.HasStencel=true
_GuiPro.StencelHolder=self
love.graphics.stencil(_GuiPro.circleStencilFunction)
love.graphics.setStencilTest("notequal",0)
end
love.graphics.circle("fill",x,y,r,s)
love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],(self.BorderVisibility or 1))
for b=0,self.BorderSize-1 do
love.graphics.circle("line",x,y,r+b,s)
end
if string.find(self.Type, "Text") then
if self.text~=nil then
if self.AutoScaleText then
self.FontSize=math.floor(self.height/1.45833)
end
love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility)
love.graphics.setFont(self.Font)
love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat)
end
end
end
end

View File

@ -1,73 +0,0 @@
function gui:drawR()
if love.mouse.isDown("l")==false and love.mouse.isDown("m")==false and love.mouse.isDown("r")==false then
_GuiPro.DragItem={}
_GuiPro.hasDrag=false
end
if self.hidden then
self.x=(self.Parent.width*self.scale.pos.x)+self.offset.pos.x+self.Parent.x
self.y=(self.Parent.height*self.scale.pos.y)+self.offset.pos.y+self.Parent.y
self.width=(self.Parent.width*self.scale.size.x)+self.offset.size.x
self.height=(self.Parent.height*self.scale.size.y)+self.offset.size.y
self.VIS = false
end
if self.Visible==true and self.VIS==true then
self.x=(self.Parent.width*self.scale.pos.x)+self.offset.pos.x+self.Parent.x
self.y=(self.Parent.height*self.scale.pos.y)+self.offset.pos.y+self.Parent.y
self.width=(self.Parent.width*self.scale.size.x)+self.offset.size.x
self.height=(self.Parent.height*self.scale.size.y)+self.offset.size.y
local b=true
for i,v in pairs(_GuiPro.Clips) do
if self:isDescendant(v)==true then
b=false
end
end
if b==true then
love.graphics.setStencilTest()
love.graphics.setScissor()
end
if self.DrawRulesB then
for dr=1,#self.DrawRulesB do
self.DrawRulesB[dr](self)
end
end
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
if self.ClipDescendants==true then
_GuiPro.Clips[tostring(self)]=self
love.graphics.setScissor(self.x, self.y, self.width, self.height)
end
if self:hasRoundness() then
-- love.graphics.stencil(self.stfunc, "replace", 1)
-- love.graphics.setStencilTest("greater", 0)
end
love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI)
if string.find(self.Type, "Image") then
self:ImageRule()
end
if self.Type=="Video" then
self:VideoRule()
end
if self:hasRoundness() then
-- love.graphics.setStencilTest()
end
love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],(self.BorderVisibility or 1))
for b=0,self.BorderSize-1 do
love.graphics.rectangle("line", self.x-(b/2), self.y-(b/2), self.width+b, self.height+b,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI)
end
if string.find(self.Type, "Text") then
if self.text~=nil and self.TextFormat ~= "center" then
love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility)
love.graphics.setFont(self.Font)
love.graphics.printf(self.text, self.x, self.y, self.width, self.TextFormat,self.TextRotaion)
elseif self.text~=nil and self.TextFormat == "center" then
love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility)
love.graphics.setFont(self.Font)
love.graphics.printf(self.text, self.x+(self.width-self.Font:getWidth(self.text))/2, self.y+(self.height-self.Font:getHeight())/2, self.width, "left",self.TextRotaion)
end
end
if self.DrawRulesE then
for dr=1,#self.DrawRulesE do
self.DrawRulesE[dr](self)
end
end
end
end

View File

@ -1,37 +0,0 @@
function gui:newDropFrame(name,x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("DropFrame",name, x, y, w, h, sx ,sy ,sw ,sh)
c.WasBeingDragged=false
c.IsBeingDragged=false
c.Draggable=false
c.funcD={}
function c:GetDroppedItems()
local t=self:getChildren()
local tab={}
for i=1,#t do
if t[i].Type=="TextImageButtonFrameDrag" then
table.insert(tab,t[i])
end
end
return tab
end
function c:OnDropped(func)
table.insert(self.funcD,func)
end
c:OnUpdate(function(self)
if _GuiPro.DragItem then
if _GuiPro.DragItem.Type=="TextImageButtonFrameDrag" and love.mouse.isDown(_GuiPro.DragItem.dragbut or "m")==false and self:IsHovering() then
local t=_GuiPro.DragItem
_GuiPro.DragItem={}
for i=1,#t.funcD do
t.funcD[i](self,t)
end
for i=1,#self.funcD do
self.funcD[i](self,t)
end
_GuiPro.hasDrag=false
end
end
end)
return c
end

View File

@ -1,8 +0,0 @@
function gui:newFrame(name,x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("Frame",name, x, y, w, h, sx ,sy ,sw ,sh)
c.WasBeingDragged=false
c.IsBeingDragged=false
c.Draggable=false
return c
end

View File

@ -1,4 +0,0 @@
function gui:newFullFrame(name)
name=name or ""
return self:newFrame(name,0,0,0,0,0,0,1,1)
end

View File

@ -1,59 +0,0 @@
function gui:newTabFrame(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=gui:newFrame(name, x, y, w, h, sx ,sy ,sw ,sh)
c.tabheight=20
c.Holder=c:newFrame("Holder",0,c.tabheight,0,0,0,0,1,1)
c.TabHolder=c:newFrame("TabHolder",0,0,0,c.tabheight,0,0,1)
function c:setTabHeight(n)
self.tabheight=n
self.Holder:SetDualDim(0,-self.tabheight,0,0,0,0,1,1)
end
function c:addTab(name,colorT,colorH)
if colorT and not(colorH) then
colorH=colorT
end
local tab=self.TabHolder:newTextButton(name,name,0,0,0,0,0,0,0,1)
tab.Tween=-3
if colorT then
tab.Color=colorT
end
local holder=self.Holder:newFrame(name,0,0,0,0,0,0,1,1)
if colorH then
holder.Color=colorH
end
tab.frame=holder
tab:OnReleased(function(b,self)
if b=="l" then
local tt=self.Parent:getChildren()
local th=self.Parent.Parent.Holder:getChildren()
for i=1,#th do
th[i].Visible=false
end
for i=1,#tt do
tt[i].frame.Visible=false
tt[i].BorderSize=1
end
self.BorderSize=0
self.frame.Visible=true
end
end)
local tt=self.TabHolder:getChildren()
for i=1,#tt do
tt[i].frame.Visible=false
tt[i].BorderSize=1
end
tab.frame.Visible=true
tab.BorderSize=0
return tab,holder
end
c:OnUpdate(function(self)
local th=self.TabHolder:getChildren()
local l=self.width/#th
for i=1,#th do
th[i]:SetDualDim(l*(i-1),0,l)
end
if #th==0 then
self:Destroy()
end
end)
return c
end

View File

@ -1,16 +0,0 @@
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

View File

@ -1,60 +0,0 @@
-- 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

View File

@ -1,44 +0,0 @@
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

View File

@ -1,67 +0,0 @@
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 count = 0
local max
for i=1,#_files do
if string.sub(_files[i],-1,-1)~="b" then
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,count,1,c.delay)
c.step.parent=c
c.rotation=0
c.step:OnStart(function(step)
for i=1,#step.parent.AnimStart do
step.parent.AnimStart[i](step.parent)
end
end)
c.step:OnStep(function(step,pos)
step.parent:SetImage(step.parent.files[pos])
end)
c.step:OnEnd(function(step)
for i=1,#step.parent.AnimEnd do
step.parent.AnimEnd[i](step.parent)
end
end)
function c:OnAnimStart(func)
table.insert(self.AnimStart,func)
end
function c:OnAnimEnd(func)
table.insert(self.AnimEnd,func)
end
function c:Pause()
self.step:Pause()
end
function c:Resume()
self.step:Resume()
end
function c:Reset()
self.step.pos=1
self.step:Reset()
end
function c:getFrames()
return #self.files
end
function c:getFrame()
return self.step.pos
end
function c:setFrame(n)
return self:SetImage(self.files[n])
end
return c
end

View File

@ -1,52 +0,0 @@
function gui:newAnimFromData(data,delay, x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("ImageAnimation","FromFile", x, y, w, h, sx ,sy ,sw ,sh)
c.Visibility=0
c.ImageVisibility=1
c.delay=delay or .05
c.files=data
c.AnimStart={}
c.AnimEnd={}
c:SetImage(c.files[1])
c.step=multi:newTStep(1,#c.files,1,c.delay)
c.step.parent=c
c.rotation=0
c.step:OnStart(function(step)
for i=1,#step.parent.AnimStart do
step.parent.AnimStart[i](step.parent)
end
end)
c.step:OnStep(function(pos,step)
step.parent:SetImage(step.parent.files[pos])
end)
c.step:OnEnd(function(step)
for i=1,#step.parent.AnimEnd do
step.parent.AnimEnd[i](step.parent)
end
end)
function c:OnAnimStart(func)
table.insert(self.AnimStart,func)
end
function c:OnAnimEnd(func)
table.insert(self.AnimEnd,func)
end
function c:Pause()
self.step:Pause()
end
function c:Resume()
self.step:Resume()
end
function c:Reset()
self.step.pos=1
end
function c:getFrames()
return #self.files
end
function c:getFrame()
return self.step.pos
end
function c:setFrame(n)
return self:SetImage(self.files[n])
end
return c
end

View File

@ -1,59 +0,0 @@
function gui:newAnimFromTiles(file,xd,yd,delay, x, y, w, h, sx ,sy ,sw ,sh)
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)
local im=love.image.newImageData(file)
local _x,_y=im:getDimensions()
c.Visibility=0
c.ImageVisibility=1
c.delay=delay or .05
c.files={}
c.AnimStart={}
c.AnimEnd={}
for i=0,_y/yd-1 do
for j=0,_x/xd-1 do
table.insert(c.files,gui:getTile(im,j*xd,i*yd,xd,yd))
end
end
c:SetImage(c.files[1])
c.step=multi:newTStep(1,#c.files,1,c.delay)
c.step.parent=c
c.rotation=0
c.step:OnStart(function(step)
for i=1,#step.parent.AnimStart do
step.parent.AnimStart[i](step.parent)
end
end)
c.step:OnStep(function(step,pos)
step.parent:SetImage(step.parent.files[pos])
end)
c.step:OnEnd(function(step)
for i=1,#step.parent.AnimEnd do
step.parent.AnimEnd[i](step.parent)
end
end)
function c:OnAnimStart(func)
table.insert(self.AnimStart,func)
end
function c:OnAnimEnd(func)
table.insert(self.AnimEnd,func)
end
function c:Pause()
self.step:Pause()
end
function c:Resume()
self.step:Resume()
end
function c:Reset()
self.step.pos=1
end
function c:getFrames()
return #self.files
end
function c:getFrame()
return self.step.pos
end
function c:setFrame(n)
return self:SetImage(self.files[n])
end
return c
end

View File

@ -1,3 +0,0 @@
function gui:newFullImageLabel(i,name)
return self:newImageLabel(i,name,0,0,0,0,0,0,1,1)
end

View File

@ -1,15 +0,0 @@
function gui:newImageButton(i,name, x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("ImageButton",name, x, y, w, h, sx ,sy ,sw ,sh)
c:SetImage(i)
c.Visibility=0
c.ImageVisibility=1
c.rotation=0
c:OnEnter(function()
love.mouse.setCursor(_GuiPro.CursorH)
end)
c:OnExit(function()
love.mouse.setCursor(_GuiPro.CursorN)
end)
return c
end

View File

@ -1,10 +0,0 @@
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)
c.Visibility=0
c.ImageVisibility=1
c.rotation=0
return c
end

View File

@ -1,62 +0,0 @@
function gui:newVideo(name,i,x,y,w,h,sx,sy,sw,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("Video",name, x, y, w, h, sx ,sy ,sw ,sh)
if type(i)=="string" then
c.Video=love.graphics.newVideo(i)
else
c.Video=i
end
c.Visibility=0
c.VideoVisibility=1
c.rotation=0
if c.Video~=nil then
c.VideoHeigth=c.Video:getHeight()
c.VideoWidth=c.Video:getWidth()
c.Quad=love.graphics.newQuad(0,0,w,h,c.VideoWidth,c.VideoHeigth)
end
c.funcV={}
function c:Play()
self.handStart=true
self.Video:play()
end
function c:Pause()
self.Video:pause()
end
c.Resume=c.Play
function c:Stop()
self.handStart=false
self:Pause()
self:Rewind()
for i=1,# self.funcV do
self.funcV[i](self)
end
end
function c:OnVideoStopped(func)
table.insert(self.funcV,func)
end
function c:Rewind()
self.Video:rewind()
end
function c:Restart()
self:Rewind()
self:Play()
end
function c:Seek(o)
self.Video:seek(o)
end
function c:Tell()
self.Video:tell()
end
function c:SetFilter(min, mag, anisotropy)
self.Video:setFilter(min, mag, anisotropy)
end
function c:IsPlaying()
return self.Video:isPlaying()
end
c:OnUpdate(function(self)
if self.Video:isPlaying()==false and self.handStart == true then
self:Stop()
end
end)
return c
end

View File

@ -1,51 +0,0 @@
function gui:newDragItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("TextImageButtonFrameDrag",name, x, y, w, h, sx ,sy ,sw ,sh)
c.WasBeingDragged=false
c.IsBeingDragged=false
c.Draggable=true
c.funcD={}
if type(i)=="string" then
c.Image=love.graphics.newImage(i)
c.ImageVisibility=1
c.ImageHeigth=c.Image:getHeight()
c.ImageWidth=c.Image:getWidth()
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
elseif type(i)=="image" then
c.Image=i
c.ImageVisibility=1
c.ImageHeigth=c.Image:getHeight()
c.ImageWidth=c.Image:getWidth()
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
end
c:OnDragStart(function(self,x,y)
if _GuiPro.hasDrag==false then
self:setParent(_GuiPro)
self:SetDualDim(x,y)
self:TopStack()
end
end)
c.rotation=0
c.Tween=0
c.XTween=0
c.text = t
c.AutoScaleText=false
c.FontHeight=_defaultfont:getHeight()
c.Font=_defaultfont
c.FontSize=15
c.TextFormat="center"
c.TextVisibility=1
c.TextColor = {0, 0, 0}
function c:OnDropped(func)
table.insert(self.funcD,func)
end
c:OnUpdate(function(self)
if love.mouse.isDown("m" or self.dragbut)==false and self==_GuiPro.DragItem and self.hovering==false then
_GuiPro.DragItem={}
for i=1,#self.func7 do
self.func7[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2)
end
end
end)
return c
end

View File

@ -1,28 +0,0 @@
function gui:newItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("TextImageButtonFrame",name, x, y, w, h, sx ,sy ,sw ,sh)
if type(i)=="string" then
c.Image=love.graphics.newImage(i)
else
c.Image=i
end
c.rotation=0
c.ImageVisibility=1
c.Draggable=false
if c.Image~=nil then
c.ImageHeigth=c.Image:getHeight()
c.ImageWidth=c.Image:getWidth()
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
end
c.Tween=0
c.XTween=0
c.text = t
c.AutoScaleText=false
c.FontHeight=_defaultfont:getHeight()
c.Font=_defaultfont
c.FontSize=15
c.TextFormat="center"
c.TextVisibility=1 -- 0=invisible,1=solid (self.TextVisibility*254+1)
c.TextColor = {0, 0, 0}
return c
end

View File

@ -1,45 +0,0 @@
function gui:AdvTextBox(txt,x,y,w,h,sx,sy,sw,sh)
name="AdvTextBox"
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("AdvTextBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh)
c.Draggable=true
c.dragbut="r"
c.BorderSize=0
c:ApplyGradient{Color.Blue,Color.sexy_purple}
c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple
c.funcO={}
c.funcX={}
c:OnDragStart(function(self)
self:TopStack()
end)
--local temp = c:newTextButton("X","Close",-25,5,20,20,1)
--temp.Tween=-5
--temp.XTween=-2
--temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end)
--temp.Color=Color.Red
c.tLink=c:newTextBox("puttext","TextBox",5,h-95,-40,30,0,1,1,1)
c.tLink.Color=Color.light_gray
c.tLink.ClearOnFocus=true
c.tLink:OnFocus(function(self) self.ClearOnFocus=false end)
local temp=c:newTextButton("OK","Ok",-35,h-65,30,30,1,1)
temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent,self.Parent.tLink.text) end end)
temp.Color=Color.Green
temp.XTween=-2
local temp=c:newTextButton("X","Cancel",-35,h-95,30,30,1,1)
temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent,self.Parent.tLink.text) end end)
temp.Color=Color.Red
temp.XTween=-2
function c:Close()
self.Visible=false
end
function c:Open()
self.Visible=true
end
function c:OnOk(func)
table.insert(self.funcO,func)
end
function c:OnX(func)
table.insert(self.funcX,func)
end
return c
end

View File

@ -1,36 +0,0 @@
function _GuiPro.gradient(colors)
local direction = colors.direction or "horizontal"
colors.direction=nil
trans = colors.trans or 1
trans=math.floor(trans)
if direction == "horizontal" then
direction = true
elseif direction == "vertical" then
direction = false
else
error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.")
end
local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1,"rgba32f")
for __i, color in ipairs(colors) do
local x, y
if direction then
x, y = 0, __i - 1
else
x, y = __i - 1, 0
end
result:setPixel(x, y, color[1], color[2], color[3], trans)
end
result = love.graphics.newImage(result)
result:setFilter('linear', 'linear')
return result
end
function _GuiPro.drawinrect(img, x, y, w, h, r, ox, oy, kx, ky)
love.graphics.draw(img, x, y, r, w / img:getWidth(), h / img:getHeight(), ox, oy, kx, ky)
end
function gui:ApplyGradient(rules)
self.Image=nil
self.Type=self.Type.."w/GradImage"
self.rotation=0
self.ImageVisibility=rules.visibility or 1
self:SetImage(_GuiPro.gradient(rules))
end

View File

@ -1,10 +0,0 @@
function gui:BottomStack()
childs=self.Parent:getChildren()
for i=1,#childs do
if childs[i]==self then
table.remove(self.Parent.Children,i)
table.insert(self.Parent.Children,1,self)
break
end
end
end

View File

@ -1,18 +0,0 @@
function gui:ClipDescendants(bool)
local c = self:GetAllChildren()
if not c[#c] then return end
if bool then
self.clipParent = self.Parent
self.Clipping = true
c[#c].resetClip = true
for i = 1,#c do
c[i].ClipReference = self
end
else
self.Clipping = nil
c[#c].resetClip = nil
for i = 1,#c do
c[i].ClipReference = nil
end
end
end

View File

@ -1,13 +0,0 @@
function gui:Destroy()
check=self.Parent:getChildren()
local cc=0
for cc=1,#check do
if check[cc]==self then
table.remove(self.Parent.Children,cc)
end
end
self.Destroyed = true
if #self.Parent.Children==0 then
self.Parent.isLeaf = true
end
end

View File

@ -1,25 +0,0 @@
function gui:GetAllChildren()
local Stuff = {}
function Seek(Items)
for i=1,#Items do
if Items[i].Visible==true then
table.insert(Stuff,Items[i])
local NItems = Items[i]:getChildren()
if NItems ~= nil then
Seek(NItems)
end
end
end
end
local Objs = self:getChildren()
for i=1,#Objs do
if Objs[i].Visible==true then
table.insert(Stuff,Objs[i])
local Items = Objs[i]:getChildren()
if Items ~= nil then
Seek(Items)
end
end
end
return Stuff
end

View File

@ -1,3 +0,0 @@
function gui:GetChild(name)
return self.Children[name] or self
end

View File

@ -1,3 +0,0 @@
function InGrid(i,x,y,s)
return math.floor((i-1)/x)*s,(i-1)*s-(math.floor((i-1)/y)*(s*x))
end

View File

@ -1,5 +0,0 @@
function InGridX(i,w,h,xs,ys)
local xc,yc=math.floor(w/xs),math.floor(h/ys)
local xi,yi=(i-1)%xc,math.floor((i-1)/xc)
return xi*xs,yi*ys
end

View File

@ -1,5 +0,0 @@
function InGridY(i,w,h,xs,ys)
local xc,yc=math.floor(w/xs),math.floor(h/ys)
local xi,yi=math.floor((i-1)/yc),(i-1)%yc
return xi*xs,yi*ys
end

View File

@ -1,3 +0,0 @@
function gui:IsHovering()
return (love.mouse.getX() > self.x and love.mouse.getX() < self.x+self.width and love.mouse.getY() > self.y and love.mouse.getY() < self.y+self.height)
end

View File

@ -1,4 +0,0 @@
function gui:Move(x,y)
self.offset.pos.x=self.offset.pos.x+x
self.offset.pos.y=self.offset.pos.y+y
end

View File

@ -1,46 +0,0 @@
function gui:SetDualDim(x, y, w, h, sx ,sy ,sw ,sh)
if _GuiPro.DPI_ENABLED then
if x then
x=self.DPI*x
end
if y then
y=self.DPI*y
end
if w then
w=self.DPI*w
end
if h then
h=self.DPI*h
end
end
if sx then
self.scale.pos.x=sx
end
if sy then
self.scale.pos.y=sy
end
if x then
self.offset.pos.x=x
end
if y then
self.offset.pos.y=y
end
if sw then
self.scale.size.x=sw
end
if sh then
self.scale.size.y=sh
end
if w then
self.offset.size.x=w
end
if h then
self.offset.size.y=h
end
if self.Image then
self:SetImage(self.Image)
end
end
function gui:setDualDim(...)
self:SetDualDim(...)
end

View File

@ -1,5 +0,0 @@
_GuiPro.CursorN=love.mouse.getSystemCursor("arrow")
_GuiPro.CursorH=love.mouse.getSystemCursor("hand")
function gui:SetHand(img,x,y)
_GuiPro.CursorN=love.mouse.newCursor(img,x,y)
end

View File

@ -1,3 +0,0 @@
function gui:SetHover(img,x,y)
_GuiPro.CursorH=love.mouse.newCursor(img,x,y)
end

View File

@ -1,4 +0,0 @@
function gui:SetName(name)
self.Parent.Children[name]=self
self.Name=name
end

View File

@ -1,9 +0,0 @@
function gui:SquareX(n)
local n = n or 1
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)
self:Move(s,s)
return self.Parent.width,rw
end

View File

@ -1,9 +0,0 @@
function gui:SquareY(n)
local n = n or 1
local w = self.Parent.height
local rw = w*n
local s = (w-rw)/2
self:setDualDim(nil,nil,rw,rw)
self:Move(s,s)
return self.Parent.height,rw
end

View File

@ -1,10 +0,0 @@
function gui:TopStack()
childs=self.Parent:getChildren()
for i=1,#childs do
if childs[i]==self then
table.remove(self.Parent.Children,i)
table.insert(self.Parent.Children,self)
break
end
end
end

View File

@ -1,5 +0,0 @@
function gui:UpdateImage()
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

View File

@ -1,797 +0,0 @@
-- os Additions
function os.getSystemBit()
if (os.getenv('PROCESSOR_ARCHITEW6432')=='AMD64' or os.getenv('PROCESSOR_ARCHITECTURE')=='AMD64') then
return 64
else
return 32
end
end
function os.sleep(n)
if not n then n=0 end
local t0 = os.clock()
while os.clock() - t0 <= n do end
end
function os.pause(msg)
if msg ~= nil then
print(msg)
end
io.read()
end
function os.batCmd(cmd)
io.mkFile('temp.bat',cmd)
local temp = os.execute([[temp.bat]])
io.delFile('temp.bat')
return temp
end
function os._getOS()
if package.config:sub(1,1)=='\\' then
return 'windows'
else
return 'unix'
end
end
function os.getOS(t)
if not t then
return os._getOS()
end
if os._getOS()=='unix' then
fh,err = io.popen('uname -o 2>/dev/null','r')
if fh then
osname = fh:read()
end
if osname then return osname end
end
local winver='Unknown Version'
local a,b,c=os.capture('ver'):match('(%d+).(%d+).(%d+)')
local win=a..'.'..b..'.'..c
if type(t)=='string' then
win=t
end
if win=='4.00.950' then
winver='95'
elseif win=='4.00.1111' then
winver='95 OSR2'
elseif win=='4.00.1381' then
winver='NT 4.0'
elseif win=='4.10.1998' then
winver='98'
elseif win=='4.10.2222' then
winver='98 SE'
elseif win=='4.90.3000' then
winver='ME'
elseif win=='5.00.2195' then
winver='2000'
elseif win=='5.1.2600' then
winver='XP'
elseif win=='5.2.3790' then
winver='Server 2003'
elseif win=='6.0.6000' then
winver='Vista/Windows Server 2008'
elseif win=='6.0.6002' then
winver='Vista SP2'
elseif win=='6.1.7600' then
winver='7/Windows Server 2008 R2'
elseif win=='6.1.7601' then
winver='7 SP1/Windows Server 2008 R2 SP1'
elseif win=='6.2.9200' then
winver='8/Windows Server 2012'
elseif win=='6.3.9600' then
winver='8.1/Windows Server 2012'
elseif win=='6.4.9841' then
winver='10 Technical Preview 1'
elseif win=='6.4.9860' then
winver='10 Technical Preview 2'
elseif win=='6.4.9879' then
winver='10 Technical Preview 3'
elseif win=='10.0.9926' then
winver='10 Technical Preview 4'
end
return 'Windows '..winver
end
function os.getLuaArch()
return (#tostring({})-7)*4
end
if os.getOS()=='windows' then
function os.sleep(n)
if n > 0 then os.execute('ping -n ' .. tonumber(n+1) .. ' localhost > NUL') end
end
else
function os.sleep(n)
os.execute('sleep ' .. tonumber(n))
end
end
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
function os.getCurrentUser()
return os.getenv('$USER') or os.getenv('USERNAME')
end
-- string Additions
function string.trim(s)
local from = s:match"^%s*()"
return from > #s and "" or s:match(".*%S", from)
end
function string.random(n)
local str = ''
strings = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
for i=1,n do
h = math.random(1,#strings)
str = str..''..strings[h]
end
return str
end
function string.linesToTable(s)
local t = {}
local i = 0
while true do
i = string.find(s, '\n', i+1)
if i == nil then return t end
table.insert(t, i)
end
end
function string.lines(str)
local t = {}
local function helper(line) table.insert(t, line) return '' end
helper((str:gsub('(.-)\r?\n', helper)))
return t
end
function string.split(str, pat)
local t = {} -- NOTE: use {n = 0} in Lua-5.0
local fpat = '(.-)' .. pat
local last_end = 1
local s, e, cap = str:find(fpat, 1)
while s do
if s ~= 1 or cap ~= '' then
table.insert(t,cap)
end
last_end = e+1
s, e, cap = str:find(fpat, last_end)
end
if last_end <= #str then
cap = str:sub(last_end)
table.insert(t, cap)
end
return t
end
function string.shuffle(inputStr)
math.randomseed(os.time());
local outputStr = '';
local strLength = string.len(inputStr);
while (strLength ~=0) do
local pos = math.random(strLength);
outputStr = outputStr..string.sub(inputStr,pos,pos);
inputStr = inputStr:sub(1, pos-1) .. inputStr:sub(pos+1);
strLength = string.len(inputStr);
end
return outputStr;
end
function string.genKeys(chars,a,f,s,GG)
if GG then
chars=string.rep(chars,a)
end
if s then
chars=string.shuffle(chars)
end
b=#chars
if a==0 then return end
local taken = {} local slots = {}
for i=1,a do slots[i]=0 end
for i=1,b do taken[i]=false end
local index = 1
local tab={}
for i=1,#chars do
table.insert(tab,chars:sub(i,i))
end
while index > 0 do repeat
repeat slots[index] = slots[index] + 1
until slots[index] > b or not taken[slots[index]]
if slots[index] > b then
slots[index] = 0
index = index - 1
if index > 0 then
taken[slots[index]] = false
end
break
else
taken[slots[index]] = true
end
if index == a then
local tt={}
for i=1,a do
table.insert(tt,tab[slots[i]])
end
f(table.concat(tt))
taken[slots[index]] = false
break
end
index = index + 1
until true end
end
-- io Additions
function io.getInput(msg)
if msg ~= nil then
io.write(msg)
end
return io.read()
end
function io.scanDir(directory)
directory=directory or io.getDir()
local i, t, popen = 0, {}, io.popen
if os.getOS()=='unix' then
for filename in popen('ls -a \''..directory..'\''):lines() do
i = i + 1
t[i] = filename
end
else
for filename in popen('dir \''..directory..'\' /b'):lines() do
i = i + 1
t[i] = filename
end
end
return t
end
function io.buildFromTree(tbl, indent,folder)
if not indent then indent = 0 end
if not folder then folder = '' end
for k, v in pairs(tbl) do
formatting = string.rep(' ', indent) .. k .. ':'
if type(v) == 'table' then
if not(io.dirExists(folder..string.sub(formatting,1,-2))) then
io.mkDir(folder..string.sub(formatting,1,-2))
end
io.buildFromTree(v,0,folder..string.sub(formatting,1,-2)..'\\')
else
a=string.find(tostring(v),':',1,true)
if a then
file=string.sub(tostring(v),1,a-1)
data=string.sub(tostring(v),a+1)
io.mkFile(folder..file,data,'wb')
else
io.mkFile(folder..v,'','wb')
end
end
end
end
function io.cpFile(path,topath)
if os.getOS()=='unix' then
os.execute('cp '..file1..' '..file2)
else
os.execute('Copy '..path..' '..topath)
end
end
function io.delDir(directoryname)
if os.getOS()=='unix' then
os.execute('rm -rf '..directoryname)
else
os.execute('rmdir '..directoryname..' /s /q')
end
end
function io.delFile(path)
os.remove(path)
end
function io.mkDir(dirname)
os.execute('mkdir "' .. dirname..'"')
end
function io.mkFile(filename,data,tp)
if not(tp) then tp='wb' end
if not(data) then data='' end
file = io.open(filename, tp)
if file==nil then return end
file:write(data)
file:close()
end
function io.movFile(path,topath)
io.cpFile(path,topath)
io.delFile(path)
end
function io.listFiles(dir)
if not(dir) then dir='' end
local f = io.popen('dir \''..dir..'\'')
if f then
return f:read('*a')
else
print('failed to read')
end
end
function io.getDir(dir)
if not dir then return io.getWorkingDir() end
if os.getOS()=='unix' then
return os.capture('cd '..dir..' ; cd')
else
return os.capture('cd '..dir..' & cd')
end
end
function io.getWorkingDir()
return io.popen'cd':read'*l'
end
function io.fileExists(path)
g=io.open(path or '','r')
if path =='' then
p='empty path'
return nil
end
if g~=nil and true or false then
p=(g~=nil and true or false)
end
if g~=nil then
io.close(g)
else
return false
end
return p
end
function io.fileCheck(file_name)
if not file_name then print('No path inputed') return false end
local file_found=io.open(file_name, 'r')
if file_found==nil then
file_found=false
else
file_found=true
end
return file_found
end
function io.dirExists(strFolderName)
strFolderName = strFolderName or io.getDir()
local fileHandle, strError = io.open(strFolderName..'\\*.*','r')
if fileHandle ~= nil then
io.close(fileHandle)
return true
else
if string.match(strError,'No such file or directory') then
return false
else
return true
end
end
end
function io.getAllItems(dir)
local t=os.capture("cd \""..dir.."\" & dir /a-d | find",true):lines()
return t
end
function io.listItems(dir)
if io.dirExists(dir) then
temp=io.listFiles(dir) -- current directory if blank
if io.getDir(dir)=='C:\\\n' then
a,b=string.find(temp,'C:\\',1,true)
a=a+2
else
a,b=string.find(temp,'..',1,true)
end
temp=string.sub(temp,a+2)
list=string.linesToTable(temp)
temp=string.sub(temp,1,list[#list-2])
slist=string.lines(temp)
table.remove(slist,1)
table.remove(slist,#slist)
temp={}
temp2={}
for i=1,#slist do
table.insert(temp,string.sub(slist[i],40,-1))
end
return temp
else
return nil
end
end
function io.getDirectories(dir,l)
if dir then
dir=dir..'\\'
else
dir=''
end
local temp2=io.scanDir(dir)
for i=#temp2,1,-1 do
if io.fileExists(dir..temp2[i]) then
table.remove(temp2,i)
elseif l then
temp2[i]=dir..temp2[i]
end
end
return temp2
end
function io.getFiles(dir,l)
if dir then
dir=dir..'\\'
else
dir=''
end
local temp2=io.scanDir(dir)
for i=#temp2,1,-1 do
if io.dirExists(dir..temp2[i]) then
table.remove(temp2,i)
elseif l then
temp2[i]=dir..temp2[i]
end
end
return temp2
end
function io.getFullName(name)
local temp=name or arg[0]
if string.find(temp,'\\',1,true) or string.find(temp,'/',1,true) then
temp=string.reverse(temp)
a,b=string.find(temp,'\\',1,true)
if not(a) or not(b) then
a,b=string.find(temp,'/',1,true)
end
return string.reverse(string.sub(temp,1,b-1))
end
return temp
end
function io.getName(file)
local name=io.getFullName(file)
name=string.reverse(name)
a,b=string.find(name,'.',1,true)
name=string.sub(name,a+1,-1)
return string.reverse(name)
end
function io.readFile(file)
local f = io.open(file, 'rb')
local content = f:read('*all')
f:close()
return content
end
function io.getExtension(file)
local file=io.getFullName(file)
file=string.reverse(file)
local a,b=string.find(file,'.',0,true)
local temp=string.sub(file,1,b)
return string.reverse(temp)
end
function io.pathToTable(path)
local p=io.splitPath(path)
local temp={}
temp[p[1]]={}
local last=temp[p[1]]
for i=2,#p do
snd=last
last[p[i]]={}
last=last[p[i]]
end
return temp,last,snd
end
function io.splitPath(str)
return string.split(str,'[\\/]+')
end
function io.parseDir(dir,t)
io.tempFiles={}
function _p(dir)
local dirs=io.getDirectories(dir,true)
local files=io.getFiles(dir,true)
for i=1,#files do
p,l,s=io.pathToTable(files[i])
if t then
s[io.getFullName(files[i])]=io.readFile(files[i])
else
s[io.getFullName(files[i])]=io.open(files[i],'r+')
end
table.merge(io.tempFiles,p)
end
for i=1,#dirs do
table.merge(io.tempFiles,io.pathToTable(dirs[i]))
_p(dirs[i],t)
end
end
_p(dir)
return io.tempFiles
end
function io.parsedir(dir,f)
io.tempFiles={}
function _p(dir,f)
local dirs=io.getDirectories(dir,true)
local files=io.getFiles(dir,true)
for i=1,#files do
if not f then
table.insert(io.tempFiles,files[i])
else
f(files[i])
end
end
for i=1,#dirs do
_p(dirs[i],f)
end
end
_p(dir,f)
return io.tempFiles
end
function io.driveReady(drive)
drive=drive:upper()
if not(drive:find(':',1,true)) then
drive=drive..':'
end
drives=io.getDrives()
for i=1,#drives do
if drives[i]==drive then
return true
end
end
return false
end
function io.getDrives()
if os.getOS()=='windows' then
local temp={}
local t1=os.capture('wmic logicaldisk where drivetype=2 get deviceid, volumename',true)
local t2=os.capture('wmic logicaldisk where drivetype=3 get deviceid, volumename',true)
for drive,d2 in t1:gmatch('(.:)%s-(%w+)') do
if #d2>1 then
table.insert(temp,drive)
end
end
for drive in t2:gmatch('(.:)') do
table.insert(temp,drive)
end
return temp
end
error('Command is windows only!')
end
-- table Additions
function table.dump(t,indent)
local names = {}
if not indent then indent = '' end
for n,g in pairs(t) do
table.insert(names,n)
end
table.sort(names)
for i,n in pairs(names) do
local v = t[n]
if type(v) == 'table' then
if(v==t) then
print(indent..tostring(n)..': <-')
else
print(indent..tostring(n)..':')
table.dump(v,indent..' ')
end
else
if type(v) == 'function' then
print(indent..tostring(n)..'()')
else
print(indent..tostring(n)..': '..tostring(v))
end
end
end
end
function table.alphanumsort(o)
local function padnum(d) local dec, n = string.match(d, '(%.?)0*(.+)')
return #dec > 0 and ('%.12f'):format(d) or ('%s%03d%s'):format(dec, #n, n)
end
table.sort(o, function(a,b) return tostring(a):gsub('%.?%d+',padnum)..('%3d'):format(#b)< tostring(b):gsub('%.?%d+',padnum)..('%3d'):format(#a) end)
return o
end
function table.foreach(t,f)
for i,v in pairs(t) do
f(v)
end
end
function table.merge(t1, t2)
for k,v in pairs(t2) do
if type(v) == 'table' then
if type(t1[k] or false) == 'table' then
table.merge(t1[k] or {}, t2[k] or {})
else
t1[k] = v
end
else
t1[k] = v
end
end
return t1
end
function table.print(tbl, indent)
if not indent then indent = 0 end
for k, v in pairs(tbl) do
formatting = string.rep(' ', indent) .. k .. ': '
if type(v) == 'table' then
print(formatting)
table.print(v, indent+1)
else
print(formatting .. tostring(v))
end
end
end
function table.merge(t1, t2)
for k,v in pairs(t2) do
if type(v) == 'table' then
if type(t1[k] or false) == 'table' then
table.merge(t1[k] or {}, t2[k] or {})
else
t1[k] = v
end
else
t1[k] = v
end
end
return t1
end
function table.clear(t)
for k in pairs (t) do
t[k] = nil
end
end
function table.copy(t)
function deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
return deepcopy(t)
end
function table.swap(tab,i1,i2)
tab[i1],tab[i2]=tab[i2],tab[i1]
end
function table.append(t1, ...)
t1,t2= t1 or {},{...}
for k,v in pairs(t2) do
t1[#t1+1]=t2[k]
end
return t1
end
function table.compare(t1, t2,d)
if d then
return table.deepCompare(t1,t2)
end
--if #t1 ~= #t2 then return false end
if #t2>#t1 then
for i=1,#t2 do
if t1[i] ~= t2[i] then
return false,t2[i]
end
end
else
for i=1,#t1 do
if t1[i] ~= t2[i] then
return false,t2[i]
end
end
end
return true
end
function table.deepCompare(t1,t2)
if t1==t2 then return true end
if (type(t1)~='table') then return false end
local mt1 = getmetatable(t1)
local mt2 = getmetatable(t2)
if( not table.deepCompare(mt1,mt2) ) then return false end
for k1,v1 in pairs(t1) do
local v2 = t2[k1]
if( not table.deepCompare(v1,v2) ) then return false end
end
for k2,v2 in pairs(t2) do
local v1 = t1[k2]
if( not table.deepCompare(v1,v2) ) then return false end
end
return true
end
function table.has(t,_v)
for i,v in pairs(t) do
if v==_v then
return true
end
end
return false
end
function table.reverse(tab)
local size = #tab
local newTable = {}
for i,v in ipairs (tab) do
newTable[size-i] = v
end
for i=1,#newTable do
tab[i]=newTable[i]
end
end
-- Math Additions
local Y = function(g) local a = function(f) return f(f) end return a(function(f) return g(function(x) local c=f(f) return c(x) end) end) end
local F = function(f) return function(n)if n == 0 then return 1 else return n*f(n-1) end end end
math.factorial = Y(F)
math.fib={}
math.fib.fibL={}
setmetatable(math.fib,{__call=function(self,n)
if n<=2 then
return 1
else
if self.fibL[n] then
return self.fibL[n]
else
local t=math.fib(n-1)+math.fib(n-2)
self.fibL[n]=t
return t
end
end
end})
local floor,insert = math.floor, table.insert
function math.basen(n,b)
n = floor(n)
if not b or b == 10 then return tostring(n) end
local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
local t = {}
local sign = ''
if n < 0 then
sign = '-'
n = -n
end
repeat
local d = (n % b) + 1
n = floor(n / b)
insert(t, 1, digits:sub(d,d))
until n == 0
return sign .. table.concat(t,'')
end
function math.convbase(n,b,tb)
return math.basen(tonumber(tostring(n),b),tb)
end
if BigNum then
function BigNum.mod(a,b)
return a-((a/b)*b)
end
local floor,insert = math.floor, table.insert
function math.basen(n,b)
n = BigNum.new(n)
if not b or b == 10 then return tostring(n) end
local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
local t = {}
local sign = ''
if n < BigNum.new(0) then
sign = '-'
n = -n
end
repeat
local d = BigNum.mod(n , b) + 1
n = n/b
d=tonumber(tostring(d))
insert(t, 1, digits:sub(d,d))
until tonumber(tostring(n)) == 0
return sign .. table.concat(t,'')
end
function math.to10(n,b)
local num=tostring(n)
local sum=BigNum.new()
local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i=1,#num do
local v=digits:find(num:sub(i,i),1,true)
sum=sum+BigNum.new(tonumber(v)-1)*BigNum.pow(BigNum.new(b),BigNum.new(#num-i))
end
return sum
end
function math.convbase(n,b,tb)
return math.basen(math.to10(n,b),tb)
end
end
function math.numfix(n,x)
local str=tostring(n)
if #str<x then
str=('0'):rep(x-#str)..str
end
return str
end
-- Misc Additions
function smartPrint(...)
local args={...}
for i=1,#args do
if type(args[i])=='table' then
table.print(args[i])
else
print(args[i])
end
end
end
function totable(v)
if type(v)=='table' then return v end
return {v}
end
print(math.factorial(2))

View File

@ -1,3 +0,0 @@
function gui:addDominance()
--_GuiPro.TopHovered=self
end

View File

@ -1,7 +0,0 @@
function alphanumsort(o)
local function padnum(d) local dec, n = string.match(d, "(%.?)0*(.+)")
return #dec > 0 and ("%.12f"):format(d) or ("%s%03d%s"):format(dec, #n, n)
end
table.sort(o, function(a,b) return tostring(a):gsub("%.?%d+",padnum)..("%3d"):format(#b)< tostring(b):gsub("%.?%d+",padnum)..("%3d"):format(#a) end)
return o
end

View File

@ -1,3 +0,0 @@
function gui:anchorRight(n)
self:SetDualDim(-(self.width+n),nil,nil,nil,1)
end

View File

@ -1,4 +0,0 @@
function gui:center()
self:centerX()
self:centerY()
end

View File

@ -1,3 +0,0 @@
function gui:centerX()
self:SetDualDim(-(self.width/2),nil,nil,nil,.5)
end

View File

@ -1,3 +0,0 @@
function gui:centerY()
self:SetDualDim(nil,-(self.height/2),nil,nil,nil,.5)
end

View File

@ -1,3 +0,0 @@
function gui:disrespectHierarchy()
_GuiPro.Hierarchy=false
end

View File

@ -1,3 +0,0 @@
function gui:getChildren()
return self.Children
end

View File

@ -1,3 +0,0 @@
function gui:getColor(cindex)
return Color[cindex]
end

View File

@ -1,14 +0,0 @@
function gui:getFullSize()
local maxx,maxy=self.width,self.height
local px,py=self.x,self.y
local temp = self:GetAllChildren()
for i=1,#temp do
if temp[i].width+temp[i].x>maxx then
maxx=temp[i].width+temp[i].x
end
if temp[i].height+temp[i].y>maxy then
maxy=temp[i].height+temp[i].y
end
end
return maxx,maxy,px,py
end

View File

@ -1,5 +0,0 @@
function gui:getHighest()
if self.Children[#self.Children]~=nil then
return self.Children[#self.Children]
end
end

View File

@ -1,5 +0,0 @@
function gui:getLowest()
if self.Children[1]~=nil then
return self.Children[1]
end
end

View File

@ -1,20 +0,0 @@
function gui:getTile(i,x,y,w,h)-- returns imagedata
if type(i)=="string" then
i=love.graphics.newImage(i)
elseif type(i)=="userdata" then
-- do nothing
elseif string.find(self.Type,"Image",1,true) then
local i,x,y,w,h=self.Image,i,x,y,w
else
error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)")
end
local iw,ih=i:getDimensions()
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

View File

@ -1,9 +0,0 @@
function gui:isDescendant(obj)
local things = obj:GetAllChildren()
for i=1,#things do
if things[i] == self then
return true
end
end
return false
end

View File

@ -1,3 +0,0 @@
function gui:isHighest()
return (self==self.Parent:getHighest())
end

View File

@ -1,3 +0,0 @@
function gui:isLowest()
return (self==self.Parent:getLowest())
end

View File

@ -1,6 +0,0 @@
function gui.massMutate(t,...)
local mut={...}
for i=1,#mut do
mut[i]:Mutate(t)
end
end

View File

@ -1,41 +0,0 @@
if love.filesystem.getInfo("CheckBoxes.png") then
_GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16)
_GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16)
_GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16)
_GuiPro.CH=gui:getTile("CheckBoxes.png",16,16,16,16)
end
function gui:newCheckBox(name,x,y)
if not(_GuiPro.UC) then error("CheckBoxes.png not found! Cannot currently use checkbox without the data") end
if type(name)~="String" then
x,y,name=name,x,"CheckBox"
end
local c=self:newImageLabel(_GuiPro.UC,name, x, y, 16,16)
c.Visibility=0
c.check=false
c:OnEnter(function(self)
if self.check then
self:SetImage(_GuiPro.CH)
else
self:SetImage(_GuiPro.UCH)
end
end)
function c:isChecked()
return self.check
end
c:OnExit(function(self)
if self.check then
self:SetImage(_GuiPro.C)
else
self:SetImage(_GuiPro.UC)
end
end)
c:OnReleased(function(b,self)
self.check=not(self.check)
if self.check then
self:SetImage(_GuiPro.CH)
else
self:SetImage(_GuiPro.UCH)
end
end)
return c
end

View File

@ -1,36 +0,0 @@
function gui:newMessageBox(txt,x,y,w,h,sx,sy,sw,sh)
name="MessageBox"
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("MessageBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh)
c.Draggable=true
c.dragbut="r"
c:ApplyGradient{Color.Blue,Color.sexy_purple}
c.BorderSize=0
c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple
c.funcO={}
c.funcX={}
c:OnDragStart(function(self)
self:TopStack()
end)
local temp = c:newTextButton("X","Close",-25,5,20,20,1)
temp.Tween=-5
temp.XTween=-2
temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end)
temp.Color=Color.Red
local temp=c:newTextButton("OK","Ok",0,h-65,0,30,.25,1,.5)
temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent) end end)
temp.Color=Color.Green
function c:Close()
self.Visible=false
end
function c:Open()
self.Visible=true
end
function c:OnOk(func)
table.insert(self.funcO,func)
end
function c:OnX(func)
table.insert(self.funcX,func)
end
return c
end

View File

@ -1,49 +0,0 @@
function gui:newPart(x, y,w ,h , sx ,sy ,sw ,sh)
local c = {}
setmetatable(c, gui)
if self==gui then
c.Parent=_GuiPro
else
c.Parent=self
end
c.funcs={}
c.funcs2={}
c.funcs3={}
c.funcs4={}
c.funcs5={}
c.func6={}
c.func7={}
c.func8={}
c.func9={}
c.func10={}
c.form="rectangle"
c.Color = {255, 255, 255}
c.scale={}
c.scale.size={}
c.scale.size.x=sw or 0
c.scale.size.y=sh or 0
c.offset={}
c.offset.size={}
c.offset.size.x=w or 0
c.offset.size.y=h or 0
c.scale.pos={}
c.scale.pos.x=sx or 0
c.scale.pos.y=sy or 0
c.offset.pos={}
c.offset.pos.x=x or 0
c.offset.pos.y=y or 0
c.VIS=true
c.Visible=true
c.Visibility=1
c.BorderColor={0,0,0}
c.BorderSize=0
c.Type="Part"
c.Name="GuiPart"
_GuiPro.count=_GuiPro.count+1
c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x
c.y=(c.Parent.height*c.scale.pos.y)+c.offset.pos.y+c.Parent.y
c.width=(c.Parent.width*c.scale.size.x)+c.offset.size.x
c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y
table.insert(c.Parent.Children,c)
return c
end

View File

@ -1,45 +0,0 @@
function gui:newProgressBar(txt,x,y,w,h,sx,sy,sw,sh)
name="newProgressBar"
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase("newProgressBarFrame",name, x, y, w, 30, sx ,sy ,sw ,sh)
c.Draggable=true
c.dragbut="r"
c.BorderSize=0
c:ApplyGradient{Color.Blue,Color.sexy_purple}
c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple
c.funcO={}
c.funcX={}
c:OnDragStart(function(self)
self:TopStack()
end)
local temp = c:newTextButton("X","Close",-25,5,20,20,1)
temp.Tween=-5
temp.XTween=-2
temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end)
temp.Color=Color.Red
c.BarBG=c:newTextButton("",5,h-65,-10,30,0,1,1)
c.BarBG:ApplyGradient{Color.Red,Color.light_red}
c.Bar=c.BarBG:newTextLabel("",0,0,0,0,0,0,0,1)
c.Bar:ApplyGradient{Color.Green,Color.light_green}
c.BarDisp=c.BarBG:newTextLabel("0%","0%",0,0,0,0,0,0,1,1)
c.BarDisp.Visibility=0
c.BarDisp.Link=c.Bar
c.BarDisp:OnUpdate(function(self)
self.text=self.Link.scale.size.x*100 .."%"
end)
c.Func1={}
function c:On100(func)
table.insert(self.Func1,func)
end
c:OnUpdate(function(self)
if self.Bar.scale.size.x*100>=100 then
for P=1,#self.Func1 do
self.Func1[P](self)
end
end
end)
function c:SetPercentage(n)
self.Bar:SetDualDim(0,0,0,0,0,0,n/100,1)
end
return c
end

View File

@ -1,42 +0,0 @@
function gui:newScrollBar(color1,color2)
local scrollbar=self:newFrame(-20,0,20,0,1,0,0,1)
scrollbar.funcS={}
scrollbar.Color=color1 or Color.saddle_brown
scrollbar:OnClicked(function(b,self,x,y)
love.mouse.setX(self.x+10)
if y>=10 and y<=self.height-10 then
self.mover:SetDualDim(0,y-10)
end
if y<10 then
love.mouse.setY(10+self.y)
end
if y>self.height-10 then
love.mouse.setY((self.height-10)+self.y)
end
for i=1,#self.funcS do
self.funcS[i](self,self:getPosition())
end
end)
scrollbar:OnEnter(function(self)
self:addDominance()
end)
scrollbar:OnExit(function(self)
self:removeDominance()
end)
scrollbar.mover=scrollbar:newTextButton("","",0,0,20,20)
scrollbar.mover.Color=color2 or Color.light_brown
function scrollbar:getPosition()
return ((self.mover.offset.pos.y)/(self.height-20))*100
end
function scrollbar:setPosition(n)
print((self.height-20),n)
self.mover.offset.pos.y=((self.height-20)/(100/n))
for i=1,#self.funcS do
self.funcS[i](self,self:getPosition())
end
end
function scrollbar:OnScroll(func)
table.insert(self.funcS,func)
end
return scrollbar
end

View File

@ -1,81 +0,0 @@
function gui:newScrollMenu(name)
local temp = self:newFullFrame(name)
temp.ref = {
[[setNewFont(16)]],
[[setRoundness(10,10,180)]],
Tween = 6
}
temp.allowOverlapping = true
temp.Visibility = 0
local ScrollY = temp:newFrame(name.."ScrollY",-20,0,20,0,1,0,0,1)
temp.scroll = ScrollY
ScrollY.Color=Color.new(80,80,80)
ScrollY.allowOverlapping = true
ScrollY.Mover = ScrollY:newFrame(name.."MoverY",5,5,10,80)
ScrollY.Mover.Color = Color.new(60,60,60)
local func = function(b,self,x,y,nn)
temp.symbolicY = y
if y>45 and y<self.height-45 then
self.Mover:SetDualDim(nil,y-40)
temp.first:setDualDim(nil,nil,nil,nil,nil,-((y-46)/(self.height-92))*((temp.max-temp.height+60)/temp.height))
if not nn then
self:setMouseXY(10)
end
end
end
ScrollY:OnClicked(func)
temp.symbolicY = 45
temp.scrollM = 2
temp:OnMouseWheelMoved(function(self,x,y)
temp.symbolicY=temp.symbolicY-(y*temp.scrollM)
if temp.symbolicY<45 then
temp.symbolicY = 45
elseif temp.symbolicY>ScrollY.height-40 then
temp.symbolicY = ScrollY.height-40
end
func("l",ScrollY,x,temp.symbolicY,true)
end)
temp.ClipDescendants=true
temp.first = temp:newTextLabel("","",15,10,-50,40,0,0,1)
local nice = temp:newTextLabel(name,name,15,10,-50,40,0,0,1)
temp.header = nice
temp.last = temp.first
temp.last.BorderSize = 0
temp.last.Visibility = 0
nice:setNewFont(26)
nice.Tween = 6
temp.list = {}
local alarm
multi:newLoop(function()
for i=1,#temp.list do
local val = (temp.first.y+(temp.list[i].staticpos)+10)
if val>temp.y and val<temp.height+temp.y+temp.height then
temp.list[i].Visible = true
else
temp.list[i].Visible = false
end
end
end)
function temp:setRef(ref)
self.ref = ref
end
temp.max = 40
function temp:addItem(text, height, padding, obj)
local padding = padding or 10
local height = height or 30
temp.max = temp.max + padding-- + height
if obj then
obj:SetDualDim(nil,temp.max-padding,nil,height,nil,nil,1)
obj:setParent(self.first)
end
local c = obj or self.first:newTextLabel(text,text,0,temp.max-padding,0,height,0,0,1)
if not obj then
c:Mutate(temp.ref)
end
temp.max = temp.max + height
c.staticpos = temp.max
temp.list[#temp.list+1] = c
return c
end
return temp
end

View File

@ -1,15 +0,0 @@
_GuiPro.jobqueue.OnJobCompleted(function(JOBID,n,i,t)
if t~="PRE" then return end
_GuiPro.imagecache[i]=n
end)
function gui:preloadImages(tab)
local t
if type(tab)=="string" then
t = {tab}
else
t = tab
end
for i = 1,#t do
_GuiPro.jobqueue:pushJob("LoadImage",t[i],"PRE")
end
end

View File

@ -1,6 +0,0 @@
function gui:destroyAllChildren()
local c=self.Children
for i=1,#c do
c[i]:Destroy()
end
end

View File

@ -1,3 +0,0 @@
function gui:removeDominance()
_GuiPro.TopHovered=nil
end

View File

@ -1,3 +0,0 @@
function gui:respectHierarchy()
_GuiPro.Hierarchy=true
end

View File

@ -1,4 +0,0 @@
function gui.round(num, idp)
local mult = 10^(idp or 0)
return math.floor(num * mult + 0.5) / mult
end

View File

@ -1,3 +0,0 @@
function gui.setBG(i)
gui.ff:SetImage(i)
end

View File

@ -1,14 +0,0 @@
function gui:setColor(a,b,c)
if type(a)=="string" then
self.Color=Color[a]
elseif type(a)=="number" then
self.Color=Color.new(a,b,c)
end
end
function gui:setTextColor(a,b,c)
if type(a)=="string" then
self.TextColor=Color[a]
elseif type(a)=="number" then
self.TextColor=Color.new(a,b,c)
end
end

View File

@ -1,8 +0,0 @@
function gui:setMouseXY(x,y)
if x then
love.mouse.setX(x+self.x)
end
if y then
love.mouse.setY(y+self.y)
end
end

View File

@ -1,14 +0,0 @@
function gui:setParent(parent,name)-- Needs fixing!!!
local temp=self.Parent:getChildren()
for i=1,#temp do
if temp[i]==self then
table.remove(self.Parent.Children,i)
break
end
end
table.insert(parent.Children,self)
self.Parent=parent
if name then
self:SetName(name)
end
end

View File

@ -1,14 +0,0 @@
function gui:setVisiblity(val)
self.Visible=val
self.oV=val
doto=self:GetAllChildren()
if val==false then
for i=1,#doto do
doto[i].Visible=val
end
else
for i=1,#doto do
doto[i].Visible=doto[i].oV
end
end
end

View File

@ -1,29 +0,0 @@
function gui:fitFont(n)
local font
if self.FontFile then
if self.FontFile:match("ttf") then
font = function(n)
return love.graphics.newFont(self.FontFile, n,"normal")
end
else
font = function(n)
return love.graphics.newFont(self.FontFile, n)
end
end
else
font = function(n)
return love.graphics.newFont(n)
end
end
local Font,width,height,text=self.Font,self.width,self.height,self.text
local s = 3
Font = font(s)
while Font:getHeight()<height and Font:getWidth(text)<width do
s = s + 1
Font = font(s)
end
Font = font(s - (2+(n or 0)))
Font:setFilter("linear","nearest",4)
self.Font = Font
return s - (2+(n or 0))
end

View File

@ -1,17 +0,0 @@
function gui:newTextBase(tp,t,name,x,y,w,h,sx,sy,sw,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
c.Tween=0
c.XTween=0
c.FontHeight=_defaultfont:getHeight()
c.Font=_defaultfont
c.Font:setFilter("linear","nearest",4)
c.FontSize=15
c.TextFormat="center"
c.text = t
c.AutoScaleText=false
c.TextVisibility=1
c.Color = {220, 220, 220}
c.TextColor = {0, 0, 0}
return c
end

View File

@ -1,152 +0,0 @@
function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newTextBase("TextBox",t,name, x, y, w, h, sx ,sy ,sw ,sh)
local realText = {}
local hiddenText = {}
for i = 1,#t do
table.insert(realText,t:sub(i,i))
table.insert(hiddenText,t:sub(i,i))
end
local curpos = 1
c.ClearOnFocus=false
c.LoseFocusOnEnter=true
c.hideText = false
local funcE = {}
local clear = true
local Focused = false
local autoScaleFont = false
local moved = false
local alarm = multi:newAlarm(.5):OnRing(function(a)
moved = false
end)
function c:AutoScaleFont(bool)
autoScaleFont = bool
self:fitFont()
end
function c:ClearOnFocus(bool)
clear = bool
end
c.funcF={function()
love.keyboard.setTextInput(true)
end}
c.funcE={function()
love.keyboard.setTextInput(false)
end}
function c:OnEnter(func)
table.insert(funcE,func)
end
function c:focus()
Focused = true
love.keyboard.setKeyRepeat(true)
love.keyboard.setTextInput(true)
end
function c:unfocus()
Focused = false
love.keyboard.setKeyRepeat(false)
love.keyboard.setTextInput(false)
end
c:OnPressed(function(b,self,x,y)
if not Focused then
if clear then
realText = {}
hiddenText = {}
curpos = 1
end
tags:ClearOnFocus(false)
self:focus()
end
moved = true
alarm:Reset()
local width = self.Font:getWidth(self.text)
if x > self.x+width then
curpos = #hiddenText+1
elseif x < self.x then
curpos = 1
else
for i = 1,#hiddenText do
width = self.Font:getWidth(self.text:sub(1,i))
if x-self.x < width then
curpos = i
break
end
end
end
end)
c:OnPressedOuter(function(b,self)
if Focused then
self:unfocus()
end
end)
c:OnUpdate(function(self)
if #hiddenText==0 then self.text = "" return end
if self.hideText then
self.text = table.concat(hiddenText)
else
self.text = table.concat(realText)
end
self.TextFormat = "left"
end)
multi.OnTextInput(function(t)
table.insert(hiddenText,curpos,"*")
table.insert(realText,curpos,t)
curpos = curpos + 1
if autoScaleFont then
c:fitFont()
end
end)
multi.OnKeyPressed(function(key, scancode, isrepeat )
if key == "backspace" then
table.remove(hiddenText,curpos-1)
table.remove(realText,curpos-1)
curpos = curpos - 1
if curpos < 1 then
curpos = 1
end
if autoScaleFont then
c:fitFont()
end
elseif key == "enter" then
elseif key == "delete" then
realText = {}
hiddenText = {}
curpos = 1
elseif key == "left" then
curpos = curpos - 1
if curpos < 1 then
curpos = 1
end
moved = true
alarm:Reset()
elseif key == "right" then
curpos = curpos + 1
if curpos > #realText+1 then
curpos = #realText+1
end
moved = true
alarm:Reset()
end
end)
local blink = false
multi:newThread("TextCursonBlinker",function()
while true do
thread.sleep(1.5)
blink = not blink
end
end)
self.DrawRulesE = {function()
if --[[blink or moved]] true then
local width = c.Font:getWidth(c.text:sub(1,curpos-1))
local height = c.Font:getHeight()
if c.TextFormat == "center" then
-- print(c.x+(c.width/2+width),c.height,c.x+(c.width/2+width),c.height+height)
-- love.graphics.line(c.x+(c.width/2+width),c.height,c.x+(c.width/2+width),c.height+height)
elseif c.TextFormat == "right" then
--love.graphics.line(c.x+width,c.y,c.x+width,c.y+c.Font:getHeight())
elseif c.TextFormat == "left" then
love.graphics.line(c.x+width,c.y,c.x+width,c.y+height)
end
end
end}
return c
end

View File

@ -1,11 +0,0 @@
function gui:newTextButton(t,name, x, y, w, h, sx ,sy ,sw ,sh)
local x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
local c=self:newTextBase("TextButton",t,name, x, y, w, h, sx ,sy ,sw ,sh)
c:OnMouseEnter(function()
love.mouse.setCursor(_GuiPro.CursorH)
end)
c:OnMouseExit(function()
love.mouse.setCursor(_GuiPro.CursorN)
end)
return c
end

View File

@ -1,4 +0,0 @@
function gui:newTextLabel(t,name, x, y, w, h, sx ,sy ,sw ,sh)
local x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
return self:newTextBase("TextLabel",t,name, x, y, w, h, sx ,sy ,sw ,sh)
end

View File

@ -1,3 +0,0 @@
function gui:setDefualtFont(font)
_defaultfont = font
end

View File

@ -1,9 +0,0 @@
function gui:setNewFont(filename,FontSize)
if type(filename)=="string" then
self.FontFile = filename
self.Font = love.graphics.newFont(filename, tonumber(FontSize))
else
self.Font=love.graphics.newFont(tonumber(filename))
end
self.Font:setFilter("linear","nearest",4)
end

View File

@ -1,6 +0,0 @@
function gui:setText(txt)
self.text=txt
end
function gui:getText(txt)
return self.text
end

View File

@ -1,5 +0,0 @@
function gui:widthToTextSize(n)
if self.Font then
self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0)
end
end

Some files were not shown because too many files have changed in this diff Show More