Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8782fa4538 | |||
| 2e19a444da | |||
| 63f3f165ca | |||
| 59dc3d1da7 | |||
| abf90042e7 | |||
| dcd7a20c14 | |||
| f742a3fe8e |
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
38
.vscode/launch.json
vendored
Normal file
38
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
// 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",
|
||||
}
|
||||
]
|
||||
}
|
||||
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/.classpath": true,
|
||||
"**/.project": true,
|
||||
"**/.settings": true,
|
||||
"**/.factorypath": true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
BIN
Audio/Creaky.ogg
BIN
Audio/Creaky.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Audio/Laugh.ogg
BIN
Audio/Laugh.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Audio/Yawn.ogg
BIN
Audio/Yawn.ogg
Binary file not shown.
BIN
Audio/alarm.ogg
BIN
Audio/alarm.ogg
Binary file not shown.
BIN
Audio/bed.ogg
BIN
Audio/bed.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Audio/hmm.ogg
BIN
Audio/hmm.ogg
Binary file not shown.
BIN
Audio/knife.ogg
BIN
Audio/knife.ogg
Binary file not shown.
BIN
Audio/over.ogg
BIN
Audio/over.ogg
Binary file not shown.
BIN
Audio/paper.ogg
BIN
Audio/paper.ogg
Binary file not shown.
BIN
Audio/pots.ogg
BIN
Audio/pots.ogg
Binary file not shown.
BIN
Audio/select.ogg
BIN
Audio/select.ogg
Binary file not shown.
BIN
Audio/sigh.ogg
BIN
Audio/sigh.ogg
Binary file not shown.
BIN
Audio/stairs.ogg
BIN
Audio/stairs.ogg
Binary file not shown.
BIN
Audio/store.ogg
BIN
Audio/store.ogg
Binary file not shown.
Binary file not shown.
@ -1,15 +0,0 @@
|
||||
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
|
||||
@ -1,5 +0,0 @@
|
||||
function DrawThings(items)
|
||||
for i=1,#items do
|
||||
items[i]:draw()
|
||||
end
|
||||
end
|
||||
@ -1,85 +0,0 @@
|
||||
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
|
||||
@ -1,46 +0,0 @@
|
||||
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
|
||||
@ -1,14 +0,0 @@
|
||||
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
|
||||
@ -1,118 +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.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
|
||||
@ -1,13 +0,0 @@
|
||||
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
|
||||
@ -1,18 +0,0 @@
|
||||
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
|
||||
@ -1,4 +0,0 @@
|
||||
function gui:Center()
|
||||
local x,y=self:getFullSize()
|
||||
self:SetDualDim(-math.floor(x/2),-math.floor(y/2),nil,nil,.5,.5)
|
||||
end
|
||||
@ -1,3 +0,0 @@
|
||||
function gui:addDominance()
|
||||
_GuiPro.TopHovered=self
|
||||
end
|
||||
@ -1,6 +0,0 @@
|
||||
function gui:addHotKey(key)
|
||||
local temp=self:newFrame(0,0,0,0)
|
||||
temp.Visible=false
|
||||
temp:setHotKey(key)
|
||||
return temp
|
||||
end
|
||||
@ -1,12 +0,0 @@
|
||||
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
|
||||
@ -1,98 +0,0 @@
|
||||
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
|
||||
@ -1,24 +0,0 @@
|
||||
function gui:setHotKey(key)
|
||||
local tab=key:split("+")
|
||||
self.hotkeys=tab
|
||||
self.cooldown=false
|
||||
self.Alarm=multi:newAlarm(1)
|
||||
self.Alarm.parent=self
|
||||
self.args={}
|
||||
self.funcHK=multi:newConnection()
|
||||
self.Alarm:OnRing(function(alarm) alarm.parent.cooldown=false end)
|
||||
function self:OnHotKey(func)
|
||||
self.funcHK:connect(func)
|
||||
end
|
||||
self:OnUpdate(function(self)
|
||||
if self.cooldown then return end
|
||||
for i=1,#self.hotkeys do
|
||||
if not(love.keyboard.isDown(self.hotkeys[i])) then
|
||||
return
|
||||
end
|
||||
end
|
||||
self.cooldown=true
|
||||
self.funcHK:Fire(self)
|
||||
self.Alarm:Reset()
|
||||
end)
|
||||
end
|
||||
@ -1,3 +0,0 @@
|
||||
function gui:setNewFont(FontSize)
|
||||
self.Font=love.graphics.setNewFont(tonumber(FontSize))
|
||||
end
|
||||
@ -1,178 +0,0 @@
|
||||
function string:insert(p,s)
|
||||
return ("%s%s%s"):format(self:sub(1,p), s, self:sub(p+1))
|
||||
end
|
||||
function string:remove(p,l)
|
||||
l=l or 1
|
||||
return ("%s%s"):format(self:sub(1,p-1), self:sub(p+l))
|
||||
end
|
||||
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:newBase("TextBox",name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.ClearOnFocus=false
|
||||
c.LoseFocusOnEnter=true
|
||||
c.Tween=0
|
||||
c.XTween=0
|
||||
c.FontHeight=_defaultfont:getHeight()
|
||||
c.Font=_defaultfont
|
||||
c.FontSize=15
|
||||
c.TextFormat="center"
|
||||
c.text = t
|
||||
c.ttext= t
|
||||
c.AutoScaleText=false
|
||||
c.TextVisibility=1
|
||||
c.Color = {220, 220, 220}
|
||||
c.TextColor = {0, 0, 0}
|
||||
c.Active=false
|
||||
c.hidden=false
|
||||
c.cursor={0,1}
|
||||
c.mark=nil
|
||||
c.arrowkeys=false
|
||||
c.funcF={function()
|
||||
love.keyboard.setTextInput(true,0,200,400,200)
|
||||
end}
|
||||
c.cooldown=false
|
||||
c.cooldown2=false
|
||||
c.funcE={function()
|
||||
love.keyboard.setTextInput(false)
|
||||
end}
|
||||
function c:triggerEnter()
|
||||
for cc=1,#self.funcE do
|
||||
self.funcE[cc](self,self.ttext)
|
||||
end
|
||||
self.text=""
|
||||
self.ttext=""
|
||||
end
|
||||
c.Enter=true
|
||||
c.Alarm=multi:newAlarm(.1)
|
||||
c.Alarm.parent=c
|
||||
c.Alarm:OnRing(function(alarm) alarm.parent.cooldown=false end)
|
||||
c.Alarm2=multi:newAlarm(.5)
|
||||
c.Alarm2.parent=c
|
||||
c.Alarm2:OnRing(function(alarm) alarm.parent.cooldown2=false end)
|
||||
c.ArrowAlarm=multi:newAlarm(.1)
|
||||
c.ArrowAlarm.parent=c
|
||||
c.ArrowAlarm:OnRing(function(alarm) alarm.parent.arrowkeys=false end)
|
||||
function c:OnFocus(func)
|
||||
table.insert(self.funcF,func)
|
||||
end
|
||||
function c:OnEnter(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
c:OnClicked(function(b,self)
|
||||
for cc=1,#self.funcF do
|
||||
self.funcF[cc](self)
|
||||
end
|
||||
if self.Active==false then
|
||||
if self.ClearOnFocus==true then
|
||||
self.text=""
|
||||
self.ttext=""
|
||||
end
|
||||
for tb=1,#gui.TB do
|
||||
if gui.TB[tb]~=nil then
|
||||
gui.TB[tb].Active=false
|
||||
end
|
||||
end
|
||||
self.Active=true
|
||||
end
|
||||
end)
|
||||
c:OnClicked(function(b,self,x,y)
|
||||
local dwidth, wrappedtext = _defaultfont:getWrap(self.text:sub(1,self.cursor[1]), self.width)
|
||||
local height = _defaultfont:getHeight()
|
||||
if #wrappedtext>=1 then
|
||||
width= _defaultfont:getWidth(wrappedtext[#wrappedtext])
|
||||
self.cursor[2]=#wrappedtext
|
||||
else
|
||||
self.cursor[2]=1
|
||||
width=0
|
||||
end
|
||||
yc=math.ceil(((y/self.DPI)-(self.FontHeight/2)+self.Tween-self.y)/height)
|
||||
xc=math.floor(x)
|
||||
end)
|
||||
c:AddDrawRuleE(function(self)
|
||||
if self.Active then
|
||||
local dwidth, wrappedtext = _defaultfont:getWrap(self.text:sub(1,self.cursor[1]), self.width)
|
||||
local height = _defaultfont:getHeight()
|
||||
if #wrappedtext>=1 then
|
||||
width= _defaultfont:getWidth(wrappedtext[#wrappedtext])
|
||||
self.cursor[2]=#wrappedtext
|
||||
else
|
||||
self.cursor[2]=1
|
||||
width=0
|
||||
end
|
||||
x1=width+2+self.x+self.XTween
|
||||
y1=(self.y+(height*(self.cursor[2]-1))+(self.FontHeight/2)+self.Tween)*self.DPI
|
||||
x2=width+2+self.x+self.XTween
|
||||
y2=(self.y+(self.FontHeight/2)+self.Tween*self.DPI)+height*self.cursor[2]
|
||||
love.graphics.line(x1,y1,x2,y2)
|
||||
end
|
||||
end)
|
||||
c:OnUpdate(function(self)
|
||||
if love.keyboard.isDown("backspace") and self.Active and self.cooldown==false then
|
||||
if #self.text>0 then
|
||||
self.text = self.text:remove(self.cursor[1])
|
||||
self.ttext = self.ttext:remove(self.cursor[1])
|
||||
self.cursor[1]=self.cursor[1]-1
|
||||
end
|
||||
self.cooldown=true
|
||||
self.Alarm:Reset()
|
||||
elseif love.keyboard.isDown("backspace")==false then
|
||||
self.cooldown=false
|
||||
end
|
||||
if love.keyboard.isDown("left") and self.arrowkeys==false and self.Active then
|
||||
self.arrowkeys=true
|
||||
self.cursor[1]=self.cursor[1]-1
|
||||
if self.cursor[1]<0 then
|
||||
self.cursor[1]=0
|
||||
end
|
||||
self.ArrowAlarm:Reset()
|
||||
elseif love.keyboard.isDown("right") and self.arrowkeys==false and self.Active then
|
||||
self.arrowkeys=true
|
||||
self.cursor[1]=self.cursor[1]+1
|
||||
if self.cursor[1]>#self.text then
|
||||
self.cursor[1]=#self.text
|
||||
end
|
||||
self.ArrowAlarm:Reset()
|
||||
end
|
||||
if love.keyboard.isDown("delete") and self.Active then
|
||||
if #self.text>0 then
|
||||
self.text = ""
|
||||
self.ttext = ""
|
||||
self.cursor[1]=1
|
||||
end
|
||||
elseif (love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) and love.keyboard.isDown("return") and self.cooldown2==false then
|
||||
self.text=self.text.."\n"
|
||||
self.ttext=self.ttext.."\n"
|
||||
self.cooldown2=true
|
||||
c.Alarm2:Reset()
|
||||
elseif (love.keyboard.isDown("return") or love.keyboard.isDown("enter") or love.keyboard.isDown("kpenter")) and self.Active and self.Enter and not(love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) then
|
||||
if self.LoseFocusOnEnter then
|
||||
self.Active=false
|
||||
else
|
||||
self.Active=true
|
||||
end
|
||||
for cc=1,#self.funcE do
|
||||
self.funcE[cc](self,self.ttext)
|
||||
end
|
||||
end
|
||||
end)
|
||||
table.insert(gui.TB,c)
|
||||
return c
|
||||
end
|
||||
--TEXT BOX HELPER FUNCTION
|
||||
function love.textinput(t)
|
||||
for tb=1,#gui.TB do
|
||||
if gui.TB[tb]~=nil then
|
||||
if gui.TB[tb].Active then
|
||||
if gui.TB[tb].hidden then
|
||||
--gui.TB[tb].text=gui.TB[tb].text.."*"
|
||||
gui.TB[tb].text=gui.TB[tb].text:insert(gui.TB[tb].cursor[1],"*")
|
||||
else
|
||||
--gui.TB[tb].text=gui.TB[tb].text..t
|
||||
gui.TB[tb].text=gui.TB[tb].text:insert(gui.TB[tb].cursor[1],t)
|
||||
end
|
||||
gui.TB[tb].ttext=gui.TB[tb].ttext:insert(gui.TB[tb].cursor[1],t)
|
||||
gui.TB[tb].cursor[1]=gui.TB[tb].cursor[1]+1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,22 +0,0 @@
|
||||
function gui:newTextButton(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("TextButton",name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.Tween=0
|
||||
c.XTween=0
|
||||
c.FontHeight=_defaultfont:getHeight()
|
||||
c.Font=_defaultfont
|
||||
c.FontSize=15
|
||||
c.TextFormat="center"
|
||||
c.text = t
|
||||
c.AutoScaleText=false
|
||||
c.TextVisibility=1 -- 0=invisible,1=solid (self.TextVisibility*254+1)
|
||||
c.Color = {220, 220, 220}
|
||||
c.TextColor = {0, 0, 0}
|
||||
c:OnEnter(function()
|
||||
love.mouse.setCursor(_GuiPro.CursorH)
|
||||
end)
|
||||
c:OnExit(function()
|
||||
love.mouse.setCursor(_GuiPro.CursorN)
|
||||
end)
|
||||
return c
|
||||
end
|
||||
@ -1,81 +0,0 @@
|
||||
function gui:newHeader()
|
||||
local header=self:newFrame(0,0,0,20,0,0,1)
|
||||
header:ApplyGradient({Color.white,Color.light_blue,Color.blue,trans=200})
|
||||
header.last={x=0,width=0}
|
||||
function header:newTab(name)
|
||||
local font=love.graphics.getFont()
|
||||
local tab=self:newTextButton(name,self.last.x+self.last.width,0,font:getWidth(name)+6,20)
|
||||
self.last=tab
|
||||
tab.Visibility=0
|
||||
tab.Tween=-3
|
||||
tab.XTween=-2
|
||||
tab.Color=Color.white
|
||||
tab.largest={x=0,width=0}
|
||||
tab.Options=tab:newFrame("Options",0,20)
|
||||
tab.Options.Visible=false
|
||||
tab.Options.Color=Color.light_gray
|
||||
tab:OnEnter(function(self)
|
||||
self.Visibility=.5
|
||||
end)
|
||||
tab:OnExit(function(self)
|
||||
self.Visibility=0
|
||||
end)
|
||||
tab:OnReleased(function(b,self)
|
||||
if b=="l" then
|
||||
self.Options.Visible=true
|
||||
self:addDominance()
|
||||
end
|
||||
end)
|
||||
tab.Options:OnExit(function(self)
|
||||
self.Visible=false
|
||||
self:removeDominance()
|
||||
end)
|
||||
function tab:newOption(name,func,HK)
|
||||
local opt=self.Options:newTextButton(name,0,#self.Options:getChildren()*20,0,20,0,0,1)
|
||||
if HK then
|
||||
if type(HK)=="table" then
|
||||
for i=1,#HK do
|
||||
opt:addHotKey(HK[i]):OnHotKey(func)
|
||||
name=name.."\t\t\t\t\t\t"
|
||||
local temp=opt:newTextLabel(HK[i],-(font:getWidth(HK[i])+2),0,font:getWidth(HK[i])+2,20,1)
|
||||
temp.Visibility=0
|
||||
temp.Tween=-3
|
||||
temp.XTween=-2
|
||||
opt.text=name
|
||||
end
|
||||
else
|
||||
opt:setHotKey(HK)
|
||||
opt:OnHotKey(func)
|
||||
name=name.."\t\t\t\t\t\t"
|
||||
local temp=opt:newTextLabel(HK,-(font:getWidth(HK)+2),0,font:getWidth(HK)+2,20,1)
|
||||
temp.Visibility=0
|
||||
temp.Tween=-3
|
||||
temp.XTween=-2
|
||||
opt.text=name
|
||||
end
|
||||
end
|
||||
opt.TextFormat="left"
|
||||
opt.Visibility=0
|
||||
opt.Color=Color.white
|
||||
opt.Tween=-3
|
||||
opt:OnEnter(function(self)
|
||||
self.Visibility=.5
|
||||
end)
|
||||
opt:OnExit(function(self)
|
||||
self.Visibility=0
|
||||
end)
|
||||
local font=love.graphics.getFont()
|
||||
local c=self:getChildren()
|
||||
if font:getWidth(name)+6>self.largest.width then
|
||||
self.largest={width=font:getWidth(name)+6}
|
||||
end
|
||||
self.Options:SetDualDim(0,20,self.largest.width,#self.Options:getChildren()*20)
|
||||
if func then
|
||||
opt:OnReleased(func)
|
||||
end
|
||||
return opt
|
||||
end
|
||||
return tab
|
||||
end
|
||||
return header
|
||||
end
|
||||
@ -1,77 +0,0 @@
|
||||
function gui:addTip(tip,n,padding)
|
||||
local font=love.graphics.getFont()
|
||||
self.t=gui:newTextLabel(tip,"Tooltip",0,0,font:getWidth(tip)+(padding or 4),14)
|
||||
self.t:setNewFont(10)
|
||||
self.t.Visible=false
|
||||
self.t.Tween=1
|
||||
self.t.Color=Color.tan
|
||||
self.alarm=multi:newAlarm(0)
|
||||
self.alarm:Pause()
|
||||
self.alarm.parent=self
|
||||
self.time=n or 2
|
||||
self.padding=padding or 4
|
||||
self.alarm:OnRing(function(alarm)
|
||||
alarm.parent.t:SetDualDim(love.mouse.getX()-2,love.mouse.getY()-2)
|
||||
alarm.parent.t.Visible=true
|
||||
alarm.parent.t:addDominance()
|
||||
end)
|
||||
self:OnEnter(function(self)
|
||||
self.Visibility=.5
|
||||
self.alarm:Reset(self.time)
|
||||
end)
|
||||
self:OnExit(function(self)
|
||||
self.alarm:Pause()
|
||||
self.Visibility=0
|
||||
end)
|
||||
self.t:OnExit(function(self)
|
||||
self.Visible=false
|
||||
self:removeDominance()
|
||||
end)
|
||||
end
|
||||
function gui:newWindow(name)
|
||||
local win=self:newFrame(0,0,400,20)
|
||||
win.Draggable=true
|
||||
win.dragbut="r"
|
||||
win:OnDragStart(function(self)
|
||||
self:TopStack()
|
||||
end)
|
||||
if name then
|
||||
local font=love.graphics.getFont()
|
||||
win.title=win:newTextLabel(name,0,0,font:getWidth(name),20)
|
||||
win.title.TextFormat="left"
|
||||
win.title.Visibility=0
|
||||
win.title.XTween=3
|
||||
win.title.Tween=-3
|
||||
end
|
||||
win:ApplyGradient({Color.white,Color.light_blue,Color.blue,trans=200})
|
||||
win.close=win:newImageButton("icons/cancel.png",-20,2,16,16,1)
|
||||
win.close:OnEnter(function(self)
|
||||
self.Parent:removeDominance()
|
||||
self:addDominance()
|
||||
end)
|
||||
win.close:OnReleased(function(b,self)
|
||||
self.Parent:Destroy()
|
||||
self:removeDominance()
|
||||
love.mouse.setCursor()
|
||||
end)
|
||||
win.close:OnExit(function(self)
|
||||
self:removeDominance()
|
||||
end)
|
||||
win.holder=win:newFrame(0,0,0,280,0,1,1)
|
||||
win:OnUpdate(function(self)
|
||||
if self.y<40 then self:SetDualDim(nil,0) love.mouse.setY(50) end
|
||||
end)
|
||||
win:OnEnter(function(self)
|
||||
self:addDominance()
|
||||
end)
|
||||
win:OnExit(function(self)
|
||||
self:removeDominance()
|
||||
end)
|
||||
win.holder:OnEnter(function(self)
|
||||
self:addDominance()
|
||||
end)
|
||||
win.holder:OnExit(function(self)
|
||||
self:removeDominance()
|
||||
end)
|
||||
return win.holder,win
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
These libraries Namely the MultiManager, bin, and the Library, libraries will be documented because i plan on sharing them
|
||||
everything else will mostlikely not be documented
|
||||
598
Libs/T1.lua
598
Libs/T1.lua
@ -1,598 +0,0 @@
|
||||
require("love.timer")
|
||||
require("love.system")
|
||||
require("love.sound")
|
||||
require("love.physics")
|
||||
require("love.mouse")
|
||||
require("love.math")
|
||||
require("love.keyboard")
|
||||
require("love.joystick")
|
||||
require("love.image")
|
||||
require("love.font")
|
||||
require("love.filesystem")
|
||||
require("love.event")
|
||||
require("love.audio")
|
||||
require("love.graphics")
|
||||
require("love.window")
|
||||
_defaultfont = love.graphics.getFont()
|
||||
gui = {}
|
||||
function gui.getTile(i,x,y,w,h)-- returns imagedata
|
||||
if type(i)=="userdata" then
|
||||
-- do nothing
|
||||
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
|
||||
multi = {}
|
||||
multi.Version="4.0.0"
|
||||
multi.__index = multi
|
||||
multi.Mainloop={}
|
||||
multi.Tasks={}
|
||||
multi.Tasks2={}
|
||||
multi.Garbage={}
|
||||
multi.Children={}
|
||||
multi.Paused={}
|
||||
multi.MasterId=0
|
||||
multi.Active=true
|
||||
multi.Id=-1
|
||||
multi.Type="MainInt"
|
||||
multi.Rest=0
|
||||
-- System
|
||||
os.sleep=love.timer.sleep
|
||||
function multi:newBase(ins)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then error("Can only create an object on multi or an interface obj") return false end
|
||||
local c = {}
|
||||
if self.Type=="int" then
|
||||
setmetatable(c, self.Parent)
|
||||
else
|
||||
setmetatable(c, self)
|
||||
end
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Act=function() end
|
||||
c.Parent=self
|
||||
if ins then
|
||||
table.insert(self.Mainloop,ins,c)
|
||||
else
|
||||
table.insert(self.Mainloop,c)
|
||||
end
|
||||
self.MasterId=self.MasterId+1
|
||||
return c
|
||||
end
|
||||
function multi:reboot(r)
|
||||
self.Mainloop={}
|
||||
self.Tasks={}
|
||||
self.Tasks2={}
|
||||
self.Garbage={}
|
||||
self.Children={}
|
||||
self.Paused={}
|
||||
self.MasterId=0
|
||||
self.Active=true
|
||||
self.Id=-1
|
||||
if r then
|
||||
for i,v in pairs(_G) do
|
||||
if type(i)=="table" then
|
||||
if i.Parent and i.Id and i.Act then
|
||||
i={}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:getChildren()
|
||||
return self.Mainloop
|
||||
end
|
||||
--Processor
|
||||
function multi:Do_Order()
|
||||
for _D=#self.Mainloop,1,-1 do
|
||||
if self.Mainloop[_D]~=nil then
|
||||
self.Mainloop[_D].Id=_D
|
||||
self.Mainloop[_D]:Act()
|
||||
end
|
||||
if self.Mainloop[_D].rem then
|
||||
table.remove(self.Mainloop,_D)
|
||||
end
|
||||
end
|
||||
if self.Rest>0 then
|
||||
os.sleep(self.Rest)
|
||||
end
|
||||
end
|
||||
function multi:benchMark(sec)
|
||||
local temp=self:newLoop(function(t,self)
|
||||
if os.clock()-self.init>self.sec then
|
||||
print(self.c.." steps in "..self.sec.." second(s)")
|
||||
self.tt(self.sec)
|
||||
self:Destroy()
|
||||
else
|
||||
self.c=self.c+1
|
||||
end
|
||||
end)
|
||||
function temp:OnBench(func)
|
||||
self.tt=func
|
||||
end
|
||||
self.tt=function() end
|
||||
temp.sec=sec
|
||||
temp.init=os.clock()
|
||||
temp.c=0
|
||||
return temp
|
||||
end
|
||||
function multi:newInterface()
|
||||
if not(self.Type=="MainInt") then error("Can only create an interface on the multi obj") return false end
|
||||
local c = {}
|
||||
setmetatable(c, self)
|
||||
c.Parent=self
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Type="int"
|
||||
c.Mainloop={}
|
||||
c.Tasks={}
|
||||
c.Tasks2={}
|
||||
c.Garbage={}
|
||||
c.Children={}
|
||||
c.Paused={}
|
||||
c.MasterId=0
|
||||
c.Active=true
|
||||
c.Id=-1
|
||||
c.Rest=0
|
||||
function c:Start()
|
||||
if self.l then
|
||||
self.l:Resume()
|
||||
else
|
||||
self.l=self.Parent:newLoop(function(dt) c:uManager(dt) end)
|
||||
end
|
||||
end
|
||||
function c:Stop()
|
||||
if self.l then
|
||||
self.l:Pause()
|
||||
end
|
||||
end
|
||||
function c:Remove()
|
||||
self:Destroy()
|
||||
self.l:Destroy()
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Helpers
|
||||
function multi:FreeMainEvent()
|
||||
self.func={}
|
||||
end
|
||||
function multi:isPaused()
|
||||
return not(self.Active)
|
||||
end
|
||||
function multi:Pause(n)
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=false
|
||||
if not(n) then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Pause()
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
else
|
||||
if not(n) then
|
||||
self.Active=false
|
||||
if self.Parent.Mainloop[self.Id]~=nil then
|
||||
table.remove(self.Parent.Mainloop,self.Id)
|
||||
table.insert(self.Parent.Paused,self)
|
||||
self.Id=#self.Parent.Paused
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Resume()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=true
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Resume()
|
||||
end
|
||||
else
|
||||
if self:isPaused() then
|
||||
self.Active=true
|
||||
for i=1,#self.Parent.Paused do
|
||||
if self.Parent.Paused[i]==self then
|
||||
table.remove(self.Parent.Paused,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Mainloop,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Destroy()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Destroy()
|
||||
end
|
||||
else
|
||||
self.rem=true
|
||||
end
|
||||
end
|
||||
function multi:hold(task)
|
||||
self:Pause()
|
||||
if type(task)=="number" then
|
||||
local alarm=self:newAlarm(task)
|
||||
while alarm.Active==true do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
alarm:Destroy()
|
||||
self:Resume()
|
||||
elseif type(task)=="function" then
|
||||
local env=self.Parent:newEvent(task)
|
||||
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
|
||||
while env.Active do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
env:Destroy()
|
||||
self:Resume()
|
||||
else
|
||||
print("Error Data Type!!!")
|
||||
end
|
||||
end
|
||||
function multi:oneTime(func,...)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then
|
||||
for _k=1,#self.Parent.Tasks2 do
|
||||
if self.Parent.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
else
|
||||
for _k=1,#self.Tasks2 do
|
||||
if self.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
end
|
||||
end
|
||||
--Constructors
|
||||
function multi:newEvent(task)
|
||||
local c=self:newBase()
|
||||
c.Type="Event"
|
||||
c.Task=task or function() end
|
||||
function c:Act()
|
||||
if self.Task(self) and self.Active==true then
|
||||
self:Pause()
|
||||
for _E=1,#self.func do
|
||||
self.func[_E](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEvent(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newAlarm(set)
|
||||
local c=self:newBase()
|
||||
c.Type="Alarm"
|
||||
c.timer=os.clock()
|
||||
c.set=set or 0
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Pause()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnRing(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTask(func)
|
||||
table.insert(self.Tasks,func)
|
||||
end
|
||||
function multi:newLoop(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Loop"
|
||||
if func then
|
||||
c.func={func}
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](os.clock()-self.Parent.Start,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnLoop(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newStep(start,reset,count,skip)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="Step"
|
||||
c.pos=start or 1
|
||||
c.endAt=reset or math.huge
|
||||
c.skip=skip or 0
|
||||
c.spos=0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.start=start or 1
|
||||
if start~=nil and reset~=nil then
|
||||
if start>reset then
|
||||
think=-1
|
||||
end
|
||||
end
|
||||
function c:Act()
|
||||
if self~=nil then
|
||||
if self.spos==0 then
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
self.spos=self.spos+1
|
||||
if self.spos>=self.skip then
|
||||
self.spos=0
|
||||
end
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,1,func)
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Update(start,reset,count,skip)
|
||||
self.start=start or self.start
|
||||
self.endAt=reset or self.endAt
|
||||
self.skip=skip or self.skip
|
||||
self.count=count or self.count
|
||||
self:Resume()
|
||||
end
|
||||
c:OnStep(function(p,s)
|
||||
if s.count>0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
elseif s.count<0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
end
|
||||
end)
|
||||
return c
|
||||
end
|
||||
function multi:newTStep(start,reset,count,set)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="TStep"
|
||||
c.start=start or 1
|
||||
local reset = reset or math.huge
|
||||
c.endAt=reset
|
||||
c.pos=start or 1
|
||||
c.skip=skip or 0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.timer=os.clock()
|
||||
c.set=set or 1
|
||||
function c:Update(start,reset,count,set)
|
||||
self.start=start or self.start
|
||||
self.pos=start
|
||||
self.endAt=reset or self.endAt
|
||||
self.set=set or self.set
|
||||
self.count=count or self.count or 1
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Reset()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
if self.endAt==self.pos then
|
||||
for fe=1,#self.funcE do
|
||||
self.funcE[fe](self)
|
||||
end
|
||||
self.pos=self.start-1
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTrigger(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Trigger"
|
||||
c.trigfunc=func or function() end
|
||||
function c:Fire(...)
|
||||
self:trigfunc(self,...)
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Managers
|
||||
function multi:mainloop()
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
self.Start=os.clock()
|
||||
while self.Active do
|
||||
self:Do_Order()
|
||||
end
|
||||
end
|
||||
function multi._tFunc(self,dt)
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
print("once!")
|
||||
if dt then
|
||||
self.pump=true
|
||||
end
|
||||
self.pumpvar=dt
|
||||
self.Start=os.clock()
|
||||
end
|
||||
function multi:uManager(dt)
|
||||
self:oneTime(self._tFunc,self,dt)
|
||||
self:Do_Order()
|
||||
end
|
||||
multi.drawF={}
|
||||
function multi:dManager()
|
||||
for ii=1,#multi.drawF do
|
||||
multi.drawF[ii]()
|
||||
end
|
||||
end
|
||||
function multi:onDraw(func)
|
||||
table.insert(self.drawF,func)
|
||||
end
|
||||
function multi:lManager()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
Thread={}
|
||||
Thread.Name="Thread 1"
|
||||
Thread.ChannelThread = love.thread.getChannel("Easy1")
|
||||
Thread.ChannelMain = love.thread.getChannel("EasyMain")
|
||||
Thread.Global = {}
|
||||
function Thread:packTable(G)
|
||||
function escapeStr(str)
|
||||
local temp=""
|
||||
for i=1,#str do
|
||||
temp=temp.."\\"..string.byte(string.sub(str,i,i))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function ToStr(t)
|
||||
local dat="{"
|
||||
for i,v in pairs(t) do
|
||||
if type(i)=="number" then
|
||||
i="["..i.."]="
|
||||
else
|
||||
i=i.."="
|
||||
end
|
||||
if type(v)=="string" then
|
||||
dat=dat..i.."\""..v.."\","
|
||||
elseif type(v)=="number" then
|
||||
dat=dat..i..v..","
|
||||
elseif type(v)=="boolean" then
|
||||
dat=dat..i..tostring(v)..","
|
||||
elseif type(v)=="table" and not(G==v) then
|
||||
dat=dat..i..ToStr(v)..","
|
||||
--elseif type(v)=="table" and G==v then
|
||||
-- dat=dat..i.."assert(loadstring(\"return self\")),"
|
||||
elseif type(v)=="function" then
|
||||
dat=dat..i.."assert(loadstring(\""..escapeStr(string.dump(v)).."\")),"
|
||||
end
|
||||
end
|
||||
return string.sub(dat,1,-2).."}"
|
||||
end
|
||||
return "return "..ToStr(G)
|
||||
end
|
||||
function Thread:Send(name,var)
|
||||
arg3="1"
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3="table"
|
||||
end
|
||||
self.ChannelMain:push({name,var,arg3})
|
||||
end
|
||||
function Thread:UnPackChannel()
|
||||
local c=self.ChannelThread:getCount()
|
||||
for i=1,c do
|
||||
local temp=self.ChannelThread:pop()
|
||||
if temp[1] and temp[2] then
|
||||
if temp[1]=="func" and type(temp[2])=="string" then
|
||||
loadstring(temp[2])(temp[3])
|
||||
elseif temp[1]=="table" then
|
||||
_G[temp[3]]=loadstring(temp[2])()
|
||||
else
|
||||
_G[temp[1]]=temp[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
if #multi:getChildren()<2 then
|
||||
os.sleep(.05)
|
||||
end
|
||||
end
|
||||
function Thread:boost(func,name)
|
||||
self:Send(name,string.dump(func))
|
||||
end
|
||||
function Thread.mainloop()
|
||||
Thread:UnPackChannel()
|
||||
end
|
||||
Thread.MainThread=false
|
||||
multi:newLoop():OnLoop(Thread.mainloop)
|
||||
multi:mainloop()
|
||||
598
Libs/T2.lua
598
Libs/T2.lua
@ -1,598 +0,0 @@
|
||||
require("love.timer")
|
||||
require("love.system")
|
||||
require("love.sound")
|
||||
require("love.physics")
|
||||
require("love.mouse")
|
||||
require("love.math")
|
||||
require("love.keyboard")
|
||||
require("love.joystick")
|
||||
require("love.image")
|
||||
require("love.font")
|
||||
require("love.filesystem")
|
||||
require("love.event")
|
||||
require("love.audio")
|
||||
require("love.graphics")
|
||||
require("love.window")
|
||||
_defaultfont = love.graphics.getFont()
|
||||
gui = {}
|
||||
function gui.getTile(i,x,y,w,h)-- returns imagedata
|
||||
if type(i)=="userdata" then
|
||||
-- do nothing
|
||||
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
|
||||
multi = {}
|
||||
multi.Version="4.0.0"
|
||||
multi.__index = multi
|
||||
multi.Mainloop={}
|
||||
multi.Tasks={}
|
||||
multi.Tasks2={}
|
||||
multi.Garbage={}
|
||||
multi.Children={}
|
||||
multi.Paused={}
|
||||
multi.MasterId=0
|
||||
multi.Active=true
|
||||
multi.Id=-1
|
||||
multi.Type="MainInt"
|
||||
multi.Rest=0
|
||||
-- System
|
||||
os.sleep=love.timer.sleep
|
||||
function multi:newBase(ins)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then error("Can only create an object on multi or an interface obj") return false end
|
||||
local c = {}
|
||||
if self.Type=="int" then
|
||||
setmetatable(c, self.Parent)
|
||||
else
|
||||
setmetatable(c, self)
|
||||
end
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Act=function() end
|
||||
c.Parent=self
|
||||
if ins then
|
||||
table.insert(self.Mainloop,ins,c)
|
||||
else
|
||||
table.insert(self.Mainloop,c)
|
||||
end
|
||||
self.MasterId=self.MasterId+1
|
||||
return c
|
||||
end
|
||||
function multi:reboot(r)
|
||||
self.Mainloop={}
|
||||
self.Tasks={}
|
||||
self.Tasks2={}
|
||||
self.Garbage={}
|
||||
self.Children={}
|
||||
self.Paused={}
|
||||
self.MasterId=0
|
||||
self.Active=true
|
||||
self.Id=-1
|
||||
if r then
|
||||
for i,v in pairs(_G) do
|
||||
if type(i)=="table" then
|
||||
if i.Parent and i.Id and i.Act then
|
||||
i={}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:getChildren()
|
||||
return self.Mainloop
|
||||
end
|
||||
--Processor
|
||||
function multi:Do_Order()
|
||||
for _D=#self.Mainloop,1,-1 do
|
||||
if self.Mainloop[_D]~=nil then
|
||||
self.Mainloop[_D].Id=_D
|
||||
self.Mainloop[_D]:Act()
|
||||
end
|
||||
if self.Mainloop[_D].rem then
|
||||
table.remove(self.Mainloop,_D)
|
||||
end
|
||||
end
|
||||
if self.Rest>0 then
|
||||
os.sleep(self.Rest)
|
||||
end
|
||||
end
|
||||
function multi:benchMark(sec)
|
||||
local temp=self:newLoop(function(t,self)
|
||||
if os.clock()-self.init>self.sec then
|
||||
print(self.c.." steps in "..self.sec.." second(s)")
|
||||
self.tt(self.sec)
|
||||
self:Destroy()
|
||||
else
|
||||
self.c=self.c+1
|
||||
end
|
||||
end)
|
||||
function temp:OnBench(func)
|
||||
self.tt=func
|
||||
end
|
||||
self.tt=function() end
|
||||
temp.sec=sec
|
||||
temp.init=os.clock()
|
||||
temp.c=0
|
||||
return temp
|
||||
end
|
||||
function multi:newInterface()
|
||||
if not(self.Type=="MainInt") then error("Can only create an interface on the multi obj") return false end
|
||||
local c = {}
|
||||
setmetatable(c, self)
|
||||
c.Parent=self
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Type="int"
|
||||
c.Mainloop={}
|
||||
c.Tasks={}
|
||||
c.Tasks2={}
|
||||
c.Garbage={}
|
||||
c.Children={}
|
||||
c.Paused={}
|
||||
c.MasterId=0
|
||||
c.Active=true
|
||||
c.Id=-1
|
||||
c.Rest=0
|
||||
function c:Start()
|
||||
if self.l then
|
||||
self.l:Resume()
|
||||
else
|
||||
self.l=self.Parent:newLoop(function(dt) c:uManager(dt) end)
|
||||
end
|
||||
end
|
||||
function c:Stop()
|
||||
if self.l then
|
||||
self.l:Pause()
|
||||
end
|
||||
end
|
||||
function c:Remove()
|
||||
self:Destroy()
|
||||
self.l:Destroy()
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Helpers
|
||||
function multi:FreeMainEvent()
|
||||
self.func={}
|
||||
end
|
||||
function multi:isPaused()
|
||||
return not(self.Active)
|
||||
end
|
||||
function multi:Pause(n)
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=false
|
||||
if not(n) then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Pause()
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
else
|
||||
if not(n) then
|
||||
self.Active=false
|
||||
if self.Parent.Mainloop[self.Id]~=nil then
|
||||
table.remove(self.Parent.Mainloop,self.Id)
|
||||
table.insert(self.Parent.Paused,self)
|
||||
self.Id=#self.Parent.Paused
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Resume()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=true
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Resume()
|
||||
end
|
||||
else
|
||||
if self:isPaused() then
|
||||
self.Active=true
|
||||
for i=1,#self.Parent.Paused do
|
||||
if self.Parent.Paused[i]==self then
|
||||
table.remove(self.Parent.Paused,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Mainloop,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Destroy()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Destroy()
|
||||
end
|
||||
else
|
||||
self.rem=true
|
||||
end
|
||||
end
|
||||
function multi:hold(task)
|
||||
self:Pause()
|
||||
if type(task)=="number" then
|
||||
local alarm=self:newAlarm(task)
|
||||
while alarm.Active==true do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
alarm:Destroy()
|
||||
self:Resume()
|
||||
elseif type(task)=="function" then
|
||||
local env=self.Parent:newEvent(task)
|
||||
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
|
||||
while env.Active do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
env:Destroy()
|
||||
self:Resume()
|
||||
else
|
||||
print("Error Data Type!!!")
|
||||
end
|
||||
end
|
||||
function multi:oneTime(func,...)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then
|
||||
for _k=1,#self.Parent.Tasks2 do
|
||||
if self.Parent.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
else
|
||||
for _k=1,#self.Tasks2 do
|
||||
if self.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
end
|
||||
end
|
||||
--Constructors
|
||||
function multi:newEvent(task)
|
||||
local c=self:newBase()
|
||||
c.Type="Event"
|
||||
c.Task=task or function() end
|
||||
function c:Act()
|
||||
if self.Task(self) and self.Active==true then
|
||||
self:Pause()
|
||||
for _E=1,#self.func do
|
||||
self.func[_E](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEvent(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newAlarm(set)
|
||||
local c=self:newBase()
|
||||
c.Type="Alarm"
|
||||
c.timer=os.clock()
|
||||
c.set=set or 0
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Pause()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnRing(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTask(func)
|
||||
table.insert(self.Tasks,func)
|
||||
end
|
||||
function multi:newLoop(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Loop"
|
||||
if func then
|
||||
c.func={func}
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](os.clock()-self.Parent.Start,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnLoop(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newStep(start,reset,count,skip)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="Step"
|
||||
c.pos=start or 1
|
||||
c.endAt=reset or math.huge
|
||||
c.skip=skip or 0
|
||||
c.spos=0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.start=start or 1
|
||||
if start~=nil and reset~=nil then
|
||||
if start>reset then
|
||||
think=-1
|
||||
end
|
||||
end
|
||||
function c:Act()
|
||||
if self~=nil then
|
||||
if self.spos==0 then
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
self.spos=self.spos+1
|
||||
if self.spos>=self.skip then
|
||||
self.spos=0
|
||||
end
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,1,func)
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Update(start,reset,count,skip)
|
||||
self.start=start or self.start
|
||||
self.endAt=reset or self.endAt
|
||||
self.skip=skip or self.skip
|
||||
self.count=count or self.count
|
||||
self:Resume()
|
||||
end
|
||||
c:OnStep(function(p,s)
|
||||
if s.count>0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
elseif s.count<0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
end
|
||||
end)
|
||||
return c
|
||||
end
|
||||
function multi:newTStep(start,reset,count,set)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="TStep"
|
||||
c.start=start or 1
|
||||
local reset = reset or math.huge
|
||||
c.endAt=reset
|
||||
c.pos=start or 1
|
||||
c.skip=skip or 0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.timer=os.clock()
|
||||
c.set=set or 1
|
||||
function c:Update(start,reset,count,set)
|
||||
self.start=start or self.start
|
||||
self.pos=start
|
||||
self.endAt=reset or self.endAt
|
||||
self.set=set or self.set
|
||||
self.count=count or self.count or 1
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Reset()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
if self.endAt==self.pos then
|
||||
for fe=1,#self.funcE do
|
||||
self.funcE[fe](self)
|
||||
end
|
||||
self.pos=self.start-1
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTrigger(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Trigger"
|
||||
c.trigfunc=func or function() end
|
||||
function c:Fire(...)
|
||||
self:trigfunc(self,...)
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Managers
|
||||
function multi:mainloop()
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
self.Start=os.clock()
|
||||
while self.Active do
|
||||
self:Do_Order()
|
||||
end
|
||||
end
|
||||
function multi._tFunc(self,dt)
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
print("once!")
|
||||
if dt then
|
||||
self.pump=true
|
||||
end
|
||||
self.pumpvar=dt
|
||||
self.Start=os.clock()
|
||||
end
|
||||
function multi:uManager(dt)
|
||||
self:oneTime(self._tFunc,self,dt)
|
||||
self:Do_Order()
|
||||
end
|
||||
multi.drawF={}
|
||||
function multi:dManager()
|
||||
for ii=1,#multi.drawF do
|
||||
multi.drawF[ii]()
|
||||
end
|
||||
end
|
||||
function multi:onDraw(func)
|
||||
table.insert(self.drawF,func)
|
||||
end
|
||||
function multi:lManager()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
Thread={}
|
||||
Thread.Name="Thread 2"
|
||||
Thread.ChannelThread = love.thread.getChannel("Easy2")
|
||||
Thread.ChannelMain = love.thread.getChannel("EasyMain")
|
||||
Thread.Global = {}
|
||||
function Thread:packTable(G)
|
||||
function escapeStr(str)
|
||||
local temp=""
|
||||
for i=1,#str do
|
||||
temp=temp.."\\"..string.byte(string.sub(str,i,i))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function ToStr(t)
|
||||
local dat="{"
|
||||
for i,v in pairs(t) do
|
||||
if type(i)=="number" then
|
||||
i="["..i.."]="
|
||||
else
|
||||
i=i.."="
|
||||
end
|
||||
if type(v)=="string" then
|
||||
dat=dat..i.."\""..v.."\","
|
||||
elseif type(v)=="number" then
|
||||
dat=dat..i..v..","
|
||||
elseif type(v)=="boolean" then
|
||||
dat=dat..i..tostring(v)..","
|
||||
elseif type(v)=="table" and not(G==v) then
|
||||
dat=dat..i..ToStr(v)..","
|
||||
--elseif type(v)=="table" and G==v then
|
||||
-- dat=dat..i.."assert(loadstring(\"return self\")),"
|
||||
elseif type(v)=="function" then
|
||||
dat=dat..i.."assert(loadstring(\""..escapeStr(string.dump(v)).."\")),"
|
||||
end
|
||||
end
|
||||
return string.sub(dat,1,-2).."}"
|
||||
end
|
||||
return "return "..ToStr(G)
|
||||
end
|
||||
function Thread:Send(name,var)
|
||||
arg3="2"
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3="table"
|
||||
end
|
||||
self.ChannelMain:push({name,var,arg3})
|
||||
end
|
||||
function Thread:UnPackChannel()
|
||||
local c=self.ChannelThread:getCount()
|
||||
for i=1,c do
|
||||
local temp=self.ChannelThread:pop()
|
||||
if temp[1] and temp[2] then
|
||||
if temp[1]=="func" and type(temp[2])=="string" then
|
||||
loadstring(temp[2])(temp[3])
|
||||
elseif temp[1]=="table" then
|
||||
_G[temp[3]]=loadstring(temp[2])()
|
||||
else
|
||||
_G[temp[1]]=temp[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
if #multi:getChildren()<2 then
|
||||
os.sleep(.05)
|
||||
end
|
||||
end
|
||||
function Thread:boost(func,name)
|
||||
self:Send(name,string.dump(func))
|
||||
end
|
||||
function Thread.mainloop()
|
||||
Thread:UnPackChannel()
|
||||
end
|
||||
Thread.MainThread=false
|
||||
multi:newLoop():OnLoop(Thread.mainloop)
|
||||
multi:mainloop()
|
||||
596
Libs/T3.lua
596
Libs/T3.lua
@ -1,596 +0,0 @@
|
||||
require("love.timer")
|
||||
require("love.system")
|
||||
require("love.sound")
|
||||
require("love.physics")
|
||||
require("love.mouse")
|
||||
require("love.math")
|
||||
require("love.keyboard")
|
||||
require("love.joystick")
|
||||
require("love.image")
|
||||
require("love.font")
|
||||
require("love.filesystem")
|
||||
require("love.event")
|
||||
require("love.audio")
|
||||
require("love.graphics")
|
||||
require("love.window")
|
||||
_defaultfont = love.graphics.getFont()
|
||||
gui = {}
|
||||
function gui.getTile(i,x,y,w,h)-- returns imagedata
|
||||
if type(i)=="userdata" then
|
||||
-- do nothing
|
||||
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
|
||||
multi = {}
|
||||
multi.Version="4.0.0"
|
||||
multi.__index = multi
|
||||
multi.Mainloop={}
|
||||
multi.Tasks={}
|
||||
multi.Tasks2={}
|
||||
multi.Garbage={}
|
||||
multi.Children={}
|
||||
multi.Paused={}
|
||||
multi.MasterId=0
|
||||
multi.Active=true
|
||||
multi.Id=-1
|
||||
multi.Type="MainInt"
|
||||
multi.Rest=0
|
||||
-- System
|
||||
os.sleep=love.timer.sleep
|
||||
function multi:newBase(ins)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then error("Can only create an object on multi or an interface obj") return false end
|
||||
local c = {}
|
||||
if self.Type=="int" then
|
||||
setmetatable(c, self.Parent)
|
||||
else
|
||||
setmetatable(c, self)
|
||||
end
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Act=function() end
|
||||
c.Parent=self
|
||||
if ins then
|
||||
table.insert(self.Mainloop,ins,c)
|
||||
else
|
||||
table.insert(self.Mainloop,c)
|
||||
end
|
||||
self.MasterId=self.MasterId+1
|
||||
return c
|
||||
end
|
||||
function multi:reboot(r)
|
||||
self.Mainloop={}
|
||||
self.Tasks={}
|
||||
self.Tasks2={}
|
||||
self.Garbage={}
|
||||
self.Children={}
|
||||
self.Paused={}
|
||||
self.MasterId=0
|
||||
self.Active=true
|
||||
self.Id=-1
|
||||
if r then
|
||||
for i,v in pairs(_G) do
|
||||
if type(i)=="table" then
|
||||
if i.Parent and i.Id and i.Act then
|
||||
i={}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:getChildren()
|
||||
return self.Mainloop
|
||||
end
|
||||
--Processor
|
||||
function multi:Do_Order()
|
||||
for _D=#self.Mainloop,1,-1 do
|
||||
if self.Mainloop[_D]~=nil then
|
||||
self.Mainloop[_D].Id=_D
|
||||
self.Mainloop[_D]:Act()
|
||||
end
|
||||
if self.Mainloop[_D].rem then
|
||||
table.remove(self.Mainloop,_D)
|
||||
end
|
||||
end
|
||||
if self.Rest>0 then
|
||||
os.sleep(self.Rest)
|
||||
end
|
||||
end
|
||||
function multi:benchMark(sec)
|
||||
local temp=self:newLoop(function(t,self)
|
||||
if os.clock()-self.init>self.sec then
|
||||
print(self.c.." steps in "..self.sec.." second(s)")
|
||||
self.tt(self.sec)
|
||||
self:Destroy()
|
||||
else
|
||||
self.c=self.c+1
|
||||
end
|
||||
end)
|
||||
function temp:OnBench(func)
|
||||
self.tt=func
|
||||
end
|
||||
self.tt=function() end
|
||||
temp.sec=sec
|
||||
temp.init=os.clock()
|
||||
temp.c=0
|
||||
return temp
|
||||
end
|
||||
function multi:newInterface()
|
||||
if not(self.Type=="MainInt") then error("Can only create an interface on the multi obj") return false end
|
||||
local c = {}
|
||||
setmetatable(c, self)
|
||||
c.Parent=self
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Type="int"
|
||||
c.Mainloop={}
|
||||
c.Tasks={}
|
||||
c.Tasks2={}
|
||||
c.Garbage={}
|
||||
c.Children={}
|
||||
c.Paused={}
|
||||
c.MasterId=0
|
||||
c.Active=true
|
||||
c.Id=-1
|
||||
c.Rest=0
|
||||
function c:Start()
|
||||
if self.l then
|
||||
self.l:Resume()
|
||||
else
|
||||
self.l=self.Parent:newLoop(function(dt) c:uManager(dt) end)
|
||||
end
|
||||
end
|
||||
function c:Stop()
|
||||
if self.l then
|
||||
self.l:Pause()
|
||||
end
|
||||
end
|
||||
function c:Remove()
|
||||
self:Destroy()
|
||||
self.l:Destroy()
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Helpers
|
||||
function multi:FreeMainEvent()
|
||||
self.func={}
|
||||
end
|
||||
function multi:isPaused()
|
||||
return not(self.Active)
|
||||
end
|
||||
function multi:Pause(n)
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=false
|
||||
if not(n) then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Pause()
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
else
|
||||
if not(n) then
|
||||
self.Active=false
|
||||
if self.Parent.Mainloop[self.Id]~=nil then
|
||||
table.remove(self.Parent.Mainloop,self.Id)
|
||||
table.insert(self.Parent.Paused,self)
|
||||
self.Id=#self.Parent.Paused
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Resume()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=true
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Resume()
|
||||
end
|
||||
else
|
||||
if self:isPaused() then
|
||||
self.Active=true
|
||||
for i=1,#self.Parent.Paused do
|
||||
if self.Parent.Paused[i]==self then
|
||||
table.remove(self.Parent.Paused,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Mainloop,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Destroy()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Destroy()
|
||||
end
|
||||
else
|
||||
self.rem=true
|
||||
end
|
||||
end
|
||||
function multi:hold(task)
|
||||
self:Pause()
|
||||
if type(task)=="number" then
|
||||
local alarm=self:newAlarm(task)
|
||||
while alarm.Active==true do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
alarm:Destroy()
|
||||
self:Resume()
|
||||
elseif type(task)=="function" then
|
||||
local env=self.Parent:newEvent(task)
|
||||
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
|
||||
while env.Active do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
env:Destroy()
|
||||
self:Resume()
|
||||
else
|
||||
print("Error Data Type!!!")
|
||||
end
|
||||
end
|
||||
function multi:oneTime(func,...)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then
|
||||
for _k=1,#self.Parent.Tasks2 do
|
||||
if self.Parent.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
else
|
||||
for _k=1,#self.Tasks2 do
|
||||
if self.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
end
|
||||
end
|
||||
--Constructors
|
||||
function multi:newEvent(task)
|
||||
local c=self:newBase()
|
||||
c.Type="Event"
|
||||
c.Task=task or function() end
|
||||
function c:Act()
|
||||
if self.Task(self) and self.Active==true then
|
||||
self:Pause()
|
||||
for _E=1,#self.func do
|
||||
self.func[_E](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEvent(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newAlarm(set)
|
||||
local c=self:newBase()
|
||||
c.Type="Alarm"
|
||||
c.timer=os.clock()
|
||||
c.set=set or 0
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Pause()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnRing(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTask(func)
|
||||
table.insert(self.Tasks,func)
|
||||
end
|
||||
function multi:newLoop(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Loop"
|
||||
if func then
|
||||
c.func={func}
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](os.clock()-self.Parent.Start,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnLoop(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newStep(start,reset,count,skip)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="Step"
|
||||
c.pos=start or 1
|
||||
c.endAt=reset or math.huge
|
||||
c.skip=skip or 0
|
||||
c.spos=0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.start=start or 1
|
||||
if start~=nil and reset~=nil then
|
||||
if start>reset then
|
||||
think=-1
|
||||
end
|
||||
end
|
||||
function c:Act()
|
||||
if self~=nil then
|
||||
if self.spos==0 then
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
self.spos=self.spos+1
|
||||
if self.spos>=self.skip then
|
||||
self.spos=0
|
||||
end
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,1,func)
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Update(start,reset,count,skip)
|
||||
self.start=start or self.start
|
||||
self.endAt=reset or self.endAt
|
||||
self.skip=skip or self.skip
|
||||
self.count=count or self.count
|
||||
self:Resume()
|
||||
end
|
||||
c:OnStep(function(p,s)
|
||||
if s.count>0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
elseif s.count<0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
end
|
||||
end)
|
||||
return c
|
||||
end
|
||||
function multi:newTStep(start,reset,count,set)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="TStep"
|
||||
c.start=start or 1
|
||||
local reset = reset or math.huge
|
||||
c.endAt=reset
|
||||
c.pos=start or 1
|
||||
c.skip=skip or 0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.timer=os.clock()
|
||||
c.set=set or 1
|
||||
function c:Update(start,reset,count,set)
|
||||
self.start=start or self.start
|
||||
self.pos=start
|
||||
self.endAt=reset or self.endAt
|
||||
self.set=set or self.set
|
||||
self.count=count or self.count or 1
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Reset()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
if self.endAt==self.pos then
|
||||
for fe=1,#self.funcE do
|
||||
self.funcE[fe](self)
|
||||
end
|
||||
self.pos=self.start-1
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTrigger(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Trigger"
|
||||
c.trigfunc=func or function() end
|
||||
function c:Fire(...)
|
||||
self:trigfunc(self,...)
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Managers
|
||||
function multi:mainloop()
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
self.Start=os.clock()
|
||||
while self.Active do
|
||||
self:Do_Order()
|
||||
end
|
||||
end
|
||||
function multi._tFunc(self,dt)
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
print("once!")
|
||||
if dt then
|
||||
self.pump=true
|
||||
end
|
||||
self.pumpvar=dt
|
||||
self.Start=os.clock()
|
||||
end
|
||||
function multi:uManager(dt)
|
||||
self:oneTime(self._tFunc,self,dt)
|
||||
self:Do_Order()
|
||||
end
|
||||
multi.drawF={}
|
||||
function multi:dManager()
|
||||
for ii=1,#multi.drawF do
|
||||
multi.drawF[ii]()
|
||||
end
|
||||
end
|
||||
function multi:onDraw(func)
|
||||
table.insert(self.drawF,func)
|
||||
end
|
||||
function multi:lManager()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
Thread={}
|
||||
Thread.Name="Thread 3"
|
||||
Thread.ChannelThread = love.thread.getChannel("Easy3")
|
||||
Thread.ChannelMain = love.thread.getChannel("EasyMain")
|
||||
Thread.Global = {}
|
||||
function Thread:packTable(G)
|
||||
function escapeStr(str)
|
||||
local temp=""
|
||||
for i=1,#str do
|
||||
temp=temp.."\\"..string.byte(string.sub(str,i,i))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function ToStr(t)
|
||||
local dat="{"
|
||||
for i,v in pairs(t) do
|
||||
if type(i)=="number" then
|
||||
i="["..i.."]="
|
||||
else
|
||||
i=i.."="
|
||||
end
|
||||
if type(v)=="string" then
|
||||
dat=dat..i.."\""..v.."\","
|
||||
elseif type(v)=="number" then
|
||||
dat=dat..i..v..","
|
||||
elseif type(v)=="boolean" then
|
||||
dat=dat..i..tostring(v)..","
|
||||
elseif type(v)=="table" and not(G==v) then
|
||||
dat=dat..i..ToStr(v)..","
|
||||
--elseif type(v)=="table" and G==v then
|
||||
-- dat=dat..i.."assert(loadstring(\"return self\")),"
|
||||
elseif type(v)=="function" then
|
||||
dat=dat..i.."assert(loadstring(\""..escapeStr(string.dump(v)).."\")),"
|
||||
end
|
||||
end
|
||||
return string.sub(dat,1,-2).."}"
|
||||
end
|
||||
return "return "..ToStr(G)
|
||||
end
|
||||
function Thread:Send(name,var)
|
||||
arg3="3"
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3="table"
|
||||
end
|
||||
self.ChannelMain:push({name,var,arg3})
|
||||
end
|
||||
function Thread:UnPackChannel()
|
||||
local c=self.ChannelThread:getCount()
|
||||
for i=1,c do
|
||||
local temp=self.ChannelThread:pop()
|
||||
if temp[1] and temp[2] then
|
||||
if temp[1]=="func" and type(temp[2])=="string" then
|
||||
loadstring(temp[2])(temp[3])
|
||||
else
|
||||
_G[temp[1]]=temp[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
if #multi:getChildren()<2 then
|
||||
os.sleep(.05)
|
||||
end
|
||||
end
|
||||
function Thread:boost(func,name)
|
||||
self:Send(name,string.dump(func))
|
||||
end
|
||||
function Thread.mainloop()
|
||||
Thread:UnPackChannel()
|
||||
end
|
||||
Thread.MainThread=false
|
||||
multi:newLoop():OnLoop(Thread.mainloop)
|
||||
multi:mainloop()
|
||||
596
Libs/T4.lua
596
Libs/T4.lua
@ -1,596 +0,0 @@
|
||||
require("love.timer")
|
||||
require("love.system")
|
||||
require("love.sound")
|
||||
require("love.physics")
|
||||
require("love.mouse")
|
||||
require("love.math")
|
||||
require("love.keyboard")
|
||||
require("love.joystick")
|
||||
require("love.image")
|
||||
require("love.font")
|
||||
require("love.filesystem")
|
||||
require("love.event")
|
||||
require("love.audio")
|
||||
require("love.graphics")
|
||||
require("love.window")
|
||||
_defaultfont = love.graphics.getFont()
|
||||
gui = {}
|
||||
function gui.getTile(i,x,y,w,h)-- returns imagedata
|
||||
if type(i)=="userdata" then
|
||||
-- do nothing
|
||||
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
|
||||
multi = {}
|
||||
multi.Version="4.0.0"
|
||||
multi.__index = multi
|
||||
multi.Mainloop={}
|
||||
multi.Tasks={}
|
||||
multi.Tasks2={}
|
||||
multi.Garbage={}
|
||||
multi.Children={}
|
||||
multi.Paused={}
|
||||
multi.MasterId=0
|
||||
multi.Active=true
|
||||
multi.Id=-1
|
||||
multi.Type="MainInt"
|
||||
multi.Rest=0
|
||||
-- System
|
||||
os.sleep=love.timer.sleep
|
||||
function multi:newBase(ins)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then error("Can only create an object on multi or an interface obj") return false end
|
||||
local c = {}
|
||||
if self.Type=="int" then
|
||||
setmetatable(c, self.Parent)
|
||||
else
|
||||
setmetatable(c, self)
|
||||
end
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Act=function() end
|
||||
c.Parent=self
|
||||
if ins then
|
||||
table.insert(self.Mainloop,ins,c)
|
||||
else
|
||||
table.insert(self.Mainloop,c)
|
||||
end
|
||||
self.MasterId=self.MasterId+1
|
||||
return c
|
||||
end
|
||||
function multi:reboot(r)
|
||||
self.Mainloop={}
|
||||
self.Tasks={}
|
||||
self.Tasks2={}
|
||||
self.Garbage={}
|
||||
self.Children={}
|
||||
self.Paused={}
|
||||
self.MasterId=0
|
||||
self.Active=true
|
||||
self.Id=-1
|
||||
if r then
|
||||
for i,v in pairs(_G) do
|
||||
if type(i)=="table" then
|
||||
if i.Parent and i.Id and i.Act then
|
||||
i={}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:getChildren()
|
||||
return self.Mainloop
|
||||
end
|
||||
--Processor
|
||||
function multi:Do_Order()
|
||||
for _D=#self.Mainloop,1,-1 do
|
||||
if self.Mainloop[_D]~=nil then
|
||||
self.Mainloop[_D].Id=_D
|
||||
self.Mainloop[_D]:Act()
|
||||
end
|
||||
if self.Mainloop[_D].rem then
|
||||
table.remove(self.Mainloop,_D)
|
||||
end
|
||||
end
|
||||
if self.Rest>0 then
|
||||
os.sleep(self.Rest)
|
||||
end
|
||||
end
|
||||
function multi:benchMark(sec)
|
||||
local temp=self:newLoop(function(t,self)
|
||||
if os.clock()-self.init>self.sec then
|
||||
print(self.c.." steps in "..self.sec.." second(s)")
|
||||
self.tt(self.sec)
|
||||
self:Destroy()
|
||||
else
|
||||
self.c=self.c+1
|
||||
end
|
||||
end)
|
||||
function temp:OnBench(func)
|
||||
self.tt=func
|
||||
end
|
||||
self.tt=function() end
|
||||
temp.sec=sec
|
||||
temp.init=os.clock()
|
||||
temp.c=0
|
||||
return temp
|
||||
end
|
||||
function multi:newInterface()
|
||||
if not(self.Type=="MainInt") then error("Can only create an interface on the multi obj") return false end
|
||||
local c = {}
|
||||
setmetatable(c, self)
|
||||
c.Parent=self
|
||||
c.Active=true
|
||||
c.func={}
|
||||
c.Id=0
|
||||
c.Type="int"
|
||||
c.Mainloop={}
|
||||
c.Tasks={}
|
||||
c.Tasks2={}
|
||||
c.Garbage={}
|
||||
c.Children={}
|
||||
c.Paused={}
|
||||
c.MasterId=0
|
||||
c.Active=true
|
||||
c.Id=-1
|
||||
c.Rest=0
|
||||
function c:Start()
|
||||
if self.l then
|
||||
self.l:Resume()
|
||||
else
|
||||
self.l=self.Parent:newLoop(function(dt) c:uManager(dt) end)
|
||||
end
|
||||
end
|
||||
function c:Stop()
|
||||
if self.l then
|
||||
self.l:Pause()
|
||||
end
|
||||
end
|
||||
function c:Remove()
|
||||
self:Destroy()
|
||||
self.l:Destroy()
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Helpers
|
||||
function multi:FreeMainEvent()
|
||||
self.func={}
|
||||
end
|
||||
function multi:isPaused()
|
||||
return not(self.Active)
|
||||
end
|
||||
function multi:Pause(n)
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=false
|
||||
if not(n) then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Pause()
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
else
|
||||
if not(n) then
|
||||
self.Active=false
|
||||
if self.Parent.Mainloop[self.Id]~=nil then
|
||||
table.remove(self.Parent.Mainloop,self.Id)
|
||||
table.insert(self.Parent.Paused,self)
|
||||
self.Id=#self.Parent.Paused
|
||||
end
|
||||
else
|
||||
self:hold(n)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Resume()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
self.Active=true
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Resume()
|
||||
end
|
||||
else
|
||||
if self:isPaused() then
|
||||
self.Active=true
|
||||
for i=1,#self.Parent.Paused do
|
||||
if self.Parent.Paused[i]==self then
|
||||
table.remove(self.Parent.Paused,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Mainloop,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function multi:Destroy()
|
||||
if self.Type=="int" or self.Type=="MainInt" then
|
||||
local c=self:getChildren()
|
||||
for i=1,#c do
|
||||
c[i]:Destroy()
|
||||
end
|
||||
else
|
||||
self.rem=true
|
||||
end
|
||||
end
|
||||
function multi:hold(task)
|
||||
self:Pause()
|
||||
if type(task)=="number" then
|
||||
local alarm=self:newAlarm(task)
|
||||
while alarm.Active==true do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
alarm:Destroy()
|
||||
self:Resume()
|
||||
elseif type(task)=="function" then
|
||||
local env=self.Parent:newEvent(task)
|
||||
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
|
||||
while env.Active do
|
||||
if love then
|
||||
self.Parent.lManager()
|
||||
else
|
||||
self.Parent.Do_Order()
|
||||
end
|
||||
end
|
||||
env:Destroy()
|
||||
self:Resume()
|
||||
else
|
||||
print("Error Data Type!!!")
|
||||
end
|
||||
end
|
||||
function multi:oneTime(func,...)
|
||||
if not(self.Type=="MainInt" or self.Type=="int") then
|
||||
for _k=1,#self.Parent.Tasks2 do
|
||||
if self.Parent.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Parent.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
else
|
||||
for _k=1,#self.Tasks2 do
|
||||
if self.Tasks2[_k]==func then
|
||||
return false
|
||||
end
|
||||
end
|
||||
table.insert(self.Tasks2,func)
|
||||
func(...)
|
||||
return true
|
||||
end
|
||||
end
|
||||
--Constructors
|
||||
function multi:newEvent(task)
|
||||
local c=self:newBase()
|
||||
c.Type="Event"
|
||||
c.Task=task or function() end
|
||||
function c:Act()
|
||||
if self.Task(self) and self.Active==true then
|
||||
self:Pause()
|
||||
for _E=1,#self.func do
|
||||
self.func[_E](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEvent(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newAlarm(set)
|
||||
local c=self:newBase()
|
||||
c.Type="Alarm"
|
||||
c.timer=os.clock()
|
||||
c.set=set or 0
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Pause()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnRing(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTask(func)
|
||||
table.insert(self.Tasks,func)
|
||||
end
|
||||
function multi:newLoop(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Loop"
|
||||
if func then
|
||||
c.func={func}
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](os.clock()-self.Parent.Start,self)
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnLoop(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newStep(start,reset,count,skip)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="Step"
|
||||
c.pos=start or 1
|
||||
c.endAt=reset or math.huge
|
||||
c.skip=skip or 0
|
||||
c.spos=0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.start=start or 1
|
||||
if start~=nil and reset~=nil then
|
||||
if start>reset then
|
||||
think=-1
|
||||
end
|
||||
end
|
||||
function c:Act()
|
||||
if self~=nil then
|
||||
if self.spos==0 then
|
||||
if self.Active==true then
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
self.spos=self.spos+1
|
||||
if self.spos>=self.skip then
|
||||
self.spos=0
|
||||
end
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,1,func)
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Update(start,reset,count,skip)
|
||||
self.start=start or self.start
|
||||
self.endAt=reset or self.endAt
|
||||
self.skip=skip or self.skip
|
||||
self.count=count or self.count
|
||||
self:Resume()
|
||||
end
|
||||
c:OnStep(function(p,s)
|
||||
if s.count>0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
elseif s.count<0 and s.endAt==p then
|
||||
for fe=1,#s.funcE do
|
||||
s.funcE[fe](s)
|
||||
end
|
||||
s.pos=s.start-1
|
||||
end
|
||||
end)
|
||||
return c
|
||||
end
|
||||
function multi:newTStep(start,reset,count,set)
|
||||
local c=self:newBase()
|
||||
think=1
|
||||
c.Type="TStep"
|
||||
c.start=start or 1
|
||||
local reset = reset or math.huge
|
||||
c.endAt=reset
|
||||
c.pos=start or 1
|
||||
c.skip=skip or 0
|
||||
c.count=count or 1*think
|
||||
c.funcE={}
|
||||
c.timer=os.clock()
|
||||
c.set=set or 1
|
||||
function c:Update(start,reset,count,set)
|
||||
self.start=start or self.start
|
||||
self.pos=start
|
||||
self.endAt=reset or self.endAt
|
||||
self.set=set or self.set
|
||||
self.count=count or self.count or 1
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:Act()
|
||||
if self.Active then
|
||||
if os.clock()-self.timer>=self.set then
|
||||
self:Reset()
|
||||
for i=1,#self.func do
|
||||
self.func[i](self.pos,self)
|
||||
end
|
||||
if self.endAt==self.pos then
|
||||
for fe=1,#self.funcE do
|
||||
self.funcE[fe](self)
|
||||
end
|
||||
self.pos=self.start-1
|
||||
end
|
||||
self.pos=self.pos+self.count
|
||||
end
|
||||
end
|
||||
end
|
||||
function c:OnEnd(func)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
function c:Reset(n)
|
||||
if n then self.set=n end
|
||||
self.timer=os.clock()
|
||||
self:Resume()
|
||||
end
|
||||
function c:OnStep(func)
|
||||
table.insert(self.func,func)
|
||||
end
|
||||
return c
|
||||
end
|
||||
function multi:newTrigger(func)
|
||||
local c=self:newBase()
|
||||
c.Type="Trigger"
|
||||
c.trigfunc=func or function() end
|
||||
function c:Fire(...)
|
||||
self:trigfunc(self,...)
|
||||
end
|
||||
return c
|
||||
end
|
||||
--Managers
|
||||
function multi:mainloop()
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
self.Start=os.clock()
|
||||
while self.Active do
|
||||
self:Do_Order()
|
||||
end
|
||||
end
|
||||
function multi._tFunc(self,dt)
|
||||
for i=1,#self.Tasks do
|
||||
self.Tasks[i](self)
|
||||
end
|
||||
print("once!")
|
||||
if dt then
|
||||
self.pump=true
|
||||
end
|
||||
self.pumpvar=dt
|
||||
self.Start=os.clock()
|
||||
end
|
||||
function multi:uManager(dt)
|
||||
self:oneTime(self._tFunc,self,dt)
|
||||
self:Do_Order()
|
||||
end
|
||||
multi.drawF={}
|
||||
function multi:dManager()
|
||||
for ii=1,#multi.drawF do
|
||||
multi.drawF[ii]()
|
||||
end
|
||||
end
|
||||
function multi:onDraw(func)
|
||||
table.insert(self.drawF,func)
|
||||
end
|
||||
function multi:lManager()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
Thread={}
|
||||
Thread.Name="Thread 4"
|
||||
Thread.ChannelThread = love.thread.getChannel("Easy4")
|
||||
Thread.ChannelMain = love.thread.getChannel("EasyMain")
|
||||
Thread.Global = {}
|
||||
function Thread:packTable(G)
|
||||
function escapeStr(str)
|
||||
local temp=""
|
||||
for i=1,#str do
|
||||
temp=temp.."\\"..string.byte(string.sub(str,i,i))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function ToStr(t)
|
||||
local dat="{"
|
||||
for i,v in pairs(t) do
|
||||
if type(i)=="number" then
|
||||
i="["..i.."]="
|
||||
else
|
||||
i=i.."="
|
||||
end
|
||||
if type(v)=="string" then
|
||||
dat=dat..i.."\""..v.."\","
|
||||
elseif type(v)=="number" then
|
||||
dat=dat..i..v..","
|
||||
elseif type(v)=="boolean" then
|
||||
dat=dat..i..tostring(v)..","
|
||||
elseif type(v)=="table" and not(G==v) then
|
||||
dat=dat..i..ToStr(v)..","
|
||||
--elseif type(v)=="table" and G==v then
|
||||
-- dat=dat..i.."assert(loadstring(\"return self\")),"
|
||||
elseif type(v)=="function" then
|
||||
dat=dat..i.."assert(loadstring(\""..escapeStr(string.dump(v)).."\")),"
|
||||
end
|
||||
end
|
||||
return string.sub(dat,1,-2).."}"
|
||||
end
|
||||
return "return "..ToStr(G)
|
||||
end
|
||||
function Thread:Send(name,var)
|
||||
arg3="4"
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3="table"
|
||||
end
|
||||
self.ChannelMain:push({name,var,arg3})
|
||||
end
|
||||
function Thread:UnPackChannel()
|
||||
local c=self.ChannelThread:getCount()
|
||||
for i=1,c do
|
||||
local temp=self.ChannelThread:pop()
|
||||
if temp[1] and temp[2] then
|
||||
if temp[1]=="func" and type(temp[2])=="string" then
|
||||
loadstring(temp[2])(temp[3])
|
||||
else
|
||||
_G[temp[1]]=temp[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
if #multi:getChildren()<2 then
|
||||
os.sleep(.05)
|
||||
end
|
||||
end
|
||||
function Thread:boost(func,name)
|
||||
self:Send(name,string.dump(func))
|
||||
end
|
||||
function Thread.mainloop()
|
||||
Thread:UnPackChannel()
|
||||
end
|
||||
Thread.MainThread=false
|
||||
multi:newLoop():OnLoop(Thread.mainloop)
|
||||
multi:mainloop()
|
||||
@ -1,158 +0,0 @@
|
||||
Thread={}
|
||||
Thread.ChannelT1 = love.thread.getChannel("Easy1")
|
||||
Thread.ChannelT2 = love.thread.getChannel("Easy2")
|
||||
Thread.ChannelT3 = love.thread.getChannel("Easy3")
|
||||
Thread.ChannelT4 = love.thread.getChannel("Easy4")
|
||||
Thread.ChannelMain = love.thread.getChannel("EasyMain")
|
||||
Thread.Name = "Thread Main"
|
||||
Thread.n=0
|
||||
Thread.count=1
|
||||
function Thread:packTable(G)
|
||||
function escapeStr(str)
|
||||
local temp=""
|
||||
for i=1,#str do
|
||||
temp=temp.."\\"..string.byte(string.sub(str,i,i))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function ToStr(t)
|
||||
local dat="{"
|
||||
for i,v in pairs(t) do
|
||||
if type(i)=="number" then
|
||||
i="["..i.."]="
|
||||
else
|
||||
i=i.."="
|
||||
end
|
||||
if type(v)=="string" then
|
||||
dat=dat..i.."\""..v.."\","
|
||||
elseif type(v)=="number" then
|
||||
dat=dat..i..v..","
|
||||
elseif type(v)=="boolean" then
|
||||
dat=dat..i..tostring(v)..","
|
||||
elseif type(v)=="table" and not(G==v) then
|
||||
dat=dat..i..bin.ToStr(v)..","
|
||||
--elseif type(v)=="table" and G==v then
|
||||
-- dat=dat..i.."assert(loadstring(\"return self\")),"
|
||||
elseif type(v)=="function" then
|
||||
dat=dat..i.."assert(loadstring(\""..escapeStr(string.dump(v)).."\")),"
|
||||
end
|
||||
end
|
||||
return string.sub(dat,1,-2).."}"
|
||||
end
|
||||
return ToStr(G)
|
||||
end
|
||||
Thread.last={}
|
||||
function Thread:GetStatus()
|
||||
print(self.n.." Threads Exist!!!")
|
||||
for i=1,self.n do
|
||||
print("\tThread "..i.." Running: "..tostring(self["Thread"..i]:isRunning()))
|
||||
if not(self["Thread"..i]:isRunning()) then
|
||||
print("\t\t"..self["Thread"..i]:getError())
|
||||
end
|
||||
end
|
||||
end
|
||||
function Thread:Start(n)
|
||||
local x=love.system.getProcessorCount()
|
||||
if x>1 then
|
||||
x=x-1
|
||||
else
|
||||
x=1
|
||||
end
|
||||
n=n or x
|
||||
if n<1 then
|
||||
print("Must be atleast 1 thread running!!!")
|
||||
return
|
||||
end
|
||||
if n>4 then
|
||||
print("Must be no more than 4 threads running!!!")
|
||||
return
|
||||
end
|
||||
for i=1,n do
|
||||
self["Thread"..i]=love.thread.newThread("Libs/T"..i..".lua")
|
||||
self["Thread"..i]:start()
|
||||
end
|
||||
Thread.n=n
|
||||
end
|
||||
function Thread:RestartBroken()
|
||||
for i=1,self.n do
|
||||
if self["Thread"..i]:isRunning()==false then
|
||||
self["Thread"..i]:start()
|
||||
end
|
||||
Thread:Boost(Thread.last[1],Thread.last[2])
|
||||
end
|
||||
end
|
||||
function Thread:Send(name,var,arg3)
|
||||
if self.n>0 then
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3=name
|
||||
name="table"
|
||||
end
|
||||
self["ChannelT"..((self.count-1)%self.n)+1]:push({name,var,arg3})
|
||||
self.count=self.count+1
|
||||
end
|
||||
end
|
||||
function Thread:SendAll(name,var,arg3)
|
||||
if self.n>0 then
|
||||
for i=1,self.n do
|
||||
if type(var)=="table" then
|
||||
var=Thread:packTable(var)
|
||||
arg3=name
|
||||
name="table"
|
||||
end
|
||||
self["ChannelT"..i]:push({name,var,arg3})
|
||||
end
|
||||
end
|
||||
end
|
||||
function Thread:UnPackChannel()
|
||||
local c=self.ChannelMain:getCount()
|
||||
for i=1,c do
|
||||
local temp=self.ChannelMain:pop()
|
||||
if temp[3]=="table" then
|
||||
_G[temp[1]]=assert(loadstring(temp[2]))()
|
||||
else
|
||||
if Thread.OnDataRecieved then
|
||||
Thread.OnDataRecieved(temp[1],temp[2],temp[3])
|
||||
end
|
||||
_G[temp[1]]=temp[2]
|
||||
end
|
||||
end
|
||||
end
|
||||
function Thread:Boost(func,name)
|
||||
if Thread.last[1]==nil then
|
||||
return
|
||||
end
|
||||
Thread.last={func,name}
|
||||
name=name or "nil"
|
||||
if self.n>0 then
|
||||
self:Send("func",string.dump(func),name)
|
||||
end
|
||||
end
|
||||
function Thread:SendLibs(func,name)
|
||||
name=name or "nil"
|
||||
if self.n>0 then
|
||||
self:SendAll("func",string.dump(func),name)
|
||||
end
|
||||
end
|
||||
function Thread.mainloop()
|
||||
if Thread.n>0 then
|
||||
Thread:UnPackChannel()
|
||||
end
|
||||
end
|
||||
Thread.MainThread=true
|
||||
local loop = multi:newLoop()
|
||||
loop:OnLoop(Thread.mainloop)
|
||||
OnThreadError=multi:newConnection()
|
||||
function love.threaderror(thread, errorstr)
|
||||
Thread:GetStatus()
|
||||
Thread:RestartBroken()
|
||||
Thread:GetStatus()
|
||||
OnThreadError:Fire(thread,errorstr)
|
||||
end
|
||||
multi:newTask(function()
|
||||
math.randomseed(math.floor(os.time()/2))
|
||||
for i=1,Thread.n do
|
||||
Thread["ChannelT"..i]:push({"randseed",math.random(-1000000,1000000)})
|
||||
Thread["ChannelT"..i]:push({"func",string.dump(function() math.randomseed(randseed) end),"randomizing"})
|
||||
end
|
||||
end)
|
||||
2675
Libs/bin.lua
2675
Libs/bin.lua
File diff suppressed because it is too large
Load Diff
@ -1,103 +0,0 @@
|
||||
os.sleep=love.timer.sleep
|
||||
function bin.load(file,s,r)
|
||||
content, size = love.filesystem.read(file)
|
||||
local temp=bin.new(content)
|
||||
temp.filepath=file
|
||||
return temp
|
||||
end
|
||||
function bin:tofile(filename)
|
||||
if not(filename) or self.Stream then return nil end
|
||||
love.filesystem.write(filename,self.data)
|
||||
end
|
||||
function bin.stream(file,l)
|
||||
error("Sorry streaming is not available when using love2d :(, I am looking for a solution though :)")
|
||||
end
|
||||
function love.run()
|
||||
if love.math then
|
||||
love.math.setRandomSeed(os.time())
|
||||
end
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
end
|
||||
if love.load then love.load(arg) end
|
||||
if love.timer then love.timer.step() end
|
||||
local dt = 0
|
||||
while true do
|
||||
-- Process events.
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
if multi.boost then
|
||||
for i=1,multi.boost-1 do
|
||||
multi:uManager(dt)
|
||||
end
|
||||
end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
end
|
||||
multi.drawF={}
|
||||
function multi:dManager()
|
||||
for ii=1,#multi.drawF do
|
||||
multi.drawF[ii]()
|
||||
end
|
||||
end
|
||||
function multi:onDraw(func,i)
|
||||
i=i or 1
|
||||
table.insert(self.drawF,i,func)
|
||||
end
|
||||
function multi:lManager()
|
||||
if love.event then
|
||||
love.event.pump()
|
||||
for e,a,b,c,d in love.event.poll() do
|
||||
if e == "quit" then
|
||||
if not love.quit or not love.quit() then
|
||||
if love.audio then
|
||||
love.audio.stop()
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
love.handlers[e](a,b,c,d)
|
||||
end
|
||||
end
|
||||
if love.timer then
|
||||
love.timer.step()
|
||||
dt = love.timer.getDelta()
|
||||
end
|
||||
if love.update then love.update(dt) end
|
||||
multi:uManager(dt)
|
||||
if love.window and love.graphics and love.window.isCreated() then
|
||||
love.graphics.clear()
|
||||
love.graphics.origin()
|
||||
if love.draw then love.draw() end
|
||||
multi.dManager()
|
||||
love.graphics.setColor(255,255,255,255)
|
||||
if multi.draw then multi.draw() end
|
||||
love.graphics.present()
|
||||
end
|
||||
end
|
||||
BIN
Libs/test.dat
BIN
Libs/test.dat
Binary file not shown.
@ -1,18 +0,0 @@
|
||||
require("Library")
|
||||
local clock = os.clock
|
||||
function sleep(n) -- seconds
|
||||
local t0 = clock()
|
||||
while clock() - t0 <= n do end
|
||||
end
|
||||
function tester(test)
|
||||
sleep(1)
|
||||
return test*10
|
||||
end
|
||||
--~ require("bin")
|
||||
--~ test=bin.namedBlockManager()
|
||||
--~ test["name"]="Ryan"
|
||||
--~ test["age"]=21
|
||||
--~ test:tofile("test.dat")
|
||||
--~ test2=bin.namedBlockManager("test.dat")
|
||||
--~ print(test2["name"])
|
||||
--~ print(test2["age"])
|
||||
BIN
OpenAL32.dll
Normal file
BIN
OpenAL32.dll
Normal file
Binary file not shown.
38
Tests.dmf
38
Tests.dmf
@ -1,38 +0,0 @@
|
||||
USING AICM
|
||||
USING EBIM
|
||||
[ONCHAT:function(msg,speaker)]{
|
||||
p"(msg:cap1)What is (.+)?"<
|
||||
"I don't know what $cap1$ is sorry..." GOTO(end)
|
||||
"How would I know what cap1$ is?" GOTO(end)
|
||||
"Funny that you asked about that, because I have no idea what $cap1$ is." GOTO(end)
|
||||
>
|
||||
::end::
|
||||
}
|
||||
[START]{
|
||||
msg="What is love?"
|
||||
p(msg:cap1)What is (.+)?
|
||||
"$cap1$";"hi!"
|
||||
test=[1,144,3]
|
||||
num=100
|
||||
a=num
|
||||
"$a$"
|
||||
--Comment Here
|
||||
switch key:
|
||||
case "A"
|
||||
--[[
|
||||
long
|
||||
comment
|
||||
]]
|
||||
"Hello Whats up!"
|
||||
"You are here now"
|
||||
case "B" JUMP(BLOCKOTHER)
|
||||
case "C" JUMP(BLOCKOTHER)
|
||||
case "D" JUMP(BLOCKOTHER)
|
||||
else JUMP(BLOCKOTHER)
|
||||
endswitch
|
||||
error("Test")
|
||||
"Now we are here";"Teehee"
|
||||
}
|
||||
[ERROR]{
|
||||
error()
|
||||
}
|
||||
@ -1,5 +1,19 @@
|
||||
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={
|
||||
new=function(r,g,b)
|
||||
new=function(r,b,g)
|
||||
mt = {
|
||||
__add = function (c1,c2)
|
||||
return Color.new(c1[1]+c2[1],c1[2]+c2[2],c1[2]+c2[2])
|
||||
@ -22,14 +36,14 @@ new=function(r,g,b)
|
||||
__unm = function (c1)
|
||||
return Color.new(-c1[1],-c1[2],-c1[2])
|
||||
end,
|
||||
__tostring = function(c)
|
||||
return "("..c[1]..","..c[2]..","..c[3]..")"
|
||||
end,
|
||||
__eq = Color.EQ,
|
||||
__lt = Color.LT,
|
||||
__le = Color.LE,
|
||||
__tostring = function(self)
|
||||
return "("..self[1] ..","..self[1] ..","..self[1] ..")"
|
||||
end
|
||||
}
|
||||
local temp = {r,g,b,255}
|
||||
local temp = {r/255,b/255,g/255,1}
|
||||
setmetatable(temp, mt)
|
||||
return temp
|
||||
end,
|
||||
@ -49,24 +63,27 @@ IndexColor=function(name,r,b,g)
|
||||
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)
|
||||
end
|
||||
Color[string.lower(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.lower(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)
|
||||
end,
|
||||
Darken=function(color,v)
|
||||
currentR=color[1]
|
||||
currentG=color[2]
|
||||
currentB=color[3]
|
||||
return Color.new(currentR * (1 - v),currentG * (1 - v),currentB * (1 - v))
|
||||
return Color.new((color[1]*255) * (1 - v),(color[2]*255) * (1 - v),(color[3]*255) * (1 - v))
|
||||
end,
|
||||
Lighten=function(color,v)
|
||||
currentR=color[1]
|
||||
currentG=color[2]
|
||||
currentB=color[3]
|
||||
|
||||
return Color.new(currentR + (255 - currentR) * v,currentG + (255 - currentG) * v,currentB + (255 - currentB) * v)
|
||||
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)
|
||||
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("WHITE",255,255,255)
|
||||
Color.IndexColor("MAROON",128,20,20)
|
||||
200
Visual Novel/GuiManager/Core/EventDefinitions.lua
Normal file
200
Visual Novel/GuiManager/Core/EventDefinitions.lua
Normal file
@ -0,0 +1,200 @@
|
||||
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
|
||||
5
Visual Novel/GuiManager/Core/asRef.lua
Normal file
5
Visual Novel/GuiManager/Core/asRef.lua
Normal file
@ -0,0 +1,5 @@
|
||||
function gui:asRef()
|
||||
self.isRef = true
|
||||
self.Visible = false
|
||||
return self
|
||||
end
|
||||
75
Visual Novel/GuiManager/Core/canPress.lua
Normal file
75
Visual Novel/GuiManager/Core/canPress.lua
Normal file
@ -0,0 +1,75 @@
|
||||
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
|
||||
if self.isclipped then
|
||||
return not(mx>x+w or mx<x or my>y+h or my<y)
|
||||
end
|
||||
return true
|
||||
end
|
||||
function gui:canPress()
|
||||
local ref = self
|
||||
if self.ClipReference then ref = self.ClipReference end
|
||||
if self.Active and 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
|
||||
22
Visual Novel/GuiManager/Core/clone.lua
Normal file
22
Visual Novel/GuiManager/Core/clone.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local copy
|
||||
function copy(obj, seen)
|
||||
if type(obj) ~= 'table' then return obj end
|
||||
if seen and seen[obj] then return seen[obj] end
|
||||
local s = seen or {}
|
||||
local res = setmetatable({}, getmetatable(obj))
|
||||
s[obj] = res
|
||||
for k, v in pairs(obj) do res[copy(k, s)] = copy(v, s) end
|
||||
return res
|
||||
end
|
||||
function gui:clone(par,isRef)
|
||||
local temp = copy(self)
|
||||
temp.isACopy = true
|
||||
if par then
|
||||
temp:SetParent(par)
|
||||
end
|
||||
if isRef or self.isRef then
|
||||
self.Visible = false
|
||||
temp.Visible = true
|
||||
end
|
||||
return temp
|
||||
end
|
||||
@ -1,3 +1,6 @@
|
||||
_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())
|
||||
@ -15,6 +18,9 @@ function filter(name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
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 = {}
|
||||
@ -24,10 +30,20 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
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
|
||||
@ -52,7 +68,6 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.mclicked=false
|
||||
c.clicked=false
|
||||
c.Visibility=1
|
||||
c.ClipDescendants=false
|
||||
c.TextWrap=true
|
||||
c.scale={}
|
||||
c.scale.size={}
|
||||
@ -85,55 +100,12 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
function c:hasRoundness()
|
||||
return (self.ry or self.rx)
|
||||
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.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
|
||||
c.func6={}
|
||||
c.func7={function() _GuiPro.DragItem={} end}
|
||||
c.func8={function(self) _GuiPro.DragItem=self end}
|
||||
c.func9={}
|
||||
c.func10={}
|
||||
function c:ImageRule()
|
||||
if self.Image then
|
||||
local sx=self.width/self.ImageWidth
|
||||
@ -177,61 +149,19 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
_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
|
||||
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)
|
||||
return c
|
||||
end
|
||||
40
Visual Novel/GuiManager/Core/toString.lua
Normal file
40
Visual Novel/GuiManager/Core/toString.lua
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
||||
@ -26,7 +26,7 @@ function gui:touchable(t)
|
||||
end
|
||||
self.id=-1
|
||||
end
|
||||
multi:newTask(function() -- A bit of post-loading haha
|
||||
--multi:newTask(function() -- A bit of post-loading haha
|
||||
gui.touchpressed=multi:newConnection()
|
||||
gui.touchreleased=multi:newConnection()
|
||||
gui.touchmoved=multi:newConnection()
|
||||
@ -83,9 +83,9 @@ multi:newTask(function() -- A bit of post-loading haha
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
--end)
|
||||
-- now that that is done lets set up some more post loading checks
|
||||
_GuiPro.int=multi:newProcess()
|
||||
_GuiPro.int=multi:newProcessor()
|
||||
_GuiPro.int:Start()
|
||||
_GuiPro.int:setJobSpeed(.001)
|
||||
_GuiPro.EXACT=0
|
||||
0
Visual Novel/GuiManager/Drawing/canvas.lua
Normal file
0
Visual Novel/GuiManager/Drawing/canvas.lua
Normal file
@ -27,37 +27,37 @@ function gui:drawC()
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
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*254)
|
||||
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility)
|
||||
self.hovering=false
|
||||
self.rclicked=false
|
||||
self.lclicked=false
|
||||
@ -71,7 +71,7 @@ function gui:drawC()
|
||||
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.Visibility*254)
|
||||
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
|
||||
@ -80,7 +80,7 @@ function gui:drawC()
|
||||
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)
|
||||
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
|
||||
80
Visual Novel/GuiManager/Drawing/drawR.lua
Normal file
80
Visual Novel/GuiManager/Drawing/drawR.lua
Normal file
@ -0,0 +1,80 @@
|
||||
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) then
|
||||
b=false
|
||||
end
|
||||
end
|
||||
self.isclipped = false
|
||||
if b then
|
||||
love.graphics.setStencilTest()
|
||||
love.graphics.setScissor()
|
||||
else
|
||||
self.isclipped = true
|
||||
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
|
||||
love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility)
|
||||
love.graphics.setFont(self.Font)
|
||||
if self.text~=nil and self.TextFormat == "center" then
|
||||
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)
|
||||
elseif self.text~=nil and self.TextFormat == "middleleft" then
|
||||
love.graphics.printf(self.text, self.x + (self.XTween or 0), self.y+(self.height-self.Font:getHeight())/2, self.width, "left",self.TextRotaion)
|
||||
elseif self.text~=nil and self.TextFormat == "middleright" then
|
||||
love.graphics.printf(self.text, self.x + (self.XTween or 0), self.y+(self.height-self.Font:getHeight())/2, self.width, "right",self.TextRotaion)
|
||||
elseif self.text~=nil and self.TextFormat == "middlecenter" then
|
||||
love.graphics.printf(self.text, self.x + (self.XTween or 0), self.y+(self.height-self.Font:getHeight())/2, self.width, "center",self.TextRotaion)
|
||||
else
|
||||
love.graphics.printf(self.text, self.x + (self.XTween or 0), self.y, self.width, self.TextFormat,self.TextRotaion)
|
||||
end
|
||||
end
|
||||
if self.DrawRulesE then
|
||||
for dr=1,#self.DrawRulesE do
|
||||
self.DrawRulesE[dr](self)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
0
Visual Novel/GuiManager/Frame/newratioFrame.lua
Normal file
0
Visual Novel/GuiManager/Frame/newratioFrame.lua
Normal file
16
Visual Novel/GuiManager/Image-Animation/SetImage.lua
Normal file
16
Visual Novel/GuiManager/Image-Animation/SetImage.lua
Normal file
@ -0,0 +1,16 @@
|
||||
function gui:SetImage(i)
|
||||
if not i then return end
|
||||
if type(i) == "userdata" and i:type() == "Image" then
|
||||
self.Image=i
|
||||
self.ImageHeigth=self.Image:getHeight()
|
||||
self.ImageWidth=self.Image:getWidth()
|
||||
self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
elseif type(i)=="string" then
|
||||
gui.loadImageData(i,nil,function(imagedata)
|
||||
self.Image = love.graphics.newImage(imagedata)
|
||||
self.ImageHeigth=self.Image:getHeight()
|
||||
self.ImageWidth=self.Image:getWidth()
|
||||
self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
end)
|
||||
end
|
||||
end
|
||||
60
Visual Novel/GuiManager/Image-Animation/SetThreadedImage.lua
Normal file
60
Visual Novel/GuiManager/Image-Animation/SetThreadedImage.lua
Normal file
@ -0,0 +1,60 @@
|
||||
-- local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
-- local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
-- local code = [[
|
||||
-- require("love.image")
|
||||
-- local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
-- local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
-- local clock = os.clock
|
||||
-- local idle = clock
|
||||
-- while true do
|
||||
-- if not idle then
|
||||
-- love.timer.sleep(.001)
|
||||
-- elseif clock()-idle>=15 then
|
||||
-- love.timer.sleep(.01)
|
||||
-- end
|
||||
-- local data = queue:pop()
|
||||
-- if data then
|
||||
-- idle = clock()
|
||||
-- print(data[1],data[2])
|
||||
-- end
|
||||
-- end
|
||||
-- ]]
|
||||
-- local t = love.thread.newThread(code)
|
||||
-- t:start()
|
||||
|
||||
|
||||
-- _GuiPro.jobqueue:registerJob("LoadImage",function(path)
|
||||
-- local dat = love.image.newImageData(path)
|
||||
-- return dat
|
||||
-- end)
|
||||
-- local cache = {}
|
||||
-- _GuiPro.jobqueue.OnJobCompleted(function(JOBID,n)
|
||||
-- cache[JOBID].Image=love.graphics.newImage(n)
|
||||
-- cache[JOBID].ImageHeigth=cache[JOBID].Image:getHeight()
|
||||
-- cache[JOBID].ImageWidth=cache[JOBID].Image:getWidth()
|
||||
-- cache[JOBID].Quad=love.graphics.newQuad(0,0,cache[JOBID].width,cache[JOBID].height,cache[JOBID].ImageWidth,cache[JOBID].ImageHeigth)
|
||||
-- end)
|
||||
-- function gui:ThreadedSetImage(i)
|
||||
-- local temp = self.Image
|
||||
-- if _GuiPro.imagecache[i] then
|
||||
-- self.Image=_GuiPro.imagecache[i]
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- else
|
||||
-- if type(i)=="string" then
|
||||
-- local ii = _GuiPro.jobqueue:pushJob("LoadImage",i)
|
||||
-- cache[ii] = self
|
||||
-- elseif tostring(i):find("ImageData") then
|
||||
-- self.Image=love.graphics.newImage(i)
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- elseif i then
|
||||
-- self.Image=i
|
||||
-- self.ImageHeigth=self.Image:getHeight()
|
||||
-- self.ImageWidth=self.Image:getWidth()
|
||||
-- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
@ -0,0 +1,44 @@
|
||||
local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
local code = [[
|
||||
require("love.image")
|
||||
require("love.timer")
|
||||
local queueUpload = love.thread.getChannel("ImageUploader")
|
||||
local queueDownload = love.thread.getChannel("ImageDownloader")
|
||||
while true do
|
||||
love.timer.sleep(.001)
|
||||
local data = queueUpload:pop()
|
||||
if data then
|
||||
queueDownload:push{data[1],love.image.newImageData(data[2])}
|
||||
end
|
||||
end
|
||||
]]
|
||||
local count = 0
|
||||
local conn = multi:newConnection()
|
||||
function gui.loadImageData(path,tag,callback)
|
||||
local c = count
|
||||
count = count + 1
|
||||
queueUpload:push{c,path}
|
||||
if not callback then
|
||||
return conn
|
||||
else
|
||||
local cd
|
||||
cd = conn(function(id,data)
|
||||
if id == c then
|
||||
callback(data,tag,id)
|
||||
cd:Destroy()
|
||||
end
|
||||
end)
|
||||
end
|
||||
return c
|
||||
end
|
||||
multi:newLoop(function()
|
||||
local dat = queueDownload:pop()
|
||||
if dat then
|
||||
conn:Fire(dat[1],dat[2])
|
||||
end
|
||||
end)
|
||||
for i = 1,love.system.getProcessorCount() do
|
||||
local t = love.thread.newThread(code)
|
||||
t:start()
|
||||
end
|
||||
@ -1,19 +1,28 @@
|
||||
function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local _files=alphanumsort(love.filesystem.getDirectoryItems(file))
|
||||
local x,y,w,h,sx,sy,sw,sh=filter(file, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
if not w and not h then
|
||||
local w,h = love.graphics.newImage(file.."/".._files[1]):getDimensions()
|
||||
c:setDualDim(nil,nil,w,h)
|
||||
end
|
||||
c.Visibility=0
|
||||
c.ImageVisibility=1
|
||||
c.delay=delay or .05
|
||||
c.files={}
|
||||
c.AnimStart={}
|
||||
c.AnimEnd={}
|
||||
local _files=alphanumsort(love.filesystem.getDirectoryItems(file))
|
||||
local count = 0
|
||||
local max
|
||||
for i=1,#_files do
|
||||
if string.sub(_files[i],-1,-1)~="b" then
|
||||
table.insert(c.files,love.graphics.newImage(file.."/".._files[i]))
|
||||
count = count + 1
|
||||
gui.loadImageData(file.."/".._files[i],count,function(imagedata,id)
|
||||
c.files[id] = love.graphics.newImage(imagedata)
|
||||
end)
|
||||
end
|
||||
end
|
||||
c.step=multi:newTStep(1,#c.files,1,c.delay)
|
||||
c.step=multi:newTStep(1,count,1,c.delay)
|
||||
c.step.parent=c
|
||||
c.rotation=0
|
||||
c.step:OnStart(function(step)
|
||||
@ -21,7 +30,7 @@ function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
step.parent.AnimStart[i](step.parent)
|
||||
end
|
||||
end)
|
||||
c.step:OnStep(function(pos,step)
|
||||
c.step:OnStep(function(step,pos)
|
||||
step.parent:SetImage(step.parent.files[pos])
|
||||
end)
|
||||
c.step:OnEnd(function(step)
|
||||
@ -43,6 +52,7 @@ function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
end
|
||||
function c:Reset()
|
||||
self.step.pos=1
|
||||
self.step:Reset()
|
||||
end
|
||||
function c:getFrames()
|
||||
return #self.files
|
||||
@ -1,7 +1,7 @@
|
||||
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.graphics.newImage(file)
|
||||
local im=love.image.newImageData(file)
|
||||
local _x,_y=im:getDimensions()
|
||||
c.Visibility=0
|
||||
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)
|
||||
end
|
||||
end)
|
||||
c.step:OnStep(function(pos,step)
|
||||
c.step:OnStep(function(step,pos)
|
||||
step.parent:SetImage(step.parent.files[pos])
|
||||
end)
|
||||
c.step:OnEnd(function(step)
|
||||
@ -1,24 +1,15 @@
|
||||
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)
|
||||
if type(i)=="string" then
|
||||
c.Image=love.graphics.newImage(i)
|
||||
else
|
||||
c.Image=i
|
||||
end
|
||||
c:SetImage(i)
|
||||
c.Visibility=0
|
||||
c.ImageVisibility=1
|
||||
c.rotation=0
|
||||
if c.Image~=nil then
|
||||
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()
|
||||
c.BorderSize = 0
|
||||
c:OnMouseEnter(function()
|
||||
love.mouse.setCursor(_GuiPro.CursorH)
|
||||
end)
|
||||
c:OnExit(function()
|
||||
c:OnMouseExit(function()
|
||||
love.mouse.setCursor(_GuiPro.CursorN)
|
||||
end)
|
||||
return c
|
||||
11
Visual Novel/GuiManager/Image-Animation/newImageLabel.lua
Normal file
11
Visual Novel/GuiManager/Image-Animation/newImageLabel.lua
Normal file
@ -0,0 +1,11 @@
|
||||
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
|
||||
c.BorderSize = 0
|
||||
return c
|
||||
end
|
||||
@ -1,7 +1,7 @@
|
||||
function _GuiPro.gradient(colors)
|
||||
local direction = colors.direction or "horizontal"
|
||||
colors.direction=nil
|
||||
trans = colors.trans or 255
|
||||
trans = colors.trans or 1
|
||||
trans=math.floor(trans)
|
||||
if direction == "horizontal" then
|
||||
direction = true
|
||||
@ -10,7 +10,7 @@ function _GuiPro.gradient(colors)
|
||||
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)
|
||||
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
|
||||
18
Visual Novel/GuiManager/Misc/ClipDescendants.lua
Normal file
18
Visual Novel/GuiManager/Misc/ClipDescendants.lua
Normal file
@ -0,0 +1,18 @@
|
||||
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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user