Compare commits

..

No commits in common. "master" and "WIP" have entirely different histories.
master ... WIP

1253 changed files with 11355 additions and 14094 deletions

2
.gitattributes vendored Normal file
View File

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

38
.vscode/launch.json vendored
View File

@ -1,38 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Pure Lua",
"type": "lua",
"request": "launch",
"projectDir": "${workspaceRoot}",
"clientIndex": "1",
"program": "${workspaceRoot}/test.lua",
"luaexe": "C:/Program Files (x86)/Lua/5.1/lua.exe"
},
{
"name": "SimpleLua 2",
"type": "lua",
"request": "launch",
"projectDir": "${workspaceRoot}",
"clientIndex": "2"
},
{
"name": "SimpleLua 3",
"type": "lua",
"request": "launch",
"projectDir": "${workspaceRoot}",
"clientIndex": "3"
},
{
"type": "lua",
"request": "launch",
"name": "Launch",
"projectDir": "${workspaceRoot}",
"program": "./love.exe",
}
]
}

View File

@ -1,8 +0,0 @@
{
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
}
}

BIN
Audio/Collapse.ogg Normal file

Binary file not shown.

BIN
Audio/Creaky.ogg Normal file

Binary file not shown.

BIN
Audio/Deadly Sorrow.ogg Normal file

Binary file not shown.

BIN
Audio/Don't Die on Me.ogg Normal file

Binary file not shown.

BIN
Audio/Laugh.ogg Normal file

Binary file not shown.

BIN
Audio/Lost World - myuu.ogg Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Audio/Yawn.ogg Normal file

Binary file not shown.

BIN
Audio/alarm.ogg Normal file

Binary file not shown.

BIN
Audio/bed.ogg Normal file

Binary file not shown.

BIN
Audio/boyknife.ogg Normal file

Binary file not shown.

BIN
Audio/footsteps.ogg Normal file

Binary file not shown.

BIN
Audio/hmm.ogg Normal file

Binary file not shown.

BIN
Audio/knife.ogg Normal file

Binary file not shown.

BIN
Audio/over.ogg Normal file

Binary file not shown.

BIN
Audio/paper.ogg Normal file

Binary file not shown.

BIN
Audio/pots.ogg Normal file

Binary file not shown.

BIN
Audio/select.ogg Normal file

Binary file not shown.

BIN
Audio/sigh.ogg Normal file

Binary file not shown.

BIN
Audio/stairs.ogg Normal file

Binary file not shown.

BIN
Audio/store.ogg Normal file

Binary file not shown.

BIN
Audio/twisted.ogg Normal file

Binary file not shown.

View File

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

View File

