Updated to 9.0.0
Love2D 1.11 Support is here! :D
This commit is contained in:
parent
550bdf1441
commit
76fd457833
240
GuiManager.lua
240
GuiManager.lua
@ -1,20 +1,20 @@
|
||||
utf8 = require("utf8")
|
||||
_defaultfont = love.graphics.getFont()
|
||||
gui = {}
|
||||
gui.__index = gui
|
||||
gui.TB={}
|
||||
gui.Version="8.0.0" -- Is it really ready for release?
|
||||
gui.Version="9.0.0" -- Is it really ready for release?
|
||||
_GuiPro={GBoost=true,hasDrag=false,DragItem={},Children={},Visible=true,count=0,x=0,y=0,height=0,width=0,update=function(self) local things=GetAllChildren2(self) UpdateThings(things) end,draw=function(self) local things=GetAllChildren(self) DrawThings(things) end,getChildren=function(self) return self.Children end}
|
||||
_GuiPro.Clips={}
|
||||
_GuiPro.rotate=0
|
||||
_defaultfont = love.graphics.setNewFont(12)
|
||||
setmetatable(_GuiPro, gui)
|
||||
function gui:LoadInterface(file)
|
||||
local add=".int"
|
||||
if string.find(file,".",1,true) then add="" end
|
||||
if love.filesystem.exists(file..add) then
|
||||
if love.filesystem.getInfo(file..add) then
|
||||
a,b=pcall(love.filesystem.load(file..add))
|
||||
if a then
|
||||
print("Loaded: "..file)
|
||||
--print("Loaded: "..file)
|
||||
else
|
||||
print("Error loading file: "..file)
|
||||
print(a,b)
|
||||
@ -48,8 +48,22 @@ function gui:Clickable()
|
||||
end
|
||||
return not(mx>x+w or mx<x or my>y+h or my<y)
|
||||
end
|
||||
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])
|
||||
@ -79,7 +93,7 @@ new=function(r,g,b)
|
||||
__lt = Color.LT,
|
||||
__le = Color.LE,
|
||||
}
|
||||
local temp = {r,g,b,255}
|
||||
local temp = {r/255,b/255,g/255,1}
|
||||
setmetatable(temp, mt)
|
||||
return temp
|
||||
end,
|
||||
@ -107,14 +121,13 @@ 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((currentR*255) * (1 - v),(currentG*255) * (1 - v),(currentB*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(currentR*255 + (255 - (currentR*255)) * v,currentG*255 + (255 - (currentG*255)) * v,currentB*255 + (255 - (currentB*255)) * v)
|
||||
end
|
||||
}
|
||||
Color.IndexColor("Black",20,20,20)
|
||||
@ -1820,6 +1833,7 @@ function gui:MRelease()
|
||||
self.funcs2[i]("m",self)
|
||||
end
|
||||
end
|
||||
|
||||
function gui:full()
|
||||
self:SetDualDim(nil,nil,nil,nil,nil,nil,1,1)
|
||||
end
|
||||
@ -1849,15 +1863,15 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
else
|
||||
c.Parent=self
|
||||
end
|
||||
c.segments=nil
|
||||
c.ry=nil
|
||||
c.rx=nil
|
||||
c.DPI=1
|
||||
if _GuiPro.DPI_ENABLED then
|
||||
c.DPI=love.window.getPixelScale()
|
||||
x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
|
||||
end
|
||||
c.centerFontY=true
|
||||
c.segments=nil
|
||||
c.ry=nil
|
||||
c.rx=nil
|
||||
c.DPI=1
|
||||
if _GuiPro.DPI_ENABLED then
|
||||
c.DPI=love.window.getPixelScale()
|
||||
x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
|
||||
end
|
||||
c.centerFontY=true
|
||||
c.FormFactor="rectangle"
|
||||
c.Type=tp
|
||||
c.Active=true
|
||||
@ -2002,6 +2016,13 @@ 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
|
||||
@ -2067,6 +2088,46 @@ function love.mouse.isDown(b)
|
||||
end
|
||||
return _GuiPro.mousedownfunc(({["l"]=1,["r"]=2,["m"]=3})[b] or b)
|
||||
end
|
||||
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
|
||||
--[[WORKING ON
|
||||
doubleTap - UnFinished!
|
||||
touchRendering - Broken
|
||||
@ -2558,7 +2619,7 @@ end
|
||||
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
|
||||
if type(i)=="string" or type(i):find("ImageData") then
|
||||
c.Image=love.graphics.newImage(i)
|
||||
else
|
||||
c.Image=i
|
||||
@ -2573,17 +2634,17 @@ function gui:newImageButton(i,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
|
||||
end
|
||||
c:OnEnter(function()
|
||||
--love.mouse.setCursor(_GuiPro.CursorH)
|
||||
love.mouse.setCursor(_GuiPro.CursorH)
|
||||
end)
|
||||
c:OnExit(function()
|
||||
--love.mouse.setCursor(_GuiPro.CursorN)
|
||||
love.mouse.setCursor(_GuiPro.CursorN)
|
||||
end)
|
||||
return c
|
||||
end
|
||||
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
|
||||
if type(i)=="string" or type(i):find("ImageData") then
|
||||
c.Image=love.graphics.newImage(i)
|
||||
else
|
||||
c.Image=i
|
||||
@ -2591,7 +2652,7 @@ function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.Visibility=0
|
||||
c.ImageVisibility=1
|
||||
c.rotation=0
|
||||
if c.Image~=nil then
|
||||
if c.Image then
|
||||
c.ImageHeigth=c.Image:getHeight()
|
||||
c.ImageWidth=c.Image:getWidth()
|
||||
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
|
||||
@ -2661,12 +2722,12 @@ function gui:newVideo(name,i,x,y,w,h,sx,sy,sw,sh)
|
||||
return c
|
||||
end
|
||||
function gui:SetImage(i)
|
||||
if type(i)=="string" then
|
||||
if type(i)=="string" or tostring(i):find("ImageData") then
|
||||
self.Image=love.graphics.newImage(i)
|
||||
else
|
||||
self.Image=i
|
||||
end
|
||||
if self.Image~=nil then
|
||||
if self.Image 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)
|
||||
@ -2933,7 +2994,7 @@ end
|
||||
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
|
||||
@ -2942,7 +3003,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
|
||||
@ -2976,9 +3037,9 @@ function gui:BottomStack()
|
||||
end
|
||||
end
|
||||
end
|
||||
function gui:Center()
|
||||
local x,y=self:getFullSize()
|
||||
self:SetDualDim(-math.floor(x/2),-math.floor(y/2),nil,nil,.5,.5)
|
||||
function gui:center()
|
||||
self:centerX()
|
||||
self:centerY()
|
||||
end
|
||||
function gui:centerX()
|
||||
self:SetDualDim(-(self.width/2),nil,nil,nil,.5)
|
||||
@ -2994,6 +3055,7 @@ function gui:Destroy()
|
||||
table.remove(self.Parent.Children,cc)
|
||||
end
|
||||
end
|
||||
self.Destroyed = true
|
||||
end
|
||||
function gui:disrespectHierarchy()
|
||||
_GuiPro.Hierarchy=false
|
||||
@ -3036,9 +3098,9 @@ 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
|
||||
if temp[i].width+temp[i].offset.pos.x>maxx then
|
||||
maxx=temp[i].width+temp[i].offset.pos.x
|
||||
elseif temp[i].height>maxy then
|
||||
elseif temp[i].height+temp[i].offset.pos.y>maxy then
|
||||
maxy=temp[i].height+temp[i].offset.pos.y
|
||||
end
|
||||
end
|
||||
@ -3095,7 +3157,7 @@ function gui:Move(x,y)
|
||||
self.offset.pos.x=self.offset.pos.x+x
|
||||
self.offset.pos.y=self.offset.pos.y+y
|
||||
end
|
||||
if love.filesystem.exists("CheckBoxes.png") then
|
||||
if love.filesystem.getInfo("CheckBoxes.png") then
|
||||
_GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16)
|
||||
_GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16)
|
||||
_GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16)
|
||||
@ -3494,10 +3556,10 @@ end
|
||||
function gui:getText(txt)
|
||||
return self.text
|
||||
end
|
||||
--_GuiPro.CursorN=love.mouse.getSystemCursor("arrow")
|
||||
--_GuiPro.CursorH=love.mouse.getSystemCursor("hand")
|
||||
_GuiPro.CursorN=love.mouse.getSystemCursor("arrow")
|
||||
_GuiPro.CursorH=love.mouse.getSystemCursor("hand")
|
||||
function gui:SetHand(img,x,y)
|
||||
--_GuiPro.CursorN=love.mouse.newCursor(img,x,y)
|
||||
_GuiPro.CursorN=love.mouse.newCursor(img,x,y)
|
||||
end
|
||||
function gui:setHotKey(key)
|
||||
local tab=key:split("+")
|
||||
@ -3524,14 +3586,18 @@ function gui:setHotKey(key)
|
||||
end)
|
||||
end
|
||||
function gui:SetHover(img,x,y)
|
||||
--_GuiPro.CursorH=love.mouse.newCursor(img,x,y)
|
||||
_GuiPro.CursorH=love.mouse.newCursor(img,x,y)
|
||||
end
|
||||
function gui:SetName(name)
|
||||
self.Parent.Children[name]=self
|
||||
self.Name=name
|
||||
end
|
||||
function gui:setNewFont(FontSize)
|
||||
self.Font=love.graphics.setNewFont(tonumber(FontSize))
|
||||
function gui:setNewFont(FontSize,filename)
|
||||
if filename then
|
||||
self.Font = love.graphics.newFont(filename, tonumber(FontSize))
|
||||
else
|
||||
self.Font=love.graphics.setNewFont(tonumber(FontSize))
|
||||
end
|
||||
end
|
||||
function gui:setParent(parent,name)-- Needs fixing!!!
|
||||
local temp=self.Parent:getChildren()
|
||||
@ -3601,7 +3667,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.mark=nil
|
||||
c.arrowkeys=false
|
||||
c.funcF={function()
|
||||
love.keyboard.setTextInput(true)
|
||||
love.keyboard.setTextInput(true,0,200,400,200)
|
||||
end}
|
||||
c.cooldown=false
|
||||
c.cooldown2=false
|
||||
@ -3632,9 +3698,12 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
table.insert(self.funcE,func)
|
||||
end
|
||||
c:OnClicked(function(b,self)
|
||||
self:focus()
|
||||
end)
|
||||
function c:focus()
|
||||
for cc=1,#self.funcF do
|
||||
self.funcF[cc](self)
|
||||
end
|
||||
end
|
||||
if self.Active==false then
|
||||
if self.ClearOnFocus==true then
|
||||
self.text=""
|
||||
@ -3647,7 +3716,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
end
|
||||
self.Active=true
|
||||
end
|
||||
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()
|
||||
@ -3717,7 +3786,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
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
|
||||
elseif (love.keyboard.isDown("return") 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
|
||||
@ -3764,10 +3833,10 @@ function gui:newTextButton(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.Color = {220, 220, 220}
|
||||
c.TextColor = {0, 0, 0}
|
||||
c:OnEnter(function()
|
||||
--love.mouse.setCursor(_GuiPro.CursorH)
|
||||
love.mouse.setCursor(_GuiPro.CursorH)
|
||||
end)
|
||||
c:OnExit(function()
|
||||
--love.mouse.setCursor(_GuiPro.CursorN)
|
||||
love.mouse.setCursor(_GuiPro.CursorN)
|
||||
end)
|
||||
return c
|
||||
end
|
||||
@ -3787,6 +3856,11 @@ function gui:newTextLabel(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.TextColor = {0, 0, 0}
|
||||
return c
|
||||
end
|
||||
function gui:widthToTextSize(n)
|
||||
if self.Font then
|
||||
self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0)
|
||||
end
|
||||
end
|
||||
function gui:AddDrawRuleB(rule)
|
||||
if not(self.DrawRulesB) then self.DrawRulesB={} end
|
||||
table.insert(self.DrawRulesB,rule)
|
||||
@ -3836,37 +3910,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
|
||||
@ -3880,7 +3954,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.Visibility)
|
||||
for b=0,self.BorderSize-1 do
|
||||
love.graphics.circle("line",x,y,r+b,s)
|
||||
end
|
||||
@ -3889,7 +3963,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
|
||||
@ -3925,37 +3999,37 @@ function gui:drawR()
|
||||
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)
|
||||
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") 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)
|
||||
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") 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)
|
||||
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") 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)
|
||||
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
|
||||
@ -3969,17 +4043,18 @@ function gui:drawR()
|
||||
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
|
||||
|
||||
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)
|
||||
love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility)
|
||||
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
|
||||
@ -3988,10 +4063,16 @@ function gui:drawR()
|
||||
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)
|
||||
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)
|
||||
love.graphics.printf(
|
||||
self.text,
|
||||
(self.x+2+(self.marginL or 0) 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,
|
||||
self.TextRotation)
|
||||
else
|
||||
if type(self.Font)=="string" then
|
||||
self.Font=love.graphics.newFont(self.Font,self.FontSize)
|
||||
@ -4003,7 +4084,13 @@ function gui:drawR()
|
||||
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)
|
||||
love.graphics.printf(
|
||||
self.text,
|
||||
(self.x+2+(self.marginL or 0) 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,
|
||||
self.TextRotation)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -4025,3 +4112,4 @@ gui.ff:OnUpdate(function(self)
|
||||
self:BottomStack()
|
||||
end)
|
||||
|
||||
|
||||
|
||||
@ -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])
|
||||
@ -29,7 +43,7 @@ new=function(r,g,b)
|
||||
__lt = Color.LT,
|
||||
__le = Color.LE,
|
||||
}
|
||||
local temp = {r,g,b,255}
|
||||
local temp = {r/255,b/255,g/255,1}
|
||||
setmetatable(temp, mt)
|
||||
return temp
|
||||
end,
|
||||
@ -57,14 +71,13 @@ 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((currentR*255) * (1 - v),(currentG*255) * (1 - v),(currentB*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(currentR*255 + (255 - (currentR*255)) * v,currentG*255 + (255 - (currentG*255)) * v,currentB*255 + (255 - (currentB*255)) * v)
|
||||
end
|
||||
}
|
||||
Color.IndexColor("Black",20,20,20)
|
||||
0
GuiManager/Core/fromString.int
Normal file
0
GuiManager/Core/fromString.int
Normal file
@ -24,15 +24,15 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
else
|
||||
c.Parent=self
|
||||
end
|
||||
c.segments=nil
|
||||
c.ry=nil
|
||||
c.rx=nil
|
||||
c.DPI=1
|
||||
if _GuiPro.DPI_ENABLED then
|
||||
c.DPI=love.window.getPixelScale()
|
||||
x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
|
||||
end
|
||||
c.centerFontY=true
|
||||
c.segments=nil
|
||||
c.ry=nil
|
||||
c.rx=nil
|
||||
c.DPI=1
|
||||
if _GuiPro.DPI_ENABLED then
|
||||
c.DPI=love.window.getPixelScale()
|
||||
x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h
|
||||
end
|
||||
c.centerFontY=true
|
||||
c.FormFactor="rectangle"
|
||||
c.Type=tp
|
||||
c.Active=true
|
||||
@ -160,7 +160,7 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
end
|
||||
function c:repeatImage(b,b2)
|
||||
if b then
|
||||
self.Image:setWrap("repeat","repeat")
|
||||
self.Image:setWrap(b,b2 or "repeat")
|
||||
function self:ImageRule()
|
||||
love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255)
|
||||
love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation))
|
||||
@ -177,6 +177,13 @@ 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
|
||||
40
GuiManager/Core/toString.int
Normal file
40
GuiManager/Core/toString.int
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
|
||||
@ -1,4 +1,4 @@
|
||||
function gui:AddDrawRuleB(rule)
|
||||
if not(self.DrawRulesB) then self.DrawRulesB={} end
|
||||
table.insert(self.DrawRulesB,fule)
|
||||
table.insert(self.DrawRulesB,rule)
|
||||
end
|
||||
@ -1,4 +1,4 @@
|
||||
function gui:AddDrawRuleE(rule)
|
||||
if not(self.DrawRulesE) then self.DrawRulesE={} end
|
||||
table.insert(self.DrawRulesE,fule)
|
||||
table.insert(self.DrawRulesE,rule)
|
||||
end
|
||||
@ -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.Visibility)
|
||||
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
|
||||
@ -27,37 +27,37 @@ function gui:drawR()
|
||||
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)
|
||||
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") 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)
|
||||
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") 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)
|
||||
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") 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)
|
||||
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,17 +71,18 @@ function gui:drawR()
|
||||
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
|
||||
|
||||
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)
|
||||
love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility)
|
||||
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
|
||||
@ -90,10 +91,16 @@ function gui:drawR()
|
||||
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)
|
||||
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)
|
||||
love.graphics.printf(
|
||||
self.text,
|
||||
(self.x+2+(self.marginL or 0) 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,
|
||||
self.TextRotation)
|
||||
else
|
||||
if type(self.Font)=="string" then
|
||||
self.Font=love.graphics.newFont(self.Font,self.FontSize)
|
||||
@ -105,7 +112,13 @@ function gui:drawR()
|
||||
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)
|
||||
love.graphics.printf(
|
||||
self.text,
|
||||
(self.x+2+(self.marginL or 0) 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,
|
||||
self.TextRotation)
|
||||
end
|
||||
end
|
||||
end
|
||||
0
GuiManager/Frame/newratioFrame.int
Normal file
0
GuiManager/Frame/newratioFrame.int
Normal file
@ -1,10 +1,10 @@
|
||||
function gui:SetImage(i)
|
||||
if type(i)=="string" then
|
||||
if type(i)=="string" or tostring(i):find("ImageData") then
|
||||
self.Image=love.graphics.newImage(i)
|
||||
else
|
||||
self.Image=i
|
||||
end
|
||||
if self.Image~=nil then
|
||||
if self.Image 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)
|
||||
@ -1,7 +1,7 @@
|
||||
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
|
||||
if type(i)=="string" or type(i):find("ImageData") then
|
||||
c.Image=love.graphics.newImage(i)
|
||||
else
|
||||
c.Image=i
|
||||
@ -1,7 +1,7 @@
|
||||
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
|
||||
if type(i)=="string" or type(i):find("ImageData") then
|
||||
c.Image=love.graphics.newImage(i)
|
||||
else
|
||||
c.Image=i
|
||||
@ -9,7 +9,7 @@ function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
c.Visibility=0
|
||||
c.ImageVisibility=1
|
||||
c.rotation=0
|
||||
if c.Image~=nil then
|
||||
if c.Image then
|
||||
c.ImageHeigth=c.Image:getHeight()
|
||||
c.ImageWidth=c.Image:getWidth()
|
||||
c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth)
|
||||
@ -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
|
||||
@ -6,4 +6,5 @@ function gui:Destroy()
|
||||
table.remove(self.Parent.Children,cc)
|
||||
end
|
||||
end
|
||||
self.Destroyed = true
|
||||
end
|
||||
@ -1,4 +1,18 @@
|
||||
function gui:SetDualDim(x, y, w, h, sx ,sy ,sw ,sh)
|
||||
if _GuiPro.DPI_ENABLED then
|
||||
if x then
|
||||
x=self.DPI*x
|
||||
end
|
||||
if y then
|
||||
y=self.DPI*y
|
||||
end
|
||||
if w then
|
||||
w=self.DPI*w
|
||||
end
|
||||
if h then
|
||||
h=self.DPI*h
|
||||
end
|
||||
end
|
||||
if sx then
|
||||
self.scale.pos.x=sx
|
||||
end
|
||||
4
GuiManager/Misc/center.int
Normal file
4
GuiManager/Misc/center.int
Normal file
@ -0,0 +1,4 @@
|
||||
function gui:center()
|
||||
self:centerX()
|
||||
self:centerY()
|
||||
end
|
||||
@ -2,9 +2,9 @@ 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
|
||||
if temp[i].width+temp[i].offset.pos.x>maxx then
|
||||
maxx=temp[i].width+temp[i].offset.pos.x
|
||||
elseif temp[i].height>maxy then
|
||||
elseif temp[i].height+temp[i].offset.pos.y>maxy then
|
||||
maxy=temp[i].height+temp[i].offset.pos.y
|
||||
end
|
||||
end
|
||||
@ -1,4 +1,4 @@
|
||||
if love.filesystem.exists("CheckBoxes.png") then
|
||||
if love.filesystem.getInfo("CheckBoxes.png") then
|
||||
_GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16)
|
||||
_GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16)
|
||||
_GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16)
|
||||
14
GuiManager/Misc/setColor.int
Normal file
14
GuiManager/Misc/setColor.int
Normal file
@ -0,0 +1,14 @@
|
||||
function gui:setColor(a,b,c)
|
||||
if type(a)=="string" then
|
||||
self.Color=Color[a]
|
||||
elseif type(a)=="number" then
|
||||
self.Color=Color.new(a,b,c)
|
||||
end
|
||||
end
|
||||
function gui:setTextColor(a,b,c)
|
||||
if type(a)=="string" then
|
||||
self.TextColor=Color[a]
|
||||
elseif type(a)=="number" then
|
||||
self.TextColor=Color.new(a,b,c)
|
||||
end
|
||||
end
|
||||
7
GuiManager/Misc/setNewFont.int
Normal file
7
GuiManager/Misc/setNewFont.int
Normal file
@ -0,0 +1,7 @@
|
||||
function gui:setNewFont(FontSize,filename)
|
||||
if filename then
|
||||
self.Font = love.graphics.newFont(filename, tonumber(FontSize))
|
||||
else
|
||||
self.Font=love.graphics.setNewFont(tonumber(FontSize))
|
||||
end
|
||||
end
|
||||
181
GuiManager/Text/newTextBox.int
Normal file
181
GuiManager/Text/newTextBox.int
Normal file
@ -0,0 +1,181 @@
|
||||
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)
|
||||
self:focus()
|
||||
end)
|
||||
function c:focus()
|
||||
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("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
|
||||
5
GuiManager/Text/widthToFontSize.int
Normal file
5
GuiManager/Text/widthToFontSize.int
Normal file
@ -0,0 +1,5 @@
|
||||
function gui:widthToTextSize(n)
|
||||
if self.Font then
|
||||
self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0)
|
||||
end
|
||||
end
|
||||
@ -1,4 +1,4 @@
|
||||
_defaultfont = love.graphics.getFont()
|
||||
utf8 = require("utf8")
|
||||
gui = {}
|
||||
gui.__index = gui
|
||||
gui.TB={}
|
||||
@ -6,14 +6,15 @@ gui.Version="VERSION" -- Is it really ready for release?
|
||||
_GuiPro={GBoost=true,hasDrag=false,DragItem={},Children={},Visible=true,count=0,x=0,y=0,height=0,width=0,update=function(self) local things=GetAllChildren2(self) UpdateThings(things) end,draw=function(self) local things=GetAllChildren(self) DrawThings(things) end,getChildren=function(self) return self.Children end}
|
||||
_GuiPro.Clips={}
|
||||
_GuiPro.rotate=0
|
||||
_defaultfont = love.graphics.setNewFont(12)
|
||||
setmetatable(_GuiPro, gui)
|
||||
function gui:LoadInterface(file)
|
||||
local add=".int"
|
||||
if string.find(file,".",1,true) then add="" end
|
||||
if love.filesystem.exists(file..add) then
|
||||
if love.filesystem.getInfo(file..add) then
|
||||
a,b=pcall(love.filesystem.load(file..add))
|
||||
if a then
|
||||
print("Loaded: "..file)
|
||||
--print("Loaded: "..file)
|
||||
else
|
||||
print("Error loading file: "..file)
|
||||
print(a,b)
|
||||
@ -33,7 +34,6 @@ function gui.LoadAll(dir)
|
||||
end
|
||||
-- Start Of Load
|
||||
|
||||
--gui.LoadAll("GuiManager/LibCore")
|
||||
gui.LoadAll("GuiManager/Core")
|
||||
gui.LoadAll("GuiManager/Image-Animation")
|
||||
gui.LoadAll("GuiManager/Frame")
|
||||
@ -41,16 +41,14 @@ gui.LoadAll("GuiManager/Item")
|
||||
gui.LoadAll("GuiManager/Misc")
|
||||
gui.LoadAll("GuiManager/Text")
|
||||
gui.LoadAll("GuiManager/Drawing")
|
||||
gui.LoadAll("GuiManager/Combos")
|
||||
--gui.LoadAll("GuiManager/WIP")
|
||||
multi.boost=2
|
||||
|
||||
multi.boost=2
|
||||
-- End of Load
|
||||
gui:respectHierarchy()
|
||||
_GuiPro.width,_GuiPro.height=love.graphics.getDimensions()
|
||||
multi:newLoop():OnLoop(function() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() _GuiPro:update() end)
|
||||
multi:onDraw(function() _GuiPro:draw() end)
|
||||
gui.ff=gui:newItem("",nil,"",0,0,0,0,0,0,1,1)
|
||||
gui.ff=gui:newFrame("",0,0,0,0,0,0,1,1)
|
||||
gui.ff.Color={255,255,255}
|
||||
gui.ff:OnUpdate(function(self)
|
||||
self:BottomStack()
|
||||
@ -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,7 +0,0 @@
|
||||
function gui:setColor(a,b,c)
|
||||
if type(a)=="string" then
|
||||
self.Color=Color[a]
|
||||
elseif type(a)=="number" then
|
||||
self.Color=Color.new(a,b,c)
|
||||
end
|
||||
end
|
||||
@ -1,3 +0,0 @@
|
||||
function gui:setNewFont(FontSize)
|
||||
self.Font=love.graphics.setNewFont(tonumber(FontSize))
|
||||
end
|
||||
@ -1,104 +0,0 @@
|
||||
function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh)
|
||||
local c=self: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 -- 0=invisible,1=solid (self.TextVisibility*254+1)
|
||||
c.Color = {220, 220, 220}
|
||||
c.TextColor = {0, 0, 0}
|
||||
c.Active=false
|
||||
c.hidden=false
|
||||
c.funcF={function()
|
||||
love.keyboard.setTextInput(true)
|
||||
end}
|
||||
c.cooldown=false
|
||||
c.cooldown2=false
|
||||
c.funcE={function()
|
||||
love.keyboard.setTextInput(false)
|
||||
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)
|
||||
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:OnUpdate(function(self)
|
||||
if love.keyboard.isDown("backspace") and self.Active and self.cooldown==false then
|
||||
self.text=string.sub(self.text,1,-2)
|
||||
self.ttext=string.sub(self.ttext,1,-2)
|
||||
self.cooldown=true
|
||||
c.Alarm:Reset()
|
||||
elseif love.keyboard.isDown("backspace")==false then
|
||||
self.cooldown=false
|
||||
end
|
||||
if love.keyboard.isDown("delete") and self.Active then
|
||||
self.text=string.sub(self.text,1,-2)
|
||||
self.ttext=string.sub(self.text,1,-2)
|
||||
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].ttext=gui.TB[tb].ttext..t
|
||||
else
|
||||
gui.TB[tb].text=gui.TB[tb].text..t
|
||||
gui.TB[tb].ttext=gui.TB[tb].ttext..t
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
770
Utils.lua
Normal file
770
Utils.lua
Normal file
@ -0,0 +1,770 @@
|
||||
-- os Additions
|
||||
function os.getSystemBit()
|
||||
if (os.getenv("PROCESSOR_ARCHITEW6432")=="AMD64" or os.getenv("PROCESSOR_ARCHITECTURE")=="AMD64") then
|
||||
return 64
|
||||
else
|
||||
return 32
|
||||
end
|
||||
end
|
||||
function os.sleep(n)
|
||||
if not n then n=0 end
|
||||
local t0 = os.clock()
|
||||
while os.clock() - t0 <= n do end
|
||||
end
|
||||
function os.pause(msg)
|
||||
if msg ~= nil then
|
||||
print(msg)
|
||||
end
|
||||
io.read()
|
||||
end
|
||||
function os.batCmd(cmd)
|
||||
io.mkFile("temp.bat",cmd)
|
||||
local temp = os.execute([[temp.bat]])
|
||||
io.delFile("temp.bat")
|
||||
return temp
|
||||
end
|
||||
function os._getOS()
|
||||
if package.config:sub(1,1)=="\\" then
|
||||
return "windows"
|
||||
else
|
||||
return "unix"
|
||||
end
|
||||
end
|
||||
function os.getOS(t)
|
||||
if not t then
|
||||
return os._getOS()
|
||||
end
|
||||
if os._getOS()=="unix" then
|
||||
fh,err = io.popen("uname -o 2>/dev/null","r")
|
||||
if fh then
|
||||
osname = fh:read()
|
||||
end
|
||||
if osname then return osname end
|
||||
end
|
||||
local winver="'Unknown Version'"
|
||||
local a,b,c=os.capture("ver"):match("(%d+).(%d+).(%d+)")
|
||||
local win=a.."."..b.."."..c
|
||||
if type(t)=="string" then
|
||||
win=t
|
||||
end
|
||||
if win=="4.00.950" then
|
||||
winver="95"
|
||||
elseif win=="4.00.1111" then
|
||||
winver="95 OSR2"
|
||||
elseif win=="4.00.1381" then
|
||||
winver="NT 4.0"
|
||||
elseif win=="4.10.1998" then
|
||||
winver="98"
|
||||
elseif win=="4.10.2222" then
|
||||
winver="98 SE"
|
||||
elseif win=="4.90.3000" then
|
||||
winver="ME"
|
||||
elseif win=="5.00.2195" then
|
||||
winver="2000"
|
||||
elseif win=="5.1.2600" then
|
||||
winver="XP"
|
||||
elseif win=="5.2.3790" then
|
||||
winver="Server 2003"
|
||||
elseif win=="6.0.6000" then
|
||||
winver="Vista/Windows Server 2008"
|
||||
elseif win=="6.0.6002" then
|
||||
winver="Vista SP2"
|
||||
elseif win=="6.1.7600" then
|
||||
winver="7/Windows Server 2008 R2"
|
||||
elseif win=="6.1.7601" then
|
||||
winver="7 SP1/Windows Server 2008 R2 SP1"
|
||||
elseif win=="6.2.9200" then
|
||||
winver="8/Windows Server 2012"
|
||||
elseif win=="6.3.9600" then
|
||||
winver="8.1/Windows Server 2012"
|
||||
elseif win=="6.4.9841" then
|
||||
winver="10 Technical Preview 1"
|
||||
elseif win=="6.4.9860" then
|
||||
winver="10 Technical Preview 2"
|
||||
elseif win=="6.4.9879" then
|
||||
winver="10 Technical Preview 3"
|
||||
elseif win=="10.0.9926" then
|
||||
winver="10 Technical Preview 4"
|
||||
end
|
||||
return "Windows "..winver
|
||||
end
|
||||
function os.getLuaArch()
|
||||
return (#tostring({})-7)*4
|
||||
end
|
||||
if os.getOS()=="windows" then
|
||||
function os.sleep(n)
|
||||
if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end
|
||||
end
|
||||
else
|
||||
function os.sleep(n)
|
||||
os.execute("sleep " .. tonumber(n))
|
||||
end
|
||||
end
|
||||
function os.capture(cmd, raw)
|
||||
local f = assert(io.popen(cmd, 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
if raw then return s end
|
||||
s = string.gsub(s, '^%s+', '')
|
||||
s = string.gsub(s, '%s+$', '')
|
||||
s = string.gsub(s, '[\n\r]+', ' ')
|
||||
return s
|
||||
end
|
||||
function os.getCurrentUser()
|
||||
return os.getenv("$USER") or os.getenv("USERNAME")
|
||||
end
|
||||
-- string Additions
|
||||
function string.random(n)
|
||||
local str = ""
|
||||
strings = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}
|
||||
for i=1,n do
|
||||
h = math.random(1,#strings)
|
||||
str = str..""..strings[h]
|
||||
end
|
||||
return str
|
||||
end
|
||||
function string.linesToTable(s)
|
||||
local t = {}
|
||||
local i = 0
|
||||
while true do
|
||||
i = string.find(s, "\n", i+1)
|
||||
if i == nil then return t end
|
||||
table.insert(t, i)
|
||||
end
|
||||
end
|
||||
function string.lines(str)
|
||||
local t = {}
|
||||
local function helper(line) table.insert(t, line) return "" end
|
||||
helper((str:gsub("(.-)\r?\n", helper)))
|
||||
return t
|
||||
end
|
||||
function string.split(str, pat)
|
||||
local t = {} -- NOTE: use {n = 0} in Lua-5.0
|
||||
local fpat = "(.-)" .. pat
|
||||
local last_end = 1
|
||||
local s, e, cap = str:find(fpat, 1)
|
||||
while s do
|
||||
if s ~= 1 or cap ~= "" then
|
||||
table.insert(t,cap)
|
||||
end
|
||||
last_end = e+1
|
||||
s, e, cap = str:find(fpat, last_end)
|
||||
end
|
||||
if last_end <= #str then
|
||||
cap = str:sub(last_end)
|
||||
table.insert(t, cap)
|
||||
end
|
||||
return t
|
||||
end
|
||||
function string.shuffle(inputStr)
|
||||
math.randomseed(os.time());
|
||||
local outputStr = "";
|
||||
local strLength = string.len(inputStr);
|
||||
while (strLength ~=0) do
|
||||
local pos = math.random(strLength);
|
||||
outputStr = outputStr..string.sub(inputStr,pos,pos);
|
||||
inputStr = inputStr:sub(1, pos-1) .. inputStr:sub(pos+1);
|
||||
strLength = string.len(inputStr);
|
||||
end
|
||||
return outputStr;
|
||||
end
|
||||
function string.genKeys(chars,a,f,s,GG)
|
||||
if GG then
|
||||
chars=string.rep(chars,a)
|
||||
end
|
||||
if s then
|
||||
chars=string.shuffle(chars)
|
||||
end
|
||||
b=#chars
|
||||
if a==0 then return end
|
||||
local taken = {} local slots = {}
|
||||
for i=1,a do slots[i]=0 end
|
||||
for i=1,b do taken[i]=false end
|
||||
local index = 1
|
||||
local tab={}
|
||||
for i=1,#chars do
|
||||
table.insert(tab,chars:sub(i,i))
|
||||
end
|
||||
while index > 0 do repeat
|
||||
repeat slots[index] = slots[index] + 1
|
||||
until slots[index] > b or not taken[slots[index]]
|
||||
if slots[index] > b then
|
||||
slots[index] = 0
|
||||
index = index - 1
|
||||
if index > 0 then
|
||||
taken[slots[index]] = false
|
||||
end
|
||||
break
|
||||
else
|
||||
taken[slots[index]] = true
|
||||
end
|
||||
if index == a then
|
||||
local tt={}
|
||||
for i=1,a do
|
||||
table.insert(tt,tab[slots[i]])
|
||||
end
|
||||
f(table.concat(tt))
|
||||
taken[slots[index]] = false
|
||||
break
|
||||
end
|
||||
index = index + 1
|
||||
until true end
|
||||
end
|
||||
-- io Additions
|
||||
function io.getInput(msg)
|
||||
if msg ~= nil then
|
||||
io.write(msg)
|
||||
end
|
||||
return io.read()
|
||||
end
|
||||
function io.scanDir(directory)
|
||||
directory=directory or io.getDir()
|
||||
local i, t, popen = 0, {}, io.popen
|
||||
if os.getOS()=="unix" then
|
||||
for filename in popen('ls -a "'..directory..'"'):lines() do
|
||||
i = i + 1
|
||||
t[i] = filename
|
||||
end
|
||||
else
|
||||
for filename in popen('dir "'..directory..'" /b'):lines() do
|
||||
i = i + 1
|
||||
t[i] = filename
|
||||
end
|
||||
end
|
||||
return t
|
||||
end
|
||||
function io.buildFromTree(tbl, indent,folder)
|
||||
if not indent then indent = 0 end
|
||||
if not folder then folder = "" end
|
||||
for k, v in pairs(tbl) do
|
||||
formatting = string.rep(" ", indent) .. k .. ":"
|
||||
if type(v) == "table" then
|
||||
if not(io.dirExists(folder..string.sub(formatting,1,-2))) then
|
||||
io.mkDir(folder..string.sub(formatting,1,-2))
|
||||
end
|
||||
io.buildFromTree(v,0,folder..string.sub(formatting,1,-2).."\\")
|
||||
else
|
||||
a=string.find(tostring(v),":",1,true)
|
||||
if a then
|
||||
file=string.sub(tostring(v),1,a-1)
|
||||
data=string.sub(tostring(v),a+1)
|
||||
io.mkFile(folder..file,data,"wb")
|
||||
else
|
||||
io.mkFile(folder..v,"","wb")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function io.cpFile(path,topath)
|
||||
if os.getOS()=="unix" then
|
||||
os.execute("cp "..file1.." "..file2)
|
||||
else
|
||||
os.execute("Copy "..path.." "..topath)
|
||||
end
|
||||
end
|
||||
function io.delDir(directoryname)
|
||||
if os.getOS()=="unix" then
|
||||
os.execute("rm -rf "..directoryname)
|
||||
else
|
||||
os.execute("rmdir "..directoryname.." /s /q")
|
||||
end
|
||||
end
|
||||
function io.delFile(path)
|
||||
os.remove(path)
|
||||
end
|
||||
function io.mkDir(dirname)
|
||||
os.execute("mkdir \"" .. dirname.."\"")
|
||||
end
|
||||
function io.mkFile(filename,data,tp)
|
||||
if not(tp) then tp="wb" end
|
||||
if not(data) then data="" end
|
||||
file = io.open(filename, tp)
|
||||
if file==nil then return end
|
||||
file:write(data)
|
||||
file:close()
|
||||
end
|
||||
function io.movFile(path,topath)
|
||||
io.cpFile(path,topath)
|
||||
io.delFile(path)
|
||||
end
|
||||
function io.listFiles(dir)
|
||||
if not(dir) then dir="" end
|
||||
local f = io.popen("dir \""..dir.."\"")
|
||||
if f then
|
||||
return f:read("*a")
|
||||
else
|
||||
print("failed to read")
|
||||
end
|
||||
end
|
||||
function io.getDir(dir)
|
||||
if not dir then return io.getWorkingDir() end
|
||||
if os.getOS()=="unix" then
|
||||
return os.capture("cd "..dir.." ; cd")
|
||||
else
|
||||
return os.capture("cd "..dir.." & cd")
|
||||
end
|
||||
end
|
||||
function io.getWorkingDir()
|
||||
return io.popen"cd":read'*l'
|
||||
end
|
||||
function io.fileExists(path)
|
||||
g=io.open(path or '','r')
|
||||
if path =="" then
|
||||
p="empty path"
|
||||
return nil
|
||||
end
|
||||
if g~=nil and true or false then
|
||||
p=(g~=nil and true or false)
|
||||
end
|
||||
if g~=nil then
|
||||
io.close(g)
|
||||
else
|
||||
return false
|
||||
end
|
||||
return p
|
||||
end
|
||||
function io.fileCheck(file_name)
|
||||
if not file_name then print("No path inputed") return false end
|
||||
local file_found=io.open(file_name, "r")
|
||||
if file_found==nil then
|
||||
file_found=false
|
||||
else
|
||||
file_found=true
|
||||
end
|
||||
return file_found
|
||||
end
|
||||
function io.dirExists(strFolderName)
|
||||
strFolderName = strFolderName or io.getDir()
|
||||
local fileHandle, strError = io.open(strFolderName.."\\*.*","r")
|
||||
if fileHandle ~= nil then
|
||||
io.close(fileHandle)
|
||||
return true
|
||||
else
|
||||
if string.match(strError,"No such file or directory") then
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
function io.listItems(dir)
|
||||
if io.dirExists(dir) then
|
||||
temp=io.listFiles(dir) -- current directory if blank
|
||||
if io.getDir(dir)=="C:\\\n" then
|
||||
a,b=string.find(temp,"C:\\",1,true)
|
||||
a=a+2
|
||||
else
|
||||
a,b=string.find(temp,"..",1,true)
|
||||
end
|
||||
temp=string.sub(temp,a+2)
|
||||
list=string.linesToTable(temp)
|
||||
temp=string.sub(temp,1,list[#list-2])
|
||||
slist=string.lines(temp)
|
||||
table.remove(slist,1)
|
||||
table.remove(slist,#slist)
|
||||
temp={}
|
||||
temp2={}
|
||||
for i=1,#slist do
|
||||
table.insert(temp,string.sub(slist[i],40,-1))
|
||||
end
|
||||
return temp
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
function io.getDirectories(dir,l)
|
||||
if dir then
|
||||
dir=dir.."\\"
|
||||
else
|
||||
dir=""
|
||||
end
|
||||
local temp2=io.scanDir(dir)
|
||||
for i=#temp2,1,-1 do
|
||||
if io.fileExists(dir..temp2[i]) then
|
||||
table.remove(temp2,i)
|
||||
elseif l then
|
||||
temp2[i]=dir..temp2[i]
|
||||
end
|
||||
end
|
||||
return temp2
|
||||
end
|
||||
function io.getFiles(dir,l)
|
||||
if dir then
|
||||
dir=dir.."\\"
|
||||
else
|
||||
dir=""
|
||||
end
|
||||
local temp2=io.scanDir(dir)
|
||||
for i=#temp2,1,-1 do
|
||||
if io.dirExists(dir..temp2[i]) then
|
||||
table.remove(temp2,i)
|
||||
elseif l then
|
||||
temp2[i]=dir..temp2[i]
|
||||
end
|
||||
end
|
||||
return temp2
|
||||
end
|
||||
function io.getFullName(name)
|
||||
local temp=name or arg[0]
|
||||
if string.find(temp,"\\",1,true) or string.find(temp,"/",1,true) then
|
||||
temp=string.reverse(temp)
|
||||
a,b=string.find(temp,"\\",1,true)
|
||||
if not(a) or not(b) then
|
||||
a,b=string.find(temp,"/",1,true)
|
||||
end
|
||||
return string.reverse(string.sub(temp,1,b-1))
|
||||
end
|
||||
return temp
|
||||
end
|
||||
function io.getName(file)
|
||||
local name=io.getFullName(file)
|
||||
name=string.reverse(name)
|
||||
a,b=string.find(name,".",1,true)
|
||||
name=string.sub(name,a+1,-1)
|
||||
return string.reverse(name)
|
||||
end
|
||||
function io.readFile(file)
|
||||
local f = io.open(file, "rb")
|
||||
local content = f:read("*all")
|
||||
f:close()
|
||||
return content
|
||||
end
|
||||
function io.getExtension(file)
|
||||
local file=io.getFullName(file)
|
||||
file=string.reverse(file)
|
||||
local a,b=string.find(file,".",0,true)
|
||||
local temp=string.sub(file,1,b)
|
||||
return string.reverse(temp)
|
||||
end
|
||||
function io.pathToTable(path)
|
||||
local p=io.splitPath(path)
|
||||
local temp={}
|
||||
temp[p[1]]={}
|
||||
local last=temp[p[1]]
|
||||
for i=2,#p do
|
||||
snd=last
|
||||
last[p[i]]={}
|
||||
last=last[p[i]]
|
||||
end
|
||||
return temp,last,snd
|
||||
end
|
||||
function io.splitPath(str)
|
||||
return string.split(str,'[\\/]+')
|
||||
end
|
||||
|
||||
function io.parseDir(dir,t)
|
||||
io.tempFiles={}
|
||||
function _p(dir)
|
||||
local dirs=io.getDirectories(dir,true)
|
||||
local files=io.getFiles(dir,true)
|
||||
for i=1,#files do
|
||||
p,l,s=io.pathToTable(files[i])
|
||||
if t then
|
||||
s[io.getFullName(files[i])]=io.readFile(files[i])
|
||||
else
|
||||
s[io.getFullName(files[i])]=io.open(files[i],"r+")
|
||||
end
|
||||
table.merge(io.tempFiles,p)
|
||||
end
|
||||
for i=1,#dirs do
|
||||
table.merge(io.tempFiles,io.pathToTable(dirs[i]))
|
||||
_p(dirs[i],t)
|
||||
end
|
||||
end
|
||||
_p(dir)
|
||||
return io.tempFiles
|
||||
end
|
||||
function io.parsedir(dir,f)
|
||||
io.tempFiles={}
|
||||
function _p(dir,f)
|
||||
local dirs=io.getDirectories(dir,true)
|
||||
local files=io.getFiles(dir,true)
|
||||
for i=1,#files do
|
||||
if not f then
|
||||
table.insert(io.tempFiles,files[i])
|
||||
else
|
||||
f(files[i])
|
||||
end
|
||||
end
|
||||
for i=1,#dirs do
|
||||
_p(dirs[i],f)
|
||||
end
|
||||
end
|
||||
_p(dir,f)
|
||||
return io.tempFiles
|
||||
end
|
||||
function io.driveReady(drive)
|
||||
drive=drive:upper()
|
||||
if not(drive:find(":",1,true)) then
|
||||
drive=drive..":"
|
||||
end
|
||||
drives=io.getDrives()
|
||||
for i=1,#drives do
|
||||
if drives[i]==drive then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
function io.getDrives()
|
||||
if os.getOS()=="windows" then
|
||||
local temp={}
|
||||
local t1=os.capture("wmic logicaldisk where drivetype=2 get deviceid, volumename",true)
|
||||
local t2=os.capture("wmic logicaldisk where drivetype=3 get deviceid, volumename",true)
|
||||
for drive,d2 in t1:gmatch("(.:)%s-(%w+)") do
|
||||
if #d2>1 then
|
||||
table.insert(temp,drive)
|
||||
end
|
||||
end
|
||||
for drive in t2:gmatch("(.:)") do
|
||||
table.insert(temp,drive)
|
||||
end
|
||||
return temp
|
||||
end
|
||||
error("Command is windows only!")
|
||||
end
|
||||
-- table Additions
|
||||
function table.dump(t,indent)
|
||||
local names = {}
|
||||
if not indent then indent = "" end
|
||||
for n,g in pairs(t) do
|
||||
table.insert(names,n)
|
||||
end
|
||||
table.sort(names)
|
||||
for i,n in pairs(names) do
|
||||
local v = t[n]
|
||||
if type(v) == "table" then
|
||||
if(v==t) then
|
||||
print(indent..tostring(n)..": <-")
|
||||
else
|
||||
print(indent..tostring(n)..":")
|
||||
table.dump(v,indent.." ")
|
||||
end
|
||||
else
|
||||
if type(v) == "function" then
|
||||
print(indent..tostring(n).."()")
|
||||
else
|
||||
print(indent..tostring(n)..": "..tostring(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function table.alphanumsort(o)
|
||||
local function padnum(d) local dec, n = string.match(d, "(%.?)0*(.+)")
|
||||
return #dec > 0 and ("%.12f"):format(d) or ("%s%03d%s"):format(dec, #n, n)
|
||||
end
|
||||
table.sort(o, function(a,b) return tostring(a):gsub("%.?%d+",padnum)..("%3d"):format(#b)< tostring(b):gsub("%.?%d+",padnum)..("%3d"):format(#a) end)
|
||||
return o
|
||||
end
|
||||
function table.foreach(t,f)
|
||||
for i,v in pairs(t) do
|
||||
f(v)
|
||||
end
|
||||
end
|
||||
function table.merge(t1, t2)
|
||||
for k,v in pairs(t2) do
|
||||
if type(v) == "table" then
|
||||
if type(t1[k] or false) == "table" then
|
||||
table.merge(t1[k] or {}, t2[k] or {})
|
||||
else
|
||||
t1[k] = v
|
||||
end
|
||||
else
|
||||
t1[k] = v
|
||||
end
|
||||
end
|
||||
return t1
|
||||
end
|
||||
function table.print(tbl, indent)
|
||||
if not indent then indent = 0 end
|
||||
for k, v in pairs(tbl) do
|
||||
formatting = string.rep(" ", indent) .. k .. ": "
|
||||
if type(v) == "table" then
|
||||
print(formatting)
|
||||
table.print(v, indent+1)
|
||||
else
|
||||
print(formatting .. tostring(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
function table.merge(t1, t2)
|
||||
for k,v in pairs(t2) do
|
||||
if type(v) == "table" then
|
||||
if type(t1[k] or false) == "table" then
|
||||
table.merge(t1[k] or {}, t2[k] or {})
|
||||
else
|
||||
t1[k] = v
|
||||
end
|
||||
else
|
||||
t1[k] = v
|
||||
end
|
||||
end
|
||||
return t1
|
||||
end
|
||||
function table.clear(t)
|
||||
for k in pairs (t) do
|
||||
t[k] = nil
|
||||
end
|
||||
end
|
||||
function table.copy(t)
|
||||
function deepcopy(orig)
|
||||
local orig_type = type(orig)
|
||||
local copy
|
||||
if orig_type == 'table' then
|
||||
copy = {}
|
||||
for orig_key, orig_value in next, orig, nil do
|
||||
copy[deepcopy(orig_key)] = deepcopy(orig_value)
|
||||
end
|
||||
setmetatable(copy, deepcopy(getmetatable(orig)))
|
||||
else -- number, string, boolean, etc
|
||||
copy = orig
|
||||
end
|
||||
return copy
|
||||
end
|
||||
return deepcopy(t)
|
||||
end
|
||||
function table.swap(tab,i1,i2)
|
||||
tab[i1],tab[i2]=tab[i2],tab[i1]
|
||||
end
|
||||
function table.append(t1, ...)
|
||||
t1,t2= t1 or {},{...}
|
||||
for k,v in pairs(t2) do
|
||||
t1[#t1+1]=t2[k]
|
||||
end
|
||||
return t1
|
||||
end
|
||||
function table.compare(t1, t2,d)
|
||||
if d then
|
||||
return table.deepCompare(t1,t2)
|
||||
end
|
||||
--if #t1 ~= #t2 then return false end
|
||||
if #t2>#t1 then
|
||||
for i=1,#t2 do
|
||||
if t1[i] ~= t2[i] then
|
||||
return false,t2[i]
|
||||
end
|
||||
end
|
||||
else
|
||||
for i=1,#t1 do
|
||||
if t1[i] ~= t2[i] then
|
||||
return false,t2[i]
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
function table.deepCompare(t1,t2)
|
||||
if t1==t2 then return true end
|
||||
if (type(t1)~="table") then return false end
|
||||
local mt1 = getmetatable(t1)
|
||||
local mt2 = getmetatable(t2)
|
||||
if( not table.deepCompare(mt1,mt2) ) then return false end
|
||||
for k1,v1 in pairs(t1) do
|
||||
local v2 = t2[k1]
|
||||
if( not table.deepCompare(v1,v2) ) then return false end
|
||||
end
|
||||
for k2,v2 in pairs(t2) do
|
||||
local v1 = t1[k2]
|
||||
if( not table.deepCompare(v1,v2) ) then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
-- Math Additions
|
||||
local Y = function(g) local a = function(f) return f(f) end return a(function(f) return g(function(x) local c=f(f) return c(x) end) end) end
|
||||
local F = function(f) return function(n)if n == 0 then return 1 else return n*f(n-1) end end end
|
||||
math.factorial = Y(F)
|
||||
math.fib={}
|
||||
math.fib.fibL={}
|
||||
setmetatable(math.fib,{__call=function(self,n)
|
||||
if n<=2 then
|
||||
return 1
|
||||
else
|
||||
if self.fibL[n] then
|
||||
return self.fibL[n]
|
||||
else
|
||||
local t=math.fib(n-1)+math.fib(n-2)
|
||||
self.fibL[n]=t
|
||||
return t
|
||||
end
|
||||
end
|
||||
end})
|
||||
local floor,insert = math.floor, table.insert
|
||||
function math.basen(n,b)
|
||||
n = floor(n)
|
||||
if not b or b == 10 then return tostring(n) end
|
||||
local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
local t = {}
|
||||
local sign = ""
|
||||
if n < 0 then
|
||||
sign = "-"
|
||||
n = -n
|
||||
end
|
||||
repeat
|
||||
local d = (n % b) + 1
|
||||
n = floor(n / b)
|
||||
insert(t, 1, digits:sub(d,d))
|
||||
until n == 0
|
||||
return sign .. table.concat(t,"")
|
||||
end
|
||||
function math.convbase(n,b,tb)
|
||||
return math.basen(tonumber(tostring(n),b),tb)
|
||||
end
|
||||
if BigNum then
|
||||
function BigNum.mod(a,b)
|
||||
return a-((a/b)*b)
|
||||
end
|
||||
local floor,insert = math.floor, table.insert
|
||||
function math.basen(n,b)
|
||||
n = BigNum.new(n)
|
||||
if not b or b == 10 then return tostring(n) end
|
||||
local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
local t = {}
|
||||
local sign = ""
|
||||
if n < BigNum.new(0) then
|
||||
sign = "-"
|
||||
n = -n
|
||||
end
|
||||
repeat
|
||||
local d = BigNum.mod(n , b) + 1
|
||||
n = n/b
|
||||
d=tonumber(tostring(d))
|
||||
insert(t, 1, digits:sub(d,d))
|
||||
until tonumber(tostring(n)) == 0
|
||||
return sign .. table.concat(t,"")
|
||||
end
|
||||
function math.to10(n,b)
|
||||
local num=tostring(n)
|
||||
local sum=BigNum.new()
|
||||
local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
for i=1,#num do
|
||||
local v=digits:find(num:sub(i,i),1,true)
|
||||
sum=sum+BigNum.new(tonumber(v)-1)*BigNum.pow(BigNum.new(b),BigNum.new(#num-i))
|
||||
end
|
||||
return sum
|
||||
end
|
||||
function math.convbase(n,b,tb)
|
||||
return math.basen(math.to10(n,b),tb)
|
||||
end
|
||||
end
|
||||
function math.numfix(n,x)
|
||||
local str=tostring(n)
|
||||
if #str<x then
|
||||
str=("0"):rep(x-#str)..str
|
||||
end
|
||||
return str
|
||||
end
|
||||
-- Misc Additions
|
||||
function smartPrint(...)
|
||||
local args={...}
|
||||
for i=1,#args do
|
||||
if type(args[i])=="table" then
|
||||
table.print(args[i])
|
||||
else
|
||||
print(args[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
function totable(v)
|
||||
if type(v)=="table" then return v end
|
||||
return {v}
|
||||
end
|
||||
39
merger.lua
Normal file
39
merger.lua
Normal file
@ -0,0 +1,39 @@
|
||||
require("utils")
|
||||
require("bin")
|
||||
print("Library binder version 1.0\n")
|
||||
ver=io.getInput("Version #? ")
|
||||
merged=bin.new()
|
||||
init=bin.load("GuiManager/init.lua")
|
||||
init:gsub("gui.Version=\"VERSION\"","gui.Version=\""..ver.."\"")
|
||||
print("Parsing init file...")
|
||||
a,b=init.data:find("-- Start Of Load")
|
||||
c,d=init.data:find("-- End of Load")
|
||||
_o=init:sub(b+1,c-1)
|
||||
print("Setting up headers...")
|
||||
start=init:sub(1,a-1)
|
||||
_end=init:sub(d+1,-1)
|
||||
merged:tackE(start.."\n")
|
||||
print("Parsing paths...")
|
||||
for path in _o:gmatch("\"(.-)\"") do
|
||||
files=io.scanDir(path)
|
||||
for i=1,#files do
|
||||
merged:tackE(bin.load(path.."/"..files[i]).data.."\n")
|
||||
end
|
||||
end
|
||||
merged:tackE(_end.."\n")
|
||||
print("Finishing up...")
|
||||
merged:tofile("GuiManager.lua")
|
||||
print("GuiManager.lua has been created!")
|
||||
os.sleep(3)
|
||||
--[[
|
||||
-- Start Of Load
|
||||
gui.LoadAll("GuiManager/Core")
|
||||
gui.LoadAll("GuiManager/Animation")
|
||||
gui.LoadAll("GuiManager/Frame")
|
||||
gui.LoadAll("GuiManager/Image")
|
||||
gui.LoadAll("GuiManager/Item")
|
||||
gui.LoadAll("GuiManager/Misc")
|
||||
gui.LoadAll("GuiManager/Text")
|
||||
gui.LoadAll("GuiManager/Drawing")
|
||||
-- End of Load
|
||||
]]
|
||||
Loading…
x
Reference in New Issue
Block a user