From 80e678ce359bcdf93f1046ad7f46922f8b3d037d Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Tue, 17 Jan 2023 22:21:53 -0500 Subject: [PATCH] Reformatted library --- .gitattributes | 2 - .gitignore | 6 - .gitmodules | 3 - OldStuff/GuiManager.lua | 4115 ----------------- OldStuff/GuiManager/Core/EventDefinitions.int | 200 - OldStuff/GuiManager/Core/_GetAllChildren.int | 25 - OldStuff/GuiManager/Core/_GetAllChildren2.int | 21 - OldStuff/GuiManager/Core/canPress.int | 72 - OldStuff/GuiManager/Core/fromString.int | 0 OldStuff/GuiManager/Core/full.int | 3 - OldStuff/GuiManager/Core/newBase.int | 167 - OldStuff/GuiManager/Core/patches.int | 7 - OldStuff/GuiManager/Core/toString.int | 40 - OldStuff/GuiManager/Core/touchManager.int | 204 - OldStuff/GuiManager/Drawing/AddDrawRuleB.int | 4 - OldStuff/GuiManager/Drawing/AddDrawRuleE.int | 4 - OldStuff/GuiManager/Drawing/canvas.int | 0 OldStuff/GuiManager/Drawing/draw.int | 12 - OldStuff/GuiManager/Drawing/drawC.int | 89 - OldStuff/GuiManager/Drawing/drawR.lua | 73 - OldStuff/GuiManager/Frame/newDropFrame.int | 37 - OldStuff/GuiManager/Frame/newFrame.int | 8 - OldStuff/GuiManager/Frame/newFullFrame.int | 4 - OldStuff/GuiManager/Frame/newTabFrame.int | 59 - OldStuff/GuiManager/Frame/newratioFrame.int | 0 .../GuiManager/Image-Animation/SetImage.int | 16 - .../Image-Animation/SetThreadedImage.int | 60 - .../Image-Animation/imageThreadHandler.int | 44 - .../GuiManager/Image-Animation/newAnim.int | 67 - .../Image-Animation/newAnimFromData.int | 52 - .../Image-Animation/newAnimFromTiles.int | 59 - .../Image-Animation/newFullImageLabel.int | 3 - .../Image-Animation/newImageButton.int | 15 - .../Image-Animation/newImageLabel.int | 10 - .../GuiManager/Image-Animation/newVideo.int | 62 - OldStuff/GuiManager/Item/newDragItem.int | 51 - OldStuff/GuiManager/Item/newItem.int | 28 - OldStuff/GuiManager/Misc/AdvTextBox.int | 45 - OldStuff/GuiManager/Misc/ApplyGradient.int | 36 - OldStuff/GuiManager/Misc/BottomStack.int | 10 - OldStuff/GuiManager/Misc/ClipDescendants.int | 18 - OldStuff/GuiManager/Misc/Destroy.int | 13 - OldStuff/GuiManager/Misc/GetAllChildren.int | 25 - OldStuff/GuiManager/Misc/GetChild.int | 3 - OldStuff/GuiManager/Misc/InGrid.int | 3 - OldStuff/GuiManager/Misc/InGridX.int | 5 - OldStuff/GuiManager/Misc/InGridY.int | 5 - OldStuff/GuiManager/Misc/IsHovering.int | 3 - OldStuff/GuiManager/Misc/Move.int | 4 - OldStuff/GuiManager/Misc/SetDualDim.int | 46 - OldStuff/GuiManager/Misc/SetHand.int | 5 - OldStuff/GuiManager/Misc/SetHover.int | 3 - OldStuff/GuiManager/Misc/SetName.int | 4 - OldStuff/GuiManager/Misc/SquareX.int | 9 - OldStuff/GuiManager/Misc/SquareY.int | 9 - OldStuff/GuiManager/Misc/TopStack.int | 10 - OldStuff/GuiManager/Misc/UpdateImage.int | 5 - OldStuff/GuiManager/Misc/Utils.int | 797 ---- OldStuff/GuiManager/Misc/addDominance.int | 3 - OldStuff/GuiManager/Misc/alphanumsort.int | 7 - OldStuff/GuiManager/Misc/anchorRight.int | 3 - OldStuff/GuiManager/Misc/center.int | 4 - OldStuff/GuiManager/Misc/centerX.int | 3 - OldStuff/GuiManager/Misc/centerY.int | 3 - .../GuiManager/Misc/disrespectHierarchy.int | 3 - OldStuff/GuiManager/Misc/getChildren.int | 3 - OldStuff/GuiManager/Misc/getColor.int | 3 - OldStuff/GuiManager/Misc/getFullSize.int | 14 - OldStuff/GuiManager/Misc/getHighest.int | 5 - OldStuff/GuiManager/Misc/getLowest.int | 5 - OldStuff/GuiManager/Misc/getTile.int | 20 - OldStuff/GuiManager/Misc/isDescendant.int | 9 - OldStuff/GuiManager/Misc/isHighest.int | 3 - OldStuff/GuiManager/Misc/isLowest.int | 3 - OldStuff/GuiManager/Misc/massMutate.int | 6 - OldStuff/GuiManager/Misc/newCheckBox.int | 41 - OldStuff/GuiManager/Misc/newMessageBox.int | 36 - OldStuff/GuiManager/Misc/newPart.int | 49 - OldStuff/GuiManager/Misc/newProgressBar.int | 45 - OldStuff/GuiManager/Misc/newScrollBar.int | 42 - OldStuff/GuiManager/Misc/newScrollMenu.int | 81 - OldStuff/GuiManager/Misc/preloadImages.int | 15 - .../GuiManager/Misc/removeAllChildren.int | 6 - OldStuff/GuiManager/Misc/removeDominance.int | 3 - OldStuff/GuiManager/Misc/respectHierarchy.int | 3 - OldStuff/GuiManager/Misc/round.int | 4 - OldStuff/GuiManager/Misc/setBG.int | 3 - OldStuff/GuiManager/Misc/setColor.int | 14 - OldStuff/GuiManager/Misc/setMouseXY.int | 8 - OldStuff/GuiManager/Misc/setParent.int | 14 - OldStuff/GuiManager/Misc/setVisibility.int | 14 - OldStuff/GuiManager/Text/fitFont.int | 29 - OldStuff/GuiManager/Text/newTextBase.int | 17 - OldStuff/GuiManager/Text/newTextBox.int | 152 - OldStuff/GuiManager/Text/newTextButton.int | 11 - OldStuff/GuiManager/Text/newTextLabel.int | 4 - OldStuff/GuiManager/Text/setDefualtFont.int | 3 - OldStuff/GuiManager/Text/setNewFont.int | 9 - OldStuff/GuiManager/Text/setgetText.int | 6 - OldStuff/GuiManager/Text/widthToTextSize.int | 5 - OldStuff/GuiManager/init.lua | 82 - OldStuff/Utils.lua | 770 --- OldStuff/bin.lua | 1453 ------ OldStuff/merger.lua | 39 - {gui/addons => addons}/functions.lua | 0 {gui/addons => addons}/system.lua | 0 {gui/core => core}/color.lua | 0 {gui/core => core}/theme.lua | 0 gui/init.lua => init.lua | 2 +- multi | 1 - test.lua | 13 - 111 files changed, 1 insertion(+), 9750 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 .gitmodules delete mode 100644 OldStuff/GuiManager.lua delete mode 100644 OldStuff/GuiManager/Core/EventDefinitions.int delete mode 100644 OldStuff/GuiManager/Core/_GetAllChildren.int delete mode 100644 OldStuff/GuiManager/Core/_GetAllChildren2.int delete mode 100644 OldStuff/GuiManager/Core/canPress.int delete mode 100644 OldStuff/GuiManager/Core/fromString.int delete mode 100644 OldStuff/GuiManager/Core/full.int delete mode 100644 OldStuff/GuiManager/Core/newBase.int delete mode 100644 OldStuff/GuiManager/Core/patches.int delete mode 100644 OldStuff/GuiManager/Core/toString.int delete mode 100644 OldStuff/GuiManager/Core/touchManager.int delete mode 100644 OldStuff/GuiManager/Drawing/AddDrawRuleB.int delete mode 100644 OldStuff/GuiManager/Drawing/AddDrawRuleE.int delete mode 100644 OldStuff/GuiManager/Drawing/canvas.int delete mode 100644 OldStuff/GuiManager/Drawing/draw.int delete mode 100644 OldStuff/GuiManager/Drawing/drawC.int delete mode 100644 OldStuff/GuiManager/Drawing/drawR.lua delete mode 100644 OldStuff/GuiManager/Frame/newDropFrame.int delete mode 100644 OldStuff/GuiManager/Frame/newFrame.int delete mode 100644 OldStuff/GuiManager/Frame/newFullFrame.int delete mode 100644 OldStuff/GuiManager/Frame/newTabFrame.int delete mode 100644 OldStuff/GuiManager/Frame/newratioFrame.int delete mode 100644 OldStuff/GuiManager/Image-Animation/SetImage.int delete mode 100644 OldStuff/GuiManager/Image-Animation/SetThreadedImage.int delete mode 100644 OldStuff/GuiManager/Image-Animation/imageThreadHandler.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newAnim.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newAnimFromData.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newAnimFromTiles.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newFullImageLabel.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newImageButton.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newImageLabel.int delete mode 100644 OldStuff/GuiManager/Image-Animation/newVideo.int delete mode 100644 OldStuff/GuiManager/Item/newDragItem.int delete mode 100644 OldStuff/GuiManager/Item/newItem.int delete mode 100644 OldStuff/GuiManager/Misc/AdvTextBox.int delete mode 100644 OldStuff/GuiManager/Misc/ApplyGradient.int delete mode 100644 OldStuff/GuiManager/Misc/BottomStack.int delete mode 100644 OldStuff/GuiManager/Misc/ClipDescendants.int delete mode 100644 OldStuff/GuiManager/Misc/Destroy.int delete mode 100644 OldStuff/GuiManager/Misc/GetAllChildren.int delete mode 100644 OldStuff/GuiManager/Misc/GetChild.int delete mode 100644 OldStuff/GuiManager/Misc/InGrid.int delete mode 100644 OldStuff/GuiManager/Misc/InGridX.int delete mode 100644 OldStuff/GuiManager/Misc/InGridY.int delete mode 100644 OldStuff/GuiManager/Misc/IsHovering.int delete mode 100644 OldStuff/GuiManager/Misc/Move.int delete mode 100644 OldStuff/GuiManager/Misc/SetDualDim.int delete mode 100644 OldStuff/GuiManager/Misc/SetHand.int delete mode 100644 OldStuff/GuiManager/Misc/SetHover.int delete mode 100644 OldStuff/GuiManager/Misc/SetName.int delete mode 100644 OldStuff/GuiManager/Misc/SquareX.int delete mode 100644 OldStuff/GuiManager/Misc/SquareY.int delete mode 100644 OldStuff/GuiManager/Misc/TopStack.int delete mode 100644 OldStuff/GuiManager/Misc/UpdateImage.int delete mode 100644 OldStuff/GuiManager/Misc/Utils.int delete mode 100644 OldStuff/GuiManager/Misc/addDominance.int delete mode 100644 OldStuff/GuiManager/Misc/alphanumsort.int delete mode 100644 OldStuff/GuiManager/Misc/anchorRight.int delete mode 100644 OldStuff/GuiManager/Misc/center.int delete mode 100644 OldStuff/GuiManager/Misc/centerX.int delete mode 100644 OldStuff/GuiManager/Misc/centerY.int delete mode 100644 OldStuff/GuiManager/Misc/disrespectHierarchy.int delete mode 100644 OldStuff/GuiManager/Misc/getChildren.int delete mode 100644 OldStuff/GuiManager/Misc/getColor.int delete mode 100644 OldStuff/GuiManager/Misc/getFullSize.int delete mode 100644 OldStuff/GuiManager/Misc/getHighest.int delete mode 100644 OldStuff/GuiManager/Misc/getLowest.int delete mode 100644 OldStuff/GuiManager/Misc/getTile.int delete mode 100644 OldStuff/GuiManager/Misc/isDescendant.int delete mode 100644 OldStuff/GuiManager/Misc/isHighest.int delete mode 100644 OldStuff/GuiManager/Misc/isLowest.int delete mode 100644 OldStuff/GuiManager/Misc/massMutate.int delete mode 100644 OldStuff/GuiManager/Misc/newCheckBox.int delete mode 100644 OldStuff/GuiManager/Misc/newMessageBox.int delete mode 100644 OldStuff/GuiManager/Misc/newPart.int delete mode 100644 OldStuff/GuiManager/Misc/newProgressBar.int delete mode 100644 OldStuff/GuiManager/Misc/newScrollBar.int delete mode 100644 OldStuff/GuiManager/Misc/newScrollMenu.int delete mode 100644 OldStuff/GuiManager/Misc/preloadImages.int delete mode 100644 OldStuff/GuiManager/Misc/removeAllChildren.int delete mode 100644 OldStuff/GuiManager/Misc/removeDominance.int delete mode 100644 OldStuff/GuiManager/Misc/respectHierarchy.int delete mode 100644 OldStuff/GuiManager/Misc/round.int delete mode 100644 OldStuff/GuiManager/Misc/setBG.int delete mode 100644 OldStuff/GuiManager/Misc/setColor.int delete mode 100644 OldStuff/GuiManager/Misc/setMouseXY.int delete mode 100644 OldStuff/GuiManager/Misc/setParent.int delete mode 100644 OldStuff/GuiManager/Misc/setVisibility.int delete mode 100644 OldStuff/GuiManager/Text/fitFont.int delete mode 100644 OldStuff/GuiManager/Text/newTextBase.int delete mode 100644 OldStuff/GuiManager/Text/newTextBox.int delete mode 100644 OldStuff/GuiManager/Text/newTextButton.int delete mode 100644 OldStuff/GuiManager/Text/newTextLabel.int delete mode 100644 OldStuff/GuiManager/Text/setDefualtFont.int delete mode 100644 OldStuff/GuiManager/Text/setNewFont.int delete mode 100644 OldStuff/GuiManager/Text/setgetText.int delete mode 100644 OldStuff/GuiManager/Text/widthToTextSize.int delete mode 100644 OldStuff/GuiManager/init.lua delete mode 100644 OldStuff/Utils.lua delete mode 100644 OldStuff/bin.lua delete mode 100644 OldStuff/merger.lua rename {gui/addons => addons}/functions.lua (100%) rename {gui/addons => addons}/system.lua (100%) rename {gui/core => core}/color.lua (100%) rename {gui/core => core}/theme.lua (100%) rename gui/init.lua => init.lua (99%) delete mode 160000 multi delete mode 100644 test.lua diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index eba1110..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8f841e9..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -main.lua -conf.lua -*.ttf -*.png -*.ogv -*deck \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5de64e1..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "multi"] - path = multi - url = https://github.com/rayaman/multi diff --git a/OldStuff/GuiManager.lua b/OldStuff/GuiManager.lua deleted file mode 100644 index 4b1ab1e..0000000 --- a/OldStuff/GuiManager.lua +++ /dev/null @@ -1,4115 +0,0 @@ -utf8 = require("utf8") -gui = {} -gui.__index = gui -gui.TB={} -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.getInfo(file..add) then - a,b=pcall(love.filesystem.load(file..add)) - if a then - --print("Loaded: "..file) - else - print("Error loading file: "..file) - print(a,b) - end - else - print("File does not exist!") - return false - end -end -function gui.LoadAll(dir) - files=love.filesystem.getDirectoryItems(dir) - for i=1,#files do - if string.sub(files[i],-4)==".int" then - gui:LoadInterface(dir.."/"..files[i]) - end - end -end - -function gui:Clickable() - local x,y,w,h=love.graphics.getScissor() - local mx=love.mouse.getX() - local my=love.mouse.getY() - if _GuiPro.HasStencel then - local obj=_GuiPro.StencelHolder - if self:isDescendant(obj) then - return math.sqrt((mx-obj.x)^2+(my-obj.y)^2)<=(obj.offset.size.x or 0) - end - end - if not(x) then - return true - end - return not(mx>x+w or mxy+h or myx+w or mxy+h or my self.x and x < self.x+self.width and y > self.y and y < self.y+self.height and self:TClickable(x,y) and self:eventable()) - end - end - self.id=-1 -end -multi:newTask(function() -- A bit of post-loading haha - gui.touchpressed=multi:newConnection() - gui.touchreleased=multi:newConnection() - gui.touchmoved=multi:newConnection() - love.touchpressed=Library.convert(love.touchpressed or function() end) - love.touchreleased=Library.convert(love.touchreleased or function() end) - love.touchmoved=Library.convert(love.touchmoved or function() end) - love.touchpressed:inject(function(id, x, y, dx, dy, pressure) gui.touchpressed:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - love.touchreleased:inject(function(id, x, y, dx, dy, pressure) gui.touchreleased:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - love.touchmoved:inject(function(id, x, y, dx, dy, pressure) gui.touchmoved:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - _GuiPro.TouchReady=true - _GuiPro.TouchRegister={} - gui.touchpressed:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if #v.tid==0 then - if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - v:addTID(id) - v.touchcount=1 - for i=1,#v.ToFuncP do - v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - elseif not(v:hasTID(id)) then - if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - v:addTID(id) - v.touchcount=v.touchcount+1 - for i=1,#v.ToFuncP do - v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end - end) - gui.touchreleased:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if v:hasTID(id) then - v:removeTID(id) - for i=1,#v.ToFuncR do - v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end) - gui.touchmoved:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if v:hasTID(id) and (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - for i=1,#v.ToFuncM do - v.ToFuncM[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - elseif v:hasTID(id) and not((x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable())) then - v:removeTID(id) - for i=1,#v.ToFuncR do - v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end) -end) --- now that that is done lets set up some more post loading checks -_GuiPro.int=multi:newProcess() -_GuiPro.int:Start() -_GuiPro.int:setJobSpeed(.001) -_GuiPro.EXACT=0 -_GuiPro.LAX=.01 -_GuiPro.LAZY=.05 --- now lets define the reg function -function gui.Compare(a,b,v,tp) - if tp==">" then - if (a+v>b or a-v>b) then - return true - end - elseif tp=="<" then - if (a+v=" then - if (a+v>=b or a-v>=b) then - return true - end - elseif tp=="==" then -- this one is gonna be tricky - if (a>=b-v and a<=b+v) or (b>=a-v and b<=a+v) then - return true - end - end - return false -end -function gui:regesterTouch() - local obj=self - obj.ToFuncP={} - obj.ToFuncM={} - obj.ToFuncR={} - obj.To2Func={} - obj.ToDTFunc={} - obj.touchRendering =_GuiPro.EXACT -- exact(0), lax(), # - function obj:removeTID(id) - for i=1,#self.tid do - if self.tid[i]==id then - table.remove(self.tid,i) - self.touchcount=self.touchcount-1 - return - end - end - end - function obj:hasTID(id) - for i=1,#self.tid do - if self.tid[i]==id then - return true - end - end - return false - end - obj.txl1=0 - obj.tyl1=0 - obj.txl2=0 - obj.tyl2=0 - obj.LS=0 - obj:OnUpdate(function(self) - if self.touchcount==2 then - local x1,y1=love.touch.getPosition( self.tid[1] ) - local x2,y2=love.touch.getPosition( self.tid[2] ) - local CS=math.sqrt((x2-x1)^2+(y2-y1)^2) - if gui.Compare(CS,self.LS,self.touchRendering,">") then - for i=1,#self.To2Func do - self.To2Func[i](self,CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - elseif gui.Compare(CS,self.LS,self.touchRendering,"<") then - for i=1,#self.To2Func do - self.To2Func[i](self,-CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - elseif gui.Compare(CS,self.LS,self.touchRendering,"==") then - for i=1,#self.To2Func do - self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - end - -- if self.txl1~=x1 or self.txl2~=x2 or self.tyl1~=y1 or self.tyl2~=y2 then - -- for i=1,#self.To2Func do - -- self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - -- end - -- end - self.LS=CS - self.txl1=x1 - self.txl2=x2 - self.tyl1=y1 - self.tyl2=y2 - end - end) - function obj:OnDoubleTap(func) - table.insert(self.ToDTFunc,func) - end - function obj:On2TouchMoved(func) - table.insert(self.To2Func,func) - end - function obj:addTID(id) - table.insert(self.tid,id) - end - function obj:OnTouchPressed(func) - table.insert(self.ToFuncP,func) -- event for touches - end - function obj:OnTouchReleased(func) -- event for touches - table.insert(self.ToFuncR,func) - end - function obj:OnTouchMoved(func) -- event for touches - table.insert(self.ToFuncM,func) - end - if _GuiPro.TouchReady then -- my sneaky test - print("Registred: "..tostring(obj)) - table.insert(_GuiPro.TouchRegister,obj) - else - print("Attempting to register: "..tostring(obj)) - _GuiPro.int:newJob(function() table.insert(_GuiPro.TouchRegister,obj) end) -- a sneaky way to ensure that your object gets registered eventually, even if you call the method before the touch patch was activated. - end -end - -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 -function GetAllChildren(Object) - local Stuff = {} - function Seek(Items) - for i=1,#Items do - if Items[i].Visible==true then - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - end - local Objs = Object:getChildren() - for i=1,#Objs do - if Objs[i].Visible==true then - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - end - return Stuff -end -function GetAllChildren2(Object) - local Stuff = {} - function Seek(Items) - for i=1,#Items do - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - local Objs = Object:getChildren() - for i=1,#Objs do - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - return Stuff -end -function gui:getTile(i,x,y,w,h)-- returns imagedata - if type(i)=="string" then - i=love.graphics.newImage(i) - elseif type(i)=="userdata" then - -- do nothing - elseif string.find(self.Type,"Image",1,true) then - local i,x,y,w,h=self.Image,i,x,y,w - else - error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)") - end - local iw,ih=i:getDimensions() - local id,_id=i:getData(),love.image.newImageData(w,h) - for _x=x,w+x-1 do - for _y=y,h+y-1 do - -- - _id:setPixel(_x-x,_y-y,id:getPixel(_x,_y)) - end - end - return love.graphics.newImage(_id) -end -function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh) - local x,y,w,h,sx,sy,sw,sh=filter(file, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh) - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files={} - c.AnimStart={} - c.AnimEnd={} - local _files=alphanumsort(love.filesystem.getDirectoryItems(file)) - for i=1,#_files do - if string.sub(_files[i],-1,-1)~="b" then - table.insert(c.files,love.graphics.newImage(file.."/".._files[i])) - end - end - c.step=multi:newTStep(1,#c.files,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(pos,step) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end -function gui:newAnimFromData(data,delay, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageAnimation","FromFile", x, y, w, h, sx ,sy ,sw ,sh) - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files=data - c.AnimStart={} - c.AnimEnd={} - c:SetImage(c.files[1]) - c.step=multi:newTStep(1,#c.files,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(pos,step) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end -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 _x,_y=im:getDimensions() - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files={} - c.AnimStart={} - c.AnimEnd={} - for i=0,_y/yd-1 do - for j=0,_x/xd-1 do - table.insert(c.files,gui:getTile(im,j*xd,i*yd,xd,yd)) - end - end - c:SetImage(c.files[1]) - c.step=multi:newTStep(1,#c.files,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(pos,step) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end -function gui:newFullImageLabel(i,name) - return self:newImageLabel(i,name,0,0,0,0,0,0,1,1) -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" or type(i):find("ImageData") 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.ImageHeight=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - end - c:OnEnter(function() - love.mouse.setCursor(_GuiPro.CursorH) - end) - c:OnExit(function() - 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" or type(i):find("ImageData") then - c.Image=love.graphics.newImage(i) - else - c.Image=i - end - c.Visibility=0 - c.ImageVisibility=1 - c.rotation=0 - 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) - end - return c -end -function gui:newVideo(name,i,x,y,w,h,sx,sy,sw,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("Video",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then - c.Video=love.graphics.newVideo(i) - else - c.Video=i - end - c.Visibility=0 - c.VideoVisibility=1 - c.rotation=0 - if c.Video~=nil then - c.VideoHeigth=c.Video:getHeight() - c.VideoWidth=c.Video:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.VideoWidth,c.VideoHeigth) - end - c.funcV={} - function c:Play() - self.handStart=true - self.Video:play() - end - function c:Pause() - self.Video:pause() - end - c.Resume=c.Play - function c:Stop() - self.handStart=false - self:Pause() - self:Rewind() - for i=1,# self.funcV do - self.funcV[i](self) - end - end - function c:OnVideoStopped(func) - table.insert(self.funcV,func) - end - function c:Rewind() - self.Video:rewind() - end - function c:Restart() - self:Rewind() - self:Play() - end - function c:Seek(o) - self.Video:seek(o) - end - function c:Tell() - self.Video:tell() - end - function c:SetFilter(min, mag, anisotropy) - self.Video:setFilter(min, mag, anisotropy) - end - function c:IsPlaying() - return self.Video:isPlaying() - end - c:OnUpdate(function(self) - if self.Video:isPlaying()==false and self.handStart == true then - self:Stop() - end - end) - return c -end -function gui:SetImage(i) - if type(i)=="string" or tostring(i):find("ImageData") then - self.Image=love.graphics.newImage(i) - else - self.Image=i - end - 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) - end - return self.ImageWidth,self.ImageHeigth -end -function gui:UpdateImage() - self.ImageHeigth=self.Image:getHeight() - self.ImageWidth=self.Image:getWidth() - self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) -end -function gui:newDropFrame(name,x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("DropFrame",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=false - c.funcD={} - function c:GetDroppedItems() - local t=self:getChildren() - local tab={} - for i=1,#t do - if t[i].Type=="TextImageButtonFrameDrag" then - table.insert(tab,t[i]) - end - end - return tab - end - function c:OnDropped(func) - table.insert(self.funcD,func) - end - c:OnUpdate(function(self) - if _GuiPro.DragItem then - if _GuiPro.DragItem.Type=="TextImageButtonFrameDrag" and love.mouse.isDown(_GuiPro.DragItem.dragbut or "m")==false and self:IsHovering() then - local t=_GuiPro.DragItem - _GuiPro.DragItem={} - for i=1,#t.funcD do - t.funcD[i](self,t) - end - for i=1,#self.funcD do - self.funcD[i](self,t) - end - _GuiPro.hasDrag=false - end - end - end) - return c -end -function gui:newFrame(name,x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("Frame",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=false - return c -end -function gui:newFullFrame(name) - name=name or "" - return self:newFrame(name,0,0,0,0,0,0,1,1) -end - -function gui:newTabFrame(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=gui:newFrame(name, x, y, w, h, sx ,sy ,sw ,sh) - c.tabheight=20 - c.Holder=c:newFrame("Holder",0,c.tabheight,0,0,0,0,1,1) - c.TabHolder=c:newFrame("TabHolder",0,0,0,c.tabheight,0,0,1) - function c:setTabHeight(n) - self.tabheight=n - self.Holder:SetDualDim(0,-self.tabheight,0,0,0,0,1,1) - end - function c:addTab(name,colorT,colorH) - if colorT and not(colorH) then - colorH=colorT - end - local tab=self.TabHolder:newTextButton(name,name,0,0,0,0,0,0,0,1) - tab.Tween=-3 - if colorT then - tab.Color=colorT - end - local holder=self.Holder:newFrame(name,0,0,0,0,0,0,1,1) - if colorH then - holder.Color=colorH - end - tab.frame=holder - tab:OnReleased(function(b,self) - if b=="l" then - local tt=self.Parent:getChildren() - local th=self.Parent.Parent.Holder:getChildren() - for i=1,#th do - th[i].Visible=false - end - for i=1,#tt do - tt[i].frame.Visible=false - tt[i].BorderSize=1 - end - self.BorderSize=0 - self.frame.Visible=true - end - end) - local tt=self.TabHolder:getChildren() - for i=1,#tt do - tt[i].frame.Visible=false - tt[i].BorderSize=1 - end - tab.frame.Visible=true - tab.BorderSize=0 - return tab,holder - end - c:OnUpdate(function(self) - local th=self.TabHolder:getChildren() - local l=self.width/#th - for i=1,#th do - th[i]:SetDualDim(l*(i-1),0,l) - end - if #th==0 then - self:Destroy() - end - end) - return c -end -function gui:newDragItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("TextImageButtonFrameDrag",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=true - c.funcD={} - if type(i)=="string" then - c.Image=love.graphics.newImage(i) - c.ImageVisibility=1 - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - elseif type(i)=="image" then - c.Image=i - c.ImageVisibility=1 - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - end - c:OnDragStart(function(self,x,y) - if _GuiPro.hasDrag==false then - self:setParent(_GuiPro) - self:SetDualDim(x,y) - self:TopStack() - end - end) - c.rotation=0 - c.Tween=0 - c.XTween=0 - c.text = t - c.AutoScaleText=false - c.FontHeight=_defaultfont:getHeight() - c.Font=_defaultfont - c.FontSize=15 - c.TextFormat="center" - c.TextVisibility=1 - c.TextColor = {0, 0, 0} - function c:OnDropped(func) - table.insert(self.funcD,func) - end - c:OnUpdate(function(self) - if love.mouse.isDown("m" or self.dragbut)==false and self==_GuiPro.DragItem and self.hovering==false then - _GuiPro.DragItem={} - for i=1,#self.func7 do - self.func7[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2) - end - end - end) - return c -end -function gui:newItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("TextImageButtonFrame",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then - c.Image=love.graphics.newImage(i) - else - c.Image=i - end - c.rotation=0 - c.ImageVisibility=1 - c.Draggable=false - if c.Image~=nil then - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - end - c.Tween=0 - c.XTween=0 - c.text = t - c.AutoScaleText=false - c.FontHeight=_defaultfont:getHeight() - c.Font=_defaultfont - c.FontSize=15 - c.TextFormat="center" - c.TextVisibility=1 -- 0=invisible,1=solid (self.TextVisibility*254+1) - c.TextColor = {0, 0, 0} - return c -end -function gui:addDominance() - _GuiPro.TopHovered=self -end -function gui:addHotKey(key) - local temp=self:newFrame(0,0,0,0) - temp.Visible=false - temp:setHotKey(key) - return temp -end -function gui:AdvTextBox(txt,x,y,w,h,sx,sy,sw,sh) - name="AdvTextBox" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("AdvTextBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c.BorderSize=0 - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - --local temp = c:newTextButton("X","Close",-25,5,20,20,1) - --temp.Tween=-5 - --temp.XTween=-2 - --temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - --temp.Color=Color.Red - c.tLink=c:newTextBox("puttext","TextBox",5,h-95,-40,30,0,1,1,1) - c.tLink.Color=Color.light_gray - c.tLink.ClearOnFocus=true - c.tLink:OnFocus(function(self) self.ClearOnFocus=false end) - local temp=c:newTextButton("OK","Ok",-35,h-65,30,30,1,1) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent,self.Parent.tLink.text) end end) - temp.Color=Color.Green - temp.XTween=-2 - local temp=c:newTextButton("X","Cancel",-35,h-95,30,30,1,1) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent,self.Parent.tLink.text) end end) - temp.Color=Color.Red - temp.XTween=-2 - function c:Close() - self.Visible=false - end - function c:Open() - self.Visible=true - end - function c:OnOk(func) - table.insert(self.funcO,func) - end - function c:OnX(func) - table.insert(self.funcX,func) - end - return c -end -function alphanumsort(o) - local function padnum(d) local dec, n = string.match(d, "(%.?)0*(.+)") - return #dec > 0 and ("%.12f"):format(d) or ("%s%03d%s"):format(dec, #n, n) - end - table.sort(o, function(a,b) return tostring(a):gsub("%.?%d+",padnum)..("%3d"):format(#b)< tostring(b):gsub("%.?%d+",padnum)..("%3d"):format(#a) end) - return o -end -function gui:anchorRight(n) - self:SetDualDim(-(self.width+n),nil,nil,nil,1) -end -function _GuiPro.gradient(colors) - local direction = colors.direction or "horizontal" - colors.direction=nil - trans = colors.trans or 1 - trans=math.floor(trans) - if direction == "horizontal" then - direction = true - elseif direction == "vertical" then - direction = false - else - error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.") - end - local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1,"rgba32f") - for __i, color in ipairs(colors) do - local x, y - if direction then - x, y = 0, __i - 1 - else - x, y = __i - 1, 0 - end - result:setPixel(x, y, color[1], color[2], color[3], trans) - end - result = love.graphics.newImage(result) - result:setFilter('linear', 'linear') - return result -end -function _GuiPro.drawinrect(img, x, y, w, h, r, ox, oy, kx, ky) - love.graphics.draw(img, x, y, r, w / img:getWidth(), h / img:getHeight(), ox, oy, kx, ky) -end -function gui:ApplyGradient(rules) - self.Image=nil - self.Type=self.Type.."w/GradImage" - self.rotation=0 - self.ImageVisibility=rules.visibility or 1 - self:SetImage(_GuiPro.gradient(rules)) -end -function gui:BottomStack() - childs=self.Parent:getChildren() - for i=1,#childs do - if childs[i]==self then - table.remove(self.Parent.Children,i) - table.insert(self.Parent.Children,1,self) - break - end - end -end -function gui:center() - self:centerX() - self:centerY() -end -function gui:centerX() - self:SetDualDim(-(self.width/2),nil,nil,nil,.5) -end -function gui:centerY() - self:SetDualDim(nil,-(self.height/2),nil,nil,nil,.5) -end -function gui:Destroy() - check=self.Parent:getChildren() - local cc=0 - for cc=1,#check do - if check[cc]==self then - table.remove(self.Parent.Children,cc) - end - end - self.Destroyed = true -end -function gui:disrespectHierarchy() - _GuiPro.Hierarchy=false -end -function gui:GetAllChildren() - local Stuff = {} - function Seek(Items) - for i=1,#Items do - if Items[i].Visible==true then - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - end - local Objs = self:getChildren() - for i=1,#Objs do - if Objs[i].Visible==true then - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - end - return Stuff -end -function gui:GetChild(name) - return self.Children[name] or self -end -function gui:getChildren() - return self.Children -end -function gui:getColor(cindex) - return Color[cindex] -end -function gui:getFullSize() - local maxx,maxy=-math.huge,-math.huge - local temp = self:GetAllChildren() - for i=1,#temp do - if temp[i].width+temp[i].offset.pos.x>maxx then - maxx=temp[i].width+temp[i].offset.pos.x - elseif temp[i].height+temp[i].offset.pos.y>maxy then - maxy=temp[i].height+temp[i].offset.pos.y - end - end - return maxx,maxy -end -function gui:getHighest() - if self.Children[#self.Children]~=nil then - return self.Children[#self.Children] - end -end -function gui:getLowest() - if self.Children[1]~=nil then - return self.Children[1] - end -end -function InGrid(i,x,y,s) - return math.floor((i-1)/x)*s,(i-1)*s-(math.floor((i-1)/y)*(s*x)) -end -function InGridX(i,w,h,xs,ys) - local xc,yc=math.floor(w/xs),math.floor(h/ys) - local xi,yi=(i-1)%xc,math.floor((i-1)/xc) - return xi*xs,yi*ys -end -function InGridY(i,w,h,xs,ys) - local xc,yc=math.floor(w/xs),math.floor(h/ys) - local xi,yi=math.floor((i-1)/yc),(i-1)%yc - return xi*xs,yi*ys -end -function gui:isDescendant(obj) - local things=obj:GetAllChildren() - for i=1,#things do - if things[i]==self then - return true - end - end - return false -end -function gui:isHighest() - return (self==self.Parent:getHighest()) -end -function gui:IsHovering() - return (love.mouse.getX() > self.x and love.mouse.getX() < self.x+self.width and love.mouse.getY() > self.y and love.mouse.getY() < self.y+self.height) -end -function gui:isLowest() - return (self==self.Parent:getLowest()) -end -function gui.massMutate(t,...) - local mut={...} - for i=1,#mut do - mut[i]:Mutate(t) - end -end -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.getInfo("CheckBoxes.png") then - _GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16) - _GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16) - _GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16) - _GuiPro.CH=gui:getTile("CheckBoxes.png",16,16,16,16) -end -function gui:newCheckBox(name,x,y) - if not(_GuiPro.UC) then error("CheckBoxes.png not found! Cannot currently use checkbox without the data") end - if type(name)~="String" then - x,y,name=name,x,"CheckBox" - end - local c=self:newImageLabel(_GuiPro.UC,name, x, y, 16,16) - c.Visibility=0 - c.check=false - c:OnEnter(function(self) - if self.check then - self:SetImage(_GuiPro.CH) - else - self:SetImage(_GuiPro.UCH) - end - end) - function c:isChecked() - return self.check - end - c:OnExit(function(self) - if self.check then - self:SetImage(_GuiPro.C) - else - self:SetImage(_GuiPro.UC) - end - end) - c:OnReleased(function(b,self) - self.check=not(self.check) - if self.check then - self:SetImage(_GuiPro.CH) - else - self:SetImage(_GuiPro.UCH) - end - end) - return c -end -function gui:newMessageBox(txt,x,y,w,h,sx,sy,sw,sh) - name="MessageBox" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("MessageBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c.BorderSize=0 - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - local temp = c:newTextButton("X","Close",-25,5,20,20,1) - temp.Tween=-5 - temp.XTween=-2 - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - temp.Color=Color.Red - local temp=c:newTextButton("OK","Ok",0,h-65,0,30,.25,1,.5) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent) end end) - temp.Color=Color.Green - function c:Close() - self.Visible=false - end - function c:Open() - self.Visible=true - end - function c:OnOk(func) - table.insert(self.funcO,func) - end - function c:OnX(func) - table.insert(self.funcX,func) - end - return c -end -function gui:newPart(x, y,w ,h , sx ,sy ,sw ,sh) - local c = {} - setmetatable(c, gui) - if self==gui then - c.Parent=_GuiPro - else - c.Parent=self - end - c.funcs={} - c.funcs2={} - c.funcs3={} - c.funcs4={} - c.funcs5={} - c.func6={} - c.func7={} - c.func8={} - c.func9={} - c.func10={} - c.form="rectangle" - c.Color = {255, 255, 255} - c.scale={} - c.scale.size={} - c.scale.size.x=sw or 0 - c.scale.size.y=sh or 0 - c.offset={} - c.offset.size={} - c.offset.size.x=w or 0 - c.offset.size.y=h or 0 - c.scale.pos={} - c.scale.pos.x=sx or 0 - c.scale.pos.y=sy or 0 - c.offset.pos={} - c.offset.pos.x=x or 0 - c.offset.pos.y=y or 0 - c.VIS=true - c.Visible=true - c.Visibility=1 - c.BorderColor={0,0,0} - c.BorderSize=0 - c.Type="Part" - c.Name="GuiPart" - _GuiPro.count=_GuiPro.count+1 - c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x - c.y=(c.Parent.height*c.scale.pos.y)+c.offset.pos.y+c.Parent.y - c.width=(c.Parent.width*c.scale.size.x)+c.offset.size.x - c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y - table.insert(c.Parent.Children,c) - return c -end -function gui:newProgressBar(txt,x,y,w,h,sx,sy,sw,sh) - name="newProgressBar" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("newProgressBarFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c.BorderSize=0 - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - local temp = c:newTextButton("X","Close",-25,5,20,20,1) - temp.Tween=-5 - temp.XTween=-2 - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - temp.Color=Color.Red - c.BarBG=c:newTextButton("",5,h-65,-10,30,0,1,1) - c.BarBG:ApplyGradient{Color.Red,Color.light_red} - c.Bar=c.BarBG:newTextLabel("",0,0,0,0,0,0,0,1) - c.Bar:ApplyGradient{Color.Green,Color.light_green} - c.BarDisp=c.BarBG:newTextLabel("0%","0%",0,0,0,0,0,0,1,1) - c.BarDisp.Visibility=0 - c.BarDisp.Link=c.Bar - c.BarDisp:OnUpdate(function(self) - self.text=self.Link.scale.size.x*100 .."%" - end) - c.Func1={} - function c:On100(func) - table.insert(self.Func1,func) - end - c:OnUpdate(function(self) - if self.Bar.scale.size.x*100>=100 then - for P=1,#self.Func1 do - self.Func1[P](self) - end - end - end) - function c:SetPercentage(n) - self.Bar:SetDualDim(0,0,0,0,0,0,n/100,1) - end - return c -end -function gui:newScrollBar(color1,color2) - local scrollbar=self:newFrame(-20,0,20,0,1,0,0,1) - scrollbar.funcS={} - scrollbar.Color=color1 or Color.saddle_brown - scrollbar:OnClicked(function(b,self,x,y) - love.mouse.setX(self.x+10) - if y>=10 and y<=self.height-10 then - self.mover:SetDualDim(0,y-10) - end - if y<10 then - love.mouse.setY(10+self.y) - end - if y>self.height-10 then - love.mouse.setY((self.height-10)+self.y) - end - for i=1,#self.funcS do - self.funcS[i](self,self:getPosition()) - end - end) - scrollbar:OnEnter(function(self) - self:addDominance() - end) - scrollbar:OnExit(function(self) - self:removeDominance() - end) - scrollbar.mover=scrollbar:newTextButton("","",0,0,20,20) - scrollbar.mover.Color=color2 or Color.light_brown - function scrollbar:getPosition() - return ((self.mover.offset.pos.y)/(self.height-20))*100 - end - function scrollbar:setPosition(n) - print((self.height-20),n) - self.mover.offset.pos.y=((self.height-20)/(100/n)) - for i=1,#self.funcS do - self.funcS[i](self,self:getPosition()) - end - end - function scrollbar:OnScroll(func) - table.insert(self.funcS,func) - end - return scrollbar -end -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 -function gui:destroyAllChildren() - local c=self.Children - for i=1,#c do - c[i]:Destroy() - end -end -function gui:removeDominance() - _GuiPro.TopHovered=nil -end -function gui:respectHierarchy() - _GuiPro.Hierarchy=true -end -function gui.round(num, idp) - local mult = 10^(idp or 0) - return math.floor(num * mult + 0.5) / mult -end -function gui.setBG(i) - gui.ff:SetImage(i) -end -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 -function gui:setDefualtFont(font) - _defaultfont = font -end -function gui:SetDualDim(x, y, w, h, sx ,sy ,sw ,sh) - if _GuiPro.DPI_ENABLED then - if x then - x=self.DPI*x - end - if y then - y=self.DPI*y - end - if w then - w=self.DPI*w - end - if h then - h=self.DPI*h - end - end - if sx then - self.scale.pos.x=sx - end - if sy then - self.scale.pos.y=sy - end - if x then - self.offset.pos.x=x - end - if y then - self.offset.pos.y=y - end - if sw then - self.scale.size.x=sw - end - if sh then - self.scale.size.y=sh - end - if w then - self.offset.size.x=w - end - if h then - self.offset.size.y=h - end - if self.Image then - self:SetImage(self.Image) - end -end -function gui:setDualDim(...) - self:SetDualDim(...) -end -function gui:setText(txt) - self.text=txt -end -function gui:getText(txt) - return self.text -end -_GuiPro.CursorN=love.mouse.getSystemCursor("arrow") -_GuiPro.CursorH=love.mouse.getSystemCursor("hand") -function gui:SetHand(img,x,y) - _GuiPro.CursorN=love.mouse.newCursor(img,x,y) -end -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 -function gui:SetHover(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,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() - for i=1,#temp do - if temp[i]==self then - table.remove(self.Parent.Children,i) - break - end - end - table.insert(parent.Children,self) - self.Parent=parent - if name then - self:SetName(name) - end -end -function gui:setVisiblity(val) - self.Visible=val - self.oV=val - doto=self:GetAllChildren() - if val==false then - for i=1,#doto do - doto[i].Visible=val - end - else - for i=1,#doto do - doto[i].Visible=doto[i].oV - end - end -end -function gui:TopStack() - childs=self.Parent:getChildren() - for i=1,#childs do - if childs[i]==self then - table.remove(self.Parent.Children,i) - table.insert(self.Parent.Children,self) - break - end - end -end -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 -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 -function gui:newTextLabel(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("TextLabel",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} - 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) -end -function gui:AddDrawRuleE(rule) - if not(self.DrawRulesE) then self.DrawRulesE={} end - table.insert(self.DrawRulesE,rule) -end -function gui:draw() - if _GuiPro.rotate~=0 then - love.graphics.rotate(math.rad(_GuiPro.rotate)) - end - if self.FormFactor:lower()=="rectangle" then - self:drawR() - elseif self.FormFactor:lower()=="circle" then - self:drawC() - else - error("Unsupported FormFactor: "..self.FormFactor.."!") - end -end -function gui:drawC() - if love.mouse.isDown("l")==false and love.mouse.isDown("m")==false and love.mouse.isDown("r")==false then - _GuiPro.DragItem={} - _GuiPro.hasDrag=false - end - if self.Visible==true and self.VIS==true then - local b=true - for i,v in pairs(_GuiPro.Clips) do - if self:isDescendant(v)==true then - b=false - end - end - if b then - love.graphics.setStencilTest( ) - _GuiPro.HasStencel=false - _GuiPro.StencelHolder=nil - end - local x,y,r,s=(self.offset.pos.x or 0)+self.Parent.x,(self.offset.pos.y or 0)+self.Parent.y,self.offset.size.x or 0,self.offset.size.y or 360 - if self.CC then - x,y=x+r,y+r - end - self.x,self.y=x,y - _GuiPro.circleStencilFunction = function() - love.graphics.circle("fill",x,y,r,s) - end - if math.sqrt((love.mouse.getX()-x)^2+(love.mouse.getY()-y)^2)<=r and self:eventable() and self:Clickable() and self.Active==true then - self.hovering=true - if love.mouse.isDown("l") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.lclicked=true - elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.rclicked=true - elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.mclicked=true - else - if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - self.hovering=false - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - if self.ClipDescendants==true then - _GuiPro.Clips[tostring(self)]=self - _GuiPro.HasStencel=true - _GuiPro.StencelHolder=self - love.graphics.stencil(_GuiPro.circleStencilFunction) - love.graphics.setStencilTest("notequal",0) - end - love.graphics.circle("fill",x,y,r,s) - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility) - for b=0,self.BorderSize-1 do - love.graphics.circle("line",x,y,r+b,s) - end - if string.find(self.Type, "Text") then - if self.text~=nil then - if self.AutoScaleText then - self.FontSize=math.floor(self.height/1.45833) - end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) - love.graphics.setFont(self.Font) - love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat) - end - end - end -end -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) - else - 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) - else - 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) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.mclicked=true - else - if string.find(self.Type, "Button") 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) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - self.hovering=false - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - if self.ClipDescendants==true then - _GuiPro.Clips[tostring(self)]=self - 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) - 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) - if self.Font==_defaultfont then - love.graphics.setFont(self.Font) - 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) - 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) 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 - if self.DrawRulesE then - for dr=1,#self.DrawRulesE do - self.DrawRulesE[dr](self) - end - end - end -end - -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:newFrame("",0,0,0,0,0,0,1,1) -gui.ff.Color={255,255,255} -gui.ff:OnUpdate(function(self) - self:BottomStack() -end) - - diff --git a/OldStuff/GuiManager/Core/EventDefinitions.int b/OldStuff/GuiManager/Core/EventDefinitions.int deleted file mode 100644 index 5668e97..0000000 --- a/OldStuff/GuiManager/Core/EventDefinitions.int +++ /dev/null @@ -1,200 +0,0 @@ -local buttonConv = {"l","r","m","x1","x2"} -- For the old stuff -function gui:OnClicked(func) - if not self.clickEvnt then - self.clickEvnt = true - self._connClicked = multi:newConnection() - self._connClicked(func) - multi:newThread(self.Name.."_Updater",function() - while true do - thread.hold(function() return self.Active or self.Destroyed end) - if love.mouse.isDown(1) and self:canPress() then - self._connClicked:Fire("1",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y) - end - if love.mouse.isDown(2) and self:canPress() then - self._connClicked:Fire("r",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y) - end - if love.mouse.isDown(3) and self:canPress() then - self._connClicked:Fire("m",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y) - end - if love.mouse.isDown(4) and self:canPress() then - self._connClicked:Fire("x1",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y) - end - if love.mouse.isDown(5) and self:canPress() then - self._connClicked:Fire("x2",self,love.mouse.getX()-self.x,love.mouse.getY()-self.y) - end - if self.Destroyed then - thread.kill() - end - end - end) - else - self._connClicked(func) - end -end -function gui:OnPressed(func) - multi.OnMousePressed(function(x,y,b) - if self:canPress() then - func(buttonConv[b],self,x,y) - end - end) -end -function gui:OnPressedOuter(func) - multi.OnMousePressed(function(x,y,b) - if not(self:canPress()) then - func(buttonConv[b],self) - end - end,nil,1) -end -function gui:OnReleased(func) - multi.OnMouseReleased(function(x,y,b) - if self:canPress() then - func(buttonConv[b],self,x,y) - end - end) -end -function gui:OnReleasedOuter(func) - multi.OnMouseReleased(function(x,y,b) - if not(self:canPress()) then - func(buttonConv[b],self) - end - end,nil,1) -end -function gui:OnUpdate(func) - if not self.updateEvnt then - self._connUpdate = multi:newConnection() - self._connUpdate(func) - self.updateEvnt = true - multi:newThread(self.Name.."_Updater",function() - while true do - thread.hold(function() return self.Active end) - self._connUpdate:Fire(self) - end - end) - else - self._connUpdate(func) - end -end -function gui:OnMouseMoved(func) - multi.OnMouseMoved(function(x,y,dx,dy) - if self:canPress() then - func(self,x-self.x,y-self.y,dx,dy) - end - end,nil,1) -end -gui.WhileHovering=gui.OnMouseMoved -- To keep older features working -local mbenter = multi:newConnection() -function gui:OnMouseEnter(func) - self.HE=false - mbenter(func) - self:OnMouseMoved(function() - if self.HE == false then - self.HE=true - self._HE = true - mbenter:Fire(self) - end - end) -end -function gui:OnMouseExit(func) - if not self.exitEvnt then - self._connExit = multi:newConnection() - self._connExit(func) - self.exitEvnt = true - self.HE=false - multi:newThread(self.Name.."_OnExit",function() - while true do - thread.hold(function() return self.HE or self.Destroyed end) - if not(self:canPress()) then - self.HE=false - self._connExit:Fire(self) - end - if self.Destroyed then - thread.kill() - end - end - end) - else - self._connExit(func) - end -end ---[[ -x=(love.mouse.getX()-self.x) -y=(love.mouse.getY()-self.y) -self:Move(x,y) -]] -function gui:OnMouseWheelMoved(func) - multi.OnMouseWheelMoved(function(...) - if self:canPress() then - func(self,...) - end - end) -end -function gui:enableDragging(bool) - self.draggable = bool - if self.dragEvnt then - return - end - self.dragEvnt = true - self._connDragStart = multi:newConnection() - self._connDragging = multi:newConnection() - self._connDragEnd = multi:newConnection() - self.hasDrag = false - local startX - local startY - self:OnPressed(function(b,self,x,y) - if b~=self.dragbut or not(self.draggable) then return end - self._connDragStart:Fire(self) - self.hasDrag = true - startX = x - startY = y - end) - multi.OnMouseMoved(function(x,y,dx,dy) - if self.hasDrag and self.draggable then - self:Move(dx,dy) - self._connDragging:Fire(self) - end - end) - multi.OnMouseReleased(function(x,y,b) - if buttonConv[b]~=self.dragbut or not(self.draggable) or not(self.hasDrag) then return end - self.hasDrag = false - startX = nil - startY = nil - self._connDragEnd:Fire(self) - end) -end -function gui:OnDragStart(func) - if not self.dragEvnt then - self:enableDragging(true) - self._connDragStart(func) - else - self._connDragStart(func) - end -end -function gui:OnDragging(func) - if not self.dragEvnt then - self:enableDragging(true) - self._connDragging(func) - else - self._connDragging(func) - end -end -function gui:OnDragEnd(func) - if not self.dragEvnt then - self:enableDragging(true) - self._connDragEnd(func) - else - self._connDragEnd(func) - end -end -function gui:OnHotKey(key,func) - local tab=key:split("+") - multi.OnKeyPressed(function() - for i=1,#tab do - if not(love.keyboard.isDown(tab[i])) then - return - end - end - func(self) - end) -end -gui.addHotKey=gui.OnHotKey -gui.setHotKey=gui.OnHotKey \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/_GetAllChildren.int b/OldStuff/GuiManager/Core/_GetAllChildren.int deleted file mode 100644 index 20e962c..0000000 --- a/OldStuff/GuiManager/Core/_GetAllChildren.int +++ /dev/null @@ -1,25 +0,0 @@ -function GetAllChildren(Object) - local Stuff = {} - function Seek(Items) - for i=1,#Items do - if Items[i].Visible==true then - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - end - local Objs = Object:getChildren() - for i=1,#Objs do - if Objs[i].Visible==true then - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - end - return Stuff -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/_GetAllChildren2.int b/OldStuff/GuiManager/Core/_GetAllChildren2.int deleted file mode 100644 index d68fa1f..0000000 --- a/OldStuff/GuiManager/Core/_GetAllChildren2.int +++ /dev/null @@ -1,21 +0,0 @@ -function GetAllChildren2(Object) - local Stuff = {} - function Seek(Items) - for i=1,#Items do - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - local Objs = Object:getChildren() - for i=1,#Objs do - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - return Stuff -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/canPress.int b/OldStuff/GuiManager/Core/canPress.int deleted file mode 100644 index d3da7be..0000000 --- a/OldStuff/GuiManager/Core/canPress.int +++ /dev/null @@ -1,72 +0,0 @@ -function gui:getParents() - local c,me = {}, self.Parent - while me.Parent~=nil do - c[#c+1]=me - me = me.Parent - end - return c -end -function gui:eventable() - if self.important then - return true - end - if _GuiPro.Hierarchy then - if _GuiPro.TopHovered~=nil then - return self:isDescendant(_GuiPro.TopHovered) or _GuiPro.TopHovered==self - else - return true - end - else - return true - end -end -function gui:parentVisible() - local c = self:getParents() - for i=#c,1,-1 do - if not c[i].Visible then return false end - end - return true -end -function gui:isBeingCovering() - return false - -- if self.allowOverlapping then return false end - -- local ref = self.FrameRef or gui - -- local x,y = love.mouse.getX(),love.mouse.getY() - -- for i = 1,#_GuiPro.Frames do - -- if _GuiPro.Frames[i]~=ref then - -- if (ref.depth or 0)<(_GuiPro.Frames[i].depth or math.huge) then - -- local pos = (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height) and (x > _GuiPro.Frames[i].x and x < _GuiPro.Frames[i].x+_GuiPro.Frames[i].width and y > _GuiPro.Frames[i].y and y < _GuiPro.Frames[i].y+_GuiPro.Frames[i].height) and (x > self.x and x < self.x+self.width and y > self.y and y < self.y+self.height ) - -- if not pos then return true end - -- end - -- end - -- end -end -function gui:Clickable() - local x,y,w,h=love.graphics.getScissor() - local mx=love.mouse.getX() - local my=love.mouse.getY() - if _GuiPro.HasStencel then - local obj=_GuiPro.StencelHolder - if self:isDescendant(obj) then - return math.sqrt((mx-obj.x)^2+(my-obj.y)^2)<=(obj.offset.size.x or 0) - end - end - if not(x) then - return true - end - return not(mx>x+w or mxy+h or my 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 \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/fromString.int b/OldStuff/GuiManager/Core/fromString.int deleted file mode 100644 index e69de29..0000000 diff --git a/OldStuff/GuiManager/Core/full.int b/OldStuff/GuiManager/Core/full.int deleted file mode 100644 index b23738e..0000000 --- a/OldStuff/GuiManager/Core/full.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:full() - self:SetDualDim(nil,nil,nil,nil,nil,nil,1,1) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/newBase.int b/OldStuff/GuiManager/Core/newBase.int deleted file mode 100644 index e16bcc4..0000000 --- a/OldStuff/GuiManager/Core/newBase.int +++ /dev/null @@ -1,167 +0,0 @@ -_GuiPro.Frames = {} -_GuiPro.Type = "Window" -_GuiPro.depth = 0 -function gui.enableAutoWindowScaling(b) - _GuiPro.DPI_ENABLED=b or true - _defaultfont=love.graphics.newFont(12*love.window.getPixelScale()) -end -function filter(name, x, y, w, h, sx ,sy ,sw ,sh) - if type(name)~="string" then - sh=sw - sw=sy - sy=sx - sx=h - h=w - w=y - y=x - x=name - end - return x,y,w,h,sx,sy,sw,sh -end -function gui:getChildren() - return self.Children -end -function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh) - _GuiPro.count=_GuiPro.count+1 - local c = {} - setmetatable(c, gui) - if self==gui then - c.Parent=_GuiPro - else - c.Parent=self - end - if tp:match("Frame") then - _GuiPro.Frames[#_GuiPro.Frames+1] = c - end - if self.Type and self.Type:match("Frame") then - c.FrameRef = self - else - c.FrameRef = self.FrameRef - end - c.segments=nil - c.ry=nil - c.rx=nil - c.DPI=1 - c.isLeaf = true - c.Parent.isLeaf = false - if _GuiPro.DPI_ENABLED then - c.DPI=love.window.getPixelScale() - x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h - end - c.centerFontY=true - c.FormFactor="rectangle" - c.Type=tp - c.Active=true - c.form="rectangle" - c.Draggable=false - c.Name=name or "Gui"..tp - c:SetName(name) - c.BorderSize=1 - c.BorderColor={0,0,0} - c.VIS=true - c.Visible=true - c.oV=true - c.Children={} - c.hovering=false - c.rclicked=false - c.lclicked=false - c.mclicked=false - c.clicked=false - c.Visibility=1 - c.TextWrap=true - c.scale={} - c.scale.size={} - c.scale.size.x=sw or 0 - c.scale.size.y=sh or 0 - c.offset={} - c.offset.size={} - c.offset.size.x=w or 0 - c.offset.size.y=h or 0 - c.scale.pos={} - c.scale.pos.x=sx or 0 - c.scale.pos.y=sy or 0 - c.offset.pos={} - c.offset.pos.x=x or 0 - c.offset.pos.y=y or 0 - c.width = 0 - c.height = 0 - c.LRE=false - c.RRE=false - c.MRE=false - c.Color = {255, 255, 255} - function c:setRoundness(rx,ry,segments) - self.segments=segments - self.ry=ry - self.rx=rx - end - function c.stfunc() - love.graphics.rectangle("fill", c.x, c.y, c.width, c.height,c.rx,c.ry,c.segments) - end - function c:hasRoundness() - return (self.ry or self.rx) - end - c.tid={} - c.touchcount=0 - c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x - c.y=(c.Parent.height*c.scale.pos.y)+c.offset.pos.y+c.Parent.y - c.width=(c.Parent.width*c.scale.size.x)+c.offset.size.x - c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y - function c:ImageRule() - if self.Image then - local sx=self.width/self.ImageWidth - local sy=self.height/self.ImageHeigth - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255) - if self.width~=self.ImageWidth and self.height~=self.ImageHeigth then - love.graphics.draw(self.Image,self.x,self.y,math.rad(self.rotation),sx,sy) - else - love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy) - end - end - end - function c:VideoRule() - if self.Video then - local sx=self.width/self.VideoWidth - local sy=self.height/self.VideoHeigth - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.VideoVisibility*255) - if self.width~=self.VideoWidth and self.height~=self.VideoHeigth then - love.graphics.draw(self.Video,self.x,self.y,math.rad(self.rotation),sx,sy) - else - love.graphics.draw(self.Video,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy) - end - end - end - function c:repeatImage(b,b2) - if b then - self.Image:setWrap(b,b2 or "repeat") - function self:ImageRule() - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255) - love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation)) - end - else - sx=self.width/self.ImageWidth - sy=self.height/self.ImageHeigth - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255) - love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation),sx,sy) - end - end - function c:Mutate(t) - for i,v in pairs(t) do - _GuiPro.self=self - if type(i)=="number" then - loadstring("_GuiPro.self:"..v)() - elseif i:match"__self__" then - local ind=i:match"__self__(.+)" - if not self[ind] then self[ind]={} end - loadstring("_GuiPro.self."..ind.."=_GuiPro.self:"..v)() - elseif i:match"__child__" then - local ind,child = i:match"__child__(%S-)_(.+)" - self[ind][child]=v - else - self[i]=v - end - end - return self - end - table.insert(c.Parent.Children,c) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/patches.int b/OldStuff/GuiManager/Core/patches.int deleted file mode 100644 index 7c8f66a..0000000 --- a/OldStuff/GuiManager/Core/patches.int +++ /dev/null @@ -1,7 +0,0 @@ -_GuiPro.mousedownfunc=love.mouse.isDown -function love.mouse.isDown(b) - if not(b) then - return false - end - return _GuiPro.mousedownfunc(({["l"]=1,["r"]=2,["m"]=3})[b] or b) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/toString.int b/OldStuff/GuiManager/Core/toString.int deleted file mode 100644 index 741685c..0000000 --- a/OldStuff/GuiManager/Core/toString.int +++ /dev/null @@ -1,40 +0,0 @@ -function gui:toString() -- oh boy this is gonna be painful lol - multi:newThread("saving data: ",function() - local dat=bin.stream("test.dat",false) - function GetAllChildren2(Object) - local Stuff = {} - function Seek(Items) - for i=1,#Items do - --table.insert(Stuff,Items[i]) - for a,v in pairs(Items[i]) do - -- dat:tackE(a.."|"..tostring(v)) - print(a.."|"..tostring(v)) - -- dat.workingfile:flush() - end - thread.skip() - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - local Objs = Object:getChildren() - for i=1,#Objs do - -- table.insert(Stuff,Objs[i]) - for a,v in pairs(Objs[i]) do - -- dat:tackE(a.."|"..tostring(v)) - print(Objs[i].Type..":"..a.."|"..tostring(v)) - -- dat.workingfile:flush() - end - thread.skip() - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - -- dat:tofile("test.dat") - return Stuff - end - GetAllChildren2(self) - end) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Core/touchManager.int b/OldStuff/GuiManager/Core/touchManager.int deleted file mode 100644 index 06259c7..0000000 --- a/OldStuff/GuiManager/Core/touchManager.int +++ /dev/null @@ -1,204 +0,0 @@ ---[[WORKING ON -doubleTap - UnFinished! -touchRendering - Broken -]] -function gui:TClickable(mx,my) - local x,y,w,h=love.graphics.getScissor() - if _GuiPro.HasStencel then - local obj=_GuiPro.StencelHolder - if self:isDescendant(obj) then - return math.sqrt((mx-obj.x)^2+(my-obj.y)^2)<=(obj.offset.size.x or 0) - end - end - if not(x) then - return true - end - return not(mx>x+w or mxy+h or my self.x and x < self.x+self.width and y > self.y and y < self.y+self.height and self:TClickable(x,y) and self:eventable()) - end - end - self.id=-1 -end ---multi:newTask(function() -- A bit of post-loading haha - gui.touchpressed=multi:newConnection() - gui.touchreleased=multi:newConnection() - gui.touchmoved=multi:newConnection() - love.touchpressed=Library.convert(love.touchpressed or function() end) - love.touchreleased=Library.convert(love.touchreleased or function() end) - love.touchmoved=Library.convert(love.touchmoved or function() end) - love.touchpressed:inject(function(id, x, y, dx, dy, pressure) gui.touchpressed:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - love.touchreleased:inject(function(id, x, y, dx, dy, pressure) gui.touchreleased:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - love.touchmoved:inject(function(id, x, y, dx, dy, pressure) gui.touchmoved:Fire(id, x, y, dx, dy, pressure) return {id, x, y, dx, dy, pressure} end,1) - _GuiPro.TouchReady=true - _GuiPro.TouchRegister={} - gui.touchpressed:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if #v.tid==0 then - if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - v:addTID(id) - v.touchcount=1 - for i=1,#v.ToFuncP do - v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - elseif not(v:hasTID(id)) then - if (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - v:addTID(id) - v.touchcount=v.touchcount+1 - for i=1,#v.ToFuncP do - v.ToFuncP[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end - end) - gui.touchreleased:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if v:hasTID(id) then - v:removeTID(id) - for i=1,#v.ToFuncR do - v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end) - gui.touchmoved:connect(function(id, x, y, dx, dy, pressure) - for i,v in pairs(_GuiPro.TouchRegister) do - if v:hasTID(id) and (x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable()) then - for i=1,#v.ToFuncM do - v.ToFuncM[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - elseif v:hasTID(id) and not((x > v.x and x < v.x+v.width and y > v.y and y < v.y+v.height and v:TClickable(x,y) and v:eventable())) then - v:removeTID(id) - for i=1,#v.ToFuncR do - v.ToFuncR[i](v,id, x-v.x, y-v.y, dx, dy or 0, pressure or 1) - end - end - end - end) ---end) --- now that that is done lets set up some more post loading checks -_GuiPro.int=multi:newProcessor() -_GuiPro.int:Start() -_GuiPro.int:setJobSpeed(.001) -_GuiPro.EXACT=0 -_GuiPro.LAX=.01 -_GuiPro.LAZY=.05 --- now lets define the reg function -function gui.Compare(a,b,v,tp) - if tp==">" then - if (a+v>b or a-v>b) then - return true - end - elseif tp=="<" then - if (a+v=" then - if (a+v>=b or a-v>=b) then - return true - end - elseif tp=="==" then -- this one is gonna be tricky - if (a>=b-v and a<=b+v) or (b>=a-v and b<=a+v) then - return true - end - end - return false -end -function gui:regesterTouch() - local obj=self - obj.ToFuncP={} - obj.ToFuncM={} - obj.ToFuncR={} - obj.To2Func={} - obj.ToDTFunc={} - obj.touchRendering =_GuiPro.EXACT -- exact(0), lax(), # - function obj:removeTID(id) - for i=1,#self.tid do - if self.tid[i]==id then - table.remove(self.tid,i) - self.touchcount=self.touchcount-1 - return - end - end - end - function obj:hasTID(id) - for i=1,#self.tid do - if self.tid[i]==id then - return true - end - end - return false - end - obj.txl1=0 - obj.tyl1=0 - obj.txl2=0 - obj.tyl2=0 - obj.LS=0 - obj:OnUpdate(function(self) - if self.touchcount==2 then - local x1,y1=love.touch.getPosition( self.tid[1] ) - local x2,y2=love.touch.getPosition( self.tid[2] ) - local CS=math.sqrt((x2-x1)^2+(y2-y1)^2) - if gui.Compare(CS,self.LS,self.touchRendering,">") then - for i=1,#self.To2Func do - self.To2Func[i](self,CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - elseif gui.Compare(CS,self.LS,self.touchRendering,"<") then - for i=1,#self.To2Func do - self.To2Func[i](self,-CS,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - elseif gui.Compare(CS,self.LS,self.touchRendering,"==") then - for i=1,#self.To2Func do - self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - end - end - -- if self.txl1~=x1 or self.txl2~=x2 or self.tyl1~=y1 or self.tyl2~=y2 then - -- for i=1,#self.To2Func do - -- self.To2Func[i](self,0,x1-self.x,y1-self.y,x2-self.x,y2-self.y) - -- end - -- end - self.LS=CS - self.txl1=x1 - self.txl2=x2 - self.tyl1=y1 - self.tyl2=y2 - end - end) - function obj:OnDoubleTap(func) - table.insert(self.ToDTFunc,func) - end - function obj:On2TouchMoved(func) - table.insert(self.To2Func,func) - end - function obj:addTID(id) - table.insert(self.tid,id) - end - function obj:OnTouchPressed(func) - table.insert(self.ToFuncP,func) -- event for touches - end - function obj:OnTouchReleased(func) -- event for touches - table.insert(self.ToFuncR,func) - end - function obj:OnTouchMoved(func) -- event for touches - table.insert(self.ToFuncM,func) - end - if _GuiPro.TouchReady then -- my sneaky test - print("Registred: "..tostring(obj)) - table.insert(_GuiPro.TouchRegister,obj) - else - print("Attempting to register: "..tostring(obj)) - _GuiPro.int:newJob(function() table.insert(_GuiPro.TouchRegister,obj) end) -- a sneaky way to ensure that your object gets registered eventually, even if you call the method before the touch patch was activated. - end -end diff --git a/OldStuff/GuiManager/Drawing/AddDrawRuleB.int b/OldStuff/GuiManager/Drawing/AddDrawRuleB.int deleted file mode 100644 index 5510a3d..0000000 --- a/OldStuff/GuiManager/Drawing/AddDrawRuleB.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:AddDrawRuleB(rule) - if not(self.DrawRulesB) then self.DrawRulesB={} end - table.insert(self.DrawRulesB,rule) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Drawing/AddDrawRuleE.int b/OldStuff/GuiManager/Drawing/AddDrawRuleE.int deleted file mode 100644 index a025f89..0000000 --- a/OldStuff/GuiManager/Drawing/AddDrawRuleE.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:AddDrawRuleE(rule) - if not(self.DrawRulesE) then self.DrawRulesE={} end - table.insert(self.DrawRulesE,rule) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Drawing/canvas.int b/OldStuff/GuiManager/Drawing/canvas.int deleted file mode 100644 index e69de29..0000000 diff --git a/OldStuff/GuiManager/Drawing/draw.int b/OldStuff/GuiManager/Drawing/draw.int deleted file mode 100644 index d0b2404..0000000 --- a/OldStuff/GuiManager/Drawing/draw.int +++ /dev/null @@ -1,12 +0,0 @@ -function gui:draw() - if _GuiPro.rotate~=0 then - love.graphics.rotate(math.rad(_GuiPro.rotate)) - end - if self.FormFactor:lower()=="rectangle" then - self:drawR() - elseif self.FormFactor:lower()=="circle" then - self:drawC() - else - error("Unsupported FormFactor: "..self.FormFactor.."!") - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Drawing/drawC.int b/OldStuff/GuiManager/Drawing/drawC.int deleted file mode 100644 index 95febad..0000000 --- a/OldStuff/GuiManager/Drawing/drawC.int +++ /dev/null @@ -1,89 +0,0 @@ -function gui:drawC() - if love.mouse.isDown("l")==false and love.mouse.isDown("m")==false and love.mouse.isDown("r")==false then - _GuiPro.DragItem={} - _GuiPro.hasDrag=false - end - if self.Visible==true and self.VIS==true then - local b=true - for i,v in pairs(_GuiPro.Clips) do - if self:isDescendant(v)==true then - b=false - end - end - if b then - love.graphics.setStencilTest( ) - _GuiPro.HasStencel=false - _GuiPro.StencelHolder=nil - end - local x,y,r,s=(self.offset.pos.x or 0)+self.Parent.x,(self.offset.pos.y or 0)+self.Parent.y,self.offset.size.x or 0,self.offset.size.y or 360 - if self.CC then - x,y=x+r,y+r - end - self.x,self.y=x,y - _GuiPro.circleStencilFunction = function() - love.graphics.circle("fill",x,y,r,s) - end - if math.sqrt((love.mouse.getX()-x)^2+(love.mouse.getY()-y)^2)<=r and self:eventable() and self:Clickable() and self.Active==true then - self.hovering=true - if love.mouse.isDown("l") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.lclicked=true - elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.rclicked=true - elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then - if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.mclicked=true - else - if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - end - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - self.hovering=false - self.rclicked=false - self.lclicked=false - self.mclicked=false - end - if self.ClipDescendants==true then - _GuiPro.Clips[tostring(self)]=self - _GuiPro.HasStencel=true - _GuiPro.StencelHolder=self - love.graphics.stencil(_GuiPro.circleStencilFunction) - love.graphics.setStencilTest("notequal",0) - end - love.graphics.circle("fill",x,y,r,s) - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],(self.BorderVisibility or 1)) - for b=0,self.BorderSize-1 do - love.graphics.circle("line",x,y,r+b,s) - end - if string.find(self.Type, "Text") then - if self.text~=nil then - if self.AutoScaleText then - self.FontSize=math.floor(self.height/1.45833) - end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) - love.graphics.setFont(self.Font) - love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat) - end - end - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Drawing/drawR.lua b/OldStuff/GuiManager/Drawing/drawR.lua deleted file mode 100644 index 05a96f0..0000000 --- a/OldStuff/GuiManager/Drawing/drawR.lua +++ /dev/null @@ -1,73 +0,0 @@ -function gui:drawR() - if love.mouse.isDown("l")==false and love.mouse.isDown("m")==false and love.mouse.isDown("r")==false then - _GuiPro.DragItem={} - _GuiPro.hasDrag=false - end - if self.hidden then - self.x=(self.Parent.width*self.scale.pos.x)+self.offset.pos.x+self.Parent.x - self.y=(self.Parent.height*self.scale.pos.y)+self.offset.pos.y+self.Parent.y - self.width=(self.Parent.width*self.scale.size.x)+self.offset.size.x - self.height=(self.Parent.height*self.scale.size.y)+self.offset.size.y - self.VIS = false - end - if self.Visible==true and self.VIS==true then - self.x=(self.Parent.width*self.scale.pos.x)+self.offset.pos.x+self.Parent.x - self.y=(self.Parent.height*self.scale.pos.y)+self.offset.pos.y+self.Parent.y - self.width=(self.Parent.width*self.scale.size.x)+self.offset.size.x - self.height=(self.Parent.height*self.scale.size.y)+self.offset.size.y - local b=true - for i,v in pairs(_GuiPro.Clips) do - if self:isDescendant(v)==true then - b=false - end - end - if b==true then - love.graphics.setStencilTest() - love.graphics.setScissor() - end - if self.DrawRulesB then - for dr=1,#self.DrawRulesB do - self.DrawRulesB[dr](self) - end - end - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) - if self.ClipDescendants==true then - _GuiPro.Clips[tostring(self)]=self - love.graphics.setScissor(self.x, self.y, self.width, self.height) - end - if self:hasRoundness() then - -- love.graphics.stencil(self.stfunc, "replace", 1) - -- love.graphics.setStencilTest("greater", 0) - end - love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) - if string.find(self.Type, "Image") then - self:ImageRule() - end - if self.Type=="Video" then - self:VideoRule() - end - if self:hasRoundness() then - -- love.graphics.setStencilTest() - end - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],(self.BorderVisibility or 1)) - for b=0,self.BorderSize-1 do - love.graphics.rectangle("line", self.x-(b/2), self.y-(b/2), self.width+b, self.height+b,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) - end - if string.find(self.Type, "Text") then - if self.text~=nil and self.TextFormat ~= "center" then - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) - love.graphics.setFont(self.Font) - love.graphics.printf(self.text, self.x, self.y, self.width, self.TextFormat,self.TextRotaion) - elseif self.text~=nil and self.TextFormat == "center" then - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) - love.graphics.setFont(self.Font) - love.graphics.printf(self.text, self.x+(self.width-self.Font:getWidth(self.text))/2, self.y+(self.height-self.Font:getHeight())/2, self.width, "left",self.TextRotaion) - end - end - if self.DrawRulesE then - for dr=1,#self.DrawRulesE do - self.DrawRulesE[dr](self) - end - end - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Frame/newDropFrame.int b/OldStuff/GuiManager/Frame/newDropFrame.int deleted file mode 100644 index 97e4720..0000000 --- a/OldStuff/GuiManager/Frame/newDropFrame.int +++ /dev/null @@ -1,37 +0,0 @@ -function gui:newDropFrame(name,x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("DropFrame",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=false - c.funcD={} - function c:GetDroppedItems() - local t=self:getChildren() - local tab={} - for i=1,#t do - if t[i].Type=="TextImageButtonFrameDrag" then - table.insert(tab,t[i]) - end - end - return tab - end - function c:OnDropped(func) - table.insert(self.funcD,func) - end - c:OnUpdate(function(self) - if _GuiPro.DragItem then - if _GuiPro.DragItem.Type=="TextImageButtonFrameDrag" and love.mouse.isDown(_GuiPro.DragItem.dragbut or "m")==false and self:IsHovering() then - local t=_GuiPro.DragItem - _GuiPro.DragItem={} - for i=1,#t.funcD do - t.funcD[i](self,t) - end - for i=1,#self.funcD do - self.funcD[i](self,t) - end - _GuiPro.hasDrag=false - end - end - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Frame/newFrame.int b/OldStuff/GuiManager/Frame/newFrame.int deleted file mode 100644 index 5e6b084..0000000 --- a/OldStuff/GuiManager/Frame/newFrame.int +++ /dev/null @@ -1,8 +0,0 @@ -function gui:newFrame(name,x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("Frame",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=false - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Frame/newFullFrame.int b/OldStuff/GuiManager/Frame/newFullFrame.int deleted file mode 100644 index 5cda200..0000000 --- a/OldStuff/GuiManager/Frame/newFullFrame.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:newFullFrame(name) - name=name or "" - return self:newFrame(name,0,0,0,0,0,0,1,1) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Frame/newTabFrame.int b/OldStuff/GuiManager/Frame/newTabFrame.int deleted file mode 100644 index 9f8f8fe..0000000 --- a/OldStuff/GuiManager/Frame/newTabFrame.int +++ /dev/null @@ -1,59 +0,0 @@ -function gui:newTabFrame(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=gui:newFrame(name, x, y, w, h, sx ,sy ,sw ,sh) - c.tabheight=20 - c.Holder=c:newFrame("Holder",0,c.tabheight,0,0,0,0,1,1) - c.TabHolder=c:newFrame("TabHolder",0,0,0,c.tabheight,0,0,1) - function c:setTabHeight(n) - self.tabheight=n - self.Holder:SetDualDim(0,-self.tabheight,0,0,0,0,1,1) - end - function c:addTab(name,colorT,colorH) - if colorT and not(colorH) then - colorH=colorT - end - local tab=self.TabHolder:newTextButton(name,name,0,0,0,0,0,0,0,1) - tab.Tween=-3 - if colorT then - tab.Color=colorT - end - local holder=self.Holder:newFrame(name,0,0,0,0,0,0,1,1) - if colorH then - holder.Color=colorH - end - tab.frame=holder - tab:OnReleased(function(b,self) - if b=="l" then - local tt=self.Parent:getChildren() - local th=self.Parent.Parent.Holder:getChildren() - for i=1,#th do - th[i].Visible=false - end - for i=1,#tt do - tt[i].frame.Visible=false - tt[i].BorderSize=1 - end - self.BorderSize=0 - self.frame.Visible=true - end - end) - local tt=self.TabHolder:getChildren() - for i=1,#tt do - tt[i].frame.Visible=false - tt[i].BorderSize=1 - end - tab.frame.Visible=true - tab.BorderSize=0 - return tab,holder - end - c:OnUpdate(function(self) - local th=self.TabHolder:getChildren() - local l=self.width/#th - for i=1,#th do - th[i]:SetDualDim(l*(i-1),0,l) - end - if #th==0 then - self:Destroy() - end - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Frame/newratioFrame.int b/OldStuff/GuiManager/Frame/newratioFrame.int deleted file mode 100644 index e69de29..0000000 diff --git a/OldStuff/GuiManager/Image-Animation/SetImage.int b/OldStuff/GuiManager/Image-Animation/SetImage.int deleted file mode 100644 index 7ff105f..0000000 --- a/OldStuff/GuiManager/Image-Animation/SetImage.int +++ /dev/null @@ -1,16 +0,0 @@ -function gui:SetImage(i) - if not i then return end - if type(i) == "userdata" and i:type() == "Image" then - self.Image=i - self.ImageHeigth=self.Image:getHeight() - self.ImageWidth=self.Image:getWidth() - self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) - elseif type(i)=="string" then - gui.loadImageData(i,nil,function(imagedata) - self.Image = love.graphics.newImage(imagedata) - self.ImageHeigth=self.Image:getHeight() - self.ImageWidth=self.Image:getWidth() - self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) - end) - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/SetThreadedImage.int b/OldStuff/GuiManager/Image-Animation/SetThreadedImage.int deleted file mode 100644 index c791c5a..0000000 --- a/OldStuff/GuiManager/Image-Animation/SetThreadedImage.int +++ /dev/null @@ -1,60 +0,0 @@ --- local queueUpload = love.thread.getChannel("ImageUploader") --- local queueDownload = love.thread.getChannel("ImageDownloader") --- local code = [[ --- require("love.image") --- local queueUpload = love.thread.getChannel("ImageUploader") --- local queueDownload = love.thread.getChannel("ImageDownloader") --- local clock = os.clock --- local idle = clock --- while true do - -- if not idle then - -- love.timer.sleep(.001) - -- elseif clock()-idle>=15 then - -- love.timer.sleep(.01) - -- end - -- local data = queue:pop() - -- if data then - -- idle = clock() - -- print(data[1],data[2]) - -- end --- end --- ]] --- local t = love.thread.newThread(code) --- t:start() - - --- _GuiPro.jobqueue:registerJob("LoadImage",function(path) - -- local dat = love.image.newImageData(path) - -- return dat --- end) --- local cache = {} --- _GuiPro.jobqueue.OnJobCompleted(function(JOBID,n) - -- cache[JOBID].Image=love.graphics.newImage(n) - -- cache[JOBID].ImageHeigth=cache[JOBID].Image:getHeight() - -- cache[JOBID].ImageWidth=cache[JOBID].Image:getWidth() - -- cache[JOBID].Quad=love.graphics.newQuad(0,0,cache[JOBID].width,cache[JOBID].height,cache[JOBID].ImageWidth,cache[JOBID].ImageHeigth) --- end) --- function gui:ThreadedSetImage(i) - -- local temp = self.Image - -- if _GuiPro.imagecache[i] then - -- self.Image=_GuiPro.imagecache[i] - -- self.ImageHeigth=self.Image:getHeight() - -- self.ImageWidth=self.Image:getWidth() - -- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) - -- else - -- if type(i)=="string" then - -- local ii = _GuiPro.jobqueue:pushJob("LoadImage",i) - -- cache[ii] = self - -- elseif tostring(i):find("ImageData") then - -- self.Image=love.graphics.newImage(i) - -- self.ImageHeigth=self.Image:getHeight() - -- self.ImageWidth=self.Image:getWidth() - -- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) - -- elseif i then - -- self.Image=i - -- self.ImageHeigth=self.Image:getHeight() - -- self.ImageWidth=self.Image:getWidth() - -- self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) - -- end - -- end --- end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/imageThreadHandler.int b/OldStuff/GuiManager/Image-Animation/imageThreadHandler.int deleted file mode 100644 index 08d3073..0000000 --- a/OldStuff/GuiManager/Image-Animation/imageThreadHandler.int +++ /dev/null @@ -1,44 +0,0 @@ -local queueUpload = love.thread.getChannel("ImageUploader") -local queueDownload = love.thread.getChannel("ImageDownloader") -local code = [[ -require("love.image") -require("love.timer") -local queueUpload = love.thread.getChannel("ImageUploader") -local queueDownload = love.thread.getChannel("ImageDownloader") -while true do - love.timer.sleep(.001) - local data = queueUpload:pop() - if data then - queueDownload:push{data[1],love.image.newImageData(data[2])} - end -end -]] -local count = 0 -local conn = multi:newConnection() -function gui.loadImageData(path,tag,callback) - local c = count - count = count + 1 - queueUpload:push{c,path} - if not callback then - return conn - else - local cd - cd = conn(function(id,data) - if id == c then - callback(data,tag,id) - cd:Destroy() - end - end) - end - return c -end -multi:newLoop(function() - local dat = queueDownload:pop() - if dat then - conn:Fire(dat[1],dat[2]) - end -end) -for i = 1,love.system.getProcessorCount() do - local t = love.thread.newThread(code) - t:start() -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newAnim.int b/OldStuff/GuiManager/Image-Animation/newAnim.int deleted file mode 100644 index 64bcda9..0000000 --- a/OldStuff/GuiManager/Image-Animation/newAnim.int +++ /dev/null @@ -1,67 +0,0 @@ -function gui:newAnim(file,delay, x, y, w, h, sx ,sy ,sw ,sh) - local _files=alphanumsort(love.filesystem.getDirectoryItems(file)) - local x,y,w,h,sx,sy,sw,sh=filter(file, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh) - if not w and not h then - local w,h = love.graphics.newImage(file.."/".._files[1]):getDimensions() - c:setDualDim(nil,nil,w,h) - end - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files={} - c.AnimStart={} - c.AnimEnd={} - local count = 0 - local max - for i=1,#_files do - if string.sub(_files[i],-1,-1)~="b" then - count = count + 1 - gui.loadImageData(file.."/".._files[i],count,function(imagedata,id) - c.files[id] = love.graphics.newImage(imagedata) - end) - end - end - c.step=multi:newTStep(1,count,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(step,pos) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - self.step:Reset() - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newAnimFromData.int b/OldStuff/GuiManager/Image-Animation/newAnimFromData.int deleted file mode 100644 index 02c85c7..0000000 --- a/OldStuff/GuiManager/Image-Animation/newAnimFromData.int +++ /dev/null @@ -1,52 +0,0 @@ -function gui:newAnimFromData(data,delay, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageAnimation","FromFile", x, y, w, h, sx ,sy ,sw ,sh) - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files=data - c.AnimStart={} - c.AnimEnd={} - c:SetImage(c.files[1]) - c.step=multi:newTStep(1,#c.files,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(pos,step) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newAnimFromTiles.int b/OldStuff/GuiManager/Image-Animation/newAnimFromTiles.int deleted file mode 100644 index 56fd0d8..0000000 --- a/OldStuff/GuiManager/Image-Animation/newAnimFromTiles.int +++ /dev/null @@ -1,59 +0,0 @@ -function gui:newAnimFromTiles(file,xd,yd,delay, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(file, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageAnimation",file, x, y, w, h, sx ,sy ,sw ,sh) - local im=love.image.newImageData(file) - local _x,_y=im:getDimensions() - c.Visibility=0 - c.ImageVisibility=1 - c.delay=delay or .05 - c.files={} - c.AnimStart={} - c.AnimEnd={} - for i=0,_y/yd-1 do - for j=0,_x/xd-1 do - table.insert(c.files,gui:getTile(im,j*xd,i*yd,xd,yd)) - end - end - c:SetImage(c.files[1]) - c.step=multi:newTStep(1,#c.files,1,c.delay) - c.step.parent=c - c.rotation=0 - c.step:OnStart(function(step) - for i=1,#step.parent.AnimStart do - step.parent.AnimStart[i](step.parent) - end - end) - c.step:OnStep(function(step,pos) - step.parent:SetImage(step.parent.files[pos]) - end) - c.step:OnEnd(function(step) - for i=1,#step.parent.AnimEnd do - step.parent.AnimEnd[i](step.parent) - end - end) - function c:OnAnimStart(func) - table.insert(self.AnimStart,func) - end - function c:OnAnimEnd(func) - table.insert(self.AnimEnd,func) - end - function c:Pause() - self.step:Pause() - end - function c:Resume() - self.step:Resume() - end - function c:Reset() - self.step.pos=1 - end - function c:getFrames() - return #self.files - end - function c:getFrame() - return self.step.pos - end - function c:setFrame(n) - return self:SetImage(self.files[n]) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newFullImageLabel.int b/OldStuff/GuiManager/Image-Animation/newFullImageLabel.int deleted file mode 100644 index 953f480..0000000 --- a/OldStuff/GuiManager/Image-Animation/newFullImageLabel.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:newFullImageLabel(i,name) - return self:newImageLabel(i,name,0,0,0,0,0,0,1,1) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newImageButton.int b/OldStuff/GuiManager/Image-Animation/newImageButton.int deleted file mode 100644 index 3b3810b..0000000 --- a/OldStuff/GuiManager/Image-Animation/newImageButton.int +++ /dev/null @@ -1,15 +0,0 @@ -function gui:newImageButton(i,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageButton",name, x, y, w, h, sx ,sy ,sw ,sh) - c:SetImage(i) - c.Visibility=0 - c.ImageVisibility=1 - c.rotation=0 - c:OnEnter(function() - love.mouse.setCursor(_GuiPro.CursorH) - end) - c:OnExit(function() - love.mouse.setCursor(_GuiPro.CursorN) - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newImageLabel.int b/OldStuff/GuiManager/Image-Animation/newImageLabel.int deleted file mode 100644 index db7d0f3..0000000 --- a/OldStuff/GuiManager/Image-Animation/newImageLabel.int +++ /dev/null @@ -1,10 +0,0 @@ -function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh) - if not name then name = "Imagelabel" end - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("ImageLabel",name, x, y, w, h, sx ,sy ,sw ,sh) - c:SetImage(i) - c.Visibility=0 - c.ImageVisibility=1 - c.rotation=0 - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Image-Animation/newVideo.int b/OldStuff/GuiManager/Image-Animation/newVideo.int deleted file mode 100644 index de2c379..0000000 --- a/OldStuff/GuiManager/Image-Animation/newVideo.int +++ /dev/null @@ -1,62 +0,0 @@ -function gui:newVideo(name,i,x,y,w,h,sx,sy,sw,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("Video",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then - c.Video=love.graphics.newVideo(i) - else - c.Video=i - end - c.Visibility=0 - c.VideoVisibility=1 - c.rotation=0 - if c.Video~=nil then - c.VideoHeigth=c.Video:getHeight() - c.VideoWidth=c.Video:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.VideoWidth,c.VideoHeigth) - end - c.funcV={} - function c:Play() - self.handStart=true - self.Video:play() - end - function c:Pause() - self.Video:pause() - end - c.Resume=c.Play - function c:Stop() - self.handStart=false - self:Pause() - self:Rewind() - for i=1,# self.funcV do - self.funcV[i](self) - end - end - function c:OnVideoStopped(func) - table.insert(self.funcV,func) - end - function c:Rewind() - self.Video:rewind() - end - function c:Restart() - self:Rewind() - self:Play() - end - function c:Seek(o) - self.Video:seek(o) - end - function c:Tell() - self.Video:tell() - end - function c:SetFilter(min, mag, anisotropy) - self.Video:setFilter(min, mag, anisotropy) - end - function c:IsPlaying() - return self.Video:isPlaying() - end - c:OnUpdate(function(self) - if self.Video:isPlaying()==false and self.handStart == true then - self:Stop() - end - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Item/newDragItem.int b/OldStuff/GuiManager/Item/newDragItem.int deleted file mode 100644 index 162341c..0000000 --- a/OldStuff/GuiManager/Item/newDragItem.int +++ /dev/null @@ -1,51 +0,0 @@ -function gui:newDragItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("TextImageButtonFrameDrag",name, x, y, w, h, sx ,sy ,sw ,sh) - c.WasBeingDragged=false - c.IsBeingDragged=false - c.Draggable=true - c.funcD={} - if type(i)=="string" then - c.Image=love.graphics.newImage(i) - c.ImageVisibility=1 - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - elseif type(i)=="image" then - c.Image=i - c.ImageVisibility=1 - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - end - c:OnDragStart(function(self,x,y) - if _GuiPro.hasDrag==false then - self:setParent(_GuiPro) - self:SetDualDim(x,y) - self:TopStack() - end - end) - c.rotation=0 - c.Tween=0 - c.XTween=0 - c.text = t - c.AutoScaleText=false - c.FontHeight=_defaultfont:getHeight() - c.Font=_defaultfont - c.FontSize=15 - c.TextFormat="center" - c.TextVisibility=1 - c.TextColor = {0, 0, 0} - function c:OnDropped(func) - table.insert(self.funcD,func) - end - c:OnUpdate(function(self) - if love.mouse.isDown("m" or self.dragbut)==false and self==_GuiPro.DragItem and self.hovering==false then - _GuiPro.DragItem={} - for i=1,#self.func7 do - self.func7[i](self,(love.mouse.getX())-self.width/2,(love.mouse.getY())-self.height/2) - end - end - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Item/newItem.int b/OldStuff/GuiManager/Item/newItem.int deleted file mode 100644 index 57a68d5..0000000 --- a/OldStuff/GuiManager/Item/newItem.int +++ /dev/null @@ -1,28 +0,0 @@ -function gui:newItem(t,i,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("TextImageButtonFrame",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then - c.Image=love.graphics.newImage(i) - else - c.Image=i - end - c.rotation=0 - c.ImageVisibility=1 - c.Draggable=false - if c.Image~=nil then - c.ImageHeigth=c.Image:getHeight() - c.ImageWidth=c.Image:getWidth() - c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) - end - c.Tween=0 - c.XTween=0 - c.text = t - c.AutoScaleText=false - c.FontHeight=_defaultfont:getHeight() - c.Font=_defaultfont - c.FontSize=15 - c.TextFormat="center" - c.TextVisibility=1 -- 0=invisible,1=solid (self.TextVisibility*254+1) - c.TextColor = {0, 0, 0} - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/AdvTextBox.int b/OldStuff/GuiManager/Misc/AdvTextBox.int deleted file mode 100644 index 08a3499..0000000 --- a/OldStuff/GuiManager/Misc/AdvTextBox.int +++ /dev/null @@ -1,45 +0,0 @@ -function gui:AdvTextBox(txt,x,y,w,h,sx,sy,sw,sh) - name="AdvTextBox" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("AdvTextBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c.BorderSize=0 - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - --local temp = c:newTextButton("X","Close",-25,5,20,20,1) - --temp.Tween=-5 - --temp.XTween=-2 - --temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - --temp.Color=Color.Red - c.tLink=c:newTextBox("puttext","TextBox",5,h-95,-40,30,0,1,1,1) - c.tLink.Color=Color.light_gray - c.tLink.ClearOnFocus=true - c.tLink:OnFocus(function(self) self.ClearOnFocus=false end) - local temp=c:newTextButton("OK","Ok",-35,h-65,30,30,1,1) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent,self.Parent.tLink.text) end end) - temp.Color=Color.Green - temp.XTween=-2 - local temp=c:newTextButton("X","Cancel",-35,h-95,30,30,1,1) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent,self.Parent.tLink.text) end end) - temp.Color=Color.Red - temp.XTween=-2 - function c:Close() - self.Visible=false - end - function c:Open() - self.Visible=true - end - function c:OnOk(func) - table.insert(self.funcO,func) - end - function c:OnX(func) - table.insert(self.funcX,func) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/ApplyGradient.int b/OldStuff/GuiManager/Misc/ApplyGradient.int deleted file mode 100644 index 87cb97d..0000000 --- a/OldStuff/GuiManager/Misc/ApplyGradient.int +++ /dev/null @@ -1,36 +0,0 @@ -function _GuiPro.gradient(colors) - local direction = colors.direction or "horizontal" - colors.direction=nil - trans = colors.trans or 1 - trans=math.floor(trans) - if direction == "horizontal" then - direction = true - elseif direction == "vertical" then - direction = false - else - error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.") - end - local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1,"rgba32f") - for __i, color in ipairs(colors) do - local x, y - if direction then - x, y = 0, __i - 1 - else - x, y = __i - 1, 0 - end - result:setPixel(x, y, color[1], color[2], color[3], trans) - end - result = love.graphics.newImage(result) - result:setFilter('linear', 'linear') - return result -end -function _GuiPro.drawinrect(img, x, y, w, h, r, ox, oy, kx, ky) - love.graphics.draw(img, x, y, r, w / img:getWidth(), h / img:getHeight(), ox, oy, kx, ky) -end -function gui:ApplyGradient(rules) - self.Image=nil - self.Type=self.Type.."w/GradImage" - self.rotation=0 - self.ImageVisibility=rules.visibility or 1 - self:SetImage(_GuiPro.gradient(rules)) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/BottomStack.int b/OldStuff/GuiManager/Misc/BottomStack.int deleted file mode 100644 index b339ec4..0000000 --- a/OldStuff/GuiManager/Misc/BottomStack.int +++ /dev/null @@ -1,10 +0,0 @@ -function gui:BottomStack() - childs=self.Parent:getChildren() - for i=1,#childs do - if childs[i]==self then - table.remove(self.Parent.Children,i) - table.insert(self.Parent.Children,1,self) - break - end - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/ClipDescendants.int b/OldStuff/GuiManager/Misc/ClipDescendants.int deleted file mode 100644 index c57d96d..0000000 --- a/OldStuff/GuiManager/Misc/ClipDescendants.int +++ /dev/null @@ -1,18 +0,0 @@ -function gui:ClipDescendants(bool) - local c = self:GetAllChildren() - if not c[#c] then return end - if bool then - self.clipParent = self.Parent - self.Clipping = true - c[#c].resetClip = true - for i = 1,#c do - c[i].ClipReference = self - end - else - self.Clipping = nil - c[#c].resetClip = nil - for i = 1,#c do - c[i].ClipReference = nil - end - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/Destroy.int b/OldStuff/GuiManager/Misc/Destroy.int deleted file mode 100644 index dd8f5de..0000000 --- a/OldStuff/GuiManager/Misc/Destroy.int +++ /dev/null @@ -1,13 +0,0 @@ -function gui:Destroy() - check=self.Parent:getChildren() - local cc=0 - for cc=1,#check do - if check[cc]==self then - table.remove(self.Parent.Children,cc) - end - end - self.Destroyed = true - if #self.Parent.Children==0 then - self.Parent.isLeaf = true - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/GetAllChildren.int b/OldStuff/GuiManager/Misc/GetAllChildren.int deleted file mode 100644 index b3a0ae4..0000000 --- a/OldStuff/GuiManager/Misc/GetAllChildren.int +++ /dev/null @@ -1,25 +0,0 @@ -function gui:GetAllChildren() - local Stuff = {} - function Seek(Items) - for i=1,#Items do - if Items[i].Visible==true then - table.insert(Stuff,Items[i]) - local NItems = Items[i]:getChildren() - if NItems ~= nil then - Seek(NItems) - end - end - end - end - local Objs = self:getChildren() - for i=1,#Objs do - if Objs[i].Visible==true then - table.insert(Stuff,Objs[i]) - local Items = Objs[i]:getChildren() - if Items ~= nil then - Seek(Items) - end - end - end - return Stuff -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/GetChild.int b/OldStuff/GuiManager/Misc/GetChild.int deleted file mode 100644 index d434f40..0000000 --- a/OldStuff/GuiManager/Misc/GetChild.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:GetChild(name) - return self.Children[name] or self -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/InGrid.int b/OldStuff/GuiManager/Misc/InGrid.int deleted file mode 100644 index 4e097a7..0000000 --- a/OldStuff/GuiManager/Misc/InGrid.int +++ /dev/null @@ -1,3 +0,0 @@ -function InGrid(i,x,y,s) - return math.floor((i-1)/x)*s,(i-1)*s-(math.floor((i-1)/y)*(s*x)) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/InGridX.int b/OldStuff/GuiManager/Misc/InGridX.int deleted file mode 100644 index c4aadc2..0000000 --- a/OldStuff/GuiManager/Misc/InGridX.int +++ /dev/null @@ -1,5 +0,0 @@ -function InGridX(i,w,h,xs,ys) - local xc,yc=math.floor(w/xs),math.floor(h/ys) - local xi,yi=(i-1)%xc,math.floor((i-1)/xc) - return xi*xs,yi*ys -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/InGridY.int b/OldStuff/GuiManager/Misc/InGridY.int deleted file mode 100644 index 555c72a..0000000 --- a/OldStuff/GuiManager/Misc/InGridY.int +++ /dev/null @@ -1,5 +0,0 @@ -function InGridY(i,w,h,xs,ys) - local xc,yc=math.floor(w/xs),math.floor(h/ys) - local xi,yi=math.floor((i-1)/yc),(i-1)%yc - return xi*xs,yi*ys -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/IsHovering.int b/OldStuff/GuiManager/Misc/IsHovering.int deleted file mode 100644 index 072bb54..0000000 --- a/OldStuff/GuiManager/Misc/IsHovering.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:IsHovering() - return (love.mouse.getX() > self.x and love.mouse.getX() < self.x+self.width and love.mouse.getY() > self.y and love.mouse.getY() < self.y+self.height) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/Move.int b/OldStuff/GuiManager/Misc/Move.int deleted file mode 100644 index 6f32db9..0000000 --- a/OldStuff/GuiManager/Misc/Move.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:Move(x,y) - self.offset.pos.x=self.offset.pos.x+x - self.offset.pos.y=self.offset.pos.y+y -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SetDualDim.int b/OldStuff/GuiManager/Misc/SetDualDim.int deleted file mode 100644 index 0774965..0000000 --- a/OldStuff/GuiManager/Misc/SetDualDim.int +++ /dev/null @@ -1,46 +0,0 @@ -function gui:SetDualDim(x, y, w, h, sx ,sy ,sw ,sh) - if _GuiPro.DPI_ENABLED then - if x then - x=self.DPI*x - end - if y then - y=self.DPI*y - end - if w then - w=self.DPI*w - end - if h then - h=self.DPI*h - end - end - if sx then - self.scale.pos.x=sx - end - if sy then - self.scale.pos.y=sy - end - if x then - self.offset.pos.x=x - end - if y then - self.offset.pos.y=y - end - if sw then - self.scale.size.x=sw - end - if sh then - self.scale.size.y=sh - end - if w then - self.offset.size.x=w - end - if h then - self.offset.size.y=h - end - if self.Image then - self:SetImage(self.Image) - end -end -function gui:setDualDim(...) - self:SetDualDim(...) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SetHand.int b/OldStuff/GuiManager/Misc/SetHand.int deleted file mode 100644 index 8171f2c..0000000 --- a/OldStuff/GuiManager/Misc/SetHand.int +++ /dev/null @@ -1,5 +0,0 @@ -_GuiPro.CursorN=love.mouse.getSystemCursor("arrow") -_GuiPro.CursorH=love.mouse.getSystemCursor("hand") -function gui:SetHand(img,x,y) - _GuiPro.CursorN=love.mouse.newCursor(img,x,y) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SetHover.int b/OldStuff/GuiManager/Misc/SetHover.int deleted file mode 100644 index 956e593..0000000 --- a/OldStuff/GuiManager/Misc/SetHover.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:SetHover(img,x,y) - _GuiPro.CursorH=love.mouse.newCursor(img,x,y) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SetName.int b/OldStuff/GuiManager/Misc/SetName.int deleted file mode 100644 index 1e69edd..0000000 --- a/OldStuff/GuiManager/Misc/SetName.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:SetName(name) - self.Parent.Children[name]=self - self.Name=name -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SquareX.int b/OldStuff/GuiManager/Misc/SquareX.int deleted file mode 100644 index c846e39..0000000 --- a/OldStuff/GuiManager/Misc/SquareX.int +++ /dev/null @@ -1,9 +0,0 @@ -function gui:SquareX(n) - local n = n or 1 - local w = self.Parent.width - local rw = w*n - local s = (w-rw)/2 - self:setDualDim(self.x+s,self.y+s,rw,rw,sx,sy) - self:Move(s,s) - return self.Parent.width,rw -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/SquareY.int b/OldStuff/GuiManager/Misc/SquareY.int deleted file mode 100644 index c90020b..0000000 --- a/OldStuff/GuiManager/Misc/SquareY.int +++ /dev/null @@ -1,9 +0,0 @@ -function gui:SquareY(n) - local n = n or 1 - local w = self.Parent.height - local rw = w*n - local s = (w-rw)/2 - self:setDualDim(nil,nil,rw,rw) - self:Move(s,s) - return self.Parent.height,rw -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/TopStack.int b/OldStuff/GuiManager/Misc/TopStack.int deleted file mode 100644 index a1db016..0000000 --- a/OldStuff/GuiManager/Misc/TopStack.int +++ /dev/null @@ -1,10 +0,0 @@ -function gui:TopStack() - childs=self.Parent:getChildren() - for i=1,#childs do - if childs[i]==self then - table.remove(self.Parent.Children,i) - table.insert(self.Parent.Children,self) - break - end - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/UpdateImage.int b/OldStuff/GuiManager/Misc/UpdateImage.int deleted file mode 100644 index be4cfd7..0000000 --- a/OldStuff/GuiManager/Misc/UpdateImage.int +++ /dev/null @@ -1,5 +0,0 @@ -function gui:UpdateImage() - self.ImageHeigth=self.Image:getHeight() - self.ImageWidth=self.Image:getWidth() - self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/Utils.int b/OldStuff/GuiManager/Misc/Utils.int deleted file mode 100644 index c80b4bc..0000000 --- a/OldStuff/GuiManager/Misc/Utils.int +++ /dev/null @@ -1,797 +0,0 @@ --- os Additions -function os.getSystemBit() - if (os.getenv('PROCESSOR_ARCHITEW6432')=='AMD64' or os.getenv('PROCESSOR_ARCHITECTURE')=='AMD64') then - return 64 - else - return 32 - end -end -function os.sleep(n) - if not n then n=0 end - local t0 = os.clock() - while os.clock() - t0 <= n do end -end -function os.pause(msg) - if msg ~= nil then - print(msg) - end - io.read() -end -function os.batCmd(cmd) - io.mkFile('temp.bat',cmd) - local temp = os.execute([[temp.bat]]) - io.delFile('temp.bat') - return temp -end -function os._getOS() - if package.config:sub(1,1)=='\\' then - return 'windows' - else - return 'unix' - end -end -function os.getOS(t) - if not t then - return os._getOS() - end - if os._getOS()=='unix' then - fh,err = io.popen('uname -o 2>/dev/null','r') - if fh then - osname = fh:read() - end - if osname then return osname end - end - local winver='Unknown Version' - local a,b,c=os.capture('ver'):match('(%d+).(%d+).(%d+)') - local win=a..'.'..b..'.'..c - if type(t)=='string' then - win=t - end - if win=='4.00.950' then - winver='95' - elseif win=='4.00.1111' then - winver='95 OSR2' - elseif win=='4.00.1381' then - winver='NT 4.0' - elseif win=='4.10.1998' then - winver='98' - elseif win=='4.10.2222' then - winver='98 SE' - elseif win=='4.90.3000' then - winver='ME' - elseif win=='5.00.2195' then - winver='2000' - elseif win=='5.1.2600' then - winver='XP' - elseif win=='5.2.3790' then - winver='Server 2003' - elseif win=='6.0.6000' then - winver='Vista/Windows Server 2008' - elseif win=='6.0.6002' then - winver='Vista SP2' - elseif win=='6.1.7600' then - winver='7/Windows Server 2008 R2' - elseif win=='6.1.7601' then - winver='7 SP1/Windows Server 2008 R2 SP1' - elseif win=='6.2.9200' then - winver='8/Windows Server 2012' - elseif win=='6.3.9600' then - winver='8.1/Windows Server 2012' - elseif win=='6.4.9841' then - winver='10 Technical Preview 1' - elseif win=='6.4.9860' then - winver='10 Technical Preview 2' - elseif win=='6.4.9879' then - winver='10 Technical Preview 3' - elseif win=='10.0.9926' then - winver='10 Technical Preview 4' - end - return 'Windows '..winver -end -function os.getLuaArch() - return (#tostring({})-7)*4 -end -if os.getOS()=='windows' then - function os.sleep(n) - if n > 0 then os.execute('ping -n ' .. tonumber(n+1) .. ' localhost > NUL') end - end -else - function os.sleep(n) - os.execute('sleep ' .. tonumber(n)) - end -end -function os.capture(cmd, raw) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) - f:close() - if raw then return s end - s = string.gsub(s, '^%s+', '') - s = string.gsub(s, '%s+$', '') - s = string.gsub(s, '[\n\r]+', ' ') - return s -end -function os.getCurrentUser() - return os.getenv('$USER') or os.getenv('USERNAME') -end --- string Additions -function string.trim(s) - local from = s:match"^%s*()" - return from > #s and "" or s:match(".*%S", from) -end -function string.random(n) - local str = '' - strings = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'} - for i=1,n do - h = math.random(1,#strings) - str = str..''..strings[h] - end - return str -end -function string.linesToTable(s) - local t = {} - local i = 0 - while true do - i = string.find(s, '\n', i+1) - if i == nil then return t end - table.insert(t, i) - end -end -function string.lines(str) - local t = {} - local function helper(line) table.insert(t, line) return '' end - helper((str:gsub('(.-)\r?\n', helper))) - return t -end -function string.split(str, pat) - local t = {} -- NOTE: use {n = 0} in Lua-5.0 - local fpat = '(.-)' .. pat - local last_end = 1 - local s, e, cap = str:find(fpat, 1) - while s do - if s ~= 1 or cap ~= '' then - table.insert(t,cap) - end - last_end = e+1 - s, e, cap = str:find(fpat, last_end) - end - if last_end <= #str then - cap = str:sub(last_end) - table.insert(t, cap) - end - return t -end -function string.shuffle(inputStr) - math.randomseed(os.time()); - local outputStr = ''; - local strLength = string.len(inputStr); - while (strLength ~=0) do - local pos = math.random(strLength); - outputStr = outputStr..string.sub(inputStr,pos,pos); - inputStr = inputStr:sub(1, pos-1) .. inputStr:sub(pos+1); - strLength = string.len(inputStr); - end - return outputStr; -end -function string.genKeys(chars,a,f,s,GG) - if GG then - chars=string.rep(chars,a) - end - if s then - chars=string.shuffle(chars) - end - b=#chars - if a==0 then return end - local taken = {} local slots = {} - for i=1,a do slots[i]=0 end - for i=1,b do taken[i]=false end - local index = 1 - local tab={} - for i=1,#chars do - table.insert(tab,chars:sub(i,i)) - end - while index > 0 do repeat - repeat slots[index] = slots[index] + 1 - until slots[index] > b or not taken[slots[index]] - if slots[index] > b then - slots[index] = 0 - index = index - 1 - if index > 0 then - taken[slots[index]] = false - end - break - else - taken[slots[index]] = true - end - if index == a then - local tt={} - for i=1,a do - table.insert(tt,tab[slots[i]]) - end - f(table.concat(tt)) - taken[slots[index]] = false - break - end - index = index + 1 - until true end -end --- io Additions -function io.getInput(msg) - if msg ~= nil then - io.write(msg) - end - return io.read() -end -function io.scanDir(directory) - directory=directory or io.getDir() - local i, t, popen = 0, {}, io.popen - if os.getOS()=='unix' then - for filename in popen('ls -a \''..directory..'\''):lines() do - i = i + 1 - t[i] = filename - end - else - for filename in popen('dir \''..directory..'\' /b'):lines() do - i = i + 1 - t[i] = filename - end - end - return t -end -function io.buildFromTree(tbl, indent,folder) - if not indent then indent = 0 end - if not folder then folder = '' end - for k, v in pairs(tbl) do - formatting = string.rep(' ', indent) .. k .. ':' - if type(v) == 'table' then - if not(io.dirExists(folder..string.sub(formatting,1,-2))) then - io.mkDir(folder..string.sub(formatting,1,-2)) - end - io.buildFromTree(v,0,folder..string.sub(formatting,1,-2)..'\\') - else - a=string.find(tostring(v),':',1,true) - if a then - file=string.sub(tostring(v),1,a-1) - data=string.sub(tostring(v),a+1) - io.mkFile(folder..file,data,'wb') - else - io.mkFile(folder..v,'','wb') - end - end - end -end -function io.cpFile(path,topath) - if os.getOS()=='unix' then - os.execute('cp '..file1..' '..file2) - else - os.execute('Copy '..path..' '..topath) - end -end -function io.delDir(directoryname) - if os.getOS()=='unix' then - os.execute('rm -rf '..directoryname) - else - os.execute('rmdir '..directoryname..' /s /q') - end -end -function io.delFile(path) - os.remove(path) -end -function io.mkDir(dirname) - os.execute('mkdir "' .. dirname..'"') -end -function io.mkFile(filename,data,tp) - if not(tp) then tp='wb' end - if not(data) then data='' end - file = io.open(filename, tp) - if file==nil then return end - file:write(data) - file:close() -end -function io.movFile(path,topath) - io.cpFile(path,topath) - io.delFile(path) -end -function io.listFiles(dir) - if not(dir) then dir='' end - local f = io.popen('dir \''..dir..'\'') - if f then - return f:read('*a') - else - print('failed to read') - end -end -function io.getDir(dir) - if not dir then return io.getWorkingDir() end - if os.getOS()=='unix' then - return os.capture('cd '..dir..' ; cd') - else - return os.capture('cd '..dir..' & cd') - end -end -function io.getWorkingDir() - return io.popen'cd':read'*l' -end -function io.fileExists(path) - g=io.open(path or '','r') - if path =='' then - p='empty path' - return nil - end - if g~=nil and true or false then - p=(g~=nil and true or false) - end - if g~=nil then - io.close(g) - else - return false - end - return p -end -function io.fileCheck(file_name) - if not file_name then print('No path inputed') return false end - local file_found=io.open(file_name, 'r') - if file_found==nil then - file_found=false - else - file_found=true - end - return file_found -end -function io.dirExists(strFolderName) - strFolderName = strFolderName or io.getDir() - local fileHandle, strError = io.open(strFolderName..'\\*.*','r') - if fileHandle ~= nil then - io.close(fileHandle) - return true - else - if string.match(strError,'No such file or directory') then - return false - else - return true - end - end -end -function io.getAllItems(dir) - local t=os.capture("cd \""..dir.."\" & dir /a-d | find",true):lines() - return t -end -function io.listItems(dir) - if io.dirExists(dir) then - temp=io.listFiles(dir) -- current directory if blank - if io.getDir(dir)=='C:\\\n' then - a,b=string.find(temp,'C:\\',1,true) - a=a+2 - else - a,b=string.find(temp,'..',1,true) - end - temp=string.sub(temp,a+2) - list=string.linesToTable(temp) - temp=string.sub(temp,1,list[#list-2]) - slist=string.lines(temp) - table.remove(slist,1) - table.remove(slist,#slist) - temp={} - temp2={} - for i=1,#slist do - table.insert(temp,string.sub(slist[i],40,-1)) - end - return temp - else - return nil - end -end -function io.getDirectories(dir,l) - if dir then - dir=dir..'\\' - else - dir='' - end - local temp2=io.scanDir(dir) - for i=#temp2,1,-1 do - if io.fileExists(dir..temp2[i]) then - table.remove(temp2,i) - elseif l then - temp2[i]=dir..temp2[i] - end - end - return temp2 -end -function io.getFiles(dir,l) - if dir then - dir=dir..'\\' - else - dir='' - end - local temp2=io.scanDir(dir) - for i=#temp2,1,-1 do - if io.dirExists(dir..temp2[i]) then - table.remove(temp2,i) - elseif l then - temp2[i]=dir..temp2[i] - end - end - return temp2 -end -function io.getFullName(name) - local temp=name or arg[0] - if string.find(temp,'\\',1,true) or string.find(temp,'/',1,true) then - temp=string.reverse(temp) - a,b=string.find(temp,'\\',1,true) - if not(a) or not(b) then - a,b=string.find(temp,'/',1,true) - end - return string.reverse(string.sub(temp,1,b-1)) - end - return temp -end -function io.getName(file) - local name=io.getFullName(file) - name=string.reverse(name) - a,b=string.find(name,'.',1,true) - name=string.sub(name,a+1,-1) - return string.reverse(name) -end -function io.readFile(file) - local f = io.open(file, 'rb') - local content = f:read('*all') - f:close() - return content -end -function io.getExtension(file) - local file=io.getFullName(file) - file=string.reverse(file) - local a,b=string.find(file,'.',0,true) - local temp=string.sub(file,1,b) - return string.reverse(temp) -end -function io.pathToTable(path) - local p=io.splitPath(path) - local temp={} - temp[p[1]]={} - local last=temp[p[1]] - for i=2,#p do - snd=last - last[p[i]]={} - last=last[p[i]] - end - return temp,last,snd -end -function io.splitPath(str) - return string.split(str,'[\\/]+') -end - -function io.parseDir(dir,t) - io.tempFiles={} - function _p(dir) - local dirs=io.getDirectories(dir,true) - local files=io.getFiles(dir,true) - for i=1,#files do - p,l,s=io.pathToTable(files[i]) - if t then - s[io.getFullName(files[i])]=io.readFile(files[i]) - else - s[io.getFullName(files[i])]=io.open(files[i],'r+') - end - table.merge(io.tempFiles,p) - end - for i=1,#dirs do - table.merge(io.tempFiles,io.pathToTable(dirs[i])) - _p(dirs[i],t) - end - end - _p(dir) - return io.tempFiles -end -function io.parsedir(dir,f) - io.tempFiles={} - function _p(dir,f) - local dirs=io.getDirectories(dir,true) - local files=io.getFiles(dir,true) - for i=1,#files do - if not f then - table.insert(io.tempFiles,files[i]) - else - f(files[i]) - end - end - for i=1,#dirs do - _p(dirs[i],f) - end - end - _p(dir,f) - return io.tempFiles -end -function io.driveReady(drive) - drive=drive:upper() - if not(drive:find(':',1,true)) then - drive=drive..':' - end - drives=io.getDrives() - for i=1,#drives do - if drives[i]==drive then - return true - end - end - return false -end -function io.getDrives() - if os.getOS()=='windows' then - local temp={} - local t1=os.capture('wmic logicaldisk where drivetype=2 get deviceid, volumename',true) - local t2=os.capture('wmic logicaldisk where drivetype=3 get deviceid, volumename',true) - for drive,d2 in t1:gmatch('(.:)%s-(%w+)') do - if #d2>1 then - table.insert(temp,drive) - end - end - for drive in t2:gmatch('(.:)') do - table.insert(temp,drive) - end - return temp - end - error('Command is windows only!') -end --- table Additions -function table.dump(t,indent) - local names = {} - if not indent then indent = '' end - for n,g in pairs(t) do - table.insert(names,n) - end - table.sort(names) - for i,n in pairs(names) do - local v = t[n] - if type(v) == 'table' then - if(v==t) then - print(indent..tostring(n)..': <-') - else - print(indent..tostring(n)..':') - table.dump(v,indent..' ') - end - else - if type(v) == 'function' then - print(indent..tostring(n)..'()') - else - print(indent..tostring(n)..': '..tostring(v)) - end - end - end -end -function table.alphanumsort(o) - local function padnum(d) local dec, n = string.match(d, '(%.?)0*(.+)') - return #dec > 0 and ('%.12f'):format(d) or ('%s%03d%s'):format(dec, #n, n) - end - table.sort(o, function(a,b) return tostring(a):gsub('%.?%d+',padnum)..('%3d'):format(#b)< tostring(b):gsub('%.?%d+',padnum)..('%3d'):format(#a) end) - return o -end -function table.foreach(t,f) - for i,v in pairs(t) do - f(v) - end -end -function table.merge(t1, t2) - for k,v in pairs(t2) do - if type(v) == 'table' then - if type(t1[k] or false) == 'table' then - table.merge(t1[k] or {}, t2[k] or {}) - else - t1[k] = v - end - else - t1[k] = v - end - end - return t1 -end -function table.print(tbl, indent) - if not indent then indent = 0 end - for k, v in pairs(tbl) do - formatting = string.rep(' ', indent) .. k .. ': ' - if type(v) == 'table' then - print(formatting) - table.print(v, indent+1) - else - print(formatting .. tostring(v)) - end - end -end -function table.merge(t1, t2) - for k,v in pairs(t2) do - if type(v) == 'table' then - if type(t1[k] or false) == 'table' then - table.merge(t1[k] or {}, t2[k] or {}) - else - t1[k] = v - end - else - t1[k] = v - end - end - return t1 -end -function table.clear(t) - for k in pairs (t) do - t[k] = nil - end -end -function table.copy(t) - function deepcopy(orig) - local orig_type = type(orig) - local copy - if orig_type == 'table' then - copy = {} - for orig_key, orig_value in next, orig, nil do - copy[deepcopy(orig_key)] = deepcopy(orig_value) - end - setmetatable(copy, deepcopy(getmetatable(orig))) - else -- number, string, boolean, etc - copy = orig - end - return copy - end - return deepcopy(t) -end -function table.swap(tab,i1,i2) - tab[i1],tab[i2]=tab[i2],tab[i1] -end -function table.append(t1, ...) - t1,t2= t1 or {},{...} - for k,v in pairs(t2) do - t1[#t1+1]=t2[k] - end - return t1 -end -function table.compare(t1, t2,d) - if d then - return table.deepCompare(t1,t2) - end - --if #t1 ~= #t2 then return false end - if #t2>#t1 then - for i=1,#t2 do - if t1[i] ~= t2[i] then - return false,t2[i] - end - end - else - for i=1,#t1 do - if t1[i] ~= t2[i] then - return false,t2[i] - end - end - end - return true -end -function table.deepCompare(t1,t2) - if t1==t2 then return true end - if (type(t1)~='table') then return false end - local mt1 = getmetatable(t1) - local mt2 = getmetatable(t2) - if( not table.deepCompare(mt1,mt2) ) then return false end - for k1,v1 in pairs(t1) do - local v2 = t2[k1] - if( not table.deepCompare(v1,v2) ) then return false end - end - for k2,v2 in pairs(t2) do - local v1 = t1[k2] - if( not table.deepCompare(v1,v2) ) then return false end - end - return true -end -function table.has(t,_v) - for i,v in pairs(t) do - if v==_v then - return true - end - end - return false -end -function table.reverse(tab) - local size = #tab - local newTable = {} - for i,v in ipairs (tab) do - newTable[size-i] = v - end - for i=1,#newTable do - tab[i]=newTable[i] - end -end --- Math Additions -local Y = function(g) local a = function(f) return f(f) end return a(function(f) return g(function(x) local c=f(f) return c(x) end) end) end -local F = function(f) return function(n)if n == 0 then return 1 else return n*f(n-1) end end end -math.factorial = Y(F) -math.fib={} -math.fib.fibL={} -setmetatable(math.fib,{__call=function(self,n) - if n<=2 then - return 1 - else - if self.fibL[n] then - return self.fibL[n] - else - local t=math.fib(n-1)+math.fib(n-2) - self.fibL[n]=t - return t - end - end -end}) -local floor,insert = math.floor, table.insert -function math.basen(n,b) - n = floor(n) - if not b or b == 10 then return tostring(n) end - local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' - local t = {} - local sign = '' - if n < 0 then - sign = '-' - n = -n - end - repeat - local d = (n % b) + 1 - n = floor(n / b) - insert(t, 1, digits:sub(d,d)) - until n == 0 - return sign .. table.concat(t,'') -end -function math.convbase(n,b,tb) - return math.basen(tonumber(tostring(n),b),tb) -end -if BigNum then - function BigNum.mod(a,b) - return a-((a/b)*b) - end - local floor,insert = math.floor, table.insert - function math.basen(n,b) - n = BigNum.new(n) - if not b or b == 10 then return tostring(n) end - local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' - local t = {} - local sign = '' - if n < BigNum.new(0) then - sign = '-' - n = -n - end - repeat - local d = BigNum.mod(n , b) + 1 - n = n/b - d=tonumber(tostring(d)) - insert(t, 1, digits:sub(d,d)) - until tonumber(tostring(n)) == 0 - return sign .. table.concat(t,'') - end - function math.to10(n,b) - local num=tostring(n) - local sum=BigNum.new() - local digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' - for i=1,#num do - local v=digits:find(num:sub(i,i),1,true) - sum=sum+BigNum.new(tonumber(v)-1)*BigNum.pow(BigNum.new(b),BigNum.new(#num-i)) - end - return sum - end - function math.convbase(n,b,tb) - return math.basen(math.to10(n,b),tb) - end -end -function math.numfix(n,x) - local str=tostring(n) - if #str 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 \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/anchorRight.int b/OldStuff/GuiManager/Misc/anchorRight.int deleted file mode 100644 index 91251ad..0000000 --- a/OldStuff/GuiManager/Misc/anchorRight.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:anchorRight(n) - self:SetDualDim(-(self.width+n),nil,nil,nil,1) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/center.int b/OldStuff/GuiManager/Misc/center.int deleted file mode 100644 index fb22fea..0000000 --- a/OldStuff/GuiManager/Misc/center.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:center() - self:centerX() - self:centerY() -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/centerX.int b/OldStuff/GuiManager/Misc/centerX.int deleted file mode 100644 index ea1f599..0000000 --- a/OldStuff/GuiManager/Misc/centerX.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:centerX() - self:SetDualDim(-(self.width/2),nil,nil,nil,.5) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/centerY.int b/OldStuff/GuiManager/Misc/centerY.int deleted file mode 100644 index c998589..0000000 --- a/OldStuff/GuiManager/Misc/centerY.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:centerY() - self:SetDualDim(nil,-(self.height/2),nil,nil,nil,.5) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/disrespectHierarchy.int b/OldStuff/GuiManager/Misc/disrespectHierarchy.int deleted file mode 100644 index d25162d..0000000 --- a/OldStuff/GuiManager/Misc/disrespectHierarchy.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:disrespectHierarchy() - _GuiPro.Hierarchy=false -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getChildren.int b/OldStuff/GuiManager/Misc/getChildren.int deleted file mode 100644 index 295c5fc..0000000 --- a/OldStuff/GuiManager/Misc/getChildren.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:getChildren() - return self.Children -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getColor.int b/OldStuff/GuiManager/Misc/getColor.int deleted file mode 100644 index bef482e..0000000 --- a/OldStuff/GuiManager/Misc/getColor.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:getColor(cindex) - return Color[cindex] -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getFullSize.int b/OldStuff/GuiManager/Misc/getFullSize.int deleted file mode 100644 index 62c6221..0000000 --- a/OldStuff/GuiManager/Misc/getFullSize.int +++ /dev/null @@ -1,14 +0,0 @@ -function gui:getFullSize() - local maxx,maxy=self.width,self.height - local px,py=self.x,self.y - local temp = self:GetAllChildren() - for i=1,#temp do - if temp[i].width+temp[i].x>maxx then - maxx=temp[i].width+temp[i].x - end - if temp[i].height+temp[i].y>maxy then - maxy=temp[i].height+temp[i].y - end - end - return maxx,maxy,px,py -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getHighest.int b/OldStuff/GuiManager/Misc/getHighest.int deleted file mode 100644 index df7121a..0000000 --- a/OldStuff/GuiManager/Misc/getHighest.int +++ /dev/null @@ -1,5 +0,0 @@ -function gui:getHighest() - if self.Children[#self.Children]~=nil then - return self.Children[#self.Children] - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getLowest.int b/OldStuff/GuiManager/Misc/getLowest.int deleted file mode 100644 index 5319544..0000000 --- a/OldStuff/GuiManager/Misc/getLowest.int +++ /dev/null @@ -1,5 +0,0 @@ -function gui:getLowest() - if self.Children[1]~=nil then - return self.Children[1] - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/getTile.int b/OldStuff/GuiManager/Misc/getTile.int deleted file mode 100644 index 6b6fcae..0000000 --- a/OldStuff/GuiManager/Misc/getTile.int +++ /dev/null @@ -1,20 +0,0 @@ -function gui:getTile(i,x,y,w,h)-- returns imagedata - if type(i)=="string" then - i=love.graphics.newImage(i) - elseif type(i)=="userdata" then - -- do nothing - elseif string.find(self.Type,"Image",1,true) then - local i,x,y,w,h=self.Image,i,x,y,w - else - error("getTile invalid args!!! Usage: ImageElement:getTile(x,y,w,h) or gui:getTile(imagedata,x,y,w,h)") - end - local iw,ih=i:getDimensions() - local id,_id=i:getData(),love.image.newImageData(w,h) - for _x=x,w+x-1 do - for _y=y,h+y-1 do - -- - _id:setPixel(_x-x,_y-y,id:getPixel(_x,_y)) - end - end - return love.graphics.newImage(_id) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/isDescendant.int b/OldStuff/GuiManager/Misc/isDescendant.int deleted file mode 100644 index f004182..0000000 --- a/OldStuff/GuiManager/Misc/isDescendant.int +++ /dev/null @@ -1,9 +0,0 @@ -function gui:isDescendant(obj) - local things = obj:GetAllChildren() - for i=1,#things do - if things[i] == self then - return true - end - end - return false -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/isHighest.int b/OldStuff/GuiManager/Misc/isHighest.int deleted file mode 100644 index 0453c16..0000000 --- a/OldStuff/GuiManager/Misc/isHighest.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:isHighest() - return (self==self.Parent:getHighest()) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/isLowest.int b/OldStuff/GuiManager/Misc/isLowest.int deleted file mode 100644 index a210883..0000000 --- a/OldStuff/GuiManager/Misc/isLowest.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:isLowest() - return (self==self.Parent:getLowest()) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/massMutate.int b/OldStuff/GuiManager/Misc/massMutate.int deleted file mode 100644 index 1c75aee..0000000 --- a/OldStuff/GuiManager/Misc/massMutate.int +++ /dev/null @@ -1,6 +0,0 @@ -function gui.massMutate(t,...) - local mut={...} - for i=1,#mut do - mut[i]:Mutate(t) - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newCheckBox.int b/OldStuff/GuiManager/Misc/newCheckBox.int deleted file mode 100644 index 607d5d9..0000000 --- a/OldStuff/GuiManager/Misc/newCheckBox.int +++ /dev/null @@ -1,41 +0,0 @@ -if love.filesystem.getInfo("CheckBoxes.png") then - _GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16) - _GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16) - _GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16) - _GuiPro.CH=gui:getTile("CheckBoxes.png",16,16,16,16) -end -function gui:newCheckBox(name,x,y) - if not(_GuiPro.UC) then error("CheckBoxes.png not found! Cannot currently use checkbox without the data") end - if type(name)~="String" then - x,y,name=name,x,"CheckBox" - end - local c=self:newImageLabel(_GuiPro.UC,name, x, y, 16,16) - c.Visibility=0 - c.check=false - c:OnEnter(function(self) - if self.check then - self:SetImage(_GuiPro.CH) - else - self:SetImage(_GuiPro.UCH) - end - end) - function c:isChecked() - return self.check - end - c:OnExit(function(self) - if self.check then - self:SetImage(_GuiPro.C) - else - self:SetImage(_GuiPro.UC) - end - end) - c:OnReleased(function(b,self) - self.check=not(self.check) - if self.check then - self:SetImage(_GuiPro.CH) - else - self:SetImage(_GuiPro.UCH) - end - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newMessageBox.int b/OldStuff/GuiManager/Misc/newMessageBox.int deleted file mode 100644 index 6b11a5a..0000000 --- a/OldStuff/GuiManager/Misc/newMessageBox.int +++ /dev/null @@ -1,36 +0,0 @@ -function gui:newMessageBox(txt,x,y,w,h,sx,sy,sw,sh) - name="MessageBox" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("MessageBoxFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c.BorderSize=0 - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - local temp = c:newTextButton("X","Close",-25,5,20,20,1) - temp.Tween=-5 - temp.XTween=-2 - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - temp.Color=Color.Red - local temp=c:newTextButton("OK","Ok",0,h-65,0,30,.25,1,.5) - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcO do self.Parent.funcO[i](self.Parent) end end) - temp.Color=Color.Green - function c:Close() - self.Visible=false - end - function c:Open() - self.Visible=true - end - function c:OnOk(func) - table.insert(self.funcO,func) - end - function c:OnX(func) - table.insert(self.funcX,func) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newPart.int b/OldStuff/GuiManager/Misc/newPart.int deleted file mode 100644 index 79bd3e5..0000000 --- a/OldStuff/GuiManager/Misc/newPart.int +++ /dev/null @@ -1,49 +0,0 @@ -function gui:newPart(x, y,w ,h , sx ,sy ,sw ,sh) - local c = {} - setmetatable(c, gui) - if self==gui then - c.Parent=_GuiPro - else - c.Parent=self - end - c.funcs={} - c.funcs2={} - c.funcs3={} - c.funcs4={} - c.funcs5={} - c.func6={} - c.func7={} - c.func8={} - c.func9={} - c.func10={} - c.form="rectangle" - c.Color = {255, 255, 255} - c.scale={} - c.scale.size={} - c.scale.size.x=sw or 0 - c.scale.size.y=sh or 0 - c.offset={} - c.offset.size={} - c.offset.size.x=w or 0 - c.offset.size.y=h or 0 - c.scale.pos={} - c.scale.pos.x=sx or 0 - c.scale.pos.y=sy or 0 - c.offset.pos={} - c.offset.pos.x=x or 0 - c.offset.pos.y=y or 0 - c.VIS=true - c.Visible=true - c.Visibility=1 - c.BorderColor={0,0,0} - c.BorderSize=0 - c.Type="Part" - c.Name="GuiPart" - _GuiPro.count=_GuiPro.count+1 - c.x=(c.Parent.width*c.scale.pos.x)+c.offset.pos.x+c.Parent.x - c.y=(c.Parent.height*c.scale.pos.y)+c.offset.pos.y+c.Parent.y - c.width=(c.Parent.width*c.scale.size.x)+c.offset.size.x - c.height=(c.Parent.height*c.scale.size.y)+c.offset.size.y - table.insert(c.Parent.Children,c) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newProgressBar.int b/OldStuff/GuiManager/Misc/newProgressBar.int deleted file mode 100644 index 2f82f9f..0000000 --- a/OldStuff/GuiManager/Misc/newProgressBar.int +++ /dev/null @@ -1,45 +0,0 @@ -function gui:newProgressBar(txt,x,y,w,h,sx,sy,sw,sh) - name="newProgressBar" - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("newProgressBarFrame",name, x, y, w, 30, sx ,sy ,sw ,sh) - c.Draggable=true - c.dragbut="r" - c.BorderSize=0 - c:ApplyGradient{Color.Blue,Color.sexy_purple} - c:newTextLabel(txt,"Holder",0,0,0,h-30,0,1,1,0).Color=Color.sexy_purple - c.funcO={} - c.funcX={} - c:OnDragStart(function(self) - self:TopStack() - end) - local temp = c:newTextButton("X","Close",-25,5,20,20,1) - temp.Tween=-5 - temp.XTween=-2 - temp:OnReleased(function(b,self) for i=1,#self.Parent.funcX do self.Parent.funcX[i](self.Parent) end end) - temp.Color=Color.Red - c.BarBG=c:newTextButton("",5,h-65,-10,30,0,1,1) - c.BarBG:ApplyGradient{Color.Red,Color.light_red} - c.Bar=c.BarBG:newTextLabel("",0,0,0,0,0,0,0,1) - c.Bar:ApplyGradient{Color.Green,Color.light_green} - c.BarDisp=c.BarBG:newTextLabel("0%","0%",0,0,0,0,0,0,1,1) - c.BarDisp.Visibility=0 - c.BarDisp.Link=c.Bar - c.BarDisp:OnUpdate(function(self) - self.text=self.Link.scale.size.x*100 .."%" - end) - c.Func1={} - function c:On100(func) - table.insert(self.Func1,func) - end - c:OnUpdate(function(self) - if self.Bar.scale.size.x*100>=100 then - for P=1,#self.Func1 do - self.Func1[P](self) - end - end - end) - function c:SetPercentage(n) - self.Bar:SetDualDim(0,0,0,0,0,0,n/100,1) - end - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newScrollBar.int b/OldStuff/GuiManager/Misc/newScrollBar.int deleted file mode 100644 index 6fa810a..0000000 --- a/OldStuff/GuiManager/Misc/newScrollBar.int +++ /dev/null @@ -1,42 +0,0 @@ -function gui:newScrollBar(color1,color2) - local scrollbar=self:newFrame(-20,0,20,0,1,0,0,1) - scrollbar.funcS={} - scrollbar.Color=color1 or Color.saddle_brown - scrollbar:OnClicked(function(b,self,x,y) - love.mouse.setX(self.x+10) - if y>=10 and y<=self.height-10 then - self.mover:SetDualDim(0,y-10) - end - if y<10 then - love.mouse.setY(10+self.y) - end - if y>self.height-10 then - love.mouse.setY((self.height-10)+self.y) - end - for i=1,#self.funcS do - self.funcS[i](self,self:getPosition()) - end - end) - scrollbar:OnEnter(function(self) - self:addDominance() - end) - scrollbar:OnExit(function(self) - self:removeDominance() - end) - scrollbar.mover=scrollbar:newTextButton("","",0,0,20,20) - scrollbar.mover.Color=color2 or Color.light_brown - function scrollbar:getPosition() - return ((self.mover.offset.pos.y)/(self.height-20))*100 - end - function scrollbar:setPosition(n) - print((self.height-20),n) - self.mover.offset.pos.y=((self.height-20)/(100/n)) - for i=1,#self.funcS do - self.funcS[i](self,self:getPosition()) - end - end - function scrollbar:OnScroll(func) - table.insert(self.funcS,func) - end - return scrollbar -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Misc/newScrollMenu.int b/OldStuff/GuiManager/Misc/newScrollMenu.int deleted file mode 100644 index f7ee5ac..0000000 --- a/OldStuff/GuiManager/Misc/newScrollMenu.int +++ /dev/null @@ -1,81 +0,0 @@ -function gui:newScrollMenu(name) - local temp = self:newFullFrame(name) - temp.ref = { - [[setNewFont(16)]], - [[setRoundness(10,10,180)]], - Tween = 6 - } - temp.allowOverlapping = true - temp.Visibility = 0 - local ScrollY = temp:newFrame(name.."ScrollY",-20,0,20,0,1,0,0,1) - temp.scroll = ScrollY - ScrollY.Color=Color.new(80,80,80) - ScrollY.allowOverlapping = true - ScrollY.Mover = ScrollY:newFrame(name.."MoverY",5,5,10,80) - ScrollY.Mover.Color = Color.new(60,60,60) - local func = function(b,self,x,y,nn) - temp.symbolicY = y - if y>45 and yScrollY.height-40 then - temp.symbolicY = ScrollY.height-40 - end - func("l",ScrollY,x,temp.symbolicY,true) - end) - temp.ClipDescendants=true - temp.first = temp:newTextLabel("","",15,10,-50,40,0,0,1) - local nice = temp:newTextLabel(name,name,15,10,-50,40,0,0,1) - temp.header = nice - temp.last = temp.first - temp.last.BorderSize = 0 - temp.last.Visibility = 0 - nice:setNewFont(26) - nice.Tween = 6 - temp.list = {} - local alarm - multi:newLoop(function() - for i=1,#temp.list do - local val = (temp.first.y+(temp.list[i].staticpos)+10) - if val>temp.y and val self.x+width then - curpos = #hiddenText+1 - elseif x < self.x then - curpos = 1 - else - for i = 1,#hiddenText do - width = self.Font:getWidth(self.text:sub(1,i)) - if x-self.x < width then - curpos = i - break - end - end - end - end) - c:OnPressedOuter(function(b,self) - if Focused then - self:unfocus() - end - end) - c:OnUpdate(function(self) - if #hiddenText==0 then self.text = "" return end - if self.hideText then - self.text = table.concat(hiddenText) - else - self.text = table.concat(realText) - end - self.TextFormat = "left" - end) - multi.OnTextInput(function(t) - table.insert(hiddenText,curpos,"*") - table.insert(realText,curpos,t) - curpos = curpos + 1 - if autoScaleFont then - c:fitFont() - end - end) - multi.OnKeyPressed(function(key, scancode, isrepeat ) - if key == "backspace" then - table.remove(hiddenText,curpos-1) - table.remove(realText,curpos-1) - curpos = curpos - 1 - if curpos < 1 then - curpos = 1 - end - if autoScaleFont then - c:fitFont() - end - elseif key == "enter" then - - elseif key == "delete" then - realText = {} - hiddenText = {} - curpos = 1 - elseif key == "left" then - curpos = curpos - 1 - if curpos < 1 then - curpos = 1 - end - moved = true - alarm:Reset() - elseif key == "right" then - curpos = curpos + 1 - if curpos > #realText+1 then - curpos = #realText+1 - end - moved = true - alarm:Reset() - end - end) - local blink = false - multi:newThread("TextCursonBlinker",function() - while true do - thread.sleep(1.5) - blink = not blink - end - end) - self.DrawRulesE = {function() - if --[[blink or moved]] true then - local width = c.Font:getWidth(c.text:sub(1,curpos-1)) - local height = c.Font:getHeight() - if c.TextFormat == "center" then - -- print(c.x+(c.width/2+width),c.height,c.x+(c.width/2+width),c.height+height) - -- love.graphics.line(c.x+(c.width/2+width),c.height,c.x+(c.width/2+width),c.height+height) - elseif c.TextFormat == "right" then - --love.graphics.line(c.x+width,c.y,c.x+width,c.y+c.Font:getHeight()) - elseif c.TextFormat == "left" then - love.graphics.line(c.x+width,c.y,c.x+width,c.y+height) - end - end - end} - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/newTextButton.int b/OldStuff/GuiManager/Text/newTextButton.int deleted file mode 100644 index be43ef0..0000000 --- a/OldStuff/GuiManager/Text/newTextButton.int +++ /dev/null @@ -1,11 +0,0 @@ -function gui:newTextButton(t,name, x, y, w, h, sx ,sy ,sw ,sh) - local x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newTextBase("TextButton",t,name, x, y, w, h, sx ,sy ,sw ,sh) - c:OnMouseEnter(function() - love.mouse.setCursor(_GuiPro.CursorH) - end) - c:OnMouseExit(function() - love.mouse.setCursor(_GuiPro.CursorN) - end) - return c -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/newTextLabel.int b/OldStuff/GuiManager/Text/newTextLabel.int deleted file mode 100644 index 679224d..0000000 --- a/OldStuff/GuiManager/Text/newTextLabel.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:newTextLabel(t,name, x, y, w, h, sx ,sy ,sw ,sh) - local x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - return self:newTextBase("TextLabel",t,name, x, y, w, h, sx ,sy ,sw ,sh) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/setDefualtFont.int b/OldStuff/GuiManager/Text/setDefualtFont.int deleted file mode 100644 index 001b9f7..0000000 --- a/OldStuff/GuiManager/Text/setDefualtFont.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:setDefualtFont(font) - _defaultfont = font -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/setNewFont.int b/OldStuff/GuiManager/Text/setNewFont.int deleted file mode 100644 index 9b0c840..0000000 --- a/OldStuff/GuiManager/Text/setNewFont.int +++ /dev/null @@ -1,9 +0,0 @@ -function gui:setNewFont(filename,FontSize) - if type(filename)=="string" then - self.FontFile = filename - self.Font = love.graphics.newFont(filename, tonumber(FontSize)) - else - self.Font=love.graphics.newFont(tonumber(filename)) - end - self.Font:setFilter("linear","nearest",4) -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/setgetText.int b/OldStuff/GuiManager/Text/setgetText.int deleted file mode 100644 index bb4afc6..0000000 --- a/OldStuff/GuiManager/Text/setgetText.int +++ /dev/null @@ -1,6 +0,0 @@ -function gui:setText(txt) - self.text=txt -end -function gui:getText(txt) - return self.text -end \ No newline at end of file diff --git a/OldStuff/GuiManager/Text/widthToTextSize.int b/OldStuff/GuiManager/Text/widthToTextSize.int deleted file mode 100644 index a36b6dc..0000000 --- a/OldStuff/GuiManager/Text/widthToTextSize.int +++ /dev/null @@ -1,5 +0,0 @@ -function gui:widthToTextSize(n) - if self.Font then - self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0) - end -end \ No newline at end of file diff --git a/OldStuff/GuiManager/init.lua b/OldStuff/GuiManager/init.lua deleted file mode 100644 index a1d65f0..0000000 --- a/OldStuff/GuiManager/init.lua +++ /dev/null @@ -1,82 +0,0 @@ -local multi = require("multi") -local GLOBAL,THREAD=require("multi.integration.loveManager").init() -local p = print -print = multi.print --- automatic resource loading will be added soonish -utf8 = require("utf8") -gui = {} -gui.__index = gui -gui.TB={} -gui.Version="VERSION" -- Is it really ready for release? -_GuiPro={ - GLOBAL = GLOBAL, - THREAD = THREAD, - jobqueue = multi:newSystemThreadedJobQueue("ImageJobQueue"), - imagecache = {}, - GBoost=true, - hasDrag=false, - DragItem={}, - Children={}, - Visible=true, - count=0, - x=0, - y=0, - height=0, - width=0, - 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.getInfo(file..add) then - a,b=pcall(love.filesystem.load(file..add)) - if a then - --print("Loaded: "..file) - else - print("Error loading file: "..file,b) - end - else - print("File does not exist!") - return false - end -end -function gui.LoadAll(dir) - files=love.filesystem.getDirectoryItems(dir) - for i=1,#files do - if string.sub(files[i],-4)==".int" then - gui:LoadInterface(dir.."/"..files[i]) - end - end -end --- Start Of Load - -gui.LoadAll("GuiManager/Core") -gui.LoadAll("GuiManager/Image-Animation") -gui.LoadAll("GuiManager/Frame") -gui.LoadAll("GuiManager/Item") -gui.LoadAll("GuiManager/Misc") -gui.LoadAll("GuiManager/Text") -gui.LoadAll("GuiManager/Drawing") - --- End of Load -gui:respectHierarchy() -_GuiPro.width,_GuiPro.height=love.graphics.getDimensions() -multi:newLoop(function() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() end):setName("gui.mainUpdater") -multi:onDraw(function() - local items=GetAllChildren(_GuiPro) - for i=1,#items do - items[i]:draw() - end -end) -gui.ff=gui:newFrame("",0,0,0,0,0,0,1,1) -gui.ff.Color={0,0,0} -gui.ff:OnUpdate(function(self) - self:BottomStack() -end) -print = p diff --git a/OldStuff/Utils.lua b/OldStuff/Utils.lua deleted file mode 100644 index 5f97d52..0000000 --- a/OldStuff/Utils.lua +++ /dev/null @@ -1,770 +0,0 @@ --- os Additions -function os.getSystemBit() - if (os.getenv("PROCESSOR_ARCHITEW6432")=="AMD64" or os.getenv("PROCESSOR_ARCHITECTURE")=="AMD64") then - return 64 - else - return 32 - end -end -function os.sleep(n) - if not n then n=0 end - local t0 = os.clock() - while os.clock() - t0 <= n do end -end -function os.pause(msg) - if msg ~= nil then - print(msg) - end - io.read() -end -function os.batCmd(cmd) - io.mkFile("temp.bat",cmd) - local temp = os.execute([[temp.bat]]) - io.delFile("temp.bat") - return temp -end -function os._getOS() - if package.config:sub(1,1)=="\\" then - return "windows" - else - return "unix" - end -end -function os.getOS(t) - if not t then - return os._getOS() - end - if os._getOS()=="unix" then - fh,err = io.popen("uname -o 2>/dev/null","r") - if fh then - osname = fh:read() - end - if osname then return osname end - end - local winver="'Unknown Version'" - local a,b,c=os.capture("ver"):match("(%d+).(%d+).(%d+)") - local win=a.."."..b.."."..c - if type(t)=="string" then - win=t - end - if win=="4.00.950" then - winver="95" - elseif win=="4.00.1111" then - winver="95 OSR2" - elseif win=="4.00.1381" then - winver="NT 4.0" - elseif win=="4.10.1998" then - winver="98" - elseif win=="4.10.2222" then - winver="98 SE" - elseif win=="4.90.3000" then - winver="ME" - elseif win=="5.00.2195" then - winver="2000" - elseif win=="5.1.2600" then - winver="XP" - elseif win=="5.2.3790" then - winver="Server 2003" - elseif win=="6.0.6000" then - winver="Vista/Windows Server 2008" - elseif win=="6.0.6002" then - winver="Vista SP2" - elseif win=="6.1.7600" then - winver="7/Windows Server 2008 R2" - elseif win=="6.1.7601" then - winver="7 SP1/Windows Server 2008 R2 SP1" - elseif win=="6.2.9200" then - winver="8/Windows Server 2012" - elseif win=="6.3.9600" then - winver="8.1/Windows Server 2012" - elseif win=="6.4.9841" then - winver="10 Technical Preview 1" - elseif win=="6.4.9860" then - winver="10 Technical Preview 2" - elseif win=="6.4.9879" then - winver="10 Technical Preview 3" - elseif win=="10.0.9926" then - winver="10 Technical Preview 4" - end - return "Windows "..winver -end -function os.getLuaArch() - return (#tostring({})-7)*4 -end -if os.getOS()=="windows" then - function os.sleep(n) - if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end - end -else - function os.sleep(n) - os.execute("sleep " .. tonumber(n)) - end -end -function os.capture(cmd, raw) - local f = assert(io.popen(cmd, 'r')) - local s = assert(f:read('*a')) - f:close() - if raw then return s end - s = string.gsub(s, '^%s+', '') - s = string.gsub(s, '%s+$', '') - s = string.gsub(s, '[\n\r]+', ' ') - return s -end -function os.getCurrentUser() - return os.getenv("$USER") or os.getenv("USERNAME") -end --- string Additions -function string.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 olleh -nil = binobj:flipbits() -- flips the binary bits -nil** = binobj:segment(a,b) -- gets a segment of the binobj data works just like string.sub(a,b) without str -nil* = binobj:insert(a,i) -- inserts i (string or number(converts into string)) in position a -nil* = binobj:parseN(n) -- removes ever (nth) byte of data -nil = binobj:getlength() -- gets length or size of binary data -nil* = binobj:shift(n) -- shift the binary data by n positive --> negitive <-- -nil* = binobj:delete(a,b) -- deletes part of a binobj data Usage: binobj:delete(#) deletes at pos # binobj:delete(#1,#2) deletes from #1 to #2 binobj:delete("string") deletes all instances of "byte" as a string Use string.char(#) or "\#" to get byte as a string -nil* = binobj:encrypt(seed) -- encrypts data using a seed, seed may be left blank -nil* = binobj:decrypt(seed) -- decrypts data encrypted with encrypt(seed) -nil* = binobj:shuffle() -- Shuffles the data randomly Note: there is no way to get it back!!! If original is needed clone beforehand -nil** = binobj:mutate(a,i) -- changes position a's value to i -nil = binobj:merge(o,t) -- o is the binobj you are merging if t is true it merges the new data to the left of the binobj EX: b:merge(o,true) b="yo" o="data" output: b="datayo" b:merge(o) b="yo" o="data" output: b="yodata" -nil* = binobj:parseA(n,a,t) -- n is every byte where you add, a is the data you are adding, t is true or false true before false after -nil = binobj:getHEX(a,b) -- returns the HEX of the bytes between a,b inclusive -nil = binobj:cryptM() -- a mirrorable encryptor/decryptor -nil = binobj:addBlock(d,n) -- adds a block of data to a binobj s is size d is data e is a bool if true then encrypts string values. if data is larger than 'n' then data is lost. n is the size of bytes the data is Note: n is no longer needed but you must use getBlock(type) to get it back -nil = binobj:getBlock(t,n) -- gets block of code by type -nil = binobj:seek(n) -- used with getBlock EX below with all 3 -nil* = binobj:morph(a,b,d) -- changes data between point a and b inclusive to d -nil = binobj:fill(n,d) -- fills binobj with data "d" for n -nil = binobj:fillrandom(n) -- fills binobj with random data for n -nil = binobj:shiftbits(n) -- shifts all bits by n amount -nil = binobj:shiftbit(n,i) -- shifts a bit ai index i by n -nil# = binobj:streamwrite(d,n) -- writes to the streamable binobj d data n position -nil# = binobj:open() -- opens the streamable binobj -nil# = binobj:close() -- closes the streamable binobj -nil# = binobj:wipe() -- erases all data in the file -nil* = binobj:tackB(d) -- adds data to the beginning of a file -nil = binobj:tackE(d) -- adds data to the end of a file -nil = binobj:parse(n,f) -- loops through each byte calling function 'f' with the args(i,binobj,data at i) -nil = binobj:flipbit(i) -- flips the binary bit at position i -nil* = binobj:gsub() -- just like string:gsub(), but mutates self - -numbers are written in Little-endian use bin.endianflop(d) to filp to Big-endian - -Note: binobj:tonumber() returns little,big so if printing do: l,b=binobj:tonumber() print(l) print(b) - -nil = bitobj:add(i) -- adds i to the bitobj i can be a number (base 10) or a bitobj -nil = bitobj:sub(i) -- subs i to the bitobj i can be a number (base 10) or a bitobj -nil = bitobj:multi(i) -- multiplys i to the bitobj i can be a number (base 10) or a bitobj -nil = bitobj:div(i) -- divides i to the bitobj i can be a number (base 10) or a bitobj -nil = bitobj:flipbits() -- filps the bits 1 --> 0, 0 --> 1 -string = bitobj:getBin() -- returns 1's & 0's of the bitobj - -# stream objects only -* not compatible with stream files -** works but do not use with large files or it works to some degree -*** all changes are made directly to the file no need to do tofile() -]] -bin.Changelog=[[ -Version.Major.Minor -------------------------- -1.0.0 : initial release load/new/tofile/clone/closeto/compare/sub/reverse/flip/segment/insert/insert/parseN/getlength/shift -1.0.1 : update Delete/tonumber/getbyte/ -1.0.2 : update Changed how delete works. Added encrypt/decrypt/shuffle -1.0.3 : update Added bits class, Added in bin: tobit/mutate/parseA Added in bits: add/sub/multi/div/isover/tobyte/tonumber/flip -1.0.4 : update Changed tobyte() to tobytes()/flipbit() to flipbits() and it now returns a binobj not str Added bin:merge -1.0.5 : update Changed bin.new() now hex data can be inserted EX: bin.new("0xFFC353D") Added in bin: getHEX/cryptM/addBlock/getBlock/seek -1.0.6 : update Added bin.NumtoHEX/bin:getHEX/bin.HEXtoBin/bin.HEXtoStr/bin.tohex/bin.fromhex -1.0.7 : update Added bin:morph/bin.endianflop/bin:scan/bin.ToStr -1.0.8 : update Added bin:fill/bin:fillrandom -1.1.0 : update Added bin.packLLIB/bin.unpackLLIB -1.2.0 : update Updated llib files -1.3.0 : Update Changed bin.unpackLLIB and bin.load() Added: bin.fileExist -1.4.0 : Update Changed bin.unpackLLIB bin.packLLIB Added: bin:shiftbits(n) bin:shiftbit(n,i) - -Woot!!! Version 2 -2.0.0 HUGE UPDATE Added Streamable files!!! lua 5.1, 5.2 and 5.3 compatable!!! -#binobj is the same as binobj:getlength() but only works in 5.2 in 5.1 just use getlength() for compatibility -Now you can work with gigabyte sized data without memory crashes(streamable files[WIP]). - -Stream Compatible methods: - sub(a,b) - getlength() - tofile(filename) - flipbits() - tonumber(a,b) - getbyte(n) - segment(a,b) - parse(n,f) - tobits(i) - reverse() - flipbit(i) - cryptM() - getBlock(t,n) - addBlock(d,n) - shiftbits(n) - shiftbit(n,i) - getHEX(a,b) - -Added functions in this version: - binobj:streamwrite(d,n) - binobj:open() - binobj:close() - binobj:tackB(d) - binobj:tackE(d) - binobj:parse(n,f) - binobj:flipbit(i) - bin.stream(file) - binobj:streamData(a,b) - bin.getVersion() - bin.escapeStr(str) - binobj:streamread(a,b) - binobj:canStreamWrite() - binobj:wipe() - -Woot!!! Version 3 -3.0.0 HUGE UPDATE!!! - Added: bin.newVFS() bin.loadVFS() bin.textToBinary(txt) bin.decodeBits(bindata) bitobj:getBin() - Updated: bin.addBlock() <-- Fixed error with added features to the bits.new() function that allow for new functions to work - Notice: The bin library now requires the utils library!!! Put utils.lua in the lua/ directory - -3.1.0 - Added: bin.newTempFile(data) binobj:setEndOfFile(n) bin.randomName(n,ext) - Updated: bin:tackE() bin:fill() bin:fillrandom() are now stream compatible! - Notic: bin:setEndOfFile() only works on streamable files! -3.1.1 - Added: bin.trimNul(s) bin:gsub() -3.1.2 - Added: log(data,name,fmt) - - In secret something is brewing... -]] -bin.data="" -bin.t="bin" -bin.__index = bin -bin.__tostring=function(self) return self.data end -bin.__len=function(self) return self:getlength() end -bits={} -bits.data="" -bits.t="bits" -bits.__index = bits -bits.__tostring=function(self) return self.data end -bits.__len=function(self) return (#self.data)/8 end ---[[---------------------------------------- -MISC -------------------------------------------]] -function log(data,name,fmt) - if not bin.logger then - bin.logger = bin.stream(name or "lua.log",false) - elseif bin.logger and name then - bin.logger:close() - bin.logger = bin.stream(name or "lua.log",false) - end - local d=os.date("*t",os.time()) - bin.logger:tackE((fmt or "["..math.numfix(d.month,2).."-"..math.numfix(d.day,2).."-"..d.year.."|"..math.numfix(d.hour,2)..":"..math.numfix(d.min,2)..":"..math.numfix(d.sec,2).."]\t")..data.."\n") -end ---[[---------------------------------------- -BIN -------------------------------------------]] -function bin.getVersion() - return bin.Version[1].."."..bin.Version[2].."."..bin.Version[3] -end ---[[function bin:gsub(...) - return self.data:gsub(...) -end -function bin:find(...) - return self.data:find(...) -end]] -function bin:gsub(...) - self.data=self.data:gsub(...) -end -function bin:find(...) - self.data=self.data:find(...) -end -function bin.fromhex(str) - return (str:gsub('..', function (cc) - return string.char(tonumber(cc, 16)) - end)) -end -if table.unpack==nil then - table.unpack=unpack -end -function bin.tohex(str) - return (str:gsub('.', function (c) - return string.format('%02X', string.byte(c)) - end)) -end -function bin:streamData(a,b) - if type(a)=="table" then - a,b,t=table.unpack(a) - end - if type(a)=="number" and type(b)=="string" then - return bin.load(self.file,a,b),bin.load(self.file,a,b).data - else - error("Invalid args!!! Is do you have a valid stream handle or is this a streamable object?") - end -end -function bin.new(data) - data=tostring(data) - local c = {} - setmetatable(c, bin) - data=data or "" - if string.sub(data,1,2)=="0x" then - data=string.sub(data,3) - data=bin.fromhex(data) - end - c.data=data - c.t="bin" - c.Stream=false - return c -end -function bin.stream(file,l) - local c=bin.new() - if bin.fileExist(file) then - c.file=file - c.lock = l - c.workingfile=io.open(file,"r+") - else - c.file=file - c.lock = l - c.workingfile=io.open(file,"w") - io.close(c.workingfile) - c.workingfile=io.open(file,"r+") - end - c.Stream=true - return c -end -function bin:streamwrite(d,n) - if self:canStreamWrite() then - if n then - self.workingfile:seek("set",n) - else - self.workingfile:seek("set",self.workingfile:seek("end")) - end - self.workingfile:write(d) - end -end -function bin:streamread(a,b) - a=tonumber(a) - b=tostring(b) - return bin.load(self.file,a,b).data -end -function bin:close() - if self:canStreamWrite() then - self.workingfile:close() - end -end -function bin:open() - if self:canStreamWrite() then - self.workingfile=io.open(self.file,"r+") - end -end -function bin:canStreamWrite() - return (self.Stream==true and self.lock==false) -end -function bin.load(file,s,r) - if not(s) or not(r) then - local f = io.open(file, "rb") - local content = f:read("*a") - f:close() - return bin.new(content) - end - s=s or 0 - r=r or -1 - if type(r)=="number" then - r=r+s-1 - elseif type(r)=="string" then - r=tonumber(r) or -1 - end - local f = io.open(file, "rb") - f:seek("set",s) - local content = f:read((r+1)-s) - f:close() - return bin.new(content) -end -function bin:tofile(filename) - if not(filename) or self.Stream then return nil end - io.mkFile(filename,self.data) -end -function bin.trimNul(s) - for i=1,#s do - if s:sub(i,i)=="\0" then - return s:sub(1,i-1) - end - end - return s -end -function bin:match(pat) - return self.data:match(pat) -end -function bin:gmatch(pat) - return self.data:gmatch(pat) -end -function bin.randomName(n,ext) - n=n or math.random(7,15) - if ext then - a,b=ext:find(".",1,true) - if a and b then - ext=ext:sub(2) - end - end - local str,h = "",0 - 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.."."..(ext or "tmp") -end -function bin.newTempFile(data) - data=data or "" - local name=bin.randomName() - bin.new():tofile(name) - local tempfile=bin.stream(name,false) - tempfile:streamwrite(data,0) - tempfile:setEndOfFile(#data) - return tempfile -end -function bin:wipe() - if self:canStreamWrite() then - os.remove(self.file) - else - self.data="" - end -end -function bin:setEndOfFile(n) - if self:canStreamWrite() then - local name=bin.randomName() - local tempfile=bin.stream(name,false) - tempfile:streamwrite(self:sub(0,n-1)) - self:close() - os.remove(self.file) - tempfile:close() - os.rename(name,self.file) - self:open() - tempfile=nil - else - self.data=self.data:sub(1,n) - end -end -function bin:reverse() - if self:canStreamWrite() then - local x,f,b=self:getlength(),0,0 - for i=0,math.floor((x-1)/2) do - self:streamwrite(self:sub(i+1,i+1),x-i-1) - self:streamwrite(self:sub(x-i,x-i),i) - end - elseif self.Stream==false then - self.data=string.reverse(self.data) - end -end -function bin:flipbits() - if self:canStreamWrite() then - for i=0,self:getlength()-1 do - self:streamwrite(string.char(255-string.byte(self:streamread(i,i))),i) - end - elseif self.Stream==false then - local temp={} - for i=1,#self.data do - table.insert(temp,string.char(255-string.byte(string.sub(self.data,i,i)))) - end - self.data=table.concat(temp,"") - end -end -function bin:flipbit(i) - if self:canStreamWrite() then - self:streamwrite(string.char(255-string.byte(self:streamread(i-1,i-1))),i-1) - elseif self.Stream==false then - self:mutate(string.char(255-string.byte(string.sub(self.data,i,i))),i) - end -end -function bin:segment(a,b) -- needs to be updated!!! - if self:canStreamWrite() then - --[[local pos=1 - for i=a,b do - self:streamwrite(self:sub(i,i),b-a-i) - end]] - local temp=self:sub(a,b) - self:close() - local f=io.open(self.file,"w") - f:write(temp) - io.close(f) - self:open() - elseif self.Stream==false then - self.data=string.sub(self.data,a,b) - end -end -function bin:insert(i,a) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - if type(i)=="number" then i=string.char(i) end - self.data=string.sub(self.data,1,a)..i..string.sub(self.data,a+1) - end -end -function bin:parseN(n) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - local temp={} - for i=1,#self.data do - if i%n==0 then - table.insert(temp,string.sub(self.data,i,i)) - end - end - self.data=table.concat(temp,"") - end -end -function bin:parse(n,f) - local f = f - local n=n or 1 - if not(f) then return end - for i=1,self:getlength() do - if i%n==0 then - f(i,self,self:sub(i,i)) - end - end -end -function bin.copy(file,tofile,s) - if not(s) then - bin.load(file):tofile(tofile) - else - rf=bin.stream(file) - wf=bin.stream(tofile,false) - for i=1,rf:getlength(),s do - wf:streamwrite(rf:sub(i,i-1+s)) - end - end -end -function bin:getlength() - if self.Stream then - local current = self.workingfile:seek() -- get current position - local size = self.workingfile:seek("end") -- get file size - self.workingfile:seek("set", current) -- restore position - return size - elseif self.Stream==false then - return #self.data - end -end -function bin:sub(a,b) - if self.Stream then - return bin.load(self.file,a-1,tostring(b-1)).data - elseif self.Stream==false then - return string.sub(self.data,a,b) - end -end -function bin:tackB(d) - if self:canStreamWrite() then - -- do something don't know if possible - elseif self.Stream==false then - self.data=d..self.data - end -end -function bin:tackE(d) - if type(d)=="table" then - if d:canStreamWrite() then - d=d:sub(0,d:getlength()) - else - d=d.data - end - end - if self:canStreamWrite() then - self:streamwrite(d) - elseif self.Stream==false then - self.data=self.data..d - end -end -function bin:clone(filename) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - return bin.new(self.data) - end -end -function bin.closeto(a,b,v) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - if type(a)~=type(b) then - error("Attempt to compare unlike types") - elseif type(a)=="number" and type(b)=="number" then - return math.abs(a-b)<=v - elseif type(a)=="table" and type(b)=="table" then - if a.data and b.data then - return (math.abs(string.byte(a.data)-string.byte(b.data)))<=v - else - error("Attempt to compare non-bin data") - end - elseif type(a)=="string" and type(b)=="string" then - return math.abs(string.byte(a)-string.byte(b))<=v - else - error("Attempt to compare non-bin data") - end - end -end -function bin:compare(_bin,t) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - t=t or 1 - local tab={} - local a,b=self:getlength(),_bin:getlength() - if not(a==b) then - print("Unequal Lengths!!! Equalizing...") - if a>b then - _bin.data=_bin.data..string.rep(string.char(0),a-b) - else - self.data=self.data..string.rep(string.char(0),b-a) - end - end - if t==1 then - for i=1,self:getlength() do - table.insert(tab,self:sub(i,i)==_bin:sub(i,i)) - end - else - for i=1,self:getlength() do - table.insert(tab,bin.closeto(self:sub(i,i),_bin:sub(i,i),t)) - end - end - local temp=0 - for i=1,#tab do - if tab[i]==true then - temp=temp+1 - end - end - return (temp/#tab)*100 - end -end -function bin:shift(n) - if self:canStreamWrite() then - local a,b,x,p="","",self:getlength(),0 - for i=1,x do - if i+n>x then - p=(i+n)-(x) - else - p=i+n - end - end - elseif self.Stream==false then - n=n or 0 - local s=#self.data - if n>0 then - self.data = string.sub(self.data,s-n+1)..string.sub(self.data,1,s-n) - elseif n<0 then - n=math.abs(n) - self.data = string.sub(self.data,n+1)..string.sub(self.data,1,n*1) - end - end -end -function bin:delete(a,b) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - if type(a)=="string" then - local tab={} - for i=1,self:getlength() do - if self:getbyte(i)~=string.byte(a) then - table.insert(tab,self:sub(i,i)) - end - end - self.data=table.concat(tab) - elseif a and not(b) then - self.data=self:sub(1,a-1)..self:sub(a+1) - elseif a and b then - self.data=self:sub(1,a-1)..self:sub(b+1) - else - self.data="" - end - end -end -function bin:tonumber(a,b) - local temp={} - if a then - temp.data=self:sub(a,b) - else - temp=self - end - local l,r=0,0 - local g=#temp.data - for i=1,g do - r=r+(256^(g)-i)*string.byte(string.sub(temp.data,i,i)) - l=l+(256^(i-1))*string.byte(string.sub(temp.data,i,i)) - end - return l,r -end -function bin:getbyte(n) - return string.byte(self:sub(n,n)) -end -function bin:encrypt(s) - if self:canStreamWrite() then - s=tonumber(s) or 4546 - math.randomseed(s) - self:shift(math.random(1,self:getlength())) - self:flipbits() - elseif self.Stream==false then - s=tonumber(s) or 4546 - math.randomseed(s) - self:shift(math.random(1,self:getlength())) - self:flipbits() - end -end -function bin:decrypt(s) - if self:canStreamWrite() then - s=tonumber(s) or 4546 - math.randomseed(s) - self:flipbits() - self:shift(-math.random(1,self:getlength())) - elseif self.Stream==false then - s=tonumber(s) or 4546 - math.randomseed(s) - self:flipbits() - self:shift(-math.random(1,self:getlength())) - end -end -function bin:shuffle(s) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - s=tonumber(s) or 4546 - math.randomseed(s) - local t={} - for i=1,self:getlength() do - table.insert(t,self:sub(i,i)) - end - local n = #t - while n >= 2 do - local k = math.random(n) - t[n], t[k] = t[k], t[n] - n = n - 1 - end - self.data=table.concat(t) - end -end -function bin:tobits(i) - return bits.new(self:getbyte(i)) -end -function bin:mutate(a,i) - if self:canStreamWrite() then - self:streamwrite(a,i-1) - elseif self.Stream==false then - self:delete(i) - self:insert(a,i-1) - end -end -function bin:parseA(n,a,t) - if self:canStreamWrite() then - -- do something - elseif self.Stream==false then - local temp={} - for i=1,#self.data do - if i%n==0 then - if t then - table.insert(temp,a) - table.insert(temp,string.sub(self.data,i,i)) - else - table.insert(temp,string.sub(self.data,i,i)) - table.insert(temp,a) - end - else - table.insert(temp,string.sub(self.data,i,i)) - end - end - self.data=table.concat(temp,"") - end -end -function bin:merge(o,t) - if self:canStreamWrite() then - self:close() - self.workingfile=io.open(self.file,"a+") - self.workingfile:write(o.data) - self:close() - self:open() - elseif self.Stream==false then - if not(t) then - self.data=self.data..o.data - else - seld.data=o.data..self.data - end - end -end -function bin:cryptM() - self:flipbits() - self:reverse() -end -function bin.escapeStr(str) - local temp="" - for i=1,#str do - temp=temp.."\\"..string.byte(string.sub(str,i,i)) - end - return temp -end -function bin.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" then - dat=dat..i..bin.ToStr(v).."," - elseif type(v)=="function" then - dat=dat..i.."assert(loadstring(\""..bin.escapeStr(string.dump(v)).."\"))," - end - end - return string.sub(dat,1,-2).."}" -end -function bin:addBlock(d,n,e) - local temp={} - if type(d)=="table" then - if d.t=="bin" then - temp=d - elseif d.t=="bit" then - temp=bin.new(d:tobytes()) - else - self:addBlock("return "..bin.ToStr(d)) - return - end - elseif type(d)=="string" then - temp=bin.new(d) - if e or not(n) then - temp.data=temp.data.."_EOF" - temp:flipbits() - end - elseif type(d)=="function" then - temp=bin.new(string.dump(d)) - if e or not(n) then - temp.data=temp.data.."_EOF" - temp:flipbits() - end - elseif type(d)=="number" then - local nn=tostring(d) - if nn:find(".",1,true) then - temp=bin.new(nn) - temp.data=temp.data.."_EOF" - temp:flipbits() - else - temp=bits.new(d):tobytes() - if not n then - temp.data=temp.data.."_EOF" - temp:flipbits() - end - end - elseif type(d)=="boolean" then - n=1 - if d then - temp=bits.new(math.random(0,127)):tobytes() - else - temp=bits.new(math.random(128,255)):tobytes() - end - end - if n then - if temp:getlength()n then - temp:segment(1,n) - end - end - self:merge(temp) -end -function bin:getBlock(t,n) - if not(self.Block) then - self.Block=1 - end - local x=self.Block - local temp=bin.new() - if n then - temp=bin.new(self:sub(x,x+n-1)) - self.Block=self.Block+n - end - if t=="stringe" or t=="stre" or t=="se" and n then - temp:flipbits() - return temp.data - elseif t=="string" or t=="str" or t=="s" and n then - return temp.data - elseif t=="number" or t=="num" or t=="n" and n then - return self:tonumber(x,x+n-1) - elseif t=="boolean" or t=="bool" or t=="b" then - self.Block=self.Block+1 - return self:tonumber(x,x)<127 - elseif t=="stringe" or t=="stre" or t=="se" or t=="string" or t=="str" or t=="s" then - local a,b=self:scan("_EOF",self.Block,true) - if not(b) then return nil end - local t=bin.new(self:sub(self.Block,b-4)) - t:flipbits() - self.Block=self.Block+t:getlength()+4 - return tostring(t) - elseif t=="table" or t=="tab" or t=="t" then - temp=self:getBlock("s") - if temp=="return }" then - return {} - end - return assert(loadstring(temp))() - elseif t=="function" or t=="func" or t=="f" then - return assert(loadstring(self:getBlock("s"))) - elseif t=="number" or t=="num" or t=="n" then - local num=bin.new(self:getBlock("s")) - if tonumber(num.data) then - return tonumber(num.data) - end - local a,b=num:tonumber() - return a - elseif n then - -- C data - else - print("Invalid Args!!!") - end -end -function bin:seek(n) - self.Block=self.Block+n -end -function bin.NumtoHEX(num) - local hexstr = '0123456789ABCDEF' - local s = '' - while num > 0 do - local mod = math.fmod(num, 16) - s = string.sub(hexstr, mod+1, mod+1) .. s - num = math.floor(num / 16) - end - if s == '' then - s = '0' - end - return s -end -function bin:getHEX(a,b,e) - a=a or 1 - local temp = self:sub(a,b) - if e then temp=string.reverse(temp) end - return bin.tohex(temp) -end -function bin.HEXtoBin(hex,e) - if e then - return bin.new(string.reverse(bin.fromhex(hex))) - else - return bin.new(bin.fromhex(hex)) - end -end -function bin.HEXtoStr(hex,e) - if e then - return string.reverse(bin.fromhex(hex)) - else - return bin.fromhex(hex) - end -end -function bin:morph(a,b,d) - if self:canStreamWrite() then - local len=self:getlength() - local temp=bin.newTempFile(self:sub(b+1,self:getlength())) - self:streamwrite(d,a-1) - print(temp:sub(1,temp:getlength())) - self:setEndOfFile(len+(b-a)+#d) - self:streamwrite(temp:sub(1,temp:getlength()),a-1) - temp:remove() - elseif self.Stream==false then - if a and b then - self.data=self:sub(1,a-1)..d..self:sub(b+1) - else - print("error both arguments must be numbers and the third a string") - end - end -end -function bin.endianflop(data,n) - n=n or 1 - local tab={} - for i=1,#data,n do - table.insert(tab,1,string.sub(data,i,i+1)) - end - return table.concat(tab) -end -function bin:scan(s,n,f) - n=n or 1 - if self.Stream then - for i=n,self:getlength() do - if f then - local temp=bin.new(self:sub(i,i+#s-1)) - temp:flipbits() - if temp.data==s then - return i,i+#s-1 - end - else - if self:sub(i,i+#s-1)==s then - return i,i+#s-1 - end - end - end - elseif self.Stream==false then - if f then - s=bin.new(s) - s:flipbits() - s=s.data - end - n=n or 1 - local a,b=string.find(self.data,s,n,true) - return a,b - end -end -function bin:fill(s,n) - if self:canStreamWrite() then - self:streamwrite(string.rep(s,n),0) - self:setEndOfFile(n*#s) - elseif self.Stream==false then - self.data=string.rep(s,n) - end -end -function bin:fillrandom(n) - if self:canStreamWrite() then - local t={} - for i=1,n do - table.insert(t,string.char(math.random(0,255))) - end - self:streamwrite(table.concat(t),0) - self:setEndOfFile(n) - elseif self.Stream==false then - local t={} - for i=1,n do - table.insert(t,string.char(math.random(0,255))) - end - self.data=table.concat(t) - end -end -function bin.packLLIB(name,tab,ext) - local temp=bin.new() - temp:addBlock("") - temp:addBlock(bin.getVersion()) - temp:addBlock(tab) - for i=1,#tab do - temp:addBlock(tab[i]) - temp:addBlock(bin.load(tab[i]).data) - end - temp:addBlock("Done") - temp:tofile(name.. ("."..ext or ".llib")) -end -function bin.unpackLLIB(name,exe,todir,over,ext) - local temp=bin.load(name..("."..ext or ".llib")) - local name="" - Head=temp:getBlock("s") - ver=temp:getBlock("s") - infiles=temp:getBlock("t") - if ver~=bin.getVersion() then - print("Incompatable llib file") - return nil - end - local tab={} - while name~="Done" do - name,data=temp:getBlock("s"),bin.new(temp:getBlock("s")) - if string.find(name,".lua",1,true) then - table.insert(tab,data.data) - else - if not(bin.fileExist((todir or "")..name) and not(over)) then - data:tofile((todir or "")..name) - end - end - end - os.remove((todir or "").."Done") - if exe then - for i=1,#tab do - assert(loadstring(tab[i]))() - end - end - return infiles -end -function bin.fileExist(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 bin:shiftbits(n) - if self:canStreamWrite() then - n=n or 0 - if n>=0 then - for i=0,self:getlength() do - print(string.byte(self:sub(i,i))+n%256) - self:streamwrite(string.char(string.byte(self:sub(i,i))+n%256),i-1) - end - else - n=math.abs(n) - for i=0,self:getlength() do - self:streamwrite(string.char((string.byte(self:sub(i,i))+(256-n%256))%256),i-1) - end - end - elseif self.Stream==false then - n=n or 0 - if n>=0 then - for i=1,self:getlength() do - self:morph(i,i,string.char(string.byte(self:sub(i,i))+n%256)) - end - else - n=math.abs(n) - for i=1,self:getlength() do - self:morph(i,i,string.char((string.byte(self:sub(i,i))+(256-n%256))%256)) - end - end - end -end -function bin:shiftbit(n,i) - if self:canStreamWrite() then - i=i-1 - n=n or 0 - if n>=0 then - self:streamwrite(string.char(string.byte(self:sub(i,i))+n%256),i) - else - n=math.abs(n) - self:streamwrite(string.char((string.byte(self:sub(i,i))+(256-n%256))%256),i) - end - elseif self.Stream==false then - n=n or 0 - if n>=0 then - self:morph(i,i,string.char(string.byte(self:sub(i,i))+n%256)) - else - n=math.abs(n) - self:morph(i,i,string.char((string.byte(self:sub(i,i))+(256-n%256))%256)) - end - end -end -function bin.decodeBits(par) - if type(par)=="table" then - if par.t=="bit" then - return bin.new(par:toSbytes()) - end - else - if par:find(" ") then - par=par:gsub(" ","") - end - local temp=bits.new() - temp.data=par - return bin.new((temp:toSbytes()):reverse()) - end -end -function bin.textToBinary(txt) - return bin.new(bits.new(txt:reverse()):getBin()) -end ---[[---------------------------------------- -VFS -------------------------------------------]] -local _require = require -function require(path,vfs) - if bin.fileExist(path..".lvfs") then - local data = bin.loadVFS(path..".lvfs") - if data:fileExist(vsf) then - loadstring(data:readFile(vfs))() - end - else - return _require(path) - end -end -function bin.loadVFS(path) - return bin.newVFS(bin.load(path):getBlock("t")) -end -function bin.copyDir(dir,todir) - local vfs=bin.newVFS(dir,true) - vfs:toFS(todir) - vfs=nil -end -function bin.newVFS(t,l) - if type(t)=="string" then - t=io.parseDir(t,l) - end - local c={} - c.FS= t or {} - function c:merge(vfs) - bin.newVFS(table.merge(self.FS,vfs.FS)) - end - function c:mkdir(path) - table.merge(self.FS,io.pathToTable(path)) - end - function c:scanDir(path) - path=path or "" - local tab={} - if path=="" then - for i,v in pairs(self.FS) do - tab[#tab+1]=i - end - return tab - end - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath-1 do - last=last[spath[i]] - end - return last[spath[#spath]] - end - function c:getFiles(path) - if not self:dirExist(path) then return end - path=path or "" - local tab={} - if path=="" then - for i,v in pairs(self.FS) do - if self:fileExist(i) then - tab[#tab+1]=i - end - end - return tab - end - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath-1 do - last=last[spath[i]] - end - local t=last[spath[#spath]] - for i,v in pairs(t) do - if self:fileExist(path.."/"..i) then - tab[#tab+1]=path.."/"..i - end - end - return tab - end - function c:getDirectories(path) - if not self:dirExist(path) then return end - path=path or "" - local tab={} - if path=="" then - for i,v in pairs(self.FS) do - if self:dirExist(i) then - tab[#tab+1]=i - end - end - return tab - end - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath-1 do - last=last[spath[i]] - end - local t=last[spath[#spath]] - for i,v in pairs(t) do - if self:dirExist(path.."/"..i) then - tab[#tab+1]=path.."/"..i - end - end - return tab - end - function c:mkfile(path,data) - local name=io.getFullName(path) - local temp=path:reverse() - local a,b=temp:find("/") - if not a then - a,b=temp:find("\\") - end - if a then - temp=temp:sub(a+1):reverse() - path=temp - local t,l=io.pathToTable(path) - l[name]=data - table.merge(self.FS,t) - else - self.FS[name]=data - end - end - function c:remove(path) - if path=="" or path==nil then return end - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath-1 do - last=last[spath[i]] - end - last[spath[#spath]]=nil - end - function c:readFile(path) - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath do - last=last[spath[i]] - end - if type(last)=="userdata" then - last=last:read("*all") - end - return last - end - function c:copyFile(p1,p2) - self:mkfile(p2,self:readFile(p1)) - end - function c:moveFile(p1,p2) - self:copyFile(p1,p2) - self:remove(p1) - end - function c:fileExist(path) - return type(self:readFile(path))=="string" - end - function c:dirExist(path) - if path=="" or path==nil then return end - spath=io.splitPath(path) - local last=self.FS - for i=1,#spath-1 do - last=last[spath[i]] - end - if last[spath[#spath]]~=nil then - if type(last[spath[#spath]])=="table" then - return true - end - end - return false - end - function c:tofile(path) - local temp=bin.new() - temp:addBlock(self.FS) - temp:tofile(path) - end - function c:toFS(path) - if path then - if path:sub(-1,-1)~="\\" then - path=path.."\\" - elseif path:find("/") then - path=path:gsub("/","\\") - end - io.mkDir(path) - else - path="" - end - function build(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 v.t~=nil then - io.mkFile(folder..k,v.data,"wb") - else - if not(io.dirExists(path..folder..string.sub(formatting,1,-2))) then - io.mkDir(folder..string.sub(formatting,1,-2)) - end - build(v,0,folder..string.sub(formatting,1,-2).."\\") - end - elseif type(v)=="string" then - io.mkFile(folder..k,v,"wb") - elseif type(v)=="userdata" then - io.mkFile(folder..k,v:read("*all"),"wb") - end - end - end - build(self.FS,0,path) - end - function c:print() - table.print(self.FS) - end - return c -end ---[[---------------------------------------- -BITS -------------------------------------------]] -function bits.new(n) - if type(n)=="string" then - local t=tonumber(n,2) - if not t then - t={} - for i=#n,1,-1 do - table.insert(t,bits:conv(string.byte(n,i))) - end - n=table.concat(t) - else - n=t - end - end - local temp={} - temp.t="bit" - setmetatable(temp, bits) - if not type(n)=="string" then - local tab={} - while n>=1 do - table.insert(tab,n%2) - n=math.floor(n/2) - end - local str=string.reverse(table.concat(tab)) - if #str%8~=0 then - str=string.rep("0",8-#str%8)..str - end - temp.data=str - else - temp.data=n - end - setmetatable({__tostring=function(self) return self.data end},temp) - return temp -end -function bits:conv(n) - local tab={} - while n>=1 do - table.insert(tab,n%2) - n=math.floor(n/2) - end - local str=string.reverse(table.concat(tab)) - if #str%8~=0 then - str=string.rep("0",8-#str%8)..str - end - return str -end -function bits:add(i) - if type(i)=="number" then - i=bits.new(i) - end - self.data=self:conv(tonumber(self.data,2)+tonumber(i.data,2)) -end -function bits:sub(i) - if type(i)=="number" then - i=bits.new(i) - end - self.data=self:conv(tonumber(self.data,2)-tonumber(i.data,2)) -end -function bits:multi(i) - if type(i)=="number" then - i=bits.new(i) - end - self.data=self:conv(tonumber(self.data,2)*tonumber(i.data,2)) -end -function bits:div(i) - if type(i)=="number" then - i=bits.new(i) - end - self.data=self:conv(tonumber(self.data,2)/tonumber(i.data,2)) -end -function bits:tonumber(s) - if type(s)=="string" then - return tonumber(self.data,2) - end - s=s or 1 - return tonumber(string.sub(self.data,(8*(s-1))+1,8*s),2) or error("Bounds!") -end -function bits:isover() - return #self.data>8 -end -function bits:flipbits() - tab={} - for i=1,#self.data do - if string.sub(self.data,i,i)=="1" then - table.insert(tab,"0") - else - table.insert(tab,"1") - end - end - self.data=table.concat(tab) -end -function bits:tobytes() - local tab={} - for i=self:getbytes(),1,-1 do - table.insert(tab,string.char(self:tonumber(i))) - end - return bin.new(table.concat(tab)) -end -function bits:toSbytes() - local tab={} - for i=self:getbytes(),1,-1 do - table.insert(tab,string.char(self:tonumber(i))) - end - return table.concat(tab) -end -function bits:getBin() - return self.data -end -function bits:getbytes() - print(self.data) - return #self.data/8 -end diff --git a/OldStuff/merger.lua b/OldStuff/merger.lua deleted file mode 100644 index d4187a8..0000000 --- a/OldStuff/merger.lua +++ /dev/null @@ -1,39 +0,0 @@ -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 -]] diff --git a/gui/addons/functions.lua b/addons/functions.lua similarity index 100% rename from gui/addons/functions.lua rename to addons/functions.lua diff --git a/gui/addons/system.lua b/addons/system.lua similarity index 100% rename from gui/addons/system.lua rename to addons/system.lua diff --git a/gui/core/color.lua b/core/color.lua similarity index 100% rename from gui/core/color.lua rename to core/color.lua diff --git a/gui/core/theme.lua b/core/theme.lua similarity index 100% rename from gui/core/theme.lua rename to core/theme.lua diff --git a/gui/init.lua b/init.lua similarity index 99% rename from gui/init.lua rename to init.lua index 4ba7ce0..fd2620d 100644 --- a/gui/init.lua +++ b/init.lua @@ -1001,7 +1001,7 @@ end) function gui:newImageBase(typ, x, y, w, h, sx, sy, sw, sh) local c = self:newBase(image + typ, x, y, w, h, sx, sy, sw, sh) c.color = color.white - -- c.visibility = 0 + c.visibility = 0 local IMAGE function c:getUniques() return gui.getUniques(c, { diff --git a/multi b/multi deleted file mode 160000 index a7a902a..0000000 --- a/multi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a7a902acd68339aa128310ea49d56af2473e3a61 diff --git a/test.lua b/test.lua deleted file mode 100644 index 1bcb552..0000000 --- a/test.lua +++ /dev/null @@ -1,13 +0,0 @@ -local multi, thread = require("multi"):init() -conn1 = multi:newConnection() -conn2 = multi:newConnection(); - -((conn1 * conn2))(function() print("Triggered!") end) - -conn1:Fire() -conn2:Fire() - --- Looks like this is trigering a response. It shouldn't. We need to account for this -conn1:Fire() -conn1:Fire() -conn2:Fire()