@ -1,19 +1,5 @@
local function HSL(h, s, l, a)
if s<=0 then return l,l,l,a end
h, s, l = h/256*6, s/255, l/255
local c = (1-math.abs(2*l-1))*s
local x = (1-math.abs(h%2-1))*c
local m,r,b,g = (l-.5*c), 0,0,0
if h < 1 then r,b,g = c,x,0
elseif h < 2 then r,b,g = x,c,0
elseif h < 3 then r,b,g = 0,c,x
elseif h < 4 then r,b,g = 0,x,c
elseif h < 5 then r,b,g = x,0,c
else r,b,g = c,0,x
end return (r+m)*255,(g+m)*255,(b+m)*255,a
end
Color={ Color={
new=function(r,b,g) new=function(r,g,b)
mt = { mt = {
__add = function (c1,c2) __add = function (c1,c2)
return Color.new(c1[1]+c2[1],c1[2]+c2[2],c1[2]+c2[2]) return Color.new(c1[1]+c2[1],c1[2]+c2[2],c1[2]+c2[2])
@ -36,14 +22,14 @@ new=function(r,b,g)
__unm = function (c1) __unm = function (c1)
return Color.new(-c1[1],-c1[2],-c1[2]) return Color.new(-c1[1],-c1[2],-c1[2])
end, end,
__tostring = function(c)
return "("..c[1]..","..c[2]..","..c[3]..")"
end,
__eq = Color.EQ, __eq = Color.EQ,
__lt = Color.LT, __lt = Color.LT,
__le = Color.LE, __le = Color.LE,
__tostring = function(self)
return "("..self[1] ..","..self[1] ..","..self[1] ..")"
end
} }
local temp = {r/255,b/255,g/255,1} local temp = {r,g,b,255}
setmetatable(temp, mt) setmetatable(temp, mt)
return temp return temp
end, end,
@ -63,27 +49,24 @@ IndexColor=function(name,r,b,g)
if type(r)=="string" then if type(r)=="string" then
r,b,g=tonumber(string.sub(r,1,2),16),tonumber(string.sub(r,3,4),16),tonumber(string.sub(r,5,6),16) r,b,g=tonumber(string.sub(r,1,2),16),tonumber(string.sub(r,3,4),16),tonumber(string.sub(r,5,6),16)
end end
_Color[string.lower(name)]=Color.new(r,b,g) Color[string.lower(name)]=Color.new(r,b,g)
_Color[string.upper(name)]=Color.new(r,b,g) Color[string.upper(name)]=Color.new(r,b,g)
_Color[string.upper(string.sub(name,1,1))..string.lower(string.sub(name,2))]=Color.new(r,b,g) Color[string.upper(string.sub(name,1,1))..string.lower(string.sub(name,2))]=Color.new(r,b,g)
end, end,
Darken=function(color,v) Darken=function(color,v)
return Color.new((color[1]*255) * (1 - v),(color[2]*255) * (1 - v),(color[3]*255) * (1 - v)) currentR=color[1]
currentG=color[2]
currentB=color[3]
return Color.new(currentR * (1 - v),currentG * (1 - v),currentB * (1 - v))
end, end,
Lighten=function(color,v) Lighten=function(color,v)
currentR=color[1] currentR=color[1]
currentG=color[2] currentG=color[2]
currentB=color[3] currentB=color[3]
return Color.new(color[1]*255 + (255 - (color[1]*255)) * v,color[2]*255 + (255 - (color[2]*255)) * v,color[3]*255 + (255 - (color[3]*255)) * v)
return Color.new(currentR + (255 - currentR) * v,currentG + (255 - currentG) * v,currentB + (255 - currentB) * v)
end end
} }
_Color = {}
setmetatable(Color,{
__index = function(self,k)
local c = _Color[k]
return Color.new(c[1]*255,c[2]*255,c[3]*255)
end,
})
Color.IndexColor("Black",20,20,20) Color.IndexColor("Black",20,20,20)
Color.IndexColor("WHITE",255,255,255) Color.IndexColor("WHITE",255,255,255)
Color.IndexColor("MAROON",128,20,20) Color.IndexColor("MAROON",128,20,20)

View File

@ -0,0 +1,5 @@
function DrawThings(items)
for i=1,#items do
items[i]:draw()
end
end

View File

