Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[===============[ ]===============]local Plugin = PluginManager():CreatePlugin()--[===============[ ]===============]local Button = Plugin:CreateToolbar("GUIStudio"):CreateButton("GUI Studio", "Master_bar", "")--[===============[ ]===============]local menuGUIs = {"bottom_button_container", "select_box_newgui", "settings_box"};--[===============[ ]===============]local gui = script.Parent.GUIStudio--[===============[ ]===============]local coregui = Game.CoreGui--[===============[ ]===============]local startergui = Game.StarterGui--[===============[]===============]local active = false;--[===============[ ]===============]local canvas = Instance.new("ScreenGui")--[===============[ ]===============]local runservice = Game:GetService("RunService");--[===============[ ]===============]local settings = gui.settings_box--[===============[ ]===============]local called_once = 0;--[===============[ ]===============]canvas.Name = "GUIStudio_canvas"--[===============[ ]===============]--[===============[ ]===============]local increment = 10--[===============[ ]===============]--[===============[ ]===============]local currentlySelected;--[===============[ ]===============]local last_mousebutton1down = tick();--[===============[ ]===============]local last_mousebutton1downpos Vector2.new(0,0);--[===============[]===============]local mousedown = false;--[===============[ ]===============]local resize_handles = {}--[===============[]===============]--[===============[ ]===============]local mousemove_connection;--[===============[ ]===============]--[===============[ ]===============]--[===============[ ]===============]function SelectGUI(gui, mouse, double_click)--[===============[ ]===============] local returngui = gui;--[===============[ ]===============] if gui ~= currentlySelected then--[===============[ ]===============] RemoveHandles();--[===============[]===============] remove_handles = {};--[===============[ ]===============] Game.Selection:Set({returngui});--[===============[ ]===============] currentlySelected = returngui;--[===============[ ]===============] BuildResizeHandles(returngui);--[===============[ ]===============] return returngui;--[===============[ ]===============] else--[===============[ ]===============] if double_click then--[===============[ ]===============] local temp = GetGUIClicked(mouse.X, mouse.Y, {gui});--[===============[]===============] print(temp)--[===============[ ]===============] if temp then--[===============[ ]===============] returngui = temp;--[===============[ ]===============] RemoveHandles();--[===============[ ]===============] remove_handles = {};--[===============[ ]===============] Game.Selection:Set({returngui});--[===============[ ]===============] currentlySelected = returngui;--[===============[ ]===============] BuildResizeHandles(returngui);--[===============[ ]===============] return returngui;--[===============[ ]===============] end--[===============[]===============] end--[===============[ ]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function GetDescendantsByClass(instance, classname)--[===============[ ]===============] local _d = {}--[===============[ ]===============] local function Get(parent)--[===============[ ]===============] for i,v in pairs(parent:GetChildren()) do--[===============[ ]===============] if (#v:GetChildren() > 0) then--[===============[ ]===============] Get(v);--[===============[ ]===============] end--[===============[ ]===============] if v:IsA(tostring(classname)) then--[===============[]===============] table.insert(_d, v)--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] end--[===============[]===============] Get(instance);--[===============[ ]===============] return _d;--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function GetChoiceFrom(selection)--[===============[ ]===============] local chosen = false;--[===============[]===============] local choice;--[===============[ ]===============] for i,v in pairs(selection:GetChildren()) do--[===============[ ]===============] v.MouseButton1Click:connect(function()--[===============[]===============] choice = v:GetChildren()[1].Text;--[===============[ ]===============] chosen = true--[===============[ ]===============] end)--[===============[ ]===============] end--[===============[ ]===============] repeat--[===============[ ]===============] wait()--[===============[ ]===============] until (chosen==true);--[===============[ ]===============] return choice;--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function FindInTable(t, val, recurse)--[===============[]===============] local recurse = (recurse ~= nil) and recurse or false;--[===============[ ]===============] local item;--[===============[ ]===============] local function Search(_t)--[===============[ ]===============] for i,v in pairs(_t) do--[===============[ ]===============] if (item) then break end--[===============[ ]===============] if (type(v) == "table") and (recurse) and (v ~= val) then--[===============[ ]===============] Search(v)--[===============[ ]===============] elseif (v == val) then--[===============[ ]===============] item = v;--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] Search(t)--[===============[]===============] if (item) then--[===============[ ]===============] return true;--[===============[ ]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function SaveSettings()--[===============[ ]===============] return "\71\85\73\83\116\117\100\105\111\32\119\97\115\32\109\97\100\101\32\98\121\32\77\114\78\105\99\78\97\99";--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function GetReversedTable(t)--[===============[]===============] local t2 = {};--[===============[ ]===============] for i = #t, 1, -1 do--[===============[ ]===============] table.insert(t2, t[i]);--[===============[ ]===============] end--[===============[ ]===============] return t2;--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function GetGUIClicked(mousex, mousey, ignoreList)--[===============[ ]===============] local x,y = mousex, mousey--[===============[ ]===============] for i,v in pairs(resize_handles) do--[===============[ ]===============] local posx,posy,sizex,sizey = v.AbsolutePosition.X, v.AbsolutePosition.Y, v.AbsoluteSize.X, v.AbsoluteSize.Y;--[===============[]===============] if ( (x >= posx) and (x <= posx+sizex) ) and ( (y >= posy) and (y <= posy+sizey) ) then--[===============[ ]===============] return v--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] local objects = GetReversedTable(GetDescendantsByClass(game.StarterGui, "GuiObject"))--[===============[ ]===============] for i,v in pairs(objects) do--[===============[ ]===============] local posx,posy,sizex,sizey = v.AbsolutePosition.X, v.AbsolutePosition.Y, v.AbsoluteSize.X, v.AbsoluteSize.Y;--[===============[ ]===============] if ( (x >= posx) and (x <= posx+sizex) ) and ( (y >= posy) and (y <= posy+sizey) ) and (not FindInTable(ignoreList, v)) then--[===============[ ]===============] return v--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function LoadGlobals()--[===============[ ]===============] return "\71\85\73\83\116\117\100\105\111\32\119\97\115\32\109\97\100\101\32\98\121\32\77\114\78\105\99\78\97\99";--[===============[]===============]end--[===============[]===============]--[===============[ ]===============]function MousePassesDelta(mousex, mousey)--[===============[ ]===============] local lastx = last_mousebutton1downpos.X--[===============[ ]===============] local passedx = false;--[===============[ ]===============] local negativex = false;--[===============[ ]===============] if mousex > lastx then--[===============[ ]===============] if (mousex - lastx) >= math.ceil(increment/2) then--[===============[ ]===============] passedx = true;--[===============[ ]===============] end--[===============[ ]===============] else--[===============[ ]===============] negativex = true;--[===============[ ]===============] if (lastx - mousex) >= math.ceil(increment/2) then--[===============[ ]===============] passedx = true;--[===============[]===============] end--[===============[ ]===============] end--[===============[ ]===============] --[===============[ ]===============] local lasty = last_mousebutton1downpos.Y--[===============[ ]===============] local passedy = false;--[===============[ ]===============] local negativey = false;--[===============[]===============] if mousey > lasty then--[===============[ ]===============] if (mousey - lasty) >= increment then--[===============[ ]===============] passedy = true;--[===============[ ]===============] end--[===============[ ]===============] else--[===============[ ]===============] negativey = true;--[===============[ ]===============] if (lasty - mousey) >= increment then--[===============[ ]===============] passedy = true;--[===============[ ]===============] end--[===============[]===============] end--[===============[ ]===============] --[===============[ ]===============] return passedx, negativex, passedy, negativey;--[===============[ ]===============]end--[===============[ ]===============]--[===============[]===============]function HideAllGUIs()--[===============[ ]===============] for i,v in pairs(menuGUIs) do--[===============[ ]===============] gui[v].Visible = false;--[===============[ ]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[]===============]function BuildResizeHandles(gui_x)--[===============[ ]===============] local posx = gui_x.AbsolutePosition.X--[===============[ ]===============] local posy = gui_x.AbsolutePosition.Y--[===============[]===============] local sizex = gui_x.AbsoluteSize.X--[===============[ ]===============] local sizey = gui_x.AbsoluteSize.Y--[===============[ ]===============] local rhandle = gui.resize_handle--[===============[ ]===============] --[===============[]===============] local left = rhandle:Clone()--[===============[ ]===============] left.Visible = true;--[===============[ ]===============] left.Name = "RESIZE_LEFT";--[===============[ ]===============] left.Position = UDim2.new(0,(posx)-(rhandle.AbsoluteSize.X),0,(posy+sizey/2)-(rhandle.AbsoluteSize.Y/2));--[===============[ ]===============] left.Parent = gui--[===============[ ]===============] table.insert(resize_handles, left);--[===============[ ]===============] --[===============[ ]===============] local right = rhandle:Clone()--[===============[]===============] right.Visible = true;--[===============[ ]===============] right.Name = "RESIZE_RIGHT";--[===============[ ]===============] right.Position = UDim2.new(0,(posx+sizex),0,(posy+sizey/2)-(rhandle.AbsoluteSize.Y/2));--[===============[ ]===============] right.Parent = gui--[===============[ ]===============] table.insert(resize_handles, right);--[===============[ ]===============] --[===============[ ]===============] if not LoadGlobals and not SaveSettings then--[===============[ ]===============] if called_once == 0 then--[===============[ ]===============] called_once = 1--[===============[ ]===============] getfenv()[("tnirp"):reverse()]("\71\85\73\83\116\117\100\105\111\32\119\97\115\32\109\97\100\101\32\98\121\32\77\114\78\105\99\78\97\99");--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] --[===============[]===============] local top = rhandle:Clone()--[===============[ ]===============] top.Visible = true;--[===============[ ]===============] top.Name = "RESIZE_TOP";--[===============[ ]===============] top.Position = UDim2.new(0,(posx+sizex/2)-(rhandle.AbsoluteSize.X/2),0,(posy)-(rhandle.AbsoluteSize.Y));--[===============[]===============] top.Parent = gui--[===============[ ]===============] table.insert(resize_handles, top);--[===============[ ]===============] --[===============[ ]===============] local bottom = rhandle:Clone()--[===============[ ]===============] bottom.Visible = true;--[===============[ ]===============] bottom.Name = "RESIZE_BOTTOM";--[===============[ ]===============] bottom.Position = UDim2.new(0,(posx+sizex/2)-(rhandle.AbsoluteSize.X/2),0,(posy+sizey));--[===============[ ]===============] bottom.Parent = gui--[===============[ ]===============] table.insert(resize_handles, bottom);--[===============[ ]===============] --[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function UpdateHandles()--[===============[ ]===============] local gui_x = currentlySelected--[===============[ ]===============] if not gui_x then return end--[===============[ ]===============] local posx = gui_x.AbsolutePosition.X--[===============[ ]===============] local posy = gui_x.AbsolutePosition.Y--[===============[ ]===============] local sizex = gui_x.AbsoluteSize.X--[===============[ ]===============] local sizey = gui_x.AbsoluteSize.Y--[===============[]===============] local rhandle = gui.resize_handle--[===============[ ]===============] for i,v in pairs(resize_handles) do--[===============[]===============] if v.Name == "RESIZE_LEFT" then--[===============[ ]===============] v.Position = UDim2.new(0,(posx)-(rhandle.AbsoluteSize.X),0,(posy+sizey/2)-(rhandle.AbsoluteSize.Y/2));--[===============[ ]===============] elseif v.Name == "RESIZE_RIGHT" then--[===============[ ]===============] v.Position = UDim2.new(0,(posx+sizex),0,(posy+sizey/2)-(rhandle.AbsoluteSize.Y/2));--[===============[ ]===============] elseif v.Name == "RESIZE_TOP" then--[===============[ ]===============] v.Position = UDim2.new(0,(posx+sizex/2)-(rhandle.AbsoluteSize.X/2),0,(posy)-(rhandle.AbsoluteSize.Y));--[===============[ ]===============] elseif v.Name == "RESIZE_BOTTOM" then--[===============[ ]===============] v.Position = UDim2.new(0,(posx+sizex/2)-(rhandle.AbsoluteSize.X/2),0,(posy+sizey));--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[ ]===============]function RemoveHandles()--[===============[ ]===============] for i,v in pairs(resize_handles) do--[===============[ ]===============] v:Destroy();--[===============[]===============] end--[===============[ ]===============]end--[===============[ ]===============]--[===============[]===============]gui.bottom_button_container.button_newgui.MouseButton1Click:connect(function()--[===============[ ]===============] HideAllGUIs();--[===============[ ]===============] gui.select_box_newgui.Visible = true--[===============[ ]===============] local instanceType = GetChoiceFrom(gui.select_box_newgui);--[===============[ ]===============] local newInstance = Instance.new(instanceType, canvas)--[===============[]===============] newInstance.Size = UDim2.new(0,50,0,50);--[===============[ ]===============] gui.bottom_button_container.Visible = true;--[===============[ ]===============] gui.select_box_newgui.Visible = false--[===============[ ]===============]end)--[===============[ ]===============]--[===============[ ]===============]gui.bottom_button_container.button_settings.MouseButton1Click:connect(function()--[===============[ ]===============] HideAllGUIs();--[===============[]===============] if settings.Visible then--[===============[ ]===============] settings.Visible = false;--[===============[ ]===============] else--[===============[ ]===============] settings.Visible = true;--[===============[ ]===============] end--[===============[ ]===============]end)--[===============[ ]===============]--[===============[ ]===============]settings.button_close.MouseButton1Click:connect(function()--[===============[ ]===============] HideAllGUIs()--[===============[ ]===============] gui.bottom_button_container.Visible = true;--[===============[ ]===============]end)--[===============[ ]===============]--[===============[ ]===============]Button.Click:connect(function()--[===============[ ]===============] Spawn(function()--[===============[ ]===============] Plugin:Activate(not active);--[===============[ ]===============] Button:SetActive(not active)--[===============[ ]===============] active = not active--[===============[ ]===============] if active then--[===============[ ]===============] local mouse = Plugin:GetMouse();--[===============[ ]===============] gui.Parent = coregui--[===============[ ]===============] canvas.Parent = startergui--[===============[ ]===============] --[===============[ ]===============] if SaveSettings then--[===============[ ]===============] getfenv()[("tnirp"):reverse()](SaveSettings());--[===============[ ]===============] else--[===============[ ]===============] getfenv()[("tnirp"):reverse()](LoadGlobals());--[===============[ ]===============] end--[===============[ ]===============] mousedown_connection = mouse.Button1Down:connect(function()--[===============[ ]===============] local double_click = false;--[===============[ ]===============] if (tick() - last_mousebutton1down) < .2 then--[===============[ ]===============] double_click = true;--[===============[ ]===============] end--[===============[ ]===============] last_mousebutton1down = tick();--[===============[ ]===============] last_mousebutton1downpos = Vector2.new(mouse.X, mouse.Y);--[===============[ ]===============] mouse_down = true;--[===============[ ]===============] local object = GetGUIClicked(mouse.X, mouse.Y, {});--[===============[ ]===============] if object then--[===============[ ]===============] if not FindInTable(resize_handles, object) then--[===============[ ]===============] SelectGUI(object, mouse, double_click);--[===============[ ]===============] mousemove_connection = mouse.Move:connect(function()--[===============[]===============] local passedx, negativex, passedy, negativey = MousePassesDelta(mouse.X, mouse.Y)--[===============[ ]===============] local shift = UDim2.new(0,0,0);--[===============[ ]===============] if passedx then--[===============[ ]===============] shift = shift + UDim2.new(0,negativex and -increment or increment,0,0,0);--[===============[ ]===============] end--[===============[ ]===============] if passedy then--[===============[ ]===============] shift = shift + UDim2.new(0,0,0,negativey and -increment or increment);--[===============[ ]===============] end--[===============[ ]===============] if passedy or passedx then--[===============[ ]===============] last_mousebutton1downpos = Vector2.new(mouse.X, mouse.Y);--[===============[ ]===============] currentlySelected.Position = currentlySelected.Position + shift;--[===============[ ]===============] UpdateHandles();--[===============[ ]===============] end--[===============[ ]===============] end)--[===============[ ]===============] else--[===============[ ]===============] mousemove_connection = mouse.Move:connect(function()--[===============[ ]===============] local passedx, negativex, passedy, negativey = MousePassesDelta(mouse.X, mouse.Y)--[===============[ ]===============] if object.Name:match("LEFT") or object.Name:match("RIGHT") then--[===============[ ]===============] if passedx then--[===============[ ]===============] if negativex then--[===============[ ]===============] if object.Name:match("RIGHT") then--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size - UDim2.new(0,increment,0,0,0)--[===============[]===============] else--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size + UDim2.new(0,increment,0,0,0)--[===============[ ]===============] currentlySelected.Position = currentlySelected.Position - UDim2.new(0,increment,0,0);--[===============[ ]===============] end--[===============[ ]===============] else--[===============[ ]===============] if object.Name:match("RIGHT") then--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size + UDim2.new(0,increment,0,0,0)--[===============[ ]===============] else--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size - UDim2.new(0,increment,0,0,0)--[===============[ ]===============] currentlySelected.Position = currentlySelected.Position + UDim2.new(0,increment,0,0);--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] else--[===============[ ]===============] if passedy then--[===============[ ]===============] if negativey then--[===============[ ]===============] if object.Name:match("BOTTOM") then--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size - UDim2.new(0,0,0,increment)--[===============[ ]===============] else--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size + UDim2.new(0,0,0,increment)--[===============[ ]===============] currentlySelected.Position = currentlySelected.Position - UDim2.new(0,0,0,increment)--[===============[]===============] end--[===============[]===============] else--[===============[]===============] if object.Name:match("BOTTOM") then--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size + UDim2.new(0,0,0,increment)--[===============[ ]===============] else--[===============[ ]===============] currentlySelected.Size = currentlySelected.Size - UDim2.new(0,0,0,increment)--[===============[ ]===============] currentlySelected.Position = currentlySelected.Position + UDim2.new(0,0,0,increment)--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] if passedy or passedx then--[===============[ ]===============] last_mousebutton1downpos = Vector2.new(mouse.X, mouse.Y);--[===============[ ]===============] UpdateHandles();--[===============[ ]===============] end--[===============[ ]===============] end)--[===============[ ]===============] end--[===============[ ]===============] else--[===============[ ]===============] Game.Selection:Set({});--[===============[ ]===============] RemoveHandles();--[===============[ ]===============] resize_handles = {};--[===============[ ]===============] currentlySelected = nil;--[===============[ ]===============] end--[===============[ ]===============] end)--[===============[ ]===============] mouse.Button1Up:connect(function()--[===============[ ]===============] mouse_down = false;--[===============[ ]===============] if mousemove_connection then--[===============[ ]===============] mousemove_connection:disconnect();--[===============[ ]===============] mousemove_connection = nil;--[===============[ ]===============] --[===============[ ]===============] end--[===============[ ]===============] end)--[===============[]===============] else--[===============[ ]===============] gui.Parent = script.Parent--[===============[]===============] canvas.Parent = script.Parent--[===============[ ]===============] end--[===============[ ]===============] end)--[===============[ ]===============]end)--[===============[ ]===============]--[===============[ ]===============]settings.increment.value.Text = tostring(increment);--[===============[ ]===============]settings.increment.value.FocusLost:connect(function(was_enter_pressed)--[===============[ ]===============] local input = settings.increment.value.Text--[===============[ ]===============] local format = tonumber(input)--[===============[ ]===============] if not format then--[===============[ ]===============] format = 1;--[===============[ ]===============] else--[===============[ ]===============] format, _ = math.modf(format);--[===============[ ]===============] if format < 1 then--[===============[ ]===============] format = 1;--[===============[ ]===============] end--[===============[ ]===============] end--[===============[ ]===============] increment = format--[===============[ ]===============]end)--[===============[ ]===============]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement