Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a ScrollingFrame to ChoiceDialogue #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions ChoiceDialog.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- 2-step Choice Dialog ReplicatedPseudoInstance
-- @source https://raw.githubusercontent.com/RoStrap/RoStrapUI/master/ChoiceDialog.lua
-- @rostrap ChoiceDialog
-- @documentation https://rostrap.github.io/Libraries/RoStrapUI/ChoiceDialog/
-- @author Validark

Expand Down Expand Up @@ -68,6 +70,18 @@ local Frame do
Background.Name = "Background"
Background.ZIndex = 2
Background.Parent = Frame

local ScrollingFrame = Instance.new("ScrollingFrame")
ScrollingFrame.Size = UDim2.fromScale(1, 0.67)
ScrollingFrame.Position = UDim2.fromOffset(0, 64)
ScrollingFrame.BackgroundTransparency = 1
ScrollingFrame.ZIndex = 2
ScrollingFrame.BorderSizePixel = 0
ScrollingFrame.MidImage = "rbxassetid://3419963"
ScrollingFrame.TopImage = "rbxassetid://3419963"
ScrollingFrame.BottomImage = "rbxassetid://3419963"
ScrollingFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
ScrollingFrame.Parent = Background

local Header = Instance.new("TextLabel")
Header.Font = SourceSansSemibold
Expand Down Expand Up @@ -143,6 +157,7 @@ return PseudoInstance:Register("ChoiceDialog", {

Methods = {
Enter = function(self)
self.Dismissed = false
self.UIScale.Parent = self.Object
self.Object.Parent = self.SCREEN
AdjustButtonSize(self.DismissButton)
Expand Down Expand Up @@ -177,7 +192,9 @@ return PseudoInstance:Register("ChoiceDialog", {

Options = Typer.AssignSignature(2, Typer.ArrayOfStrings, function(self, Options)
local NumOptions = #Options
self.Background.Size = UDim2.new(0, 280, 0, 117 + 48 * NumOptions)
self.Background.Size = UDim2.new(0, 280, 0, math.clamp(117, 357, 117 + 48 * NumOptions))
self.ScrollingFrame.Size = UDim2.fromOffset(280, math.clamp(0, 240, 48 * NumOptions))
self.ScrollingFrame.CanvasSize = UDim2.fromOffset(0, 48 * NumOptions)

for Item, ItemContainer in next, self.AssociatedRadioContainers do
Item:Destroy()
Expand All @@ -197,12 +214,12 @@ return PseudoInstance:Register("ChoiceDialog", {
local ChoiceName = Options[i]

local ItemContainer = PseudoInstance.new("RippleButton")
ItemContainer.Position = UDim2.new(0, 0, 0, 64 + 48 * (i - 1))
ItemContainer.Position = UDim2.new(0, 0, 0, 48 * (i - 1))
ItemContainer.Size = UDim2.new(1, 0, 0, 48)
ItemContainer.BorderRadius = 0
ItemContainer.ZIndex = 5
ItemContainer.Style = Flat
ItemContainer.Parent = self.Background
ItemContainer.Parent = self.ScrollingFrame

local Item = PseudoInstance.new("Radio")
Item.AnchorPoint = Vector2.new(0.5, 0.5)
Expand Down Expand Up @@ -255,6 +272,7 @@ return PseudoInstance:Register("ChoiceDialog", {
self:rawset("Object", Frame:Clone())
self.UIScale = self.Object.UIScale
self.Background = self.Object.Background
self:rawset("ScrollingFrame", self.Background.ScrollingFrame)
self.Header = self.Background.Header
self.AssociatedRadioContainers = {}

Expand All @@ -266,6 +284,7 @@ return PseudoInstance:Register("ChoiceDialog", {
ConfirmButton.TextSize = 16
ConfirmButton.TextTransparency = 0.13
ConfirmButton.Style = Flat
ConfirmButton.Elevation = 2
ConfirmButton.Parent = self.Background

local DismissButton = ConfirmButton:Clone()
Expand Down