@ -0,0 +1,85 @@
function gui:OnClicked(func)
table.insert(self.funcs,func)
end
function gui:OnReleased(func)
table.insert(self.funcs2,func)
end
function gui:OnEnter(func)
table.insert(self.funcs3,func)
end
function gui:OnExit(func)
table.insert(self.funcs4,func)
end
function gui:OnUpdate(func)
table.insert(self.funcs5,func)
end
function gui:OnDragStart(func)
table.insert(self.func8,func)
end
function gui:OnDragging(func)
table.insert(self.func6,func)
end
function gui:OnDragEnd(func)
table.insert(self.func7,func)
end
function gui:WhileHovering(func)
table.insert(self.func9,func)
end
function gui:OnMouseMoved(func)
table.insert(self.func10,func)
end
function gui:getChildren()
return self.Children
end
function gui:LClicked()
return self.lclicked
end
function gui:RClicked()
return self.rclicked
end
function gui:MClicked()
return self.mclicked
end
function gui:Clicked()
return (self.lclicked or self.rclicked)
end
function gui:Hovering()
return self.hovering
end
function gui:FreeConnections()
self.funcs={function(b,self) if b=="l" then self.LRE=true end end,function(b,self) if b=="r" then self.RRE=true end end,function(b,self) if b=="m" then self.MRE=true end end}
self.funcs2={function(b,self) if b=="l" then self.LRE=false end end,function(b,self) if b=="r" then self.RRE=false end end,function(b,self) if b=="m" then self.MRE=false end end}
self.funcs3={function(self) self.HE=true end}
self.funcs4={function(self) self.HE=false end}
self.funcs5={function(self) 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 end}
end
function gui:LClick()
for i=1,#self.funcs do
self.funcs[i]("l",self)
end
end
function gui:RClick()
for i=1,#self.funcs do
self.funcs[i]("r",self)
end
end
function gui:MClick()
for i=1,#self.funcs do
self.funcs[i]("m",self)
end
end
function gui:LRelease()
for i=1,#self.funcs2 do
self.funcs2[i]("l",self)
end
end
function gui:RRelease()
for i=1,#self.funcs2 do
self.funcs2[i]("r",self)
end
end
function gui:MRelease()
for i=1,#self.funcs2 do
self.funcs2[i]("m",self)
end
end

View File

