Last active
November 29, 2020 04:14
-
-
Save howmanysmall/f19175fde1e19500908dc0b2dbe731d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Players = game:GetService("Players") | |
local ReplicatedStorage = game:GetService("ReplicatedStorage") | |
local RunService = game:GetService("RunService") | |
local Resources = require(ReplicatedStorage:WaitForChild("Resources")) | |
local Color = Resources:LoadLibrary("Color") | |
local Tween = Resources:LoadLibrary("Tween") | |
local Typer = Resources:LoadLibrary("Typer") | |
local Enumeration = Resources:LoadLibrary("Enumeration") | |
local PseudoInstance = Resources:LoadLibrary("PseudoInstance") | |
local RoStrapPriorityUI = Resources:LoadLibrary("RoStrapPriorityUI") | |
Resources:LoadLibrary("ReplicatedPseudoInstance") | |
Resources:LoadLibrary("Shadow") | |
Resources:LoadLibrary("RippleButton") | |
local BUTTON_WIDTH_PADDING = 8 | |
local Left = Enum.TextXAlignment.Left | |
local SourceSansSemibold = Enum.Font.SourceSansSemibold | |
local SourceSans = Enum.Font.SourceSans | |
local Flat = Enumeration.ButtonStyle.Flat | |
local InBack = Enumeration.EasingFunction.InBack | |
local OutBack = Enumeration.EasingFunction.OutBack | |
local LocalPlayer, PlayerGui do | |
if RunService:IsClient() then | |
if RunService:IsServer() then | |
PlayerGui = game:GetService("CoreGui") | |
else | |
repeat LocalPlayer = Players.LocalPlayer until LocalPlayer or not wait() | |
repeat PlayerGui = LocalPlayer:FindFirstChildOfClass("PlayerGui") until PlayerGui or not wait() | |
end | |
end | |
end | |
local Frame do | |
Frame = Instance.new("Frame") | |
Frame.BackgroundTransparency = 1 | |
Frame.Position = UDim2.new(0.5, 0, 0.5, 0) | |
Frame.AnchorPoint = Vector2.new(0.5, 0.5) | |
Frame.Size = UDim2.new(1, 0, 1, 0) | |
Frame.Name = "ConfirmationDialog" | |
local UIScale = Instance.new("UIScale") | |
UIScale.Scale = 0 | |
UIScale.Name = "UIScale" | |
UIScale.Parent = Frame | |
local Background = Instance.new("ImageLabel") | |
Background.BackgroundTransparency = 1 | |
Background.ScaleType = Enum.ScaleType.Slice | |
Background.SliceCenter = Rect.new(4, 4, 252, 252) | |
Background.Image = "rbxassetid://1934624205" | |
Background.Size = UDim2.new(0, 560, 0, 182) | |
Background.Position = UDim2.new(0.5, 0, 0.5, 0) | |
Background.AnchorPoint = Vector2.new(0.5, 0.5) | |
Background.Name = "Background" | |
Background.ZIndex = 2 | |
Background.Parent = Frame | |
local UIPadding = Instance.new("UIPadding") | |
UIPadding.PaddingLeft = UDim.new(0, 24) | |
UIPadding.PaddingTop = UDim.new(0, 24) | |
UIPadding.Parent = Background | |
local Header = Instance.new("TextLabel") | |
Header.Font = SourceSansSemibold | |
Header.TextSize = 24 | |
Header.Size = UDim2.new(1, -24, 0, 28) | |
Header.Position = UDim2.new() | |
Header.BackgroundTransparency = 1 | |
Header.TextXAlignment = Left | |
Header.TextTransparency = 0.129 | |
Header.TextColor3 = Color.Black | |
Header.Name = "Header" | |
Header.ZIndex = 3 | |
Header.Parent = Background | |
local DialogTextLabel = Instance.new("TextLabel") | |
DialogTextLabel.BackgroundTransparency = 1 | |
DialogTextLabel.Name = "DialogTextLabel" | |
DialogTextLabel.Position = UDim2.new(0, 0, 0, 40) | |
DialogTextLabel.Size = UDim2.new(1, -24, 0, 64) | |
DialogTextLabel.ZIndex = 3 | |
DialogTextLabel.Font = SourceSans | |
DialogTextLabel.TextXAlignment = Left | |
DialogTextLabel.TextTransparency = 0.4 | |
DialogTextLabel.TextColor3 = Color.Black | |
DialogTextLabel.TextScaled = true | |
DialogTextLabel.Parent = Background | |
local Shadow = PseudoInstance.new("Shadow") | |
Shadow.Elevation = 8 | |
Shadow.Parent = Background | |
end | |
local function OnAction1(self) | |
if not self.Dismissed then | |
self:Dismiss() | |
self.OnConfirmed:Fire(LocalPlayer, false) | |
end | |
end | |
local function OnAction2(self) | |
if not self.Dismissed then | |
self:Dismiss() | |
self.OnConfirmed:Fire(LocalPlayer, true) | |
end | |
end | |
local function HideUIScale(self) | |
self.UIScale.Parent = nil | |
end | |
local DialogsActive = 0 | |
local function SubDialogsActive() | |
DialogsActive = DialogsActive - 1 | |
end | |
local function AdjustButtonSize(Button) | |
Button.Size = UDim2.new(0, Button.TextBounds.X + BUTTON_WIDTH_PADDING * 2, 0, 36) | |
end | |
return PseudoInstance:Register("ConfirmationDialog", { | |
Storage = {}; | |
Internals = { | |
"Action1", "Action2", "Header", "UIScale", "UIPadding", "Background", "DialogTextLabel"; | |
SHOULD_BLUR = false; | |
}; | |
Events = {"OnConfirmed"}; | |
Methods = { | |
Enter = function(self) | |
self.UIScale.Parent = self.Object | |
self.Object.Parent = self.SCREEN | |
AdjustButtonSize(self.DismissButton) | |
AdjustButtonSize(self.ConfirmButton) | |
Tween(self.UIScale, "Scale", 1, OutBack, self.ENTER_TIME, true, HideUIScale, self) | |
end; | |
Dismiss = function(self) | |
-- Destroys Dialog when done | |
if not self.Dismissed then | |
self.Dismissed = true | |
Tween(self.UIScale, "Scale", 0, InBack, self.DISMISS_TIME, true, self.Janitor) | |
self.UIScale.Parent = self.Object | |
end | |
end; | |
}; | |
Properties = { | |
PrimaryColor3 = Typer.AssignSignature(2, Typer.Color3, function(self, PrimaryColor3) | |
self.Action1.PrimaryColor3 = PrimaryColor3 | |
self.Action2.PrimaryColor3 = PrimaryColor3 | |
self:rawset("PrimaryColor3", PrimaryColor3) | |
end); | |
Action1Text = Typer.AssignSignature(2, Typer.String, function(self, Text) | |
self.Action1.Text = Text | |
self:rawset("Action1Text", Text) | |
end); | |
Action2Text = Typer.AssignSignature(2, Typer.String, function(self, Text) | |
self.Action2.Text = Text | |
self:rawset("Action2Text", Text) | |
end); | |
HeaderText = Typer.AssignSignature(2, Typer.String, function(self, Text) | |
self.Header.Text = Text | |
self:rawset("HeaderText", self.Header.Text) | |
end); | |
DialogText = Typer.AssignSignature(2, Typer.String, function(self, Text) | |
self.DialogTextLabel.Text = Text | |
self:rawset("DialogText", self.DialogTextLabel.Text) | |
end); | |
}; | |
Init = function(self, ...) | |
-- print("Before:", self.Object) | |
self:rawset("Object", Frame:Clone()) | |
-- print("After:", self.Object) | |
self.UIScale = self.Object.UIScale | |
self.Background = self.Object.Background | |
self.Header = self.Background.Header | |
self.DialogTextLabel = self.Background.DialogTextLabel | |
local Action1 = PseudoInstance.new("RippleButton") | |
Action1.AnchorPoint = Vector2.new(1, 1) | |
Action1.Size = UDim2.new(0, 117, 0, 28) | |
Action1.Position = UDim2.new(1, -133, 1, -8) | |
Action1.BorderRadius = 4 | |
Action1.ZIndex = 10 | |
Action1.TextSize = 20 | |
Action1.TextTransparency = 0.129 | |
Action1.Style = Flat | |
Action1.Parent = self.Background | |
local Action2 = PseudoInstance.new("RippleButton") | |
Action2.AnchorPoint = Vector2.new(1, 1) | |
Action2.Size = UDim2.new(0, 117, 0, 28) | |
Action2.Position = UDim2.new(1, -8, 1, -8) | |
Action2.BorderRadius = 4 | |
Action2.ZIndex = 10 | |
Action2.TextSize = 20 | |
Action2.TextTransparency = 0.129 | |
Action2.Style = Flat | |
Action2.Parent = self.Background | |
self.Janitor:Add(Action1:GetPropertyChangedSignal("TextBounds"):Connect(AdjustButtonSize, Action1), "Disconnect") | |
self.Janitor:Add(Action2:GetPropertyChangedSignal("TextBounds"):Connect(AdjustButtonSize, Action2), "Disconnect") | |
self.Action1 = Action1 | |
self.Action2 = Action2 | |
self.Janitor:Add(Action1.OnPressed:Connect(OnAction1, self), "Disconnect") | |
self.Janitor:Add(Action2.OnPressed:Connect(OnAction2, self), "Disconnect") | |
self.Janitor:Add(self.Object, "Destroy") | |
self.Janitor:Add(self.UIScale, "Destroy") | |
self.Janitor:Add(SubDialogsActive, true) | |
self.PrimaryColor3 = Color3.fromRGB(98, 0, 238) | |
self:superinit(...) | |
end; | |
}, RoStrapPriorityUI) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment