From 76fd4578337e1eba7d55557947557f33f972d81d Mon Sep 17 00:00:00 2001 From: Ryan Ward Date: Sat, 9 Jun 2018 14:54:54 -0400 Subject: [PATCH] Updated to 9.0.0 Love2D 1.11 Support is here! :D --- GuiManager.lua | 240 ++- .../Core/Clickable.int | 0 .../Core/Colors.int | 23 +- .../Core/DrawThings.int | 0 .../Core/EventDefinitions.int | 0 .../Core/UpdateThings.int | 0 .../Core/_GetAllChildren.int | 0 .../Core/_GetAllChildren2.int | 0 .../Core/eventable.int | 0 GuiManager/Core/fromString.int | 0 {GuiManagerDebug => GuiManager}/Core/full.int | 0 .../Core/newBase.int | 27 +- .../Core/patches.int | 0 GuiManager/Core/toString.int | 40 + .../Core/touchManager.int | 0 .../Drawing/AddDrawRuleB.int | 2 +- .../Drawing/AddDrawRuleE.int | 2 +- .../Drawing/draw.int | 0 .../Drawing/drawC.int | 22 +- .../Drawing/drawR.int | 53 +- .../Frame/newDropFrame.int | 0 .../Frame/newFrame.int | 0 .../Frame/newFullFrame.int | 0 .../Frame/newTabFrame.int | 0 GuiManager/Frame/newratioFrame.int | 0 .../Image-Animation/SetImage.int | 4 +- .../Image-Animation/UpdateImage.int | 0 .../Image-Animation/getTile.int | 0 .../Image-Animation/newAnim.int | 0 .../Image-Animation/newAnimFromData.int | 0 .../Image-Animation/newAnimFromTiles.int | 0 .../Image-Animation/newFullImageLabel.int | 0 .../Image-Animation/newImageButton.int | 2 +- .../Image-Animation/newImageLabel.int | 4 +- .../Image-Animation/newVideo.int | 0 .../Item/newDragItem.int | 0 .../Item/newItem.int | 0 .../Misc/AdvTextBox.int | 0 .../Misc/ApplyGradient.int | 4 +- .../Misc/BottomStack.int | 0 .../Misc/Destroy.int | 1 + .../Misc/GetAllChildren.int | 0 .../Misc/GetChild.int | 0 .../Misc/InGrid.int | 0 .../Misc/InGridX.int | 0 .../Misc/InGridY.int | 0 .../Misc/IsHovering.int | 0 {GuiManagerDebug => GuiManager}/Misc/Move.int | 0 .../Misc/SetDualDim.int | 14 + .../Misc/SetHand.int | 0 .../Misc/SetHover.int | 0 .../Misc/SetName.int | 0 .../Misc/TopStack.int | 0 .../Misc/addDominance.int | 0 .../Misc/addHotKey.int | 0 .../Misc/alphanumsort.int | 0 .../Misc/anchorRight.int | 0 GuiManager/Misc/center.int | 4 + .../Misc/centerX.int | 0 .../Misc/centerY.int | 0 .../Misc/disrespectHierarchy.int | 0 .../Misc/getChildren.int | 0 .../Misc/getColor.int | 0 .../Misc/getFullSize.int | 4 +- .../Misc/getHighest.int | 0 .../Misc/getLowest.int | 0 .../Misc/isDescendant.int | 0 .../Misc/isHighest.int | 0 .../Misc/isLowest.int | 0 .../Misc/massMutate.int | 0 .../Misc/newCheckBox.int | 2 +- .../Misc/newMessageBox.int | 0 .../Misc/newPart.int | 0 .../Misc/newProgressBar.int | 0 .../Misc/newScrollBar.int | 0 .../Misc/newScrollMenu.int | 0 .../Misc/removeAllChildren.int | 0 .../Misc/removeDominance.int | 0 .../Misc/respectHierarchy.int | 0 .../Misc/round.int | 0 .../Misc/setBG.int | 0 GuiManager/Misc/setColor.int | 14 + .../Misc/setDefualtFont.int | 0 .../Misc/setHotKey.int | 0 GuiManager/Misc/setNewFont.int | 7 + .../Misc/setParent.int | 0 .../Misc/setVisibility.int | 0 .../Misc/setgetText.int | 0 GuiManager/Text/newTextBox.int | 181 ++ .../Text/newTextButton.int | 0 .../Text/newTextLabel.int | 0 GuiManager/Text/widthToFontSize.int | 5 + {GuiManagerDebug => GuiManager}/init.lua | 14 +- GuiManagerDebug/Misc/Center.int | 4 - GuiManagerDebug/Misc/setColor.int | 7 - GuiManagerDebug/Misc/setNewFont.int | 3 - GuiManagerDebug/Text/newTextBox.int | 104 -- Utils.lua | 770 +++++++++ bin.lua | 1453 +++++++++++++++++ merger.lua | 39 + 100 files changed, 2789 insertions(+), 260 deletions(-) rename {GuiManagerDebug => GuiManager}/Core/Clickable.int (100%) rename {GuiManagerDebug => GuiManager}/Core/Colors.int (98%) rename {GuiManagerDebug => GuiManager}/Core/DrawThings.int (100%) rename {GuiManagerDebug => GuiManager}/Core/EventDefinitions.int (100%) rename {GuiManagerDebug => GuiManager}/Core/UpdateThings.int (100%) rename {GuiManagerDebug => GuiManager}/Core/_GetAllChildren.int (100%) rename {GuiManagerDebug => GuiManager}/Core/_GetAllChildren2.int (100%) rename {GuiManagerDebug => GuiManager}/Core/eventable.int (100%) create mode 100644 GuiManager/Core/fromString.int rename {GuiManagerDebug => GuiManager}/Core/full.int (100%) rename {GuiManagerDebug => GuiManager}/Core/newBase.int (92%) rename {GuiManagerDebug => GuiManager}/Core/patches.int (100%) create mode 100644 GuiManager/Core/toString.int rename {GuiManagerDebug => GuiManager}/Core/touchManager.int (100%) rename {GuiManagerDebug => GuiManager}/Drawing/AddDrawRuleB.int (68%) rename {GuiManagerDebug => GuiManager}/Drawing/AddDrawRuleE.int (68%) rename {GuiManagerDebug => GuiManager}/Drawing/draw.int (100%) rename {GuiManagerDebug => GuiManager}/Drawing/drawC.int (89%) rename {GuiManagerDebug => GuiManager}/Drawing/drawR.int (76%) rename {GuiManagerDebug => GuiManager}/Frame/newDropFrame.int (100%) rename {GuiManagerDebug => GuiManager}/Frame/newFrame.int (100%) rename {GuiManagerDebug => GuiManager}/Frame/newFullFrame.int (100%) rename {GuiManagerDebug => GuiManager}/Frame/newTabFrame.int (100%) create mode 100644 GuiManager/Frame/newratioFrame.int rename {GuiManagerDebug => GuiManager}/Image-Animation/SetImage.int (79%) rename {GuiManagerDebug => GuiManager}/Image-Animation/UpdateImage.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/getTile.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newAnim.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newAnimFromData.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newAnimFromTiles.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newFullImageLabel.int (100%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newImageButton.int (91%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newImageLabel.int (85%) rename {GuiManagerDebug => GuiManager}/Image-Animation/newVideo.int (100%) rename {GuiManagerDebug => GuiManager}/Item/newDragItem.int (100%) rename {GuiManagerDebug => GuiManager}/Item/newItem.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/AdvTextBox.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/ApplyGradient.int (93%) rename {GuiManagerDebug => GuiManager}/Misc/BottomStack.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/Destroy.int (86%) rename {GuiManagerDebug => GuiManager}/Misc/GetAllChildren.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/GetChild.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/InGrid.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/InGridX.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/InGridY.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/IsHovering.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/Move.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/SetDualDim.int (73%) rename {GuiManagerDebug => GuiManager}/Misc/SetHand.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/SetHover.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/SetName.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/TopStack.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/addDominance.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/addHotKey.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/alphanumsort.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/anchorRight.int (100%) create mode 100644 GuiManager/Misc/center.int rename {GuiManagerDebug => GuiManager}/Misc/centerX.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/centerY.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/disrespectHierarchy.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/getChildren.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/getColor.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/getFullSize.int (68%) rename {GuiManagerDebug => GuiManager}/Misc/getHighest.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/getLowest.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/isDescendant.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/isHighest.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/isLowest.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/massMutate.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/newCheckBox.int (94%) rename {GuiManagerDebug => GuiManager}/Misc/newMessageBox.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/newPart.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/newProgressBar.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/newScrollBar.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/newScrollMenu.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/removeAllChildren.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/removeDominance.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/respectHierarchy.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/round.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/setBG.int (100%) create mode 100644 GuiManager/Misc/setColor.int rename {GuiManagerDebug => GuiManager}/Misc/setDefualtFont.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/setHotKey.int (100%) create mode 100644 GuiManager/Misc/setNewFont.int rename {GuiManagerDebug => GuiManager}/Misc/setParent.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/setVisibility.int (100%) rename {GuiManagerDebug => GuiManager}/Misc/setgetText.int (100%) create mode 100644 GuiManager/Text/newTextBox.int rename {GuiManagerDebug => GuiManager}/Text/newTextButton.int (100%) rename {GuiManagerDebug => GuiManager}/Text/newTextLabel.int (100%) create mode 100644 GuiManager/Text/widthToFontSize.int rename {GuiManagerDebug => GuiManager}/init.lua (85%) delete mode 100644 GuiManagerDebug/Misc/Center.int delete mode 100644 GuiManagerDebug/Misc/setColor.int delete mode 100644 GuiManagerDebug/Misc/setNewFont.int delete mode 100644 GuiManagerDebug/Text/newTextBox.int create mode 100644 Utils.lua create mode 100644 bin.lua create mode 100644 merger.lua diff --git a/GuiManager.lua b/GuiManager.lua index f86fa69..4b1ab1e 100644 --- a/GuiManager.lua +++ b/GuiManager.lua @@ -1,20 +1,20 @@ utf8 = require("utf8") -_defaultfont = love.graphics.getFont() gui = {} gui.__index = gui gui.TB={} -gui.Version="8.0.0" -- Is it really ready for release? +gui.Version="9.0.0" -- Is it really ready for release? _GuiPro={GBoost=true,hasDrag=false,DragItem={},Children={},Visible=true,count=0,x=0,y=0,height=0,width=0,update=function(self) local things=GetAllChildren2(self) UpdateThings(things) end,draw=function(self) local things=GetAllChildren(self) DrawThings(things) end,getChildren=function(self) return self.Children end} _GuiPro.Clips={} _GuiPro.rotate=0 +_defaultfont = love.graphics.setNewFont(12) setmetatable(_GuiPro, gui) function gui:LoadInterface(file) local add=".int" if string.find(file,".",1,true) then add="" end - if love.filesystem.exists(file..add) then + if love.filesystem.getInfo(file..add) then a,b=pcall(love.filesystem.load(file..add)) if a then - print("Loaded: "..file) + --print("Loaded: "..file) else print("Error loading file: "..file) print(a,b) @@ -48,8 +48,22 @@ function gui:Clickable() end return not(mx>x+w or mxy+h or mymaxx then + if temp[i].width+temp[i].offset.pos.x>maxx then maxx=temp[i].width+temp[i].offset.pos.x - elseif temp[i].height>maxy then + elseif temp[i].height+temp[i].offset.pos.y>maxy then maxy=temp[i].height+temp[i].offset.pos.y end end @@ -3095,7 +3157,7 @@ function gui:Move(x,y) self.offset.pos.x=self.offset.pos.x+x self.offset.pos.y=self.offset.pos.y+y end -if love.filesystem.exists("CheckBoxes.png") then +if love.filesystem.getInfo("CheckBoxes.png") then _GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16) _GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16) _GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16) @@ -3494,10 +3556,10 @@ end function gui:getText(txt) return self.text end ---_GuiPro.CursorN=love.mouse.getSystemCursor("arrow") ---_GuiPro.CursorH=love.mouse.getSystemCursor("hand") +_GuiPro.CursorN=love.mouse.getSystemCursor("arrow") +_GuiPro.CursorH=love.mouse.getSystemCursor("hand") function gui:SetHand(img,x,y) - --_GuiPro.CursorN=love.mouse.newCursor(img,x,y) + _GuiPro.CursorN=love.mouse.newCursor(img,x,y) end function gui:setHotKey(key) local tab=key:split("+") @@ -3524,14 +3586,18 @@ function gui:setHotKey(key) end) end function gui:SetHover(img,x,y) - --_GuiPro.CursorH=love.mouse.newCursor(img,x,y) + _GuiPro.CursorH=love.mouse.newCursor(img,x,y) end function gui:SetName(name) self.Parent.Children[name]=self self.Name=name end -function gui:setNewFont(FontSize) - self.Font=love.graphics.setNewFont(tonumber(FontSize)) +function gui:setNewFont(FontSize,filename) + if filename then + self.Font = love.graphics.newFont(filename, tonumber(FontSize)) + else + self.Font=love.graphics.setNewFont(tonumber(FontSize)) + end end function gui:setParent(parent,name)-- Needs fixing!!! local temp=self.Parent:getChildren() @@ -3601,7 +3667,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) c.mark=nil c.arrowkeys=false c.funcF={function() - love.keyboard.setTextInput(true) + love.keyboard.setTextInput(true,0,200,400,200) end} c.cooldown=false c.cooldown2=false @@ -3632,9 +3698,12 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) table.insert(self.funcE,func) end c:OnClicked(function(b,self) + self:focus() + end) + function c:focus() for cc=1,#self.funcF do self.funcF[cc](self) - end + end if self.Active==false then if self.ClearOnFocus==true then self.text="" @@ -3647,7 +3716,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) end self.Active=true end - end) + end c:OnClicked(function(b,self,x,y) local dwidth, wrappedtext = _defaultfont:getWrap(self.text:sub(1,self.cursor[1]), self.width) local height = _defaultfont:getHeight() @@ -3717,7 +3786,7 @@ function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) self.ttext=self.ttext.."\n" self.cooldown2=true c.Alarm2:Reset() - elseif (love.keyboard.isDown("return") or love.keyboard.isDown("enter") or love.keyboard.isDown("kpenter")) and self.Active and self.Enter and not(love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) then + elseif (love.keyboard.isDown("return") or love.keyboard.isDown("kpenter")) and self.Active and self.Enter and not(love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) then if self.LoseFocusOnEnter then self.Active=false else @@ -3764,10 +3833,10 @@ function gui:newTextButton(t,name, x, y, w, h, sx ,sy ,sw ,sh) c.Color = {220, 220, 220} c.TextColor = {0, 0, 0} c:OnEnter(function() - --love.mouse.setCursor(_GuiPro.CursorH) + love.mouse.setCursor(_GuiPro.CursorH) end) c:OnExit(function() - --love.mouse.setCursor(_GuiPro.CursorN) + love.mouse.setCursor(_GuiPro.CursorN) end) return c end @@ -3787,6 +3856,11 @@ function gui:newTextLabel(t,name, x, y, w, h, sx ,sy ,sw ,sh) c.TextColor = {0, 0, 0} return c end +function gui:widthToTextSize(n) + if self.Font then + self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0) + end +end function gui:AddDrawRuleB(rule) if not(self.DrawRulesB) then self.DrawRulesB={} end table.insert(self.DrawRulesB,rule) @@ -3836,37 +3910,37 @@ function gui:drawC() self.hovering=true if love.mouse.isDown("l") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.lclicked=true elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=true elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.mclicked=true else if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254) + love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=false self.lclicked=false self.mclicked=false end else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) self.hovering=false self.rclicked=false self.lclicked=false @@ -3880,7 +3954,7 @@ function gui:drawC() love.graphics.setStencilTest("notequal",0) end love.graphics.circle("fill",x,y,r,s) - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility*254) + love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility) for b=0,self.BorderSize-1 do love.graphics.circle("line",x,y,r+b,s) end @@ -3889,7 +3963,7 @@ function gui:drawC() if self.AutoScaleText then self.FontSize=math.floor(self.height/1.45833) end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility*254) + love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) love.graphics.setFont(self.Font) love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat) end @@ -3925,37 +3999,37 @@ function gui:drawR() self.hovering=true if love.mouse.isDown("l") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.lclicked=true elseif love.mouse.isDown("r") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=true elseif love.mouse.isDown("m") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.mclicked=true else if string.find(self.Type, "Button") or self:touchable("r") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254) + love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=false self.lclicked=false self.mclicked=false end else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) self.hovering=false self.rclicked=false self.lclicked=false @@ -3969,17 +4043,18 @@ function gui:drawR() love.graphics.stencil(self.stfunc, "replace", 1) love.graphics.setStencilTest("greater", 0) end - love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) - if string.find(self.Type, "Image") then - self:ImageRule() - end - if self.Type=="Video" then - self:VideoRule() - end + + love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) + if string.find(self.Type, "Image") then + self:ImageRule() + end + if self.Type=="Video" then + self:VideoRule() + end if self:hasRoundness() then love.graphics.setStencilTest() end - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility*254) + love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility) for b=0,self.BorderSize-1 do love.graphics.rectangle("line", self.x-(b/2), self.y-(b/2), self.width+b, self.height+b,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) end @@ -3988,10 +4063,16 @@ function gui:drawR() if self.AutoScaleText then self.FontSize=math.floor(self.height/1.45833) end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility*254) + love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) if self.Font==_defaultfont then love.graphics.setFont(self.Font) - love.graphics.printf(self.text, self.x+2+(self.XTween*self.DPI)+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+(self.FontHeight/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat) + love.graphics.printf( + self.text, + (self.x+2+(self.marginL or 0) or self.XTween)*self.DPI, + (self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween)*self.DPI, + (self.width+(0 or (self.marginR or 0)))*self.DPI, + self.TextFormat, + self.TextRotation) else if type(self.Font)=="string" then self.Font=love.graphics.newFont(self.Font,self.FontSize) @@ -4003,7 +4084,13 @@ function gui:drawR() self.FontSize=tonumber(self.FontSize) love.graphics.setNewFont(self.FontSize) end - love.graphics.printf(self.text, self.x+2+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat) + love.graphics.printf( + self.text, + (self.x+2+(self.marginL or 0) or self.XTween)*self.DPI, + (self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween)*self.DPI, + (self.width+(0 or (self.marginR or 0)))*self.DPI, + self.TextFormat, + self.TextRotation) end end end @@ -4025,3 +4112,4 @@ gui.ff:OnUpdate(function(self) self:BottomStack() end) + diff --git a/GuiManagerDebug/Core/Clickable.int b/GuiManager/Core/Clickable.int similarity index 100% rename from GuiManagerDebug/Core/Clickable.int rename to GuiManager/Core/Clickable.int diff --git a/GuiManagerDebug/Core/Colors.int b/GuiManager/Core/Colors.int similarity index 98% rename from GuiManagerDebug/Core/Colors.int rename to GuiManager/Core/Colors.int index 896a745..eda5f1e 100644 --- a/GuiManagerDebug/Core/Colors.int +++ b/GuiManager/Core/Colors.int @@ -1,5 +1,19 @@ +local function HSL(h, s, l, a) + if s<=0 then return l,l,l,a end + h, s, l = h/256*6, s/255, l/255 + local c = (1-math.abs(2*l-1))*s + local x = (1-math.abs(h%2-1))*c + local m,r,b,g = (l-.5*c), 0,0,0 + if h < 1 then r,b,g = c,x,0 + elseif h < 2 then r,b,g = x,c,0 + elseif h < 3 then r,b,g = 0,c,x + elseif h < 4 then r,b,g = 0,x,c + elseif h < 5 then r,b,g = x,0,c + else r,b,g = c,0,x + end return (r+m)*255,(g+m)*255,(b+m)*255,a +end Color={ -new=function(r,g,b) +new=function(r,b,g) mt = { __add = function (c1,c2) return Color.new(c1[1]+c2[1],c1[2]+c2[2],c1[2]+c2[2]) @@ -29,7 +43,7 @@ new=function(r,g,b) __lt = Color.LT, __le = Color.LE, } - local temp = {r,g,b,255} + local temp = {r/255,b/255,g/255,1} setmetatable(temp, mt) return temp end, @@ -57,14 +71,13 @@ Darken=function(color,v) currentR=color[1] currentG=color[2] currentB=color[3] - return Color.new(currentR * (1 - v),currentG * (1 - v),currentB * (1 - v)) + return Color.new((currentR*255) * (1 - v),(currentG*255) * (1 - v),(currentB*255) * (1 - v)) end, Lighten=function(color,v) currentR=color[1] currentG=color[2] currentB=color[3] - - return Color.new(currentR + (255 - currentR) * v,currentG + (255 - currentG) * v,currentB + (255 - currentB) * v) + return Color.new(currentR*255 + (255 - (currentR*255)) * v,currentG*255 + (255 - (currentG*255)) * v,currentB*255 + (255 - (currentB*255)) * v) end } Color.IndexColor("Black",20,20,20) diff --git a/GuiManagerDebug/Core/DrawThings.int b/GuiManager/Core/DrawThings.int similarity index 100% rename from GuiManagerDebug/Core/DrawThings.int rename to GuiManager/Core/DrawThings.int diff --git a/GuiManagerDebug/Core/EventDefinitions.int b/GuiManager/Core/EventDefinitions.int similarity index 100% rename from GuiManagerDebug/Core/EventDefinitions.int rename to GuiManager/Core/EventDefinitions.int diff --git a/GuiManagerDebug/Core/UpdateThings.int b/GuiManager/Core/UpdateThings.int similarity index 100% rename from GuiManagerDebug/Core/UpdateThings.int rename to GuiManager/Core/UpdateThings.int diff --git a/GuiManagerDebug/Core/_GetAllChildren.int b/GuiManager/Core/_GetAllChildren.int similarity index 100% rename from GuiManagerDebug/Core/_GetAllChildren.int rename to GuiManager/Core/_GetAllChildren.int diff --git a/GuiManagerDebug/Core/_GetAllChildren2.int b/GuiManager/Core/_GetAllChildren2.int similarity index 100% rename from GuiManagerDebug/Core/_GetAllChildren2.int rename to GuiManager/Core/_GetAllChildren2.int diff --git a/GuiManagerDebug/Core/eventable.int b/GuiManager/Core/eventable.int similarity index 100% rename from GuiManagerDebug/Core/eventable.int rename to GuiManager/Core/eventable.int diff --git a/GuiManager/Core/fromString.int b/GuiManager/Core/fromString.int new file mode 100644 index 0000000..e69de29 diff --git a/GuiManagerDebug/Core/full.int b/GuiManager/Core/full.int similarity index 100% rename from GuiManagerDebug/Core/full.int rename to GuiManager/Core/full.int diff --git a/GuiManagerDebug/Core/newBase.int b/GuiManager/Core/newBase.int similarity index 92% rename from GuiManagerDebug/Core/newBase.int rename to GuiManager/Core/newBase.int index 69d4051..31b7fff 100644 --- a/GuiManagerDebug/Core/newBase.int +++ b/GuiManager/Core/newBase.int @@ -24,15 +24,15 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh) else c.Parent=self end - c.segments=nil - c.ry=nil - c.rx=nil - c.DPI=1 - if _GuiPro.DPI_ENABLED then - c.DPI=love.window.getPixelScale() - x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h - end - c.centerFontY=true + c.segments=nil + c.ry=nil + c.rx=nil + c.DPI=1 + if _GuiPro.DPI_ENABLED then + c.DPI=love.window.getPixelScale() + x, y, w, h=c.DPI*x,c.DPI*y,c.DPI*w,c.DPI*h + end + c.centerFontY=true c.FormFactor="rectangle" c.Type=tp c.Active=true @@ -160,7 +160,7 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh) end function c:repeatImage(b,b2) if b then - self.Image:setWrap("repeat","repeat") + self.Image:setWrap(b,b2 or "repeat") function self:ImageRule() love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.ImageVisibility*255) love.graphics.draw(self.Image,self.Quad,self.x,self.y,math.rad(self.rotation)) @@ -177,6 +177,13 @@ function gui:newBase(tp,name, x, y, w, h, sx ,sy ,sw ,sh) _GuiPro.self=self if type(i)=="number" then loadstring("_GuiPro.self:"..v)() + elseif i:match"__self__" then + local ind=i:match"__self__(.+)" + if not self[ind] then self[ind]={} end + loadstring("_GuiPro.self."..ind.."=_GuiPro.self:"..v)() + elseif i:match"__child__" then + local ind,child = i:match"__child__(%S-)_(.+)" + self[ind][child]=v else self[i]=v end diff --git a/GuiManagerDebug/Core/patches.int b/GuiManager/Core/patches.int similarity index 100% rename from GuiManagerDebug/Core/patches.int rename to GuiManager/Core/patches.int diff --git a/GuiManager/Core/toString.int b/GuiManager/Core/toString.int new file mode 100644 index 0000000..741685c --- /dev/null +++ b/GuiManager/Core/toString.int @@ -0,0 +1,40 @@ +function gui:toString() -- oh boy this is gonna be painful lol + multi:newThread("saving data: ",function() + local dat=bin.stream("test.dat",false) + function GetAllChildren2(Object) + local Stuff = {} + function Seek(Items) + for i=1,#Items do + --table.insert(Stuff,Items[i]) + for a,v in pairs(Items[i]) do + -- dat:tackE(a.."|"..tostring(v)) + print(a.."|"..tostring(v)) + -- dat.workingfile:flush() + end + thread.skip() + local NItems = Items[i]:getChildren() + if NItems ~= nil then + Seek(NItems) + end + end + end + local Objs = Object:getChildren() + for i=1,#Objs do + -- table.insert(Stuff,Objs[i]) + for a,v in pairs(Objs[i]) do + -- dat:tackE(a.."|"..tostring(v)) + print(Objs[i].Type..":"..a.."|"..tostring(v)) + -- dat.workingfile:flush() + end + thread.skip() + local Items = Objs[i]:getChildren() + if Items ~= nil then + Seek(Items) + end + end + -- dat:tofile("test.dat") + return Stuff + end + GetAllChildren2(self) + end) +end \ No newline at end of file diff --git a/GuiManagerDebug/Core/touchManager.int b/GuiManager/Core/touchManager.int similarity index 100% rename from GuiManagerDebug/Core/touchManager.int rename to GuiManager/Core/touchManager.int diff --git a/GuiManagerDebug/Drawing/AddDrawRuleB.int b/GuiManager/Drawing/AddDrawRuleB.int similarity index 68% rename from GuiManagerDebug/Drawing/AddDrawRuleB.int rename to GuiManager/Drawing/AddDrawRuleB.int index 58a0b8a..5510a3d 100644 --- a/GuiManagerDebug/Drawing/AddDrawRuleB.int +++ b/GuiManager/Drawing/AddDrawRuleB.int @@ -1,4 +1,4 @@ function gui:AddDrawRuleB(rule) if not(self.DrawRulesB) then self.DrawRulesB={} end - table.insert(self.DrawRulesB,fule) + table.insert(self.DrawRulesB,rule) end \ No newline at end of file diff --git a/GuiManagerDebug/Drawing/AddDrawRuleE.int b/GuiManager/Drawing/AddDrawRuleE.int similarity index 68% rename from GuiManagerDebug/Drawing/AddDrawRuleE.int rename to GuiManager/Drawing/AddDrawRuleE.int index 18caa4b..a025f89 100644 --- a/GuiManagerDebug/Drawing/AddDrawRuleE.int +++ b/GuiManager/Drawing/AddDrawRuleE.int @@ -1,4 +1,4 @@ function gui:AddDrawRuleE(rule) if not(self.DrawRulesE) then self.DrawRulesE={} end - table.insert(self.DrawRulesE,fule) + table.insert(self.DrawRulesE,rule) end \ No newline at end of file diff --git a/GuiManagerDebug/Drawing/draw.int b/GuiManager/Drawing/draw.int similarity index 100% rename from GuiManagerDebug/Drawing/draw.int rename to GuiManager/Drawing/draw.int diff --git a/GuiManagerDebug/Drawing/drawC.int b/GuiManager/Drawing/drawC.int similarity index 89% rename from GuiManagerDebug/Drawing/drawC.int rename to GuiManager/Drawing/drawC.int index 84592b5..1f299a7 100644 --- a/GuiManagerDebug/Drawing/drawC.int +++ b/GuiManager/Drawing/drawC.int @@ -27,37 +27,37 @@ function gui:drawC() self.hovering=true if love.mouse.isDown("l") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.lclicked=true elseif love.mouse.isDown("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=true elseif love.mouse.isDown("m") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.mclicked=true else if string.find(self.Type, "Button") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254) + love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=false self.lclicked=false self.mclicked=false end else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) self.hovering=false self.rclicked=false self.lclicked=false @@ -71,7 +71,7 @@ function gui:drawC() love.graphics.setStencilTest("notequal",0) end love.graphics.circle("fill",x,y,r,s) - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility*254) + love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility) for b=0,self.BorderSize-1 do love.graphics.circle("line",x,y,r+b,s) end @@ -80,7 +80,7 @@ function gui:drawC() if self.AutoScaleText then self.FontSize=math.floor(self.height/1.45833) end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility*254) + love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) love.graphics.setFont(self.Font) love.graphics.printf(self.text, x-(r/2)+(self.XTween), y-(r/2)+self.Tween, r, self.TextFormat) end diff --git a/GuiManagerDebug/Drawing/drawR.int b/GuiManager/Drawing/drawR.int similarity index 76% rename from GuiManagerDebug/Drawing/drawR.int rename to GuiManager/Drawing/drawR.int index 33a1d0c..36b07c3 100644 --- a/GuiManagerDebug/Drawing/drawR.int +++ b/GuiManager/Drawing/drawR.int @@ -27,37 +27,37 @@ function gui:drawR() self.hovering=true if love.mouse.isDown("l") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.lclicked=true elseif love.mouse.isDown("r") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=true elseif love.mouse.isDown("m") or self:touchable("r") and _GuiPro.hasDrag==false then if string.find(self.Type, "Button") then - love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility*254) + love.graphics.setColor(self.Color[1]-10, self.Color[2]-10, self.Color[3]-10,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.mclicked=true else if string.find(self.Type, "Button") or self:touchable("r") and _GuiPro.hasDrag==false then - love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility*254) + love.graphics.setColor(self.Color[1]-5, self.Color[2]-5, self.Color[3]-5,self.Visibility) else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) end self.rclicked=false self.lclicked=false self.mclicked=false end else - love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility*254) + love.graphics.setColor(self.Color[1],self.Color[2],self.Color[3],self.Visibility) self.hovering=false self.rclicked=false self.lclicked=false @@ -71,17 +71,18 @@ function gui:drawR() love.graphics.stencil(self.stfunc, "replace", 1) love.graphics.setStencilTest("greater", 0) end - love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) - if string.find(self.Type, "Image") then - self:ImageRule() - end - if self.Type=="Video" then - self:VideoRule() - end + + love.graphics.rectangle("fill", self.x, self.y, self.width, self.height,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) + if string.find(self.Type, "Image") then + self:ImageRule() + end + if self.Type=="Video" then + self:VideoRule() + end if self:hasRoundness() then love.graphics.setStencilTest() end - love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility*254) + love.graphics.setColor(self.BorderColor[1], self.BorderColor[2], self.BorderColor[3],self.Visibility) for b=0,self.BorderSize-1 do love.graphics.rectangle("line", self.x-(b/2), self.y-(b/2), self.width+b, self.height+b,(self.rx or 1)*self.DPI,(self.ry or 1)*self.DPI,(self.segments or 1)*self.DPI) end @@ -90,10 +91,16 @@ function gui:drawR() if self.AutoScaleText then self.FontSize=math.floor(self.height/1.45833) end - love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility*254) + love.graphics.setColor(self.TextColor[1],self.TextColor[2],self.TextColor[3],self.TextVisibility) if self.Font==_defaultfont then love.graphics.setFont(self.Font) - love.graphics.printf(self.text, self.x+2+(self.XTween*self.DPI)+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+(self.FontHeight/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat) + love.graphics.printf( + self.text, + (self.x+2+(self.marginL or 0) or self.XTween)*self.DPI, + (self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween)*self.DPI, + (self.width+(0 or (self.marginR or 0)))*self.DPI, + self.TextFormat, + self.TextRotation) else if type(self.Font)=="string" then self.Font=love.graphics.newFont(self.Font,self.FontSize) @@ -105,7 +112,13 @@ function gui:drawR() self.FontSize=tonumber(self.FontSize) love.graphics.setNewFont(self.FontSize) end - love.graphics.printf(self.text, self.x+2+((self.marginL or 0)*self.DPI or self.XTween*self.DPI), self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween*self.DPI, self.width+(0 or (self.marginR or 0)*self.DPI), self.TextFormat) + love.graphics.printf( + self.text, + (self.x+2+(self.marginL or 0) or self.XTween)*self.DPI, + (self.y+math.floor((self.FontHeight-self.FontSize)/2)+self.Tween)*self.DPI, + (self.width+(0 or (self.marginR or 0)))*self.DPI, + self.TextFormat, + self.TextRotation) end end end diff --git a/GuiManagerDebug/Frame/newDropFrame.int b/GuiManager/Frame/newDropFrame.int similarity index 100% rename from GuiManagerDebug/Frame/newDropFrame.int rename to GuiManager/Frame/newDropFrame.int diff --git a/GuiManagerDebug/Frame/newFrame.int b/GuiManager/Frame/newFrame.int similarity index 100% rename from GuiManagerDebug/Frame/newFrame.int rename to GuiManager/Frame/newFrame.int diff --git a/GuiManagerDebug/Frame/newFullFrame.int b/GuiManager/Frame/newFullFrame.int similarity index 100% rename from GuiManagerDebug/Frame/newFullFrame.int rename to GuiManager/Frame/newFullFrame.int diff --git a/GuiManagerDebug/Frame/newTabFrame.int b/GuiManager/Frame/newTabFrame.int similarity index 100% rename from GuiManagerDebug/Frame/newTabFrame.int rename to GuiManager/Frame/newTabFrame.int diff --git a/GuiManager/Frame/newratioFrame.int b/GuiManager/Frame/newratioFrame.int new file mode 100644 index 0000000..e69de29 diff --git a/GuiManagerDebug/Image-Animation/SetImage.int b/GuiManager/Image-Animation/SetImage.int similarity index 79% rename from GuiManagerDebug/Image-Animation/SetImage.int rename to GuiManager/Image-Animation/SetImage.int index d0d5f78..3a1b2fb 100644 --- a/GuiManagerDebug/Image-Animation/SetImage.int +++ b/GuiManager/Image-Animation/SetImage.int @@ -1,10 +1,10 @@ function gui:SetImage(i) - if type(i)=="string" then + if type(i)=="string" or tostring(i):find("ImageData") then self.Image=love.graphics.newImage(i) else self.Image=i end - if self.Image~=nil then + if self.Image then self.ImageHeigth=self.Image:getHeight() self.ImageWidth=self.Image:getWidth() self.Quad=love.graphics.newQuad(0,0,self.width,self.height,self.ImageWidth,self.ImageHeigth) diff --git a/GuiManagerDebug/Image-Animation/UpdateImage.int b/GuiManager/Image-Animation/UpdateImage.int similarity index 100% rename from GuiManagerDebug/Image-Animation/UpdateImage.int rename to GuiManager/Image-Animation/UpdateImage.int diff --git a/GuiManagerDebug/Image-Animation/getTile.int b/GuiManager/Image-Animation/getTile.int similarity index 100% rename from GuiManagerDebug/Image-Animation/getTile.int rename to GuiManager/Image-Animation/getTile.int diff --git a/GuiManagerDebug/Image-Animation/newAnim.int b/GuiManager/Image-Animation/newAnim.int similarity index 100% rename from GuiManagerDebug/Image-Animation/newAnim.int rename to GuiManager/Image-Animation/newAnim.int diff --git a/GuiManagerDebug/Image-Animation/newAnimFromData.int b/GuiManager/Image-Animation/newAnimFromData.int similarity index 100% rename from GuiManagerDebug/Image-Animation/newAnimFromData.int rename to GuiManager/Image-Animation/newAnimFromData.int diff --git a/GuiManagerDebug/Image-Animation/newAnimFromTiles.int b/GuiManager/Image-Animation/newAnimFromTiles.int similarity index 100% rename from GuiManagerDebug/Image-Animation/newAnimFromTiles.int rename to GuiManager/Image-Animation/newAnimFromTiles.int diff --git a/GuiManagerDebug/Image-Animation/newFullImageLabel.int b/GuiManager/Image-Animation/newFullImageLabel.int similarity index 100% rename from GuiManagerDebug/Image-Animation/newFullImageLabel.int rename to GuiManager/Image-Animation/newFullImageLabel.int diff --git a/GuiManagerDebug/Image-Animation/newImageButton.int b/GuiManager/Image-Animation/newImageButton.int similarity index 91% rename from GuiManagerDebug/Image-Animation/newImageButton.int rename to GuiManager/Image-Animation/newImageButton.int index 6d0e51d..5d03572 100644 --- a/GuiManagerDebug/Image-Animation/newImageButton.int +++ b/GuiManager/Image-Animation/newImageButton.int @@ -1,7 +1,7 @@ function gui:newImageButton(i,name, x, y, w, h, sx ,sy ,sw ,sh) x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) local c=self:newBase("ImageButton",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then + if type(i)=="string" or type(i):find("ImageData") then c.Image=love.graphics.newImage(i) else c.Image=i diff --git a/GuiManagerDebug/Image-Animation/newImageLabel.int b/GuiManager/Image-Animation/newImageLabel.int similarity index 85% rename from GuiManagerDebug/Image-Animation/newImageLabel.int rename to GuiManager/Image-Animation/newImageLabel.int index 47323e1..c969bf8 100644 --- a/GuiManagerDebug/Image-Animation/newImageLabel.int +++ b/GuiManager/Image-Animation/newImageLabel.int @@ -1,7 +1,7 @@ function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh) x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) local c=self:newBase("ImageLabel",name, x, y, w, h, sx ,sy ,sw ,sh) - if type(i)=="string" then + if type(i)=="string" or type(i):find("ImageData") then c.Image=love.graphics.newImage(i) else c.Image=i @@ -9,7 +9,7 @@ function gui:newImageLabel(i,name, x, y, w, h, sx ,sy ,sw ,sh) c.Visibility=0 c.ImageVisibility=1 c.rotation=0 - if c.Image~=nil then + if c.Image then c.ImageHeigth=c.Image:getHeight() c.ImageWidth=c.Image:getWidth() c.Quad=love.graphics.newQuad(0,0,w,h,c.ImageWidth,c.ImageHeigth) diff --git a/GuiManagerDebug/Image-Animation/newVideo.int b/GuiManager/Image-Animation/newVideo.int similarity index 100% rename from GuiManagerDebug/Image-Animation/newVideo.int rename to GuiManager/Image-Animation/newVideo.int diff --git a/GuiManagerDebug/Item/newDragItem.int b/GuiManager/Item/newDragItem.int similarity index 100% rename from GuiManagerDebug/Item/newDragItem.int rename to GuiManager/Item/newDragItem.int diff --git a/GuiManagerDebug/Item/newItem.int b/GuiManager/Item/newItem.int similarity index 100% rename from GuiManagerDebug/Item/newItem.int rename to GuiManager/Item/newItem.int diff --git a/GuiManagerDebug/Misc/AdvTextBox.int b/GuiManager/Misc/AdvTextBox.int similarity index 100% rename from GuiManagerDebug/Misc/AdvTextBox.int rename to GuiManager/Misc/AdvTextBox.int diff --git a/GuiManagerDebug/Misc/ApplyGradient.int b/GuiManager/Misc/ApplyGradient.int similarity index 93% rename from GuiManagerDebug/Misc/ApplyGradient.int rename to GuiManager/Misc/ApplyGradient.int index e092739..87cb97d 100644 --- a/GuiManagerDebug/Misc/ApplyGradient.int +++ b/GuiManager/Misc/ApplyGradient.int @@ -1,7 +1,7 @@ function _GuiPro.gradient(colors) local direction = colors.direction or "horizontal" colors.direction=nil - trans = colors.trans or 255 + trans = colors.trans or 1 trans=math.floor(trans) if direction == "horizontal" then direction = true @@ -10,7 +10,7 @@ function _GuiPro.gradient(colors) else error("Invalid direction '" .. tostring(direction) "' for gradient. Horizontal or vertical expected.") end - local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1) + local result = love.image.newImageData(direction and 1 or #colors, direction and #colors or 1,"rgba32f") for __i, color in ipairs(colors) do local x, y if direction then diff --git a/GuiManagerDebug/Misc/BottomStack.int b/GuiManager/Misc/BottomStack.int similarity index 100% rename from GuiManagerDebug/Misc/BottomStack.int rename to GuiManager/Misc/BottomStack.int diff --git a/GuiManagerDebug/Misc/Destroy.int b/GuiManager/Misc/Destroy.int similarity index 86% rename from GuiManagerDebug/Misc/Destroy.int rename to GuiManager/Misc/Destroy.int index 9c524f1..f127af8 100644 --- a/GuiManagerDebug/Misc/Destroy.int +++ b/GuiManager/Misc/Destroy.int @@ -6,4 +6,5 @@ function gui:Destroy() table.remove(self.Parent.Children,cc) end end + self.Destroyed = true end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/GetAllChildren.int b/GuiManager/Misc/GetAllChildren.int similarity index 100% rename from GuiManagerDebug/Misc/GetAllChildren.int rename to GuiManager/Misc/GetAllChildren.int diff --git a/GuiManagerDebug/Misc/GetChild.int b/GuiManager/Misc/GetChild.int similarity index 100% rename from GuiManagerDebug/Misc/GetChild.int rename to GuiManager/Misc/GetChild.int diff --git a/GuiManagerDebug/Misc/InGrid.int b/GuiManager/Misc/InGrid.int similarity index 100% rename from GuiManagerDebug/Misc/InGrid.int rename to GuiManager/Misc/InGrid.int diff --git a/GuiManagerDebug/Misc/InGridX.int b/GuiManager/Misc/InGridX.int similarity index 100% rename from GuiManagerDebug/Misc/InGridX.int rename to GuiManager/Misc/InGridX.int diff --git a/GuiManagerDebug/Misc/InGridY.int b/GuiManager/Misc/InGridY.int similarity index 100% rename from GuiManagerDebug/Misc/InGridY.int rename to GuiManager/Misc/InGridY.int diff --git a/GuiManagerDebug/Misc/IsHovering.int b/GuiManager/Misc/IsHovering.int similarity index 100% rename from GuiManagerDebug/Misc/IsHovering.int rename to GuiManager/Misc/IsHovering.int diff --git a/GuiManagerDebug/Misc/Move.int b/GuiManager/Misc/Move.int similarity index 100% rename from GuiManagerDebug/Misc/Move.int rename to GuiManager/Misc/Move.int diff --git a/GuiManagerDebug/Misc/SetDualDim.int b/GuiManager/Misc/SetDualDim.int similarity index 73% rename from GuiManagerDebug/Misc/SetDualDim.int rename to GuiManager/Misc/SetDualDim.int index 435bbb1..0774965 100644 --- a/GuiManagerDebug/Misc/SetDualDim.int +++ b/GuiManager/Misc/SetDualDim.int @@ -1,4 +1,18 @@ function gui:SetDualDim(x, y, w, h, sx ,sy ,sw ,sh) + if _GuiPro.DPI_ENABLED then + if x then + x=self.DPI*x + end + if y then + y=self.DPI*y + end + if w then + w=self.DPI*w + end + if h then + h=self.DPI*h + end + end if sx then self.scale.pos.x=sx end diff --git a/GuiManagerDebug/Misc/SetHand.int b/GuiManager/Misc/SetHand.int similarity index 100% rename from GuiManagerDebug/Misc/SetHand.int rename to GuiManager/Misc/SetHand.int diff --git a/GuiManagerDebug/Misc/SetHover.int b/GuiManager/Misc/SetHover.int similarity index 100% rename from GuiManagerDebug/Misc/SetHover.int rename to GuiManager/Misc/SetHover.int diff --git a/GuiManagerDebug/Misc/SetName.int b/GuiManager/Misc/SetName.int similarity index 100% rename from GuiManagerDebug/Misc/SetName.int rename to GuiManager/Misc/SetName.int diff --git a/GuiManagerDebug/Misc/TopStack.int b/GuiManager/Misc/TopStack.int similarity index 100% rename from GuiManagerDebug/Misc/TopStack.int rename to GuiManager/Misc/TopStack.int diff --git a/GuiManagerDebug/Misc/addDominance.int b/GuiManager/Misc/addDominance.int similarity index 100% rename from GuiManagerDebug/Misc/addDominance.int rename to GuiManager/Misc/addDominance.int diff --git a/GuiManagerDebug/Misc/addHotKey.int b/GuiManager/Misc/addHotKey.int similarity index 100% rename from GuiManagerDebug/Misc/addHotKey.int rename to GuiManager/Misc/addHotKey.int diff --git a/GuiManagerDebug/Misc/alphanumsort.int b/GuiManager/Misc/alphanumsort.int similarity index 100% rename from GuiManagerDebug/Misc/alphanumsort.int rename to GuiManager/Misc/alphanumsort.int diff --git a/GuiManagerDebug/Misc/anchorRight.int b/GuiManager/Misc/anchorRight.int similarity index 100% rename from GuiManagerDebug/Misc/anchorRight.int rename to GuiManager/Misc/anchorRight.int diff --git a/GuiManager/Misc/center.int b/GuiManager/Misc/center.int new file mode 100644 index 0000000..fb22fea --- /dev/null +++ b/GuiManager/Misc/center.int @@ -0,0 +1,4 @@ +function gui:center() + self:centerX() + self:centerY() +end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/centerX.int b/GuiManager/Misc/centerX.int similarity index 100% rename from GuiManagerDebug/Misc/centerX.int rename to GuiManager/Misc/centerX.int diff --git a/GuiManagerDebug/Misc/centerY.int b/GuiManager/Misc/centerY.int similarity index 100% rename from GuiManagerDebug/Misc/centerY.int rename to GuiManager/Misc/centerY.int diff --git a/GuiManagerDebug/Misc/disrespectHierarchy.int b/GuiManager/Misc/disrespectHierarchy.int similarity index 100% rename from GuiManagerDebug/Misc/disrespectHierarchy.int rename to GuiManager/Misc/disrespectHierarchy.int diff --git a/GuiManagerDebug/Misc/getChildren.int b/GuiManager/Misc/getChildren.int similarity index 100% rename from GuiManagerDebug/Misc/getChildren.int rename to GuiManager/Misc/getChildren.int diff --git a/GuiManagerDebug/Misc/getColor.int b/GuiManager/Misc/getColor.int similarity index 100% rename from GuiManagerDebug/Misc/getColor.int rename to GuiManager/Misc/getColor.int diff --git a/GuiManagerDebug/Misc/getFullSize.int b/GuiManager/Misc/getFullSize.int similarity index 68% rename from GuiManagerDebug/Misc/getFullSize.int rename to GuiManager/Misc/getFullSize.int index 294667a..d2ad2d5 100644 --- a/GuiManagerDebug/Misc/getFullSize.int +++ b/GuiManager/Misc/getFullSize.int @@ -2,9 +2,9 @@ function gui:getFullSize() local maxx,maxy=-math.huge,-math.huge local temp = self:GetAllChildren() for i=1,#temp do - if temp[i].width>maxx then + if temp[i].width+temp[i].offset.pos.x>maxx then maxx=temp[i].width+temp[i].offset.pos.x - elseif temp[i].height>maxy then + elseif temp[i].height+temp[i].offset.pos.y>maxy then maxy=temp[i].height+temp[i].offset.pos.y end end diff --git a/GuiManagerDebug/Misc/getHighest.int b/GuiManager/Misc/getHighest.int similarity index 100% rename from GuiManagerDebug/Misc/getHighest.int rename to GuiManager/Misc/getHighest.int diff --git a/GuiManagerDebug/Misc/getLowest.int b/GuiManager/Misc/getLowest.int similarity index 100% rename from GuiManagerDebug/Misc/getLowest.int rename to GuiManager/Misc/getLowest.int diff --git a/GuiManagerDebug/Misc/isDescendant.int b/GuiManager/Misc/isDescendant.int similarity index 100% rename from GuiManagerDebug/Misc/isDescendant.int rename to GuiManager/Misc/isDescendant.int diff --git a/GuiManagerDebug/Misc/isHighest.int b/GuiManager/Misc/isHighest.int similarity index 100% rename from GuiManagerDebug/Misc/isHighest.int rename to GuiManager/Misc/isHighest.int diff --git a/GuiManagerDebug/Misc/isLowest.int b/GuiManager/Misc/isLowest.int similarity index 100% rename from GuiManagerDebug/Misc/isLowest.int rename to GuiManager/Misc/isLowest.int diff --git a/GuiManagerDebug/Misc/massMutate.int b/GuiManager/Misc/massMutate.int similarity index 100% rename from GuiManagerDebug/Misc/massMutate.int rename to GuiManager/Misc/massMutate.int diff --git a/GuiManagerDebug/Misc/newCheckBox.int b/GuiManager/Misc/newCheckBox.int similarity index 94% rename from GuiManagerDebug/Misc/newCheckBox.int rename to GuiManager/Misc/newCheckBox.int index ccd530c..607d5d9 100644 --- a/GuiManagerDebug/Misc/newCheckBox.int +++ b/GuiManager/Misc/newCheckBox.int @@ -1,4 +1,4 @@ -if love.filesystem.exists("CheckBoxes.png") then +if love.filesystem.getInfo("CheckBoxes.png") then _GuiPro.UC=gui:getTile("CheckBoxes.png",0,0,16,16) _GuiPro.C=gui:getTile("CheckBoxes.png",16,0,16,16) _GuiPro.UCH=gui:getTile("CheckBoxes.png",0,16,16,16) diff --git a/GuiManagerDebug/Misc/newMessageBox.int b/GuiManager/Misc/newMessageBox.int similarity index 100% rename from GuiManagerDebug/Misc/newMessageBox.int rename to GuiManager/Misc/newMessageBox.int diff --git a/GuiManagerDebug/Misc/newPart.int b/GuiManager/Misc/newPart.int similarity index 100% rename from GuiManagerDebug/Misc/newPart.int rename to GuiManager/Misc/newPart.int diff --git a/GuiManagerDebug/Misc/newProgressBar.int b/GuiManager/Misc/newProgressBar.int similarity index 100% rename from GuiManagerDebug/Misc/newProgressBar.int rename to GuiManager/Misc/newProgressBar.int diff --git a/GuiManagerDebug/Misc/newScrollBar.int b/GuiManager/Misc/newScrollBar.int similarity index 100% rename from GuiManagerDebug/Misc/newScrollBar.int rename to GuiManager/Misc/newScrollBar.int diff --git a/GuiManagerDebug/Misc/newScrollMenu.int b/GuiManager/Misc/newScrollMenu.int similarity index 100% rename from GuiManagerDebug/Misc/newScrollMenu.int rename to GuiManager/Misc/newScrollMenu.int diff --git a/GuiManagerDebug/Misc/removeAllChildren.int b/GuiManager/Misc/removeAllChildren.int similarity index 100% rename from GuiManagerDebug/Misc/removeAllChildren.int rename to GuiManager/Misc/removeAllChildren.int diff --git a/GuiManagerDebug/Misc/removeDominance.int b/GuiManager/Misc/removeDominance.int similarity index 100% rename from GuiManagerDebug/Misc/removeDominance.int rename to GuiManager/Misc/removeDominance.int diff --git a/GuiManagerDebug/Misc/respectHierarchy.int b/GuiManager/Misc/respectHierarchy.int similarity index 100% rename from GuiManagerDebug/Misc/respectHierarchy.int rename to GuiManager/Misc/respectHierarchy.int diff --git a/GuiManagerDebug/Misc/round.int b/GuiManager/Misc/round.int similarity index 100% rename from GuiManagerDebug/Misc/round.int rename to GuiManager/Misc/round.int diff --git a/GuiManagerDebug/Misc/setBG.int b/GuiManager/Misc/setBG.int similarity index 100% rename from GuiManagerDebug/Misc/setBG.int rename to GuiManager/Misc/setBG.int diff --git a/GuiManager/Misc/setColor.int b/GuiManager/Misc/setColor.int new file mode 100644 index 0000000..7a81a6f --- /dev/null +++ b/GuiManager/Misc/setColor.int @@ -0,0 +1,14 @@ +function gui:setColor(a,b,c) + if type(a)=="string" then + self.Color=Color[a] + elseif type(a)=="number" then + self.Color=Color.new(a,b,c) + end +end +function gui:setTextColor(a,b,c) + if type(a)=="string" then + self.TextColor=Color[a] + elseif type(a)=="number" then + self.TextColor=Color.new(a,b,c) + end +end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/setDefualtFont.int b/GuiManager/Misc/setDefualtFont.int similarity index 100% rename from GuiManagerDebug/Misc/setDefualtFont.int rename to GuiManager/Misc/setDefualtFont.int diff --git a/GuiManagerDebug/Misc/setHotKey.int b/GuiManager/Misc/setHotKey.int similarity index 100% rename from GuiManagerDebug/Misc/setHotKey.int rename to GuiManager/Misc/setHotKey.int diff --git a/GuiManager/Misc/setNewFont.int b/GuiManager/Misc/setNewFont.int new file mode 100644 index 0000000..2ee8adf --- /dev/null +++ b/GuiManager/Misc/setNewFont.int @@ -0,0 +1,7 @@ +function gui:setNewFont(FontSize,filename) + if filename then + self.Font = love.graphics.newFont(filename, tonumber(FontSize)) + else + self.Font=love.graphics.setNewFont(tonumber(FontSize)) + end +end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/setParent.int b/GuiManager/Misc/setParent.int similarity index 100% rename from GuiManagerDebug/Misc/setParent.int rename to GuiManager/Misc/setParent.int diff --git a/GuiManagerDebug/Misc/setVisibility.int b/GuiManager/Misc/setVisibility.int similarity index 100% rename from GuiManagerDebug/Misc/setVisibility.int rename to GuiManager/Misc/setVisibility.int diff --git a/GuiManagerDebug/Misc/setgetText.int b/GuiManager/Misc/setgetText.int similarity index 100% rename from GuiManagerDebug/Misc/setgetText.int rename to GuiManager/Misc/setgetText.int diff --git a/GuiManager/Text/newTextBox.int b/GuiManager/Text/newTextBox.int new file mode 100644 index 0000000..69e2683 --- /dev/null +++ b/GuiManager/Text/newTextBox.int @@ -0,0 +1,181 @@ +function string:insert(p,s) + return ("%s%s%s"):format(self:sub(1,p), s, self:sub(p+1)) +end +function string:remove(p,l) + l=l or 1 + return ("%s%s"):format(self:sub(1,p-1), self:sub(p+l)) +end +function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) + x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) + local c=self:newBase("TextBox",name, x, y, w, h, sx ,sy ,sw ,sh) + c.ClearOnFocus=false + c.LoseFocusOnEnter=true + c.Tween=0 + c.XTween=0 + c.FontHeight=_defaultfont:getHeight() + c.Font=_defaultfont + c.FontSize=15 + c.TextFormat="center" + c.text = t + c.ttext= t + c.AutoScaleText=false + c.TextVisibility=1 + c.Color = {220, 220, 220} + c.TextColor = {0, 0, 0} + c.Active=false + c.hidden=false + c.cursor={0,1} + c.mark=nil + c.arrowkeys=false + c.funcF={function() + love.keyboard.setTextInput(true,0,200,400,200) + end} + c.cooldown=false + c.cooldown2=false + c.funcE={function() + love.keyboard.setTextInput(false) + end} + function c:triggerEnter() + for cc=1,#self.funcE do + self.funcE[cc](self,self.ttext) + end + self.text="" + self.ttext="" + end + c.Enter=true + c.Alarm=multi:newAlarm(.1) + c.Alarm.parent=c + c.Alarm:OnRing(function(alarm) alarm.parent.cooldown=false end) + c.Alarm2=multi:newAlarm(.5) + c.Alarm2.parent=c + c.Alarm2:OnRing(function(alarm) alarm.parent.cooldown2=false end) + c.ArrowAlarm=multi:newAlarm(.1) + c.ArrowAlarm.parent=c + c.ArrowAlarm:OnRing(function(alarm) alarm.parent.arrowkeys=false end) + function c:OnFocus(func) + table.insert(self.funcF,func) + end + function c:OnEnter(func) + table.insert(self.funcE,func) + end + c:OnClicked(function(b,self) + self:focus() + end) + function c:focus() + for cc=1,#self.funcF do + self.funcF[cc](self) + end + if self.Active==false then + if self.ClearOnFocus==true then + self.text="" + self.ttext="" + end + for tb=1,#gui.TB do + if gui.TB[tb]~=nil then + gui.TB[tb].Active=false + end + end + self.Active=true + end + end + c:OnClicked(function(b,self,x,y) + local dwidth, wrappedtext = _defaultfont:getWrap(self.text:sub(1,self.cursor[1]), self.width) + local height = _defaultfont:getHeight() + if #wrappedtext>=1 then + width= _defaultfont:getWidth(wrappedtext[#wrappedtext]) + self.cursor[2]=#wrappedtext + else + self.cursor[2]=1 + width=0 + end + yc=math.ceil(((y/self.DPI)-(self.FontHeight/2)+self.Tween-self.y)/height) + xc=math.floor(x) + end) + c:AddDrawRuleE(function(self) + if self.Active then + local dwidth, wrappedtext = _defaultfont:getWrap(self.text:sub(1,self.cursor[1]), self.width) + local height = _defaultfont:getHeight() + if #wrappedtext>=1 then + width= _defaultfont:getWidth(wrappedtext[#wrappedtext]) + self.cursor[2]=#wrappedtext + else + self.cursor[2]=1 + width=0 + end + x1=width+2+self.x+self.XTween + y1=(self.y+(height*(self.cursor[2]-1))+(self.FontHeight/2)+self.Tween)*self.DPI + x2=width+2+self.x+self.XTween + y2=(self.y+(self.FontHeight/2)+self.Tween*self.DPI)+height*self.cursor[2] + love.graphics.line(x1,y1,x2,y2) + end + end) + c:OnUpdate(function(self) + if love.keyboard.isDown("backspace") and self.Active and self.cooldown==false then + if #self.text>0 then + self.text = self.text:remove(self.cursor[1]) + self.ttext = self.ttext:remove(self.cursor[1]) + self.cursor[1]=self.cursor[1]-1 + end + self.cooldown=true + self.Alarm:Reset() + elseif love.keyboard.isDown("backspace")==false then + self.cooldown=false + end + if love.keyboard.isDown("left") and self.arrowkeys==false and self.Active then + self.arrowkeys=true + self.cursor[1]=self.cursor[1]-1 + if self.cursor[1]<0 then + self.cursor[1]=0 + end + self.ArrowAlarm:Reset() + elseif love.keyboard.isDown("right") and self.arrowkeys==false and self.Active then + self.arrowkeys=true + self.cursor[1]=self.cursor[1]+1 + if self.cursor[1]>#self.text then + self.cursor[1]=#self.text + end + self.ArrowAlarm:Reset() + end + if love.keyboard.isDown("delete") and self.Active then + if #self.text>0 then + self.text = "" + self.ttext = "" + self.cursor[1]=1 + end + elseif (love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) and love.keyboard.isDown("return") and self.cooldown2==false then + self.text=self.text.."\n" + self.ttext=self.ttext.."\n" + self.cooldown2=true + c.Alarm2:Reset() + elseif (love.keyboard.isDown("return") or love.keyboard.isDown("kpenter")) and self.Active and self.Enter and not(love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) then + if self.LoseFocusOnEnter then + self.Active=false + else + self.Active=true + end + for cc=1,#self.funcE do + self.funcE[cc](self,self.ttext) + end + end + end) + table.insert(gui.TB,c) + return c +end +--TEXT BOX HELPER FUNCTION +function love.textinput(t) + for tb=1,#gui.TB do + if gui.TB[tb]~=nil then + if gui.TB[tb].Active then + if gui.TB[tb].hidden then + --gui.TB[tb].text=gui.TB[tb].text.."*" + gui.TB[tb].text=gui.TB[tb].text:insert(gui.TB[tb].cursor[1],"*") + else + --gui.TB[tb].text=gui.TB[tb].text..t + gui.TB[tb].text=gui.TB[tb].text:insert(gui.TB[tb].cursor[1],t) + end + gui.TB[tb].ttext=gui.TB[tb].ttext:insert(gui.TB[tb].cursor[1],t) + gui.TB[tb].cursor[1]=gui.TB[tb].cursor[1]+1 + end + end + end +end \ No newline at end of file diff --git a/GuiManagerDebug/Text/newTextButton.int b/GuiManager/Text/newTextButton.int similarity index 100% rename from GuiManagerDebug/Text/newTextButton.int rename to GuiManager/Text/newTextButton.int diff --git a/GuiManagerDebug/Text/newTextLabel.int b/GuiManager/Text/newTextLabel.int similarity index 100% rename from GuiManagerDebug/Text/newTextLabel.int rename to GuiManager/Text/newTextLabel.int diff --git a/GuiManager/Text/widthToFontSize.int b/GuiManager/Text/widthToFontSize.int new file mode 100644 index 0000000..a36b6dc --- /dev/null +++ b/GuiManager/Text/widthToFontSize.int @@ -0,0 +1,5 @@ +function gui:widthToTextSize(n) + if self.Font then + self:setDualDim(nil,nil,self.Font:getWidth(self.text)+(n or 4),nil,nil,nil,0) + end +end \ No newline at end of file diff --git a/GuiManagerDebug/init.lua b/GuiManager/init.lua similarity index 85% rename from GuiManagerDebug/init.lua rename to GuiManager/init.lua index 31e5632..2eba1e6 100644 --- a/GuiManagerDebug/init.lua +++ b/GuiManager/init.lua @@ -1,4 +1,4 @@ -_defaultfont = love.graphics.getFont() +utf8 = require("utf8") gui = {} gui.__index = gui gui.TB={} @@ -6,14 +6,15 @@ gui.Version="VERSION" -- Is it really ready for release? _GuiPro={GBoost=true,hasDrag=false,DragItem={},Children={},Visible=true,count=0,x=0,y=0,height=0,width=0,update=function(self) local things=GetAllChildren2(self) UpdateThings(things) end,draw=function(self) local things=GetAllChildren(self) DrawThings(things) end,getChildren=function(self) return self.Children end} _GuiPro.Clips={} _GuiPro.rotate=0 +_defaultfont = love.graphics.setNewFont(12) setmetatable(_GuiPro, gui) function gui:LoadInterface(file) local add=".int" if string.find(file,".",1,true) then add="" end - if love.filesystem.exists(file..add) then + if love.filesystem.getInfo(file..add) then a,b=pcall(love.filesystem.load(file..add)) if a then - print("Loaded: "..file) + --print("Loaded: "..file) else print("Error loading file: "..file) print(a,b) @@ -33,7 +34,6 @@ function gui.LoadAll(dir) end -- Start Of Load ---gui.LoadAll("GuiManager/LibCore") gui.LoadAll("GuiManager/Core") gui.LoadAll("GuiManager/Image-Animation") gui.LoadAll("GuiManager/Frame") @@ -41,16 +41,14 @@ gui.LoadAll("GuiManager/Item") gui.LoadAll("GuiManager/Misc") gui.LoadAll("GuiManager/Text") gui.LoadAll("GuiManager/Drawing") -gui.LoadAll("GuiManager/Combos") ---gui.LoadAll("GuiManager/WIP") -multi.boost=2 +multi.boost=2 -- End of Load gui:respectHierarchy() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() multi:newLoop():OnLoop(function() _GuiPro.width,_GuiPro.height=love.graphics.getDimensions() _GuiPro:update() end) multi:onDraw(function() _GuiPro:draw() end) -gui.ff=gui:newItem("",nil,"",0,0,0,0,0,0,1,1) +gui.ff=gui:newFrame("",0,0,0,0,0,0,1,1) gui.ff.Color={255,255,255} gui.ff:OnUpdate(function(self) self:BottomStack() diff --git a/GuiManagerDebug/Misc/Center.int b/GuiManagerDebug/Misc/Center.int deleted file mode 100644 index 0089c93..0000000 --- a/GuiManagerDebug/Misc/Center.int +++ /dev/null @@ -1,4 +0,0 @@ -function gui:Center() - local x,y=self:getFullSize() - self:SetDualDim(-math.floor(x/2),-math.floor(y/2),nil,nil,.5,.5) -end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/setColor.int b/GuiManagerDebug/Misc/setColor.int deleted file mode 100644 index 6b8f05a..0000000 --- a/GuiManagerDebug/Misc/setColor.int +++ /dev/null @@ -1,7 +0,0 @@ -function gui:setColor(a,b,c) - if type(a)=="string" then - self.Color=Color[a] - elseif type(a)=="number" then - self.Color=Color.new(a,b,c) - end -end \ No newline at end of file diff --git a/GuiManagerDebug/Misc/setNewFont.int b/GuiManagerDebug/Misc/setNewFont.int deleted file mode 100644 index 93d95c5..0000000 --- a/GuiManagerDebug/Misc/setNewFont.int +++ /dev/null @@ -1,3 +0,0 @@ -function gui:setNewFont(FontSize) - self.Font=love.graphics.setNewFont(tonumber(FontSize)) -end \ No newline at end of file diff --git a/GuiManagerDebug/Text/newTextBox.int b/GuiManagerDebug/Text/newTextBox.int deleted file mode 100644 index 445a560..0000000 --- a/GuiManagerDebug/Text/newTextBox.int +++ /dev/null @@ -1,104 +0,0 @@ -function gui:newTextBox(t,name, x, y, w, h, sx ,sy ,sw ,sh) - x,y,w,h,sx,sy,sw,sh=filter(name, x, y, w, h, sx ,sy ,sw ,sh) - local c=self:newBase("TextBox",name, x, y, w, h, sx ,sy ,sw ,sh) - c.ClearOnFocus=false - c.LoseFocusOnEnter=true - c.Tween=0 - c.XTween=0 - c.FontHeight=_defaultfont:getHeight() - c.Font=_defaultfont - c.FontSize=15 - c.TextFormat="center" - c.text = t - c.ttext= t - c.AutoScaleText=false - c.TextVisibility=1 -- 0=invisible,1=solid (self.TextVisibility*254+1) - c.Color = {220, 220, 220} - c.TextColor = {0, 0, 0} - c.Active=false - c.hidden=false - c.funcF={function() - love.keyboard.setTextInput(true) - end} - c.cooldown=false - c.cooldown2=false - c.funcE={function() - love.keyboard.setTextInput(false) - end} - c.Enter=true - c.Alarm=multi:newAlarm(.1) - c.Alarm.parent=c - c.Alarm:OnRing(function(alarm) alarm.parent.cooldown=false end) - c.Alarm2=multi:newAlarm(.5) - c.Alarm2.parent=c - c.Alarm2:OnRing(function(alarm) alarm.parent.cooldown2=false end) - function c:OnFocus(func) - table.insert(self.funcF,func) - end - function c:OnEnter(func) - table.insert(self.funcE,func) - end - c:OnClicked(function(b,self) - for cc=1,#self.funcF do - self.funcF[cc](self) - end - if self.Active==false then - if self.ClearOnFocus==true then - self.text="" - self.ttext="" - end - for tb=1,#gui.TB do - if gui.TB[tb]~=nil then - gui.TB[tb].Active=false - end - end - self.Active=true - end - end) - c:OnUpdate(function(self) - if love.keyboard.isDown("backspace") and self.Active and self.cooldown==false then - self.text=string.sub(self.text,1,-2) - self.ttext=string.sub(self.ttext,1,-2) - self.cooldown=true - c.Alarm:Reset() - elseif love.keyboard.isDown("backspace")==false then - self.cooldown=false - end - if love.keyboard.isDown("delete") and self.Active then - self.text=string.sub(self.text,1,-2) - self.ttext=string.sub(self.text,1,-2) - elseif (love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) and love.keyboard.isDown("return") and self.cooldown2==false then - self.text=self.text.."\n" - self.ttext=self.ttext.."\n" - self.cooldown2=true - c.Alarm2:Reset() - elseif (love.keyboard.isDown("return") or love.keyboard.isDown("enter") or love.keyboard.isDown("kpenter")) and self.Active and self.Enter and not(love.keyboard.isDown("lshift") or love.keyboard.isDown("rshift")) then - if self.LoseFocusOnEnter then - self.Active=false - else - self.Active=true - end - for cc=1,#self.funcE do - self.funcE[cc](self,self.ttext) - end - end - end) - table.insert(gui.TB,c) - return c -end ---TEXT BOX HELPER FUNCTION -function love.textinput(t) - for tb=1,#gui.TB do - if gui.TB[tb]~=nil then - if gui.TB[tb].Active then - if gui.TB[tb].hidden then - gui.TB[tb].text=gui.TB[tb].text.."*" - gui.TB[tb].ttext=gui.TB[tb].ttext..t - else - gui.TB[tb].text=gui.TB[tb].text..t - gui.TB[tb].ttext=gui.TB[tb].ttext..t - end - end - end - end -end \ No newline at end of file diff --git a/Utils.lua b/Utils.lua new file mode 100644 index 0000000..5f97d52 --- /dev/null +++ b/Utils.lua @@ -0,0 +1,770 @@ +-- os Additions +function os.getSystemBit() + if (os.getenv("PROCESSOR_ARCHITEW6432")=="AMD64" or os.getenv("PROCESSOR_ARCHITECTURE")=="AMD64") then + return 64 + else + return 32 + end +end +function os.sleep(n) + if not n then n=0 end + local t0 = os.clock() + while os.clock() - t0 <= n do end +end +function os.pause(msg) + if msg ~= nil then + print(msg) + end + io.read() +end +function os.batCmd(cmd) + io.mkFile("temp.bat",cmd) + local temp = os.execute([[temp.bat]]) + io.delFile("temp.bat") + return temp +end +function os._getOS() + if package.config:sub(1,1)=="\\" then + return "windows" + else + return "unix" + end +end +function os.getOS(t) + if not t then + return os._getOS() + end + if os._getOS()=="unix" then + fh,err = io.popen("uname -o 2>/dev/null","r") + if fh then + osname = fh:read() + end + if osname then return osname end + end + local winver="'Unknown Version'" + local a,b,c=os.capture("ver"):match("(%d+).(%d+).(%d+)") + local win=a.."."..b.."."..c + if type(t)=="string" then + win=t + end + if win=="4.00.950" then + winver="95" + elseif win=="4.00.1111" then + winver="95 OSR2" + elseif win=="4.00.1381" then + winver="NT 4.0" + elseif win=="4.10.1998" then + winver="98" + elseif win=="4.10.2222" then + winver="98 SE" + elseif win=="4.90.3000" then + winver="ME" + elseif win=="5.00.2195" then + winver="2000" + elseif win=="5.1.2600" then + winver="XP" + elseif win=="5.2.3790" then + winver="Server 2003" + elseif win=="6.0.6000" then + winver="Vista/Windows Server 2008" + elseif win=="6.0.6002" then + winver="Vista SP2" + elseif win=="6.1.7600" then + winver="7/Windows Server 2008 R2" + elseif win=="6.1.7601" then + winver="7 SP1/Windows Server 2008 R2 SP1" + elseif win=="6.2.9200" then + winver="8/Windows Server 2012" + elseif win=="6.3.9600" then + winver="8.1/Windows Server 2012" + elseif win=="6.4.9841" then + winver="10 Technical Preview 1" + elseif win=="6.4.9860" then + winver="10 Technical Preview 2" + elseif win=="6.4.9879" then + winver="10 Technical Preview 3" + elseif win=="10.0.9926" then + winver="10 Technical Preview 4" + end + return "Windows "..winver +end +function os.getLuaArch() + return (#tostring({})-7)*4 +end +if os.getOS()=="windows" then + function os.sleep(n) + if n > 0 then os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL") end + end +else + function os.sleep(n) + os.execute("sleep " .. tonumber(n)) + end +end +function os.capture(cmd, raw) + local f = assert(io.popen(cmd, 'r')) + local s = assert(f:read('*a')) + f:close() + if raw then return s end + s = string.gsub(s, '^%s+', '') + s = string.gsub(s, '%s+$', '') + s = string.gsub(s, '[\n\r]+', ' ') + return s +end +function os.getCurrentUser() + return os.getenv("$USER") or os.getenv("USERNAME") +end +-- string Additions +function string.random(n) + local str = "" + strings = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} + for i=1,n do + h = math.random(1,#strings) + str = str..""..strings[h] + end + return str +end +function string.linesToTable(s) + local t = {} + local i = 0 + while true do + i = string.find(s, "\n", i+1) + if i == nil then return t end + table.insert(t, i) + end +end +function string.lines(str) + local t = {} + local function helper(line) table.insert(t, line) return "" end + helper((str:gsub("(.-)\r?\n", helper))) + return t +end +function string.split(str, pat) + local t = {} -- NOTE: use {n = 0} in Lua-5.0 + local fpat = "(.-)" .. pat + local last_end = 1 + local s, e, cap = str:find(fpat, 1) + while s do + if s ~= 1 or cap ~= "" then + table.insert(t,cap) + end + last_end = e+1 + s, e, cap = str:find(fpat, last_end) + end + if last_end <= #str then + cap = str:sub(last_end) + table.insert(t, cap) + end + return t +end +function string.shuffle(inputStr) + math.randomseed(os.time()); + local outputStr = ""; + local strLength = string.len(inputStr); + while (strLength ~=0) do + local pos = math.random(strLength); + outputStr = outputStr..string.sub(inputStr,pos,pos); + inputStr = inputStr:sub(1, pos-1) .. inputStr:sub(pos+1); + strLength = string.len(inputStr); + end + return outputStr; +end +function string.genKeys(chars,a,f,s,GG) + if GG then + chars=string.rep(chars,a) + end + if s then + chars=string.shuffle(chars) + end + b=#chars + if a==0 then return end + local taken = {} local slots = {} + for i=1,a do slots[i]=0 end + for i=1,b do taken[i]=false end + local index = 1 + local tab={} + for i=1,#chars do + table.insert(tab,chars:sub(i,i)) + end + while index > 0 do repeat + repeat slots[index] = slots[index] + 1 + until slots[index] > b or not taken[slots[index]] + if slots[index] > b then + slots[index] = 0 + index = index - 1 + if index > 0 then + taken[slots[index]] = false + end + break + else + taken[slots[index]] = true + end + if index == a then + local tt={} + for i=1,a do + table.insert(tt,tab[slots[i]]) + end + f(table.concat(tt)) + taken[slots[index]] = false + break + end + index = index + 1 + until true end +end +-- io Additions +function io.getInput(msg) + if msg ~= nil then + io.write(msg) + end + return io.read() +end +function io.scanDir(directory) + directory=directory or io.getDir() + local i, t, popen = 0, {}, io.popen + if os.getOS()=="unix" then + for filename in popen('ls -a "'..directory..'"'):lines() do + i = i + 1 + t[i] = filename + end + else + for filename in popen('dir "'..directory..'" /b'):lines() do + i = i + 1 + t[i] = filename + end + end + return t +end +function io.buildFromTree(tbl, indent,folder) + if not indent then indent = 0 end + if not folder then folder = "" end + for k, v in pairs(tbl) do + formatting = string.rep(" ", indent) .. k .. ":" + if type(v) == "table" then + if not(io.dirExists(folder..string.sub(formatting,1,-2))) then + io.mkDir(folder..string.sub(formatting,1,-2)) + end + io.buildFromTree(v,0,folder..string.sub(formatting,1,-2).."\\") + else + a=string.find(tostring(v),":",1,true) + if a then + file=string.sub(tostring(v),1,a-1) + data=string.sub(tostring(v),a+1) + io.mkFile(folder..file,data,"wb") + else + io.mkFile(folder..v,"","wb") + end + end + end +end +function io.cpFile(path,topath) + if os.getOS()=="unix" then + os.execute("cp "..file1.." "..file2) + else + os.execute("Copy "..path.." "..topath) + end +end +function io.delDir(directoryname) + if os.getOS()=="unix" then + os.execute("rm -rf "..directoryname) + else + os.execute("rmdir "..directoryname.." /s /q") + end +end +function io.delFile(path) + os.remove(path) +end +function io.mkDir(dirname) + os.execute("mkdir \"" .. dirname.."\"") +end +function io.mkFile(filename,data,tp) + if not(tp) then tp="wb" end + if not(data) then data="" end + file = io.open(filename, tp) + if file==nil then return end + file:write(data) + file:close() +end +function io.movFile(path,topath) + io.cpFile(path,topath) + io.delFile(path) +end +function io.listFiles(dir) + if not(dir) then dir="" end + local f = io.popen("dir \""..dir.."\"") + if f then + return f:read("*a") + else + print("failed to read") + end +end +function io.getDir(dir) + if not dir then return io.getWorkingDir() end + if os.getOS()=="unix" then + return os.capture("cd "..dir.." ; cd") + else + return os.capture("cd "..dir.." & cd") + end +end +function io.getWorkingDir() + return io.popen"cd":read'*l' +end +function io.fileExists(path) + g=io.open(path or '','r') + if path =="" then + p="empty path" + return nil + end + if g~=nil and true or false then + p=(g~=nil and true or false) + end + if g~=nil then + io.close(g) + else + return false + end + return p +end +function io.fileCheck(file_name) + if not file_name then print("No path inputed") return false end + local file_found=io.open(file_name, "r") + if file_found==nil then + file_found=false + else + file_found=true + end + return file_found +end +function io.dirExists(strFolderName) + strFolderName = strFolderName or io.getDir() + local fileHandle, strError = io.open(strFolderName.."\\*.*","r") + if fileHandle ~= nil then + io.close(fileHandle) + return true + else + if string.match(strError,"No such file or directory") then + return false + else + return true + end + end +end +function io.listItems(dir) + if io.dirExists(dir) then + temp=io.listFiles(dir) -- current directory if blank + if io.getDir(dir)=="C:\\\n" then + a,b=string.find(temp,"C:\\",1,true) + a=a+2 + else + a,b=string.find(temp,"..",1,true) + end + temp=string.sub(temp,a+2) + list=string.linesToTable(temp) + temp=string.sub(temp,1,list[#list-2]) + slist=string.lines(temp) + table.remove(slist,1) + table.remove(slist,#slist) + temp={} + temp2={} + for i=1,#slist do + table.insert(temp,string.sub(slist[i],40,-1)) + end + return temp + else + return nil + end +end +function io.getDirectories(dir,l) + if dir then + dir=dir.."\\" + else + dir="" + end + local temp2=io.scanDir(dir) + for i=#temp2,1,-1 do + if io.fileExists(dir..temp2[i]) then + table.remove(temp2,i) + elseif l then + temp2[i]=dir..temp2[i] + end + end + return temp2 +end +function io.getFiles(dir,l) + if dir then + dir=dir.."\\" + else + dir="" + end + local temp2=io.scanDir(dir) + for i=#temp2,1,-1 do + if io.dirExists(dir..temp2[i]) then + table.remove(temp2,i) + elseif l then + temp2[i]=dir..temp2[i] + end + end + return temp2 +end +function io.getFullName(name) + local temp=name or arg[0] + if string.find(temp,"\\",1,true) or string.find(temp,"/",1,true) then + temp=string.reverse(temp) + a,b=string.find(temp,"\\",1,true) + if not(a) or not(b) then + a,b=string.find(temp,"/",1,true) + end + return string.reverse(string.sub(temp,1,b-1)) + end + return temp +end +function io.getName(file) + local name=io.getFullName(file) + name=string.reverse(name) + a,b=string.find(name,".",1,true) + name=string.sub(name,a+1,-1) + return string.reverse(name) +end +function io.readFile(file) + local f = io.open(file, "rb") + local content = f:read("*all") + f:close() + return content +end +function io.getExtension(file) + local file=io.getFullName(file) + file=string.reverse(file) + local a,b=string.find(file,".",0,true) + local temp=string.sub(file,1,b) + return string.reverse(temp) +end +function io.pathToTable(path) + local p=io.splitPath(path) + local temp={} + temp[p[1]]={} + local last=temp[p[1]] + for i=2,#p do + snd=last + last[p[i]]={} + last=last[p[i]] + end + return temp,last,snd +end +function io.splitPath(str) + return string.split(str,'[\\/]+') +end + +function io.parseDir(dir,t) + io.tempFiles={} + function _p(dir) + local dirs=io.getDirectories(dir,true) + local files=io.getFiles(dir,true) + for i=1,#files do + p,l,s=io.pathToTable(files[i]) + if t then + s[io.getFullName(files[i])]=io.readFile(files[i]) + else + s[io.getFullName(files[i])]=io.open(files[i],"r+") + end + table.merge(io.tempFiles,p) + end + for i=1,#dirs do + table.merge(io.tempFiles,io.pathToTable(dirs[i])) + _p(dirs[i],t) + end + end + _p(dir) + return io.tempFiles +end +function io.parsedir(dir,f) + io.tempFiles={} + function _p(dir,f) + local dirs=io.getDirectories(dir,true) + local files=io.getFiles(dir,true) + for i=1,#files do + if not f then + table.insert(io.tempFiles,files[i]) + else + f(files[i]) + end + end + for i=1,#dirs do + _p(dirs[i],f) + end + end + _p(dir,f) + return io.tempFiles +end +function io.driveReady(drive) + drive=drive:upper() + if not(drive:find(":",1,true)) then + drive=drive..":" + end + drives=io.getDrives() + for i=1,#drives do + if drives[i]==drive then + return true + end + end + return false +end +function io.getDrives() + if os.getOS()=="windows" then + local temp={} + local t1=os.capture("wmic logicaldisk where drivetype=2 get deviceid, volumename",true) + local t2=os.capture("wmic logicaldisk where drivetype=3 get deviceid, volumename",true) + for drive,d2 in t1:gmatch("(.:)%s-(%w+)") do + if #d2>1 then + table.insert(temp,drive) + end + end + for drive in t2:gmatch("(.:)") do + table.insert(temp,drive) + end + return temp + end + error("Command is windows only!") +end +-- table Additions +function table.dump(t,indent) + local names = {} + if not indent then indent = "" end + for n,g in pairs(t) do + table.insert(names,n) + end + table.sort(names) + for i,n in pairs(names) do + local v = t[n] + if type(v) == "table" then + if(v==t) then + print(indent..tostring(n)..": <-") + else + print(indent..tostring(n)..":") + table.dump(v,indent.." ") + end + else + if type(v) == "function" then + print(indent..tostring(n).."()") + else + print(indent..tostring(n)..": "..tostring(v)) + end + end + end +end +function table.alphanumsort(o) + local function padnum(d) local dec, n = string.match(d, "(%.?)0*(.+)") + return #dec > 0 and ("%.12f"):format(d) or ("%s%03d%s"):format(dec, #n, n) + end + table.sort(o, function(a,b) return tostring(a):gsub("%.?%d+",padnum)..("%3d"):format(#b)< tostring(b):gsub("%.?%d+",padnum)..("%3d"):format(#a) end) + return o +end +function table.foreach(t,f) + for i,v in pairs(t) do + f(v) + end +end +function table.merge(t1, t2) + for k,v in pairs(t2) do + if type(v) == "table" then + if type(t1[k] or false) == "table" then + table.merge(t1[k] or {}, t2[k] or {}) + else + t1[k] = v + end + else + t1[k] = v + end + end + return t1 +end +function table.print(tbl, indent) + if not indent then indent = 0 end + for k, v in pairs(tbl) do + formatting = string.rep(" ", indent) .. k .. ": " + if type(v) == "table" then + print(formatting) + table.print(v, indent+1) + else + print(formatting .. tostring(v)) + end + end +end +function table.merge(t1, t2) + for k,v in pairs(t2) do + if type(v) == "table" then + if type(t1[k] or false) == "table" then + table.merge(t1[k] or {}, t2[k] or {}) + else + t1[k] = v + end + else + t1[k] = v + end + end + return t1 +end +function table.clear(t) + for k in pairs (t) do + t[k] = nil + end +end +function table.copy(t) + function deepcopy(orig) + local orig_type = type(orig) + local copy + if orig_type == 'table' then + copy = {} + for orig_key, orig_value in next, orig, nil do + copy[deepcopy(orig_key)] = deepcopy(orig_value) + end + setmetatable(copy, deepcopy(getmetatable(orig))) + else -- number, string, boolean, etc + copy = orig + end + return copy + end + return deepcopy(t) +end +function table.swap(tab,i1,i2) + tab[i1],tab[i2]=tab[i2],tab[i1] +end +function table.append(t1, ...) + t1,t2= t1 or {},{...} + for k,v in pairs(t2) do + t1[#t1+1]=t2[k] + end + return t1 +end +function table.compare(t1, t2,d) + if d then + return table.deepCompare(t1,t2) + end + --if #t1 ~= #t2 then return false end + if #t2>#t1 then + for i=1,#t2 do + if t1[i] ~= t2[i] then + return false,t2[i] + end + end + else + for i=1,#t1 do + if t1[i] ~= t2[i] then + return false,t2[i] + end + end + end + return true +end +function table.deepCompare(t1,t2) + if t1==t2 then return true end + if (type(t1)~="table") then return false end + local mt1 = getmetatable(t1) + local mt2 = getmetatable(t2) + if( not table.deepCompare(mt1,mt2) ) then return false end + for k1,v1 in pairs(t1) do + local v2 = t2[k1] + if( not table.deepCompare(v1,v2) ) then return false end + end + for k2,v2 in pairs(t2) do + local v1 = t1[k2] + if( not table.deepCompare(v1,v2) ) then return false end + end + return true +end +-- Math Additions +local Y = function(g) local a = function(f) return f(f) end return a(function(f) return g(function(x) local c=f(f) return c(x) end) end) end +local F = function(f) return function(n)if n == 0 then return 1 else return n*f(n-1) end end end +math.factorial = Y(F) +math.fib={} +math.fib.fibL={} +setmetatable(math.fib,{__call=function(self,n) + if n<=2 then + return 1 + else + if self.fibL[n] then + return self.fibL[n] + else + local t=math.fib(n-1)+math.fib(n-2) + self.fibL[n]=t + return t + end + end +end}) +local floor,insert = math.floor, table.insert +function math.basen(n,b) + n = floor(n) + if not b or b == 10 then return tostring(n) end + local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + local t = {} + local sign = "" + if n < 0 then + sign = "-" + n = -n + end + repeat + local d = (n % b) + 1 + n = floor(n / b) + insert(t, 1, digits:sub(d,d)) + until n == 0 + return sign .. table.concat(t,"") +end +function math.convbase(n,b,tb) + return math.basen(tonumber(tostring(n),b),tb) +end +if BigNum then + function BigNum.mod(a,b) + return a-((a/b)*b) + end + local floor,insert = math.floor, table.insert + function math.basen(n,b) + n = BigNum.new(n) + if not b or b == 10 then return tostring(n) end + local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + local t = {} + local sign = "" + if n < BigNum.new(0) then + sign = "-" + n = -n + end + repeat + local d = BigNum.mod(n , b) + 1 + n = n/b + d=tonumber(tostring(d)) + insert(t, 1, digits:sub(d,d)) + until tonumber(tostring(n)) == 0 + return sign .. table.concat(t,"") + end + function math.to10(n,b) + local num=tostring(n) + local sum=BigNum.new() + local digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" + for i=1,#num do + local v=digits:find(num:sub(i,i),1,true) + sum=sum+BigNum.new(tonumber(v)-1)*BigNum.pow(BigNum.new(b),BigNum.new(#num-i)) + end + return sum + end + function math.convbase(n,b,tb) + return math.basen(math.to10(n,b),tb) + end +end +function math.numfix(n,x) + local str=tostring(n) + if #str 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/merger.lua b/merger.lua new file mode 100644 index 0000000..d4187a8 --- /dev/null +++ b/merger.lua @@ -0,0 +1,39 @@ +require("utils") +require("bin") +print("Library binder version 1.0\n") +ver=io.getInput("Version #? ") +merged=bin.new() +init=bin.load("GuiManager/init.lua") +init:gsub("gui.Version=\"VERSION\"","gui.Version=\""..ver.."\"") +print("Parsing init file...") +a,b=init.data:find("-- Start Of Load") +c,d=init.data:find("-- End of Load") +_o=init:sub(b+1,c-1) +print("Setting up headers...") +start=init:sub(1,a-1) +_end=init:sub(d+1,-1) +merged:tackE(start.."\n") +print("Parsing paths...") +for path in _o:gmatch("\"(.-)\"") do + files=io.scanDir(path) + for i=1,#files do + merged:tackE(bin.load(path.."/"..files[i]).data.."\n") + end +end +merged:tackE(_end.."\n") +print("Finishing up...") +merged:tofile("GuiManager.lua") +print("GuiManager.lua has been created!") +os.sleep(3) +--[[ +-- Start Of Load +gui.LoadAll("GuiManager/Core") +gui.LoadAll("GuiManager/Animation") +gui.LoadAll("GuiManager/Frame") +gui.LoadAll("GuiManager/Image") +gui.LoadAll("GuiManager/Item") +gui.LoadAll("GuiManager/Misc") +gui.LoadAll("GuiManager/Text") +gui.LoadAll("GuiManager/Drawing") +-- End of Load +]]