@ -0,0 +1,46 @@
function UpdateThings(items)
for i=#items,1,-1 do
if items[i]:LClicked() then
for g=1,#items[i].funcs do
items[i].funcs[g]("l",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif items[i]:RClicked() then
for g=1,#items[i].funcs do
items[i].funcs[g]("r",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif items[i]:MClicked() then
for g=1,#items[i].funcs do
items[i].funcs[g]("m",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
end
if not(items[i]:LClicked()) and items[i].LRE then
for g=1,#items[i].funcs2 do
items[i].funcs2[g]("l",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif not(items[i]:RClicked()) and items[i].RRE then
for g=1,#items[i].funcs2 do
items[i].funcs2[g]("r",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif not(items[i]:MClicked()) and items[i].MRE then
for g=1,#items[i].funcs2 do
items[i].funcs2[g]("m",items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
end
if items[i]:Hovering() and items[i].HE==false then
for g=1,#items[i].funcs3 do
items[i].funcs3[g](items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif not(items[i]:Hovering()) and items[i].HE==true then
for g=1,#items[i].funcs4 do
items[i].funcs4[g](items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
elseif items[i]:Hovering() then
for g=1,#items[i].func9 do
items[i].func9[g](items[i],love.mouse.getX()-items[i].x,love.mouse.getY()-items[i].y)
end
end
for g=1,#items[i].funcs5 do
items[i].funcs5[g](items[i])
end
end
end

View File

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

View File

@ -1,6 +1,3 @@
_GuiPro.Frames = {}
_GuiPro.Type = "Window"
_GuiPro.depth = 0
function gui.enableAutoWindowScaling(b) function gui.enableAutoWindowScaling(b)
_GuiPro.DPI_ENABLED=b or true _GuiPro.DPI_ENABLED=b or true
_defaultfont=love.graphics.newFont(12*love.window.getPixelScale()) _defaultfont=love.graphics.newFont(12*love.window.getPixelScale())
@ -18,9 +15,6 @@ function filter(name, x, y, w, h, sx ,sy ,sw ,sh)
end end
return x,y,w,h,sx,sy,sw,sh return x,y,w,h,sx,sy,sw,sh
end end
function gui:getChildren()
return self.Children
end
function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh) function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
_GuiPro.count=_GuiPro.count+1 _GuiPro.count=_GuiPro.count+1
local c = {} local c = {}
@ -30,25 +24,15 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
else else
c.Parent=self c.Parent=self
end end
if tp:match("Frame") then c.segments=nil
_GuiPro.Frames[#_GuiPro.Frames+1] = c c.ry=nil
end c.rx=nil
if self.Type and self.Type:match("Frame") then c.DPI=1
c.FrameRef = self if _GuiPro.DPI_ENABLED then
else c.DPI=love.window.getPixelScale()
c.FrameRef = self.FrameRef x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
end end
c.segments=nil c.centerFontY=true
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.FormFactor="rectangle"
c.Type=tp c.Type=tp
c.Active=true c.Active=true
@ -68,6 +52,7 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
c.mclicked=false c.mclicked=false
c.clicked=false c.clicked=false
c.Visibility=1 c.Visibility=1
c.ClipDescendants=false
c.TextWrap=true c.TextWrap=true
c.scale={} c.scale={}
c.scale.size={} c.scale.size={}
@ -89,23 +74,66 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
c.RRE=false c.RRE=false
c.MRE=false c.MRE=false
c.Color = {255, 255, 255} c.Color = {255, 255, 255}
function c:setRoundness(rx,ry,segments) function c:setRoundness(rx,ry,segments)
self.segments=segments self.segments=segments
self.ry=ry self.ry=ry
self.rx=rx self.rx=rx
end end
function c.stfunc() function c.stfunc()
love.graphics.rectangle("fill", c.x, c.y, c.width, c.height,c.rx,c.ry,c.segments) love.graphics.rectangle("fill", c.x, c.y, c.width, c.height,c.rx,c.ry,c.segments)
end end
function c:hasRoundness() function c:hasRoundness()
return (self.ry or self.rx) return (self.ry or self.rx)
end end
c.funcs={function(b,self)
if b=="l" then
self.LRE=true
end
end,
function(b,self)
if b=="r" then
self.RRE=true
end
end,
function(b,self)
if b=="m" then
self.MRE=true
end
end}
c.funcs2={function(b,self)
if b=="l" then
self.LRE=false
end
end,
function(b,self)
if b=="r" then
self.RRE=false
end
end,
function(b,self)
if b=="m" then
self.MRE=false
end
end}
c.HE=false
c.funcs3={function(self)
self.HE=true
end}
c.funcs4={function(self)
self.HE=false
end}
c.funcs5={}
c.tid={} c.tid={}
c.touchcount=0 c.touchcount=0
c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x 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.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.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 c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y
c.func6={}
c.func7={function() _GuiPro.DragItem={} end}
c.func8={function(self) _GuiPro.DragItem=self end}
c.func9={}
c.func10={}
function c:ImageRule() function c:ImageRule()
if self.Image then if self.Image then
local sx=self.width/self.ImageWidth local sx=self.width/self.ImageWidth
@ -149,19 +177,61 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
_GuiPro.self=self _GuiPro.self=self
if type(i)=="number" then if type(i)=="number" then
loadstring("_GuiPro.self:"..v)() 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 else
self[i]=v self[i]=v
end end
end end
return self return self
end end
c:WhileHovering(function(self)
self.omx=self.nmx
self.omy=self.nmy
self.nmx=love.mouse.getX()
self.nmy=love.mouse.getY()
if self.omx~=self.nmx or self.omy~=self.nmy then
for i=1,#self.func10 do
if self and self.nmx and self.nmy and self.omx and self.omy then
self.func10[i](self,self.nmx,self.nmy,self.omx,self.omy)
end
end
end
if self.WasBeingDragged==true and love.mouse.isDown(self.dragbut or "m")==false and self.Type~="TextImageButtonFrameDrag" then
for i=1,#self.func7 do
self.func7[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2)
end
end
if _GuiPro.hasDrag==false and love.mouse.isDown(self.dragbut or "m") then
for i=1,#self.func8 do
self.func8[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2)
end
end
if self.IsBeingDragged==true then
_GuiPro.hasDrag=true
self.WasBeingDragged=true
elseif self.WasBeingDragged==true and self.IsBeingDragged==false then
self.WasBeingDragged=false
_GuiPro.hasDrag=false
end
if self.Draggable==true and love.mouse.isDown(self.dragbut or "m") and _GuiPro.hasDrag==false then
for i=1,#self.func6 do
self.func6[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2)
end
_GuiPro.hasDrag=true
if self.FormFactor:lower()=="circle" or self.FormFactor:lower()=="c" or self.FormFactor:lower()=="cir" then
self.IsBeingDragged=true
x=(love.mouse.getX()-self.x)
y=(love.mouse.getY()-self.y)
self:Move(x,y)
elseif self.FormFactor:lower()=="rectangle" or self.FormFactor:lower()=="r" or self.FormFactor:lower()=="rect" then
self.IsBeingDragged=true
x=(love.mouse.getX()-self.x)-self.width/2
y=(love.mouse.getY()-self.y)-self.height/2
self:Move(x,y)
end
else
self.IsBeingDragged=false
end
end)
table.insert(c.Parent.Children,c) table.insert(c.Parent.Children,c)
return c return c
end end

View File

@ -26,7 +26,7 @@ function gui:touchable(t)
end end
self.id=-1 self.id=-1
end end
--multi:newTask(function() -- A bit of post-loading haha multi:newTask(function() -- A bit of post-loading haha
gui.touchpressed=multi:newConnection() gui.touchpressed=multi:newConnection()
gui.touchreleased=multi:newConnection() gui.touchreleased=multi:newConnection()
gui.touchmoved=multi:newConnection() gui.touchmoved=multi:newConnection()
@ -83,9 +83,9 @@ end
end end
end end
end) end)
--end) end)
-- now that that is done lets set up some more post loading checks -- now that that is done lets set up some more post loading checks
_GuiPro.int=multi:newProcessor() _GuiPro.int=multi:newProcess()
_GuiPro.int:Start() _GuiPro.int:Start()
_GuiPro.int:setJobSpeed(.001) _GuiPro.int:setJobSpeed(.001)
_GuiPro.EXACT=0 _GuiPro.EXACT=0

View File

@ -27,37 +27,37 @@ function gui:drawC()
self.hovering=true self.hovering=true
if love.mouse.isDown("l") and _GuiPro.hasDrag==false then if love.mouse.isDown("l") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") 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) love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254)
else else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end end
self.lclicked=true self.lclicked=true
elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") 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) love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254)
else else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end end
self.rclicked=true self.rclicked=true
elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then
if string.find(self.Type, "Button") 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) love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254)
else else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end end
self.mclicked=true self.mclicked=true
else else
if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then 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) love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254)
else else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end end
self.rclicked=false self.rclicked=false
self.lclicked=false self.lclicked=false
self.mclicked=false self.mclicked=false
end end
else else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
self.hovering=false self.hovering=false
self.rclicked=false self.rclicked=false
self.lclicked=false self.lclicked=false
@ -71,7 +71,7 @@ function gui:drawC()
love.graphics.setStencilTest("notequal",0) love.graphics.setStencilTest("notequal",0)
end end
love.graphics.circle("fill",x,y,r,s) love.graphics.circle("fill",x,y,r,s)
love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],(self.BorderVisibility or 1)) love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility*254)
for b=0,self.BorderSize-1 do for b=0,self.BorderSize-1 do
love.graphics.circle("line",x,y,r+b,s) love.graphics.circle("line",x,y,r+b,s)
end end
@ -80,7 +80,7 @@ function gui:drawC()
if self.AutoScaleText then if self.AutoScaleText then
self.FontSize=math.floor(self.height/1.45833) self.FontSize=math.floor(self.height/1.45833)
end end
love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility*254)
love.graphics.setFont(self.Font) love.graphics.setFont(self.Font)
love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat) love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat)
end end

