diff --git a/processed/45284430.lua b/processed/45284430.lua index 7312973..53c4b92 100644 --- a/processed/45284430.lua +++ b/processed/45284430.lua @@ -1,51 +1,44 @@ -local t = {} - -local function ScopedConnect(parentInstance, instance, event, signalFunc, syncFunc, removeFunc) - local eventConnection = nil - - --Connection on parentInstance is scoped by parentInstance (when destroyed, it goes away) - local tryConnect = function() +print("[Mercury]: Loaded corescript 45284430") +local t = { } +local ScopedConnect +ScopedConnect = function(parentInstance, instance, event, signalFunc, syncFunc, removeFunc) + local eventConnection + local tryConnect + tryConnect = function() if game:IsAncestorOf(parentInstance) then - --Entering the world, make sure we are connected/synced if not eventConnection then eventConnection = instance[event]:connect(signalFunc) if syncFunc then - syncFunc() + return syncFunc() end end else - --Probably leaving the world, so disconnect for now if eventConnection then eventConnection:disconnect() if removeFunc then - removeFunc() + return removeFunc() end end end end - - --Hook it up to ancestryChanged signal local connection = parentInstance.AncestryChanged:connect(tryConnect) - - --Now connect us if we're already in the world tryConnect() - return connection end - -local function getScreenGuiAncestor(instance) +local getScreenGuiAncestor +getScreenGuiAncestor = function(instance) local localInstance = instance - while localInstance and not localInstance:IsA "ScreenGui" do + while localInstance and not localInstance:IsA("ScreenGui") do localInstance = localInstance.Parent end return localInstance end - -local function CreateButtons(frame, buttons, yPos, ySize) +local CreateButtons +CreateButtons = function(frame, buttons, yPos, ySize) local buttonNum = 1 - local buttonObjs = {} + local buttonObjs = { } for _, obj in ipairs(buttons) do - local button = Instance.new "TextButton" + local button = Instance.new("TextButton") button.Name = "Button" .. buttonNum button.Font = Enum.Font.Arial button.FontSize = Enum.FontSize.Size18 @@ -61,67 +54,58 @@ local function CreateButtons(frame, buttons, yPos, ySize) button.MouseButton1Click:connect(obj.Function) button.Parent = frame buttonObjs[buttonNum] = button - buttonNum = buttonNum + 1 end local numButtons = buttonNum - 1 - if numButtons == 1 then frame.Button1.Position = UDim2.new(0.35, 0, yPos.Scale, yPos.Offset) frame.Button1.Size = UDim2.new(0.4, 0, ySize.Scale, ySize.Offset) elseif numButtons == 2 then frame.Button1.Position = UDim2.new(0.1, 0, yPos.Scale, yPos.Offset) frame.Button1.Size = UDim2.new(0.8 / 3, 0, ySize.Scale, ySize.Offset) - frame.Button2.Position = UDim2.new(0.55, 0, yPos.Scale, yPos.Offset) frame.Button2.Size = UDim2.new(0.35, 0, ySize.Scale, ySize.Offset) elseif numButtons >= 3 then local spacing = 0.1 / numButtons local buttonSize = 0.9 / numButtons - buttonNum = 1 while buttonNum <= numButtons do - buttonObjs[buttonNum].Position = - UDim2.new(spacing * buttonNum + (buttonNum - 1) * buttonSize, 0, yPos.Scale, yPos.Offset) + buttonObjs[buttonNum].Position = UDim2.new(spacing * buttonNum + (buttonNum - 1) * buttonSize, 0, yPos.Scale, yPos.Offset) buttonObjs[buttonNum].Size = UDim2.new(buttonSize, 0, ySize.Scale, ySize.Offset) buttonNum = buttonNum + 1 end end end - -local function setSliderPos(newAbsPosX, slider, sliderPosition, bar, steps) - local newStep = steps - 1 --otherwise we really get one more step than we want +local setSliderPos +setSliderPos = function(newAbsPosX, slider, sliderPosition, bar, steps) + local newStep = steps - 1 local relativePosX = math.min(1, math.max(0, (newAbsPosX - bar.AbsolutePosition.X) / bar.AbsoluteSize.X)) local wholeNum, remainder = math.modf(relativePosX * newStep) if remainder > 0.5 then wholeNum = wholeNum + 1 end relativePosX = wholeNum / newStep - local result = math.ceil(relativePosX * newStep) - if sliderPosition.Value ~= (result + 1) then --only update if we moved a step + if sliderPosition.Value ~= (result + 1) then sliderPosition.Value = result + 1 - slider.Position = - UDim2.new(relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset) + slider.Position = UDim2.new(relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset) end end - -local function cancelSlide(areaSoak) +local cancelSlide +cancelSlide = function(areaSoak) areaSoak.Visible = false if areaSoakMouseMoveCon then - areaSoakMouseMoveCon:disconnect() + return areaSoakMouseMoveCon:disconnect() end end - t.CreateStyledMessageDialog = function(title, message, style, buttons) - local frame = Instance.new "Frame" + local frame = Instance.new("Frame") frame.Size = UDim2.new(0.5, 0, 0, 165) frame.Position = UDim2.new(0.25, 0, 0.5, -72.5) frame.Name = "MessageDialog" frame.Active = true frame.Style = Enum.FrameStyle.RobloxRound - - local styleImage = Instance.new "ImageLabel" + local styleImage = Instance.new("ImageLabel") styleImage.Name = "StyleImage" styleImage.BackgroundTransparency = 1 styleImage.Position = UDim2.new(0, 5, 0, 15) @@ -138,8 +122,7 @@ t.CreateStyledMessageDialog = function(title, message, style, buttons) return t.CreateMessageDialog(title, message, buttons) end styleImage.Parent = frame - - local titleLabel = Instance.new "TextLabel" + local titleLabel = Instance.new("TextLabel") titleLabel.Name = "Title" titleLabel.Text = title titleLabel.TextStrokeTransparency = 0 @@ -152,8 +135,7 @@ t.CreateStyledMessageDialog = function(title, message, style, buttons) titleLabel.TextXAlignment = Enum.TextXAlignment.Center titleLabel.TextYAlignment = Enum.TextYAlignment.Center titleLabel.Parent = frame - - local messageLabel = Instance.new "TextLabel" + local messageLabel = Instance.new("TextLabel") messageLabel.Name = "Message" messageLabel.Text = message messageLabel.TextStrokeTransparency = 0 @@ -167,21 +149,17 @@ t.CreateStyledMessageDialog = function(title, message, style, buttons) messageLabel.TextXAlignment = Enum.TextXAlignment.Left messageLabel.TextYAlignment = Enum.TextYAlignment.Top messageLabel.Parent = frame - CreateButtons(frame, buttons, UDim.new(0, 105), UDim.new(0, 40)) - return frame end - t.CreateMessageDialog = function(title, message, buttons) - local frame = Instance.new "Frame" + local frame = Instance.new("Frame") frame.Size = UDim2.new(0.5, 0, 0.5, 0) frame.Position = UDim2.new(0.25, 0, 0.25, 0) frame.Name = "MessageDialog" frame.Active = true frame.Style = Enum.FrameStyle.RobloxRound - - local titleLabel = Instance.new "TextLabel" + local titleLabel = Instance.new("TextLabel") titleLabel.Name = "Title" titleLabel.Text = title titleLabel.BackgroundTransparency = 1 @@ -193,8 +171,7 @@ t.CreateMessageDialog = function(title, message, buttons) titleLabel.TextXAlignment = Enum.TextXAlignment.Center titleLabel.TextYAlignment = Enum.TextYAlignment.Center titleLabel.Parent = frame - - local messageLabel = Instance.new "TextLabel" + local messageLabel = Instance.new("TextLabel") messageLabel.Name = "Message" messageLabel.Text = message messageLabel.TextColor3 = Color3.new(221 / 255, 221 / 255, 221 / 255) @@ -207,22 +184,17 @@ t.CreateMessageDialog = function(title, message, buttons) messageLabel.TextXAlignment = Enum.TextXAlignment.Left messageLabel.TextYAlignment = Enum.TextYAlignment.Top messageLabel.Parent = frame - CreateButtons(frame, buttons, UDim.new(0.8, 0), UDim.new(0.15, 0)) - return frame end - t.CreateDropDownMenu = function(items, onSelect, forRoblox) local width = UDim.new(0, 100) local height = UDim.new(0, 32) - - local frame = Instance.new "Frame" + local frame = Instance.new("Frame") frame.Name = "DropDownMenu" frame.BackgroundTransparency = 1 frame.Size = UDim2.new(width, height) - - local dropDownMenu = Instance.new "TextButton" + local dropDownMenu = Instance.new("TextButton") dropDownMenu.Name = "DropDownMenuButton" dropDownMenu.TextWrap = true dropDownMenu.TextColor3 = Color3.new(1, 1, 1) @@ -237,8 +209,7 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) dropDownMenu.Size = UDim2.new(1, 0, 1, 0) dropDownMenu.Parent = frame dropDownMenu.ZIndex = 2 - - local dropDownIcon = Instance.new "ImageLabel" + local dropDownIcon = Instance.new("ImageLabel") dropDownIcon.Name = "Icon" dropDownIcon.Active = false dropDownIcon.Image = "http://www.roblox.com/asset/?id=45732894" @@ -247,7 +218,6 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) dropDownIcon.Position = UDim2.new(1, -11, 0.5, -2) dropDownIcon.Parent = dropDownMenu dropDownIcon.ZIndex = 2 - local itemCount = #items local dropDownItemCount = #items local useScrollButtons = false @@ -255,21 +225,18 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) useScrollButtons = true dropDownItemCount = 6 end - - local droppedDownMenu = Instance.new "TextButton" + local droppedDownMenu = Instance.new("TextButton") droppedDownMenu.Name = "List" droppedDownMenu.Text = "" droppedDownMenu.BackgroundTransparency = 1 - --droppedDownMenu.AutoButtonColor = true droppedDownMenu.Style = Enum.ButtonStyle.RobloxButton droppedDownMenu.Visible = false - droppedDownMenu.Active = true --Blocks clicks + droppedDownMenu.Active = true droppedDownMenu.Position = UDim2.new(0, 0, 0, 0) droppedDownMenu.Size = UDim2.new(1, 0, (1 + dropDownItemCount) * 0.8, 0) droppedDownMenu.Parent = frame droppedDownMenu.ZIndex = 2 - - local choiceButton = Instance.new "TextButton" + local choiceButton = Instance.new("TextButton") choiceButton.Name = "ChoiceButton" choiceButton.BackgroundTransparency = 1 choiceButton.BorderSizePixel = 0 @@ -287,8 +254,7 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end choiceButton.TextWrap = true choiceButton.ZIndex = 2 - - local areaSoak = Instance.new "TextButton" + local areaSoak = Instance.new("TextButton") areaSoak.Name = "AreaSoak" areaSoak.Text = "" areaSoak.BackgroundTransparency = 1 @@ -296,14 +262,12 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) areaSoak.Size = UDim2.new(1, 0, 1, 0) areaSoak.Visible = false areaSoak.ZIndex = 3 - local dropDownSelected = false - local scrollUpButton local scrollDownButton local scrollMouseCount = 0 - - local setZIndex = function(baseZIndex) + local setZIndex + setZIndex = function(baseZIndex) droppedDownMenu.ZIndex = baseZIndex + 1 if scrollUpButton then scrollUpButton.ZIndex = baseZIndex + 3 @@ -311,7 +275,6 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) if scrollDownButton then scrollDownButton.ZIndex = baseZIndex + 3 end - local children = droppedDownMenu:GetChildren() if children then for _, child in ipairs(children) do @@ -323,41 +286,37 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end end end - local scrollBarPosition = 1 - local updateScroll = function() + local updateScroll + updateScroll = function() if scrollUpButton then scrollUpButton.Active = scrollBarPosition > 1 end if scrollDownButton then scrollDownButton.Active = scrollBarPosition + dropDownItemCount <= itemCount end - local children = droppedDownMenu:GetChildren() if not children then return end - local childNum = 1 for _, obj in ipairs(children) do if obj.Name == "ChoiceButton" then if childNum < scrollBarPosition or childNum >= scrollBarPosition + dropDownItemCount then obj.Visible = false else - obj.Position = - UDim2.new(0, 0, ((childNum - scrollBarPosition + 1) * 0.8) / ((dropDownItemCount + 1) * 0.8), 0) + obj.Position = UDim2.new(0, 0, ((childNum - scrollBarPosition + 1) * 0.8) / ((dropDownItemCount + 1) * 0.8), 0) obj.Visible = true end obj.TextColor3 = Color3.new(1, 1, 1) obj.BackgroundTransparency = 1 - childNum = childNum + 1 end end end - local toggleVisibility = function() + local toggleVisibility + toggleVisibility = function() dropDownSelected = not dropDownSelected - areaSoak.Visible = not areaSoak.Visible dropDownMenu.Visible = not dropDownSelected droppedDownMenu.Visible = dropDownSelected @@ -367,12 +326,12 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) setZIndex(2) end if useScrollButtons then - updateScroll() + return updateScroll() end end droppedDownMenu.MouseButton1Click:connect(toggleVisibility) - - local updateSelection = function(text) + local updateSelection + updateSelection = function(text) local foundItem = false local children = droppedDownMenu:GetChildren() local childNum = 1 @@ -397,16 +356,14 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) if not foundItem then error("Invalid Selection Update -- " .. text) end - if scrollBarPosition + dropDownItemCount > itemCount + 1 then scrollBarPosition = itemCount - dropDownItemCount + 1 end - dropDownMenu.Text = text end end - - local function scrollDown() + local scrollDown + scrollDown = function() if scrollBarPosition + dropDownItemCount <= itemCount then scrollBarPosition = scrollBarPosition + 1 updateScroll() @@ -414,7 +371,8 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end return false end - local function scrollUp() + local scrollUp + scrollUp = function() if scrollBarPosition > 1 then scrollBarPosition = scrollBarPosition - 1 updateScroll() @@ -422,10 +380,8 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end return false end - if useScrollButtons then - --Make some scroll buttons - scrollUpButton = Instance.new "ImageButton" + scrollUpButton = Instance.new("ImageButton") scrollUpButton.Name = "ScrollUpButton" scrollUpButton.BackgroundTransparency = 1 scrollUpButton.Image = "rbxasset://textures/ui/scrollbuttonUp.png" @@ -439,7 +395,6 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end) scrollUpButton.MouseButton1Down:connect(function() scrollMouseCount = scrollMouseCount + 1 - scrollUp() local val = scrollMouseCount wait(0.5) @@ -450,10 +405,8 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) wait(0.1) end end) - scrollUpButton.Parent = droppedDownMenu - - scrollDownButton = Instance.new "ImageButton" + scrollDownButton = Instance.new("ImageButton") scrollDownButton.Name = "ScrollDownButton" scrollDownButton.BackgroundTransparency = 1 scrollDownButton.Image = "rbxasset://textures/ui/scrollbuttonDown.png" @@ -468,7 +421,6 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) end) scrollDownButton.MouseButton1Down:connect(function() scrollMouseCount = scrollMouseCount + 1 - scrollDown() local val = scrollMouseCount wait(0.5) @@ -479,8 +431,7 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) wait(0.1) end end) - - local scrollbar = Instance.new "ImageLabel" + local scrollbar = Instance.new("ImageLabel") scrollbar.Name = "ScrollBar" scrollbar.Image = "rbxasset://textures/ui/scrollbar.png" scrollbar.BackgroundTransparency = 1 @@ -488,9 +439,7 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) scrollbar.Position = UDim2.new(1, -11, (1 * 0.8) / ((dropDownItemCount + 1) * 0.8), 17 + 2) scrollbar.Parent = droppedDownMenu end - for _, item in ipairs(items) do - -- needed to maintain local scope for items in event listeners below local button = choiceButton:clone() if forRoblox then button.RobloxLocked = true @@ -498,31 +447,22 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) button.Text = item button.Parent = droppedDownMenu button.MouseButton1Click:connect(function() - --Remove Highlight button.TextColor3 = Color3.new(1, 1, 1) button.BackgroundTransparency = 1 - updateSelection(item) onSelect(item) - - toggleVisibility() + return toggleVisibility() end) button.MouseEnter:connect(function() - --Add Highlight button.TextColor3 = Color3.new(0, 0, 0) button.BackgroundTransparency = 0 end) - button.MouseLeave:connect(function() - --Remove Highlight button.TextColor3 = Color3.new(1, 1, 1) button.BackgroundTransparency = 1 end) end - - --This does the initial layout of the buttons updateScroll() - frame.AncestryChanged:connect(function(_, parent) if parent == nil then areaSoak.Parent = nil @@ -530,43 +470,36 @@ t.CreateDropDownMenu = function(items, onSelect, forRoblox) areaSoak.Parent = getScreenGuiAncestor(frame) end end) - dropDownMenu.MouseButton1Click:connect(toggleVisibility) areaSoak.MouseButton1Click:connect(toggleVisibility) return frame, updateSelection end - t.CreatePropertyDropDownMenu = function(instance, property, enum) local items = enum:GetEnumItems() - local names = {} - local nameToItem = {} + local names = { } + local nameToItem = { } for i, obj in ipairs(items) do names[i] = obj.Name nameToItem[obj.Name] = obj end - local frame local updateSelection frame, updateSelection = t.CreateDropDownMenu(names, function(text) instance[property] = nameToItem[text] end) - ScopedConnect(frame, instance, "Changed", function(prop) if prop == property then - updateSelection(instance[property].Name) + return updateSelection(instance[property].Name) end end, function() - updateSelection(instance[property].Name) + return updateSelection(instance[property].Name) end) - return frame end - t.GetFontHeight = function(font, fontSize) if font == nil or fontSize == nil then - error "Font and FontSize must be non-nil" + error("Font and FontSize must be non-nil") end - if font == Enum.Font.Legacy then if fontSize == Enum.FontSize.Size8 then return 12 @@ -589,7 +522,7 @@ t.GetFontHeight = function(font, fontSize) elseif fontSize == Enum.FontSize.Size48 then return 72 else - error "Unknown FontSize" + return error("Unknown FontSize") end elseif font == Enum.Font.Arial or font == Enum.Font.ArialBold then if fontSize == Enum.FontSize.Size8 then @@ -613,51 +546,37 @@ t.GetFontHeight = function(font, fontSize) elseif fontSize == Enum.FontSize.Size48 then return 48 else - error "Unknown FontSize" + return error("Unknown FontSize") end else - error("Unknown Font " .. font) + return error("Unknown Font " .. font) end end - -local function layoutGuiObjectsHelper(frame, guiObjects, settingsTable) +local layoutGuiObjectsHelper +layoutGuiObjectsHelper = function(frame, guiObjects, settingsTable) local totalPixels = frame.AbsoluteSize.Y local pixelsRemaining = frame.AbsoluteSize.Y for _, child in ipairs(guiObjects) do - if child:IsA "TextLabel" or child:IsA "TextButton" then - local isLabel = child:IsA "TextLabel" + if child:IsA("TextLabel") or child:IsA("TextButton") then + local isLabel = child:IsA("TextLabel") if isLabel then pixelsRemaining = pixelsRemaining - settingsTable["TextLabelPositionPadY"] else pixelsRemaining = pixelsRemaining - settingsTable["TextButtonPositionPadY"] end - child.Position = - UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) + child.Position = UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, pixelsRemaining) - if child.TextFits and child.TextBounds.Y < pixelsRemaining then child.Visible = true if isLabel then - child.Size = UDim2.new( - child.Size.X.Scale, - child.Size.X.Offset, - 0, - child.TextBounds.Y + settingsTable["TextLabelSizePadY"] - ) + child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.TextBounds.Y + settingsTable["TextLabelSizePadY"]) else - child.Size = UDim2.new( - child.Size.X.Scale, - child.Size.X.Offset, - 0, - child.TextBounds.Y + settingsTable["TextButtonSizePadY"] - ) + child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.TextBounds.Y + settingsTable["TextButtonSizePadY"]) end - while not child.TextFits do child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.AbsoluteSize.Y + 1) end pixelsRemaining = pixelsRemaining - child.AbsoluteSize.Y - if isLabel then pixelsRemaining = pixelsRemaining - settingsTable["TextLabelPositionPadY"] else @@ -668,29 +587,24 @@ local function layoutGuiObjectsHelper(frame, guiObjects, settingsTable) pixelsRemaining = -1 end else - --GuiObject - child.Position = - UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) + child.Position = UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) pixelsRemaining = pixelsRemaining - child.AbsoluteSize.Y child.Visible = (pixelsRemaining >= 0) end end end - t.LayoutGuiObjects = function(frame, guiObjects, settingsTable) - if not frame:IsA "GuiObject" then - error "Frame must be a GuiObject" + if not frame:IsA("GuiObject") then + error("Frame must be a GuiObject") end for _, child in ipairs(guiObjects) do - if not child:IsA "GuiObject" then - error "All elements that are layed out must be of type GuiObject" + if not child:IsA("GuiObject") then + error("All elements that are layed out must be of type GuiObject") end end - if not settingsTable then - settingsTable = {} + settingsTable = { } end - if not settingsTable["TextLabelSizePadY"] then settingsTable["TextLabelSizePadY"] = 0 end @@ -703,46 +617,37 @@ t.LayoutGuiObjects = function(frame, guiObjects, settingsTable) if not settingsTable["TextButtonPositionPadY"] then settingsTable["TextButtonPositionPadY"] = 2 end - - --Wrapper frame takes care of styled objects - local wrapperFrame = Instance.new "Frame" + local wrapperFrame = Instance.new("Frame") wrapperFrame.Name = "WrapperFrame" wrapperFrame.BackgroundTransparency = 1 wrapperFrame.Size = UDim2.new(1, 0, 1, 0) wrapperFrame.Parent = frame - for _, child in ipairs(guiObjects) do child.Parent = wrapperFrame end - - local recalculate = function() + local recalculate + recalculate = function() wait() - layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable) + return layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable) end - frame.Changed:connect(function(prop) if prop == "AbsoluteSize" then - --Wait a heartbeat for it to sync in - recalculate(nil) + return recalculate(nil) end end) frame.AncestryChanged:connect(recalculate) - - layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable) + return layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable) end - t.CreateSlider = function(steps, width, position) - local sliderGui = Instance.new "Frame" + local sliderGui = Instance.new("Frame") sliderGui.Size = UDim2.new(1, 0, 1, 0) sliderGui.BackgroundTransparency = 1 sliderGui.Name = "SliderGui" - - local sliderSteps = Instance.new "IntValue" + local sliderSteps = Instance.new("IntValue") sliderSteps.Name = "SliderSteps" sliderSteps.Value = steps sliderSteps.Parent = sliderGui - - local areaSoak = Instance.new "TextButton" + local areaSoak = Instance.new("TextButton") areaSoak.Name = "AreaSoak" areaSoak.Text = "" areaSoak.BackgroundTransparency = 1 @@ -750,7 +655,6 @@ t.CreateSlider = function(steps, width, position) areaSoak.Size = UDim2.new(1, 0, 1, 0) areaSoak.Visible = false areaSoak.ZIndex = 4 - sliderGui.AncestryChanged:connect(function(_, parent) if parent == nil then areaSoak.Parent = nil @@ -758,13 +662,11 @@ t.CreateSlider = function(steps, width, position) areaSoak.Parent = getScreenGuiAncestor(sliderGui) end end) - - local sliderPosition = Instance.new "IntValue" + local sliderPosition = Instance.new("IntValue") sliderPosition.Name = "SliderPosition" sliderPosition.Value = 0 sliderPosition.Parent = sliderGui - - local bar = Instance.new "TextButton" + local bar = Instance.new("TextButton") bar.Text = "" bar.AutoButtonColor = false bar.Name = "Bar" @@ -777,19 +679,10 @@ t.CreateSlider = function(steps, width, position) bar.BorderColor3 = Color3.new(95 / 255, 95 / 255, 95 / 255) bar.ZIndex = 2 bar.Parent = sliderGui - - if - position["X"] - and position["X"]["Scale"] - and position["X"]["Offset"] - and position["Y"] - and position["Y"]["Scale"] - and position["Y"]["Offset"] - then + if position["X"] and position["X"]["Scale"] and position["X"]["Offset"] and position["Y"] and position["Y"]["Scale"] and position["Y"]["Offset"] then bar.Position = position end - - local slider = Instance.new "ImageButton" + local slider = Instance.new("ImageButton") slider.Name = "Slider" slider.BackgroundTransparency = 1 slider.Image = "rbxasset://textures/ui/Slider.png" @@ -797,83 +690,66 @@ t.CreateSlider = function(steps, width, position) slider.Size = UDim2.new(0, 20, 0, 20) slider.ZIndex = 3 slider.Parent = bar - - local areaSoakMouseMoveCon = nil - + local areaSoakMouseMoveCon areaSoak.MouseLeave:connect(function() if areaSoak.Visible then - cancelSlide(areaSoak) + return cancelSlide(areaSoak) end end) areaSoak.MouseButton1Up:connect(function() if areaSoak.Visible then - cancelSlide(areaSoak) + return cancelSlide(areaSoak) end end) - slider.MouseButton1Down:connect(function() areaSoak.Visible = true if areaSoakMouseMoveCon then areaSoakMouseMoveCon:disconnect() end areaSoakMouseMoveCon = areaSoak.MouseMoved:connect(function(x, _) - setSliderPos(x, slider, sliderPosition, bar, steps) + return setSliderPos(x, slider, sliderPosition, bar, steps) end) end) - slider.MouseButton1Up:connect(function() - cancelSlide(areaSoak) + return cancelSlide(areaSoak) end) - sliderPosition.Changed:connect(function(_) sliderPosition.Value = math.min(steps, math.max(1, sliderPosition.Value)) local relativePosX = (sliderPosition.Value - 1) / (steps - 1) - slider.Position = - UDim2.new(relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset) + slider.Position = UDim2.new(relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset) end) - bar.MouseButton1Down:connect(function(x, _) - setSliderPos(x, slider, sliderPosition, bar, steps) + return setSliderPos(x, slider, sliderPosition, bar, steps) end) - return sliderGui, sliderPosition, sliderSteps end - t.CreateTrueScrollingFrame = function() - local lowY = nil - local highY = nil - - local dragCon = nil - local upCon = nil - + local lowY + local highY + local dragCon + local upCon local internalChange = false - - local descendantsChangeConMap = {} - - local scrollingFrame = Instance.new "Frame" + local descendantsChangeConMap = { } + local scrollingFrame = Instance.new("Frame") scrollingFrame.Name = "ScrollingFrame" scrollingFrame.Active = true scrollingFrame.Size = UDim2.new(1, 0, 1, 0) scrollingFrame.ClipsDescendants = true - - local controlFrame = Instance.new "Frame" + local controlFrame = Instance.new("Frame") controlFrame.Name = "ControlFrame" controlFrame.BackgroundTransparency = 1 controlFrame.Size = UDim2.new(0, 18, 1, 0) controlFrame.Position = UDim2.new(1, -20, 0, 0) controlFrame.Parent = scrollingFrame - - local scrollBottom = Instance.new "BoolValue" + local scrollBottom = Instance.new("BoolValue") scrollBottom.Value = false scrollBottom.Name = "ScrollBottom" scrollBottom.Parent = controlFrame - - local scrollUp = Instance.new "BoolValue" + local scrollUp = Instance.new("BoolValue") scrollUp.Value = false scrollUp.Name = "scrollUp" scrollUp.Parent = controlFrame - - local scrollUpButton = Instance.new "TextButton" + local scrollUpButton = Instance.new("TextButton") scrollUpButton.Name = "ScrollUpButton" scrollUpButton.Text = "" scrollUpButton.AutoButtonColor = false @@ -884,7 +760,7 @@ t.CreateTrueScrollingFrame = function() scrollUpButton.ZIndex = 2 scrollUpButton.Parent = controlFrame for i = 1, 6 do - local triFrame = Instance.new "Frame" + local triFrame = Instance.new("Frame") triFrame.BorderColor3 = Color3.new(1, 1, 1) triFrame.Name = "tri" .. tostring(i) triFrame.ZIndex = 3 @@ -907,7 +783,6 @@ t.CreateTrueScrollingFrame = function() upChildren[i].BackgroundTransparency = 0.5 end end) - local scrollDownButton = scrollUpButton:clone() scrollDownButton.Name = "ScrollDownButton" scrollDownButton.Position = UDim2.new(0, 0, 1, -18) @@ -917,28 +792,26 @@ t.CreateTrueScrollingFrame = function() end scrollDownButton.MouseEnter:connect(function() scrollDownButton.BackgroundTransparency = 0.1 - local downChildren = scrollDownButton:GetChildren() + downChildren = scrollDownButton:GetChildren() for i = 1, #downChildren do downChildren[i].BackgroundTransparency = 0.1 end end) scrollDownButton.MouseLeave:connect(function() scrollDownButton.BackgroundTransparency = 0.5 - local downChildren = scrollDownButton:GetChildren() + downChildren = scrollDownButton:GetChildren() for i = 1, #downChildren do downChildren[i].BackgroundTransparency = 0.5 end end) scrollDownButton.Parent = controlFrame - - local scrollTrack = Instance.new "Frame" + local scrollTrack = Instance.new("Frame") scrollTrack.Name = "ScrollTrack" scrollTrack.BackgroundTransparency = 1 scrollTrack.Size = UDim2.new(0, 18, 1, -38) scrollTrack.Position = UDim2.new(0, 0, 0, 19) scrollTrack.Parent = controlFrame - - local scrollbar = Instance.new "TextButton" + local scrollbar = Instance.new("TextButton") scrollbar.BackgroundColor3 = Color3.new(0, 0, 0) scrollbar.BorderColor3 = Color3.new(1, 1, 1) scrollbar.BackgroundTransparency = 0.5 @@ -951,8 +824,7 @@ t.CreateTrueScrollingFrame = function() scrollbar.Size = UDim2.new(0, 18, 0.1, 0) scrollbar.Position = UDim2.new(0, 0, 0, 0) scrollbar.Parent = scrollTrack - - local scrollNub = Instance.new "Frame" + local scrollNub = Instance.new("Frame") scrollNub.Name = "ScrollNub" scrollNub.BorderColor3 = Color3.new(1, 1, 1) scrollNub.Size = UDim2.new(0, 10, 0, 0) @@ -960,15 +832,12 @@ t.CreateTrueScrollingFrame = function() scrollNub.ZIndex = 2 scrollNub.BackgroundTransparency = 0.5 scrollNub.Parent = scrollbar - local newNub = scrollNub:clone() newNub.Position = UDim2.new(0.5, -5, 0.5, -2) newNub.Parent = scrollbar - local lastNub = scrollNub:clone() lastNub.Position = UDim2.new(0.5, -5, 0.5, 2) lastNub.Parent = scrollbar - scrollbar.MouseEnter:connect(function() scrollbar.BackgroundTransparency = 0.1 scrollNub.BackgroundTransparency = 0.1 @@ -981,8 +850,7 @@ t.CreateTrueScrollingFrame = function() newNub.BackgroundTransparency = 0.5 lastNub.BackgroundTransparency = 0.5 end) - - local mouseDrag = Instance.new "ImageButton" + local mouseDrag = Instance.new("ImageButton") mouseDrag.Active = false mouseDrag.Size = UDim2.new(1.5, 0, 1.5, 0) mouseDrag.AutoButtonColor = false @@ -990,17 +858,14 @@ t.CreateTrueScrollingFrame = function() mouseDrag.Name = "mouseDrag" mouseDrag.Position = UDim2.new(-0.25, 0, -0.25, 0) mouseDrag.ZIndex = 10 - - local function positionScrollBar(_, y, offset) + local positionScrollBar + positionScrollBar = function(_, y, offset) local oldPos = scrollbar.Position - if y < scrollTrack.AbsolutePosition.y then scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 0, 0) return (oldPos ~= scrollbar.Position) end - local relativeSize = scrollbar.AbsoluteSize.Y / scrollTrack.AbsoluteSize.Y - if y > (scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y) then scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 1 - relativeSize, 0) return (oldPos ~= scrollbar.Position) @@ -1019,12 +884,11 @@ t.CreateTrueScrollingFrame = function() scrollBottom.Value = false end scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, newScaleYPos, 0) - return (oldPos ~= scrollbar.Position) end - - local function drillDownSetHighLow(instance) - if not instance or not instance:IsA "GuiObject" then + local drillDownSetHighLow + drillDownSetHighLow = function(instance) + if not instance or not instance:IsA("GuiObject") then return end if instance == controlFrame then @@ -1036,7 +900,6 @@ t.CreateTrueScrollingFrame = function() if not instance.Visible then return end - if (lowY and lowY > instance.AbsolutePosition.Y) or not lowY then lowY = instance.AbsolutePosition.Y end @@ -1048,23 +911,20 @@ t.CreateTrueScrollingFrame = function() drillDownSetHighLow(children[i]) end end - - local function resetHighLow() + local resetHighLow + resetHighLow = function() local firstChildren = scrollingFrame:GetChildren() - for i = 1, #firstChildren do drillDownSetHighLow(firstChildren[i]) end end - - local function recalculate() + local recalculate + recalculate = function() internalChange = true - local percentFrame = 0 if scrollbar.Position.Y.Scale > 0 then if scrollbar.Visible then - percentFrame = scrollbar.Position.Y.Scale - / ((scrollTrack.AbsoluteSize.Y - scrollbar.AbsoluteSize.Y) / scrollTrack.AbsoluteSize.Y) + percentFrame = scrollbar.Position.Y.Scale / ((scrollTrack.AbsoluteSize.Y - scrollbar.AbsoluteSize.Y) / scrollTrack.AbsoluteSize.Y) else percentFrame = 0 end @@ -1072,38 +932,28 @@ t.CreateTrueScrollingFrame = function() if percentFrame > 0.99 then percentFrame = 1 end - local hiddenYAmount = (scrollingFrame.AbsoluteSize.Y - (highY - lowY)) * percentFrame - local guiChildren = scrollingFrame:GetChildren() for i = 1, #guiChildren do if guiChildren[i] ~= controlFrame then - guiChildren[i].Position = UDim2.new( - guiChildren[i].Position.X.Scale, - guiChildren[i].Position.X.Offset, - 0, - math.ceil(guiChildren[i].AbsolutePosition.Y) - math.ceil(lowY) + hiddenYAmount - ) + guiChildren[i].Position = UDim2.new(guiChildren[i].Position.X.Scale, guiChildren[i].Position.X.Offset, 0, math.ceil(guiChildren[i].AbsolutePosition.Y) - math.ceil(lowY + hiddenYAmount)) end end - lowY = nil highY = nil resetHighLow() internalChange = false end - - local function setSliderSizeAndPosition() + local setSliderSizeAndPosition + setSliderSizeAndPosition = function() if not highY or not lowY then return end - local totalYSpan = math.abs(highY - lowY) if totalYSpan == 0 then scrollbar.Visible = false scrollDownButton.Visible = false scrollUpButton.Visible = false - if dragCon then dragCon:disconnect() dragCon = nil @@ -1114,7 +964,6 @@ t.CreateTrueScrollingFrame = function() end return end - local percentShown = scrollingFrame.AbsoluteSize.Y / totalYSpan if percentShown >= 1 then scrollbar.Visible = false @@ -1125,59 +974,44 @@ t.CreateTrueScrollingFrame = function() scrollbar.Visible = true scrollDownButton.Visible = true scrollUpButton.Visible = true - scrollbar.Size = UDim2.new(scrollbar.Size.X.Scale, scrollbar.Size.X.Offset, percentShown, 0) end - local percentPosition = (scrollingFrame.AbsolutePosition.Y - lowY) / totalYSpan - scrollbar.Position = UDim2.new( - scrollbar.Position.X.Scale, - scrollbar.Position.X.Offset, - percentPosition, - -scrollbar.AbsoluteSize.X / 2 - ) - + scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, percentPosition, -scrollbar.AbsoluteSize.X / 2) if scrollbar.AbsolutePosition.y < scrollTrack.AbsolutePosition.y then scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 0, 0) end - - if - (scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.Y) - > (scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y) - then + if (scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.Y) > (scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y) then local relativeSize = scrollbar.AbsoluteSize.Y / scrollTrack.AbsoluteSize.Y scrollbar.Position = UDim2.new(scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 1 - relativeSize, 0) end end - local buttonScrollAmountPixels = 7 local reentrancyGuardScrollUp = false - local function doScrollUp() + local doScrollUp + doScrollUp = function() if reentrancyGuardScrollUp then return end - reentrancyGuardScrollUp = true if positionScrollBar(0, scrollbar.AbsolutePosition.Y - buttonScrollAmountPixels, 0) then recalculate() end reentrancyGuardScrollUp = false end - local reentrancyGuardScrollDown = false - local function doScrollDown() + local doScrollDown + doScrollDown = function() if reentrancyGuardScrollDown then return end - reentrancyGuardScrollDown = true if positionScrollBar(0, scrollbar.AbsolutePosition.Y + buttonScrollAmountPixels, 0) then recalculate() end reentrancyGuardScrollDown = false end - - local function scrollUp(mouseYPos) + scrollUp = function(mouseYPos) if scrollUpButton.Active then local scrollStamp = tick() local current = scrollStamp @@ -1185,12 +1019,12 @@ t.CreateTrueScrollingFrame = function() upCon = mouseDrag.MouseButton1Up:connect(function() scrollStamp = tick() mouseDrag.Parent = nil - upCon:disconnect() + return upCon:disconnect() end) mouseDrag.Parent = getScreenGuiAncestor(scrollbar) doScrollUp() wait(0.2) - local t = tick() + t = tick() local w = 0.1 while scrollStamp == current do doScrollUp() @@ -1209,8 +1043,8 @@ t.CreateTrueScrollingFrame = function() end end end - - local function scrollDown(mouseYPos) + local scrollDown + scrollDown = function(mouseYPos) if scrollDownButton.Active then local scrollStamp = tick() local current = scrollStamp @@ -1218,12 +1052,12 @@ t.CreateTrueScrollingFrame = function() downCon = mouseDrag.MouseButton1Up:connect(function() scrollStamp = tick() mouseDrag.Parent = nil - downCon:disconnect() + return downCon:disconnect() end) mouseDrag.Parent = getScreenGuiAncestor(scrollbar) doScrollDown() wait(0.2) - local t = tick() + t = tick() local w = 0.1 while scrollStamp == current do doScrollDown() @@ -1242,7 +1076,6 @@ t.CreateTrueScrollingFrame = function() end end end - scrollbar.MouseButton1Down:connect(function(_, y) if scrollbar.Active then local scrollStamp = tick() @@ -1260,7 +1093,6 @@ t.CreateTrueScrollingFrame = function() if reentrancyGuardMouseScroll then return end - reentrancyGuardMouseScroll = true if positionScrollBar(x, y, mouseOffset) then recalculate() @@ -1278,133 +1110,107 @@ t.CreateTrueScrollingFrame = function() mouseDrag.Parent = getScreenGuiAncestor(scrollbar) end end) - local scrollMouseCount = 0 - scrollUpButton.MouseButton1Down:connect(function() - scrollUp() + return scrollUp() end) scrollDownButton.MouseButton1Down:connect(function() - scrollDown() + return scrollDown() end) - - local function scrollTick() + local scrollTick + scrollTick = function() scrollStamp = tick() end - scrollUpButton.MouseButton1Up:connect(scrollTick) scrollDownButton.MouseButton1Up:connect(scrollTick) scrollbar.MouseButton1Up:connect(scrollTick) - - -- local function heightCheck(instance) - -- if (highY and (instance.AbsolutePosition.Y + instance.AbsoluteSize.Y) > highY) or not highY then - -- highY = instance.AbsolutePosition.Y + instance.AbsoluteSize.Y - -- end - -- setSliderSizeAndPosition() - -- end - - local function highLowRecheck() + local highLowRecheck + highLowRecheck = function() local oldLowY = lowY local oldHighY = highY lowY = nil highY = nil resetHighLow() - if (lowY ~= oldLowY) or (highY ~= oldHighY) then - setSliderSizeAndPosition() + return setSliderSizeAndPosition() end end - - local function descendantChanged(this, prop) + local descendantChanged + descendantChanged = function(this, prop) if internalChange then return end if not this.Visible then return end - if prop == "Size" or prop == "Position" then + wait() + return highLowRecheck() + end + end + scrollingFrame.DescendantAdded:connect(function(instance) + if not instance:IsA("GuiObject") then + return + end + if instance.Visible then wait() highLowRecheck() end - end - - scrollingFrame.DescendantAdded:connect(function(instance) - if not instance:IsA "GuiObject" then - return - end - - if instance.Visible then - wait() -- wait a heartbeat for sizes to reconfig - highLowRecheck() - end - descendantsChangeConMap[instance] = instance.Changed:connect(function(prop) - descendantChanged(instance, prop) + return descendantChanged(instance, prop) end) end) - scrollingFrame.DescendantRemoving:connect(function(instance) - if not instance:IsA "GuiObject" then + if not instance:IsA("GuiObject") then return end if descendantsChangeConMap[instance] then descendantsChangeConMap[instance]:disconnect() descendantsChangeConMap[instance] = nil end - wait() -- wait a heartbeat for sizes to reconfig - highLowRecheck() + wait() + return highLowRecheck() end) - scrollingFrame.Changed:connect(function(prop) if prop == "AbsoluteSize" then if not highY or not lowY then return end - highLowRecheck() - setSliderSizeAndPosition() + return setSliderSizeAndPosition() end end) - return scrollingFrame, controlFrame end - t.CreateScrollingFrame = function(orderList, scrollStyle) - local frame = Instance.new "Frame" + local frame = Instance.new("Frame") frame.Name = "ScrollingFrame" frame.BackgroundTransparency = 1 frame.Size = UDim2.new(1, 0, 1, 0) - - local scrollUpButton = Instance.new "ImageButton" + local scrollUpButton = Instance.new("ImageButton") scrollUpButton.Name = "ScrollUpButton" scrollUpButton.BackgroundTransparency = 1 scrollUpButton.Image = "rbxasset://textures/ui/scrollbuttonUp.png" scrollUpButton.Size = UDim2.new(0, 17, 0, 17) - - local scrollDownButton = Instance.new "ImageButton" + local scrollDownButton = Instance.new("ImageButton") scrollDownButton.Name = "ScrollDownButton" scrollDownButton.BackgroundTransparency = 1 scrollDownButton.Image = "rbxasset://textures/ui/scrollbuttonDown.png" scrollDownButton.Size = UDim2.new(0, 17, 0, 17) - - local scrollbar = Instance.new "ImageButton" + local scrollbar = Instance.new("ImageButton") scrollbar.Name = "ScrollBar" scrollbar.Image = "rbxasset://textures/ui/scrollbar.png" scrollbar.BackgroundTransparency = 1 scrollbar.Size = UDim2.new(0, 18, 0, 150) - local scrollStamp = 0 - - local scrollDrag = Instance.new "ImageButton" + local scrollDrag = Instance.new("ImageButton") scrollDrag.Image = "http://www.roblox.com/asset/?id=61367186" scrollDrag.Size = UDim2.new(1, 0, 0, 16) scrollDrag.BackgroundTransparency = 1 scrollDrag.Name = "ScrollDrag" scrollDrag.Active = true scrollDrag.Parent = scrollbar - - local mouseDrag = Instance.new "ImageButton" + local mouseDrag = Instance.new("ImageButton") mouseDrag.Active = false mouseDrag.Size = UDim2.new(1.5, 0, 1.5, 0) mouseDrag.AutoButtonColor = false @@ -1412,19 +1218,17 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) mouseDrag.Name = "mouseDrag" mouseDrag.Position = UDim2.new(-0.25, 0, -0.25, 0) mouseDrag.ZIndex = 10 - local style = "simple" if scrollStyle and tostring(scrollStyle) then style = scrollStyle end - local scrollPosition = 1 local rowSize = 0 local howManyDisplayed = 0 - - local layoutGridScrollBar = function() + local layoutGridScrollBar + layoutGridScrollBar = function() howManyDisplayed = 0 - local guiObjects = {} + local guiObjects = { } if orderList then for _, child in ipairs(orderList) do if child.Parent == frame then @@ -1435,7 +1239,7 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) local children = frame:GetChildren() if children then for _, child in ipairs(children) do - if child:IsA "GuiObject" then + if child:IsA("GuiObject") then table.insert(guiObjects, child) end end @@ -1448,34 +1252,24 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) scrollPosition = 1 return end - if scrollPosition > #guiObjects then scrollPosition = #guiObjects end - if scrollPosition < 1 then scrollPosition = 1 end - local totalPixelsY = frame.AbsoluteSize.Y local pixelsRemainingY = frame.AbsoluteSize.Y - local totalPixelsX = frame.AbsoluteSize.X - local xCounter = 0 local rowSizeCounter = 0 local setRowSize = true - local pixelsBelowScrollbar = 0 local pos = #guiObjects - local currentRowY = 0 - pos = scrollPosition - --count up from current scroll position to fill out grid while pos <= #guiObjects and pixelsBelowScrollbar < totalPixelsY do xCounter = xCounter + guiObjects[pos].AbsoluteSize.X - --previous pos was the end of a row if xCounter >= totalPixelsX then pixelsBelowScrollbar = pixelsBelowScrollbar + currentRowY currentRowY = 0 @@ -1486,17 +1280,10 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) end pos = pos + 1 end - --Count wherever current row left off pixelsBelowScrollbar = pixelsBelowScrollbar + currentRowY currentRowY = 0 - pos = scrollPosition - 1 xCounter = 0 - - --objects with varying X,Y dimensions can rarely cause minor errors - --rechecking every new scrollPosition is necessary to avoid 100% of errors - - --count backwards from current scrollPosition to see if we can add more rows while pixelsBelowScrollbar + currentRowY < totalPixelsY and pos >= 1 do xCounter = xCounter + guiObjects[pos].AbsoluteSize.X rowSizeCounter = rowSizeCounter + 1 @@ -1505,7 +1292,6 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) rowSizeCounter = 0 xCounter = guiObjects[pos].AbsoluteSize.X if pixelsBelowScrollbar + currentRowY <= totalPixelsY then - --It fits, so back up our scroll position pixelsBelowScrollbar = pixelsBelowScrollbar + currentRowY if scrollPosition <= rowSize then scrollPosition = 1 @@ -1518,42 +1304,31 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) break end end - if guiObjects[pos].AbsoluteSize.Y > currentRowY then currentRowY = guiObjects[pos].AbsoluteSize.Y end - pos = pos - 1 end - - --Do check last time if pos = 0 if (pos == 0) and (pixelsBelowScrollbar + currentRowY <= totalPixelsY) then scrollPosition = 1 end - xCounter = 0 - --pos = scrollPosition rowSizeCounter = 0 setRowSize = true local lastChildSize = 0 - - local xOffset, yOffset = 0 + local xOffset = 0 + local yOffset = 0 if guiObjects[1] then yOffset = math.ceil(math.floor(math.fmod(totalPixelsY, guiObjects[1].AbsoluteSize.X)) / 2) xOffset = math.ceil(math.floor(math.fmod(totalPixelsX, guiObjects[1].AbsoluteSize.Y)) / 2) end - for i, child in ipairs(guiObjects) do if i < scrollPosition then - --print("Hiding " .. child.Name) child.Visible = false else if pixelsRemainingY < 0 then - --print("Out of Space " .. child.Name) child.Visible = false else - --print("Laying out " .. child.Name) - --GuiObject if setRowSize then rowSizeCounter = rowSizeCounter + 1 end @@ -1565,12 +1340,7 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) xCounter = 0 pixelsRemainingY = pixelsRemainingY - child.AbsoluteSize.Y end - child.Position = UDim2.new( - child.Position.X.Scale, - xCounter + xOffset, - 0, - totalPixelsY - pixelsRemainingY + yOffset - ) + child.Position = UDim2.new(child.Position.X.Scale, xCounter + xOffset, 0, totalPixelsY - pixelsRemainingY + yOffset) xCounter = xCounter + child.AbsoluteSize.X child.Visible = ((pixelsRemainingY - child.AbsoluteSize.Y) >= 0) if child.Visible then @@ -1580,7 +1350,6 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) end end end - scrollUpButton.Active = (scrollPosition > 1) if lastChildSize == 0 then scrollDownButton.Active = false @@ -1590,11 +1359,10 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) scrollDrag.Active = #guiObjects > howManyDisplayed scrollDrag.Visible = scrollDrag.Active end - - local layoutSimpleScrollBar = function() - local guiObjects = {} + local layoutSimpleScrollBar + layoutSimpleScrollBar = function() + local guiObjects = { } howManyDisplayed = 0 - if orderList then for _, child in ipairs(orderList) do if child.Parent == frame then @@ -1605,7 +1373,7 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) local children = frame:GetChildren() if children then for _, child in ipairs(children) do - if child:IsA "GuiObject" then + if child:IsA("GuiObject") then table.insert(guiObjects, child) end end @@ -1618,14 +1386,11 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) scrollPosition = 1 return end - if scrollPosition > #guiObjects then scrollPosition = #guiObjects end - local totalPixels = frame.AbsoluteSize.Y local pixelsRemaining = frame.AbsoluteSize.Y - local pixelsBelowScrollbar = 0 local pos = #guiObjects while pixelsBelowScrollbar < totalPixels and pos >= 1 do @@ -1633,13 +1398,11 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) pixelsBelowScrollbar = pixelsBelowScrollbar + guiObjects[pos].AbsoluteSize.Y else if pixelsBelowScrollbar + guiObjects[pos].AbsoluteSize.Y <= totalPixels then - --It fits, so back up our scroll position pixelsBelowScrollbar = pixelsBelowScrollbar + guiObjects[pos].AbsoluteSize.Y if scrollPosition <= 1 then scrollPosition = 1 break else - --local ("Backing up ScrollPosition from -- " ..scrollPosition) scrollPosition = scrollPosition - 1 end else @@ -1648,21 +1411,15 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) end pos = pos - 1 end - pos = scrollPosition for i, child in ipairs(guiObjects) do if i < scrollPosition then - --print("Hiding " .. child.Name) child.Visible = false else if pixelsRemaining < 0 then - --print("Out of Space " .. child.Name) child.Visible = false else - --print("Laying out " .. child.Name) - --GuiObject - child.Position = - UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) + child.Position = UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining) pixelsRemaining = pixelsRemaining - child.AbsoluteSize.Y if pixelsRemaining >= 0 then child.Visible = true @@ -1678,29 +1435,25 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) scrollDrag.Active = #guiObjects > howManyDisplayed scrollDrag.Visible = scrollDrag.Active end - - local moveDragger = function() + local moveDragger + moveDragger = function() local guiObjects = 0 local children = frame:GetChildren() if children then for _, child in ipairs(children) do - if child:IsA "GuiObject" then + if child:IsA("GuiObject") then guiObjects = guiObjects + 1 end end end - if not scrollDrag.Parent then return end - local dragSizeY = scrollDrag.Parent.AbsoluteSize.y * (1 / (guiObjects - howManyDisplayed + 1)) if dragSizeY < 16 then dragSizeY = 16 end - scrollDrag.Size = - UDim2.new(scrollDrag.Size.X.Scale, scrollDrag.Size.X.Offset, scrollDrag.Size.Y.Scale, dragSizeY) - + scrollDrag.Size = UDim2.new(scrollDrag.Size.X.Scale, scrollDrag.Size.X.Offset, scrollDrag.Size.Y.Scale, dragSizeY) local relativeYPos = (scrollPosition - 1) / (guiObjects - howManyDisplayed) if relativeYPos > 1 then relativeYPos = 1 @@ -1708,30 +1461,27 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) relativeYPos = 0 end local absYPos = 0 - if relativeYPos ~= 0 then absYPos = (relativeYPos * scrollbar.AbsoluteSize.y) - (relativeYPos * scrollDrag.AbsoluteSize.y) end - - scrollDrag.Position = - UDim2.new(scrollDrag.Position.X.Scale, scrollDrag.Position.X.Offset, scrollDrag.Position.Y.Scale, absYPos) + scrollDrag.Position = UDim2.new(scrollDrag.Position.X.Scale, scrollDrag.Position.X.Offset, scrollDrag.Position.Y.Scale, absYPos) end - local reentrancyGuard = false - local recalculate = function() + local recalculate + recalculate = function() if reentrancyGuard then return end reentrancyGuard = true wait() - local success, err = nil + local success, err if style == "grid" then success, err = pcall(function() - layoutGridScrollBar() + return layoutGridScrollBar() end) elseif style == "simple" then success, err = pcall(function() - layoutSimpleScrollBar() + return layoutSimpleScrollBar() end) end if not success then @@ -1740,21 +1490,21 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) moveDragger() reentrancyGuard = false end - - local doScrollUp = function() + local doScrollUp + doScrollUp = function() scrollPosition = scrollPosition - rowSize if scrollPosition < 1 then scrollPosition = 1 end - recalculate(nil) + return recalculate(nil) end - - local doScrollDown = function() + local doScrollDown + doScrollDown = function() scrollPosition = scrollPosition + rowSize - recalculate(nil) + return recalculate(nil) end - - local scrollUp = function(mouseYPos) + local scrollUp + scrollUp = function(mouseYPos) if scrollUpButton.Active then scrollStamp = tick() local current = scrollStamp @@ -1762,12 +1512,12 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) upCon = mouseDrag.MouseButton1Up:connect(function() scrollStamp = tick() mouseDrag.Parent = nil - upCon:disconnect() + return upCon:disconnect() end) mouseDrag.Parent = getScreenGuiAncestor(scrollbar) doScrollUp() wait(0.2) - local t = tick() + t = tick() local w = 0.1 while scrollStamp == current do doScrollUp() @@ -1786,8 +1536,8 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) end end end - - local scrollDown = function(mouseYPos) + local scrollDown + scrollDown = function(mouseYPos) if scrollDownButton.Active then scrollStamp = tick() local current = scrollStamp @@ -1795,12 +1545,12 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) downCon = mouseDrag.MouseButton1Up:connect(function() scrollStamp = tick() mouseDrag.Parent = nil - downCon:disconnect() + return downCon:disconnect() end) mouseDrag.Parent = getScreenGuiAncestor(scrollbar) doScrollDown() wait(0.2) - local t = tick() + t = tick() local w = 0.1 while scrollStamp == current do doScrollDown() @@ -1819,8 +1569,6 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) end end end - - -- local y = 0 scrollDrag.MouseButton1Down:connect(function(_, y) if scrollDrag.Active then scrollStamp = tick() @@ -1830,23 +1578,20 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) dragCon = mouseDrag.MouseMoved:connect(function(_, y) local barAbsPos = scrollbar.AbsolutePosition.y local barAbsSize = scrollbar.AbsoluteSize.y - local dragAbsSize = scrollDrag.AbsoluteSize.y local barAbsOne = barAbsPos + barAbsSize - dragAbsSize y = y - mouseOffset y = y < barAbsPos and barAbsPos or y > barAbsOne and barAbsOne or y y = y - barAbsPos - local guiObjects = 0 local children = frame:GetChildren() if children then for _, child in ipairs(children) do - if child:IsA "GuiObject" then + if child:IsA("GuiObject") then guiObjects = guiObjects + 1 end end end - local doublePercent = y / (barAbsSize - dragAbsSize) local rowDiff = rowSize local totalScrollCount = guiObjects - (howManyDisplayed - 1) @@ -1854,13 +1599,11 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) if newScrollPosition < scrollPosition then rowDiff = -rowDiff end - if newScrollPosition < 1 then newScrollPosition = 1 end - scrollPosition = newScrollPosition - recalculate(nil) + return recalculate(nil) end) upCon = mouseDrag.MouseButton1Up:connect(function() scrollStamp = tick() @@ -1873,109 +1616,91 @@ t.CreateScrollingFrame = function(orderList, scrollStyle) mouseDrag.Parent = getScreenGuiAncestor(scrollbar) end end) - local scrollMouseCount = 0 - scrollUpButton.MouseButton1Down:connect(function() - scrollUp() + return scrollUp() end) scrollUpButton.MouseButton1Up:connect(function() scrollStamp = tick() end) - scrollDownButton.MouseButton1Up:connect(function() scrollStamp = tick() end) scrollDownButton.MouseButton1Down:connect(function() - scrollDown() + return scrollDown() end) - scrollbar.MouseButton1Up:connect(function() scrollStamp = tick() end) scrollbar.MouseButton1Down:connect(function(_, y) if y > (scrollDrag.AbsoluteSize.y + scrollDrag.AbsolutePosition.y) then - scrollDown(y) + return scrollDown(y) elseif y < scrollDrag.AbsolutePosition.y then - scrollUp(y) + return scrollUp(y) end end) - frame.ChildAdded:connect(function() - recalculate(nil) + return recalculate(nil) end) - frame.ChildRemoved:connect(function() - recalculate(nil) + return recalculate(nil) end) - frame.Changed:connect(function(prop) if prop == "AbsoluteSize" then - --Wait a heartbeat for it to sync in - recalculate(nil) + return recalculate(nil) end end) frame.AncestryChanged:connect(function() - recalculate(nil) + return recalculate(nil) end) - return frame, scrollUpButton, scrollDownButton, recalculate, scrollbar end -local function binaryGrow(min, max, fits) +local binaryGrow +binaryGrow = function(min, max, fits) if min > max then return min end local biggestLegal = min - while min <= max do local mid = min + math.floor((max - min) / 2) - if fits(mid) and (biggestLegal == nil or biggestLegal < mid) then + if fits(mid and (biggestLegal == nil or biggestLegal < mid)) then biggestLegal = mid - - --Try growing min = mid + 1 else - --Doesn't fit, shrink max = mid - 1 end end return biggestLegal end - -local function binaryShrink(min, max, fits) +local binaryShrink +binaryShrink = function(min, max, fits) if min > max then return min end local smallestLegal = max - while min <= max do local mid = min + math.floor((max - min) / 2) - if fits(mid) and (smallestLegal == nil or smallestLegal > mid) then + if fits(mid and (smallestLegal == nil or smallestLegal > mid)) then smallestLegal = mid - - --It fits, shrink max = mid - 1 else - --Doesn't fit, grow min = mid + 1 end end return smallestLegal end - -local function getGuiOwner(instance) +local getGuiOwner +getGuiOwner = function(instance) while instance ~= nil do - if instance:IsA "ScreenGui" or instance:IsA "BillboardGui" then + if instance:IsA("ScreenGui") or instance:IsA("BillboardGui") then return instance end instance = instance.Parent end return nil end - t.AutoTruncateTextObject = function(textLabel) local text = textLabel.Text - local fullLabel = textLabel:Clone() fullLabel.Name = "Full" .. textLabel.Name fullLabel.BorderSizePixel = 0 @@ -1986,18 +1711,16 @@ t.AutoTruncateTextObject = function(textLabel) fullLabel.Size = UDim2.new(0, 100, 1, 0) fullLabel.Visible = false fullLabel.Parent = textLabel - - local shortText = nil - local mouseEnterConnection = nil - local mouseLeaveConnection = nil - - local checkForResize = function() - if getGuiOwner(textLabel) == nil then + local shortText + local mouseEnterConnection + local mouseLeaveConnection + local checkForResize + checkForResize = function() + if getGuiOwner(textLabel == nil) then return end textLabel.Text = text if textLabel.TextFits then - --Tear down the rollover if it is active if mouseEnterConnection then mouseEnterConnection:disconnect() mouseEnterConnection = nil @@ -2009,8 +1732,6 @@ t.AutoTruncateTextObject = function(textLabel) else local len = string.len(text) textLabel.Text = text .. "~" - - --Shrink the text local textSize = binaryGrow(0, len, function(pos) if pos == 0 then textLabel.Text = "~" @@ -2021,32 +1742,23 @@ t.AutoTruncateTextObject = function(textLabel) end) shortText = string.sub(text, 1, textSize) .. "~" textLabel.Text = shortText - - --Make sure the fullLabel fits if not fullLabel.TextFits then - --Already too small, grow it really bit to start fullLabel.Size = UDim2.new(0, 10000, 1, 0) end - - --Okay, now try to binary shrink it back down local fullLabelSize = binaryShrink(textLabel.AbsoluteSize.X, fullLabel.AbsoluteSize.X, function(size) fullLabel.Size = UDim2.new(0, size, 1, 0) return fullLabel.TextFits end) fullLabel.Size = UDim2.new(0, fullLabelSize + 6, 1, 0) - - --Now setup the rollover effects, if they are currently off if mouseEnterConnection == nil then mouseEnterConnection = textLabel.MouseEnter:connect(function() fullLabel.ZIndex = textLabel.ZIndex + 1 fullLabel.Visible = true - --textLabel.Text = "" end) end if mouseLeaveConnection == nil then mouseLeaveConnection = textLabel.MouseLeave:connect(function() fullLabel.Visible = false - --textLabel.Text = shortText end) end end @@ -2054,22 +1766,20 @@ t.AutoTruncateTextObject = function(textLabel) textLabel.AncestryChanged:connect(checkForResize) textLabel.Changed:connect(function(prop) if prop == "AbsoluteSize" then - checkForResize() + return checkForResize() end end) - checkForResize() - - local function changeText(newText) + local changeText + changeText = function(newText) text = newText fullLabel.Text = text - checkForResize() + return checkForResize() end - return textLabel, changeText end - -local function TransitionTutorialPages(fromPage, toPage, transitionFrame, currentPageValue) +local TransitionTutorialPages +TransitionTutorialPages = function(fromPage, toPage, transitionFrame, currentPageValue) if fromPage then fromPage.Visible = false if transitionFrame.Visible == false then @@ -2084,72 +1794,55 @@ local function TransitionTutorialPages(fromPage, toPage, transitionFrame, curren end transitionFrame.Visible = true currentPageValue.Value = nil - local newSize, newPosition if toPage then - --Make it visible so it resizes toPage.Visible = true - newSize = toPage.Size newPosition = toPage.Position - toPage.Visible = false else newSize = UDim2.new(0, 50, 0, 50) newPosition = UDim2.new(0.5, -25, 0.5, -25) end - transitionFrame:TweenSizeAndPosition( - newSize, - newPosition, - Enum.EasingDirection.InOut, - Enum.EasingStyle.Quad, - 0.3, - true, - function(state) - if state == Enum.TweenStatus.Completed then - transitionFrame.Visible = false - if toPage then - toPage.Visible = true - currentPageValue.Value = toPage - end + return transitionFrame:TweenSizeAndPosition(newSize, newPosition, Enum.EasingDirection.InOut, Enum.EasingStyle.Quad, 0.3, true, function(state) + if state == Enum.TweenStatus.Completed then + transitionFrame.Visible = false + if toPage then + toPage.Visible = true + currentPageValue.Value = toPage end end - ) + end) end - t.CreateTutorial = function(name, tutorialKey, createButtons) - local frame = Instance.new "Frame" + local frame = Instance.new("Frame") frame.Name = "Tutorial-" .. name frame.BackgroundTransparency = 1 frame.Size = UDim2.new(0.6, 0, 0.6, 0) frame.Position = UDim2.new(0.2, 0, 0.2, 0) - - local transitionFrame = Instance.new "Frame" + local transitionFrame = Instance.new("Frame") transitionFrame.Name = "TransitionFrame" transitionFrame.Style = Enum.FrameStyle.RobloxRound transitionFrame.Size = UDim2.new(0.6, 0, 0.6, 0) transitionFrame.Position = UDim2.new(0.2, 0, 0.2, 0) transitionFrame.Visible = false transitionFrame.Parent = frame - - local currentPageValue = Instance.new "ObjectValue" + local currentPageValue = Instance.new("ObjectValue") currentPageValue.Name = "CurrentTutorialPage" currentPageValue.Value = nil currentPageValue.Parent = frame - - local boolValue = Instance.new "BoolValue" + local boolValue = Instance.new("BoolValue") boolValue.Name = "Buttons" boolValue.Value = createButtons boolValue.Parent = frame - - local pages = Instance.new "Frame" + local pages = Instance.new("Frame") pages.Name = "Pages" pages.BackgroundTransparency = 1 pages.Size = UDim2.new(1, 0, 1, 0) pages.Parent = frame - - local function getVisiblePageAndHideOthers() - local visiblePage = nil + local getVisiblePageAndHideOthers + getVisiblePageAndHideOthers = function() + local visiblePage local children = pages:GetChildren() if children then for _, child in ipairs(children) do @@ -2164,49 +1857,44 @@ t.CreateTutorial = function(name, tutorialKey, createButtons) end return visiblePage end - - local showTutorial = function(alwaysShow) - if alwaysShow or UserSettings().GameSettings:GetTutorialState(tutorialKey) == false then + local showTutorial + showTutorial = function(alwaysShow) + if alwaysShow or UserSettings().GameSettings:GetTutorialState(tutorialKey == false) then print("Showing tutorial-", tutorialKey) local currentTutorialPage = getVisiblePageAndHideOthers() - - local firstPage = pages:FindFirstChild "TutorialPage1" + local firstPage = pages:FindFirstChild("TutorialPage1") if firstPage then - TransitionTutorialPages(currentTutorialPage, firstPage, transitionFrame, currentPageValue) + return TransitionTutorialPages(currentTutorialPage, firstPage, transitionFrame, currentPageValue) else - error "Could not find TutorialPage1" + return error("Could not find TutorialPage1") end end end - - local dismissTutorial = function() + local dismissTutorial + dismissTutorial = function() local currentTutorialPage = getVisiblePageAndHideOthers() - if currentTutorialPage then TransitionTutorialPages(currentTutorialPage, nil, transitionFrame, currentPageValue) end - - UserSettings().GameSettings:SetTutorialState(tutorialKey, true) + return UserSettings().GameSettings:SetTutorialState(tutorialKey, true) end - - local gotoPage = function(pageNum) + local gotoPage + gotoPage = function(pageNum) local page = pages:FindFirstChild("TutorialPage" .. pageNum) local currentTutorialPage = getVisiblePageAndHideOthers() - TransitionTutorialPages(currentTutorialPage, page, transitionFrame, currentPageValue) + return TransitionTutorialPages(currentTutorialPage, page, transitionFrame, currentPageValue) end - return frame, showTutorial, dismissTutorial, gotoPage end - -local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDoneButton) - local frame = Instance.new "Frame" +local CreateBasicTutorialPage +CreateBasicTutorialPage = function(name, handleResize, skipTutorial, giveDoneButton) + local frame = Instance.new("Frame") frame.Name = "TutorialPage" frame.Style = Enum.FrameStyle.RobloxRound frame.Size = UDim2.new(0.6, 0, 0.6, 0) frame.Position = UDim2.new(0.2, 0, 0.2, 0) frame.Visible = false - - local frameHeader = Instance.new "TextLabel" + local frameHeader = Instance.new("TextLabel") frameHeader.Name = "Header" frameHeader.Text = name frameHeader.BackgroundTransparency = 1 @@ -2218,14 +1906,13 @@ local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDon frameHeader.Size = UDim2.new(1, -55, 0, 22) frameHeader.Position = UDim2.new(0, 0, 0, 0) frameHeader.Parent = frame - - local skipButton = Instance.new "ImageButton" + local skipButton = Instance.new("ImageButton") skipButton.Name = "SkipButton" skipButton.AutoButtonColor = false skipButton.BackgroundTransparency = 1 skipButton.Image = "rbxasset://textures/ui/closeButton.png" skipButton.MouseButton1Click:connect(function() - skipTutorial() + return skipTutorial() end) skipButton.MouseEnter:connect(function() skipButton.Image = "rbxasset://textures/ui/closeButton_dn.png" @@ -2236,9 +1923,8 @@ local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDon skipButton.Size = UDim2.new(0, 25, 0, 25) skipButton.Position = UDim2.new(1, -25, 0, 0) skipButton.Parent = frame - if giveDoneButton then - local doneButton = Instance.new "TextButton" + local doneButton = Instance.new("TextButton") doneButton.Name = "DoneButton" doneButton.Style = Enum.ButtonStyle.RobloxButtonDefault doneButton.Text = "Done" @@ -2247,23 +1933,19 @@ local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDon doneButton.FontSize = Enum.FontSize.Size18 doneButton.Size = UDim2.new(0, 100, 0, 50) doneButton.Position = UDim2.new(0.5, -50, 1, -50) - if skipTutorial then doneButton.MouseButton1Click:connect(function() - skipTutorial() + return skipTutorial() end) end - doneButton.Parent = frame end - - local innerFrame = Instance.new "Frame" + local innerFrame = Instance.new("Frame") innerFrame.Name = "ContentFrame" innerFrame.BackgroundTransparency = 1 innerFrame.Position = UDim2.new(0, 0, 0, 25) innerFrame.Parent = frame - - local nextButton = Instance.new "TextButton" + local nextButton = Instance.new("TextButton") nextButton.Name = "NextButton" nextButton.Text = "Next" nextButton.TextColor3 = Color3.new(1, 1, 1) @@ -2275,8 +1957,7 @@ local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDon nextButton.Active = false nextButton.Visible = false nextButton.Parent = frame - - local prevButton = Instance.new "TextButton" + local prevButton = Instance.new("TextButton") prevButton.Name = "PrevButton" prevButton.Text = "Previous" prevButton.TextColor3 = Color3.new(1, 1, 1) @@ -2288,52 +1969,45 @@ local function CreateBasicTutorialPage(name, handleResize, skipTutorial, giveDon prevButton.Active = false prevButton.Visible = false prevButton.Parent = frame - if giveDoneButton then innerFrame.Size = UDim2.new(1, 0, 1, -75) else innerFrame.Size = UDim2.new(1, 0, 1, -22) end - - local parentConnection = nil - - local function basicHandleResize() + local parentConnection + local basicHandleResize + basicHandleResize = function() if frame.Visible and frame.Parent then local maxSize = math.min(frame.Parent.AbsoluteSize.X, frame.Parent.AbsoluteSize.Y) - handleResize(200, maxSize) + return handleResize(200, maxSize) end end - frame.Changed:connect(function(prop) if prop == "Parent" then if parentConnection ~= nil then parentConnection:disconnect() parentConnection = nil end - if frame.Parent and frame.Parent:IsA "GuiObject" then + if frame.Parent and frame.Parent:IsA("GuiObject") then parentConnection = frame.Parent.Changed:connect(function(parentProp) if parentProp == "AbsoluteSize" then wait() - basicHandleResize() + return basicHandleResize() end end) basicHandleResize() end end - if prop == "Visible" then - basicHandleResize() + return basicHandleResize() end end) - return frame, innerFrame end - t.CreateTextTutorialPage = function(name, text, skipTutorialFunc) - local frame = nil - local contentFrame = nil - - local textLabel = Instance.new "TextLabel" + local frame + local contentFrame + local textLabel = Instance.new("TextLabel") textLabel.BackgroundTransparency = 1 textLabel.TextColor3 = Color3.new(1, 1, 1) textLabel.Text = text @@ -2343,8 +2017,8 @@ t.CreateTextTutorialPage = function(name, text, skipTutorialFunc) textLabel.Font = Enum.Font.Arial textLabel.FontSize = Enum.FontSize.Size14 textLabel.Size = UDim2.new(1, 0, 1, 0) - - local function handleResize(minSize, maxSize) + local handleResize + handleResize = function(minSize, maxSize) local size = binaryShrink(minSize, maxSize, function(size) frame.Size = UDim2.new(0, size, 0, size) return textLabel.TextFits @@ -2352,24 +2026,20 @@ t.CreateTextTutorialPage = function(name, text, skipTutorialFunc) frame.Size = UDim2.new(0, size, 0, size) frame.Position = UDim2.new(0.5, -size / 2, 0.5, -size / 2) end - frame, contentFrame = CreateBasicTutorialPage(name, handleResize, skipTutorialFunc) textLabel.Parent = contentFrame - return frame end - t.CreateImageTutorialPage = function(name, imageAsset, x, y, skipTutorialFunc, giveDoneButton) - local frame = nil - local contentFrame = nil - - local imageLabel = Instance.new "ImageLabel" + local frame + local contentFrame + local imageLabel = Instance.new("ImageLabel") imageLabel.BackgroundTransparency = 1 imageLabel.Image = imageAsset imageLabel.Size = UDim2.new(0, x, 0, y) imageLabel.Position = UDim2.new(0.5, -x / 2, 0.5, -y / 2) - - local function handleResize(minSize, maxSize) + local handleResize + handleResize = function(minSize, maxSize) local size = binaryShrink(minSize, maxSize, function(size) return size >= x and size >= y end) @@ -2378,11 +2048,9 @@ t.CreateImageTutorialPage = function(name, imageAsset, x, y, skipTutorialFunc, g imageLabel.Position = UDim2.new(0.5, -x / 2, 0.5, -y / 2) else if x > y then - --X is limiter, so imageLabel.Size = UDim2.new(1, 0, y / x, 0) imageLabel.Position = UDim2.new(0, 0, 0.5 - (y / x) / 2, 0) else - --Y is limiter imageLabel.Size = UDim2.new(x / y, 0, 1, 0) imageLabel.Position = UDim2.new(0.5 - (x / y) / 2, 0, 0, 0) end @@ -2391,124 +2059,85 @@ t.CreateImageTutorialPage = function(name, imageAsset, x, y, skipTutorialFunc, g frame.Size = UDim2.new(0, size, 0, size) frame.Position = UDim2.new(0.5, -size / 2, 0.5, -size / 2) end - frame, contentFrame = CreateBasicTutorialPage(name, handleResize, skipTutorialFunc, giveDoneButton) imageLabel.Parent = contentFrame - return frame end - t.AddTutorialPage = function(tutorial, tutorialPage) local transitionFrame = tutorial.TransitionFrame local currentPageValue = tutorial.CurrentTutorialPage - if not tutorial.Buttons.Value then tutorialPage.NextButton.Parent = nil tutorialPage.PrevButton.Parent = nil end - local children = tutorial.Pages:GetChildren() if children and #children > 0 then tutorialPage.Name = "TutorialPage" .. (#children + 1) local previousPage = children[#children] - if not previousPage:IsA "GuiObject" then - error "All elements under Pages must be GuiObjects" + if not previousPage:IsA("GuiObject") then + error("All elements under Pages must be GuiObjects") end - if tutorial.Buttons.Value then if previousPage.NextButton.Active then - error "NextButton already Active on previousPage, please only add pages with RbxGui.AddTutorialPage function" + error("NextButton already Active on previousPage, please only add pages with RbxGui.AddTutorialPage function") end previousPage.NextButton.MouseButton1Click:connect(function() - TransitionTutorialPages(previousPage, tutorialPage, transitionFrame, currentPageValue) + return TransitionTutorialPages(previousPage, tutorialPage, transitionFrame, currentPageValue) end) previousPage.NextButton.Active = true previousPage.NextButton.Visible = true - if tutorialPage.PrevButton.Active then - error "PrevButton already Active on tutorialPage, please only add pages with RbxGui.AddTutorialPage function" + error("PrevButton already Active on tutorialPage, please only add pages with RbxGui.AddTutorialPage function") end tutorialPage.PrevButton.MouseButton1Click:connect(function() - TransitionTutorialPages(tutorialPage, previousPage, transitionFrame, currentPageValue) + return TransitionTutorialPages(tutorialPage, previousPage, transitionFrame, currentPageValue) end) tutorialPage.PrevButton.Active = true tutorialPage.PrevButton.Visible = true end - tutorialPage.Parent = tutorial.Pages else - --First child tutorialPage.Name = "TutorialPage1" tutorialPage.Parent = tutorial.Pages end end - -t.CreateSetPanel = function( - userIdsForSets, - objectSelected, - dialogClosed, - size, - position, - showAdminCategories, - useAssetVersionId -) +t.CreateSetPanel = function(userIdsForSets, objectSelected, dialogClosed, size, position, showAdminCategories, useAssetVersionId) if not userIdsForSets then - error "CreateSetPanel: userIdsForSets (first arg) is nil, should be a table of number ids" + error("CreateSetPanel: userIdsForSets (first arg) is nil, should be a table of number ids") end if type(userIdsForSets) ~= "table" and type(userIdsForSets) ~= "userdata" then - error( - "CreateSetPanel: userIdsForSets (first arg) is of type " - .. type(userIdsForSets) - .. ", should be of type table or userdata" - ) + error("CreateSetPanel: userIdsForSets (first arg) is of type " .. tostring(type(userIdsForSets)) .. ", should be of type table or userdata") end if not objectSelected then - error "CreateSetPanel: objectSelected (second arg) is nil, should be a callback function!" + error("CreateSetPanel: objectSelected (second arg) is nil, should be a callback function!") end if type(objectSelected) ~= "function" then - error( - "CreateSetPanel: objectSelected (second arg) is of type " - .. type(objectSelected) - .. ", should be of type function!" - ) + error("CreateSetPanel: objectSelected (second arg) is of type " .. tostring(type(objectSelected)) .. ", should be of type function!") end if dialogClosed and type(dialogClosed) ~= "function" then - error( - "CreateSetPanel: dialogClosed (third arg) is of type " - .. type(dialogClosed) - .. ", should be of type function!" - ) + error("CreateSetPanel: dialogClosed (third arg) is of type " .. tostring(type(dialogClosed)) .. ", should be of type function!") end - - if showAdminCategories == nil then -- by default, don't show beta sets + if showAdminCategories == nil then showAdminCategories = false end - local arrayPosition = 1 - local insertButtons = {} - local insertButtonCons = {} - local contents = nil - local setGui = nil - - -- used for water selections + local insertButtons = { } + local insertButtonCons = { } + local contents + local setGui local waterForceDirection = "NegX" local waterForce = "None" - local waterGui, waterTypeChangedEvent = nil - - local Data = {} + local waterGui, waterTypeChangedEvent + local Data = { } Data.CurrentCategory = nil - Data.Category = {} - local SetCache = {} - - local userCategoryButtons = nil - + Data.Category = { } + local SetCache = { } + local userCategoryButtons local buttonWidth = 64 local buttonHeight = buttonWidth - - local SmallThumbnailUrl = nil - local LargeThumbnailUrl = nil + local SmallThumbnailUrl + local LargeThumbnailUrl local BaseUrl = game:GetService("ContentProvider").BaseUrl:lower() - if useAssetVersionId then LargeThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&assetversionid=" SmallThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&assetversionid=" @@ -2516,38 +2145,53 @@ t.CreateSetPanel = function( LargeThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&aid=" SmallThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&aid=" end - - local function drillDownSetZIndex(parent, index) + local drillDownSetZIndex + drillDownSetZIndex = function(parent, index) local children = parent:GetChildren() for i = 1, #children do - if children[i]:IsA "GuiObject" then + if children[i]:IsA("GuiObject") then children[i].ZIndex = index end drillDownSetZIndex(children[i], index) end end - - -- for terrain stamping - local currTerrainDropDownFrame = nil - local terrainShapes = - { "Block", "Vertical Ramp", "Corner Wedge", "Inverse Corner Wedge", "Horizontal Ramp", "Auto-Wedge" } - local terrainShapeMap = {} + local currTerrainDropDownFrame + local terrainShapes = { + "Block", + "Vertical Ramp", + "Corner Wedge", + "Inverse Corner Wedge", + "Horizontal Ramp", + "Auto-Wedge" + } + local terrainShapeMap = { } for i = 1, #terrainShapes do terrainShapeMap[terrainShapes[i]] = i - 1 end terrainShapeMap[terrainShapes[#terrainShapes]] = 6 - - local function createWaterGui() - local waterForceDirections = { "NegX", "X", "NegY", "Y", "NegZ", "Z" } - local waterForces = { "None", "Small", "Medium", "Strong", "Max" } - - local waterFrame = Instance.new "Frame" + local createWaterGui + createWaterGui = function() + local waterForceDirections = { + "NegX", + "X", + "NegY", + "Y", + "NegZ", + "Z" + } + local waterForces = { + "None", + "Small", + "Medium", + "Strong", + "Max" + } + local waterFrame = Instance.new("Frame") waterFrame.Name = "WaterFrame" waterFrame.Style = Enum.FrameStyle.RobloxSquare waterFrame.Size = UDim2.new(0, 150, 0, 110) waterFrame.Visible = false - - local waterForceLabel = Instance.new "TextLabel" + local waterForceLabel = Instance.new("TextLabel") waterForceLabel.Name = "WaterForceLabel" waterForceLabel.BackgroundTransparency = 1 waterForceLabel.Size = UDim2.new(1, 0, 0, 12) @@ -2557,48 +2201,47 @@ t.CreateSetPanel = function( waterForceLabel.TextXAlignment = Enum.TextXAlignment.Left waterForceLabel.Text = "Water Force" waterForceLabel.Parent = waterFrame - local waterForceDirLabel = waterForceLabel:Clone() waterForceDirLabel.Name = "WaterForceDirectionLabel" waterForceDirLabel.Text = "Water Force Direction" waterForceDirLabel.Position = UDim2.new(0, 0, 0, 50) waterForceDirLabel.Parent = waterFrame - - local waterTypeChangedEvent = Instance.new "BindableEvent" + waterTypeChangedEvent = Instance.new("BindableEvent") waterTypeChangedEvent.Name = "WaterTypeChangedEvent" waterTypeChangedEvent.Parent = waterFrame - - local waterForceDirectionSelectedFunc = function(newForceDirection) + local waterForceDirectionSelectedFunc + waterForceDirectionSelectedFunc = function(newForceDirection) waterForceDirection = newForceDirection - waterTypeChangedEvent:Fire { waterForce, waterForceDirection } + return waterTypeChangedEvent:Fire({ + waterForce, + waterForceDirection + }) end - local waterForceSelectedFunc = function(newForce) + local waterForceSelectedFunc + waterForceSelectedFunc = function(newForce) waterForce = newForce - waterTypeChangedEvent:Fire { waterForce, waterForceDirection } + return waterTypeChangedEvent:Fire({ + waterForce, + waterForceDirection + }) end - - local waterForceDirectionDropDown, forceWaterDirectionSelection = - t.CreateDropDownMenu(waterForceDirections, waterForceDirectionSelectedFunc) + local waterForceDirectionDropDown, forceWaterDirectionSelection = t.CreateDropDownMenu(waterForceDirections, waterForceDirectionSelectedFunc) waterForceDirectionDropDown.Size = UDim2.new(1, 0, 0, 25) waterForceDirectionDropDown.Position = UDim2.new(0, 0, 1, 3) - forceWaterDirectionSelection "NegX" + forceWaterDirectionSelection("NegX") waterForceDirectionDropDown.Parent = waterForceDirLabel - local waterForceDropDown, forceWaterForceSelection = t.CreateDropDownMenu(waterForces, waterForceSelectedFunc) - forceWaterForceSelection "None" + forceWaterForceSelection("None") waterForceDropDown.Size = UDim2.new(1, 0, 0, 25) waterForceDropDown.Position = UDim2.new(0, 0, 1, 3) waterForceDropDown.Parent = waterForceLabel - return waterFrame, waterTypeChangedEvent end - - -- Helper Function that contructs gui elements - local function createSetGui() - local setGui = Instance.new "ScreenGui" + local createSetGui + createSetGui = function() + setGui = Instance.new("ScreenGui") setGui.Name = "SetGui" - - local setPanel = Instance.new "Frame" + local setPanel = Instance.new("Frame") setPanel.Name = "SetPanel" setPanel.Active = true setPanel.BackgroundTransparency = 1 @@ -2615,27 +2258,21 @@ t.CreateSetPanel = function( setPanel.Style = Enum.FrameStyle.RobloxRound setPanel.ZIndex = 6 setPanel.Parent = setGui - - -- Children of SetPanel - local itemPreview = Instance.new "Frame" + local itemPreview = Instance.new("Frame") itemPreview.Name = "ItemPreview" itemPreview.BackgroundTransparency = 1 itemPreview.Position = UDim2.new(0.8, 5, 0.085, 0) itemPreview.Size = UDim2.new(0.21, 0, 0.9, 0) itemPreview.ZIndex = 6 itemPreview.Parent = setPanel - - -- Children of ItemPreview - local textPanel = Instance.new "Frame" + local textPanel = Instance.new("Frame") textPanel.Name = "TextPanel" textPanel.BackgroundTransparency = 1 textPanel.Position = UDim2.new(0, 0, 0.45, 0) textPanel.Size = UDim2.new(1, 0, 0.55, 0) textPanel.ZIndex = 6 textPanel.Parent = itemPreview - - -- Children of TextPanel - local rolloverText = Instance.new "TextLabel" + local rolloverText = Instance.new("TextLabel") rolloverText.Name = "RolloverText" rolloverText.BackgroundTransparency = 1 rolloverText.Size = UDim2.new(1, 0, 0, 48) @@ -2648,25 +2285,21 @@ t.CreateSetPanel = function( rolloverText.TextXAlignment = Enum.TextXAlignment.Left rolloverText.TextYAlignment = Enum.TextYAlignment.Top rolloverText.Parent = textPanel - - local largePreview = Instance.new "ImageLabel" + local largePreview = Instance.new("ImageLabel") largePreview.Name = "LargePreview" largePreview.BackgroundTransparency = 1 largePreview.Image = "" largePreview.Size = UDim2.new(1, 0, 0, 170) largePreview.ZIndex = 6 largePreview.Parent = itemPreview - - local sets = Instance.new "Frame" + local sets = Instance.new("Frame") sets.Name = "Sets" sets.BackgroundTransparency = 1 sets.Position = UDim2.new(0, 0, 0, 5) sets.Size = UDim2.new(0.23, 0, 1, -5) sets.ZIndex = 6 sets.Parent = setPanel - - -- Children of Sets - local line = Instance.new "Frame" + local line = Instance.new("Frame") line.Name = "Line" line.BackgroundColor3 = Color3.new(1, 1, 1) line.BackgroundTransparency = 0.7 @@ -2675,7 +2308,6 @@ t.CreateSetPanel = function( line.Size = UDim2.new(0, 3, 0.9, 0) line.ZIndex = 6 line.Parent = sets - local setsLists, controlFrame = t.CreateTrueScrollingFrame() setsLists.Size = UDim2.new(1, -6, 0.94, 0) setsLists.Position = UDim2.new(0, 0, 0.06, 0) @@ -2684,8 +2316,7 @@ t.CreateSetPanel = function( setsLists.ZIndex = 6 setsLists.Parent = sets drillDownSetZIndex(controlFrame, 7) - - local setsHeader = Instance.new "TextLabel" + local setsHeader = Instance.new("TextLabel") setsHeader.Name = "SetsHeader" setsHeader.BackgroundTransparency = 1 setsHeader.Size = UDim2.new(0, 47, 0, 24) @@ -2697,8 +2328,7 @@ t.CreateSetPanel = function( setsHeader.TextXAlignment = Enum.TextXAlignment.Left setsHeader.TextYAlignment = Enum.TextYAlignment.Top setsHeader.Parent = sets - - local cancelButton = Instance.new "TextButton" + local cancelButton = Instance.new("TextButton") cancelButton.Name = "CancelButton" cancelButton.Position = UDim2.new(1, -32, 0, -2) cancelButton.Size = UDim2.new(0, 34, 0, 34) @@ -2707,9 +2337,7 @@ t.CreateSetPanel = function( cancelButton.Text = "" cancelButton.Modal = true cancelButton.Parent = setPanel - - -- Children of Cancel Button - local cancelImage = Instance.new "ImageLabel" + local cancelImage = Instance.new("ImageLabel") cancelImage.Name = "CancelImage" cancelImage.BackgroundTransparency = 1 cancelImage.Image = "http://www.roblox.com/asset?id=54135717" @@ -2717,19 +2345,16 @@ t.CreateSetPanel = function( cancelImage.Size = UDim2.new(0, 16, 0, 16) cancelImage.ZIndex = 6 cancelImage.Parent = cancelButton - return setGui end - - local function createSetButton(text) - local setButton = Instance.new "TextButton" - + local createSetButton + createSetButton = function(text) + local setButton = Instance.new("TextButton") if text then setButton.Text = text else setButton.Text = "" end - setButton.AutoButtonColor = false setButton.BackgroundTransparency = 1 setButton.BackgroundColor3 = Color3.new(1, 1, 1) @@ -2741,75 +2366,64 @@ t.CreateSetPanel = function( setButton.FontSize = Enum.FontSize.Size18 setButton.TextColor3 = Color3.new(1, 1, 1) setButton.TextXAlignment = Enum.TextXAlignment.Left - return setButton end - - local function buildSetButton(name, setId, _, _, _) + local buildSetButton + buildSetButton = function(name, setId, _, _, _) local button = createSetButton(name) button.Text = name button.Name = "SetButton" button.Visible = true - - local setValue = Instance.new "IntValue" + local setValue = Instance.new("IntValue") setValue.Name = "SetId" setValue.Value = setId setValue.Parent = button - - local setName = Instance.new "StringValue" + local setName = Instance.new("StringValue") setName.Name = "SetName" setName.Value = name setName.Parent = button - return button end - - local function processCategory(sets) - local setButtons = {} + local processCategory + processCategory = function(sets) + local setButtons = { } local numSkipped = 0 for i = 1, #sets do if not showAdminCategories and sets[i].Name == "Beta" then numSkipped = numSkipped + 1 else - setButtons[i - numSkipped] = - buildSetButton(sets[i].Name, sets[i].CategoryId, sets[i].ImageAssetId, i - numSkipped, #sets) + setButtons[i - numSkipped] = buildSetButton(sets[i].Name, sets[i].CategoryId, sets[i].ImageAssetId, i - numSkipped, #sets) end end return setButtons end - - local function handleResize() - wait() -- neccessary to insure heartbeat happened - + local handleResize + handleResize = function() + wait() local itemPreview = setGui.SetPanel.ItemPreview - itemPreview.LargePreview.Size = UDim2.new(1, 0, 0, itemPreview.AbsoluteSize.X) itemPreview.LargePreview.Position = UDim2.new(0.5, -itemPreview.LargePreview.AbsoluteSize.X / 2, 0, 0) itemPreview.TextPanel.Position = UDim2.new(0, 0, 0, itemPreview.LargePreview.AbsoluteSize.Y) - itemPreview.TextPanel.Size = - UDim2.new(1, 0, 0, itemPreview.AbsoluteSize.Y - itemPreview.LargePreview.AbsoluteSize.Y) + itemPreview.TextPanel.Size = UDim2.new(1, 0, 0, itemPreview.AbsoluteSize.Y - itemPreview.LargePreview.AbsoluteSize.Y) end - - local function makeInsertAssetButton() - local insertAssetButtonExample = Instance.new "Frame" + local makeInsertAssetButton + makeInsertAssetButton = function() + local insertAssetButtonExample = Instance.new("Frame") insertAssetButtonExample.Name = "InsertAssetButtonExample" insertAssetButtonExample.Position = UDim2.new(0, 128, 0, 64) insertAssetButtonExample.Size = UDim2.new(0, 64, 0, 64) insertAssetButtonExample.BackgroundTransparency = 1 insertAssetButtonExample.ZIndex = 6 insertAssetButtonExample.Visible = false - - local assetId = Instance.new "IntValue" + local assetId = Instance.new("IntValue") assetId.Name = "AssetId" assetId.Value = 0 assetId.Parent = insertAssetButtonExample - - local assetName = Instance.new "StringValue" + local assetName = Instance.new("StringValue") assetName.Name = "AssetName" assetName.Value = "" assetName.Parent = insertAssetButtonExample - - local button = Instance.new "TextButton" + local button = Instance.new("TextButton") button.Name = "Button" button.Text = "" button.Style = Enum.ButtonStyle.RobloxButton @@ -2817,8 +2431,7 @@ t.CreateSetPanel = function( button.Size = UDim2.new(0.95, 0, 0.95, 0) button.ZIndex = 6 button.Parent = insertAssetButtonExample - - local buttonImage = Instance.new "ImageLabel" + local buttonImage = Instance.new("ImageLabel") buttonImage.Name = "ButtonImage" buttonImage.Image = "" buttonImage.Position = UDim2.new(0, -7, 0, -7) @@ -2826,7 +2439,6 @@ t.CreateSetPanel = function( buttonImage.BackgroundTransparency = 1 buttonImage.ZIndex = 7 buttonImage.Parent = button - local configIcon = buttonImage:clone() configIcon.Name = "ConfigIcon" configIcon.Visible = false @@ -2835,35 +2447,29 @@ t.CreateSetPanel = function( configIcon.Image = "" configIcon.ZIndex = 6 configIcon.Parent = insertAssetButtonExample - return insertAssetButtonExample end - - local function showLargePreview(insertButton) - if insertButton:FindFirstChild "AssetId" then + local showLargePreview + showLargePreview = function(insertButton) + if insertButton:FindFirstChild("AssetId") then delay(0, function() game:GetService("ContentProvider"):Preload(LargeThumbnailUrl .. tostring(insertButton.AssetId.Value)) - setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl - .. tostring(insertButton.AssetId.Value) + setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl .. tostring(insertButton.AssetId.Value) end) end - if insertButton:FindFirstChild "AssetName" then + if insertButton:FindFirstChild("AssetName") then setGui.SetPanel.ItemPreview.TextPanel.RolloverText.Text = insertButton.AssetName.Value end end - - local function selectTerrainShape(shape) + local selectTerrainShape + selectTerrainShape = function(shape) if currTerrainDropDownFrame then - objectSelected( - tostring(currTerrainDropDownFrame.AssetName.Value), - tonumber(currTerrainDropDownFrame.AssetId.Value), - shape - ) + return objectSelected(tostring(currTerrainDropDownFrame.AssetName.Value), tonumber(currTerrainDropDownFrame.AssetId.Value), shape) end end - - local function createTerrainTypeButton(name, parent) - local dropDownTextButton = Instance.new "TextButton" + local createTerrainTypeButton + createTerrainTypeButton = function(name, parent) + local dropDownTextButton = Instance.new("TextButton") dropDownTextButton.Name = name .. "Button" dropDownTextButton.Font = Enum.Font.ArialBold dropDownTextButton.FontSize = Enum.FontSize.Size14 @@ -2875,31 +2481,27 @@ t.CreateSetPanel = function( dropDownTextButton.ZIndex = parent.ZIndex + 1 dropDownTextButton.Size = UDim2.new(0, parent.Size.X.Offset - 2, 0, 16) dropDownTextButton.Position = UDim2.new(0, 1, 0, 0) - dropDownTextButton.MouseEnter:connect(function() dropDownTextButton.BackgroundTransparency = 0 dropDownTextButton.TextColor3 = Color3.new(0, 0, 0) end) - dropDownTextButton.MouseLeave:connect(function() dropDownTextButton.BackgroundTransparency = 1 dropDownTextButton.TextColor3 = Color3.new(1, 1, 1) end) - dropDownTextButton.MouseButton1Click:connect(function() dropDownTextButton.BackgroundTransparency = 1 dropDownTextButton.TextColor3 = Color3.new(1, 1, 1) - if dropDownTextButton.Parent and dropDownTextButton.Parent:IsA "GuiObject" then + if dropDownTextButton.Parent and dropDownTextButton.Parent:IsA("GuiObject") then dropDownTextButton.Parent.Visible = false end - selectTerrainShape(terrainShapeMap[dropDownTextButton.Text]) + return selectTerrainShape(terrainShapeMap[dropDownTextButton.Text]) end) - return dropDownTextButton end - - local function createTerrainDropDownMenu(zIndex) - local dropDown = Instance.new "Frame" + local createTerrainDropDownMenu + createTerrainDropDownMenu = function(zIndex) + local dropDown = Instance.new("Frame") dropDown.Name = "TerrainDropDown" dropDown.BackgroundColor3 = Color3.new(0, 0, 0) dropDown.BorderColor3 = Color3.new(1, 0, 0) @@ -2907,21 +2509,19 @@ t.CreateSetPanel = function( dropDown.Visible = false dropDown.ZIndex = zIndex dropDown.Parent = setGui - for i = 1, #terrainShapes do local shapeButton = createTerrainTypeButton(terrainShapes[i], dropDown) shapeButton.Position = UDim2.new(0, 1, 0, (i - 1) * shapeButton.Size.Y.Offset) shapeButton.Parent = dropDown dropDown.Size = UDim2.new(0, 200, 0, dropDown.Size.Y.Offset + shapeButton.Size.Y.Offset) end - - dropDown.MouseLeave:connect(function() + return dropDown.MouseLeave:connect(function() dropDown.Visible = false end) end - - local function createDropDownMenuButton(parent) - local dropDownButton = Instance.new "ImageButton" + local createDropDownMenuButton + createDropDownMenuButton = function(parent) + local dropDownButton = Instance.new("ImageButton") dropDownButton.Name = "DropDownButton" dropDownButton.Image = "http://www.roblox.com/asset/?id=67581509" dropDownButton.BackgroundTransparency = 1 @@ -2929,40 +2529,36 @@ t.CreateSetPanel = function( dropDownButton.Position = UDim2.new(1, -24, 0, 6) dropDownButton.ZIndex = parent.ZIndex + 2 dropDownButton.Parent = parent - - if not setGui:FindFirstChild "TerrainDropDown" then + if not setGui:FindFirstChild("TerrainDropDown") then createTerrainDropDownMenu(8) end - - dropDownButton.MouseButton1Click:connect(function() + return dropDownButton.MouseButton1Click:connect(function() setGui.TerrainDropDown.Visible = true setGui.TerrainDropDown.Position = UDim2.new(0, parent.AbsolutePosition.X, 0, parent.AbsolutePosition.Y) currTerrainDropDownFrame = parent end) end - - local function buildInsertButton() + local buildInsertButton + buildInsertButton = function() local insertButton = makeInsertAssetButton() insertButton.Name = "InsertAssetButton" insertButton.Visible = true - if Data.Category[Data.CurrentCategory].SetName == "High Scalability" then createDropDownMenuButton(insertButton) end - - local lastEnter = nil + local lastEnter local mouseEnterCon = insertButton.MouseEnter:connect(function() lastEnter = insertButton - delay(0.1, function() + return delay(0.1, function() if lastEnter == insertButton then - showLargePreview(insertButton) + return showLargePreview(insertButton) end end) end) return insertButton, mouseEnterCon end - - local function realignButtonGrid(columns) + local realignButtonGrid + realignButtonGrid = function(columns) local x = 0 local y = 0 for i = 1, #insertButtons do @@ -2974,8 +2570,8 @@ t.CreateSetPanel = function( end end end - - local function setInsertButtonImageBehavior(insertFrame, visible, name, assetId) + local setInsertButtonImageBehavior + setInsertButtonImageBehavior = function(insertFrame, visible, name, assetId) if visible then insertFrame.AssetName.Value = name insertFrame.AssetId.Value = assetId @@ -2986,40 +2582,31 @@ t.CreateSetPanel = function( insertFrame.Button.ButtonImage.Image = SmallThumbnailUrl .. assetId end) end - table.insert( - insertButtonCons, - insertFrame.Button.MouseButton1Click:connect(function() - -- special case for water, show water selection gui - local isWaterSelected = (name == "Water") - and (Data.Category[Data.CurrentCategory].SetName == "High Scalability") - waterGui.Visible = isWaterSelected - if isWaterSelected then - objectSelected(name, tonumber(assetId), nil) - else - objectSelected(name, tonumber(assetId)) - end - end) - ) + table.insert(insertButtonCons, insertFrame.Button.MouseButton1Click:connect(function() + local isWaterSelected = (name == "Water") and (Data.Category[Data.CurrentCategory].SetName == "High Scalability") + waterGui.Visible = isWaterSelected + if isWaterSelected then + return objectSelected(name, tonumber(assetId, nil)) + else + return objectSelected(name, tonumber(assetId)) + end + end)) insertFrame.Visible = true else insertFrame.Visible = false end end - - local function loadSectionOfItems(setGui, rows, columns) + local loadSectionOfItems + loadSectionOfItems = function(setGui, rows, columns) local pageSize = rows * columns - if arrayPosition > #contents then return end - local origArrayPos = arrayPosition - for _ = 1, pageSize + 1 do if arrayPosition >= #contents + 1 then break end - local buttonCon insertButtons[arrayPosition], buttonCon = buildInsertButton() table.insert(insertButtonCons, buttonCon) @@ -3027,18 +2614,14 @@ t.CreateSetPanel = function( arrayPosition = arrayPosition + 1 end realignButtonGrid(columns) - - -- local indexCopy = origArrayPos for index = origArrayPos, arrayPosition do if insertButtons[index] then if contents[index] then - -- we don't want water to have a drop down button if contents[index].Name == "Water" then if Data.Category[Data.CurrentCategory].SetName == "High Scalability" then insertButtons[index]:FindFirstChild("DropDownButton", true):Destroy() end end - local assetId if useAssetVersionId then assetId = contents[index].AssetVersionId @@ -3052,19 +2635,15 @@ t.CreateSetPanel = function( else break end - -- indexCopy = index end end - - local function setSetIndex() + local setSetIndex + setSetIndex = function() Data.Category[Data.CurrentCategory].Index = 0 - local rows = 7 local columns = math.floor(setGui.SetPanel.ItemsFrame.AbsoluteSize.X / buttonWidth) - contents = Data.Category[Data.CurrentCategory].Contents if contents then - -- remove our buttons and their connections for i = 1, #insertButtons do insertButtons[i]:remove() end @@ -3073,65 +2652,56 @@ t.CreateSetPanel = function( insertButtonCons[i]:disconnect() end end - insertButtonCons = {} - insertButtons = {} - + insertButtonCons = { } + insertButtons = { } arrayPosition = 1 - loadSectionOfItems(setGui, rows, columns) + return loadSectionOfItems(setGui, rows, columns) end end - - local function selectSet(button, setName, setId, _) + local selectSet + selectSet = function(button, setName, setId, _) if button and Data.Category[Data.CurrentCategory] ~= nil then if button ~= Data.Category[Data.CurrentCategory].Button then Data.Category[Data.CurrentCategory].Button = button - if SetCache[setId] == nil then SetCache[setId] = game:GetService("InsertService"):GetCollection(setId) end Data.Category[Data.CurrentCategory].Contents = SetCache[setId] - Data.Category[Data.CurrentCategory].SetName = setName Data.Category[Data.CurrentCategory].SetId = setId end - setSetIndex() + return setSetIndex() end end - - local function selectCategoryPage(buttons, _) + local selectCategoryPage + selectCategoryPage = function(buttons, _) if buttons ~= Data.CurrentCategory then if Data.CurrentCategory then for _, button in pairs(Data.CurrentCategory) do button.Visible = false end end - Data.CurrentCategory = buttons if Data.Category[Data.CurrentCategory] == nil then - Data.Category[Data.CurrentCategory] = {} + Data.Category[Data.CurrentCategory] = { } if #buttons > 0 then - selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0) + return selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0) end else Data.Category[Data.CurrentCategory].Button = nil - selectSet( - Data.Category[Data.CurrentCategory].ButtonFrame, - Data.Category[Data.CurrentCategory].SetName, - Data.Category[Data.CurrentCategory].SetId, - Data.Category[Data.CurrentCategory].Index - ) + return selectSet(Data.Category[Data.CurrentCategory].ButtonFrame, Data.Category[Data.CurrentCategory].SetName, Data.Category[Data.CurrentCategory].SetId, Data.Category[Data.CurrentCategory].Index) end end end - - local function selectCategory(category) - selectCategoryPage(category, 0) + local selectCategory + selectCategory = function(category) + return selectCategoryPage(category, 0) end - - local function resetAllSetButtonSelection() + local resetAllSetButtonSelection + resetAllSetButtonSelection = function() local setButtons = setGui.SetPanel.Sets.SetsLists:GetChildren() for i = 1, #setButtons do - if setButtons[i]:IsA "TextButton" then + if setButtons[i]:IsA("TextButton") then setButtons[i].Selected = false setButtons[i].BackgroundTransparency = 1 setButtons[i].TextColor3 = Color3.new(1, 1, 1) @@ -3139,22 +2709,20 @@ t.CreateSetPanel = function( end end end - - local function populateSetsFrame() + local populateSetsFrame + populateSetsFrame = function() local currRow = 0 for i = 1, #userCategoryButtons do local button = userCategoryButtons[i] button.Visible = true button.Position = UDim2.new(0, 5, 0, currRow * button.Size.Y.Offset) button.Parent = setGui.SetPanel.Sets.SetsLists - - if i == 1 then -- we will have this selected by default, so show it + if i == 1 then button.Selected = true button.BackgroundColor3 = Color3.new(0, 204 / 255, 0) button.TextColor3 = Color3.new(0, 0, 0) button.BackgroundTransparency = 0 end - button.MouseEnter:connect(function() if not button.Selected then button.BackgroundTransparency = 0 @@ -3173,18 +2741,14 @@ t.CreateSetPanel = function( button.BackgroundColor3 = Color3.new(0, 204 / 255, 0) button.TextColor3 = Color3.new(0, 0, 0) button.BackgroundTransparency = 0 - selectSet(button, button.Text, userCategoryButtons[i].SetId.Value, 0) + return selectSet(button, button.Text, userCategoryButtons[i].SetId.Value, 0) end) - currRow = currRow + 1 end - local buttons = setGui.SetPanel.Sets.SetsLists:GetChildren() - - -- set first category as loaded for default if buttons then for i = 1, #buttons do - if buttons[i]:IsA "TextButton" then + if buttons[i]:IsA("TextButton") then selectSet(buttons[i], buttons[i].Text, userCategoryButtons[i].SetId.Value, 0) selectCategory(userCategoryButtons) break @@ -3192,18 +2756,16 @@ t.CreateSetPanel = function( end end end - setGui = createSetGui() waterGui, waterTypeChangedEvent = createWaterGui() waterGui.Position = UDim2.new(0, 55, 0, 0) waterGui.Parent = setGui - setGui.Changed:connect(function(prop) -- this resizes the preview image to always be the right size + setGui.Changed:connect(function(prop) if prop == "AbsoluteSize" then handleResize() - setSetIndex() + return setSetIndex() end end) - local scrollFrame, controlFrame = t.CreateTrueScrollingFrame() scrollFrame.Size = UDim2.new(0.54, 0, 0.85, 0) scrollFrame.Position = UDim2.new(0.24, 0, 0.085, 0) @@ -3211,12 +2773,9 @@ t.CreateSetPanel = function( scrollFrame.ZIndex = 6 scrollFrame.Parent = setGui.SetPanel scrollFrame.BackgroundTransparency = 1 - drillDownSetZIndex(controlFrame, 7) - controlFrame.Parent = setGui.SetPanel controlFrame.Position = UDim2.new(0.76, 5, 0, 0) - local debounce = false controlFrame.ScrollBottom.Changed:connect(function(_) if controlFrame.ScrollBottom.Value == true then @@ -3228,14 +2787,12 @@ t.CreateSetPanel = function( debounce = false end end) - - local userData = {} + local userData = { } for id = 1, #userIdsForSets do local newUserData = game:GetService("InsertService"):GetUserSets(userIdsForSets[id]) if newUserData and #newUserData > 2 then - -- start at #3 to skip over My Decals and My Models for each account for category = 3, #newUserData do - if newUserData[category].Name == "High Scalability" then -- we want high scalability parts to show first + if newUserData[category].Name == "High Scalability" then table.insert(userData, 1, newUserData[category]) else table.insert(userData, newUserData[category]) @@ -3246,48 +2803,39 @@ t.CreateSetPanel = function( if userData then userCategoryButtons = processCategory(userData) end - rows = math.floor(setGui.SetPanel.ItemsFrame.AbsoluteSize.Y / buttonHeight) columns = math.floor(setGui.SetPanel.ItemsFrame.AbsoluteSize.X / buttonWidth) - populateSetsFrame() - - --[[local insertPanelCloseCon = ]] setGui.SetPanel.CancelButton.MouseButton1Click:connect(function() setGui.SetPanel.Visible = false if dialogClosed then - dialogClosed() + return dialogClosed() end end) - - local setVisibilityFunction = function(visible) + local setVisibilityFunction + setVisibilityFunction = function(visible) if visible then setGui.SetPanel.Visible = true else setGui.SetPanel.Visible = false end end - - local getVisibilityFunction = function() + local getVisibilityFunction + getVisibilityFunction = function() if setGui then - if setGui:FindFirstChild "SetPanel" then + if setGui:FindFirstChild("SetPanel") then return setGui.SetPanel.Visible end end - return false end - return setGui, setVisibilityFunction, getVisibilityFunction, waterTypeChangedEvent end - t.CreateTerrainMaterialSelector = function(size, position) - local terrainMaterialSelectionChanged = Instance.new "BindableEvent" + local terrainMaterialSelectionChanged = Instance.new("BindableEvent") terrainMaterialSelectionChanged.Name = "TerrainMaterialSelectionChanged" - - local selectedButton = nil - - local frame = Instance.new "Frame" + local selectedButton + local frame = Instance.new("Frame") frame.Name = "TerrainMaterialSelector" if size then frame.Size = size @@ -3300,12 +2848,9 @@ t.CreateTerrainMaterialSelector = function(size, position) frame.BorderSizePixel = 0 frame.BackgroundColor3 = Color3.new(0, 0, 0) frame.Active = true - terrainMaterialSelectionChanged.Parent = frame - - local waterEnabled = true -- todo: turn this on when water is ready - - local materialToImageMap = {} + local waterEnabled = true + local materialToImageMap = { } local materialNames = { "Grass", "Sand", @@ -3322,14 +2867,14 @@ t.CreateTerrainMaterialSelector = function(size, position) "Stone Wall", "Concrete", "Plastic (red)", - "Plastic (blue)", + "Plastic (blue)" } if waterEnabled then table.insert(materialNames, "Water") end local currentMaterial = 1 - - function getEnumFromName(choice) + local getEnumFromName + getEnumFromName = function(choice) if choice == "Grass" then return 1 end @@ -3385,8 +2930,8 @@ t.CreateTerrainMaterialSelector = function(size, position) return 17 end end - - function getNameFromEnum(choice) + local getNameFromEnum + getNameFromEnum = function(choice) if choice == Enum.CellMaterial.Grass or choice == 1 then return "Grass" elseif choice == Enum.CellMaterial.Sand or choice == 2 then @@ -3422,22 +2967,19 @@ t.CreateTerrainMaterialSelector = function(size, position) elseif choice == Enum.CellMaterial.BluePlastic or choice == 16 then return "Plastic (blue)" end - if waterEnabled then if choice == Enum.CellMaterial.Water or choice == 17 then return "Water" end end end - - local function updateMaterialChoice(choice) + local updateMaterialChoice + updateMaterialChoice = function(choice) currentMaterial = getEnumFromName(choice) - terrainMaterialSelectionChanged:Fire(currentMaterial) + return terrainMaterialSelectionChanged:Fire(currentMaterial) end - - -- we so need a better way to do this for _, v in pairs(materialNames) do - materialToImageMap[v] = {} + materialToImageMap[v] = { } if v == "Grass" then materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=56563112" elseif v == "Sand" then @@ -3473,32 +3015,29 @@ t.CreateTerrainMaterialSelector = function(size, position) elseif v == "Water" then materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=81407474" else - materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=66887593" -- fill in the rest here!! + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=66887593" end end - local scrollFrame, scrollUp, scrollDown, recalculateScroll = t.CreateScrollingFrame(nil, "grid") scrollFrame.Size = UDim2.new(0.85, 0, 1, 0) scrollFrame.Position = UDim2.new(0, 0, 0, 0) scrollFrame.Parent = frame - scrollUp.Parent = frame scrollUp.Visible = true scrollUp.Position = UDim2.new(1, -19, 0, 0) - scrollDown.Parent = frame scrollDown.Visible = true scrollDown.Position = UDim2.new(1, -19, 1, -17) - - local function goToNewMaterial(buttonWrap, materialName) + local goToNewMaterial + goToNewMaterial = function(buttonWrap, materialName) updateMaterialChoice(materialName) buttonWrap.BackgroundTransparency = 0 selectedButton.BackgroundTransparency = 1 selectedButton = buttonWrap end - - local function createMaterialButton(name) - local buttonWrap = Instance.new "TextButton" + local createMaterialButton + createMaterialButton = function(name) + local buttonWrap = Instance.new("TextButton") buttonWrap.Text = "" buttonWrap.Size = UDim2.new(0, 32, 0, 32) buttonWrap.BackgroundColor3 = Color3.new(1, 1, 1) @@ -3506,8 +3045,7 @@ t.CreateTerrainMaterialSelector = function(size, position) buttonWrap.BackgroundTransparency = 1 buttonWrap.AutoButtonColor = false buttonWrap.Name = tostring(name) - - local imageButton = Instance.new "ImageButton" + local imageButton = Instance.new("ImageButton") imageButton.AutoButtonColor = false imageButton.BackgroundTransparency = 1 imageButton.Size = UDim2.new(0, 30, 0, 30) @@ -3515,12 +3053,10 @@ t.CreateTerrainMaterialSelector = function(size, position) imageButton.Name = tostring(name) imageButton.Parent = buttonWrap imageButton.Image = materialToImageMap[name].Regular - - local enumType = Instance.new "NumberValue" + local enumType = Instance.new("NumberValue") enumType.Name = "EnumType" enumType.Parent = buttonWrap enumType.Value = 0 - imageButton.MouseEnter:connect(function() buttonWrap.BackgroundTransparency = 0 end) @@ -3531,32 +3067,27 @@ t.CreateTerrainMaterialSelector = function(size, position) end) imageButton.MouseButton1Click:connect(function() if selectedButton ~= buttonWrap then - goToNewMaterial(buttonWrap, tostring(name)) + return goToNewMaterial(buttonWrap, tostring(name)) end end) - return buttonWrap end - for i = 1, #materialNames do local imageButton = createMaterialButton(materialNames[i]) - - if materialNames[i] == "Grass" then -- always start with grass as the default + if materialNames[i] == "Grass" then selectedButton = imageButton imageButton.BackgroundTransparency = 0 end - imageButton.Parent = scrollFrame end - - local forceTerrainMaterialSelection = function(newMaterialType) + local forceTerrainMaterialSelection + forceTerrainMaterialSelection = function(newMaterialType) if not newMaterialType then return end if currentMaterial == newMaterialType then return end - local matName = getNameFromEnum(newMaterialType) local buttons = scrollFrame:GetChildren() for i = 1, #buttons do @@ -3574,24 +3105,19 @@ t.CreateTerrainMaterialSelector = function(size, position) end end end - frame.Changed:connect(function(prop) if prop == "AbsoluteSize" then - recalculateScroll() + return recalculateScroll() end end) - recalculateScroll() return frame, terrainMaterialSelectionChanged, forceTerrainMaterialSelection end - t.CreateLoadingFrame = function(name, size, position) - game:GetService("ContentProvider"):Preload "http://www.roblox.com/asset/?id=35238053" - - local loadingFrame = Instance.new "Frame" + game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=35238053") + local loadingFrame = Instance.new("Frame") loadingFrame.Name = "LoadingFrame" loadingFrame.Style = Enum.FrameStyle.RobloxRound - if size then loadingFrame.Size = size else @@ -3602,24 +3128,21 @@ t.CreateLoadingFrame = function(name, size, position) else loadingFrame.Position = UDim2.new(0.5, -150, 0.5, -80) end - - local loadingBar = Instance.new "Frame" + local loadingBar = Instance.new("Frame") loadingBar.Name = "LoadingBar" loadingBar.BackgroundColor3 = Color3.new(0, 0, 0) loadingBar.BorderColor3 = Color3.new(79 / 255, 79 / 255, 79 / 255) loadingBar.Position = UDim2.new(0, 0, 0, 41) loadingBar.Size = UDim2.new(1, 0, 0, 30) loadingBar.Parent = loadingFrame - - local loadingGreenBar = Instance.new "ImageLabel" + local loadingGreenBar = Instance.new("ImageLabel") loadingGreenBar.Name = "LoadingGreenBar" loadingGreenBar.Image = "http://www.roblox.com/asset/?id=35238053" loadingGreenBar.Position = UDim2.new(0, 0, 0, 0) loadingGreenBar.Size = UDim2.new(0, 0, 1, 0) loadingGreenBar.Visible = false loadingGreenBar.Parent = loadingBar - - local loadingPercent = Instance.new "TextLabel" + local loadingPercent = Instance.new("TextLabel") loadingPercent.Name = "LoadingPercent" loadingPercent.BackgroundTransparency = 1 loadingPercent.Position = UDim2.new(0, 0, 1, 0) @@ -3629,8 +3152,7 @@ t.CreateLoadingFrame = function(name, size, position) loadingPercent.FontSize = Enum.FontSize.Size14 loadingPercent.TextColor3 = Color3.new(1, 1, 1) loadingPercent.Parent = loadingBar - - local cancelButton = Instance.new "TextButton" + local cancelButton = Instance.new("TextButton") cancelButton.Name = "CancelButton" cancelButton.Position = UDim2.new(0.5, -60, 1, -40) cancelButton.Size = UDim2.new(0, 120, 0, 40) @@ -3640,8 +3162,7 @@ t.CreateLoadingFrame = function(name, size, position) cancelButton.Text = "Cancel" cancelButton.Style = Enum.ButtonStyle.RobloxButton cancelButton.Parent = loadingFrame - - local loadingName = Instance.new "TextLabel" + local loadingName = Instance.new("TextLabel") loadingName.Name = "loadingName" loadingName.BackgroundTransparency = 1 loadingName.Size = UDim2.new(1, 0, 0, 18) @@ -3652,20 +3173,18 @@ t.CreateLoadingFrame = function(name, size, position) loadingName.TextStrokeTransparency = 1 loadingName.FontSize = Enum.FontSize.Size18 loadingName.Parent = loadingFrame - - local cancelButtonClicked = Instance.new "BindableEvent" + local cancelButtonClicked = Instance.new("BindableEvent") cancelButtonClicked.Name = "CancelButtonClicked" cancelButtonClicked.Parent = cancelButton cancelButton.MouseButton1Click:connect(function() - cancelButtonClicked:Fire() + return cancelButtonClicked:Fire() end) - - local updateLoadingGuiPercent = function(percent, tweenAction, tweenLength) - if percent and type(percent) ~= "number" then - error("updateLoadingGuiPercent expects number as argument, got", type(percent), "instead") + local updateLoadingGuiPercent + updateLoadingGuiPercent = function(percent, tweenAction, tweenLength) + if percent and type(percent ~= "number") then + error("updateLoadingGuiPercent expects number as argument, got " .. tostring(type(percent)) .. " instead") end - - local newSize = nil + local newSize if percent < 0 then newSize = UDim2.new(0, 0, 1, 0) elseif percent > 1 then @@ -3673,47 +3192,36 @@ t.CreateLoadingFrame = function(name, size, position) else newSize = UDim2.new(percent, 0, 1, 0) end - if tweenAction then if not tweenLength then - error "updateLoadingGuiPercent is set to tween new percentage, but got no tween time length! Please pass this in as third argument" + error("updateLoadingGuiPercent is set to tween new percentage, but got no tween time length! Please pass this in as third argument") end - if newSize.X.Scale > 0 then loadingGreenBar.Visible = true - loadingGreenBar:TweenSize(newSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenLength, true) + return loadingGreenBar:TweenSize(newSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenLength, true) else - loadingGreenBar:TweenSize( - newSize, - Enum.EasingDirection.Out, - Enum.EasingStyle.Quad, - tweenLength, - true, - function() - if newSize.X.Scale < 0 then - loadingGreenBar.Visible = false - end + return loadingGreenBar:TweenSize(newSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenLength, true, function() + if newSize.X.Scale < 0 then + loadingGreenBar.Visible = false end - ) + end) end else loadingGreenBar.Size = newSize loadingGreenBar.Visible = (newSize.X.Scale > 0) end end - loadingGreenBar.Changed:connect(function(prop) if prop == "Size" then loadingPercent.Text = tostring(math.ceil(loadingGreenBar.Size.X.Scale * 100)) .. "%" end end) - return loadingFrame, updateLoadingGuiPercent, cancelButtonClicked end - t.CreatePluginFrame = function(name, size, position, scrollable, parent) - function createMenuButton(size, position, text, fontsize, name, parent) - local button = Instance.new "TextButton" + local createMenuButton + createMenuButton = function(size, position, text, fontsize, name, parent) + local button = Instance.new("TextButton") button.AutoButtonColor = false button.Name = name button.BackgroundTransparency = 1 @@ -3725,7 +3233,6 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) button.TextColor3 = Color3.new(1, 1, 1) button.BorderSizePixel = 0 button.BackgroundColor3 = Color3.new(20 / 255, 20 / 255, 20 / 255) - button.MouseEnter:connect(function() if button.Selected then return @@ -3738,13 +3245,10 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) end button.BackgroundTransparency = 1 end) - button.Parent = parent - return button end - - local dragBar = Instance.new "Frame" + local dragBar = Instance.new("Frame") dragBar.Name = tostring(name) .. "DragBar" dragBar.BackgroundColor3 = Color3.new(39 / 255, 39 / 255, 39 / 255) dragBar.BorderColor3 = Color3.new(0, 0, 0) @@ -3758,7 +3262,6 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) end dragBar.Active = true dragBar.Draggable = true - --dragBar.Visible = false dragBar.MouseEnter:connect(function() dragBar.BackgroundColor3 = Color3.new(49 / 255, 49 / 255, 49 / 255) end) @@ -3766,9 +3269,7 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) dragBar.BackgroundColor3 = Color3.new(39 / 255, 39 / 255, 39 / 255) end) dragBar.Parent = parent - - -- plugin name label - local pluginNameLabel = Instance.new "TextLabel" + local pluginNameLabel = Instance.new("TextLabel") pluginNameLabel.Name = "BarNameLabel" pluginNameLabel.Text = " " .. tostring(name) pluginNameLabel.TextColor3 = Color3.new(1, 1, 1) @@ -3779,34 +3280,16 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) pluginNameLabel.TextXAlignment = Enum.TextXAlignment.Left pluginNameLabel.BackgroundTransparency = 1 pluginNameLabel.Parent = dragBar - - -- close button - local closeButton = createMenuButton( - UDim2.new(0, 15, 0, 17), - UDim2.new(1, -16, 0.5, -8), - "X", - Enum.FontSize.Size14, - "CloseButton", - dragBar - ) - local closeEvent = Instance.new "BindableEvent" + local closeButton = createMenuButton(UDim2.new(0, 15, 0, 17), UDim2.new(1, -16, 0.5, -8), "X", Enum.FontSize.Size14, "CloseButton", dragBar) + local closeEvent = Instance.new("BindableEvent") closeEvent.Name = "CloseEvent" closeEvent.Parent = closeButton closeButton.MouseButton1Click:connect(function() closeEvent:Fire() closeButton.BackgroundTransparency = 1 end) - - -- help button - local helpButton = createMenuButton( - UDim2.new(0, 15, 0, 17), - UDim2.new(1, -51, 0.5, -8), - "?", - Enum.FontSize.Size14, - "HelpButton", - dragBar - ) - local helpFrame = Instance.new "Frame" + local helpButton = createMenuButton(UDim2.new(0, 15, 0, 17), UDim2.new(1, -51, 0.5, -8), "?", Enum.FontSize.Size14, "HelpButton", dragBar) + local helpFrame = Instance.new("Frame") helpFrame.Name = "HelpFrame" helpFrame.BackgroundColor3 = Color3.new(0, 0, 0) helpFrame.Size = UDim2.new(0, 300, 0, 552) @@ -3815,7 +3298,6 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) helpFrame.BorderSizePixel = 0 helpFrame.Visible = false helpFrame.Parent = dragBar - helpButton.MouseButton1Click:connect(function() helpFrame.Visible = not helpFrame.Visible if helpFrame.Visible then @@ -3823,9 +3305,9 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) helpButton.BackgroundTransparency = 0 local screenGui = getScreenGuiAncestor(helpFrame) if screenGui then - if helpFrame.AbsolutePosition.X + helpFrame.AbsoluteSize.X > screenGui.AbsoluteSize.X then --position on left hand side + if helpFrame.AbsolutePosition.X + helpFrame.AbsoluteSize.X > screenGui.AbsoluteSize.X then helpFrame.Position = UDim2.new(0, -5 - helpFrame.AbsoluteSize.X, 0, 0) - else -- position on right hand side + else helpFrame.Position = UDim2.new(1, 5, 0, 0) end else @@ -3836,18 +3318,9 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) helpButton.BackgroundTransparency = 1 end end) - - local minimizeButton = createMenuButton( - UDim2.new(0, 16, 0, 17), - UDim2.new(1, -34, 0.5, -8), - "-", - Enum.FontSize.Size14, - "MinimizeButton", - dragBar - ) + local minimizeButton = createMenuButton(UDim2.new(0, 16, 0, 17), UDim2.new(1, -34, 0.5, -8), "-", Enum.FontSize.Size14, "MinimizeButton", dragBar) minimizeButton.TextYAlignment = Enum.TextYAlignment.Top - - local minimizeFrame = Instance.new "Frame" + local minimizeFrame = Instance.new("Frame") minimizeFrame.Name = "MinimizeFrame" minimizeFrame.BackgroundColor3 = Color3.new(73 / 255, 73 / 255, 73 / 255) minimizeFrame.BorderColor3 = Color3.new(0, 0, 0) @@ -3859,8 +3332,7 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) end minimizeFrame.Visible = false minimizeFrame.Parent = dragBar - - local minimizeBigButton = Instance.new "TextButton" + local minimizeBigButton = Instance.new("TextButton") minimizeBigButton.Position = UDim2.new(0.5, -50, 0.5, -20) minimizeBigButton.Name = "MinimizeButton" minimizeBigButton.Size = UDim2.new(0, 100, 0, 40) @@ -3870,20 +3342,17 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) minimizeBigButton.TextColor3 = Color3.new(1, 1, 1) minimizeBigButton.Text = "Show" minimizeBigButton.Parent = minimizeFrame - - local separatingLine = Instance.new "Frame" + local separatingLine = Instance.new("Frame") separatingLine.Name = "SeparatingLine" separatingLine.BackgroundColor3 = Color3.new(115 / 255, 115 / 255, 115 / 255) separatingLine.BorderSizePixel = 0 separatingLine.Position = UDim2.new(1, -18, 0.5, -7) separatingLine.Size = UDim2.new(0, 1, 0, 14) separatingLine.Parent = dragBar - local otherSeparatingLine = separatingLine:clone() otherSeparatingLine.Position = UDim2.new(1, -35, 0.5, -7) otherSeparatingLine.Parent = dragBar - - local widgetContainer = Instance.new "Frame" + local widgetContainer = Instance.new("Frame") widgetContainer.Name = "WidgetContainer" widgetContainer.BackgroundTransparency = 1 widgetContainer.Position = UDim2.new(0, 0, 1, 0) @@ -3893,7 +3362,6 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) widgetContainer.BackgroundColor3 = Color3.new(72 / 255, 72 / 255, 72 / 255) end widgetContainer.Parent = dragBar - if size then if scrollable then widgetContainer.Size = size @@ -3908,12 +3376,10 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) end end if position then - widgetContainer.Position = position + UDim2.new(0, 0, 0, 20) + widgetContainer.Position = widgetContainer.Position + UDim2.new(0, 0, 0, 20) end - - local frame, control, verticalDragger = nil + local frame, control, verticalDragger if scrollable then - --frame for widgets frame, control = t.CreateTrueScrollingFrame() frame.Size = UDim2.new(1, 0, 1, 0) frame.BackgroundColor3 = Color3.new(72 / 255, 72 / 255, 72 / 255) @@ -3931,16 +3397,14 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) control.Size = UDim2.new(0, 21, 0, 400) end control:FindFirstChild("ScrollDownButton").Position = UDim2.new(0, 0, 1, -20) - - local fakeLine = Instance.new "Frame" + local fakeLine = Instance.new("Frame") fakeLine.Name = "FakeLine" fakeLine.BorderSizePixel = 0 fakeLine.BackgroundColor3 = Color3.new(0, 0, 0) fakeLine.Size = UDim2.new(0, 1, 1, 1) fakeLine.Position = UDim2.new(1, 0, 0, 0) fakeLine.Parent = control - - verticalDragger = Instance.new "TextButton" + verticalDragger = Instance.new("TextButton") verticalDragger.ZIndex = 2 verticalDragger.AutoButtonColor = false verticalDragger.Name = "VerticalDragger" @@ -3951,8 +3415,7 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) verticalDragger.Active = true verticalDragger.Text = "" verticalDragger.Parent = widgetContainer - - local scrubFrame = Instance.new "Frame" + local scrubFrame = Instance.new("Frame") scrubFrame.Name = "ScrubFrame" scrubFrame.BackgroundColor3 = Color3.new(1, 1, 1) scrubFrame.BorderSizePixel = 0 @@ -3966,8 +3429,7 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) local scrubThree = scrubFrame:clone() scrubThree.Position = UDim2.new(0.5, -5, 0.5, 2) scrubThree.Parent = verticalDragger - - local areaSoak = Instance.new "TextButton" + local areaSoak = Instance.new("TextButton") areaSoak.Name = "AreaSoak" areaSoak.Size = UDim2.new(1, 0, 1, 0) areaSoak.BackgroundTransparency = 1 @@ -3977,9 +3439,8 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) areaSoak.Visible = false areaSoak.Active = true areaSoak.Parent = getScreenGuiAncestor(parent) - local draggingVertical = false - local startYPos = nil + local startYPos verticalDragger.MouseEnter:connect(function() verticalDragger.BackgroundColor3 = Color3.new(60 / 255, 60 / 255, 60 / 255) end) @@ -3999,38 +3460,24 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) if not draggingVertical then return end - local yDelta = y - startYPos if not control.ScrollDownButton.Visible and yDelta > 0 then return end - if (widgetContainer.Size.Y.Offset + yDelta) < 150 then - widgetContainer.Size = UDim2.new( - widgetContainer.Size.X.Scale, - widgetContainer.Size.X.Offset, - widgetContainer.Size.Y.Scale, - 150 - ) + widgetContainer.Size = UDim2.new(widgetContainer.Size.X.Scale, widgetContainer.Size.X.Offset, widgetContainer.Size.Y.Scale, 150) control.Size = UDim2.new(0, 21, 0, 150) return end - startYPos = y - if widgetContainer.Size.Y.Offset + yDelta >= 0 then - widgetContainer.Size = UDim2.new( - widgetContainer.Size.X.Scale, - widgetContainer.Size.X.Offset, - widgetContainer.Size.Y.Scale, - widgetContainer.Size.Y.Offset + yDelta - ) + widgetContainer.Size = UDim2.new(widgetContainer.Size.X.Scale, widgetContainer.Size.X.Offset, widgetContainer.Size.Y.Scale, widgetContainer.Size.Y.Offset + yDelta) control.Size = UDim2.new(0, 21, 0, control.Size.Y.Offset + yDelta) end end) end - - local function switchMinimize() + local switchMinimize + switchMinimize = function() minimizeFrame.Visible = not minimizeFrame.Visible if scrollable then frame.Visible = not frame.Visible @@ -4039,86 +3486,47 @@ t.CreatePluginFrame = function(name, size, position, scrollable, parent) else widgetContainer.Visible = not widgetContainer.Visible end - if minimizeFrame.Visible then minimizeButton.Text = "+" else minimizeButton.Text = "-" end end - minimizeBigButton.MouseButton1Click:connect(function() - switchMinimize() + return switchMinimize() end) - minimizeButton.MouseButton1Click:connect(function() - switchMinimize() + return switchMinimize() end) - if scrollable then return dragBar, frame, helpFrame, closeEvent else return dragBar, widgetContainer, helpFrame, closeEvent end end - t.Help = function(funcNameOrFunc) - --input argument can be a string or a function. Should return a description (of arguments and expected side effects) if funcNameOrFunc == "CreatePropertyDropDownMenu" or funcNameOrFunc == t.CreatePropertyDropDownMenu then - return "Function CreatePropertyDropDownMenu. " - .. "Arguments: (instance, propertyName, enumType). " - .. "Side effect: returns a container with a drop-down-box that is linked to the 'property' field of 'instance' which is of type 'enumType'" - end - if funcNameOrFunc == "CreateDropDownMenu" or funcNameOrFunc == t.CreateDropDownMenu then - return "Function CreateDropDownMenu. " - .. "Arguments: (items, onItemSelected). " - .. "Side effect: Returns 2 results, a container to the gui object and a 'updateSelection' function for external updating. The container is a drop-down-box created around a list of items" - end - if funcNameOrFunc == "CreateMessageDialog" or funcNameOrFunc == t.CreateMessageDialog then - return "Function CreateMessageDialog. " - .. "Arguments: (title, message, buttons). " - .. "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button" - end - if funcNameOrFunc == "CreateStyledMessageDialog" or funcNameOrFunc == t.CreateStyledMessageDialog then - return "Function CreateStyledMessageDialog. " - .. "Arguments: (title, message, style, buttons). " - .. "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button, 'style' is a string, either Error, Notify or Confirm" - end - if funcNameOrFunc == "GetFontHeight" or funcNameOrFunc == t.GetFontHeight then - return "Function GetFontHeight. " - .. "Arguments: (font, fontSize). " - .. "Side effect: returns the size in pixels of the given font + fontSize" - end - if funcNameOrFunc == "CreateScrollingFrame" or funcNameOrFunc == t.CreateScrollingFrame then - return "Function CreateScrollingFrame. " - .. "Arguments: (orderList, style) " - .. "Side effect: returns 4 objects, (scrollFrame, scrollUpButton, scrollDownButton, recalculateFunction). 'scrollFrame' can be filled with GuiObjects. It will lay them out and allow scrollUpButton/scrollDownButton to interact with them. Orderlist is optional (and specifies the order to layout the children. Without orderlist, it uses the children order. style is also optional, and allows for a 'grid' styling if style is passed 'grid' as a string. recalculateFunction can be called when a relayout is needed (when orderList changes)" - end - if funcNameOrFunc == "CreateTrueScrollingFrame" or funcNameOrFunc == t.CreateTrueScrollingFrame then - return "Function CreateTrueScrollingFrame. " - .. "Arguments: (nil) " - .. "Side effect: returns 2 objects, (scrollFrame, controlFrame). 'scrollFrame' can be filled with GuiObjects, and they will be clipped if not inside the frame's bounds. controlFrame has children scrollup and scrolldown, as well as a slider. controlFrame can be parented to any guiobject and it will readjust itself to fit." - end - if funcNameOrFunc == "AutoTruncateTextObject" or funcNameOrFunc == t.AutoTruncateTextObject then - return "Function AutoTruncateTextObject. " - .. "Arguments: (textLabel) " - .. "Side effect: returns 2 objects, (textLabel, changeText). The 'textLabel' input is modified to automatically truncate text (with ellipsis), if it gets too small to fit. 'changeText' is a function that can be used to change the text, it takes 1 string as an argument" - end - if funcNameOrFunc == "CreateSlider" or funcNameOrFunc == t.CreateSlider then - return "Function CreateSlider. " - .. "Arguments: (steps, width, position) " - .. "Side effect: returns 2 objects, (sliderGui, sliderPosition). The 'steps' argument specifies how many different positions the slider can hold along the bar. 'width' specifies in pixels how wide the bar should be (modifiable afterwards if desired). 'position' argument should be a UDim2 for slider positioning. 'sliderPosition' is an IntValue whose current .Value specifies the specific step the slider is currently on." - end - if funcNameOrFunc == "CreateLoadingFrame" or funcNameOrFunc == t.CreateLoadingFrame then - return "Function CreateLoadingFrame. " - .. "Arguments: (name, size, position) " - .. "Side effect: Creates a gui that can be manipulated to show progress for a particular action. Name appears above the loading bar, and size and position are udim2 values (both size and position are optional arguments). Returns 3 arguments, the first being the gui created. The second being updateLoadingGuiPercent, which is a bindable function. This function takes one argument (two optionally), which should be a number between 0 and 1, representing the percentage the loading gui should be at. The second argument to this function is a boolean value that if set to true will tween the current percentage value to the new percentage value, therefore our third argument is how long this tween should take. Our third returned argument is a BindableEvent, that when fired means that someone clicked the cancel button on the dialog." - end - if funcNameOrFunc == "CreateTerrainMaterialSelector" or funcNameOrFunc == t.CreateTerrainMaterialSelector then - return "Function CreateTerrainMaterialSelector. " - .. "Arguments: (size, position) " - .. "Side effect: Size and position are UDim2 values that specifies the selector's size and position. Both size and position are optional arguments. This method returns 3 objects (terrainSelectorGui, terrainSelected, forceTerrainSelection). terrainSelectorGui is just the gui object that we generate with this function, parent it as you like. TerrainSelected is a BindableEvent that is fired whenever a new terrain type is selected in the gui. ForceTerrainSelection is a function that takes an argument of Enum.CellMaterial and will force the gui to show that material as currently selected." + return "Function CreatePropertyDropDownMenu. " .. "Arguments: (instance, propertyName, enumType). " .. "Side effect: returns a container with a drop-down-box that is linked to the 'property' field of 'instance' which is of type 'enumType'" + elseif funcNameOrFunc == "CreateDropDownMenu" or funcNameOrFunc == t.CreateDropDownMenu then + return "Function CreateDropDownMenu. " .. "Arguments: (items, onItemSelected). " .. "Side effect: Returns 2 results, a container to the gui object and a 'updateSelection' function for external updating. The container is a drop-down-box created around a list of items" + elseif funcNameOrFunc == "CreateMessageDialog" or funcNameOrFunc == t.CreateMessageDialog then + return "Function CreateMessageDialog. " .. "Arguments: (title, message, buttons). " .. "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button" + elseif funcNameOrFunc == "CreateStyledMessageDialog" or funcNameOrFunc == t.CreateStyledMessageDialog then + return "Function CreateStyledMessageDialog. " .. "Arguments: (title, message, style, buttons). " .. "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button, 'style' is a string, either Error, Notify or Confirm" + elseif funcNameOrFunc == "GetFontHeight" or funcNameOrFunc == t.GetFontHeight then + return "Function GetFontHeight. " .. "Arguments: (font, fontSize). " .. "Side effect: returns the size in pixels of the given font + fontSize" + elseif funcNameOrFunc == "CreateScrollingFrame" or funcNameOrFunc == t.CreateScrollingFrame then + return "Function CreateScrollingFrame. " .. "Arguments: (orderList, style) " .. "Side effect: returns 4 objects, (scrollFrame, scrollUpButton, scrollDownButton, recalculateFunction). 'scrollFrame' can be filled with GuiObjects. It will lay them out and allow scrollUpButton/scrollDownButton to interact with them. Orderlist is optional (and specifies the order to layout the children. Without orderlist, it uses the children order. style is also optional, and allows for a 'grid' styling if style is passed 'grid' as a string. recalculateFunction can be called when a relayout is needed (when orderList changes)" + elseif funcNameOrFunc == "CreateTrueScrollingFrame" or funcNameOrFunc == t.CreateTrueScrollingFrame then + return "Function CreateTrueScrollingFrame. " .. "Arguments: (nil) " .. "Side effect: returns 2 objects, (scrollFrame, controlFrame). 'scrollFrame' can be filled with GuiObjects, and they will be clipped if not inside the frame's bounds. controlFrame has children scrollup and scrolldown, as well as a slider. controlFrame can be parented to any guiobject and it will readjust itself to fit." + elseif funcNameOrFunc == "AutoTruncateTextObject" or funcNameOrFunc == t.AutoTruncateTextObject then + return "Function AutoTruncateTextObject. " .. "Arguments: (textLabel) " .. "Side effect: returns 2 objects, (textLabel, changeText). The 'textLabel' input is modified to automatically truncate text (with ellipsis), if it gets too small to fit. 'changeText' is a function that can be used to change the text, it takes 1 string as an argument" + elseif funcNameOrFunc == "CreateSlider" or funcNameOrFunc == t.CreateSlider then + return "Function CreateSlider. " .. "Arguments: (steps, width, position) " .. "Side effect: returns 2 objects, (sliderGui, sliderPosition). The 'steps' argument specifies how many different positions the slider can hold along the bar. 'width' specifies in pixels how wide the bar should be (modifiable afterwards if desired). 'position' argument should be a UDim2 for slider positioning. 'sliderPosition' is an IntValue whose current .Value specifies the specific step the slider is currently on." + elseif funcNameOrFunc == "CreateLoadingFrame" or funcNameOrFunc == t.CreateLoadingFrame then + return "Function CreateLoadingFrame. " .. "Arguments: (name, size, position) " .. "Side effect: Creates a gui that can be manipulated to show progress for a particular action. Name appears above the loading bar, and size and position are udim2 values (both size and position are optional arguments). Returns 3 arguments, the first being the gui created. The second being updateLoadingGuiPercent, which is a bindable function. This function takes one argument (two optionally), which should be a number between 0 and 1, representing the percentage the loading gui should be at. The second argument to this function is a boolean value that if set to true will tween the current percentage value to the new percentage value, therefore our third argument is how long this tween should take. Our third returned argument is a BindableEvent, that when fired means that someone clicked the cancel button on the dialog." + elseif funcNameOrFunc == "CreateTerrainMaterialSelector" or funcNameOrFunc == t.CreateTerrainMaterialSelector then + return "Function CreateTerrainMaterialSelector. " .. "Arguments: (size, position) " .. "Side effect: Size and position are UDim2 values that specifies the selector's size and position. Both size and position are optional arguments. This method returns 3 objects (terrainSelectorGui, terrainSelected, forceTerrainSelection). terrainSelectorGui is just the gui object that we generate with this function, parent it as you like. TerrainSelected is a BindableEvent that is fired whenever a new terrain type is selected in the gui. ForceTerrainSelection is a function that takes an argument of Enum.CellMaterial and will force the gui to show that material as currently selected." end end - return t diff --git a/yue/45284430.yue b/yue/45284430.yue index b7c68b3..1856888 100644 --- a/yue/45284430.yue +++ b/yue/45284430.yue @@ -3,30 +3,6 @@ $load $FILE t = {} --- Heliodex's basic New function (basically a simplified version of melt) -New = (className, name, props) -> - if not props? -- no name was provided - props = name - name = nil - - obj = Instance.new className - obj.Name = name if name - local parent - - for k, v in pairs props - if type(k) == "string" - if k == "Parent" - parent = v - else - obj[k] = v - - elseif type(k) == "number" and type(v) == "userdata" - v.Parent = obj - - obj.Parent = parent - obj --- - ScopedConnect = (parentInstance, instance, event, signalFunc, syncFunc, removeFunc) -> local eventConnection @@ -36,12 +12,17 @@ ScopedConnect = (parentInstance, instance, event, signalFunc, syncFunc, removeFu --Entering the world, make sure we are connected/synced if not eventConnection eventConnection = instance[event]\connect signalFunc - syncFunc?! + if syncFunc + syncFunc! + + else --Probably leaving the world, so disconnect for now if eventConnection eventConnection\disconnect! - removeFunc?! + if removeFunc + removeFunc! + --Hook it up to ancestryChanged signal connection = parentInstance.AncestryChanged\connect tryConnect @@ -51,32 +32,36 @@ ScopedConnect = (parentInstance, instance, event, signalFunc, syncFunc, removeFu connection + getScreenGuiAncestor = (instance) -> localInstance = instance while localInstance and not localInstance\IsA "ScreenGui" localInstance = localInstance.Parent + localInstance + CreateButtons = (frame, buttons, yPos, ySize) -> buttonNum = 1 buttonObjs = {} for _, obj in ipairs buttons - button = New "TextButton", "Button#{buttonNum}" - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - AutoButtonColor: true - Modal: true - Style: if obj["Style"] - obj.Style - else - Enum.ButtonStyle.RobloxButton - - Text: obj.Text - TextColor3: Color3.new 1, 1, 1 - Parent: frame + button = Instance.new "TextButton" + button.Name = "Button" .. buttonNum + button.Font = Enum.Font.Arial + button.FontSize = Enum.FontSize.Size18 + button.AutoButtonColor = true + button.Modal = true + if obj["Style"] + button.Style = obj.Style + else + button.Style = Enum.ButtonStyle.RobloxButton + button.Text = obj.Text + button.TextColor3 = Color3.new 1, 1, 1 button.MouseButton1Click\connect obj.Function + button.Parent = frame buttonObjs[buttonNum] = button + buttonNum += 1 numButtons = buttonNum - 1 @@ -90,215 +75,226 @@ CreateButtons = (frame, buttons, yPos, ySize) -> frame.Button2.Position = UDim2.new 0.55, 0, yPos.Scale, yPos.Offset frame.Button2.Size = UDim2.new 0.35, 0, ySize.Scale, ySize.Offset - elseif numButtons >= 3 spacing = 0.1 / numButtons buttonSize = 0.9 / numButtons buttonNum = 1 while buttonNum <= numButtons - buttonObjs[buttonNum].Position = UDim2.new( - spacing * buttonNum + buttonSize * (buttonNum - 1), - 0, - yPos.Scale, - yPos.Offset - ) - + buttonObjs[buttonNum].Position = UDim2.new spacing * buttonNum + (buttonNum - 1) * buttonSize, 0, yPos.Scale, yPos.Offset buttonObjs[buttonNum].Size = UDim2.new buttonSize, 0, ySize.Scale, ySize.Offset buttonNum += 1 + setSliderPos = (newAbsPosX, slider, sliderPosition, bar, steps) -> newStep = steps - 1 --otherwise we really get one more step than we want - relativePosX = math.min 1, math.max 0, (newAbsPosX - bar.AbsolutePosition.X) / bar.AbsoluteSize.X + relativePosX = math.min 1, math.max(0, (newAbsPosX - bar.AbsolutePosition.X) / bar.AbsoluteSize.X) wholeNum, remainder = math.modf relativePosX * newStep if remainder > 0.5 wholeNum += 1 relativePosX = wholeNum / newStep - result = math.ceil relativePosX * newStep - if sliderPosition.Value ~= result + 1 --only update if we moved a step + result = math.ceil relativePosX * newStep + if sliderPosition.Value ~= (result + 1) --only update if we moved a step sliderPosition.Value = result + 1 - slider.Position = UDim2.new( - relativePosX, - -slider.AbsoluteSize.X / 2, - slider.Position.Y.Scale, - slider.Position.Y.Offset - ) + slider.Position = UDim2.new relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset + cancelSlide = (areaSoak) -> areaSoak.Visible = false - areaSoakMouseMoveCon?\disconnect! + if areaSoakMouseMoveCon + areaSoakMouseMoveCon\disconnect! + t.CreateStyledMessageDialog = (title, message, style, buttons) -> - frame = New "Frame", "MessageDialog" - Size: UDim2.new 0.5, 0, 0, 165 - Position: UDim2.new 0.25, 0, 0.5, -72.5 - Active: true - Style: Enum.FrameStyle.RobloxRound - - * New "ImageLabel", "StyleImage" - BackgroundTransparency: 1 - Position: UDim2.new 0, 5, 0, 15 - - * New "TextLabel", "Title" - Text: title - TextStrokeTransparency: 0 - BackgroundTransparency: 1 - TextColor3: Color3.new 221 / 255, 221 / 255, 221 / 255 - Position: UDim2.new 0, 80, 0, 0 - Size: UDim2.new 1, -80, 0, 40 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size36 - TextXAlignment: Enum.TextXAlignment.Center - TextYAlignment: Enum.TextYAlignment.Center - - * New "TextLabel", "Message" - Text: message - TextStrokeTransparency: 0 - TextColor3: Color3.new 221 / 255, 221 / 255, 221 / 255 - Position: UDim2.new 0.025, 80, 0, 45 - Size: UDim2.new 0.95, -80, 0, 55 - BackgroundTransparency: 1 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - TextWrap: true - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Top - - :StyleImage = frame + frame = Instance.new "Frame" + frame.Size = UDim2.new 0.5, 0, 0, 165 + frame.Position = UDim2.new 0.25, 0, 0.5, -72.5 + frame.Name = "MessageDialog" + frame.Active = true + frame.Style = Enum.FrameStyle.RobloxRound + styleImage = Instance.new "ImageLabel" + styleImage.Name = "StyleImage" + styleImage.BackgroundTransparency = 1 + styleImage.Position = UDim2.new 0, 5, 0, 15 if style == "error" or style == "Error" - StyleImage.Size = UDim2.new 0, 71, 0, 71 - StyleImage.Image = "http://www.roblox.com/asset?id=42565285" + styleImage.Size = UDim2.new 0, 71, 0, 71 + styleImage.Image = "http://www.roblox.com/asset?id=42565285" elseif style == "notify" or style == "Notify" - StyleImage.Size = UDim2.new 0, 71, 0, 71 - StyleImage.Image = "http://www.roblox.com/asset?id=42604978" + styleImage.Size = UDim2.new 0, 71, 0, 71 + styleImage.Image = "http://www.roblox.com/asset?id=42604978" elseif style == "confirm" or style == "Confirm" - StyleImage.Size = UDim2.new 0, 74, 0, 76 - StyleImage.Image = "http://www.roblox.com/asset?id=42557901" + styleImage.Size = UDim2.new 0, 74, 0, 76 + styleImage.Image = "http://www.roblox.com/asset?id=42557901" else return t.CreateMessageDialog title, message, buttons - CreateButtons frame, buttons, UDim.new(0, 105), UDim.new 0, 40 + styleImage.Parent = frame + + titleLabel = Instance.new "TextLabel" + titleLabel.Name = "Title" + titleLabel.Text = title + titleLabel.TextStrokeTransparency = 0 + titleLabel.BackgroundTransparency = 1 + titleLabel.TextColor3 = Color3.new 221 / 255, 221 / 255, 221 / 255 + titleLabel.Position = UDim2.new 0, 80, 0, 0 + titleLabel.Size = UDim2.new 1, -80, 0, 40 + titleLabel.Font = Enum.Font.ArialBold + titleLabel.FontSize = Enum.FontSize.Size36 + titleLabel.TextXAlignment = Enum.TextXAlignment.Center + titleLabel.TextYAlignment = Enum.TextYAlignment.Center + titleLabel.Parent = frame + + messageLabel = Instance.new "TextLabel" + messageLabel.Name = "Message" + messageLabel.Text = message + messageLabel.TextStrokeTransparency = 0 + messageLabel.TextColor3 = Color3.new 221 / 255, 221 / 255, 221 / 255 + messageLabel.Position = UDim2.new 0.025, 80, 0, 45 + messageLabel.Size = UDim2.new 0.95, -80, 0, 55 + messageLabel.BackgroundTransparency = 1 + messageLabel.Font = Enum.Font.Arial + messageLabel.FontSize = Enum.FontSize.Size18 + messageLabel.TextWrap = true + messageLabel.TextXAlignment = Enum.TextXAlignment.Left + messageLabel.TextYAlignment = Enum.TextYAlignment.Top + messageLabel.Parent = frame + + CreateButtons frame, buttons, UDim.new(0, 105), UDim.new(0, 40) frame + t.CreateMessageDialog = (title, message, buttons) -> - frame = New "Frame", "MessageDialog" - Size: UDim2.new 0.5, 0, 0.5, 0 - Position: UDim2.new 0.25, 0, 0.25, 0 - Active: true - Style: Enum.FrameStyle.RobloxRound - Parent: script.Parent + frame = Instance.new "Frame" + frame.Size = UDim2.new 0.5, 0, 0.5, 0 + frame.Position = UDim2.new 0.25, 0, 0.25, 0 + frame.Name = "MessageDialog" + frame.Active = true + frame.Style = Enum.FrameStyle.RobloxRound - * New "TextLabel", "Title" - Text: title - BackgroundTransparency: 1 - TextColor3: Color3.new 221 / 255, 221 / 255, 221 / 255 - Position: UDim2.new 0, 0, 0, 0 - Size: UDim2.new 1, 0, 0.15, 0 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size36 - TextXAlignment: Enum.TextXAlignment.Center - TextYAlignment: Enum.TextYAlignment.Center + titleLabel = Instance.new "TextLabel" + titleLabel.Name = "Title" + titleLabel.Text = title + titleLabel.BackgroundTransparency = 1 + titleLabel.TextColor3 = Color3.new 221 / 255, 221 / 255, 221 / 255 + titleLabel.Position = UDim2.new 0, 0, 0, 0 + titleLabel.Size = UDim2.new 1, 0, 0.15, 0 + titleLabel.Font = Enum.Font.ArialBold + titleLabel.FontSize = Enum.FontSize.Size36 + titleLabel.TextXAlignment = Enum.TextXAlignment.Center + titleLabel.TextYAlignment = Enum.TextYAlignment.Center + titleLabel.Parent = frame - * New "TextLabel", "Message" - Text: message - TextColor3: Color3.new 221 / 255, 221 / 255, 221 / 255 - Position: UDim2.new 0.025, 0, 0.175, 0 - Size: UDim2.new 0.95, 0, 0.55, 0 - BackgroundTransparency: 1 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - TextWrap: true - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Top + messageLabel = Instance.new "TextLabel" + messageLabel.Name = "Message" + messageLabel.Text = message + messageLabel.TextColor3 = Color3.new 221 / 255, 221 / 255, 221 / 255 + messageLabel.Position = UDim2.new 0.025, 0, 0.175, 0 + messageLabel.Size = UDim2.new 0.95, 0, 0.55, 0 + messageLabel.BackgroundTransparency = 1 + messageLabel.Font = Enum.Font.Arial + messageLabel.FontSize = Enum.FontSize.Size18 + messageLabel.TextWrap = true + messageLabel.TextXAlignment = Enum.TextXAlignment.Left + messageLabel.TextYAlignment = Enum.TextYAlignment.Top + messageLabel.Parent = frame - CreateButtons frame, buttons, UDim.new(0.8, 0), UDim.new 0.15, 0 + CreateButtons frame, buttons, UDim.new(0.8, 0), UDim.new(0.15, 0) frame + t.CreateDropDownMenu = (items, onSelect, forRoblox) -> width = UDim.new 0, 100 height = UDim.new 0, 32 - itemCount = dropDownItemCount = #items + frame = Instance.new "Frame" + frame.Name = "DropDownMenu" + frame.BackgroundTransparency = 1 + frame.Size = UDim2.new width, height + + dropDownMenu = Instance.new "TextButton" + dropDownMenu.Name = "DropDownMenuButton" + dropDownMenu.TextWrap = true + dropDownMenu.TextColor3 = Color3.new 1, 1, 1 + dropDownMenu.Text = "Choose One" + dropDownMenu.Font = Enum.Font.ArialBold + dropDownMenu.FontSize = Enum.FontSize.Size18 + dropDownMenu.TextXAlignment = Enum.TextXAlignment.Left + dropDownMenu.TextYAlignment = Enum.TextYAlignment.Center + dropDownMenu.BackgroundTransparency = 1 + dropDownMenu.AutoButtonColor = true + dropDownMenu.Style = Enum.ButtonStyle.RobloxButton + dropDownMenu.Size = UDim2.new 1, 0, 1, 0 + dropDownMenu.Parent = frame + dropDownMenu.ZIndex = 2 + + dropDownIcon = Instance.new "ImageLabel" + dropDownIcon.Name = "Icon" + dropDownIcon.Active = false + dropDownIcon.Image = "http://www.roblox.com/asset/?id=45732894" + dropDownIcon.BackgroundTransparency = 1 + dropDownIcon.Size = UDim2.new 0, 11, 0, 6 + dropDownIcon.Position = UDim2.new 1, -11, 0.5, -2 + dropDownIcon.Parent = dropDownMenu + dropDownIcon.ZIndex = 2 + + itemCount = #items + dropDownItemCount = #items useScrollButtons = false if dropDownItemCount > 6 useScrollButtons = true dropDownItemCount = 6 - frame = New "Frame", "DropDownMenu" - BackgroundTransparency: 1 - Size: UDim2.new width, height - * New "TextButton", "List" - Text: "" - BackgroundTransparency: 1 - --AutoButtonColor: true - Style: Enum.ButtonStyle.RobloxButton - Visible: false - Active: true --Blocks clicks - Position: UDim2.new 0, 0, 0, 0 - Size: UDim2.new 1, 0, (1 + dropDownItemCount) * 0.8, 0 - ZIndex: 2 + droppedDownMenu = Instance.new "TextButton" + droppedDownMenu.Name = "List" + droppedDownMenu.Text = "" + droppedDownMenu.BackgroundTransparency = 1 + --droppedDownMenu.AutoButtonColor = true + droppedDownMenu.Style = Enum.ButtonStyle.RobloxButton + droppedDownMenu.Visible = false + droppedDownMenu.Active = true --Blocks clicks + droppedDownMenu.Position = UDim2.new 0, 0, 0, 0 + droppedDownMenu.Size = UDim2.new 1, 0, (1 + dropDownItemCount) * 0.8, 0 + droppedDownMenu.Parent = frame + droppedDownMenu.ZIndex = 2 - * New "TextButton", "DropDownMenuButton" - TextWrap: true - TextColor3: Color3.new 1, 1, 1 - Text: "Choose One" - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size18 - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Center - BackgroundTransparency: 1 - AutoButtonColor: true - Style: Enum.ButtonStyle.RobloxButton - Size: UDim2.new 1, 0, 1, 0 - ZIndex: 2 + choiceButton = Instance.new "TextButton" + choiceButton.Name = "ChoiceButton" + choiceButton.BackgroundTransparency = 1 + choiceButton.BorderSizePixel = 0 + choiceButton.Text = "ReplaceMe" + choiceButton.TextColor3 = Color3.new 1, 1, 1 + choiceButton.TextXAlignment = Enum.TextXAlignment.Left + choiceButton.TextYAlignment = Enum.TextYAlignment.Center + choiceButton.BackgroundColor3 = Color3.new 1, 1, 1 + choiceButton.Font = Enum.Font.Arial + choiceButton.FontSize = Enum.FontSize.Size18 + if useScrollButtons + choiceButton.Size = UDim2.new 1, -13, 0.8 / ((dropDownItemCount + 1) * 0.8), 0 + else + choiceButton.Size = UDim2.new 1, 0, 0.8 / ((dropDownItemCount + 1) * 0.8), 0 - * New "ImageLabel", "Icon" - Active: false - Image: "http://www.roblox.com/asset/?id=45732894" - BackgroundTransparency: 1 - Size: UDim2.new 0, 11, 0, 6 - Position: UDim2.new 1, -11, 0.5, -2 - ZIndex: 2 + choiceButton.TextWrap = true + choiceButton.ZIndex = 2 - { -- Destructure - DropDownMenuButton: dropDownMenu - List: droppedDownMenu - } = frame - - choiceButton = New "TextButton", "ChoiceButton" - BackgroundTransparency: 1 - BorderSizePixel: 0 - Text: "ReplaceMe" - TextColor3: Color3.new 1, 1, 1 - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Center - BackgroundColor3: Color3.new 1, 1, 1 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - Size: UDim2.new if useScrollButtons - 1, -13, 0.8 / ((dropDownItemCount + 1) * 0.8), 0 - else - 1, 0, 0.8 / ((dropDownItemCount + 1) * 0.8), 0 - TextWrap: true - ZIndex: 2 - - areaSoak = New "TextButton", "AreaSoak" - Text: "" - BackgroundTransparency: 1 - Active: true - Size: UDim2.new 1, 0, 1, 0 - Visible: false - ZIndex: 3 + areaSoak = Instance.new "TextButton" + areaSoak.Name = "AreaSoak" + areaSoak.Text = "" + areaSoak.BackgroundTransparency = 1 + areaSoak.Active = true + areaSoak.Size = UDim2.new 1, 0, 1, 0 + areaSoak.Visible = false + areaSoak.ZIndex = 3 dropDownSelected = false - local scrollUpButton, scrollDownButton + local scrollUpButton + local scrollDownButton scrollMouseCount = 0 setZIndex = (baseZIndex) -> @@ -327,27 +323,27 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> if scrollDownButton scrollDownButton.Active = scrollBarPosition + dropDownItemCount <= itemCount + children = droppedDownMenu\GetChildren! - return if not children + if not children + return + childNum = 1 - for _, obj in ipairs(children) + for _, obj in ipairs children if obj.Name == "ChoiceButton" if childNum < scrollBarPosition or childNum >= scrollBarPosition + dropDownItemCount obj.Visible = false else - obj.Position = UDim2.new( - 0, - 0, - ((childNum - scrollBarPosition + 1) * 0.8) / ((dropDownItemCount + 1) * 0.8), - 0 - ) + obj.Position = UDim2.new 0, 0, ((childNum - scrollBarPosition + 1) * 0.8) / ((dropDownItemCount + 1) * 0.8), 0 obj.Visible = true + obj.TextColor3 = Color3.new 1, 1, 1 obj.BackgroundTransparency = 1 childNum += 1 + toggleVisibility = -> dropDownSelected = not dropDownSelected @@ -358,9 +354,11 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> setZIndex 4 else setZIndex 2 + if useScrollButtons updateScroll! + droppedDownMenu.MouseButton1Click\connect toggleVisibility updateSelection = (text) -> @@ -379,45 +377,53 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> childNum += 1 + if not text dropDownMenu.Text = "Choose One" scrollBarPosition = 1 else if not foundItem - error("Invalid Selection Update -- " .. text) + error "Invalid Selection Update -- " .. text + if scrollBarPosition + dropDownItemCount > itemCount + 1 scrollBarPosition = itemCount - dropDownItemCount + 1 + dropDownMenu.Text = text + scrollDown = -> if scrollBarPosition + dropDownItemCount <= itemCount scrollBarPosition += 1 updateScroll! return true - false + + return false scrollUp = -> if scrollBarPosition > 1 scrollBarPosition -= 1 updateScroll! return true - false + + return false + if useScrollButtons --Make some scroll buttons - scrollUpButton = New "ImageButton", "ScrollUpButton" - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/scrollbuttonUp.png" - Size: UDim2.new 0, 17, 0, 17 - Position: UDim2.new 1, -11, (1 * 0.8) / ((dropDownItemCount + 1) * 0.8), 0 - Parent: droppedDownMenu + scrollUpButton = Instance.new "ImageButton" + scrollUpButton.Name = "ScrollUpButton" + scrollUpButton.BackgroundTransparency = 1 + scrollUpButton.Image = "rbxasset://textures/ui/scrollbuttonUp.png" + scrollUpButton.Size = UDim2.new 0, 17, 0, 17 + scrollUpButton.Position = UDim2.new 1, -11, (1 * 0.8) / ((dropDownItemCount + 1) * 0.8), 0 + scrollUpButton.MouseButton1Click\connect -> + scrollMouseCount += 1 - incScrollMouseCount = -> scrollMouseCount += 1 + scrollUpButton.MouseLeave\connect -> + scrollMouseCount += 1 - scrollUpButton.MouseButton1Click\connect incScrollMouseCount - scrollUpButton.MouseLeave\connect incScrollMouseCount scrollUpButton.MouseButton1Down\connect -> scrollMouseCount += 1 @@ -425,18 +431,27 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> val = scrollMouseCount wait 0.5 while val == scrollMouseCount - break if scrollUp! == false + if scrollUp! == false + break + wait 0.1 - scrollDownButton = New "ImageButton", "ScrollDownButton" - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/scrollbuttonDown.png" - Size: UDim2.new 0, 17, 0, 17 - Position: UDim2.new 1, -11, 1, -11 - Parent: droppedDownMenu - scrollDownButton.MouseButton1Click\connect incScrollMouseCount - scrollDownButton.MouseLeave\connect incScrollMouseCount + scrollUpButton.Parent = droppedDownMenu + + scrollDownButton = Instance.new "ImageButton" + scrollDownButton.Name = "ScrollDownButton" + scrollDownButton.BackgroundTransparency = 1 + scrollDownButton.Image = "rbxasset://textures/ui/scrollbuttonDown.png" + scrollDownButton.Size = UDim2.new 0, 17, 0, 17 + scrollDownButton.Position = UDim2.new 1, -11, 1, -11 + scrollDownButton.Parent = droppedDownMenu + scrollDownButton.MouseButton1Click\connect -> + scrollMouseCount += 1 + + scrollDownButton.MouseLeave\connect -> + scrollMouseCount += 1 + scrollDownButton.MouseButton1Down\connect -> scrollMouseCount += 1 @@ -444,15 +459,20 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> val = scrollMouseCount wait 0.5 while val == scrollMouseCount - break if scrollDown! == false + if scrollDown! == false + break + wait 0.1 - New "ImageLabel", "ScrollBar" - Image: "rbxasset://textures/ui/scrollbar.png" - BackgroundTransparency: 1 - Size: UDim2.new 0, 18, (dropDownItemCount * 0.8) / ((dropDownItemCount + 1) * 0.8), -17 - 11 - 4 - Position: UDim2.new 1, -11, (1 * 0.8) / ((dropDownItemCount + 1) * 0.8), 17 + 2 - Parent: droppedDownMenu + + scrollbar = Instance.new "ImageLabel" + scrollbar.Name = "ScrollBar" + scrollbar.Image = "rbxasset://textures/ui/scrollbar.png" + scrollbar.BackgroundTransparency = 1 + scrollbar.Size = UDim2.new 0, 18, (dropDownItemCount * 0.8) / ((dropDownItemCount + 1) * 0.8), -17 - 11 - 4 + scrollbar.Position = UDim2.new 1, -11, (1 * 0.8) / ((dropDownItemCount + 1) * 0.8), 17 + 2 + scrollbar.Parent = droppedDownMenu + for _, item in ipairs items -- needed to maintain local scope for items in event listeners below @@ -477,24 +497,27 @@ t.CreateDropDownMenu = (items, onSelect, forRoblox) -> button.TextColor3 = Color3.new 0, 0, 0 button.BackgroundTransparency = 0 + button.MouseLeave\connect -> --Remove Highlight button.TextColor3 = Color3.new 1, 1, 1 button.BackgroundTransparency = 1 + --This does the initial layout of the buttons updateScroll! frame.AncestryChanged\connect (_, parent) -> - if not parent? + if parent == nil areaSoak.Parent = nil else areaSoak.Parent = getScreenGuiAncestor frame + dropDownMenu.MouseButton1Click\connect toggleVisibility areaSoak.MouseButton1Click\connect toggleVisibility + return frame, updateSelection - frame, updateSelection t.CreatePropertyDropDownMenu = (instance, property, enum) -> items = enum\GetEnumItems! @@ -504,87 +527,133 @@ t.CreatePropertyDropDownMenu = (instance, property, enum) -> names[i] = obj.Name nameToItem[obj.Name] = obj + + local frame + local updateSelection frame, updateSelection = t.CreateDropDownMenu names, (text) -> instance[property] = nameToItem[text] - t1 = (prop) -> - if prop == property - updateSelection instance[property].Name - t2 = -> updateSelection instance[property].Name + ScopedConnect(frame, instance, "Changed" + (prop) -> + if prop == property + updateSelection instance[property].Name + -> + updateSelection instance[property].Name + ) - ScopedConnect frame, instance, "Changed", t1, t2 + return frame - frame t.GetFontHeight = (font, fontSize) -> - if not (font? and fontSize?) + if font == nil or fontSize == nil error "Font and FontSize must be non-nil" + if font == Enum.Font.Legacy - return switch fontSize - when Enum.FontSize.Size8 then 12 - when Enum.FontSize.Size9 then 14 - when Enum.FontSize.Size10 then 15 - when Enum.FontSize.Size11 then 17 - when Enum.FontSize.Size12 then 18 - when Enum.FontSize.Size14 then 21 - when Enum.FontSize.Size18 then 27 - when Enum.FontSize.Size24 then 36 - when Enum.FontSize.Size36 then 54 - when Enum.FontSize.Size48 then 72 - else error "Unknown FontSize" + if fontSize == Enum.FontSize.Size8 + return 12 + elseif fontSize == Enum.FontSize.Size9 + return 14 + elseif fontSize == Enum.FontSize.Size10 + return 15 + elseif fontSize == Enum.FontSize.Size11 + return 17 + elseif fontSize == Enum.FontSize.Size12 + return 18 + elseif fontSize == Enum.FontSize.Size14 + return 21 + elseif fontSize == Enum.FontSize.Size18 + return 27 + elseif fontSize == Enum.FontSize.Size24 + return 36 + elseif fontSize == Enum.FontSize.Size36 + return 54 + elseif fontSize == Enum.FontSize.Size48 + return 72 + else + error "Unknown FontSize" elseif font == Enum.Font.Arial or font == Enum.Font.ArialBold - return switch fontSize - when Enum.FontSize.Size8 then 8 - when Enum.FontSize.Size9 then 9 - when Enum.FontSize.Size10 then 10 - when Enum.FontSize.Size11 then 11 - when Enum.FontSize.Size12 then 12 - when Enum.FontSize.Size14 then 14 - when Enum.FontSize.Size18 then 18 - when Enum.FontSize.Size24 then 24 - when Enum.FontSize.Size36 then 36 - when Enum.FontSize.Size48 then 48 - else error "Unknown FontSize" + if fontSize == Enum.FontSize.Size8 + return 8 + elseif fontSize == Enum.FontSize.Size9 + return 9 + elseif fontSize == Enum.FontSize.Size10 + return 10 + elseif fontSize == Enum.FontSize.Size11 + return 11 + elseif fontSize == Enum.FontSize.Size12 + return 12 + elseif fontSize == Enum.FontSize.Size14 + return 14 + elseif fontSize == Enum.FontSize.Size18 + return 18 + elseif fontSize == Enum.FontSize.Size24 + return 24 + elseif fontSize == Enum.FontSize.Size36 + return 36 + elseif fontSize == Enum.FontSize.Size48 + return 48 + else + error "Unknown FontSize" + + else + error "Unknown Font " .. font - else error "Unknown Font #{font}" layoutGuiObjectsHelper = (frame, guiObjects, settingsTable) -> - totalPixels = pixelsRemaining = frame.AbsoluteSize.Y - + totalPixels = frame.AbsoluteSize.Y + pixelsRemaining = frame.AbsoluteSize.Y for _, child in ipairs guiObjects if child\IsA"TextLabel" or child\IsA "TextButton" isLabel = child\IsA "TextLabel" - settingsTableIndex = "Text#{if isLabel then "Label" else "Button"}PositionPadY" - pixelsRemaining -= settingsTable[settingsTableIndex] + if isLabel + pixelsRemaining -= settingsTable["TextLabelPositionPadY"] + else + pixelsRemaining -= settingsTable["TextButtonPositionPadY"] child.Position = UDim2.new child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining child.Size = UDim2.new child.Size.X.Scale, child.Size.X.Offset, 0, pixelsRemaining if child.TextFits and child.TextBounds.Y < pixelsRemaining child.Visible = true - child.Size = UDim2.new( - child.Size.X.Scale, - child.Size.X.Offset, - 0, - child.TextBounds.Y + settingsTable[settingsTableIndex] - ) + if isLabel + child.Size = UDim2.new( + child.Size.X.Scale, + child.Size.X.Offset, + 0, + child.TextBounds.Y + settingsTable["TextLabelSizePadY"] + ) + else + child.Size = UDim2.new( + child.Size.X.Scale, + child.Size.X.Offset, + 0, + child.TextBounds.Y + settingsTable["TextButtonSizePadY"] + ) - until child.TextFits + + while not child.TextFits child.Size = UDim2.new child.Size.X.Scale, child.Size.X.Offset, 0, child.AbsoluteSize.Y + 1 pixelsRemaining -= child.AbsoluteSize.Y - pixelsRemaining -= settingsTable[settingsTableIndex] + + if isLabel + pixelsRemaining -= settingsTable["TextLabelPositionPadY"] + else + pixelsRemaining -= settingsTable["TextButtonPositionPadY"] + else child.Visible = false pixelsRemaining = -1 + else --GuiObject child.Position = UDim2.new child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining pixelsRemaining -= child.AbsoluteSize.Y - child.Visible = pixelsRemaining >= 0 + child.Visible = (pixelsRemaining >= 0) + t.LayoutGuiObjects = (frame, guiObjects, settingsTable) -> if not frame\IsA "GuiObject" @@ -594,9 +663,11 @@ t.LayoutGuiObjects = (frame, guiObjects, settingsTable) -> if not child\IsA "GuiObject" error "All elements that are layed out must be of type GuiObject" + if not settingsTable settingsTable = {} + if not settingsTable["TextLabelSizePadY"] settingsTable["TextLabelSizePadY"] = 0 @@ -609,80 +680,79 @@ t.LayoutGuiObjects = (frame, guiObjects, settingsTable) -> if not settingsTable["TextButtonPositionPadY"] settingsTable["TextButtonPositionPadY"] = 2 + --Wrapper frame takes care of styled objects - wrapperFrame = New "Frame", "WrapperFrame" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 1, 0 - Parent: frame + wrapperFrame = Instance.new "Frame" + wrapperFrame.Name = "WrapperFrame" + wrapperFrame.BackgroundTransparency = 1 + wrapperFrame.Size = UDim2.new 1, 0, 1, 0 + wrapperFrame.Parent = frame for _, child in ipairs guiObjects child.Parent = wrapperFrame + recalculate = -> wait! layoutGuiObjectsHelper wrapperFrame, guiObjects, settingsTable + frame.Changed\connect (prop) -> if prop == "AbsoluteSize" --Wait a heartbeat for it to sync in recalculate nil + frame.AncestryChanged\connect recalculate layoutGuiObjectsHelper wrapperFrame, guiObjects, settingsTable + t.CreateSlider = (steps, width, position) -> - sliderGui = New "Frame", "SliderGui" - Size: UDim2.new 1, 0, 1, 0 - BackgroundTransparency: 1 + sliderGui = Instance.new "Frame" + sliderGui.Size = UDim2.new 1, 0, 1, 0 + sliderGui.BackgroundTransparency = 1 + sliderGui.Name = "SliderGui" - * New "IntValue", "SliderSteps" - Value: steps + sliderSteps = Instance.new "IntValue" + sliderSteps.Name = "SliderSteps" + sliderSteps.Value = steps + sliderSteps.Parent = sliderGui - * New "IntValue", "SliderPosition" - Value: 0 - - * New "TextButton", "Bar" - Text: "" - AutoButtonColor: false - BackgroundColor3: Color3.new 0, 0, 0 - Size: UDim2.new( - 0, - if type(width) == "number" then width else 200, - 0, - 5 - ) - BorderColor3: Color3.new 95 / 255, 95 / 255, 95 / 255 - ZIndex: 2 - - * New "ImageButton", "Slider" - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/Slider.png" - Position: UDim2.new 0, 0, 0.5, -10 - Size: UDim2.new 0, 20, 0, 20 - ZIndex: 3 - - areaSoak = New "TextButton", "AreaSoak" - Text: "" - BackgroundTransparency: 1 - Active: false - Size: UDim2.new 1, 0, 1, 0 - Visible: false - ZIndex: 4 - - { -- Destructure - Bar: - Slider: slider - Bar: bar - SliderPosition: sliderPosition - SliderSteps: sliderSteps - } = sliderGui + areaSoak = Instance.new "TextButton" + areaSoak.Name = "AreaSoak" + areaSoak.Text = "" + areaSoak.BackgroundTransparency = 1 + areaSoak.Active = false + areaSoak.Size = UDim2.new 1, 0, 1, 0 + areaSoak.Visible = false + areaSoak.ZIndex = 4 sliderGui.AncestryChanged\connect (_, parent) -> - areaSoak.Parent = if not parent? - nil + if parent == nil + areaSoak.Parent = nil else - getScreenGuiAncestor sliderGui + areaSoak.Parent = getScreenGuiAncestor sliderGui + + + sliderPosition = Instance.new "IntValue" + sliderPosition.Name = "SliderPosition" + sliderPosition.Value = 0 + sliderPosition.Parent = sliderGui + + bar = Instance.new "TextButton" + bar.Text = "" + bar.AutoButtonColor = false + bar.Name = "Bar" + bar.BackgroundColor3 = Color3.new 0, 0, 0 + if type(width) == "number" + bar.Size = UDim2.new 0, width, 0, 5 + else + bar.Size = UDim2.new 0, 200, 0, 5 + + bar.BorderColor3 = Color3.new 95 / 255, 95 / 255, 95 / 255 + bar.ZIndex = 2 + bar.Parent = sliderGui if position["X"] and position["X"]["Scale"] and @@ -693,27 +763,43 @@ t.CreateSlider = (steps, width, position) -> bar.Position = position + + slider = Instance.new "ImageButton" + slider.Name = "Slider" + slider.BackgroundTransparency = 1 + slider.Image = "rbxasset://textures/ui/Slider.png" + slider.Position = UDim2.new 0, 0, 0.5, -10 + slider.Size = UDim2.new 0, 20, 0, 20 + slider.ZIndex = 3 + slider.Parent = bar + local areaSoakMouseMoveCon areaSoak.MouseLeave\connect -> if areaSoak.Visible cancelSlide areaSoak + areaSoak.MouseButton1Up\connect -> if areaSoak.Visible cancelSlide areaSoak + slider.MouseButton1Down\connect -> areaSoak.Visible = true - areaSoakMouseMoveCon?\disconnect! + if areaSoakMouseMoveCon + areaSoakMouseMoveCon\disconnect! + areaSoakMouseMoveCon = areaSoak.MouseMoved\connect (x, _) -> setSliderPos x, slider, sliderPosition, bar, steps + slider.MouseButton1Up\connect -> cancelSlide areaSoak + sliderPosition.Changed\connect (_) -> - sliderPosition.Value = math.min steps, math.max 1, sliderPosition.Value + sliderPosition.Value = math.min steps, math.max(1, sliderPosition.Value) relativePosX = (sliderPosition.Value - 1) / (steps - 1) slider.Position = UDim2.new relativePosX, -slider.AbsoluteSize.X / 2, slider.Position.Y.Scale, slider.Position.Y.Offset @@ -721,84 +807,63 @@ t.CreateSlider = (steps, width, position) -> bar.MouseButton1Down\connect (x, _) -> setSliderPos x, slider, sliderPosition, bar, steps - sliderGui, sliderPosition, sliderSteps + + return sliderGui, sliderPosition, sliderSteps + t.CreateTrueScrollingFrame = -> - local lowY, highY - local dragCon, upCon + local lowY + local highY + + local dragCon + local upCon internalChange = false - desantsChangeConMap = {} - scrollingFrame = New "Frame", "ScrollingFrame" - Active: true - Size: UDim2.new 1, 0, 1, 0 - ClipsDesants: true + descendantsChangeConMap = {} - * New "Frame", "ControlFrame" - BackgroundTransparency: 1 - Size: UDim2.new 0, 18, 1, 0 - Position: UDim2.new 1, -20, 0, 0 + scrollingFrame = Instance.new "Frame" + scrollingFrame.Name = "ScrollingFrame" + scrollingFrame.Active = true + scrollingFrame.Size = UDim2.new 1, 0, 1, 0 + scrollingFrame.ClipsDescendants = true - * New "BoolValue", "ScrollBottom" - Value: false + controlFrame = Instance.new "Frame" + controlFrame.Name = "ControlFrame" + controlFrame.BackgroundTransparency = 1 + controlFrame.Size = UDim2.new 0, 18, 1, 0 + controlFrame.Position = UDim2.new 1, -20, 0, 0 + controlFrame.Parent = scrollingFrame - * New "BoolValue", "scrollUp" - Value: false + scrollBottom = Instance.new "BoolValue" + scrollBottom.Value = false + scrollBottom.Name = "ScrollBottom" + scrollBottom.Parent = controlFrame - * New "TextButton", "ScrollUpButton" - Text: "" - AutoButtonColor: false - BackgroundColor3: Color3.new 0, 0, 0 - BorderColor3: Color3.new 1, 1, 1 - BackgroundTransparency: 0.5 - Size: UDim2.new 0, 18, 0, 18 - ZIndex: 2 - - * New "Frame", "ScrollTrack" - BackgroundTransparency: 1 - Size: UDim2.new 0, 18, 1, -38 - Position: UDim2.new 0, 0, 0, 19 - - * New "TextButton", "ScrollBar" - BackgroundColor3: Color3.new 0, 0, 0 - BorderColor3: Color3.new 1, 1, 1 - BackgroundTransparency: 0.5 - AutoButtonColor: false - Text: "" - Active: true - ZIndex: 2 - Size: UDim2.new 0, 18, 0.1, 0 - Position: UDim2.new 0, 0, 0, 0 - - * New "Frame", "ScrollNub" - BorderColor3: Color3.new 1, 1, 1 - Size: UDim2.new 0, 10, 0, 0 - Position: UDim2.new 0.5, -5, 0.5, 0 - ZIndex: 2 - BackgroundTransparency: 0.5 - - { -- Destructure - ControlFrame: controlFrame - ControlFrame: - ScrollBottom: scrollBottom - ScrollUp: scrollUp - ScrollUpButton: scrollUpButton - ScrollTrack: scrollTrack - ScrollTrack: - ScrollBar: scrollbar - ScrollBar: - ScrollNub: scrollNub - } = scrollingFrame + scrollUp = Instance.new "BoolValue" + scrollUp.Value = false + scrollUp.Name = "scrollUp" + scrollUp.Parent = controlFrame + scrollUpButton = Instance.new "TextButton" + scrollUpButton.Name = "ScrollUpButton" + scrollUpButton.Text = "" + scrollUpButton.AutoButtonColor = false + scrollUpButton.BackgroundColor3 = Color3.new 0, 0, 0 + scrollUpButton.BorderColor3 = Color3.new 1, 1, 1 + scrollUpButton.BackgroundTransparency = 0.5 + scrollUpButton.Size = UDim2.new 0, 18, 0, 18 + scrollUpButton.ZIndex = 2 + scrollUpButton.Parent = controlFrame for i = 1, 6 - New "Frame", "tri#{i}" - BorderColor3: Color3.new 1, 1, 1 - ZIndex: 3 - BackgroundTransparency: 0.5 - Size: UDim2.new 0, 12 - ((i - 1) * 2), 0, 0 - Position: UDim2.new 0, 3 + (i - 1), 0.5, 2 - (i - 1) - Parent: scrollUpButton + triFrame = Instance.new "Frame" + triFrame.BorderColor3 = Color3.new 1, 1, 1 + triFrame.Name = "tri" .. "#{i}" + triFrame.ZIndex = 3 + triFrame.BackgroundTransparency = 0.5 + triFrame.Size = UDim2.new 0, 12 - ((i - 1) * 2), 0, 0 + triFrame.Position = UDim2.new 0, 3 + (i - 1), 0.5, 2 - (i - 1) + triFrame.Parent = scrollUpButton scrollUpButton.MouseEnter\connect -> scrollUpButton.BackgroundTransparency = 0.1 @@ -806,34 +871,66 @@ t.CreateTrueScrollingFrame = -> for i = 1, #upChildren upChildren[i].BackgroundTransparency = 0.1 + scrollUpButton.MouseLeave\connect -> scrollUpButton.BackgroundTransparency = 0.5 upChildren = scrollUpButton\GetChildren! for i = 1, #upChildren upChildren[i].BackgroundTransparency = 0.5 + scrollDownButton = scrollUpButton\clone! + scrollDownButton.Name = "ScrollDownButton" + scrollDownButton.Position = UDim2.new 0, 0, 1, -18 + downChildren = scrollDownButton\GetChildren! + for i = 1, #downChildren + downChildren[i].Position = UDim2.new 0, 3 + (i - 1), 0.5, -2 + (i - 1) - with scrollDownButton - .Name = "ScrollDownButton" - .Position = UDim2.new 0, 0, 1, -18 - downChildren = \GetChildren! + scrollDownButton.MouseEnter\connect -> + scrollDownButton.BackgroundTransparency = 0.1 + downChildren = scrollDownButton\GetChildren! for i = 1, #downChildren - downChildren[i].Position = UDim2.new 0, 3 + (i - 1), 0.5, -2 + (i - 1) + downChildren[i].BackgroundTransparency = 0.1 - .MouseEnter\connect -> - .BackgroundTransparency = 0.1 - downChildren = \GetChildren! - for i = 1, #downChildren - downChildren[i].BackgroundTransparency = 0.1 - .MouseLeave\connect -> - .BackgroundTransparency = 0.5 - downChildren = \GetChildren! - for i = 1, #downChildren - downChildren[i].BackgroundTransparency = 0.5 + scrollDownButton.MouseLeave\connect -> + scrollDownButton.BackgroundTransparency = 0.5 + downChildren = scrollDownButton\GetChildren! + for i = 1, #downChildren + downChildren[i].BackgroundTransparency = 0.5 - .Parent = controlFrame + + scrollDownButton.Parent = controlFrame + + scrollTrack = Instance.new "Frame" + scrollTrack.Name = "ScrollTrack" + scrollTrack.BackgroundTransparency = 1 + scrollTrack.Size = UDim2.new 0, 18, 1, -38 + scrollTrack.Position = UDim2.new 0, 0, 0, 19 + scrollTrack.Parent = controlFrame + + scrollbar = Instance.new "TextButton" + scrollbar.BackgroundColor3 = Color3.new 0, 0, 0 + scrollbar.BorderColor3 = Color3.new 1, 1, 1 + scrollbar.BackgroundTransparency = 0.5 + scrollbar.AutoButtonColor = false + scrollbar.Text = "" + scrollbar.Active = true + scrollbar.Name = "ScrollBar" + scrollbar.ZIndex = 2 + scrollbar.BackgroundTransparency = 0.5 + scrollbar.Size = UDim2.new 0, 18, 0.1, 0 + scrollbar.Position = UDim2.new 0, 0, 0, 0 + scrollbar.Parent = scrollTrack + + scrollNub = Instance.new "Frame" + scrollNub.Name = "ScrollNub" + scrollNub.BorderColor3 = Color3.new 1, 1, 1 + scrollNub.Size = UDim2.new 0, 10, 0, 0 + scrollNub.Position = UDim2.new 0.5, -5, 0.5, 0 + scrollNub.ZIndex = 2 + scrollNub.BackgroundTransparency = 0.5 + scrollNub.Parent = scrollbar newNub = scrollNub\clone! newNub.Position = UDim2.new 0.5, -5, 0.5, -2 @@ -855,14 +952,15 @@ t.CreateTrueScrollingFrame = -> newNub.BackgroundTransparency = 0.5 lastNub.BackgroundTransparency = 0.5 - mouseDrag = New "ImageButton" - Active: false - Size: UDim2.new 1.5, 0, 1.5, 0 - AutoButtonColor: false - BackgroundTransparency: 1 - Name: "mouseDrag" - Position: UDim2.new -0.25, 0, -0.25, 0 - ZIndex: 10 + + mouseDrag = Instance.new "ImageButton" + mouseDrag.Active = false + mouseDrag.Size = UDim2.new 1.5, 0, 1.5, 0 + mouseDrag.AutoButtonColor = false + mouseDrag.BackgroundTransparency = 1 + mouseDrag.Name = "mouseDrag" + mouseDrag.Position = UDim2.new -0.25, 0, -0.25, 0 + mouseDrag.ZIndex = 10 positionScrollBar = (_, y, offset) -> oldPos = scrollbar.Position @@ -871,6 +969,7 @@ t.CreateTrueScrollingFrame = -> scrollbar.Position = UDim2.new scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 0, 0 return (oldPos ~= scrollbar.Position) + relativeSize = scrollbar.AbsoluteSize.Y / scrollTrack.AbsoluteSize.Y if y > (scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y) @@ -894,11 +993,20 @@ t.CreateTrueScrollingFrame = -> return (oldPos ~= scrollbar.Position) + drillDownSetHighLow = (instance) -> - return if not instance or not instance\IsA "GuiObject" - return if instance == controlFrame - return if instance\IsDesantOf controlFrame - return if not instance.Visible + if not instance or not instance\IsA "GuiObject" + return + + if instance == controlFrame + return + + if instance\IsDescendantOf controlFrame + return + + if not instance.Visible + return + if (lowY and lowY > instance.AbsolutePosition.Y) or not lowY lowY = instance.AbsolutePosition.Y @@ -910,26 +1018,29 @@ t.CreateTrueScrollingFrame = -> for i = 1, #children drillDownSetHighLow children[i] + resetHighLow = -> firstChildren = scrollingFrame\GetChildren! for i = 1, #firstChildren drillDownSetHighLow firstChildren[i] + recalculate = -> internalChange = true percentFrame = 0 if scrollbar.Position.Y.Scale > 0 if scrollbar.Visible - percentFrame = scrollbar.Position.Y.Scale / - ((scrollTrack.AbsoluteSize.Y - scrollbar.AbsoluteSize.Y) / scrollTrack.AbsoluteSize.Y) + percentFrame = scrollbar.Position.Y.Scale / ((scrollTrack.AbsoluteSize.Y - scrollbar.AbsoluteSize.Y) / scrollTrack.AbsoluteSize.Y) else percentFrame = 0 + if percentFrame > 0.99 percentFrame = 1 + hiddenYAmount = (scrollingFrame.AbsoluteSize.Y - (highY - lowY)) * percentFrame guiChildren = scrollingFrame\GetChildren! @@ -939,16 +1050,20 @@ t.CreateTrueScrollingFrame = -> guiChildren[i].Position.X.Scale, guiChildren[i].Position.X.Offset, 0, - math.ceil(guiChildren[i].AbsolutePosition.Y) - math.ceil(lowY) + hiddenYAmount + math.ceil(guiChildren[i].AbsolutePosition.Y) - math.ceil lowY + hiddenYAmount ) + lowY = nil highY = nil resetHighLow! internalChange = false + setSliderSizeAndPosition = -> - return if not highY or not lowY + if not highY or not lowY + return + totalYSpan = math.abs highY - lowY if totalYSpan == 0 @@ -956,11 +1071,16 @@ t.CreateTrueScrollingFrame = -> scrollDownButton.Visible = false scrollUpButton.Visible = false - dragCon?\disconnect! - dragCon = nil + if dragCon + dragCon\disconnect! + dragCon = nil + + if upCon + upCon\disconnect! + upCon = nil + + return - upCon?\disconnect! - upCon = nil percentShown = scrollingFrame.AbsoluteSize.Y / totalYSpan if percentShown >= 1 @@ -975,6 +1095,7 @@ t.CreateTrueScrollingFrame = -> scrollbar.Size = UDim2.new scrollbar.Size.X.Scale, scrollbar.Size.X.Offset, percentShown, 0 + percentPosition = (scrollingFrame.AbsolutePosition.Y - lowY) / totalYSpan scrollbar.Position = UDim2.new( scrollbar.Position.X.Scale, @@ -986,16 +1107,19 @@ t.CreateTrueScrollingFrame = -> if scrollbar.AbsolutePosition.y < scrollTrack.AbsolutePosition.y scrollbar.Position = UDim2.new scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 0, 0 - if scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.Y > - scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y + + if (scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.Y) > (scrollTrack.AbsolutePosition.y + scrollTrack.AbsoluteSize.y) relativeSize = scrollbar.AbsoluteSize.Y / scrollTrack.AbsoluteSize.Y scrollbar.Position = UDim2.new scrollbar.Position.X.Scale, scrollbar.Position.X.Offset, 1 - relativeSize, 0 + buttonScrollAmountPixels = 7 reentrancyGuardScrollUp = false doScrollUp = -> - return if reentrancyGuardScrollUp + if reentrancyGuardScrollUp + return + reentrancyGuardScrollUp = true if positionScrollBar 0, scrollbar.AbsolutePosition.Y - buttonScrollAmountPixels, 0 @@ -1003,10 +1127,12 @@ t.CreateTrueScrollingFrame = -> reentrancyGuardScrollUp = false - reentrancyGuardScrollDown = false + reentrancyGuardScrollDown = false doScrollDown = -> - return if reentrancyGuardScrollDown + if reentrancyGuardScrollDown + return + reentrancyGuardScrollDown = true if positionScrollBar 0, scrollbar.AbsolutePosition.Y + buttonScrollAmountPixels, 0 @@ -1014,6 +1140,7 @@ t.CreateTrueScrollingFrame = -> reentrancyGuardScrollDown = false + scrollUp = (mouseYPos) -> if scrollUpButton.Active scrollStamp = tick! @@ -1031,16 +1158,20 @@ t.CreateTrueScrollingFrame = -> w = 0.1 while scrollStamp == current doScrollUp! - break if mouseYPos and mouseYPos > scrollbar.AbsolutePosition.y - break if not scrollUpButton.Active + if mouseYPos and mouseYPos > scrollbar.AbsolutePosition.y + break - w = if tick! - t > 5 - 0 + if not scrollUpButton.Active + break + + if tick! - t > 5 + w = 0 elseif tick! - t > 2 - 0.06 + w = 0.06 wait w + scrollDown = (mouseYPos) -> if scrollDownButton.Active scrollStamp = tick! @@ -1058,31 +1189,37 @@ t.CreateTrueScrollingFrame = -> w = 0.1 while scrollStamp == current doScrollDown! - break if mouseYPos and mouseYPos < (scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.x) - break if not scrollDownButton.Active + if mouseYPos and mouseYPos < (scrollbar.AbsolutePosition.y + scrollbar.AbsoluteSize.x) + break - w = if tick! - t > 5 - 0 + if not scrollDownButton.Active + break + + if tick! - t > 5 + w = 0 elseif tick! - t > 2 - 0.06 + w = 0.06 wait w - global scrollStamp + scrollbar.MouseButton1Down\connect (_, y) -> if scrollbar.Active scrollStamp = tick! mouseOffset = y - scrollbar.AbsolutePosition.y + if dragCon + dragCon\disconnect! + dragCon = nil - dragCon?\disconnect! - dragCon = nil - - upCon?\disconnect! - upCon = nil + if upCon + upCon\disconnect! + upCon = nil reentrancyGuardMouseScroll = false dragCon = mouseDrag.MouseMoved\connect (x, y) -> - return if reentrancyGuardMouseScroll + if reentrancyGuardMouseScroll + return + reentrancyGuardMouseScroll = true if positionScrollBar x, y, mouseOffset @@ -1096,10 +1233,11 @@ t.CreateTrueScrollingFrame = -> dragCon\disconnect! dragCon = nil upCon\disconnect! - drag = nil + global drag = nil mouseDrag.Parent = getScreenGuiAncestor scrollbar + scrollMouseCount = 0 scrollUpButton.MouseButton1Down\connect -> @@ -1108,8 +1246,10 @@ t.CreateTrueScrollingFrame = -> scrollDownButton.MouseButton1Down\connect -> scrollDown! + scrollTick = -> - scrollStamp = tick! + global scrollStamp = tick! + scrollUpButton.MouseButton1Up\connect scrollTick scrollDownButton.MouseButton1Up\connect scrollTick @@ -1118,8 +1258,9 @@ t.CreateTrueScrollingFrame = -> -- heightCheck = (instance) -> -- if (highY and (instance.AbsolutePosition.Y + instance.AbsoluteSize.Y) > highY) or not highY -- highY = instance.AbsolutePosition.Y + instance.AbsoluteSize.Y - + -- end -- setSliderSizeAndPosition! + -- end highLowRecheck = -> oldLowY = lowY @@ -1131,85 +1272,107 @@ t.CreateTrueScrollingFrame = -> if (lowY ~= oldLowY) or (highY ~= oldHighY) setSliderSizeAndPosition! - desantChanged = (this, prop) -> - return if internalChange - return if not this.Visible + + descendantChanged = (this, prop) -> + if internalChange + return + + if not this.Visible + return + if prop == "Size" or prop == "Position" wait! highLowRecheck! - scrollingFrame.DesantAdded\connect (instance) -> - return if not instance\IsA "GuiObject" + + scrollingFrame.DescendantAdded\connect (instance) -> + if not instance\IsA "GuiObject" + return + if instance.Visible wait! -- wait a heartbeat for sizes to reconfig highLowRecheck! - desantsChangeConMap[instance] = instance.Changed\connect (prop) -> - desantChanged instance, prop - scrollingFrame.DesantRemoving\connect (instance) -> - return if not instance\IsA "GuiObject" + descendantsChangeConMap[instance] = instance.Changed\connect (prop) -> + descendantChanged instance, prop - if desantsChangeConMap[instance] - desantsChangeConMap[instance]\disconnect! - desantsChangeConMap[instance] = nil + + scrollingFrame.DescendantRemoving\connect (instance) -> + if not instance\IsA "GuiObject" + return + + if descendantsChangeConMap[instance] + descendantsChangeConMap[instance]\disconnect! + descendantsChangeConMap[instance] = nil wait! -- wait a heartbeat for sizes to reconfig highLowRecheck! + scrollingFrame.Changed\connect (prop) -> if prop == "AbsoluteSize" - return if not highY or not lowY + if not highY or not lowY + return + highLowRecheck! setSliderSizeAndPosition! - scrollingFrame, controlFrame + + return scrollingFrame, controlFrame + t.CreateScrollingFrame = (orderList, scrollStyle) -> - frame = New "Frame", "ScrollingFrame" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 1, 0 + frame = Instance.new "Frame" + frame.Name = "ScrollingFrame" + frame.BackgroundTransparency = 1 + frame.Size = UDim2.new 1, 0, 1, 0 - scrollUpButton = New "ImageButton", "ScrollUpButton" - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/scrollbuttonUp.png" - Size: UDim2.new 0, 17, 0, 17 + scrollUpButton = Instance.new "ImageButton" + scrollUpButton.Name = "ScrollUpButton" + scrollUpButton.BackgroundTransparency = 1 + scrollUpButton.Image = "rbxasset://textures/ui/scrollbuttonUp.png" + scrollUpButton.Size = UDim2.new 0, 17, 0, 17 - scrollDownButton = New "ImageButton", "ScrollDownButton" - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/scrollbuttonDown.png" - Size: UDim2.new 0, 17, 0, 17 + scrollDownButton = Instance.new "ImageButton" + scrollDownButton.Name = "ScrollDownButton" + scrollDownButton.BackgroundTransparency = 1 + scrollDownButton.Image = "rbxasset://textures/ui/scrollbuttonDown.png" + scrollDownButton.Size = UDim2.new 0, 17, 0, 17 - scrollbar = New "ImageButton", "ScrollBar" - Image: "rbxasset://textures/ui/scrollbar.png" - BackgroundTransparency: 1 - Size: UDim2.new 0, 18, 0, 150 - - * New "ImageButton", "ScrollDrag" - Image: "http://www.roblox.com/asset/?id=61367186" - Size: UDim2.new 1, 0, 0, 16 - BackgroundTransparency: 1 - Active: true - - :scrollDrag = scrollbar - - mouseDrag = New "ImageButton", "mouseDrag" - Active: false - Size: UDim2.new 1.5, 0, 1.5, 0 - AutoButtonColor: false - BackgroundTransparency: 1 - Position: UDim2.new -0.25, 0, -0.25, 0 - ZIndex: 10 + scrollbar = Instance.new "ImageButton" + scrollbar.Name = "ScrollBar" + scrollbar.Image = "rbxasset://textures/ui/scrollbar.png" + scrollbar.BackgroundTransparency = 1 + scrollbar.Size = UDim2.new 0, 18, 0, 150 scrollStamp = 0 + scrollDrag = Instance.new "ImageButton" + scrollDrag.Image = "http://www.roblox.com/asset/?id=61367186" + scrollDrag.Size = UDim2.new 1, 0, 0, 16 + scrollDrag.BackgroundTransparency = 1 + scrollDrag.Name = "ScrollDrag" + scrollDrag.Active = true + scrollDrag.Parent = scrollbar + + mouseDrag = Instance.new "ImageButton" + mouseDrag.Active = false + mouseDrag.Size = UDim2.new 1.5, 0, 1.5, 0 + mouseDrag.AutoButtonColor = false + mouseDrag.BackgroundTransparency = 1 + mouseDrag.Name = "mouseDrag" + mouseDrag.Position = UDim2.new -0.25, 0, -0.25, 0 + mouseDrag.ZIndex = 10 + style = "simple" - if scrollStyle and tostring scrollStyle + if scrollStyle and "#{scrollStyle}" style = scrollStyle + scrollPosition = 1 rowSize = 0 howManyDisplayed = 0 @@ -1222,6 +1385,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child.Parent == frame table.insert guiObjects, child + else children = frame\GetChildren! if children @@ -1229,6 +1393,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child\IsA "GuiObject" table.insert guiObjects, child + if #guiObjects == 0 scrollUpButton.Active = false scrollDownButton.Active = false @@ -1236,12 +1401,15 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> scrollPosition = 1 return + if scrollPosition > #guiObjects scrollPosition = #guiObjects + if scrollPosition < 1 scrollPosition = 1 + totalPixelsY = frame.AbsoluteSize.Y pixelsRemainingY = frame.AbsoluteSize.Y @@ -1260,7 +1428,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> --count up from current scroll position to fill out grid while pos <= #guiObjects and pixelsBelowScrollbar < totalPixelsY xCounter += guiObjects[pos].AbsoluteSize.X - --previous pos was the of a row + --previous pos was the end of a row if xCounter >= totalPixelsX pixelsBelowScrollbar += currentRowY currentRowY = 0 @@ -1302,15 +1470,19 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> else break + if guiObjects[pos].AbsoluteSize.Y > currentRowY currentRowY = guiObjects[pos].AbsoluteSize.Y + pos -= 1 + --Do check last time if pos = 0 if (pos == 0) and (pixelsBelowScrollbar + currentRowY <= totalPixelsY) scrollPosition = 1 + xCounter = 0 --pos = scrollPosition rowSizeCounter = 0 @@ -1322,16 +1494,17 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> yOffset = math.ceil math.floor(math.fmod(totalPixelsY, guiObjects[1].AbsoluteSize.X)) / 2 xOffset = math.ceil math.floor(math.fmod(totalPixelsX, guiObjects[1].AbsoluteSize.Y)) / 2 + for i, child in ipairs guiObjects if i < scrollPosition - --print "Hiding #{child.Name}" + --print "Hiding " .. child.Name child.Visible = false else if pixelsRemainingY < 0 - --print "Out of Space #{child.Name}" + --print "Out of Space " .. child.Name child.Visible = false else - --print "Laying out #{child.Name}" + --print "Laying out " .. child.Name --GuiObject if setRowSize rowSizeCounter += 1 @@ -1357,12 +1530,12 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> lastChildSize = child.AbsoluteSize - scrollUpButton.Active = (scrollPosition > 1) - scrollDownButton.Active = if lastChildSize == 0 - false + scrollUpButton.Active = (scrollPosition > 1) + if lastChildSize == 0 + scrollDownButton.Active = false else - (pixelsRemainingY - lastChildSize.Y) < 0 + scrollDownButton.Active = ((pixelsRemainingY - lastChildSize.Y) < 0) scrollDrag.Active = #guiObjects > howManyDisplayed scrollDrag.Visible = scrollDrag.Active @@ -1377,6 +1550,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child.Parent == frame table.insert guiObjects, child + else children = frame\GetChildren! if children @@ -1384,6 +1558,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child\IsA "GuiObject" table.insert guiObjects, child + if #guiObjects == 0 scrollUpButton.Active = false scrollDownButton.Active = false @@ -1391,9 +1566,11 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> scrollPosition = 1 return + if scrollPosition > #guiObjects scrollPosition = #guiObjects + totalPixels = frame.AbsoluteSize.Y pixelsRemaining = frame.AbsoluteSize.Y @@ -1412,7 +1589,10 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> else --local ("Backing up ScrollPosition from -- " ..scrollPosition) scrollPosition -= 1 - else break + + else + break + pos -= 1 @@ -1420,21 +1600,16 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> pos = scrollPosition for i, child in ipairs guiObjects if i < scrollPosition - -- print "Hiding #{child.Name}" + --print "Hiding " .. child.Name child.Visible = false else if pixelsRemaining < 0 - --print "Out of Space #{child.Name}" + --print "Out of Space " .. child.Name child.Visible = false else - --print "Laying out #{child.Name}" + --print "Laying out " .. child.Name --GuiObject - child.Position = UDim2.new( - child.Position.X.Scale, - child.Position.X.Offset, - 0, - totalPixels - pixelsRemaining - ) + child.Position = UDim2.new child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining pixelsRemaining -= child.AbsoluteSize.Y if pixelsRemaining >= 0 child.Visible = true @@ -1442,11 +1617,13 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> else child.Visible = false + scrollUpButton.Active = (scrollPosition > 1) scrollDownButton.Active = (pixelsRemaining < 0) scrollDrag.Active = #guiObjects > howManyDisplayed scrollDrag.Visible = scrollDrag.Active + moveDragger = -> guiObjects = 0 children = frame\GetChildren! @@ -1455,18 +1632,16 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child\IsA "GuiObject" guiObjects += 1 - return if not scrollDrag.Parent + + if not scrollDrag.Parent + return + dragSizeY = scrollDrag.Parent.AbsoluteSize.y * (1 / (guiObjects - howManyDisplayed + 1)) if dragSizeY < 16 dragSizeY = 16 - scrollDrag.Size = UDim2.new( - scrollDrag.Size.X.Scale, - scrollDrag.Size.X.Offset, - scrollDrag.Size.Y.Scale, - dragSizeY - ) + scrollDrag.Size = UDim2.new scrollDrag.Size.X.Scale, scrollDrag.Size.X.Offset, scrollDrag.Size.Y.Scale, dragSizeY relativeYPos = (scrollPosition - 1) / (guiObjects - howManyDisplayed) if relativeYPos > 1 @@ -1480,29 +1655,26 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> absYPos = (relativeYPos * scrollbar.AbsoluteSize.y) - (relativeYPos * scrollDrag.AbsoluteSize.y) - scrollDrag.Position = UDim2.new( - scrollDrag.Position.X.Scale, - scrollDrag.Position.X.Offset, - scrollDrag.Position.Y.Scale, - absYPos - ) + scrollDrag.Position = UDim2.new scrollDrag.Position.X.Scale, scrollDrag.Position.X.Offset, scrollDrag.Position.Y.Scale, absYPos reentrancyGuard = false recalculate = -> - return if reentrancyGuard + if reentrancyGuard + return reentrancyGuard = true wait! local success, err if style == "grid" - success, err = pcall -> + success, err = try layoutGridScrollBar! elseif style == "simple" - success, err = pcall -> + success, err = try layoutSimpleScrollBar! + if not success print err @@ -1517,14 +1689,17 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> recalculate nil + doScrollDown = -> scrollPosition += rowSize recalculate nil + scrollUp = (mouseYPos) -> if scrollUpButton.Active scrollStamp = tick! current = scrollStamp + local upCon upCon = mouseDrag.MouseButton1Up\connect -> scrollStamp = tick! mouseDrag.Parent = nil @@ -1537,20 +1712,25 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> w = 0.1 while scrollStamp == current doScrollUp! - break if mouseYPos and mouseYPos > scrollDrag.AbsolutePosition.y - break if not scrollUpButton.Active + if mouseYPos and mouseYPos > scrollDrag.AbsolutePosition.y + break - w = if tick! - t > 5 - 0 + if not scrollUpButton.Active + break + + if tick! - t > 5 + w = 0 elseif tick! - t > 2 - 0.06 + w = 0.06 wait w + scrollDown = (mouseYPos) -> if scrollDownButton.Active scrollStamp = tick! current = scrollStamp + local downCon downCon = mouseDrag.MouseButton1Up\connect -> scrollStamp = tick! mouseDrag.Parent = nil @@ -1563,22 +1743,27 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> w = 0.1 while scrollStamp == current doScrollDown! - break if mouseYPos and mouseYPos < (scrollDrag.AbsolutePosition.y + scrollDrag.AbsoluteSize.x) - break if not scrollDownButton.Active + if mouseYPos and mouseYPos < (scrollDrag.AbsolutePosition.y + scrollDrag.AbsoluteSize.x) + break - w = if tick! - t > 5 - 0 + if not scrollDownButton.Active + break + + if tick! - t > 5 + w = 0 elseif tick! - t > 2 - 0.06 + w = 0.06 wait w + -- y = 0 scrollDrag.MouseButton1Down\connect (_, y) -> if scrollDrag.Active scrollStamp = tick! mouseOffset = y - scrollDrag.AbsolutePosition.y - local dragCon, upCon + local dragCon + local upCon dragCon = mouseDrag.MouseMoved\connect (_, y) -> barAbsPos = scrollbar.AbsolutePosition.y barAbsSize = scrollbar.AbsoluteSize.y @@ -1596,6 +1781,7 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if child\IsA "GuiObject" guiObjects += 1 + doublePercent = y / (barAbsSize - dragAbsSize) rowDiff = rowSize totalScrollCount = guiObjects - (howManyDisplayed - 1) @@ -1603,9 +1789,11 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> if newScrollPosition < scrollPosition rowDiff = -rowDiff + if newScrollPosition < 1 newScrollPosition = 1 + scrollPosition = newScrollPosition recalculate nil @@ -1615,33 +1803,44 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> dragCon\disconnect! dragCon = nil upCon\disconnect! - drag = nil + global drag = nil mouseDrag.Parent = getScreenGuiAncestor scrollbar + scrollMouseCount = 0 scrollUpButton.MouseButton1Down\connect -> scrollUp! - scrollDownButton.MouseButton1Down\connect -> - scrollDown! scrollUpButton.MouseButton1Up\connect -> scrollStamp = tick! + + scrollDownButton.MouseButton1Up\connect -> scrollStamp = tick! + scrollDownButton.MouseButton1Down\connect -> + scrollDown! + + scrollbar.MouseButton1Up\connect -> scrollStamp = tick! + scrollbar.MouseButton1Down\connect (_, y) -> if y > (scrollDrag.AbsoluteSize.y + scrollDrag.AbsolutePosition.y) scrollDown y elseif y < scrollDrag.AbsolutePosition.y scrollUp y - frame.ChildAdded\connect -> recalculate nil - frame.ChildRemoved\connect -> recalculate nil - frame.AncestryChanged\connect -> recalculate nil + + frame.ChildAdded\connect -> + recalculate nil + + + frame.ChildRemoved\connect -> + recalculate nil + frame.Changed\connect (prop) -> if prop == "AbsoluteSize" @@ -1649,7 +1848,11 @@ t.CreateScrollingFrame = (orderList, scrollStyle) -> recalculate nil - frame, scrollUpButton, scrollDownButton, recalculate, scrollbar + frame.AncestryChanged\connect -> + recalculate nil + + + return frame, scrollUpButton, scrollDownButton, recalculate, scrollbar binaryGrow = (min, max, fits) -> if min > max @@ -1659,15 +1862,18 @@ binaryGrow = (min, max, fits) -> while min <= max mid = min + math.floor (max - min) / 2 - if fits(mid) and (not biggestLegal? or biggestLegal < mid) + if fits mid and (biggestLegal == nil or biggestLegal < mid) biggestLegal = mid + --Try growing min = mid + 1 else --Doesn't fit, shrink max = mid - 1 - biggestLegal + + return biggestLegal + binaryShrink = (min, max, fits) -> if min > max @@ -1677,69 +1883,76 @@ binaryShrink = (min, max, fits) -> while min <= max mid = min + math.floor (max - min) / 2 - if fits(mid) and (not smallestLegal? or smallestLegal > mid) + if fits mid and (smallestLegal == nil or smallestLegal > mid) smallestLegal = mid + --It fits, shrink max = mid - 1 else --Doesn't fit, grow min = mid + 1 - smallestLegal + + return smallestLegal + getGuiOwner = (instance) -> - while instance? - if instance\IsA"ScreenGui" or instance\IsA"BillboardGui" + while instance ~= nil + if instance\IsA"ScreenGui" or instance\IsA "BillboardGui" return instance instance = instance.Parent + return nil + + t.AutoTruncateTextObject = (textLabel) -> text = textLabel.Text fullLabel = textLabel\Clone! - with fullLabel - .Name = "Full#{textLabel.Name}" - .BorderSizePixel = 0 - .BackgroundTransparency = 0 - .Text = text - .TextXAlignment = Enum.TextXAlignment.Center - .Position = UDim2.new 0, -3, 0, 0 - .Size = UDim2.new 0, 100, 1, 0 - .Visible = false - .Parent = textLabel + fullLabel.Name = "Full" .. textLabel.Name + fullLabel.BorderSizePixel = 0 + fullLabel.BackgroundTransparency = 0 + fullLabel.Text = text + fullLabel.TextXAlignment = Enum.TextXAlignment.Center + fullLabel.Position = UDim2.new 0, -3, 0, 0 + fullLabel.Size = UDim2.new 0, 100, 1, 0 + fullLabel.Visible = false + fullLabel.Parent = textLabel local shortText local mouseEnterConnection local mouseLeaveConnection checkForResize = -> - return if not getGuiOwner(textLabel)? + if getGuiOwner textLabel == nil + return textLabel.Text = text if textLabel.TextFits --Tear down the rollover if it is active + if mouseEnterConnection + mouseEnterConnection\disconnect! + mouseEnterConnection = nil - mouseEnterConnection?\disconnect! - mouseEnterConnection = nil - - mouseLeaveConnection?\disconnect! - mouseLeaveConnection = nil + if mouseLeaveConnection + mouseLeaveConnection\disconnect! + mouseLeaveConnection = nil else len = string.len text - textLabel.Text = "#{text}~" + textLabel.Text = text .. "~" --Shrink the text textSize = binaryGrow 0, len, (pos) -> - textLabel.Text = if pos == 0 - "~" + if pos == 0 + textLabel.Text = "~" else - "#{string.sub text, 1, pos}~" + textLabel.Text = string.sub(text, 1, pos) .. "~" - textLabel.TextFits + return textLabel.TextFits - shortText = "#{string.sub text, 1, textSize}~" + shortText = string.sub(text, 1, textSize) .. "~" textLabel.Text = shortText --Make sure the fullLabel fits @@ -1747,30 +1960,34 @@ t.AutoTruncateTextObject = (textLabel) -> --Already too small, grow it really bit to start fullLabel.Size = UDim2.new 0, 10000, 1, 0 + --Okay, now try to binary shrink it back down fullLabelSize = binaryShrink textLabel.AbsoluteSize.X, fullLabel.AbsoluteSize.X, (size) -> fullLabel.Size = UDim2.new 0, size, 1, 0 - fullLabel.TextFits + return fullLabel.TextFits fullLabel.Size = UDim2.new 0, fullLabelSize + 6, 1, 0 --Now setup the rollover effects, if they are currently off - if not mouseEnterConnection? + if mouseEnterConnection == nil mouseEnterConnection = textLabel.MouseEnter\connect -> fullLabel.ZIndex = textLabel.ZIndex + 1 fullLabel.Visible = true --textLabel.Text = "" - if not mouseLeaveConnection? + + if mouseLeaveConnection == nil mouseLeaveConnection = textLabel.MouseLeave\connect -> fullLabel.Visible = false --textLabel.Text = shortText + textLabel.AncestryChanged\connect checkForResize textLabel.Changed\connect (prop) -> if prop == "AbsoluteSize" checkForResize! + checkForResize! changeText = (newText) -> @@ -1778,7 +1995,9 @@ t.AutoTruncateTextObject = (textLabel) -> fullLabel.Text = text checkForResize! - textLabel, changeText + + return textLabel, changeText + TransitionTutorialPages = (fromPage, toPage, transitionFrame, currentPageValue) -> if fromPage @@ -1787,9 +2006,11 @@ TransitionTutorialPages = (fromPage, toPage, transitionFrame, currentPageValue) transitionFrame.Size = fromPage.Size transitionFrame.Position = fromPage.Position - elseif transitionFrame.Visible == false - transitionFrame.Size = UDim2.new 0, 50, 0, 50 - transitionFrame.Position = UDim2.new 0.5, -25, 0.5, -25 + else + if transitionFrame.Visible == false + transitionFrame.Size = UDim2.new 0, 50, 0, 50 + transitionFrame.Position = UDim2.new 0.5, -25, 0.5, -25 + transitionFrame.Visible = true currentPageValue.Value = nil @@ -1820,35 +2041,41 @@ TransitionTutorialPages = (fromPage, toPage, transitionFrame, currentPageValue) if toPage toPage.Visible = true currentPageValue.Value = toPage + + ) + t.CreateTutorial = (name, tutorialKey, createButtons) -> - frame = New "Frame", "Tutorial-#{name}" - BackgroundTransparency: 1 - Size: UDim2.new 0.6, 0, 0.6, 0 - Position: UDim2.new 0.2, 0, 0.2, 0 + frame = Instance.new "Frame" + frame.Name = "Tutorial-" .. name + frame.BackgroundTransparency = 1 + frame.Size = UDim2.new 0.6, 0, 0.6, 0 + frame.Position = UDim2.new 0.2, 0, 0.2, 0 - * New "Frame", "TransitionFrame" - Style: Enum.FrameStyle.RobloxRound - Size: UDim2.new 0.6, 0, 0.6, 0 - Position: UDim2.new 0.2, 0, 0.2, 0 - Visible: false + transitionFrame = Instance.new "Frame" + transitionFrame.Name = "TransitionFrame" + transitionFrame.Style = Enum.FrameStyle.RobloxRound + transitionFrame.Size = UDim2.new 0.6, 0, 0.6, 0 + transitionFrame.Position = UDim2.new 0.2, 0, 0.2, 0 + transitionFrame.Visible = false + transitionFrame.Parent = frame - * New "ObjectValue", "CurrentTutorialPage" - Value: nil + currentPageValue = Instance.new "ObjectValue" + currentPageValue.Name = "CurrentTutorialPage" + currentPageValue.Value = nil + currentPageValue.Parent = frame - * New "BoolValue", "Buttons" - Value: createButtons + boolValue = Instance.new "BoolValue" + boolValue.Name = "Buttons" + boolValue.Value = createButtons + boolValue.Parent = frame - * New "Frame", "Pages" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 1, 0 - - { -- Destructure - TransitionFrame: transitionFrame - CurrentTutorialPage: currentPageValue - Pages: pages - } = frame + pages = Instance.new "Frame" + pages.Name = "Pages" + pages.BackgroundTransparency = 1 + pages.Size = UDim2.new 1, 0, 1, 0 + pages.Parent = frame getVisiblePageAndHideOthers = -> local visiblePage @@ -1861,10 +2088,12 @@ t.CreateTutorial = (name, tutorialKey, createButtons) -> else visiblePage = child - visiblePage + + return visiblePage + showTutorial = (alwaysShow) -> - if alwaysShow or UserSettings!.GameSettings\GetTutorialState(tutorialKey) == false + if alwaysShow or UserSettings!.GameSettings\GetTutorialState tutorialKey == false print "Showing tutorial-", tutorialKey currentTutorialPage = getVisiblePageAndHideOthers! @@ -1881,96 +2110,114 @@ t.CreateTutorial = (name, tutorialKey, createButtons) -> if currentTutorialPage TransitionTutorialPages currentTutorialPage, nil, transitionFrame, currentPageValue + UserSettings!.GameSettings\SetTutorialState tutorialKey, true gotoPage = (pageNum) -> - page = pages\FindFirstChild "TutorialPage#{pageNum}" + page = pages\FindFirstChild "TutorialPage" .. pageNum currentTutorialPage = getVisiblePageAndHideOthers! TransitionTutorialPages currentTutorialPage, page, transitionFrame, currentPageValue - frame, showTutorial, dismissTutorial, gotoPage + + return frame, showTutorial, dismissTutorial, gotoPage + CreateBasicTutorialPage = (name, handleResize, skipTutorial, giveDoneButton) -> - frame = New "Frame", "TutorialPage" - Style: Enum.FrameStyle.RobloxRound - Size: UDim2.new 0.6, 0, 0.6, 0 - Position: UDim2.new 0.2, 0, 0.2, 0 - Visible: false + frame = Instance.new "Frame" + frame.Name = "TutorialPage" + frame.Style = Enum.FrameStyle.RobloxRound + frame.Size = UDim2.new 0.6, 0, 0.6, 0 + frame.Position = UDim2.new 0.2, 0, 0.2, 0 + frame.Visible = false - * New "TextLabel", "Header" - Text: name - BackgroundTransparency: 1 - FontSize: Enum.FontSize.Size24 - Font: Enum.Font.ArialBold - TextColor3: Color3.new 1, 1, 1 - TextXAlignment: Enum.TextXAlignment.Center - TextWrap: true - Size: UDim2.new 1, -55, 0, 22 - Position: UDim2.new 0, 0, 0, 0 + frameHeader = Instance.new "TextLabel" + frameHeader.Name = "Header" + frameHeader.Text = name + frameHeader.BackgroundTransparency = 1 + frameHeader.FontSize = Enum.FontSize.Size24 + frameHeader.Font = Enum.Font.ArialBold + frameHeader.TextColor3 = Color3.new 1, 1, 1 + frameHeader.TextXAlignment = Enum.TextXAlignment.Center + frameHeader.TextWrap = true + frameHeader.Size = UDim2.new 1, -55, 0, 22 + frameHeader.Position = UDim2.new 0, 0, 0, 0 + frameHeader.Parent = frame - * New "ImageButton", "SkipButton" - AutoButtonColor: false - BackgroundTransparency: 1 - Image: "rbxasset://textures/ui/closeButton.png" - Size: UDim2.new 0, 25, 0, 25 - Position: UDim2.new 1, -25, 0, 0 + skipButton = Instance.new "ImageButton" + skipButton.Name = "SkipButton" + skipButton.AutoButtonColor = false + skipButton.BackgroundTransparency = 1 + skipButton.Image = "rbxasset://textures/ui/closeButton.png" + skipButton.MouseButton1Click\connect -> + skipTutorial! - * New "TextButton", "NextButton" - Text: "Next" - TextColor3: Color3.new 1, 1, 1 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - Style: Enum.ButtonStyle.RobloxButtonDefault - Size: UDim2.new 0, 80, 0, 32 - Position: UDim2.new 0.5, 5, 1, -32 - Active: false - Visible: false + skipButton.MouseEnter\connect -> + skipButton.Image = "rbxasset://textures/ui/closeButton_dn.png" - * New "TextButton", "PrevButton" - Text: "Previous" - TextColor3: Color3.new 1, 1, 1 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - Style: Enum.ButtonStyle.RobloxButton - Size: UDim2.new 0, 80, 0, 32 - Position: UDim2.new 0.5, -85, 1, -32 - Active: false - Visible: false + skipButton.MouseLeave\connect -> + skipButton.Image = "rbxasset://textures/ui/closeButton.png" - * New "Frame", "ContentFrame" - BackgroundTransparency: 1 - Position: UDim2.new 0, 0, 0, 25 - - innerFrame = frame.ContentFrame - - with frame.SkipButton - .MouseButton1Click\connect -> - skipTutorial! - .MouseEnter\connect -> - .Image = "rbxasset://textures/ui/closeButton_dn.png" - .MouseLeave\connect -> - .Image = "rbxasset://textures/ui/closeButton.png" + skipButton.Size = UDim2.new 0, 25, 0, 25 + skipButton.Position = UDim2.new 1, -25, 0, 0 + skipButton.Parent = frame if giveDoneButton - doneButton = New "TextButton", "DoneButton" - Style: Enum.ButtonStyle.RobloxButtonDefault - Text: "Done" - TextColor3: Color3.new 1, 1, 1 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size18 - Size: UDim2.new 0, 100, 0, 50 - Position: UDim2.new 0.5, -50, 1, -50 - Parent: frame + doneButton = Instance.new "TextButton" + doneButton.Name = "DoneButton" + doneButton.Style = Enum.ButtonStyle.RobloxButtonDefault + doneButton.Text = "Done" + doneButton.TextColor3 = Color3.new 1, 1, 1 + doneButton.Font = Enum.Font.ArialBold + doneButton.FontSize = Enum.FontSize.Size18 + doneButton.Size = UDim2.new 0, 100, 0, 50 + doneButton.Position = UDim2.new 0.5, -50, 1, -50 if skipTutorial doneButton.MouseButton1Click\connect -> skipTutorial! - innerFrame.Size = if giveDoneButton - UDim2.new 1, 0, 1, -75 + + doneButton.Parent = frame + + + innerFrame = Instance.new "Frame" + innerFrame.Name = "ContentFrame" + innerFrame.BackgroundTransparency = 1 + innerFrame.Position = UDim2.new 0, 0, 0, 25 + innerFrame.Parent = frame + + nextButton = Instance.new "TextButton" + nextButton.Name = "NextButton" + nextButton.Text = "Next" + nextButton.TextColor3 = Color3.new 1, 1, 1 + nextButton.Font = Enum.Font.Arial + nextButton.FontSize = Enum.FontSize.Size18 + nextButton.Style = Enum.ButtonStyle.RobloxButtonDefault + nextButton.Size = UDim2.new 0, 80, 0, 32 + nextButton.Position = UDim2.new 0.5, 5, 1, -32 + nextButton.Active = false + nextButton.Visible = false + nextButton.Parent = frame + + prevButton = Instance.new "TextButton" + prevButton.Name = "PrevButton" + prevButton.Text = "Previous" + prevButton.TextColor3 = Color3.new 1, 1, 1 + prevButton.Font = Enum.Font.Arial + prevButton.FontSize = Enum.FontSize.Size18 + prevButton.Style = Enum.ButtonStyle.RobloxButton + prevButton.Size = UDim2.new 0, 80, 0, 32 + prevButton.Position = UDim2.new 0.5, -85, 1, -32 + prevButton.Active = false + prevButton.Visible = false + prevButton.Parent = frame + + if giveDoneButton + innerFrame.Size = UDim2.new 1, 0, 1, -75 else - UDim2.new 1, 0, 1, -22 + innerFrame.Size = UDim2.new 1, 0, 1, -22 + local parentConnection @@ -1979,37 +2226,44 @@ CreateBasicTutorialPage = (name, handleResize, skipTutorial, giveDoneButton) -> maxSize = math.min frame.Parent.AbsoluteSize.X, frame.Parent.AbsoluteSize.Y handleResize 200, maxSize + frame.Changed\connect (prop) -> if prop == "Parent" - - parentConnection?\disconnect! - parentConnection = nil + if parentConnection ~= nil + parentConnection\disconnect! + parentConnection = nil if frame.Parent and frame.Parent\IsA "GuiObject" parentConnection = frame.Parent.Changed\connect (parentProp) -> if parentProp == "AbsoluteSize" wait! basicHandleResize! + + basicHandleResize! + if prop == "Visible" basicHandleResize! - frame, innerFrame + + return frame, innerFrame + t.CreateTextTutorialPage = (name, text, skipTutorialFunc) -> local frame + local contentFrame - textLabel = New "TextLabel" - BackgroundTransparency: 1 - TextColor3: Color3.new 1, 1, 1 - Text: text - TextWrap: true - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Center - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size14 - Size: UDim2.new 1, 0, 1, 0 + textLabel = Instance.new "TextLabel" + textLabel.BackgroundTransparency = 1 + textLabel.TextColor3 = Color3.new 1, 1, 1 + textLabel.Text = text + textLabel.TextWrap = true + textLabel.TextXAlignment = Enum.TextXAlignment.Left + textLabel.TextYAlignment = Enum.TextYAlignment.Center + textLabel.Font = Enum.Font.Arial + textLabel.FontSize = Enum.FontSize.Size14 + textLabel.Size = UDim2.new 1, 0, 1, 0 handleResize = (minSize, maxSize) -> size = binaryShrink minSize, maxSize, (size) -> @@ -2019,19 +2273,22 @@ t.CreateTextTutorialPage = (name, text, skipTutorialFunc) -> frame.Size = UDim2.new 0, size, 0, size frame.Position = UDim2.new 0.5, -size / 2, 0.5, -size / 2 + frame, contentFrame = CreateBasicTutorialPage name, handleResize, skipTutorialFunc textLabel.Parent = contentFrame frame -t.CreateImageTutorialPage = (name, imageAsset, x, y, skipTutorialFunc, giveDoneButton) -> - local frame, contentFrame - imageLabel = New "ImageLabel" - BackgroundTransparency: 1 - Image: imageAsset - Size: UDim2.new 0, x, 0, y - Position: UDim2.new 0.5, -x / 2, 0.5, -y / 2 +t.CreateImageTutorialPage = (name, imageAsset, x, y, skipTutorialFunc, giveDoneButton) -> + local frame + local contentFrame + + imageLabel = Instance.new "ImageLabel" + imageLabel.BackgroundTransparency = 1 + imageLabel.Image = imageAsset + imageLabel.Size = UDim2.new 0, x, 0, y + imageLabel.Position = UDim2.new 0.5, -x / 2, 0.5, -y / 2 handleResize = (minSize, maxSize) -> size = binaryShrink minSize, maxSize, (size) -> @@ -2041,37 +2298,44 @@ t.CreateImageTutorialPage = (name, imageAsset, x, y, skipTutorialFunc, giveDoneB imageLabel.Size = UDim2.new 0, x, 0, y imageLabel.Position = UDim2.new 0.5, -x / 2, 0.5, -y / 2 else - imageLabel.Size, imageLabel.Position = if x > y + if x > y --X is limiter, so - UDim2.new(1, 0, y / x, 0), UDim2.new(0, 0, 0.5 - (y / x) / 2, 0) + imageLabel.Size = UDim2.new 1, 0, y / x, 0 + imageLabel.Position = UDim2.new 0, 0, 0.5 - (y / x) / 2, 0 else --Y is limiter - UDim2.new(x / y, 0, 1, 0), UDim2.new(0.5 - (x / y) / 2, 0, 0, 0) + imageLabel.Size = UDim2.new x / y, 0, 1, 0 + imageLabel.Position = UDim2.new 0.5 - (x / y) / 2, 0, 0, 0 size += 50 frame.Size = UDim2.new 0, size, 0, size frame.Position = UDim2.new 0.5, -size / 2, 0.5, -size / 2 + frame, contentFrame = CreateBasicTutorialPage name, handleResize, skipTutorialFunc, giveDoneButton imageLabel.Parent = contentFrame frame + t.AddTutorialPage = (tutorial, tutorialPage) -> transitionFrame = tutorial.TransitionFrame currentPageValue = tutorial.CurrentTutorialPage if not tutorial.Buttons.Value - tutorialPage.NextButton.Parent = tutorialPage.PrevButton.Parent = nil + tutorialPage.NextButton.Parent = nil + tutorialPage.PrevButton.Parent = nil + children = tutorial.Pages\GetChildren! if children and #children > 0 - tutorialPage.Name = "TutorialPage#{#children + 1}" + tutorialPage.Name = "TutorialPage" .. (#children + 1) previousPage = children[#children] if not previousPage\IsA "GuiObject" error "All elements under Pages must be GuiObjects" + if tutorial.Buttons.Value if previousPage.NextButton.Active error "NextButton already Active on previousPage, please only add pages with RbxGui.AddTutorialPage function" @@ -2079,7 +2343,8 @@ t.AddTutorialPage = (tutorial, tutorialPage) -> previousPage.NextButton.MouseButton1Click\connect -> TransitionTutorialPages previousPage, tutorialPage, transitionFrame, currentPageValue - previousPage.NextButton.Active = previousPage.NextButton.Visible = true + previousPage.NextButton.Active = true + previousPage.NextButton.Visible = true if tutorialPage.PrevButton.Active error "PrevButton already Active on tutorialPage, please only add pages with RbxGui.AddTutorialPage function" @@ -2087,7 +2352,8 @@ t.AddTutorialPage = (tutorial, tutorialPage) -> tutorialPage.PrevButton.MouseButton1Click\connect -> TransitionTutorialPages tutorialPage, previousPage, transitionFrame, currentPageValue - tutorialPage.PrevButton.Active = tutorialPage.PrevButton.Visible = true + tutorialPage.PrevButton.Active = true + tutorialPage.PrevButton.Visible = true tutorialPage.Parent = tutorial.Pages @@ -2096,6 +2362,7 @@ t.AddTutorialPage = (tutorial, tutorialPage) -> tutorialPage.Name = "TutorialPage1" tutorialPage.Parent = tutorial.Pages + t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position, showAdminCategories, useAssetVersionId) -> if not userIdsForSets error "CreateSetPanel: userIdsForSets (first arg) is nil, should be a table of number ids" @@ -2112,13 +2379,16 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position if dialogClosed and type(dialogClosed) ~= "function" error "CreateSetPanel: dialogClosed (third arg) is of type #{type dialogClosed}, should be of type function!" - if not showAdminCategories? -- by default, don't show beta sets + + if showAdminCategories == nil -- by default, don't show beta sets showAdminCategories = false + arrayPosition = 1 insertButtons = {} insertButtonCons = {} - local contents, setGui + local contents + local setGui -- used for water selections waterForceDirection = "NegX" @@ -2135,13 +2405,16 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position buttonWidth = 64 buttonHeight = buttonWidth - local SmallThumbnailUrl, LargeThumbnailUrl + local SmallThumbnailUrl + local LargeThumbnailUrl BaseUrl = game\GetService"ContentProvider".BaseUrl\lower! - LargeThumbnailUrl, SmallThumbnailUrl = if useAssetVersionId - "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&assetversionid=", "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&assetversionid=" + if useAssetVersionId + LargeThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&assetversionid=" + SmallThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&assetversionid=" else - "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&aid=", "#{BaseUrl}Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&aid=" + LargeThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=420&ht=420&aid=" + SmallThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=75&ht=75&aid=" drillDownSetZIndex = (parent, index) -> @@ -2152,17 +2425,11 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position drillDownSetZIndex children[i], index + -- for terrain stamping local currTerrainDropDownFrame - terrainShapes = - * "Block" - * "Vertical Ramp" - * "Corner Wedge" - * "Inverse Corner Wedge" - * "Horizontal Ramp" - * "Auto-Wedge" + terrainShapes = { "Block", "Vertical Ramp", "Corner Wedge", "Inverse Corner Wedge", "Horizontal Ramp", "Auto-Wedge" } terrainShapeMap = {} - for i = 1, #terrainShapes terrainShapeMap[terrainShapes[i]] = i - 1 @@ -2172,30 +2439,32 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position waterForceDirections = { "NegX", "X", "NegY", "Y", "NegZ", "Z" } waterForces = { "None", "Small", "Medium", "Strong", "Max" } - waterFrame = New "Frame", "WaterFrame" - Style: Enum.FrameStyle.RobloxSquare - Size: UDim2.new 0, 150, 0, 110 - Visible: false + waterFrame = Instance.new "Frame" + waterFrame.Name = "WaterFrame" + waterFrame.Style = Enum.FrameStyle.RobloxSquare + waterFrame.Size = UDim2.new 0, 150, 0, 110 + waterFrame.Visible = false - waterForceLabel = New "TextLabel", "WaterForceLabel" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 0, 12 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size12 - TextColor3: Color3.new 1, 1, 1 - TextXAlignment: Enum.TextXAlignment.Left - Text: "Water Force" - Parent: waterFrame + waterForceLabel = Instance.new "TextLabel" + waterForceLabel.Name = "WaterForceLabel" + waterForceLabel.BackgroundTransparency = 1 + waterForceLabel.Size = UDim2.new 1, 0, 0, 12 + waterForceLabel.Font = Enum.Font.ArialBold + waterForceLabel.FontSize = Enum.FontSize.Size12 + waterForceLabel.TextColor3 = Color3.new 1, 1, 1 + waterForceLabel.TextXAlignment = Enum.TextXAlignment.Left + waterForceLabel.Text = "Water Force" + waterForceLabel.Parent = waterFrame waterForceDirLabel = waterForceLabel\Clone! - with waterForceDirLabel - .Name = "WaterForceDirectionLabel" - .Text = "Water Force Direction" - .Position = UDim2.new 0, 0, 0, 50 - .Parent = waterFrame + waterForceDirLabel.Name = "WaterForceDirectionLabel" + waterForceDirLabel.Text = "Water Force Direction" + waterForceDirLabel.Position = UDim2.new 0, 0, 0, 50 + waterForceDirLabel.Parent = waterFrame - waterTypeChangedEvent = New "BindableEvent", "WaterTypeChangedEvent" - Parent: waterFrame + waterTypeChangedEvent = Instance.new "BindableEvent" + waterTypeChangedEvent.Name = "WaterTypeChangedEvent" + waterTypeChangedEvent.Parent = waterFrame waterForceDirectionSelectedFunc = (newForceDirection) -> waterForceDirection = newForceDirection @@ -2218,7 +2487,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position waterForceDropDown.Position = UDim2.new 0, 0, 1, 3 waterForceDropDown.Parent = waterForceLabel - waterFrame, waterTypeChangedEvent + return waterFrame, waterTypeChangedEvent -- Helper Function that contructs gui elements @@ -2226,131 +2495,172 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position setGui = Instance.new "ScreenGui" setGui.Name = "SetGui" - setPanel = New "Frame", "SetPanel" - Active: true - BackgroundTransparency: 1 - Position: position or UDim2.new 0.2, 29, 0.1, 24 - Size: size or UDim2.new 0.6, -58, 0.64, 0 - Style: Enum.FrameStyle.RobloxRound - ZIndex: 6 - Parent: setGui + setPanel = Instance.new "Frame" + setPanel.Name = "SetPanel" + setPanel.Active = true + setPanel.BackgroundTransparency = 1 + if position + setPanel.Position = position + else + setPanel.Position = UDim2.new 0.2, 29, 0.1, 24 - * New "TextButton", "CancelButton" - Position: UDim2.new 1, -32, 0, -2 - Size: UDim2.new 0, 34, 0, 34 - Style: Enum.ButtonStyle.RobloxButtonDefault - ZIndex: 6 - Text: "" - Modal: true + if size + setPanel.Size = size + else + setPanel.Size = UDim2.new 0.6, -58, 0.64, 0 - * New "ImageLabel", "CancelImage" - BackgroundTransparency: 1 - Image: "http://www.roblox.com/asset?id=54135717" - Position: UDim2.new 0, -2, 0, -2 - Size: UDim2.new 0, 16, 0, 16 - ZIndex: 6 + setPanel.Style = Enum.FrameStyle.RobloxRound + setPanel.ZIndex = 6 + setPanel.Parent = setGui - * New "Frame", "ItemPreview" - BackgroundTransparency: 1 - Position: UDim2.new 0.8, 5, 0.085, 0 - Size: UDim2.new 0.21, 0, 0.9, 0 - ZIndex: 6 + -- Children of SetPanel + itemPreview = Instance.new "Frame" + itemPreview.Name = "ItemPreview" + itemPreview.BackgroundTransparency = 1 + itemPreview.Position = UDim2.new 0.8, 5, 0.085, 0 + itemPreview.Size = UDim2.new 0.21, 0, 0.9, 0 + itemPreview.ZIndex = 6 + itemPreview.Parent = setPanel - * New "ImageLabel", "LargePreview" - BackgroundTransparency: 1 - Image: "" - Size: UDim2.new 1, 0, 0, 170 - ZIndex: 6 + -- Children of ItemPreview + textPanel = Instance.new "Frame" + textPanel.Name = "TextPanel" + textPanel.BackgroundTransparency = 1 + textPanel.Position = UDim2.new 0, 0, 0.45, 0 + textPanel.Size = UDim2.new 1, 0, 0.55, 0 + textPanel.ZIndex = 6 + textPanel.Parent = itemPreview - * New "Frame", "TextPanel" - BackgroundTransparency: 1 - Position: UDim2.new 0, 0, 0.45, 0 - Size: UDim2.new 1, 0, 0.55, 0 - ZIndex: 6 + -- Children of TextPanel + rolloverText = Instance.new "TextLabel" + rolloverText.Name = "RolloverText" + rolloverText.BackgroundTransparency = 1 + rolloverText.Size = UDim2.new 1, 0, 0, 48 + rolloverText.ZIndex = 6 + rolloverText.Font = Enum.Font.ArialBold + rolloverText.FontSize = Enum.FontSize.Size24 + rolloverText.Text = "" + rolloverText.TextColor3 = Color3.new 1, 1, 1 + rolloverText.TextWrap = true + rolloverText.TextXAlignment = Enum.TextXAlignment.Left + rolloverText.TextYAlignment = Enum.TextYAlignment.Top + rolloverText.Parent = textPanel - * New "TextLabel", "RolloverText" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 0, 48 - ZIndex: 6 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size24 - Text: "" - TextColor3: Color3.new 1, 1, 1 - TextWrap: true - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Top + largePreview = Instance.new "ImageLabel" + largePreview.Name = "LargePreview" + largePreview.BackgroundTransparency = 1 + largePreview.Image = "" + largePreview.Size = UDim2.new 1, 0, 0, 170 + largePreview.ZIndex = 6 + largePreview.Parent = itemPreview - * New "Frame", "Sets" - BackgroundTransparency: 1 - Position: UDim2.new 0, 0, 0, 5 - Size: UDim2.new 0.23, 0, 1, -5 - ZIndex: 6 + sets = Instance.new "Frame" + sets.Name = "Sets" + sets.BackgroundTransparency = 1 + sets.Position = UDim2.new 0, 0, 0, 5 + sets.Size = UDim2.new 0.23, 0, 1, -5 + sets.ZIndex = 6 + sets.Parent = setPanel - * New "Frame", "Line" - BackgroundColor3: Color3.new 1, 1, 1 - BackgroundTransparency: 0.7 - BorderSizePixel: 0 - Position: UDim2.new 1, -3, 0.06, 0 - Size: UDim2.new 0, 3, 0.9, 0 - ZIndex: 6 - - * New "TextLabel", "SetsHeader" - BackgroundTransparency: 1 - Size: UDim2.new 0, 47, 0, 24 - ZIndex: 6 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size24 - Text: "Sets" - TextColor3: Color3.new 1, 1, 1 - TextXAlignment: Enum.TextXAlignment.Left - TextYAlignment: Enum.TextYAlignment.Top + -- Children of Sets + line = Instance.new "Frame" + line.Name = "Line" + line.BackgroundColor3 = Color3.new 1, 1, 1 + line.BackgroundTransparency = 0.7 + line.BorderSizePixel = 0 + line.Position = UDim2.new 1, -3, 0.06, 0 + line.Size = UDim2.new 0, 3, 0.9, 0 + line.ZIndex = 6 + line.Parent = sets setsLists, controlFrame = t.CreateTrueScrollingFrame! - with setsLists - .Size = UDim2.new 1, -6, 0.94, 0 - .Position = UDim2.new 0, 0, 0.06, 0 - .BackgroundTransparency = 1 - .Name = "SetsLists" - .ZIndex = 6 - .Parent = setPanel.Sets + setsLists.Size = UDim2.new 1, -6, 0.94, 0 + setsLists.Position = UDim2.new 0, 0, 0.06, 0 + setsLists.BackgroundTransparency = 1 + setsLists.Name = "SetsLists" + setsLists.ZIndex = 6 + setsLists.Parent = sets drillDownSetZIndex controlFrame, 7 - setGui + setsHeader = Instance.new "TextLabel" + setsHeader.Name = "SetsHeader" + setsHeader.BackgroundTransparency = 1 + setsHeader.Size = UDim2.new 0, 47, 0, 24 + setsHeader.ZIndex = 6 + setsHeader.Font = Enum.Font.ArialBold + setsHeader.FontSize = Enum.FontSize.Size24 + setsHeader.Text = "Sets" + setsHeader.TextColor3 = Color3.new 1, 1, 1 + setsHeader.TextXAlignment = Enum.TextXAlignment.Left + setsHeader.TextYAlignment = Enum.TextYAlignment.Top + setsHeader.Parent = sets + + cancelButton = Instance.new "TextButton" + cancelButton.Name = "CancelButton" + cancelButton.Position = UDim2.new 1, -32, 0, -2 + cancelButton.Size = UDim2.new 0, 34, 0, 34 + cancelButton.Style = Enum.ButtonStyle.RobloxButtonDefault + cancelButton.ZIndex = 6 + cancelButton.Text = "" + cancelButton.Modal = true + cancelButton.Parent = setPanel + + -- Children of Cancel Button + cancelImage = Instance.new "ImageLabel" + cancelImage.Name = "CancelImage" + cancelImage.BackgroundTransparency = 1 + cancelImage.Image = "http://www.roblox.com/asset?id=54135717" + cancelImage.Position = UDim2.new 0, -2, 0, -2 + cancelImage.Size = UDim2.new 0, 16, 0, 16 + cancelImage.ZIndex = 6 + cancelImage.Parent = cancelButton + + return setGui + createSetButton = (text) -> - setButton = New "TextButton" - Text: text or "" - AutoButtonColor: false - BackgroundTransparency: 1 - BackgroundColor3: Color3.new 1, 1, 1 - BorderSizePixel: 0 - Size: UDim2.new 1, -5, 0, 18 - ZIndex: 6 - Visible: false - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - TextColor3: Color3.new 1, 1, 1 - TextXAlignment: Enum.TextXAlignment.Left + setButton = Instance.new "TextButton" + + if text + setButton.Text = text + else + setButton.Text = "" + + + setButton.AutoButtonColor = false + setButton.BackgroundTransparency = 1 + setButton.BackgroundColor3 = Color3.new 1, 1, 1 + setButton.BorderSizePixel = 0 + setButton.Size = UDim2.new 1, -5, 0, 18 + setButton.ZIndex = 6 + setButton.Visible = false + setButton.Font = Enum.Font.Arial + setButton.FontSize = Enum.FontSize.Size18 + setButton.TextColor3 = Color3.new 1, 1, 1 + setButton.TextXAlignment = Enum.TextXAlignment.Left setButton + buildSetButton = (name, setId, _, _, _) -> button = createSetButton name - with button - .Text = name - .Name = "SetButton" - .Visible = true + button.Text = name + button.Name = "SetButton" + button.Visible = true - New "IntValue", "SetId" - Value: setId - Parent: button + setValue = Instance.new "IntValue" + setValue.Name = "SetId" + setValue.Value = setId + setValue.Parent = button - New "StringValue", "SetName" - Value: name - Parent: button + setName = Instance.new "StringValue" + setName.Name = "SetName" + setName.Value = name + setName.Parent = button button + processCategory = (sets) -> setButtons = {} numSkipped = 0 @@ -2360,113 +2670,138 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position else setButtons[i - numSkipped] = buildSetButton sets[i].Name, sets[i].CategoryId, sets[i].ImageAssetId, i - numSkipped, #sets + setButtons + handleResize = -> wait! -- neccessary to insure heartbeat happened - with setGui.SetPanel.ItemPreview - .LargePreview.Size = UDim2.new 1, 0, 0, .AbsoluteSize.X - .LargePreview.Position = UDim2.new 0.5, -.LargePreview.AbsoluteSize.X / 2, 0, 0 - .TextPanel.Position = UDim2.new 0, 0, 0, .LargePreview.AbsoluteSize.Y - .TextPanel.Size = UDim2.new 1, 0, 0, .AbsoluteSize.Y - .LargePreview.AbsoluteSize.Y + itemPreview = setGui.SetPanel.ItemPreview + + itemPreview.LargePreview.Size = UDim2.new 1, 0, 0, itemPreview.AbsoluteSize.X + itemPreview.LargePreview.Position = UDim2.new 0.5, -itemPreview.LargePreview.AbsoluteSize.X / 2, 0, 0 + itemPreview.TextPanel.Position = UDim2.new 0, 0, 0, itemPreview.LargePreview.AbsoluteSize.Y + itemPreview.TextPanel.Size = UDim2.new 1, 0, 0, itemPreview.AbsoluteSize.Y - itemPreview.LargePreview.AbsoluteSize.Y + makeInsertAssetButton = -> - insertAssetButtonExample = New "Frame", "InsertAssetButtonExample" - Position: UDim2.new 0, 128, 0, 64 - Size: UDim2.new 0, 64, 0, 64 - BackgroundTransparency: 1 - ZIndex: 6 - Visible: false + insertAssetButtonExample = Instance.new "Frame" + insertAssetButtonExample.Name = "InsertAssetButtonExample" + insertAssetButtonExample.Position = UDim2.new 0, 128, 0, 64 + insertAssetButtonExample.Size = UDim2.new 0, 64, 0, 64 + insertAssetButtonExample.BackgroundTransparency = 1 + insertAssetButtonExample.ZIndex = 6 + insertAssetButtonExample.Visible = false - * New "IntValue", "AssetId" - Value: 0 + assetId = Instance.new "IntValue" + assetId.Name = "AssetId" + assetId.Value = 0 + assetId.Parent = insertAssetButtonExample - * New "StringValue", "AssetName" - Value: "" + assetName = Instance.new "StringValue" + assetName.Name = "AssetName" + assetName.Value = "" + assetName.Parent = insertAssetButtonExample - * New "TextButton", "Button" - Text: "" - Style: Enum.ButtonStyle.RobloxButton - Position: UDim2.new 0.025, 0, 0.025, 0 - Size: UDim2.new 0.95, 0, 0.95, 0 - ZIndex: 6 + button = Instance.new "TextButton" + button.Name = "Button" + button.Text = "" + button.Style = Enum.ButtonStyle.RobloxButton + button.Position = UDim2.new 0.025, 0, 0.025, 0 + button.Size = UDim2.new 0.95, 0, 0.95, 0 + button.ZIndex = 6 + button.Parent = insertAssetButtonExample - * New "ImageLabel", "ButtonImage" - Image: "" - Position: UDim2.new 0, -7, 0, -7 - Size: UDim2.new 1, 14, 1, 14 - BackgroundTransparency: 1 - ZIndex: 7 + buttonImage = Instance.new "ImageLabel" + buttonImage.Name = "ButtonImage" + buttonImage.Image = "" + buttonImage.Position = UDim2.new 0, -7, 0, -7 + buttonImage.Size = UDim2.new 1, 14, 1, 14 + buttonImage.BackgroundTransparency = 1 + buttonImage.ZIndex = 7 + buttonImage.Parent = button - with insertAssetButtonExample.button.ButtonImage\clone! - .Name = "ConfigIcon" - .Visible = false - .Position = UDim2.new 1, -23, 1, -24 - .Size = UDim2.new 0, 16, 0, 16 - .Image = "" - .ZIndex = 6 - .Parent = insertAssetButtonExample + configIcon = buttonImage\clone! + configIcon.Name = "ConfigIcon" + configIcon.Visible = false + configIcon.Position = UDim2.new 1, -23, 1, -24 + configIcon.Size = UDim2.new 0, 16, 0, 16 + configIcon.Image = "" + configIcon.ZIndex = 6 + configIcon.Parent = insertAssetButtonExample + + return insertAssetButtonExample - insertAssetButtonExample showLargePreview = (insertButton) -> if insertButton\FindFirstChild "AssetId" delay 0, -> - game\GetService"ContentProvider"\Preload LargeThumbnailUrl .. "#{insertButton.AssetId.Value}" - setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl .. "#{insertButton.AssetId.Value}" + game\GetService"ContentProvider"\Preload( + LargeThumbnailUrl .. "#{insertButton.AssetId.Value}" + ) + setGui.SetPanel.ItemPreview.LargePreview.Image = LargeThumbnailUrl .. + "#{insertButton.AssetId.Value}" + if insertButton\FindFirstChild "AssetName" setGui.SetPanel.ItemPreview.TextPanel.RolloverText.Text = insertButton.AssetName.Value + selectTerrainShape = (shape) -> if currTerrainDropDownFrame objectSelected( - tostring(currTerrainDropDownFrame.AssetName.Value), + "#{currTerrainDropDownFrame.AssetName.Value}", tonumber(currTerrainDropDownFrame.AssetId.Value), shape ) + createTerrainTypeButton = (name, parent) -> - dropDownTextButton = New "TextButton", "#{name}Button" - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size14 - BorderSizePixel: 0 - TextColor3: Color3.new 1, 1, 1 - Text: name - TextXAlignment: Enum.TextXAlignment.Left - BackgroundTransparency: 1 - ZIndex: parent.ZIndex + 1 - Size: UDim2.new 0, parent.Size.X.Offset - 2, 0, 16 - Position: UDim2.new 0, 1, 0, 0 + dropDownTextButton = Instance.new "TextButton" + dropDownTextButton.Name = name .. "Button" + dropDownTextButton.Font = Enum.Font.ArialBold + dropDownTextButton.FontSize = Enum.FontSize.Size14 + dropDownTextButton.BorderSizePixel = 0 + dropDownTextButton.TextColor3 = Color3.new 1, 1, 1 + dropDownTextButton.Text = name + dropDownTextButton.TextXAlignment = Enum.TextXAlignment.Left + dropDownTextButton.BackgroundTransparency = 1 + dropDownTextButton.ZIndex = parent.ZIndex + 1 + dropDownTextButton.Size = UDim2.new 0, parent.Size.X.Offset - 2, 0, 16 + dropDownTextButton.Position = UDim2.new 0, 1, 0, 0 - with dropDownTextButton - .MouseEnter\connect -> - .BackgroundTransparency = 0 - .TextColor3 = Color3.new 0, 0, 0 + dropDownTextButton.MouseEnter\connect -> + dropDownTextButton.BackgroundTransparency = 0 + dropDownTextButton.TextColor3 = Color3.new 0, 0, 0 - .MouseLeave\connect -> - .BackgroundTransparency = 1 - .TextColor3 = Color3.new 1, 1, 1 - .MouseButton1Click\connect -> - .BackgroundTransparency = 1 - .TextColor3 = Color3.new 1, 1, 1 - if .Parent and .Parent\IsA "GuiObject" - .Parent.Visible = false + dropDownTextButton.MouseLeave\connect -> + dropDownTextButton.BackgroundTransparency = 1 + dropDownTextButton.TextColor3 = Color3.new 1, 1, 1 + + + dropDownTextButton.MouseButton1Click\connect -> + dropDownTextButton.BackgroundTransparency = 1 + dropDownTextButton.TextColor3 = Color3.new 1, 1, 1 + if dropDownTextButton.Parent and dropDownTextButton.Parent\IsA "GuiObject" + dropDownTextButton.Parent.Visible = false + + selectTerrainShape terrainShapeMap[dropDownTextButton.Text] - selectTerrainShape terrainShapeMap[.Text] dropDownTextButton + createTerrainDropDownMenu = (zIndex) -> - dropDown = New "Frame", "TerrainDropDown" - BackgroundColor3: Color3.new 0, 0, 0 - BorderColor3: Color3.new 1, 0, 0 - Size: UDim2.new 0, 200, 0, 0 - Visible: false - ZIndex: zIndex - Parent: setGui + dropDown = Instance.new "Frame" + dropDown.Name = "TerrainDropDown" + dropDown.BackgroundColor3 = Color3.new 0, 0, 0 + dropDown.BorderColor3 = Color3.new 1, 0, 0 + dropDown.Size = UDim2.new 0, 200, 0, 0 + dropDown.Visible = false + dropDown.ZIndex = zIndex + dropDown.Parent = setGui for i = 1, #terrainShapes shapeButton = createTerrainTypeButton terrainShapes[i], dropDown @@ -2474,27 +2809,31 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position shapeButton.Parent = dropDown dropDown.Size = UDim2.new 0, 200, 0, dropDown.Size.Y.Offset + shapeButton.Size.Y.Offset + dropDown.MouseLeave\connect -> dropDown.Visible = false + createDropDownMenuButton = (parent) -> - dropDownButton = New "ImageButton" - Name: "DropDownButton" - Image: "http://www.roblox.com/asset/?id=67581509" - BackgroundTransparency: 1 - Size: UDim2.new 0, 16, 0, 16 - Position: UDim2.new 1, -24, 0, 6 - ZIndex: parent.ZIndex + 2 - Parent: parent + dropDownButton = Instance.new "ImageButton" + dropDownButton.Name = "DropDownButton" + dropDownButton.Image = "http://www.roblox.com/asset/?id=67581509" + dropDownButton.BackgroundTransparency = 1 + dropDownButton.Size = UDim2.new 0, 16, 0, 16 + dropDownButton.Position = UDim2.new 1, -24, 0, 6 + dropDownButton.ZIndex = parent.ZIndex + 2 + dropDownButton.Parent = parent if not setGui\FindFirstChild "TerrainDropDown" createTerrainDropDownMenu 8 + dropDownButton.MouseButton1Click\connect -> setGui.TerrainDropDown.Visible = true setGui.TerrainDropDown.Position = UDim2.new 0, parent.AbsolutePosition.X, 0, parent.AbsolutePosition.Y currTerrainDropDownFrame = parent + buildInsertButton = -> insertButton = makeInsertAssetButton! insertButton.Name = "InsertAssetButton" @@ -2503,14 +2842,17 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position if Data.Category[Data.CurrentCategory].SetName == "High Scalability" createDropDownMenuButton insertButton - lastEnter = nil + + local lastEnter mouseEnterCon = insertButton.MouseEnter\connect -> lastEnter = insertButton delay 0.1, -> if lastEnter == insertButton showLargePreview insertButton - insertButton, mouseEnterCon + + return insertButton, mouseEnterCon + realignButtonGrid = (columns) -> x = 0 @@ -2522,6 +2864,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position x = 0 y += 1 + setInsertButtonImageBehavior = (insertFrame, visible, name, assetId) -> if visible insertFrame.AssetName.Value = name @@ -2529,36 +2872,42 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position newImageUrl = SmallThumbnailUrl .. assetId if newImageUrl ~= insertFrame.Button.ButtonImage.Image delay 0, -> - game\GetService"ContentProvider"\Preload(SmallThumbnailUrl .. assetId) + game\GetService"ContentProvider"\Preload SmallThumbnailUrl .. assetId insertFrame.Button.ButtonImage.Image = SmallThumbnailUrl .. assetId + table.insert( insertButtonCons, insertFrame.Button.MouseButton1Click\connect -> -- special case for water, show water selection gui - isWaterSelected = name == "Water" and + isWaterSelected = (name == "Water") and (Data.Category[Data.CurrentCategory].SetName == "High Scalability") waterGui.Visible = isWaterSelected - objectSelected name, if isWaterSelected - tonumber(assetId), nil + if isWaterSelected + objectSelected name, tonumber assetId, nil else - tonumber assetId + objectSelected name, tonumber assetId - ) + ) insertFrame.Visible = true else insertFrame.Visible = false + loadSectionOfItems = (setGui, rows, columns) -> pageSize = rows * columns - return if arrayPosition > #contents + if arrayPosition > #contents + return + origArrayPos = arrayPosition for _ = 1, pageSize + 1 - break if arrayPosition >= #contents + 1 + if arrayPosition >= #contents + 1 + break + local buttonCon insertButtons[arrayPosition], buttonCon = buildInsertButton! @@ -2573,22 +2922,27 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position if insertButtons[index] if contents[index] -- we don't want water to have a drop down button - if contents[index].Name == "Water" and - Data.Category[Data.CurrentCategory].SetName == "High Scalability" - insertButtons[index]\FindFirstChild("DropDownButton", true)\Destroy! + if contents[index].Name == "Water" + if Data.Category[Data.CurrentCategory].SetName == "High Scalability" + insertButtons[index]\FindFirstChild("DropDownButton", true)\Destroy! + local assetId - assetId = if useAssetVersionId - contents[index].AssetVersionId + if useAssetVersionId + assetId = contents[index].AssetVersionId else - contents[index].AssetId + assetId = contents[index].AssetId setInsertButtonImageBehavior insertButtons[index], true, contents[index].Name, assetId - else break - else break + else + break + + else + break -- indexCopy = index + setSetIndex = -> Data.Category[Data.CurrentCategory].Index = 0 @@ -2612,88 +2966,99 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position arrayPosition = 1 loadSectionOfItems setGui, rows, columns + selectSet = (button, setName, setId, _) -> - if button and Data.Category[Data.CurrentCategory]? - with Data.Category[Data.CurrentCategory] - if button ~= .Button - .Button = button + if button and Data.Category[Data.CurrentCategory] ~= nil + if button ~= Data.Category[Data.CurrentCategory].Button + Data.Category[Data.CurrentCategory].Button = button - if not SetCache[setId]? - SetCache[setId] = game\GetService"InsertService"\GetCollection setId + if SetCache[setId] == nil + SetCache[setId] = game\GetService"InsertService"\GetCollection setId - .Contents = SetCache[setId] - .SetName = setName - .SetId = setId + Data.Category[Data.CurrentCategory].Contents = SetCache[setId] + + Data.Category[Data.CurrentCategory].SetName = setName + Data.Category[Data.CurrentCategory].SetId = setId setSetIndex! + selectCategoryPage = (buttons, _) -> if buttons ~= Data.CurrentCategory if Data.CurrentCategory for _, button in pairs Data.CurrentCategory button.Visible = false + Data.CurrentCategory = buttons - if not Data.Category[Data.CurrentCategory]? + if Data.Category[Data.CurrentCategory] == nil Data.Category[Data.CurrentCategory] = {} if #buttons > 0 - selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0) + selectSet buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0 - else with Data.Category[Data.CurrentCategory] - .Button = nil + else + Data.Category[Data.CurrentCategory].Button = nil selectSet( - .ButtonFrame, - .SetName, - .SetId, - .Index + Data.Category[Data.CurrentCategory].ButtonFrame, + Data.Category[Data.CurrentCategory].SetName, + Data.Category[Data.CurrentCategory].SetId, + Data.Category[Data.CurrentCategory].Index ) + selectCategory = (category) -> selectCategoryPage category, 0 + resetAllSetButtonSelection = -> setButtons = setGui.SetPanel.Sets.SetsLists\GetChildren! for i = 1, #setButtons - with setButtons[i] do if \IsA "TextButton" - .Selected = false - .BackgroundTransparency = 1 - .TextColor3 = Color3.new 1, 1, 1 - .BackgroundColor3 = Color3.new 1, 1, 1 + if setButtons[i]\IsA "TextButton" + setButtons[i].Selected = false + setButtons[i].BackgroundTransparency = 1 + setButtons[i].TextColor3 = Color3.new 1, 1, 1 + setButtons[i].BackgroundColor3 = Color3.new 1, 1, 1 + populateSetsFrame = -> currRow = 0 - - for i = 1, #userCategoryButtons do with button = userCategoryButtons[i] - .Visible = true - .Position = UDim2.new 0, 5, 0, currRow * .Size.Y.Offset - .Parent = setGui.SetPanel.Sets.SetsLists + for i = 1, #userCategoryButtons + button = userCategoryButtons[i] + button.Visible = true + button.Position = UDim2.new 0, 5, 0, currRow * button.Size.Y.Offset + button.Parent = setGui.SetPanel.Sets.SetsLists if i == 1 -- we will have this selected by default, so show it - .Selected = true - .BackgroundColor3 = Color3.new 0, 204 / 255, 0 - .TextColor3 = Color3.new 0, 0, 0 - .BackgroundTransparency = 0 + button.Selected = true + button.BackgroundColor3 = Color3.new 0, 204 / 255, 0 + button.TextColor3 = Color3.new 0, 0, 0 + button.BackgroundTransparency = 0 - .MouseEnter\connect -> - if not .Selected - .BackgroundTransparency = 0 - .TextColor3 = Color3.new 0, 0, 0 - .MouseLeave\connect -> - if not .Selected - .BackgroundTransparency = 1 - .TextColor3 = Color3.new 1, 1, 1 + button.MouseEnter\connect -> + if not button.Selected + button.BackgroundTransparency = 0 + button.TextColor3 = Color3.new 0, 0, 0 - .MouseButton1Click\connect -> + + button.MouseLeave\connect -> + if not button.Selected + button.BackgroundTransparency = 1 + button.TextColor3 = Color3.new 1, 1, 1 + + + button.MouseButton1Click\connect -> resetAllSetButtonSelection! - .Selected = not .Selected - .BackgroundColor3 = Color3.new 0, 204 / 255, 0 - .TextColor3 = Color3.new 0, 0, 0 - .BackgroundTransparency = 0 - selectSet button, .Text, userCategoryButtons[i].SetId.Value, 0 + button.Selected = not button.Selected + button.BackgroundColor3 = Color3.new 0, 204 / 255, 0 + button.TextColor3 = Color3.new 0, 0, 0 + button.BackgroundTransparency = 0 + selectSet button, button.Text, userCategoryButtons[i].SetId.Value, 0 + currRow += 1 + buttons = setGui.SetPanel.Sets.SetsLists\GetChildren! -- set first category as loaded for default @@ -2704,6 +3069,7 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position selectCategory userCategoryButtons break + setGui = createSetGui! waterGui, waterTypeChangedEvent = createWaterGui! waterGui.Position = UDim2.new 0, 55, 0, 0 @@ -2713,14 +3079,14 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position handleResize! setSetIndex! + scrollFrame, controlFrame = t.CreateTrueScrollingFrame! - with scrollFrame - .Name = "ItemsFrame" - .Size = UDim2.new 0.54, 0, 0.85, 0 - .Position = UDim2.new 0.24, 0, 0.085, 0 - .ZIndex = 6 - .Parent = setGui.SetPanel - .BackgroundTransparency = 1 + scrollFrame.Size = UDim2.new 0.54, 0, 0.85, 0 + scrollFrame.Position = UDim2.new 0.24, 0, 0.085, 0 + scrollFrame.Name = "ItemsFrame" + scrollFrame.ZIndex = 6 + scrollFrame.Parent = setGui.SetPanel + scrollFrame.BackgroundTransparency = 1 drillDownSetZIndex controlFrame, 7 @@ -2728,48 +3094,62 @@ t.CreateSetPanel = (userIdsForSets, objectSelected, dialogClosed, size, position controlFrame.Position = UDim2.new 0.76, 5, 0, 0 debounce = false - - rows = math.floor setGui.SetPanel.ItemsFrame.AbsoluteSize.Y / buttonHeight - columns = math.floor setGui.SetPanel.ItemsFrame.AbsoluteSize.X / buttonWidth - controlFrame.ScrollBottom.Changed\connect (_) -> if controlFrame.ScrollBottom.Value == true - return if debounce + if debounce + return debounce = true loadSectionOfItems setGui, rows, columns debounce = false + userData = {} for id = 1, #userIdsForSets newUserData = game\GetService"InsertService"\GetUserSets userIdsForSets[id] if newUserData and #newUserData > 2 -- start at #3 to skip over My Decals and My Models for each account for category = 3, #newUserData - table.insert userData, if newUserData[category].Name == "High Scalability" -- we want high scalability parts to show first - 1, newUserData[category] + if newUserData[category].Name == "High Scalability" -- we want high scalability parts to show first + table.insert userData, 1, newUserData[category] else - newUserData[category] + table.insert userData, newUserData[category] + if userData userCategoryButtons = processCategory userData + + global rows = math.floor setGui.SetPanel.ItemsFrame.AbsoluteSize.Y / buttonHeight + global columns = math.floor setGui.SetPanel.ItemsFrame.AbsoluteSize.X / buttonWidth + populateSetsFrame! --[[insertPanelCloseCon = ]] setGui.SetPanel.CancelButton.MouseButton1Click\connect -> setGui.SetPanel.Visible = false - dialogClosed?! + if dialogClosed + dialogClosed! + setVisibilityFunction = (visible) -> - setGui.SetPanel.Visible = not not visible + if visible + setGui.SetPanel.Visible = true + else + setGui.SetPanel.Visible = false + getVisibilityFunction = -> - if setGui?\FindFirstChild "SetPanel" - return setGui.SetPanel.Visible - false + if setGui + if setGui\FindFirstChild "SetPanel" + return setGui.SetPanel.Visible + + + return false + + + return setGui, setVisibilityFunction, getVisibilityFunction, waterTypeChangedEvent - setGui, setVisibilityFunction, getVisibilityFunction, waterTypeChangedEvent t.CreateTerrainMaterialSelector = (size, position) -> terrainMaterialSelectionChanged = Instance.new "BindableEvent" @@ -2777,113 +3157,204 @@ t.CreateTerrainMaterialSelector = (size, position) -> local selectedButton - frame = New "Frame", "TerrainMaterialSelector" - Size: size or UDim2.new 0, 245, 0, 230 - BorderSizePixel: 0 - BackgroundColor3: Color3.new 0, 0, 0 - Active: true + frame = Instance.new "Frame" + frame.Name = "TerrainMaterialSelector" + if size + frame.Size = size + else + frame.Size = UDim2.new 0, 245, 0, 230 if position frame.Position = position + frame.BorderSizePixel = 0 + frame.BackgroundColor3 = Color3.new 0, 0, 0 + frame.Active = true + terrainMaterialSelectionChanged.Parent = frame - -- waterEnabled = true -- todo: turn this on when water is ready + waterEnabled = true -- todo: turn this on when water is ready materialToImageMap = {} - materialNames = - * "Grass" - * "Sand" - * "Brick" - * "Granite" - * "Asphalt" - * "Iron" - * "Aluminum" - * "Gold" - * "Plank" - * "Log" - * "Gravel" - * "Cinder Block" - * "Stone Wall" - * "Concrete" - * "Plastic (red)" - * "Plastic (blue)" - * "Water" - -- if waterEnabled - -- table.insert materialNames, "Water" + materialNames = { + "Grass", + "Sand", + "Brick", + "Granite", + "Asphalt", + "Iron", + "Aluminum", + "Gold", + "Plank", + "Log", + "Gravel", + "Cinder Block", + "Stone Wall", + "Concrete", + "Plastic (red)", + "Plastic (blue)", + } + if waterEnabled + table.insert materialNames, "Water" currentMaterial = 1 getEnumFromName = (choice) -> - for i, v in ipairs materialNames - return i if v == choice + if choice == "Grass" + return 1 + + if choice == "Sand" + return 2 + + if choice == "Erase" + return 0 + + if choice == "Brick" + return 3 + + if choice == "Granite" + return 4 + + if choice == "Asphalt" + return 5 + + if choice == "Iron" + return 6 + + if choice == "Aluminum" + return 7 + + if choice == "Gold" + return 8 + + if choice == "Plank" + return 9 + + if choice == "Log" + return 10 + + if choice == "Gravel" + return 11 + + if choice == "Cinder Block" + return 12 + + if choice == "Stone Wall" + return 13 + + if choice == "Concrete" + return 14 + + if choice == "Plastic (red)" + return 15 + + if choice == "Plastic (blue)" + return 16 + + if choice == "Water" + return 17 + getNameFromEnum = (choice) -> - switch choice - when Enum.CellMaterial.Grass, 1 then "Grass" - when Enum.CellMaterial.Sand, 2 then "Sand" - when Enum.CellMaterial.Empty, 0 then "Erase" - when Enum.CellMaterial.Brick, 3 then "Brick" - when Enum.CellMaterial.Granite, 4 then "Granite" - when Enum.CellMaterial.Asphalt, 5 then "Asphalt" - when Enum.CellMaterial.Iron, 6 then "Iron" - when Enum.CellMaterial.Aluminum, 7 then "Aluminum" - when Enum.CellMaterial.Gold, 8 then "Gold" - when Enum.CellMaterial.WoodPlank, 9 then "Plank" - when Enum.CellMaterial.WoodLog, 10 then "Log" - when Enum.CellMaterial.Gravel, 11 then "Gravel" - when Enum.CellMaterial.CinderBlock, 12 then "Cinder Block" - when Enum.CellMaterial.MossyStone, 13 then "Stone Wall" - when Enum.CellMaterial.Cement, 14 then "Concrete" - when Enum.CellMaterial.RedPlastic, 15 then "Plastic (red)" - when Enum.CellMaterial.BluePlastic, 16 then "Plastic (blue)" - when Enum.CellMaterial.Water, 17 then "Water" + if choice == Enum.CellMaterial.Grass or choice == 1 + return "Grass" + elseif choice == Enum.CellMaterial.Sand or choice == 2 + return "Sand" + elseif choice == Enum.CellMaterial.Empty or choice == 0 + return "Erase" + elseif choice == Enum.CellMaterial.Brick or choice == 3 + return "Brick" + elseif choice == Enum.CellMaterial.Granite or choice == 4 + return "Granite" + elseif choice == Enum.CellMaterial.Asphalt or choice == 5 + return "Asphalt" + elseif choice == Enum.CellMaterial.Iron or choice == 6 + return "Iron" + elseif choice == Enum.CellMaterial.Aluminum or choice == 7 + return "Aluminum" + elseif choice == Enum.CellMaterial.Gold or choice == 8 + return "Gold" + elseif choice == Enum.CellMaterial.WoodPlank or choice == 9 + return "Plank" + elseif choice == Enum.CellMaterial.WoodLog or choice == 10 + return "Log" + elseif choice == Enum.CellMaterial.Gravel or choice == 11 + return "Gravel" + elseif choice == Enum.CellMaterial.CinderBlock or choice == 12 + return "Cinder Block" + elseif choice == Enum.CellMaterial.MossyStone or choice == 13 + return "Stone Wall" + elseif choice == Enum.CellMaterial.Cement or choice == 14 + return "Concrete" + elseif choice == Enum.CellMaterial.RedPlastic or choice == 15 + return "Plastic (red)" + elseif choice == Enum.CellMaterial.BluePlastic or choice == 16 + return "Plastic (blue)" + + + if waterEnabled + if choice == Enum.CellMaterial.Water or choice == 17 + return "Water" + updateMaterialChoice = (choice) -> currentMaterial = getEnumFromName choice terrainMaterialSelectionChanged\Fire currentMaterial + -- we so need a better way to do this for _, v in pairs materialNames materialToImageMap[v] = {} - materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=#{switch v - when "Grass" then 56563112 - when "Sand" then 62356652 - when "Brick" then 65961537 - when "Granite" then 67532153 - when "Asphalt" then 67532038 - when "Iron" then 67532093 - when "Aluminum" then 67531995 - when "Gold" then 67532118 - when "Plastic (red)" then 67531848 - when "Plastic (blue)" then 67531924 - when "Plank" then 67532015 - when "Log" then 67532051 - when "Gravel" then 67532206 - when "Cinder Block" then 67532103 - when "Stone Wall" then 67531804 - when "Concrete" then 67532059 - when "Water" then 81407474 - else 66887593}" + if v == "Grass" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=56563112" + elseif v == "Sand" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=62356652" + elseif v == "Brick" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=65961537" + elseif v == "Granite" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532153" + elseif v == "Asphalt" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532038" + elseif v == "Iron" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532093" + elseif v == "Aluminum" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67531995" + elseif v == "Gold" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532118" + elseif v == "Plastic (red)" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67531848" + elseif v == "Plastic (blue)" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67531924" + elseif v == "Plank" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532015" + elseif v == "Log" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532051" + elseif v == "Gravel" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532206" + elseif v == "Cinder Block" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532103" + elseif v == "Stone Wall" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67531804" + elseif v == "Concrete" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=67532059" + elseif v == "Water" + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=81407474" + else + materialToImageMap[v].Regular = "http://www.roblox.com/asset/?id=66887593" -- fill in the rest here!! - -- fill in the rest here!! scrollFrame, scrollUp, scrollDown, recalculateScroll = t.CreateScrollingFrame nil, "grid" + scrollFrame.Size = UDim2.new 0.85, 0, 1, 0 + scrollFrame.Position = UDim2.new 0, 0, 0, 0 + scrollFrame.Parent = frame - with scrollFrame - .Size = UDim2.new 0.85, 0, 1, 0 - .Position = UDim2.new 0, 0, 0, 0 - .Parent = frame + scrollUp.Parent = frame + scrollUp.Visible = true + scrollUp.Position = UDim2.new 1, -19, 0, 0 - with scrollUp - .Parent = frame - .Visible = true - .Position = UDim2.new 1, -19, 0, 0 - - with scrollDown - .Parent = frame - .Visible = true - .Position = UDim2.new 1, -19, 1, -17 + scrollDown.Parent = frame + scrollDown.Visible = true + scrollDown.Position = UDim2.new 1, -19, 1, -17 goToNewMaterial = (buttonWrap, materialName) -> updateMaterialChoice materialName @@ -2891,252 +3362,283 @@ t.CreateTerrainMaterialSelector = (size, position) -> selectedButton.BackgroundTransparency = 1 selectedButton = buttonWrap + createMaterialButton = (name) -> - buttonWrap = New "TextButton", "#{name}" - Text: "" - Size: UDim2.new 0, 32, 0, 32 - BackgroundColor3: Color3.new 1, 1, 1 - BorderSizePixel: 0 - BackgroundTransparency: 1 - AutoButtonColor: false + buttonWrap = Instance.new "TextButton" + buttonWrap.Text = "" + buttonWrap.Size = UDim2.new 0, 32, 0, 32 + buttonWrap.BackgroundColor3 = Color3.new 1, 1, 1 + buttonWrap.BorderSizePixel = 0 + buttonWrap.BackgroundTransparency = 1 + buttonWrap.AutoButtonColor = false + buttonWrap.Name = "#{name}" - * New "ImageButton", "#{name}" - AutoButtonColor: false - BackgroundTransparency: 1 - Size: UDim2.new 0, 30, 0, 30 - Position: UDim2.new 0, 1, 0, 1 - Image: materialToImageMap[name].Regular + imageButton = Instance.new "ImageButton" + imageButton.AutoButtonColor = false + imageButton.BackgroundTransparency = 1 + imageButton.Size = UDim2.new 0, 30, 0, 30 + imageButton.Position = UDim2.new 0, 1, 0, 1 + imageButton.Name = "#{name}" + imageButton.Parent = buttonWrap + imageButton.Image = materialToImageMap[name].Regular - * New "NumberValue", "EnumType" - Value: 0 + enumType = Instance.new "NumberValue" + enumType.Name = "EnumType" + enumType.Parent = buttonWrap + enumType.Value = 0 - with buttonWrap.ImageButton - .MouseEnter\connect -> - buttonWrap.BackgroundTransparency = 0 - .MouseLeave\connect -> - if selectedButton ~= buttonWrap - buttonWrap.BackgroundTransparency = 1 - .MouseButton1Click\connect -> - if selectedButton ~= buttonWrap - goToNewMaterial buttonWrap, tostring name + imageButton.MouseEnter\connect -> + buttonWrap.BackgroundTransparency = 0 + + imageButton.MouseLeave\connect -> + if selectedButton ~= buttonWrap + buttonWrap.BackgroundTransparency = 1 + + + imageButton.MouseButton1Click\connect -> + if selectedButton ~= buttonWrap + goToNewMaterial buttonWrap, "#{name}" + + + return buttonWrap - buttonWrap for i = 1, #materialNames imageButton = createMaterialButton materialNames[i] - if materialNames[i] == "Grass" then -- always start with grass as the default + if materialNames[i] == "Grass" -- always start with grass as the default selectedButton = imageButton imageButton.BackgroundTransparency = 0 + imageButton.Parent = scrollFrame - forceTerrainMaterialSelection = (newMaterialType) -> - return if not newMaterialType - return if currentMaterial == newMaterialType - matName = getNameFromEnum newMaterialType + forceTerrainMaterialSelection = (newMaterialType) -> + if not newMaterialType + return + + if currentMaterial == newMaterialType + return + + + matName = getNameFromEnum newMaterialType buttons = scrollFrame\GetChildren! for i = 1, #buttons - if (buttons[i].Name == "Plastic (blue)" and matName == "Plastic (blue)") or - (buttons[i].Name == "Plastic (red)" and matName == "Plastic (red)") or - (string.find buttons[i].Name, matName) + if buttons[i].Name == "Plastic (blue)" and matName == "Plastic (blue)" goToNewMaterial buttons[i], matName return + if buttons[i].Name == "Plastic (red)" and matName == "Plastic (red)" + goToNewMaterial buttons[i], matName + return + + if string.find buttons[i].Name, matName + goToNewMaterial buttons[i], matName + return + + frame.Changed\connect (prop) -> if prop == "AbsoluteSize" recalculateScroll! + recalculateScroll! frame, terrainMaterialSelectionChanged, forceTerrainMaterialSelection + t.CreateLoadingFrame = (name, size, position) -> game\GetService"ContentProvider"\Preload "http://www.roblox.com/asset/?id=35238053" - loadingFrame = New "Frame", "LoadingFrame" - Style: Enum.FrameStyle.RobloxRound - Size: size or UDim2.new 0, 300, 0, 160 - Position: position or UDim2.new 0.5, -150, 0.5, -80 + loadingFrame = Instance.new "Frame" + loadingFrame.Name = "LoadingFrame" + loadingFrame.Style = Enum.FrameStyle.RobloxRound - * New "TextLabel", "loadingName" - BackgroundTransparency: 1 - Size: UDim2.new 1, 0, 0, 18 - Position: UDim2.new 0, 0, 0, 2 - Font: Enum.Font.Arial - Text: name - TextColor3: Color3.new 1, 1, 1 - TextStrokeTransparency: 1 - FontSize: Enum.FontSize.Size18 + if size + loadingFrame.Size = size + else + loadingFrame.Size = UDim2.new 0, 300, 0, 160 - * New "TextButton", "CancelButton" - Position: UDim2.new 0.5, -60, 1, -40 - Size: UDim2.new 0, 120, 0, 40 - Font: Enum.Font.Arial - FontSize: Enum.FontSize.Size18 - TextColor3: Color3.new 1, 1, 1 - Text: "Cancel" - Style: Enum.ButtonStyle.RobloxButton + if position + loadingFrame.Position = position + else + loadingFrame.Position = UDim2.new 0.5, -150, 0.5, -80 - * New "Frame", "LoadingBar" - BackgroundColor3: Color3.new 0, 0, 0 - BorderColor3: Color3.new 79 / 255, 79 / 255, 79 / 255 - Position: UDim2.new 0, 0, 0, 41 - Size: UDim2.new 1, 0, 0, 30 - * New "ImageLabel", "LoadingGreenBar" - Image: "http://www.roblox.com/asset/?id=35238053" - Position: UDim2.new 0, 0, 0, 0 - Size: UDim2.new 0, 0, 1, 0 - Visible: false + loadingBar = Instance.new "Frame" + loadingBar.Name = "LoadingBar" + loadingBar.BackgroundColor3 = Color3.new 0, 0, 0 + loadingBar.BorderColor3 = Color3.new 79 / 255, 79 / 255, 79 / 255 + loadingBar.Position = UDim2.new 0, 0, 0, 41 + loadingBar.Size = UDim2.new 1, 0, 0, 30 + loadingBar.Parent = loadingFrame - * New "TextLabel", "LoadingPercent" - BackgroundTransparency: 1 - Position: UDim2.new 0, 0, 1, 0 - Size: UDim2.new 1, 0, 0, 14 - Font: Enum.Font.Arial - Text: "0%" - FontSize: Enum.FontSize.Size14 - TextColor3: Color3.new 1, 1, 1 + loadingGreenBar = Instance.new "ImageLabel" + loadingGreenBar.Name = "LoadingGreenBar" + loadingGreenBar.Image = "http://www.roblox.com/asset/?id=35238053" + loadingGreenBar.Position = UDim2.new 0, 0, 0, 0 + loadingGreenBar.Size = UDim2.new 0, 0, 1, 0 + loadingGreenBar.Visible = false + loadingGreenBar.Parent = loadingBar - { -- Destructure - CancelButton: cancelButton - LoadingBar: - LoadingGreenBar: loadingGreenBar - LoadingPercent: loadingPercent - } = loadingFrame + loadingPercent = Instance.new "TextLabel" + loadingPercent.Name = "LoadingPercent" + loadingPercent.BackgroundTransparency = 1 + loadingPercent.Position = UDim2.new 0, 0, 1, 0 + loadingPercent.Size = UDim2.new 1, 0, 0, 14 + loadingPercent.Font = Enum.Font.Arial + loadingPercent.Text = "0%" + loadingPercent.FontSize = Enum.FontSize.Size14 + loadingPercent.TextColor3 = Color3.new 1, 1, 1 + loadingPercent.Parent = loadingBar - cancelButtonClicked = New "BindableEvent", "CancelButtonClicked" - Parent: cancelButton + cancelButton = Instance.new "TextButton" + cancelButton.Name = "CancelButton" + cancelButton.Position = UDim2.new 0.5, -60, 1, -40 + cancelButton.Size = UDim2.new 0, 120, 0, 40 + cancelButton.Font = Enum.Font.Arial + cancelButton.FontSize = Enum.FontSize.Size18 + cancelButton.TextColor3 = Color3.new 1, 1, 1 + cancelButton.Text = "Cancel" + cancelButton.Style = Enum.ButtonStyle.RobloxButton + cancelButton.Parent = loadingFrame + loadingName = Instance.new "TextLabel" + loadingName.Name = "loadingName" + loadingName.BackgroundTransparency = 1 + loadingName.Size = UDim2.new 1, 0, 0, 18 + loadingName.Position = UDim2.new 0, 0, 0, 2 + loadingName.Font = Enum.Font.Arial + loadingName.Text = name + loadingName.TextColor3 = Color3.new 1, 1, 1 + loadingName.TextStrokeTransparency = 1 + loadingName.FontSize = Enum.FontSize.Size18 + loadingName.Parent = loadingFrame + + cancelButtonClicked = Instance.new "BindableEvent" + cancelButtonClicked.Name = "CancelButtonClicked" + cancelButtonClicked.Parent = cancelButton cancelButton.MouseButton1Click\connect -> cancelButtonClicked\Fire! - updateLoadingGuiPercent = (percent, tweenAction, tweenLength) -> - if percent and type(percent) ~= "number" - error "updateLoadingGuiPercent expects number as argument, got", type(percent), "instead" - newSize = UDim2.new if percent < 0 - 0, 0, 1, 0 + updateLoadingGuiPercent = (percent, tweenAction, tweenLength) -> + if percent and type percent ~= "number" + error "updateLoadingGuiPercent expects number as argument, got #{type percent} instead" + + + local newSize + if percent < 0 + newSize = UDim2.new 0, 0, 1, 0 elseif percent > 1 - 1, 0, 1, 0 + newSize = UDim2.new 1, 0, 1, 0 else - percent, 0, 1, 0 + newSize = UDim2.new percent, 0, 1, 0 + if tweenAction if not tweenLength error "updateLoadingGuiPercent is set to tween new percentage, but got no tween time length! Please pass this in as third argument" - loadingGreenBar\TweenSize newSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenLength, - if newSize.X.Scale > 0 - loadingGreenBar.Visible = true - true - else - true, -> + + if newSize.X.Scale > 0 + loadingGreenBar.Visible = true + loadingGreenBar\TweenSize newSize, Enum.EasingDirection.Out, Enum.EasingStyle.Quad, tweenLength, true + else + loadingGreenBar\TweenSize( + newSize, + Enum.EasingDirection.Out, + Enum.EasingStyle.Quad, + tweenLength, + true, + -> if newSize.X.Scale < 0 loadingGreenBar.Visible = false + + ) + else loadingGreenBar.Size = newSize - loadingGreenBar.Visible = newSize.X.Scale > 0 + loadingGreenBar.Visible = (newSize.X.Scale > 0) loadingGreenBar.Changed\connect (prop) -> if prop == "Size" loadingPercent.Text = "#{math.ceil loadingGreenBar.Size.X.Scale * 100}%" + loadingFrame, updateLoadingGuiPercent, cancelButtonClicked + t.CreatePluginFrame = (name, size, position, scrollable, parent) -> createMenuButton = (size, position, text, fontsize, name, parent) -> - with New "TextButton", name, - AutoButtonColor: false - BackgroundTransparency: 1 - Position: position - Size: size - Font: Enum.Font.ArialBold - FontSize: fontsize - Text: text - TextColor3: Color3.new 1, 1, 1 - BorderSizePixel: 0 - BackgroundColor3: Color3.new 20 / 255, 20 / 255, 20 / 255 + button = Instance.new "TextButton" + button.AutoButtonColor = false + button.Name = name + button.BackgroundTransparency = 1 + button.Position = position + button.Size = size + button.Font = Enum.Font.ArialBold + button.FontSize = fontsize + button.Text = text + button.TextColor3 = Color3.new 1, 1, 1 + button.BorderSizePixel = 0 + button.BackgroundColor3 = Color3.new 20 / 255, 20 / 255, 20 / 255 - .MouseEnter\connect -> - return if .Selected - .BackgroundTransparency = 0 + button.MouseEnter\connect -> + if button.Selected + return - .MouseLeave\connect -> - return if .Selected - .BackgroundTransparency = 1 + button.BackgroundTransparency = 0 - .Parent = parent + button.MouseLeave\connect -> + if button.Selected + return - dragBar = New "Frame", "#{name}DragBar" - BackgroundColor3: Color3.new 39 / 255, 39 / 255, 39 / 255 - BorderColor3: Color3.new 0, 0, 0 - Size: if size - UDim2.new(size.X.Scale, size.X.Offset, 0, 20) + UDim2.new 0, 20, 0, 0 - else - UDim2.new 0, 183, 0, 20 - Active: true - Draggable: true + button.BackgroundTransparency = 1 - -- plugin name label - * New "TextLabel", "BarNameLabel" - Text: " #{name}" - TextColor3: Color3.new 1, 1, 1 - TextStrokeTransparency: 0 - Size: UDim2.new 1, 0, 1, 0 - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size18 - TextXAlignment: Enum.TextXAlignment.Left - BackgroundTransparency: 1 - * New "Frame", "HelpFrame" - BackgroundColor3: Color3.new 0, 0, 0 - Size: UDim2.new 0, 300, 0, 552 - Position: UDim2.new 1, 5, 0, 0 - Active: true - BorderSizePixel: 0 - Visible: false + button.Parent = parent - * New "Frame", "SeparatingLine" - BackgroundColor3: Color3.new 115 / 255, 115 / 255, 115 / 255 - BorderSizePixel: 0 - Position: UDim2.new 1, -18, 0.5, -7 - Size: UDim2.new 0, 1, 0, 14 + button - * New "Frame", "MinimizeFrame" - BackgroundColor3: Color3.new 73 / 255, 73 / 255, 73 / 255 - BorderColor3: Color3.new 0, 0, 0 - Position: UDim2.new 0, 0, 1, 0 - Size: if size - UDim2.new(size.X.Scale, size.X.Offset, 0, 50) + UDim2.new 0, 20, 0, 0 - else - UDim2.new 0, 183, 0, 50 - Visible: false - * New "TextButton", "MinimizeButton" - Position: UDim2.new 0.5, -50, 0.5, -20 - Size: UDim2.new 0, 100, 0, 40 - Style: Enum.ButtonStyle.RobloxButton - Font: Enum.Font.ArialBold - FontSize: Enum.FontSize.Size18 - TextColor3: Color3.new 1, 1, 1 - Text: "Show" + dragBar = Instance.new "Frame" + dragBar.Name = "#{name}" .. "DragBar" + dragBar.BackgroundColor3 = Color3.new 39 / 255, 39 / 255, 39 / 255 + dragBar.BorderColor3 = Color3.new 0, 0, 0 + if size + dragBar.Size = UDim2.new(size.X.Scale, size.X.Offset, 0, 20) + UDim2.new 0, 20, 0, 0 + else + dragBar.Size = UDim2.new 0, 183, 0, 20 - with dragBar - if position - .Position = position + if position + dragBar.Position = position - --.Visible = false - .MouseEnter\connect -> - .BackgroundColor3 = Color3.new 49 / 255, 49 / 255, 49 / 255 + dragBar.Active = true + dragBar.Draggable = true + --dragBar.Visible = false + dragBar.MouseEnter\connect -> + dragBar.BackgroundColor3 = Color3.new 49 / 255, 49 / 255, 49 / 255 - .MouseLeave\connect -> - .BackgroundColor3 = Color3.new 39 / 255, 39 / 255, 39 / 255 + dragBar.MouseLeave\connect -> + dragBar.BackgroundColor3 = Color3.new 39 / 255, 39 / 255, 39 / 255 - .Parent = parent + dragBar.Parent = parent + + -- plugin name label + pluginNameLabel = Instance.new "TextLabel" + pluginNameLabel.Name = "BarNameLabel" + pluginNameLabel.Text = " " .. "#{name}" + pluginNameLabel.TextColor3 = Color3.new 1, 1, 1 + pluginNameLabel.TextStrokeTransparency = 0 + pluginNameLabel.Size = UDim2.new 1, 0, 1, 0 + pluginNameLabel.Font = Enum.Font.ArialBold + pluginNameLabel.FontSize = Enum.FontSize.Size18 + pluginNameLabel.TextXAlignment = Enum.TextXAlignment.Left + pluginNameLabel.BackgroundTransparency = 1 + pluginNameLabel.Parent = dragBar -- close button closeButton = createMenuButton( @@ -3147,13 +3649,14 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> "CloseButton", dragBar ) - closeEvent = New "BindableEvent", "CloseEvent" - Parent: closeButton - + closeEvent = Instance.new "BindableEvent" + closeEvent.Name = "CloseEvent" + closeEvent.Parent = closeButton closeButton.MouseButton1Click\connect -> closeEvent\Fire! closeButton.BackgroundTransparency = 1 + -- help button helpButton = createMenuButton( UDim2.new(0, 15, 0, 17), @@ -3163,14 +3666,15 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> "HelpButton", dragBar ) - - { -- Destructure - HelpFrame: helpFrame - SeparatingLine: separatingLine - MinimizeFrame: minimizeFrame - MinimizeFrame: - MinimizeBigButton: minimizeBigButton - } = dragBar + helpFrame = Instance.new "Frame" + helpFrame.Name = "HelpFrame" + helpFrame.BackgroundColor3 = Color3.new 0, 0, 0 + helpFrame.Size = UDim2.new 0, 300, 0, 552 + helpFrame.Position = UDim2.new 1, 5, 0, 0 + helpFrame.Active = true + helpFrame.BorderSizePixel = 0 + helpFrame.Visible = false + helpFrame.Parent = dragBar helpButton.MouseButton1Click\connect -> helpFrame.Visible = not helpFrame.Visible @@ -3186,10 +3690,12 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> else helpFrame.Position = UDim2.new 1, 5, 0, 0 + else helpButton.Selected = false helpButton.BackgroundTransparency = 1 + minimizeButton = createMenuButton( UDim2.new(0, 16, 0, 17), UDim2.new(1, -34, 0.5, -8), @@ -3200,38 +3706,47 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> ) minimizeButton.TextYAlignment = Enum.TextYAlignment.Top - with separatingLine\clone! - .Position = UDim2.new 1, -35, 0.5, -7 - .Parent = dragBar + minimizeFrame = Instance.new "Frame" + minimizeFrame.Name = "MinimizeFrame" + minimizeFrame.BackgroundColor3 = Color3.new 73 / 255, 73 / 255, 73 / 255 + minimizeFrame.BorderColor3 = Color3.new 0, 0, 0 + minimizeFrame.Position = UDim2.new 0, 0, 1, 0 + if size + minimizeFrame.Size = UDim2.new(size.X.Scale, size.X.Offset, 0, 50) + UDim2.new 0, 20, 0, 0 + else + minimizeFrame.Size = UDim2.new 0, 183, 0, 50 - widgetContainer = New "Frame", "WidgetContainer" - BackgroundTransparency: 1 - Position: UDim2.new 0, 0, 1, 0 - BorderColor3: Color3.new 0, 0, 0 + minimizeFrame.Visible = false + minimizeFrame.Parent = dragBar - * New "TextButton", "VerticalDragger" - ZIndex: 2 - AutoButtonColor: false - BackgroundColor3: Color3.new 50 / 255, 50 / 255, 50 / 255 - BorderColor3: Color3.new 0, 0, 0 - Size: UDim2.new 1, 20, 0, 20 - Position: UDim2.new 0, 0, 1, 0 - Active: true - Text: "" + minimizeBigButton = Instance.new "TextButton" + minimizeBigButton.Position = UDim2.new 0.5, -50, 0.5, -20 + minimizeBigButton.Name = "MinimizeButton" + minimizeBigButton.Size = UDim2.new 0, 100, 0, 40 + minimizeBigButton.Style = Enum.ButtonStyle.RobloxButton + minimizeBigButton.Font = Enum.Font.ArialBold + minimizeBigButton.FontSize = Enum.FontSize.Size18 + minimizeBigButton.TextColor3 = Color3.new 1, 1, 1 + minimizeBigButton.Text = "Show" + minimizeBigButton.Parent = minimizeFrame - * New "Frame", "ScrubFrame" - BackgroundColor3: Color3.new 1, 1, 1 - BorderSizePixel: 0 - Position: UDim2.new 0.5, -5, 0.5, 0 - Size: UDim2.new 0, 10, 0, 1 - ZIndex: 5 + separatingLine = Instance.new "Frame" + separatingLine.Name = "SeparatingLine" + separatingLine.BackgroundColor3 = Color3.new 115 / 255, 115 / 255, 115 / 255 + separatingLine.BorderSizePixel = 0 + separatingLine.Position = UDim2.new 1, -18, 0.5, -7 + separatingLine.Size = UDim2.new 0, 1, 0, 14 + separatingLine.Parent = dragBar - { -- Destructure - VerticalDragger: verticalDragger - VerticalDragger: - ScrubFrame: scrubFrame - } = widgetContainer + otherSeparatingLine = separatingLine\clone! + otherSeparatingLine.Position = UDim2.new 1, -35, 0.5, -7 + otherSeparatingLine.Parent = dragBar + widgetContainer = Instance.new "Frame" + widgetContainer.Name = "WidgetContainer" + widgetContainer.BackgroundTransparency = 1 + widgetContainer.Position = UDim2.new 0, 0, 1, 0 + widgetContainer.BorderColor3 = Color3.new 0, 0, 0 if not scrollable widgetContainer.BackgroundTransparency = 0 widgetContainer.BackgroundColor3 = Color3.new 72 / 255, 72 / 255, 72 / 255 @@ -3239,87 +3754,114 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> widgetContainer.Parent = dragBar if size - widgetContainer.Size = if scrollable - size + if scrollable + widgetContainer.Size = size else - UDim2.new 0, dragBar.AbsoluteSize.X, size.Y.Scale, size.Y.Offset + widgetContainer.Size = UDim2.new 0, dragBar.AbsoluteSize.X, size.Y.Scale, size.Y.Offset else - widgetContainer.Size = UDim2.new if scrollable - 0, 163, 0, 400 + if scrollable + widgetContainer.Size = UDim2.new 0, 163, 0, 400 else - 0, dragBar.AbsoluteSize.X, 0, 400 + widgetContainer.Size = UDim2.new 0, dragBar.AbsoluteSize.X, 0, 400 + if position - widgetContainer.Position = position + UDim2.new 0, 0, 0, 20 + widgetContainer.Position += UDim2.new 0, 0, 0, 20 - local frame, control + + local frame, control, verticalDragger if scrollable --frame for widgets frame, control = t.CreateTrueScrollingFrame! + frame.Size = UDim2.new 1, 0, 1, 0 + frame.BackgroundColor3 = Color3.new 72 / 255, 72 / 255, 72 / 255 + frame.BorderColor3 = Color3.new 0, 0, 0 + frame.Active = true + frame.Parent = widgetContainer + control.Parent = dragBar + control.BackgroundColor3 = Color3.new 72 / 255, 72 / 255, 72 / 255 + control.BorderSizePixel = 0 + control.BackgroundTransparency = 0 + control.Position = UDim2.new 1, -21, 1, 1 + if size + control.Size = UDim2.new 0, 21, size.Y.Scale, size.Y.Offset + else + control.Size = UDim2.new 0, 21, 0, 400 - with frame - .Size = UDim2.new 1, 0, 1, 0 - .BackgroundColor3 = Color3.new 72 / 255, 72 / 255, 72 / 255 - .BorderColor3 = Color3.new 0, 0, 0 - .Active = true - .Parent = widgetContainer - with control - .BackgroundColor3 = Color3.new 72 / 255, 72 / 255, 72 / 255 - .BorderSizePixel = 0 - .BackgroundTransparency = 0 - .Position = UDim2.new 1, -21, 1, 1 - .Size = UDim2.new 0, 21, if size - size.Y.Scale, size.Y.Offset - else - 0, 400 - \FindFirstChild"ScrollDownButton".Position = UDim2.new 0, 0, 1, -20 + control\FindFirstChild("ScrollDownButton").Position = UDim2.new 0, 0, 1, -20 - .Parent = dragBar + fakeLine = Instance.new "Frame" + fakeLine.Name = "FakeLine" + fakeLine.BorderSizePixel = 0 + fakeLine.BackgroundColor3 = Color3.new 0, 0, 0 + fakeLine.Size = UDim2.new 0, 1, 1, 1 + fakeLine.Position = UDim2.new 1, 0, 0, 0 + fakeLine.Parent = control - New "Frame", "FakeLine" - BorderSizePixel: 0 - BackgroundColor3: Color3.new 0, 0, 0 - Size: UDim2.new 0, 1, 1, 1 - Position: UDim2.new 1, 0, 0, 0 - Parent: control + verticalDragger = Instance.new "TextButton" + verticalDragger.ZIndex = 2 + verticalDragger.AutoButtonColor = false + verticalDragger.Name = "VerticalDragger" + verticalDragger.BackgroundColor3 = Color3.new 50 / 255, 50 / 255, 50 / 255 + verticalDragger.BorderColor3 = Color3.new 0, 0, 0 + verticalDragger.Size = UDim2.new 1, 20, 0, 20 + verticalDragger.Position = UDim2.new 0, 0, 1, 0 + verticalDragger.Active = true + verticalDragger.Text = "" + verticalDragger.Parent = widgetContainer - for _ = 1, 2 - with scrubFrame\clone! - .Position = UDim2.new 0.5, -5, 0.5, 2 - .Parent = verticalDragger + scrubFrame = Instance.new "Frame" + scrubFrame.Name = "ScrubFrame" + scrubFrame.BackgroundColor3 = Color3.new 1, 1, 1 + scrubFrame.BorderSizePixel = 0 + scrubFrame.Position = UDim2.new 0.5, -5, 0.5, 0 + scrubFrame.Size = UDim2.new 0, 10, 0, 1 + scrubFrame.ZIndex = 5 + scrubFrame.Parent = verticalDragger + scrubTwo = scrubFrame\clone! + scrubTwo.Position = UDim2.new 0.5, -5, 0.5, -2 + scrubTwo.Parent = verticalDragger + scrubThree = scrubFrame\clone! + scrubThree.Position = UDim2.new 0.5, -5, 0.5, 2 + scrubThree.Parent = verticalDragger - areaSoak = New "TextButton", "AreaSoak" - Size: UDim2.new 1, 0, 1, 0 - BackgroundTransparency: 1 - BorderSizePixel: 0 - Text: "" - ZIndex: 10 - Visible: false - Active: true - Parent: getScreenGuiAncestor parent + areaSoak = Instance.new "TextButton" + areaSoak.Name = "AreaSoak" + areaSoak.Size = UDim2.new 1, 0, 1, 0 + areaSoak.BackgroundTransparency = 1 + areaSoak.BorderSizePixel = 0 + areaSoak.Text = "" + areaSoak.ZIndex = 10 + areaSoak.Visible = false + areaSoak.Active = true + areaSoak.Parent = getScreenGuiAncestor parent draggingVertical = false local startYPos + verticalDragger.MouseEnter\connect -> + verticalDragger.BackgroundColor3 = Color3.new 60 / 255, 60 / 255, 60 / 255 - with verticalDragger - .MouseEnter\connect -> - .BackgroundColor3 = Color3.new 60 / 255, 60 / 255, 60 / 255 - .MouseLeave\connect -> - .BackgroundColor3 = Color3.new 50 / 255, 50 / 255, 50 / 255 - .MouseButton1Down\connect (_, y) -> - draggingVertical = true - areaSoak.Visible = true - startYPos = y + verticalDragger.MouseLeave\connect -> + verticalDragger.BackgroundColor3 = Color3.new 50 / 255, 50 / 255, 50 / 255 + + verticalDragger.MouseButton1Down\connect (_, y) -> + draggingVertical = true + areaSoak.Visible = true + startYPos = y areaSoak.MouseButton1Up\connect -> draggingVertical = false areaSoak.Visible = false + areaSoak.MouseMoved\connect (_, y) -> - return if not draggingVertical + if not draggingVertical + return + yDelta = y - startYPos - return if not control.ScrollDownButton.Visible and yDelta > 0 + if not control.ScrollDownButton.Visible and yDelta > 0 + return if (widgetContainer.Size.Y.Offset + yDelta) < 150 @@ -3332,6 +3874,7 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> control.Size = UDim2.new 0, 21, 0, 150 return + startYPos = y if widgetContainer.Size.Y.Offset + yDelta >= 0 @@ -3343,6 +3886,7 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> ) control.Size = UDim2.new 0, 21, 0, control.Size.Y.Offset + yDelta + switchMinimize = -> minimizeFrame.Visible = not minimizeFrame.Visible if scrollable @@ -3352,79 +3896,82 @@ t.CreatePluginFrame = (name, size, position, scrollable, parent) -> else widgetContainer.Visible = not widgetContainer.Visible - minimizeButton.Text = if minimizeFrame.Visible - "+" + + if minimizeFrame.Visible + minimizeButton.Text = "+" else - "-" + minimizeButton.Text = "-" - minimizeBigButton.MouseButton1Click\connect switchMinimize - minimizeButton.MouseButton1Click\connect switchMinimize - return dragBar, if scrollable - frame, helpFrame, closeEvent + minimizeBigButton.MouseButton1Click\connect -> + switchMinimize! + + + minimizeButton.MouseButton1Click\connect -> + switchMinimize! + + + if scrollable + dragBar, frame, helpFrame, closeEvent else - widgetContainer, helpFrame, closeEvent + dragBar, widgetContainer, helpFrame, closeEvent + t.Help = (funcNameOrFunc) -> --input argument can be a string or a function. Should return a description (of arguments and expected side effects) - switch funcNameOrFunc - when 'CreatePropertyDropDownMenu', t.CreatePropertyDropDownMenu - 'Function CreatePropertyDropDownMenu. ' .. - 'Arguments: (instance, propertyName, enumType). ' .. - 'Side effect: returns a container with a drop-down-box that is linked to the "property" field of "instance" which is of type "enumType"' + if funcNameOrFunc == "CreatePropertyDropDownMenu" or funcNameOrFunc == t.CreatePropertyDropDownMenu + "Function CreatePropertyDropDownMenu. " .. + "Arguments: (instance, propertyName, enumType). " .. + "Side effect: returns a container with a drop-down-box that is linked to the 'property' field of 'instance' which is of type 'enumType'" - when 'CreateDropDownMenu', t.CreateDropDownMenu - 'Function CreateDropDownMenu. ' .. - 'Arguments: (items, onItemSelected). ' .. - 'Side effect: Returns 2 results, a container to the gui object and a "updateSelection" function for external updating. The container is a drop-down-box created around a list of items' + elseif funcNameOrFunc == "CreateDropDownMenu" or funcNameOrFunc == t.CreateDropDownMenu + "Function CreateDropDownMenu. " .. + "Arguments: (items, onItemSelected). " .. + "Side effect: Returns 2 results, a container to the gui object and a 'updateSelection' function for external updating. The container is a drop-down-box created around a list of items" - when 'CreateMessageDialog', t.CreateMessageDialog - 'Function CreateMessageDialog. ' .. - 'Arguments: (title, message, buttons). ' .. - 'Side effect: Returns a gui object of a message box with "title" and "message" as passed in. "buttons" input is an array of Tables contains a "Text" and "Function" field for the text/callback of each button' + elseif funcNameOrFunc == "CreateMessageDialog" or funcNameOrFunc == t.CreateMessageDialog + "Function CreateMessageDialog. " .. + "Arguments: (title, message, buttons). " .. + "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button" - when 'CreateStyledMessageDialog', t.CreateStyledMessageDialog - 'Function CreateStyledMessageDialog. ' .. - 'Arguments: (title, message, style, buttons). ' .. - 'Side effect: Returns a gui object of a message box with "title" and "message" as passed in. "buttons" input is an array of Tables contains a "Text" and "Function" field for the text/callback of each button, "style" is a string, either Error, Notify or Confirm' + elseif funcNameOrFunc == "CreateStyledMessageDialog" or funcNameOrFunc == t.CreateStyledMessageDialog + "Function CreateStyledMessageDialog. " .. + "Arguments: (title, message, style, buttons). " .. + "Side effect: Returns a gui object of a message box with 'title' and 'message' as passed in. 'buttons' input is an array of Tables contains a 'Text' and 'Function' field for the text/callback of each button, 'style' is a string, either Error, Notify or Confirm" - when 'GetFontHeight', t.GetFontHeight - 'Function GetFontHeight. ' .. - 'Arguments: (font, fontSize). ' .. - 'Side effect: returns the size in pixels of the given font + fontSize' + elseif funcNameOrFunc == "GetFontHeight" or funcNameOrFunc == t.GetFontHeight + "Function GetFontHeight. " .. + "Arguments: (font, fontSize). " .. + "Side effect: returns the size in pixels of the given font + fontSize" - when 'CreateScrollingFrame', t.CreateScrollingFrame - 'Function CreateScrollingFrame. ' .. - 'Arguments: (orderList, style) ' .. - 'Side effect: returns 4 objects, (scrollFrame, scrollUpButton, scrollDownButton, recalculateFunction). "scrollFrame" can be filled with GuiObjects. It will lay them out and allow scrollUpButton/scrollDownButton to interact with them. Orderlist is optional (and specifies the order to layout the children. Without orderlist, it uses the children order. style is also optional, and allows for a "grid" styling if style is passed "grid" as a string. recalculateFunction can be called - when a relayout is needed ( - when orderList changes)' + elseif funcNameOrFunc == "CreateScrollingFrame" or funcNameOrFunc == t.CreateScrollingFrame + "Function CreateScrollingFrame. " .. + "Arguments: (orderList, style) " .. + "Side effect: returns 4 objects, (scrollFrame, scrollUpButton, scrollDownButton, recalculateFunction). 'scrollFrame' can be filled with GuiObjects. It will lay them out and allow scrollUpButton/scrollDownButton to interact with them. Orderlist is optional (and specifies the order to layout the children. Without orderlist, it uses the children order. style is also optional, and allows for a 'grid' styling if style is passed 'grid' as a string. recalculateFunction can be called when a relayout is needed (when orderList changes)" - when 'CreateTrueScrollingFrame', t.CreateTrueScrollingFrame - 'Function CreateTrueScrollingFrame. ' .. - 'Arguments: (nil) ' .. - 'Side effect: returns 2 objects, (scrollFrame, controlFrame). "scrollFrame" can be filled with GuiObjects, and they will be clipped if not inside the frame"s bounds. controlFrame has children scrollup and scrolldown, as well as a slider. controlFrame can be parented to any guiobject and it will readjust itself to fit.' + elseif funcNameOrFunc == "CreateTrueScrollingFrame" or funcNameOrFunc == t.CreateTrueScrollingFrame + "Function CreateTrueScrollingFrame. " .. + "Arguments: (nil) " .. + "Side effect: returns 2 objects, (scrollFrame, controlFrame). 'scrollFrame' can be filled with GuiObjects, and they will be clipped if not inside the frame's bounds. controlFrame has children scrollup and scrolldown, as well as a slider. controlFrame can be parented to any guiobject and it will readjust itself to fit." - when 'AutoTruncateTextObject', t.AutoTruncateTextObject - 'Function AutoTruncateTextObject. ' .. - 'Arguments: (textLabel) ' .. - 'Side effect: returns 2 objects, (textLabel, changeText). The "textLabel" input is modified to automatically truncate text (with ellipsis), if it gets too small to fit. "changeText" is a function that can be used to change the text, it takes 1 string as an argument' + elseif funcNameOrFunc == "AutoTruncateTextObject" or funcNameOrFunc == t.AutoTruncateTextObject + "Function AutoTruncateTextObject. " .. + "Arguments: (textLabel) " .. + "Side effect: returns 2 objects, (textLabel, changeText). The 'textLabel' input is modified to automatically truncate text (with ellipsis), if it gets too small to fit. 'changeText' is a function that can be used to change the text, it takes 1 string as an argument" - when 'CreateSlider', t.CreateSlider - 'Function CreateSlider. ' .. - 'Arguments: (steps, width, position) ' .. - 'Side effect: returns 2 objects, (sliderGui, sliderPosition). The "steps" argument specifies how many different positions the slider can hold along the bar. "width" specifies in pixels how wide the bar should be (modifiable afterwards if desired). "position" argument should be a UDim2 for slider positioning. "sliderPosition" is an IntValue whose current .Value specifies the specific step the slider is currently on.' + elseif funcNameOrFunc == "CreateSlider" or funcNameOrFunc == t.CreateSlider + "Function CreateSlider. " .. + "Arguments: (steps, width, position) " .. + "Side effect: returns 2 objects, (sliderGui, sliderPosition). The 'steps' argument specifies how many different positions the slider can hold along the bar. 'width' specifies in pixels how wide the bar should be (modifiable afterwards if desired). 'position' argument should be a UDim2 for slider positioning. 'sliderPosition' is an IntValue whose current .Value specifies the specific step the slider is currently on." - when 'CreateLoadingFrame', t.CreateLoadingFrame - 'Function CreateLoadingFrame. ' .. - 'Arguments: (name, size, position) ' .. - 'Side effect: Creates a gui that can be manipulated to show progress for a particular action. Name appears above the loading bar, and size and position are udim2 values (both size and position are optional arguments). Returns 3 arguments, the first being the gui created. The second being updateLoadingGuiPercent, which is a bindable function. This function takes one argument (two optionally), which should be a number between 0 and 1, representing the percentage the loading gui should be at. The second argument to this function is a boolean value that if set to true will tween the current percentage value to the new percentage value, therefore our third argument is how long this tween should take. Our third returned argument is a BindableEvent, that - when fired means that someone clicked the cancel button on the dialog.' + elseif funcNameOrFunc == "CreateLoadingFrame" or funcNameOrFunc == t.CreateLoadingFrame + "Function CreateLoadingFrame. " .. + "Arguments: (name, size, position) " .. + "Side effect: Creates a gui that can be manipulated to show progress for a particular action. Name appears above the loading bar, and size and position are udim2 values (both size and position are optional arguments). Returns 3 arguments, the first being the gui created. The second being updateLoadingGuiPercent, which is a bindable function. This function takes one argument (two optionally), which should be a number between 0 and 1, representing the percentage the loading gui should be at. The second argument to this function is a boolean value that if set to true will tween the current percentage value to the new percentage value, therefore our third argument is how long this tween should take. Our third returned argument is a BindableEvent, that when fired means that someone clicked the cancel button on the dialog." - when 'CreateTerrainMaterialSelector', t.CreateTerrainMaterialSelector - 'Function CreateTerrainMaterialSelector. ' .. - 'Arguments: (size, position) ' .. - 'Side effect: Size and position are UDim2 values that specifies the selector"s size and position. Both size and position are optional arguments. This method returns 3 objects (terrainSelectorGui, terrainSelected, forceTerrainSelection). terrainSelectorGui is just the gui object that we generate with this function, parent it as you like. TerrainSelected is a BindableEvent that is fired whenever a new terrain type is selected in the gui. ForceTerrainSelection is a function that takes an argument of Enum.CellMaterial and will force the gui to show that material as currently selected.' + elseif funcNameOrFunc == "CreateTerrainMaterialSelector" or funcNameOrFunc == t.CreateTerrainMaterialSelector + "Function CreateTerrainMaterialSelector. " .. + "Arguments: (size, position) " .. + "Side effect: Size and position are UDim2 values that specifies the selector's size and position. Both size and position are optional arguments. This method returns 3 objects (terrainSelectorGui, terrainSelected, forceTerrainSelection). terrainSelectorGui is just the gui object that we generate with this function, parent it as you like. TerrainSelected is a BindableEvent that is fired whenever a new terrain type is selected in the gui. ForceTerrainSelection is a function that takes an argument of Enum.CellMaterial and will force the gui to show that material as currently selected." --- Thanks RbxGui, that was unbelievably tedious to port --- Heliodex +t