View File

@ -0,0 +1,118 @@
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.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==true then
love.graphics.setStencilTest()
love.graphics.setScissor()
end
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
if self.DrawRulesB then
for dr=1,#self.DrawRulesB do
self.DrawRulesB[dr](self)
end
end
if (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 and self:Clickable() and self:eventable()) or self:touchable("r") and self.Active==true then
self.hovering=true
if love.mouse.isDown("l") or self:touchable("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*254)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end
self.lclicked=true
elseif love.mouse.isDown("r") or self:touchable("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*254)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end
self.rclicked=true
elseif love.mouse.isDown("m") or self:touchable("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*254)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
end
self.mclicked=true
else
if string.find(self.Type, "Button") or self:touchable("r") and _GuiPro.hasDrag==false then
love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254)
else
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254)
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*254)
self.hovering=false
self.rclicked=false
self.lclicked=false
self.mclicked=false
end
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.Visibility*254)
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 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*254)
if self.Font==_defaultfont then
love.graphics.setFont(self.Font)
love.graphics.printf(self.text, self.x+2+(self.XTween*self.DPI)+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+(self.FontHeight/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat)
else
if type(self.Font)=="string" then
self.Font=love.graphics.newFont(self.Font,self.FontSize)
self.FontHeight=self.Font:getHeight()
else
love.graphics.setFont(self.Font)
end
if type(self.FontSize)=="string" then
self.FontSize=tonumber(self.FontSize)
love.graphics.setNewFont(self.FontSize)
end
love.graphics.printf(self.text, self.x+2+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat)
end
end
end
if self.DrawRulesE then
for dr=1,#self.DrawRulesE do
self.DrawRulesE[dr](self)
end
end
end
end

View File

@ -0,0 +1,13 @@
function gui:SetImage(i)
if type(i)=="string" then
self.Image=love.graphics.newImage(i)
else
self.Image=i
end
if self.Image~=nil then
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
return self.ImageWidth,self.ImageHeigth
end

View File

@ -1,28 +1,19 @@
function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh) 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 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 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.Visibility=0
c.ImageVisibility=1 c.ImageVisibility=1
c.delay=delay or .05 c.delay=delay or .05
c.files={} c.files={}
c.AnimStart={} c.AnimStart={}
c.AnimEnd={} c.AnimEnd={}
local count = 0 local _files=alphanumsort(love.filesystem.getDirectoryItems(file))
local max
for i=1,#_files do for i=1,#_files do
if string.sub(_files[i],-1,-1)~="b" then if string.sub(_files[i],-1,-1)~="b" then
count = count + 1 table.insert(c.files,love.graphics.newImage(file.."/".._files[i]))
gui.loadImageData(file.."/".._files[i],count,function(imagedata,id)
c.files[id] = love.graphics.newImage(imagedata)
end)
end end
end end
c.step=multi:newTStep(1,count,1,c.delay) c.step=multi:newTStep(1,#c.files,1,c.delay)
c.step.parent=c c.step.parent=c
c.rotation=0 c.rotation=0
c.step:OnStart(function(step) c.step:OnStart(function(step)
@ -30,7 +21,7 @@ function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
step.parent.AnimStart[i](step.parent) step.parent.AnimStart[i](step.parent)
end end
end) end)
c.step:OnStep(function(step,pos) c.step:OnStep(function(pos,step)
step.parent:SetImage(step.parent.files[pos]) step.parent:SetImage(step.parent.files[pos])
end) end)
c.step:OnEnd(function(step) c.step:OnEnd(function(step)
@ -52,7 +43,6 @@ function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
end end
function c:Reset() function c:Reset()
self.step.pos=1 self.step.pos=1
self.step:Reset()
end end
function c:getFrames() function c:getFrames()
return #self.files return #self.files

View File

@ -1,7 +1,7 @@
function gui:newAnimFromTiles(file,xd,yd,delay, x, y, w, h, sx ,sy ,sw ,sh) 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) 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 c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh)
local im=love.image.newImageData(file) local im=love.graphics.newImage(file)
local _x,_y=im:getDimensions() local _x,_y=im:getDimensions()
c.Visibility=0 c.Visibility=0
c.ImageVisibility=1 c.ImageVisibility=1
@ -23,7 +23,7 @@ function gui:newAnimFromTiles(file,xd,yd,delay, x, y, w, h, sx ,sy ,sw ,sh)
step.parent.AnimStart[i](step.parent) step.parent.AnimStart[i](step.parent)
end end
end) end)
c.step:OnStep(function(step,pos) c.step:OnStep(function(pos,step)
step.parent:SetImage(step.parent.files[pos]) step.parent:SetImage(step.parent.files[pos])
end) end)
c.step:OnEnd(function(step) c.step:OnEnd(function(step)

View File

@ -1,15 +1,24 @@
function gui:newImageButton(i,name, x, y, w, h, sx ,sy ,sw ,sh) 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) 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) local c=self:newBase("ImageButton",name, x, y, w, h, sx ,sy ,sw ,sh)
c:SetImage(i) if type(i)=="string" then
c.Image=love.graphics.newImage(i)
else
c.Image=i
end
c.Visibility=0 c.Visibility=0
c.ImageVisibility=1 c.ImageVisibility=1
c.rotation=0 c.rotation=0
c.BorderSize = 0 if c.Image~=nil then
c:OnMouseEnter(function() c.ImageHeigth=c.Image:getHeight()
c.ImageHeight=c.Image:getHeight()
c.ImageWidth=c.Image:getWidth()
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
end
c:OnEnter(function()
love.mouse.setCursor(_GuiPro.CursorH) love.mouse.setCursor(_GuiPro.CursorH)
end) end)
c:OnMouseExit(function() c:OnExit(function()
love.mouse.setCursor(_GuiPro.CursorN) love.mouse.setCursor(_GuiPro.CursorN)
end) end)
return c return c

View File

@ -0,0 +1,18 @@
function gui:newImageLabel(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("ImageLabel",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.Visibility=0
c.ImageVisibility=1
c.rotation=0
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
return c
end

View File

@ -1,7 +1,7 @@
function _GuiPro.gradient(colors) function _GuiPro.gradient(colors)
local direction = colors.direction or "horizontal" local direction = colors.direction or "horizontal"
colors.direction=nil colors.direction=nil
trans = colors.trans or 1 trans = colors.trans or 255
trans=math.floor(trans) trans=math.floor(trans)
if direction == "horizontal" then if direction == "horizontal" then
direction = true direction = true
@ -10,7 +10,7 @@ function _GuiPro.gradient(colors)
else else
error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.") error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.")
end end
local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1,"rgba32f") local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1)
for __i, color in ipairs(colors) do for __i, color in ipairs(colors) do
local x, y local x, y
if direction then if direction then

View File

@ -0,0 +1,4 @@
function gui:Center()
local x,y=self:getFullSize()
self:SetDualDim(-math.floor(x/2),-math.floor(y/2),nil,nil,.5,.5)
end

View File

@ -6,8 +6,4 @@ function gui:Destroy()
table.remove(self.Parent.Children,cc) table.remove(self.Parent.Children,cc)
end end
end end
self.Destroyed = true
if #self.Parent.Children==0 then
self.Parent.isLeaf = true
end
end end

View File

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

View File

@ -0,0 +1,6 @@
function gui:addHotKey(key)
local temp=self:newFrame(0,0,0,0)
temp.Visible=false
temp:setHotKey(key)
return temp
end

View File

@ -0,0 +1,12 @@
function gui:getFullSize()
local maxx,maxy=-math.huge,-math.huge
local temp = self:GetAllChildren()
for i=1,#temp do
if temp[i].width>maxx then
maxx=temp[i].width+temp[i].offset.pos.x
elseif temp[i].height>maxy then
maxy=temp[i].height+temp[i].offset.pos.y
end
end
return maxx,maxy
end

View File

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

View File

@ -1,4 +1,4 @@
if love.filesystem.getInfo("CheckBoxes.png") then if love.filesystem.exists("CheckBoxes.png") then
_GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16) _GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16)
_GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16) _GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16)
_GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16) _GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16)

View File

@ -0,0 +1,98 @@
function gui:newScrollMenu(title,tabN,onloop,x, y, w, h, sx ,sy ,sw ,sh)
local Main = self:newFrame(x, y, w, h, sx ,sy ,sw ,sh)
local Title=Main:newTextButton(title,"Title",0,0,0,20,0,0,1)
Title.Tween=-4
Title.FontSize=12
Title:OnReleased(function(b,self)
self.Parent.Tick=not(self.Parent.Tick)
end)
local scroll=Main:newTextButton("","Scroll",-20,20,20,-20,1,0,0,1)
scroll:OnClicked(function(b,self,x,y)
self.Parent.Mover:SetDualDim(0,y-10,20,20)
if self.Parent.Mover.offset.pos.y<0 then
self.Parent.Mover:SetDualDim(0,0,20,20)
end
if self.Parent.Mover.offset.pos.y>self.Parent.height-40 then
self.Parent.Mover:SetDualDim(0,self.Parent.height-40,20,20)
end
local temp = #self.Parent.TList
self.Parent.pos=(math.floor((temp*self.Parent.Mover.offset.pos.y)/self.height))+1
end)
Main:OnUpdate(function(self)
if self.Tick==false then
self.Visibility=0
end
end)
scroll:OnUpdate(function(self)
self.Visible=self.Parent.Tick
end)
local Mover=scroll:newTextLabel("",0,0,20,20)
Main.Mover=Mover
Main.TList=tabN
Main.pos=1
Main.Tick=true
function Main:Update(title,tabN,onloop)
ch=self:getChildren()
for i=#ch,1,-1 do
ch[i]:Destroy()
end
Title=Main:newTextButton(title,"Title",0,0,0,20,0,0,1)
Title.Tween=-4
Title.FontSize=12
Title:OnReleased(function(b,self)
self.Parent.Tick=not(self.Parent.Tick)
end)
scroll=Main:newTextButton("","Scroll",-20,20,20,-20,1,0,0,1)
scroll:OnClicked(function(b,self,x,y)
self.Parent.Mover:SetDualDim(0,y-10,20,20)
if self.Parent.Mover.offset.pos.y<0 then
self.Parent.Mover:SetDualDim(0,0,20,20)
end
if self.Parent.Mover.offset.pos.y>self.Parent.height-40 then
self.Parent.Mover:SetDualDim(0,self.Parent.height-40,20,20)
end
local temp = #self.Parent.TList
self.Parent.pos=(math.floor((temp*self.Parent.Mover.offset.pos.y)/self.height))+1
end)
local Mover=scroll:newTextLabel("",0,0,20,20)
Main.Mover=Mover
Main.TList=tabN
Main.pos=1
Main.Tick=true
scroll:OnUpdate(function(self)
self.Visible=self.Parent.Tick
end)
for i=1,math.floor(Main.height/20)-1 do
local temp=Main:newTextButton("","Item"..i,0,i*20,-20,20,0,0,1)
temp.FontSize=10
temp.Tween=-4
temp.pos=i
temp:OnUpdate(function(self)
self.text=self.Parent.TList[(self.Parent.pos+self.pos)-1]
self.Visible=self.Parent.Tick
end)
if onloop then
onloop(temp,i)
end
end
end
io.write(tostring(Main.height).."\n")
for i=1,math.floor(Main.height/20)-1 do
local temp=Main:newTextButton("Item"..i,0,i*20,-20,20,0,0,1)
temp.FontSize=10
temp.Tween=-4
temp.pos=i
temp:OnUpdate(function(self)
if self.Parent.TList[(self.Parent.pos+self.pos)-1]~=nil then
self.text=self.Parent.TList[(self.Parent.pos+self.pos)-1]
else
self.text=""
end
self.Visible=self.Parent.Tick
end)
if onloop then
onloop(temp,i)
end
end
return Main
end

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