forked from aya/aya
Initial commit
This commit is contained in:
@@ -0,0 +1,587 @@
|
||||
-- This script creates almost all gui elements found in the backpack (warning: there are a lot!)
|
||||
-- TODO: automate this process
|
||||
|
||||
local ICON_SIZE = 46
|
||||
|
||||
local gui = script.Parent
|
||||
|
||||
-- A couple of necessary functions
|
||||
local function waitForChild(instance, name)
|
||||
while not instance:FindFirstChild(name) do
|
||||
instance.ChildAdded:wait()
|
||||
end
|
||||
end
|
||||
local function waitForProperty(instance, property)
|
||||
while not instance[property] do
|
||||
instance.Changed:wait()
|
||||
end
|
||||
end
|
||||
|
||||
local function IsTouchDevice()
|
||||
return Game:GetService('UserInputService').TouchEnabled
|
||||
end
|
||||
|
||||
local function IsPhone()
|
||||
if Game:GetService("GuiService"):GetScreenResolution().Y <= 500 and IsTouchDevice() then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
waitForChild(game,"Players")
|
||||
waitForProperty(game:GetService("Players"),"LocalPlayer")
|
||||
local player = game:GetService("Players").LocalPlayer
|
||||
|
||||
-- First up is the current loadout
|
||||
local CurrentLoadout = Instance.new("Frame")
|
||||
CurrentLoadout.Name = "CurrentLoadout"
|
||||
CurrentLoadout.Position = UDim2.new(0.5, -300, 1, -85)
|
||||
CurrentLoadout.Size = UDim2.new(0, 600, 0, ICON_SIZE)
|
||||
CurrentLoadout.BackgroundTransparency = 1
|
||||
CurrentLoadout.RobloxLocked = true
|
||||
CurrentLoadout.Parent = gui
|
||||
|
||||
local CLBackground = Instance.new('ImageLabel')
|
||||
CLBackground.Name = 'Background';
|
||||
CLBackground.Size = UDim2.new(1.2, 0, 1.2, 0);
|
||||
CLBackground.Image = "ayaasset://textures/2015/BackpackBuilder/CLBackground.png"
|
||||
CLBackground.BackgroundTransparency = 1.0;
|
||||
CLBackground.Position = UDim2.new(-0.1, 0, -0.1, 0);
|
||||
CLBackground.ZIndex = 0.0;
|
||||
CLBackground.Parent = CurrentLoadout
|
||||
CLBackground.Visible = false
|
||||
|
||||
local Debounce = Instance.new("BoolValue")
|
||||
Debounce.Name = "Debounce"
|
||||
Debounce.RobloxLocked = true
|
||||
Debounce.Parent = CurrentLoadout
|
||||
|
||||
local BackpackButton = Instance.new("ImageButton")
|
||||
BackpackButton.RobloxLocked = true
|
||||
BackpackButton.Visible = false
|
||||
BackpackButton.Name = "BackpackButton"
|
||||
BackpackButton.BackgroundTransparency = 1
|
||||
BackpackButton.Image = "ayaasset://textures/ui/Backpack_Open.png"
|
||||
BackpackButton.Position = UDim2.new(0.5, -7, 1, -55)
|
||||
BackpackButton.Size = UDim2.new(0, 14, 0, 9)
|
||||
waitForChild(gui,"ControlFrame")
|
||||
BackpackButton.Parent = gui.ControlFrame
|
||||
|
||||
local NumSlots = 9
|
||||
|
||||
if IsPhone() then
|
||||
NumSlots = 3
|
||||
CurrentLoadout.Size = UDim2.new(0,180,0,ICON_SIZE)
|
||||
CurrentLoadout.Position = UDim2.new(0.5,-90,1,-85)
|
||||
end
|
||||
|
||||
for i = 0, NumSlots do
|
||||
local slotFrame = Instance.new("Frame")
|
||||
slotFrame.RobloxLocked = true
|
||||
slotFrame.BackgroundColor3 = Color3.new(0,0,0)
|
||||
slotFrame.BackgroundTransparency = 1
|
||||
slotFrame.BorderColor3 = Color3.new(1, 1, 1)
|
||||
slotFrame.BorderSizePixel = 0
|
||||
slotFrame.Name = "Slot" .. tostring(i)
|
||||
slotFrame.ZIndex = 4.0
|
||||
if i == 0 then
|
||||
slotFrame.Position = UDim2.new(0.9, 48, 0, 0)
|
||||
else
|
||||
slotFrame.Position = UDim2.new((i - 1) * 0.1, (i-1)* 6,0,0)
|
||||
end
|
||||
|
||||
|
||||
slotFrame.Size = UDim2.new(0, ICON_SIZE, 0, ICON_SIZE)
|
||||
slotFrame.Parent = CurrentLoadout
|
||||
|
||||
if gui.AbsoluteSize.Y <= 320 then
|
||||
slotFrame.Position = UDim2.new(0, (i-1)* 60, 0, -50)
|
||||
end
|
||||
if gui.AbsoluteSize.Y <= 320 and i == 0 then
|
||||
slotFrame:Destroy()
|
||||
end
|
||||
end
|
||||
|
||||
local TempSlot = Instance.new("ImageButton")
|
||||
TempSlot.Name = "TempSlot"
|
||||
TempSlot.Active = true
|
||||
TempSlot.Size = UDim2.new(1,0,1,0)
|
||||
TempSlot.BackgroundTransparency = 1.0
|
||||
TempSlot.Style = 'Custom'
|
||||
TempSlot.Visible = false
|
||||
TempSlot.RobloxLocked = true
|
||||
TempSlot.Parent = CurrentLoadout
|
||||
TempSlot.ZIndex = 3.0
|
||||
|
||||
local slotBackground = Instance.new('Frame')
|
||||
slotBackground.Name = 'Background'
|
||||
slotBackground.BackgroundTransparency = 1.0
|
||||
slotBackground.Style = "DropShadow"
|
||||
slotBackground.Position = UDim2.new(0, -10, 0, -10)
|
||||
slotBackground.Size = UDim2.new(1, 20, 1, 20)
|
||||
slotBackground.Parent = TempSlot
|
||||
|
||||
local HighLight = Instance.new('ImageLabel')
|
||||
HighLight.Name = 'Highlight'
|
||||
HighLight.BackgroundTransparency = 1.0
|
||||
HighLight.Image = 'ayaasset://textures/2015/BackpackBuilder/HighLight.png'
|
||||
HighLight.Size = UDim2.new(1, 0, 1, 0)
|
||||
--HighLight.Parent = TempSlot
|
||||
HighLight.Visible = false
|
||||
|
||||
-- TempSlot Children
|
||||
local GearReference = Instance.new("ObjectValue")
|
||||
GearReference.Name = "GearReference"
|
||||
GearReference.RobloxLocked = true
|
||||
GearReference.Parent = TempSlot
|
||||
|
||||
|
||||
local ToolTipLabel = Instance.new("TextLabel")
|
||||
ToolTipLabel.Name = "ToolTipLabel"
|
||||
ToolTipLabel.RobloxLocked = true
|
||||
ToolTipLabel.Text = ""
|
||||
ToolTipLabel.BackgroundTransparency = 0.5
|
||||
ToolTipLabel.BorderSizePixel = 0
|
||||
ToolTipLabel.Visible = false
|
||||
ToolTipLabel.TextColor3 = Color3.new(1,1,1)
|
||||
ToolTipLabel.BackgroundColor3 = Color3.new(0,0,0)
|
||||
ToolTipLabel.TextStrokeTransparency = 0
|
||||
ToolTipLabel.Font = Enum.Font.ArialBold
|
||||
ToolTipLabel.FontSize = Enum.FontSize.Size14
|
||||
--ToolTipLabel.TextWrap = true
|
||||
ToolTipLabel.Size = UDim2.new(1,60,0,20)
|
||||
ToolTipLabel.Position = UDim2.new(0,-30,0,-30)
|
||||
ToolTipLabel.Parent = TempSlot
|
||||
|
||||
|
||||
local Kill = Instance.new("BoolValue")
|
||||
Kill.Name = "Kill"
|
||||
Kill.RobloxLocked = true
|
||||
Kill.Parent = TempSlot
|
||||
|
||||
local GearImage = Instance.new("ImageLabel")
|
||||
GearImage.Name = "GearImage"
|
||||
GearImage.BackgroundTransparency = 1
|
||||
GearImage.Position = UDim2.new(0, 0, 0, 0)
|
||||
GearImage.Size = UDim2.new(1, 0, 1, 0)
|
||||
GearImage.ZIndex = 5.0
|
||||
GearImage.RobloxLocked = true
|
||||
GearImage.Parent = TempSlot
|
||||
|
||||
local SlotNumber = Instance.new("TextLabel")
|
||||
SlotNumber.Name = "SlotNumber"
|
||||
SlotNumber.BackgroundTransparency = 1
|
||||
SlotNumber.BorderSizePixel = 0
|
||||
SlotNumber.Font = Enum.Font.ArialBold
|
||||
SlotNumber.FontSize = Enum.FontSize.Size18
|
||||
SlotNumber.Position = UDim2.new(0, 0, 0, 0)
|
||||
SlotNumber.Size = UDim2.new(0,10,0,15)
|
||||
SlotNumber.TextColor3 = Color3.new(1,1,1)
|
||||
SlotNumber.TextTransparency = 0
|
||||
SlotNumber.TextXAlignment = Enum.TextXAlignment.Left
|
||||
SlotNumber.TextYAlignment = Enum.TextYAlignment.Bottom
|
||||
SlotNumber.RobloxLocked = true
|
||||
SlotNumber.Parent = TempSlot
|
||||
SlotNumber.ZIndex = 5
|
||||
|
||||
if IsTouchDevice() then
|
||||
SlotNumber.Visible = false
|
||||
end
|
||||
|
||||
local SlotNumberDownShadow = SlotNumber:Clone()
|
||||
SlotNumberDownShadow.Name = "SlotNumberDownShadow"
|
||||
SlotNumberDownShadow.TextColor3 = Color3.new(0,0,0)
|
||||
SlotNumberDownShadow.Position = UDim2.new(0, 1, 0, -1)
|
||||
SlotNumberDownShadow.Parent = TempSlot
|
||||
SlotNumberDownShadow.ZIndex = 2
|
||||
|
||||
local SlotNumberUpShadow = SlotNumberDownShadow:Clone()
|
||||
SlotNumberUpShadow.Name = "SlotNumberUpShadow"
|
||||
SlotNumberUpShadow.Position = UDim2.new(0, -1, 0, -1)
|
||||
SlotNumberUpShadow.Parent = TempSlot
|
||||
|
||||
local GearText = Instance.new("TextLabel")
|
||||
GearText.RobloxLocked = true
|
||||
GearText.Name = "GearText"
|
||||
GearText.BackgroundTransparency = 1
|
||||
GearText.Font = Enum.Font.Arial
|
||||
GearText.FontSize = Enum.FontSize.Size14
|
||||
GearText.Position = UDim2.new(0,0,0,0)
|
||||
GearText.Size = UDim2.new(1,0,1,0)
|
||||
GearText.Text = ""
|
||||
GearText.TextColor3 = Color3.new(1,1,1)
|
||||
GearText.TextWrap = true
|
||||
GearText.Parent = TempSlot
|
||||
GearText.ZIndex = 5.0
|
||||
|
||||
--- Great, now lets make the inventory!
|
||||
|
||||
local Backpack = Instance.new("Frame")
|
||||
Backpack.RobloxLocked = true
|
||||
Backpack.Visible = false
|
||||
Backpack.Name = "Backpack"
|
||||
Backpack.Position = UDim2.new(0.5, 0, 0.5, 0)
|
||||
Backpack.BackgroundColor3 = Color3.new(32/255, 32/255, 32/255)
|
||||
Backpack.BackgroundTransparency = 0.5
|
||||
Backpack.BorderSizePixel = 0
|
||||
Backpack.Parent = gui
|
||||
Backpack.Active = true
|
||||
|
||||
-- Backpack Children
|
||||
local SwapSlot = Instance.new("BoolValue")
|
||||
SwapSlot.RobloxLocked = true
|
||||
SwapSlot.Name = "SwapSlot"
|
||||
SwapSlot.Parent = Backpack
|
||||
|
||||
-- SwapSlot Children
|
||||
local Slot = Instance.new("IntValue")
|
||||
Slot.RobloxLocked = true
|
||||
Slot.Name = "Slot"
|
||||
Slot.Parent = SwapSlot
|
||||
|
||||
local GearButton = Instance.new("ObjectValue")
|
||||
GearButton.RobloxLocked = true
|
||||
GearButton.Name = "GearButton"
|
||||
GearButton.Parent = SwapSlot
|
||||
|
||||
local Tabs = Instance.new("Frame")
|
||||
Tabs.Name = "Tabs"
|
||||
Tabs.Visible = false
|
||||
Tabs.Active = false
|
||||
Tabs.RobloxLocked = true
|
||||
Tabs.BackgroundColor3 = Color3.new(0,0,0)
|
||||
Tabs.BackgroundTransparency = 0.08
|
||||
Tabs.BorderSizePixel = 0
|
||||
Tabs.Position = UDim2.new(0,0,-0.1,-4)
|
||||
Tabs.Size = UDim2.new(1,0,0.1,4)
|
||||
Tabs.Parent = Backpack
|
||||
|
||||
-- Tabs Children
|
||||
|
||||
local tabLine = Instance.new("Frame")
|
||||
tabLine.RobloxLocked = true
|
||||
tabLine.Name = "TabLine"
|
||||
tabLine.BackgroundColor3 = Color3.new(53/255, 53/255, 53/255)
|
||||
tabLine.BorderSizePixel = 0
|
||||
tabLine.Position = UDim2.new(0,5,1,-4)
|
||||
tabLine.Size = UDim2.new(1,-10,0,4)
|
||||
tabLine.ZIndex = 2
|
||||
tabLine.Parent = Tabs
|
||||
|
||||
local InventoryButton = Instance.new("TextButton")
|
||||
InventoryButton.RobloxLocked = true
|
||||
InventoryButton.Name = "InventoryButton"
|
||||
InventoryButton.Size = UDim2.new(0,60,0,30)
|
||||
InventoryButton.Position = UDim2.new(0,7,1,-31)
|
||||
InventoryButton.BackgroundColor3 = Color3.new(1,1,1)
|
||||
InventoryButton.BorderColor3 = Color3.new(1,1,1)
|
||||
InventoryButton.Font = Enum.Font.ArialBold
|
||||
InventoryButton.FontSize = Enum.FontSize.Size18
|
||||
InventoryButton.Text = "Gear"
|
||||
InventoryButton.AutoButtonColor = false
|
||||
InventoryButton.TextColor3 = Color3.new(0,0,0)
|
||||
InventoryButton.Selected = true
|
||||
InventoryButton.Active = true
|
||||
InventoryButton.ZIndex = 3
|
||||
InventoryButton.Parent = Tabs
|
||||
|
||||
local closeButton = Instance.new("TextButton")
|
||||
closeButton.RobloxLocked = true
|
||||
closeButton.Name = "CloseButton"
|
||||
closeButton.Font = Enum.Font.ArialBold
|
||||
closeButton.FontSize = Enum.FontSize.Size24
|
||||
closeButton.Position = UDim2.new(1,-33,0,4)
|
||||
closeButton.Size = UDim2.new(0,30,0,30)
|
||||
closeButton.Style = Enum.ButtonStyle.RobloxButton
|
||||
closeButton.Text = ""
|
||||
closeButton.TextColor3 = Color3.new(1,1,1)
|
||||
closeButton.Parent = Tabs
|
||||
closeButton.Modal = true
|
||||
|
||||
--closeButton child
|
||||
local XImage = Instance.new("ImageLabel")
|
||||
XImage.RobloxLocked = true
|
||||
XImage.Name = "XImage"
|
||||
XImage.Image = "ayaasset://2015/BackpackBuilder/XImage.png" --TODO: move to ayaasset
|
||||
XImage.BackgroundTransparency = 1
|
||||
XImage.Position = UDim2.new(-.25,-1,-.25,-1)
|
||||
XImage.Size = UDim2.new(1.5,2,1.5,2)
|
||||
XImage.ZIndex = 2
|
||||
XImage.Parent = closeButton
|
||||
|
||||
-- Generic Search gui used across backpack
|
||||
local SearchFrame = Instance.new("Frame")
|
||||
SearchFrame.RobloxLocked = true
|
||||
SearchFrame.Name = "SearchFrame"
|
||||
SearchFrame.BackgroundTransparency = 1
|
||||
SearchFrame.Position = UDim2.new(1,-220,0,2)
|
||||
SearchFrame.Size = UDim2.new(0,220,0,24)
|
||||
SearchFrame.Parent = Backpack
|
||||
|
||||
-- SearchFrame Children
|
||||
local SearchButton = Instance.new("ImageButton")
|
||||
SearchButton.RobloxLocked = true
|
||||
SearchButton.Name = "SearchButton"
|
||||
SearchButton.Size = UDim2.new(0,25,0,25)
|
||||
SearchButton.BackgroundTransparency = 1
|
||||
SearchButton.Image = "ayaasset://textures/ui/SearchIcon.png"
|
||||
SearchButton.Parent = SearchFrame
|
||||
|
||||
local SearchBoxFrame = Instance.new("TextButton")
|
||||
SearchBoxFrame.RobloxLocked = true
|
||||
SearchBoxFrame.Position = UDim2.new(0,25,0,-2)
|
||||
SearchBoxFrame.Size = UDim2.new(1,-28,0,30)
|
||||
SearchBoxFrame.Name = "SearchBoxFrame"
|
||||
SearchBoxFrame.Text = ""
|
||||
SearchBoxFrame.Style = Enum.ButtonStyle.RobloxRoundButton
|
||||
SearchBoxFrame.Parent = SearchFrame
|
||||
|
||||
-- SearchBoxFrame Children
|
||||
local SearchBox = Instance.new("TextBox")
|
||||
SearchBox.RobloxLocked = true
|
||||
SearchBox.Name = "SearchBox"
|
||||
SearchBox.BackgroundTransparency = 1
|
||||
SearchBox.Font = Enum.Font.ArialBold
|
||||
SearchBox.FontSize = Enum.FontSize.Size12
|
||||
SearchBox.Position = UDim2.new(0,-5,0,-5)
|
||||
SearchBox.Size = UDim2.new(1,10,1,10)
|
||||
SearchBox.TextColor3 = Color3.new(1,1,1)
|
||||
SearchBox.TextXAlignment = Enum.TextXAlignment.Left
|
||||
SearchBox.ZIndex = 2
|
||||
SearchBox.TextWrap = true
|
||||
SearchBox.Text = "Search..."
|
||||
SearchBox.Parent = SearchBoxFrame
|
||||
|
||||
|
||||
local ResetButton = Instance.new("TextButton")
|
||||
ResetButton.RobloxLocked = true
|
||||
ResetButton.Visible = false
|
||||
ResetButton.Name = "ResetButton"
|
||||
ResetButton.Position = UDim2.new(1,-26,0,3)
|
||||
ResetButton.Size = UDim2.new(0,20,0,20)
|
||||
ResetButton.Style = Enum.ButtonStyle.RobloxButtonDefault
|
||||
ResetButton.Text = "X"
|
||||
ResetButton.TextColor3 = Color3.new(1,1,1)
|
||||
ResetButton.Font = Enum.Font.ArialBold
|
||||
ResetButton.FontSize = Enum.FontSize.Size18
|
||||
ResetButton.ZIndex = 3
|
||||
ResetButton.Parent = SearchFrame
|
||||
|
||||
------------------------------- GEAR -------------------------------------------------------
|
||||
local Gear = Instance.new("Frame")
|
||||
Gear.Name = "Gear"
|
||||
Gear.RobloxLocked = true
|
||||
Gear.BackgroundTransparency = 1
|
||||
Gear.Size = UDim2.new(1,0,1,0)
|
||||
Gear.ClipsDescendants = true
|
||||
Gear.Parent = Backpack
|
||||
|
||||
-- Gear Children
|
||||
local AssetsList = Instance.new("Frame")
|
||||
AssetsList.RobloxLocked = true
|
||||
AssetsList.Name = "AssetsList"
|
||||
AssetsList.BackgroundTransparency = 1
|
||||
AssetsList.Size = UDim2.new(0.2,0,1,0)
|
||||
AssetsList.Style = Enum.FrameStyle.RobloxSquare
|
||||
AssetsList.Visible = false
|
||||
AssetsList.Parent = Gear
|
||||
|
||||
local GearGrid = Instance.new("Frame")
|
||||
GearGrid.RobloxLocked = true
|
||||
GearGrid.Name = "GearGrid"
|
||||
GearGrid.Size = UDim2.new(0.95, 0, 1, 0)
|
||||
GearGrid.BackgroundTransparency = 1
|
||||
GearGrid.Parent = Gear
|
||||
|
||||
|
||||
local GearButton = Instance.new("ImageButton")
|
||||
GearButton.RobloxLocked = true
|
||||
GearButton.Visible = false
|
||||
GearButton.Name = "GearButton"
|
||||
GearButton.Size = UDim2.new(0, ICON_SIZE, 0, ICON_SIZE)
|
||||
GearButton.Style = 'Custom'
|
||||
GearButton.Parent = GearGrid
|
||||
GearButton.BackgroundTransparency = 1.0
|
||||
|
||||
local slotBackground = Instance.new('Frame')
|
||||
slotBackground.Name = 'Background'
|
||||
slotBackground.BackgroundTransparency = 1.0
|
||||
slotBackground.Size = UDim2.new(1, 16, 1, 16)
|
||||
slotBackground.Position = UDim2.new(0, -8, 0, -8)
|
||||
slotBackground.Parent = GearButton
|
||||
slotBackground.Style = "DropShadow"
|
||||
|
||||
|
||||
-- GearButton Children
|
||||
local GearReference = Instance.new("ObjectValue")
|
||||
GearReference.RobloxLocked = true
|
||||
GearReference.Name = "GearReference"
|
||||
GearReference.Parent = GearButton
|
||||
|
||||
local GreyOutButton = Instance.new("Frame")
|
||||
GreyOutButton.RobloxLocked = true
|
||||
GreyOutButton.Name = "GreyOutButton"
|
||||
GreyOutButton.BackgroundTransparency = 0.5
|
||||
GreyOutButton.Size = UDim2.new(1,0,1,0)
|
||||
GreyOutButton.Active = true
|
||||
GreyOutButton.Visible = false
|
||||
GreyOutButton.ZIndex = 3
|
||||
GreyOutButton.Parent = GearButton
|
||||
|
||||
local GearText = Instance.new("TextLabel")
|
||||
GearText.RobloxLocked = true
|
||||
GearText.Name = "GearText"
|
||||
GearText.BackgroundTransparency = 1
|
||||
GearText.Font = Enum.Font.Arial
|
||||
GearText.FontSize = Enum.FontSize.Size14
|
||||
GearText.Position = UDim2.new(0,-8,0,-8)
|
||||
GearText.Size = UDim2.new(1,16,1,16)
|
||||
GearText.Text = ""
|
||||
GearText.ZIndex = 2
|
||||
GearText.TextColor3 = Color3.new(1,1,1)
|
||||
GearText.TextWrap = true
|
||||
GearText.Parent = GearButton
|
||||
|
||||
local GearGridScrollingArea = Instance.new("Frame")
|
||||
GearGridScrollingArea.RobloxLocked = true
|
||||
GearGridScrollingArea.Name = "GearGridScrollingArea"
|
||||
GearGridScrollingArea.Position = UDim2.new(1, -19, 0, 35)
|
||||
GearGridScrollingArea.Size = UDim2.new(0, 17, 1, -45)
|
||||
GearGridScrollingArea.BackgroundTransparency = 1
|
||||
GearGridScrollingArea.Parent = Gear
|
||||
|
||||
local GearLoadouts = Instance.new("Frame")
|
||||
GearLoadouts.RobloxLocked = true
|
||||
GearLoadouts.Name = "GearLoadouts"
|
||||
GearLoadouts.BackgroundTransparency = 1
|
||||
GearLoadouts.Position = UDim2.new(0.7,23,0.5,1)
|
||||
GearLoadouts.Size = UDim2.new(0.3,-23,0.5,-1)
|
||||
GearLoadouts.Parent = Gear
|
||||
GearLoadouts.Visible = false
|
||||
|
||||
-- GearLoadouts Children
|
||||
local GearLoadoutsHeader = Instance.new("Frame")
|
||||
GearLoadoutsHeader.RobloxLocked = true
|
||||
GearLoadoutsHeader.Name = "GearLoadoutsHeader"
|
||||
GearLoadoutsHeader.BackgroundColor3 = Color3.new(0,0,0)
|
||||
GearLoadoutsHeader.BackgroundTransparency = 0.2
|
||||
GearLoadoutsHeader.BorderColor3 = Color3.new(1,0,0)
|
||||
GearLoadoutsHeader.Size = UDim2.new(1,2,0.15,-1)
|
||||
GearLoadoutsHeader.Parent = GearLoadouts
|
||||
|
||||
-- GearLoadoutsHeader Children
|
||||
local LoadoutsHeaderText = Instance.new("TextLabel")
|
||||
LoadoutsHeaderText.RobloxLocked = true
|
||||
LoadoutsHeaderText.Name = "LoadoutsHeaderText"
|
||||
LoadoutsHeaderText.BackgroundTransparency = 1
|
||||
LoadoutsHeaderText.Font = Enum.Font.ArialBold
|
||||
LoadoutsHeaderText.FontSize = Enum.FontSize.Size18
|
||||
LoadoutsHeaderText.Size = UDim2.new(1,0,1,0)
|
||||
LoadoutsHeaderText.Text = "Loadouts"
|
||||
LoadoutsHeaderText.TextColor3 = Color3.new(1,1,1)
|
||||
LoadoutsHeaderText.Parent = GearLoadoutsHeader
|
||||
|
||||
local GearLoadoutsScrollingArea = GearGridScrollingArea:clone()
|
||||
GearLoadoutsScrollingArea.RobloxLocked = true
|
||||
GearLoadoutsScrollingArea.Name = "GearLoadoutsScrollingArea"
|
||||
GearLoadoutsScrollingArea.Position = UDim2.new(1,-15,0.15,2)
|
||||
GearLoadoutsScrollingArea.Size = UDim2.new(0,17,0.85,-2)
|
||||
GearLoadoutsScrollingArea.Parent = GearLoadouts
|
||||
|
||||
local LoadoutsList = Instance.new("Frame")
|
||||
LoadoutsList.RobloxLocked = true
|
||||
LoadoutsList.Name = "LoadoutsList"
|
||||
LoadoutsList.Position = UDim2.new(0,0,0.15,2)
|
||||
LoadoutsList.Size = UDim2.new(1,-17,0.85,-2)
|
||||
LoadoutsList.Style = Enum.FrameStyle.RobloxSquare
|
||||
LoadoutsList.Parent = GearLoadouts
|
||||
|
||||
local GearPreview = Instance.new("Frame")
|
||||
GearPreview.RobloxLocked = true
|
||||
GearPreview.Name = "GearPreview"
|
||||
GearPreview.Position = UDim2.new(0.7,23,0,0)
|
||||
GearPreview.Size = UDim2.new(0.3,-28,0.5,-1)
|
||||
GearPreview.BackgroundTransparency = 1
|
||||
GearPreview.ZIndex = 7
|
||||
GearPreview.Parent = Gear
|
||||
|
||||
-- GearPreview Children
|
||||
local GearStats = Instance.new("Frame")
|
||||
GearStats.RobloxLocked = true
|
||||
GearStats.Name = "GearStats"
|
||||
GearStats.BackgroundTransparency = 1
|
||||
GearStats.Position = UDim2.new(0,0,0.75,0)
|
||||
GearStats.Size = UDim2.new(1,0,0.25,0)
|
||||
GearStats.ZIndex = 8
|
||||
GearStats.Parent = GearPreview
|
||||
|
||||
-- GearStats Children
|
||||
local GearName = Instance.new("TextLabel")
|
||||
GearName.RobloxLocked = true
|
||||
GearName.Name = "GearName"
|
||||
GearName.BackgroundTransparency = 1
|
||||
GearName.Font = Enum.Font.ArialBold
|
||||
GearName.FontSize = Enum.FontSize.Size18
|
||||
GearName.Position = UDim2.new(0,-3,0,0)
|
||||
GearName.Size = UDim2.new(1,6,1,5)
|
||||
GearName.Text = ""
|
||||
GearName.TextColor3 = Color3.new(1,1,1)
|
||||
GearName.TextWrap = true
|
||||
GearName.ZIndex = 9
|
||||
GearName.Parent = GearStats
|
||||
|
||||
local GearImage = Instance.new("ImageLabel")
|
||||
GearImage.RobloxLocked = true
|
||||
GearImage.Name = "GearImage"
|
||||
GearImage.Image = ""
|
||||
GearImage.BackgroundTransparency = 1
|
||||
GearImage.Position = UDim2.new(0.125,0,0,0)
|
||||
GearImage.Size = UDim2.new(0.75,0,0.75,0)
|
||||
GearImage.ZIndex = 8
|
||||
GearImage.Parent = GearPreview
|
||||
|
||||
--GearImage Children
|
||||
local GearIcons = Instance.new("Frame")
|
||||
GearIcons.BackgroundColor3 = Color3.new(0,0,0)
|
||||
GearIcons.BackgroundTransparency = 0.5
|
||||
GearIcons.BorderSizePixel = 0
|
||||
GearIcons.RobloxLocked = true
|
||||
GearIcons.Name = "GearIcons"
|
||||
GearIcons.Position = UDim2.new(0.4,2,0.85,-2)
|
||||
GearIcons.Size = UDim2.new(0.6,0,0.15,0)
|
||||
GearIcons.Visible = false
|
||||
GearIcons.ZIndex = 9
|
||||
GearIcons.Parent = GearImage
|
||||
|
||||
-- GearIcons Children
|
||||
local GenreImage = Instance.new("ImageLabel")
|
||||
GenreImage.RobloxLocked = true
|
||||
GenreImage.Name = "GenreImage"
|
||||
GenreImage.BackgroundColor3 = Color3.new(102/255,153/255,1)
|
||||
GenreImage.BackgroundTransparency = 0.5
|
||||
GenreImage.BorderSizePixel = 0
|
||||
GenreImage.Size = UDim2.new(0.25,0,1,0)
|
||||
GenreImage.Parent = GearIcons
|
||||
|
||||
local AttributeOneImage = GenreImage:clone()
|
||||
AttributeOneImage.RobloxLocked = true
|
||||
AttributeOneImage.Name = "AttributeOneImage"
|
||||
AttributeOneImage.BackgroundColor3 = Color3.new(1,51/255,0)
|
||||
AttributeOneImage.Position = UDim2.new(0.25,0,0,0)
|
||||
AttributeOneImage.Parent = GearIcons
|
||||
|
||||
local AttributeTwoImage = GenreImage:clone()
|
||||
AttributeTwoImage.RobloxLocked = true
|
||||
AttributeTwoImage.Name = "AttributeTwoImage"
|
||||
AttributeTwoImage.BackgroundColor3 = Color3.new(153/255,1,153/255)
|
||||
AttributeTwoImage.Position = UDim2.new(0.5,0,0,0)
|
||||
AttributeTwoImage.Parent = GearIcons
|
||||
|
||||
local AttributeThreeImage = GenreImage:clone()
|
||||
AttributeThreeImage.RobloxLocked = true
|
||||
AttributeThreeImage.Name = "AttributeThreeImage"
|
||||
AttributeThreeImage.BackgroundColor3 = Color3.new(0,0.5,0.5)
|
||||
AttributeThreeImage.Position = UDim2.new(0.75,0,0,0)
|
||||
AttributeThreeImage.Parent = GearIcons
|
||||
|
||||
script:Destroy()
|
||||
659
client/common/content/scripts/CoreScripts/2015/BubbleChat.lua
Normal file
659
client/common/content/scripts/CoreScripts/2015/BubbleChat.lua
Normal file
@@ -0,0 +1,659 @@
|
||||
--[[
|
||||
// FileName: BubbleChat.lua
|
||||
// Written by: jeditkacheff
|
||||
// Description: Code for rendering bubble chat
|
||||
]]
|
||||
|
||||
--[[ SERVICES ]]
|
||||
local RunService = game:GetService('RunService')
|
||||
local CoreGuiService = game:GetService('CoreGui')
|
||||
local PlayersService = game:GetService('Players')
|
||||
local ChatService = game:GetService("Chat")
|
||||
local TextService = game:GetService("TextService")
|
||||
local GameOptions = settings()["Game Options"]
|
||||
--[[ END OF SERVICES ]]
|
||||
|
||||
|
||||
while PlayersService.LocalPlayer == nil do PlayersService.ChildAdded:wait() end
|
||||
local GuiRoot = CoreGuiService:WaitForChild('RobloxGui')
|
||||
-- local playerDropDownModule = require(GuiRoot.Modules:WaitForChild("PlayerDropDown"))
|
||||
-- local blockingUtility = playerDropDownModule:CreateBlockingUtility()
|
||||
|
||||
|
||||
--[[ SCRIPT VARIABLES ]]
|
||||
local CHAT_BUBBLE_FONT = Enum.Font.SourceSans
|
||||
local CHAT_BUBBLE_FONT_SIZE = Enum.FontSize.Size24 -- if you change CHAT_BUBBLE_FONT_SIZE_INT please change this to match
|
||||
local CHAT_BUBBLE_FONT_SIZE_INT = 24 -- if you change CHAT_BUBBLE_FONT_SIZE please change this to match
|
||||
local CHAT_BUBBLE_LINE_HEIGHT = CHAT_BUBBLE_FONT_SIZE_INT + 40
|
||||
local CHAT_BUBBLE_TAIL_HEIGHT = 20
|
||||
local CHAT_BUBBLE_WIDTH_PADDING = 60
|
||||
local CHAT_BUBBLE_FADE_SPEED = 1.5
|
||||
|
||||
local BILLBOARD_MAX_WIDTH = 400
|
||||
local BILLBOARD_MAX_HEIGHT = 250 --This limits the number of bubble chats that you see above characters
|
||||
|
||||
local ELIPSES = "..."
|
||||
local CchMaxChatMessageLength = 128 -- max chat message length, including null terminator and elipses.
|
||||
local CchMaxChatMessageLengthExclusive = CchMaxChatMessageLength - string.len(ELIPSES) - 1
|
||||
|
||||
local NEAR_BUBBLE_DISTANCE = 80 -- 65 --previously 45
|
||||
local MAX_BUBBLE_DISTANCE = 80 --100 --previously 80
|
||||
|
||||
--[[ END OF SCRIPT VARIABLES ]]
|
||||
|
||||
|
||||
-- [[ SCRIPT ENUMS ]]
|
||||
local ChatType = { PLAYER_CHAT = "pChat",
|
||||
PLAYER_TEAM_CHAT = "pChatTeam",
|
||||
PLAYER_WHISPER_CHAT = "pChatWhisper",
|
||||
GAME_MESSAGE= "gMessage",
|
||||
PLAYER_GAME_CHAT = "pGame",
|
||||
BOT_CHAT = "bChat" }
|
||||
|
||||
local BubbleColor = { WHITE = "dub",
|
||||
BLUE = "blu",
|
||||
GREEN = "gre",
|
||||
RED = "red" }
|
||||
|
||||
--[[ END OF SCRIPT ENUMS ]]
|
||||
|
||||
|
||||
|
||||
--[[ FUNCTIONS ]]
|
||||
|
||||
local function lerpLength(msg, min, max)
|
||||
return min + (max-min) * math.min(string.len(msg)/75.0, 1.0)
|
||||
end
|
||||
|
||||
local function createFifo()
|
||||
local this = {}
|
||||
this.data = {}
|
||||
|
||||
local emptyEvent = Instance.new("BindableEvent")
|
||||
this.Emptied = emptyEvent.Event
|
||||
|
||||
function this:Size()
|
||||
return #this.data
|
||||
end
|
||||
|
||||
function this:Empty()
|
||||
return this:Size() <= 0
|
||||
end
|
||||
|
||||
function this:PopFront()
|
||||
table.remove(this.data, 1)
|
||||
if this:Empty() then emptyEvent:Fire() end
|
||||
end
|
||||
|
||||
function this:Front()
|
||||
return this.data[1]
|
||||
end
|
||||
|
||||
function this:Get(index)
|
||||
return this.data[index]
|
||||
end
|
||||
|
||||
function this:PushBack(value)
|
||||
table.insert(this.data, value)
|
||||
end
|
||||
|
||||
function this:GetData()
|
||||
return this.data
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
local function createCharacterChats()
|
||||
local this = {}
|
||||
|
||||
this.Fifo = createFifo()
|
||||
this.BillboardGui = nil
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
local function createMap()
|
||||
local this = {}
|
||||
this.data = {}
|
||||
local count = 0
|
||||
|
||||
function this:Size()
|
||||
return count
|
||||
end
|
||||
|
||||
function this:Erase(key)
|
||||
if this.data[key] then count = count - 1 end
|
||||
this.data[key] = nil
|
||||
end
|
||||
|
||||
function this:Set(key, value)
|
||||
this.data[key] = value
|
||||
if value then count = count + 1 end
|
||||
end
|
||||
|
||||
function this:Get(key)
|
||||
if not this.data[key] then
|
||||
this.data[key] = createCharacterChats()
|
||||
local emptiedCon = nil
|
||||
emptiedCon = this.data[key].Fifo.Emptied:connect(function()
|
||||
emptiedCon:disconnect()
|
||||
this:Erase(key)
|
||||
end)
|
||||
end
|
||||
return this.data[key]
|
||||
end
|
||||
|
||||
function this:GetData()
|
||||
return this.data
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
local function createChatLine(chatType, message, bubbleColor, isLocalPlayer)
|
||||
local this = {}
|
||||
|
||||
function this:ComputeBubbleLifetime(msg, isSelf)
|
||||
if isSelf then
|
||||
return lerpLength(msg,8,15)
|
||||
else
|
||||
return lerpLength(msg,12,20)
|
||||
end
|
||||
end
|
||||
|
||||
function this:IsPlayerChat()
|
||||
if not this.ChatType then return false end
|
||||
|
||||
if this.ChatType == ChatType.PLAYER_CHAT or
|
||||
this.ChatType == ChatType.PLAYER_WHISPER_CHAT or
|
||||
this.ChatType == ChatType.PLAYER_TEAM_CHAT then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
this.ChatType = chatType
|
||||
this.Origin = nil
|
||||
this.RenderBubble = nil
|
||||
this.Message = message
|
||||
this.BubbleDieDelay = this:ComputeBubbleLifetime(message, isLocalPlayer)
|
||||
this.BubbleColor = bubbleColor
|
||||
this.IsLocalPlayer = isLocalPlayer
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
local function createPlayerChatLine(chatType, player, message, isLocalPlayer)
|
||||
local this = createChatLine(chatType, message, BubbleColor.WHITE, isLocalPlayer)
|
||||
|
||||
if player then
|
||||
this.User = player.Name
|
||||
this.Origin = player.Character
|
||||
end
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
local function createGameChatLine(origin, message, isLocalPlayer, bubbleColor)
|
||||
local this = createChatLine(origin and ChatType.PLAYER_GAME_CHAT or ChatType.BOT_CHAT, message, bubbleColor, isLocalPlayer)
|
||||
this.Origin = origin
|
||||
|
||||
return this
|
||||
end
|
||||
|
||||
function createChatBubbleMain(filePrefix, sliceRect)
|
||||
local chatBubbleMain = Instance.new("ImageLabel")
|
||||
chatBubbleMain.Name = "ChatBubble"
|
||||
chatBubbleMain.ScaleType = Enum.ScaleType.Slice
|
||||
chatBubbleMain.SliceCenter = sliceRect
|
||||
chatBubbleMain.Image = "ayaasset://textures/" .. tostring(filePrefix) .. ".png"
|
||||
chatBubbleMain.BackgroundTransparency = 1
|
||||
chatBubbleMain.BorderSizePixel = 0
|
||||
chatBubbleMain.Size = UDim2.new(1.0, 0, 1.0, 0)
|
||||
chatBubbleMain.Position = UDim2.new(0,0,0,0)
|
||||
|
||||
return chatBubbleMain
|
||||
end
|
||||
|
||||
function createChatBubbleTail(position, size)
|
||||
local chatBubbleTail = Instance.new("ImageLabel")
|
||||
chatBubbleTail.Name = "ChatBubbleTail"
|
||||
chatBubbleTail.Image = "ayaasset://textures/2015/ui/dialog_tail.png"
|
||||
chatBubbleTail.BackgroundTransparency = 1
|
||||
chatBubbleTail.BorderSizePixel = 0
|
||||
chatBubbleTail.Position = position
|
||||
chatBubbleTail.Size = size
|
||||
|
||||
return chatBubbleTail
|
||||
end
|
||||
|
||||
function createChatBubbleWithTail(filePrefix, position, size, sliceRect)
|
||||
local chatBubbleMain = createChatBubbleMain(filePrefix, sliceRect)
|
||||
|
||||
local chatBubbleTail = createChatBubbleTail(position, size)
|
||||
chatBubbleTail.Parent = chatBubbleMain
|
||||
|
||||
return chatBubbleMain
|
||||
end
|
||||
|
||||
function createScaledChatBubbleWithTail(filePrefix, frameScaleSize, position, sliceRect)
|
||||
local chatBubbleMain = createChatBubbleMain(filePrefix, sliceRect)
|
||||
|
||||
local frame = Instance.new("Frame")
|
||||
frame.Name = "ChatBubbleTailFrame"
|
||||
frame.BackgroundTransparency = 1
|
||||
frame.SizeConstraint = Enum.SizeConstraint.RelativeXX
|
||||
frame.Position = UDim2.new(0.5, 0, 1, 0)
|
||||
frame.Size = UDim2.new(frameScaleSize, 0, frameScaleSize, 0)
|
||||
frame.Parent = chatBubbleMain
|
||||
|
||||
local chatBubbleTail = createChatBubbleTail(position, UDim2.new(1,0,0.5,-20))
|
||||
chatBubbleTail.Parent = frame
|
||||
|
||||
return chatBubbleMain
|
||||
end
|
||||
|
||||
function createChatImposter(filePrefix, dotDotDot, yOffset)
|
||||
local result = Instance.new("ImageLabel")
|
||||
result.Name = "DialogPlaceholder"
|
||||
result.Image = "ayaasset://textures/" .. tostring(filePrefix) .. ".png"
|
||||
result.BackgroundTransparency = 1
|
||||
result.BorderSizePixel = 0
|
||||
result.Position = UDim2.new(0, 0, -1.25, 0)
|
||||
result.Size = UDim2.new(1, 0, 1, 0)
|
||||
|
||||
local image = Instance.new("ImageLabel")
|
||||
image.Name = "DotDotDot"
|
||||
image.Image = "ayaasset://textures/" .. tostring(dotDotDot) .. ".png"
|
||||
image.BackgroundTransparency = 1
|
||||
image.BorderSizePixel = 0
|
||||
image.Position = UDim2.new(0.001, 0, yOffset, 0)
|
||||
image.Size = UDim2.new(1, 0, 0.7, 0)
|
||||
image.Parent = result
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
local function createChatOutput()
|
||||
|
||||
local this = {}
|
||||
this.ChatBubble = {}
|
||||
this.ChatBubbleWithTail = {}
|
||||
this.ScalingChatBubbleWithTail = {}
|
||||
this.CharacterSortedMsg = createMap()
|
||||
|
||||
-- init chat bubble tables
|
||||
local function initChatBubbleType(chatBubbleType, fileName, imposterFileName, isInset, sliceRect)
|
||||
this.ChatBubble[chatBubbleType] = createChatBubbleMain(fileName, sliceRect)
|
||||
this.ChatBubbleWithTail[chatBubbleType] = createChatBubbleWithTail(fileName, UDim2.new(0.5, -CHAT_BUBBLE_TAIL_HEIGHT + 5, 0.995, 0), UDim2.new(0, 30, 0, 15), sliceRect)
|
||||
this.ScalingChatBubbleWithTail[chatBubbleType] = createScaledChatBubbleWithTail(fileName, 0.01, UDim2.new(-0.4, 0, 0, isInset and -1 or 0), sliceRect)
|
||||
end
|
||||
|
||||
initChatBubbleType(BubbleColor.WHITE, "2015/ui/dialog_white", "2015/ui/chatBubble_white_notify_bkg", false, Rect.new(23,23,23,23))
|
||||
initChatBubbleType(BubbleColor.BLUE, "ui/dialog_blue", "ui/chatBubble_blue_notify_bkg", true, Rect.new(7,7,33,33))
|
||||
initChatBubbleType(BubbleColor.RED, "ui/dialog_red", "ui/chatBubble_red_notify_bkg", true, Rect.new(7,7,33,33))
|
||||
initChatBubbleType(BubbleColor.GREEN, "ui/dialog_green", "ui/chatBubble_green_notify_bkg", true, Rect.new(7,7,33,33))
|
||||
|
||||
function this:SanitizeChatLine(msg)
|
||||
if string.len(msg) > CchMaxChatMessageLengthExclusive then
|
||||
return string.sub(msg, 1, CchMaxChatMessageLengthExclusive + string.len(ELIPSES))
|
||||
else
|
||||
return msg
|
||||
end
|
||||
end
|
||||
|
||||
local function createBillboardInstance(adornee)
|
||||
local billboardGui = Instance.new("BillboardGui")
|
||||
billboardGui.Adornee = adornee
|
||||
billboardGui.RobloxLocked = true
|
||||
billboardGui.Size = UDim2.new(0,BILLBOARD_MAX_WIDTH,0,BILLBOARD_MAX_HEIGHT)
|
||||
billboardGui.StudsOffset = Vector3.new(0, 1.5, 2)
|
||||
billboardGui.Parent = CoreGuiService
|
||||
|
||||
local billboardFrame = Instance.new("Frame")
|
||||
billboardFrame.Name = "BillboardFrame"
|
||||
billboardFrame.Size = UDim2.new(1,0,1,0)
|
||||
billboardFrame.Position = UDim2.new(0,0,-0.5,0)
|
||||
billboardFrame.BackgroundTransparency = 1
|
||||
billboardFrame.Parent = billboardGui
|
||||
|
||||
local billboardChildRemovedCon = nil
|
||||
billboardChildRemovedCon = billboardFrame.ChildRemoved:connect(function()
|
||||
if #billboardFrame:GetChildren() <= 1 then
|
||||
billboardChildRemovedCon:disconnect()
|
||||
billboardGui:Destroy()
|
||||
end
|
||||
end)
|
||||
|
||||
this:CreateSmallTalkBubble(BubbleColor.WHITE).Parent = billboardFrame
|
||||
|
||||
return billboardGui
|
||||
end
|
||||
|
||||
function this:CreateBillboardGuiHelper(instance, onlyCharacter)
|
||||
if not this.CharacterSortedMsg:Get(instance)["BillboardGui"] then
|
||||
if not onlyCharacter then
|
||||
if instance:IsA("Part") then
|
||||
-- Create a new billboardGui object attached to this player
|
||||
local billboardGui = createBillboardInstance(instance)
|
||||
this.CharacterSortedMsg:Get(instance)["BillboardGui"] = billboardGui
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if instance:IsA("Model") then
|
||||
local head = instance:FindFirstChild("Head")
|
||||
if head and head:IsA("Part") then
|
||||
-- Create a new billboardGui object attached to this player
|
||||
local billboardGui = createBillboardInstance(head)
|
||||
this.CharacterSortedMsg:Get(instance)["BillboardGui"] = billboardGui
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function distanceToBubbleOrigin(origin)
|
||||
if not origin then return 100000 end
|
||||
|
||||
return (origin.Position - game.Workspace.CurrentCamera.CoordinateFrame.p).magnitude
|
||||
end
|
||||
|
||||
local function isPartOfLocalPlayer(adornee)
|
||||
if adornee and PlayersService.LocalPlayer.Character then
|
||||
return adornee:IsDescendantOf(PlayersService.LocalPlayer.Character)
|
||||
end
|
||||
end
|
||||
|
||||
function this:SetBillboardLODNear(billboardGui)
|
||||
local isLocalPlayer = isPartOfLocalPlayer(billboardGui.Adornee)
|
||||
billboardGui.Size = UDim2.new(0, BILLBOARD_MAX_WIDTH, 0, BILLBOARD_MAX_HEIGHT)
|
||||
billboardGui.StudsOffset = Vector3.new(0, isLocalPlayer and 1.5 or 2.5, isLocalPlayer and 2 or 0)
|
||||
billboardGui.Enabled = true
|
||||
local billChildren = billboardGui.BillboardFrame:GetChildren()
|
||||
for i = 1, #billChildren do
|
||||
billChildren[i].Visible = true
|
||||
end
|
||||
billboardGui.BillboardFrame.SmallTalkBubble.Visible = false
|
||||
end
|
||||
|
||||
function this:SetBillboardLODDistant(billboardGui)
|
||||
local isLocalPlayer = isPartOfLocalPlayer(billboardGui.Adornee)
|
||||
billboardGui.Size = UDim2.new(4,0,3,0)
|
||||
billboardGui.StudsOffset = Vector3.new(0, 3, isLocalPlayer and 2 or 0)
|
||||
billboardGui.Enabled = true
|
||||
local billChildren = billboardGui.BillboardFrame:GetChildren()
|
||||
for i = 1, #billChildren do
|
||||
billChildren[i].Visible = false
|
||||
end
|
||||
billboardGui.BillboardFrame.SmallTalkBubble.Visible = true
|
||||
end
|
||||
|
||||
function this:SetBillboardLODVeryFar(billboardGui)
|
||||
billboardGui.Enabled = false
|
||||
end
|
||||
|
||||
function this:SetBillboardGuiLOD(billboardGui, origin)
|
||||
if not origin then return end
|
||||
|
||||
if origin:IsA("Model") then
|
||||
local head = origin:FindFirstChild("Head")
|
||||
if not head then origin = origin.PrimaryPart
|
||||
else origin = head end
|
||||
end
|
||||
|
||||
local bubbleDistance = distanceToBubbleOrigin(origin)
|
||||
|
||||
if bubbleDistance < NEAR_BUBBLE_DISTANCE then
|
||||
this:SetBillboardLODNear(billboardGui)
|
||||
elseif bubbleDistance >= NEAR_BUBBLE_DISTANCE and bubbleDistance < MAX_BUBBLE_DISTANCE then
|
||||
this:SetBillboardLODDistant(billboardGui)
|
||||
else
|
||||
this:SetBillboardLODVeryFar(billboardGui)
|
||||
end
|
||||
end
|
||||
|
||||
function this:CameraCFrameChanged()
|
||||
for index, value in pairs(this.CharacterSortedMsg:GetData()) do
|
||||
local playerBillboardGui = value["BillboardGui"]
|
||||
if playerBillboardGui then this:SetBillboardGuiLOD(playerBillboardGui, index) end
|
||||
end
|
||||
end
|
||||
|
||||
function this:CreateBubbleText(message)
|
||||
local bubbleText = Instance.new("TextLabel")
|
||||
bubbleText.Name = "BubbleText"
|
||||
bubbleText.BackgroundTransparency = 1
|
||||
bubbleText.Position = UDim2.new(0,CHAT_BUBBLE_WIDTH_PADDING/2,0,0)
|
||||
bubbleText.Size = UDim2.new(1,-CHAT_BUBBLE_WIDTH_PADDING,1,0)
|
||||
bubbleText.Font = CHAT_BUBBLE_FONT
|
||||
bubbleText.TextWrapped = true
|
||||
bubbleText.FontSize = CHAT_BUBBLE_FONT_SIZE
|
||||
bubbleText.Text = message
|
||||
bubbleText.Visible = false
|
||||
|
||||
return bubbleText
|
||||
end
|
||||
|
||||
function this:CreateSmallTalkBubble(chatBubbleType)
|
||||
local smallTalkBubble = this.ScalingChatBubbleWithTail[chatBubbleType]:Clone()
|
||||
smallTalkBubble.Name = "SmallTalkBubble"
|
||||
smallTalkBubble.Position = UDim2.new(0,0,1,-40)
|
||||
smallTalkBubble.Visible = false
|
||||
local text = this:CreateBubbleText("...")
|
||||
text.TextScaled = true
|
||||
text.TextWrapped = false
|
||||
text.Visible = true
|
||||
text.Parent = smallTalkBubble
|
||||
|
||||
return smallTalkBubble
|
||||
end
|
||||
|
||||
function this:UpdateChatLinesForOrigin(origin, currentBubbleYPos)
|
||||
local bubbleQueue = this.CharacterSortedMsg:Get(origin).Fifo
|
||||
local bubbleQueueSize = bubbleQueue:Size()
|
||||
local bubbleQueueData = bubbleQueue:GetData()
|
||||
if #bubbleQueueData <= 1 then return end
|
||||
|
||||
for index = (#bubbleQueueData - 1), 1, -1 do
|
||||
local value = bubbleQueueData[index]
|
||||
local bubble = value.RenderBubble
|
||||
if not bubble then return end
|
||||
local bubblePos = bubbleQueueSize - index + 1
|
||||
|
||||
if bubblePos > 1 then
|
||||
local tail = bubble:FindFirstChild("ChatBubbleTail")
|
||||
if tail then tail:Destroy() end
|
||||
local bubbleText = bubble:FindFirstChild("BubbleText")
|
||||
if bubbleText then bubbleText.TextTransparency = 0.5 end
|
||||
end
|
||||
|
||||
|
||||
local udimValue = UDim2.new( bubble.Position.X.Scale, bubble.Position.X.Offset,
|
||||
1, currentBubbleYPos - bubble.Size.Y.Offset )
|
||||
bubble:TweenPosition(udimValue, Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.00000001, true)
|
||||
currentBubbleYPos = currentBubbleYPos - bubble.Size.Y.Offset
|
||||
end
|
||||
end
|
||||
|
||||
function this:DestroyBubble(bubbleQueue, bubbleToDestroy)
|
||||
if not bubbleQueue then return end
|
||||
if bubbleQueue:Empty() then return end
|
||||
|
||||
local bubble = bubbleQueue:Front().RenderBubble
|
||||
if not bubble then
|
||||
bubbleQueue:PopFront()
|
||||
return
|
||||
end
|
||||
|
||||
spawn(function()
|
||||
while bubbleQueue:Front().RenderBubble ~= bubbleToDestroy do
|
||||
wait()
|
||||
end
|
||||
|
||||
bubble = bubbleQueue:Front().RenderBubble
|
||||
|
||||
local timeBetween = 0
|
||||
local bubbleText = bubble:FindFirstChild("BubbleText")
|
||||
local bubbleTail = bubble:FindFirstChild("ChatBubbleTail")
|
||||
|
||||
--[[
|
||||
while bubble and bubble.ImageTransparency < 1 do
|
||||
timeBetween = wait()
|
||||
if bubble then
|
||||
local fadeAmount = timeBetween * CHAT_BUBBLE_FADE_SPEED
|
||||
bubble.ImageTransparency = bubble.ImageTransparency + fadeAmount
|
||||
if bubbleText then bubbleText.TextTransparency = bubbleText.TextTransparency + fadeAmount end
|
||||
if bubbleTail then bubbleTail.ImageTransparency = bubbleTail.ImageTransparency + fadeAmount end
|
||||
end
|
||||
end]]
|
||||
|
||||
if bubble then
|
||||
bubble:Destroy()
|
||||
bubbleQueue:PopFront()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function this:CreateChatLineRender(instance, line, onlyCharacter, fifo)
|
||||
if not this.CharacterSortedMsg:Get(instance)["BillboardGui"] then
|
||||
this:CreateBillboardGuiHelper(instance, onlyCharacter)
|
||||
end
|
||||
|
||||
local billboardGui = this.CharacterSortedMsg:Get(instance)["BillboardGui"]
|
||||
local chatBubbleRender = this.ChatBubbleWithTail[line.BubbleColor]:Clone()
|
||||
chatBubbleRender.Visible = false
|
||||
local bubbleText = this:CreateBubbleText(line.Message)
|
||||
|
||||
bubbleText.Parent = chatBubbleRender
|
||||
chatBubbleRender.Parent = billboardGui.BillboardFrame
|
||||
|
||||
line.RenderBubble = chatBubbleRender
|
||||
|
||||
local currentTextBounds = TextService:GetTextSize(bubbleText.Text, CHAT_BUBBLE_FONT_SIZE_INT, CHAT_BUBBLE_FONT,
|
||||
Vector2.new(BILLBOARD_MAX_WIDTH, BILLBOARD_MAX_HEIGHT))
|
||||
local bubbleWidthScale = math.max((currentTextBounds.x + CHAT_BUBBLE_WIDTH_PADDING)/BILLBOARD_MAX_WIDTH, 0.1)
|
||||
local numOflines = (currentTextBounds.y/CHAT_BUBBLE_FONT_SIZE_INT)
|
||||
|
||||
-- prep chat bubble for tween
|
||||
chatBubbleRender.Size = UDim2.new(0,0,0,0)
|
||||
chatBubbleRender.Position = UDim2.new(0.5,0,1,0)
|
||||
|
||||
local newChatBubbleOffsetSizeY = numOflines * CHAT_BUBBLE_LINE_HEIGHT
|
||||
|
||||
chatBubbleRender:TweenSizeAndPosition(UDim2.new(bubbleWidthScale, 0, 0, newChatBubbleOffsetSizeY),
|
||||
UDim2.new( (1-bubbleWidthScale)/2, 0, 1, -newChatBubbleOffsetSizeY),
|
||||
Enum.EasingDirection.Out, Enum.EasingStyle.Elastic, 0.1, true,
|
||||
function() bubbleText.Visible = true end)
|
||||
|
||||
-- todo: remove when over max bubbles
|
||||
this:SetBillboardGuiLOD(billboardGui, line.Origin)
|
||||
this:UpdateChatLinesForOrigin(line.Origin, -newChatBubbleOffsetSizeY)
|
||||
|
||||
delay(line.BubbleDieDelay, function()
|
||||
this:DestroyBubble(fifo, chatBubbleRender)
|
||||
end)
|
||||
end
|
||||
|
||||
local testLabel = Instance.new('TextLabel')
|
||||
function isLabelTextAllowed(message)
|
||||
--There exists an internal filter that filters out some profanity. It does this silently if you try to set text of an object.
|
||||
--Here we check if the message is going to be filtered by applying it and comparing it.
|
||||
testLabel.Text = message
|
||||
return (testLabel.Text == message)
|
||||
end
|
||||
|
||||
function this:OnPlayerChatMessage(chatType, sourcePlayer, message, targetPlayer)
|
||||
if not this:BubbleChatEnabled() then return end
|
||||
|
||||
-- eliminate display of commands
|
||||
if string.sub(message, 1, 1) == '/' then return end
|
||||
|
||||
local localPlayer = PlayersService.LocalPlayer
|
||||
local fromOthers = localPlayer ~= nil and sourcePlayer ~= localPlayer
|
||||
|
||||
-- annihilate chats made by blocked or muted players
|
||||
-- if blockingUtility:IsPlayerBlockedByUserId(sourcePlayer.userId) or blockingUtility:IsPlayerMutedByUserId(sourcePlayer.userId) then return end
|
||||
|
||||
-- remove messages that are filtered from the default gui text filter
|
||||
if not isLabelTextAllowed(message) then return end
|
||||
|
||||
local luaChatType = ChatType.PLAYER_CHAT
|
||||
if chatType == Enum.PlayerChatType.Team then
|
||||
luaChatType = ChatType.PLAYER_TEAM_CHAT
|
||||
elseif chatType == Enum.PlayerChatType.All then
|
||||
luaChatType = ChatType.PLAYER_GAME_CHAT
|
||||
elseif chatType == Enum.PlayerChatType.Whisper then
|
||||
luaChatType = ChatType.PLAYER_WHISPER_CHAT
|
||||
end
|
||||
|
||||
local safeMessage = this:SanitizeChatLine(message)
|
||||
|
||||
local line = createPlayerChatLine(chatType, sourcePlayer, safeMessage, not fromOthers)
|
||||
|
||||
local fifo = this.CharacterSortedMsg:Get(line.Origin).Fifo
|
||||
fifo:PushBack(line)
|
||||
|
||||
if sourcePlayer then
|
||||
--Game chat (badges) won't show up here
|
||||
this:CreateChatLineRender(sourcePlayer.Character, line, true, fifo)
|
||||
end
|
||||
end
|
||||
|
||||
function this:OnGameChatMessage(origin, message, color)
|
||||
if not this:BubbleChatEnabled() then return end
|
||||
|
||||
local localPlayer = PlayersService.LocalPlayer
|
||||
local fromOthers = localPlayer ~= nil and (localPlayer.Character ~= origin)
|
||||
|
||||
local bubbleColor = BubbleColor.WHITE
|
||||
|
||||
if color == Enum.ChatColor.Blue then bubbleColor = BubbleColor.BLUE
|
||||
elseif color == Enum.ChatColor.Green then bubbleColor = BubbleColor.GREEN
|
||||
elseif color == Enum.ChatColor.Red then bubbleColor = BubbleColor.RED end
|
||||
|
||||
local safeMessage = this:SanitizeChatLine(message)
|
||||
local line = createGameChatLine(origin, safeMessage, not fromOthers, bubbleColor)
|
||||
|
||||
this.CharacterSortedMsg:Get(line.Origin).Fifo:PushBack(line)
|
||||
this:CreateChatLineRender(origin, line, false, this.CharacterSortedMsg:Get(line.Origin).Fifo)
|
||||
end
|
||||
|
||||
function this:BubbleChatEnabled()
|
||||
return PlayersService.BubbleChat
|
||||
end
|
||||
|
||||
function this:CameraChanged(prop)
|
||||
if prop == "CoordinateFrame" then
|
||||
this:CameraCFrameChanged()
|
||||
end
|
||||
end
|
||||
|
||||
-- setup to datamodel connections
|
||||
PlayersService.PlayerChatted:connect(function(chatType, player, message, targetPlayer) this:OnPlayerChatMessage(chatType, player, message, targetPlayer) end)
|
||||
ChatService.Chatted:connect(function(origin, message, color) this:OnGameChatMessage(origin, message, color) end)
|
||||
|
||||
local cameraChangedCon = nil
|
||||
if game.Workspace.CurrentCamera then
|
||||
cameraChangedCon = game.Workspace.CurrentCamera.Changed:connect(function(prop) this:CameraChanged(prop) end)
|
||||
end
|
||||
game.Workspace.Changed:connect(function(prop)
|
||||
if prop == "CurrentCamera" then
|
||||
if cameraChangedCon then cameraChangedCon:disconnect() end
|
||||
if game.Workspace.CurrentCamera then
|
||||
cameraChangedCon = game.Workspace.CurrentCamera.Changed:connect(function(prop) this:CameraChanged(prop) end)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local isClient = false
|
||||
local success = pcall(function() isClient = game:GetService("RunService"):IsClient()end)
|
||||
|
||||
-- init only if we have a simulation going
|
||||
if isClient or not success then
|
||||
createChatOutput()
|
||||
end
|
||||
1936
client/common/content/scripts/CoreScripts/2015/ChatScript.lua
Normal file
1936
client/common/content/scripts/CoreScripts/2015/ChatScript.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,263 @@
|
||||
-- ContextActionTouch.lua
|
||||
-- this script controls ui and firing of lua functions that are bound in ContextActionService for touch inputs
|
||||
-- Essentially a user can bind a lua function to a key code, input type (mousebutton1 etc.) and this
|
||||
|
||||
-- Variables
|
||||
local contextActionService = Game:GetService("ContextActionService")
|
||||
local isTouchDevice = Game:GetService("UserInputService").TouchEnabled
|
||||
local functionTable = {}
|
||||
local buttonVector = {}
|
||||
local buttonScreenGui = nil
|
||||
local buttonFrame = nil
|
||||
|
||||
local ContextDownImage = "ayaasset://textures/2015/ContextActionTouch/ContextDownImage.png"
|
||||
local ContextUpImage = "ayaasset://textures/2015/ContextActionTouch/ContextUpImage.png"
|
||||
|
||||
local oldTouches = {}
|
||||
|
||||
local buttonPositionTable = {
|
||||
[1] = UDim2.new(0,123,0,70),
|
||||
[2] = UDim2.new(0,30,0,60),
|
||||
[3] = UDim2.new(0,180,0,160),
|
||||
[4] = UDim2.new(0,85,0,-25),
|
||||
[5] = UDim2.new(0,185,0,-25),
|
||||
[6] = UDim2.new(0,185,0,260),
|
||||
[7] = UDim2.new(0,216,0,65)
|
||||
}
|
||||
local maxButtons = #buttonPositionTable
|
||||
|
||||
-- Preload images
|
||||
Game:GetService("ContentProvider"):Preload(ContextDownImage)
|
||||
Game:GetService("ContentProvider"):Preload(ContextUpImage)
|
||||
|
||||
while not Game:GetService("Players") do
|
||||
wait()
|
||||
end
|
||||
|
||||
while not Game:GetService("Players").LocalPlayer do
|
||||
wait()
|
||||
end
|
||||
|
||||
function createContextActionGui()
|
||||
if not buttonScreenGui and isTouchDevice then
|
||||
buttonScreenGui = Instance.new("ScreenGui")
|
||||
buttonScreenGui.Name = "ContextActionGui"
|
||||
|
||||
buttonFrame = Instance.new("Frame")
|
||||
buttonFrame.BackgroundTransparency = 1
|
||||
buttonFrame.Size = UDim2.new(0.3,0,0.5,0)
|
||||
buttonFrame.Position = UDim2.new(0.7,0,0.5,0)
|
||||
buttonFrame.Name = "ContextButtonFrame"
|
||||
buttonFrame.Parent = buttonScreenGui
|
||||
end
|
||||
end
|
||||
|
||||
-- functions
|
||||
function setButtonSizeAndPosition(object)
|
||||
local buttonSize = 55
|
||||
local xOffset = 10
|
||||
local yOffset = 95
|
||||
|
||||
-- todo: better way to determine mobile sized screens
|
||||
local onSmallScreen = (game:GetService("CoreGui").RobloxGui.AbsoluteSize.X < 600)
|
||||
if not onSmallScreen then
|
||||
buttonSize = 85
|
||||
xOffset = 40
|
||||
end
|
||||
|
||||
object.Size = UDim2.new(0,buttonSize,0,buttonSize)
|
||||
end
|
||||
|
||||
function contextButtonDown(button, inputObject, actionName)
|
||||
if inputObject.UserInputType == Enum.UserInputType.Touch then
|
||||
button.Image = ContextDownImage
|
||||
contextActionService:CallFunction(actionName, Enum.UserInputState.Begin, inputObject)
|
||||
end
|
||||
end
|
||||
|
||||
function contextButtonMoved(button, inputObject, actionName)
|
||||
if inputObject.UserInputType == Enum.UserInputType.Touch then
|
||||
button.Image = ContextDownImage
|
||||
contextActionService:CallFunction(actionName, Enum.UserInputState.Change, inputObject)
|
||||
end
|
||||
end
|
||||
|
||||
function contextButtonUp(button, inputObject, actionName)
|
||||
button.Image = ContextUpImage
|
||||
if inputObject.UserInputType == Enum.UserInputType.Touch and inputObject.UserInputState == Enum.UserInputState.End then
|
||||
contextActionService:CallFunction(actionName, Enum.UserInputState.End, inputObject)
|
||||
end
|
||||
end
|
||||
|
||||
function isSmallScreenDevice()
|
||||
return Game:GetService("GuiService"):GetScreenResolution().y <= 320
|
||||
end
|
||||
|
||||
|
||||
function createNewButton(actionName, functionInfoTable)
|
||||
local contextButton = Instance.new("ImageButton")
|
||||
contextButton.Name = "ContextActionButton"
|
||||
contextButton.BackgroundTransparency = 1
|
||||
contextButton.Size = UDim2.new(0,90,0,90)
|
||||
contextButton.Active = true
|
||||
if isSmallScreenDevice() then
|
||||
contextButton.Size = UDim2.new(0,70,0,70)
|
||||
end
|
||||
contextButton.Image = ContextUpImage
|
||||
contextButton.Parent = buttonFrame
|
||||
|
||||
local currentButtonTouch = nil
|
||||
|
||||
Game:GetService("UserInputService").InputEnded:connect(function ( inputObject )
|
||||
oldTouches[inputObject] = nil
|
||||
end)
|
||||
contextButton.InputBegan:connect(function(inputObject)
|
||||
if oldTouches[inputObject] then return end
|
||||
|
||||
if inputObject.UserInputState == Enum.UserInputState.Begin and currentButtonTouch == nil then
|
||||
currentButtonTouch = inputObject
|
||||
contextButtonDown(contextButton, inputObject, actionName)
|
||||
end
|
||||
end)
|
||||
contextButton.InputChanged:connect(function(inputObject)
|
||||
if oldTouches[inputObject] then return end
|
||||
if currentButtonTouch ~= inputObject then return end
|
||||
|
||||
contextButtonMoved(contextButton, inputObject, actionName)
|
||||
end)
|
||||
contextButton.InputEnded:connect(function(inputObject)
|
||||
if oldTouches[inputObject] then return end
|
||||
if currentButtonTouch ~= inputObject then return end
|
||||
|
||||
currentButtonTouch = nil
|
||||
oldTouches[inputObject] = true
|
||||
contextButtonUp(contextButton, inputObject, actionName)
|
||||
end)
|
||||
|
||||
local actionIcon = Instance.new("ImageLabel")
|
||||
actionIcon.Name = "ActionIcon"
|
||||
actionIcon.Position = UDim2.new(0.175, 0, 0.175, 0)
|
||||
actionIcon.Size = UDim2.new(0.65, 0, 0.65, 0)
|
||||
actionIcon.BackgroundTransparency = 1
|
||||
if functionInfoTable["image"] and type(functionInfoTable["image"]) == "string" then
|
||||
actionIcon.Image = functionInfoTable["image"]
|
||||
end
|
||||
actionIcon.Parent = contextButton
|
||||
|
||||
local actionTitle = Instance.new("TextLabel")
|
||||
actionTitle.Name = "ActionTitle"
|
||||
actionTitle.Size = UDim2.new(1,0,1,0)
|
||||
actionTitle.BackgroundTransparency = 1
|
||||
actionTitle.Font = Enum.Font.SourceSansBold
|
||||
actionTitle.TextColor3 = Color3.new(1,1,1)
|
||||
actionTitle.TextStrokeTransparency = 0
|
||||
actionTitle.FontSize = Enum.FontSize.Size18
|
||||
actionTitle.TextWrapped = true
|
||||
actionTitle.Text = ""
|
||||
if functionInfoTable["title"] and type(functionInfoTable["title"]) == "string" then
|
||||
actionTitle.Text = functionInfoTable["title"]
|
||||
end
|
||||
actionTitle.Parent = contextButton
|
||||
|
||||
return contextButton
|
||||
end
|
||||
|
||||
function createButton( actionName, functionInfoTable )
|
||||
local button = createNewButton(actionName, functionInfoTable)
|
||||
|
||||
local position = nil
|
||||
for i = 1,#buttonVector do
|
||||
if buttonVector[i] == "empty" then
|
||||
position = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not position then
|
||||
position = #buttonVector + 1
|
||||
end
|
||||
|
||||
if position > maxButtons then
|
||||
return -- todo: let user know we have too many buttons already?
|
||||
end
|
||||
|
||||
buttonVector[position] = button
|
||||
functionTable[actionName]["button"] = button
|
||||
|
||||
button.Position = buttonPositionTable[position]
|
||||
button.Parent = buttonFrame
|
||||
|
||||
if buttonScreenGui and buttonScreenGui.Parent == nil then
|
||||
buttonScreenGui.Parent = Game:GetService("Players").LocalPlayer.PlayerGui
|
||||
end
|
||||
end
|
||||
|
||||
function removeAction(actionName)
|
||||
if not functionTable[actionName] then return end
|
||||
|
||||
local actionButton = functionTable[actionName]["button"]
|
||||
|
||||
if actionButton then
|
||||
actionButton.Parent = nil
|
||||
|
||||
for i = 1,#buttonVector do
|
||||
if buttonVector[i] == actionButton then
|
||||
buttonVector[i] = "empty"
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
actionButton:Destroy()
|
||||
end
|
||||
|
||||
functionTable[actionName] = nil
|
||||
end
|
||||
|
||||
function addAction(actionName,createTouchButton,functionInfoTable)
|
||||
if functionTable[actionName] then
|
||||
removeAction(actionName)
|
||||
end
|
||||
functionTable[actionName] = {functionInfoTable}
|
||||
if createTouchButton and isTouchDevice then
|
||||
createContextActionGui()
|
||||
createButton(actionName, functionInfoTable)
|
||||
end
|
||||
end
|
||||
|
||||
-- Connections
|
||||
contextActionService.BoundActionChanged:connect( function(actionName, changeName, changeTable)
|
||||
if functionTable[actionName] and changeTable then
|
||||
local button = functionTable[actionName]["button"]
|
||||
if button then
|
||||
if changeName == "image" then
|
||||
button.ActionIcon.Image = changeTable[changeName]
|
||||
elseif changeName == "title" then
|
||||
button.ActionTitle.Text = changeTable[changeName]
|
||||
elseif changeName == "description" then
|
||||
-- todo: add description to menu
|
||||
elseif changeName == "position" then
|
||||
button.Position = changeTable[changeName]
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
contextActionService.BoundActionAdded:connect( function(actionName, createTouchButton, functionInfoTable)
|
||||
addAction(actionName, createTouchButton, functionInfoTable)
|
||||
end)
|
||||
|
||||
contextActionService.BoundActionRemoved:connect( function(actionName, functionInfoTable)
|
||||
removeAction(actionName)
|
||||
end)
|
||||
|
||||
contextActionService.GetActionButtonEvent:connect( function(actionName)
|
||||
if functionTable[actionName] then
|
||||
contextActionService:FireActionButtonFoundSignal(actionName, functionTable[actionName]["button"])
|
||||
end
|
||||
end)
|
||||
|
||||
-- make sure any bound data before we setup connections is handled
|
||||
local boundActions = contextActionService:GetAllBoundActionInfo()
|
||||
for actionName, actionData in pairs(boundActions) do
|
||||
addAction(actionName,actionData["createTouchButton"],actionData)
|
||||
end
|
||||
315
client/common/content/scripts/CoreScripts/2015/HealthScript.lua
Normal file
315
client/common/content/scripts/CoreScripts/2015/HealthScript.lua
Normal file
@@ -0,0 +1,315 @@
|
||||
--[[
|
||||
This script controls the gui the player sees in regards to his or her health.
|
||||
Can be turned with Game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health,false)
|
||||
--]]
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Initialize/Variables
|
||||
while not Game do
|
||||
wait(1/60)
|
||||
end
|
||||
while not Game:GetService("Players") do
|
||||
wait(1/60)
|
||||
end
|
||||
|
||||
local useCoreHealthBar = false
|
||||
local success = pcall(function() useCoreHealthBar = Game:GetService("Players"):GetUseCoreScriptHealthBar() end)
|
||||
if not success or not useCoreHealthBar then
|
||||
return
|
||||
end
|
||||
|
||||
local currentHumanoid = nil
|
||||
|
||||
local HealthGui = nil
|
||||
local lastHealth = 100
|
||||
local HealthPercentageForOverlay = 5
|
||||
local maxBarTweenTime = 0.3
|
||||
local greenColor = Color3.new(0.2, 1, 0.2)
|
||||
local redColor = Color3.new(1, 0.2, 0.2)
|
||||
local yellowColor = Color3.new(1, 1, 0.2)
|
||||
|
||||
local guiEnabled = false
|
||||
local healthChangedConnection = nil
|
||||
local humanoidDiedConnection = nil
|
||||
local characterAddedConnection = nil
|
||||
|
||||
local greenBarImage = "ayaasset://textures/ui/Health-BKG-Center.png"
|
||||
local greenBarImageLeft = "ayaasset://textures/ui/Health-BKG-Left-Cap.png"
|
||||
local greenBarImageRight = "ayaasset://textures/ui/Health-BKG-Right-Cap.png"
|
||||
local hurtOverlayImage = "ayaasset://textures/2015/HealthScript/hurtOverlayImage.png"
|
||||
|
||||
Game:GetService("ContentProvider"):Preload(greenBarImage)
|
||||
Game:GetService("ContentProvider"):Preload(hurtOverlayImage)
|
||||
|
||||
while not Game:GetService("Players").LocalPlayer do
|
||||
wait(1/60)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Functions
|
||||
|
||||
local capHeight = 15
|
||||
local capWidth = 7
|
||||
|
||||
function CreateGui()
|
||||
if HealthGui and #HealthGui:GetChildren() > 0 then
|
||||
HealthGui.Parent = Game:GetService("CoreGui").RobloxGui
|
||||
return
|
||||
end
|
||||
|
||||
local hurtOverlay = Instance.new("ImageLabel")
|
||||
hurtOverlay.Name = "HurtOverlay"
|
||||
hurtOverlay.BackgroundTransparency = 1
|
||||
hurtOverlay.Image = hurtOverlayImage
|
||||
hurtOverlay.Position = UDim2.new(-10,0,-10,0)
|
||||
hurtOverlay.Size = UDim2.new(20,0,20,0)
|
||||
hurtOverlay.Visible = false
|
||||
hurtOverlay.Parent = HealthGui
|
||||
|
||||
local healthFrame = Instance.new("Frame")
|
||||
healthFrame.Name = "HealthFrame"
|
||||
healthFrame.BackgroundTransparency = 1
|
||||
healthFrame.BackgroundColor3 = Color3.new(1,1,1)
|
||||
healthFrame.BorderColor3 = Color3.new(0,0,0)
|
||||
healthFrame.BorderSizePixel = 0
|
||||
healthFrame.Position = UDim2.new(0.5,-85,1,-20)
|
||||
healthFrame.Size = UDim2.new(0,170,0,capHeight)
|
||||
healthFrame.Parent = HealthGui
|
||||
|
||||
|
||||
local healthBarBackCenter = Instance.new("ImageLabel")
|
||||
healthBarBackCenter.Name = "healthBarBackCenter"
|
||||
healthBarBackCenter.BackgroundTransparency = 1
|
||||
healthBarBackCenter.Image = greenBarImage
|
||||
healthBarBackCenter.Size = UDim2.new(1,-capWidth*2,1,0)
|
||||
healthBarBackCenter.Position = UDim2.new(0,capWidth,0,0)
|
||||
healthBarBackCenter.Parent = healthFrame
|
||||
healthBarBackCenter.ImageColor3 = Color3.new(1,1,1)
|
||||
|
||||
local healthBarBackLeft = Instance.new("ImageLabel")
|
||||
healthBarBackLeft.Name = "healthBarBackLeft"
|
||||
healthBarBackLeft.BackgroundTransparency = 1
|
||||
healthBarBackLeft.Image = greenBarImageLeft
|
||||
healthBarBackLeft.Size = UDim2.new(0,capWidth,1,0)
|
||||
healthBarBackLeft.Position = UDim2.new(0,0,0,0)
|
||||
healthBarBackLeft.Parent = healthFrame
|
||||
healthBarBackLeft.ImageColor3 = Color3.new(1,1,1)
|
||||
|
||||
local healthBarBackRight = Instance.new("ImageLabel")
|
||||
healthBarBackRight.Name = "healthBarBackRight"
|
||||
healthBarBackRight.BackgroundTransparency = 1
|
||||
healthBarBackRight.Image = greenBarImageRight
|
||||
healthBarBackRight.Size = UDim2.new(0,capWidth,1,0)
|
||||
healthBarBackRight.Position = UDim2.new(1,-capWidth,0,0)
|
||||
healthBarBackRight.Parent = healthFrame
|
||||
healthBarBackRight.ImageColor3 = Color3.new(1,1,1)
|
||||
|
||||
|
||||
local healthBar = Instance.new("Frame")
|
||||
healthBar.Name = "HealthBar"
|
||||
healthBar.BackgroundTransparency = 1
|
||||
healthBar.BackgroundColor3 = Color3.new(1,1,1)
|
||||
healthBar.BorderColor3 = Color3.new(0,0,0)
|
||||
healthBar.BorderSizePixel = 0
|
||||
healthBar.ClipsDescendants = true
|
||||
healthBar.Position = UDim2.new(0, 0, 0, 0)
|
||||
healthBar.Size = UDim2.new(1,0,1,0)
|
||||
healthBar.Parent = healthFrame
|
||||
|
||||
|
||||
local healthBarCenter = Instance.new("ImageLabel")
|
||||
healthBarCenter.Name = "healthBarCenter"
|
||||
healthBarCenter.BackgroundTransparency = 1
|
||||
healthBarCenter.Image = greenBarImage
|
||||
healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
|
||||
healthBarCenter.Position = UDim2.new(0,capWidth,0,0)
|
||||
healthBarCenter.Parent = healthBar
|
||||
healthBarCenter.ImageColor3 = greenColor
|
||||
|
||||
local healthBarLeft = Instance.new("ImageLabel")
|
||||
healthBarLeft.Name = "healthBarLeft"
|
||||
healthBarLeft.BackgroundTransparency = 1
|
||||
healthBarLeft.Image = greenBarImageLeft
|
||||
healthBarLeft.Size = UDim2.new(0,capWidth,1,0)
|
||||
healthBarLeft.Position = UDim2.new(0,0,0,0)
|
||||
healthBarLeft.Parent = healthBar
|
||||
healthBarLeft.ImageColor3 = greenColor
|
||||
|
||||
local healthBarRight = Instance.new("ImageLabel")
|
||||
healthBarRight.Name = "healthBarRight"
|
||||
healthBarRight.BackgroundTransparency = 1
|
||||
healthBarRight.Image = greenBarImageRight
|
||||
healthBarRight.Size = UDim2.new(0,capWidth,1,0)
|
||||
healthBarRight.Position = UDim2.new(1,-capWidth,0,0)
|
||||
healthBarRight.Parent = healthBar
|
||||
healthBarRight.ImageColor3 = greenColor
|
||||
|
||||
HealthGui.Parent = Game:GetService("CoreGui").RobloxGui
|
||||
end
|
||||
|
||||
function UpdateGui(health)
|
||||
if not HealthGui then return end
|
||||
|
||||
local healthFrame = HealthGui:FindFirstChild("HealthFrame")
|
||||
if not healthFrame then return end
|
||||
|
||||
local healthBar = healthFrame:FindFirstChild("HealthBar")
|
||||
if not healthBar then return end
|
||||
|
||||
-- If more than 1/4 health, bar = green. Else, bar = red.
|
||||
local percentHealth = (health/currentHumanoid.MaxHealth)
|
||||
if percentHealth ~= percentHealth then
|
||||
percentHealth = 1
|
||||
healthBar.healthBarCenter.ImageColor3 = yellowColor
|
||||
healthBar.healthBarRight.ImageColor3 = yellowColor
|
||||
healthBar.healthBarLeft.ImageColor3 = yellowColor
|
||||
elseif percentHealth > 0.25 then
|
||||
healthBar.healthBarCenter.ImageColor3 = greenColor
|
||||
healthBar.healthBarRight.ImageColor3 = greenColor
|
||||
healthBar.healthBarLeft.ImageColor3 = greenColor
|
||||
else
|
||||
healthBar.healthBarCenter.ImageColor3 = redColor
|
||||
healthBar.healthBarRight.ImageColor3 = redColor
|
||||
healthBar.healthBarLeft.ImageColor3 = redColor
|
||||
end
|
||||
|
||||
local width = (health / currentHumanoid.MaxHealth)
|
||||
width = math.max(math.min(width,1),0) -- make sure width is between 0 and 1
|
||||
if width ~= width then width = 1 end
|
||||
|
||||
local healthDelta = lastHealth - health
|
||||
lastHealth = health
|
||||
|
||||
local percentOfTotalHealth = math.abs(healthDelta/currentHumanoid.MaxHealth)
|
||||
percentOfTotalHealth = math.max(math.min(percentOfTotalHealth,1),0) -- make sure percentOfTotalHealth is between 0 and 1
|
||||
if percentOfTotalHealth ~= percentOfTotalHealth then percentOfTotalHealth = 1 end
|
||||
|
||||
local newHealthSize = UDim2.new(width,0,1,0)
|
||||
|
||||
healthBar.Size = newHealthSize
|
||||
|
||||
local sizeX = healthBar.AbsoluteSize.X
|
||||
if sizeX < capWidth then
|
||||
healthBar.healthBarCenter.Visible = false
|
||||
healthBar.healthBarRight.Visible = false
|
||||
elseif sizeX < (2*capWidth + 1) then
|
||||
healthBar.healthBarCenter.Visible = true
|
||||
healthBar.healthBarCenter.Size = UDim2.new(0,sizeX - capWidth,1,0)
|
||||
healthBar.healthBarRight.Visible = false
|
||||
else
|
||||
healthBar.healthBarCenter.Visible = true
|
||||
healthBar.healthBarCenter.Size = UDim2.new(1,-capWidth*2,1,0)
|
||||
healthBar.healthBarRight.Visible = true
|
||||
end
|
||||
|
||||
local thresholdForHurtOverlay = currentHumanoid.MaxHealth * (HealthPercentageForOverlay/100)
|
||||
|
||||
if healthDelta >= thresholdForHurtOverlay then
|
||||
AnimateHurtOverlay()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function AnimateHurtOverlay()
|
||||
if not HealthGui then return end
|
||||
|
||||
local overlay = HealthGui:FindFirstChild("HurtOverlay")
|
||||
if not overlay then return end
|
||||
|
||||
local newSize = UDim2.new(20, 0, 20, 0)
|
||||
local newPos = UDim2.new(-10, 0, -10, 0)
|
||||
|
||||
if overlay:IsDescendantOf(Game) then
|
||||
-- stop any tweens on overlay
|
||||
overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Linear,0,true,function()
|
||||
|
||||
-- show the gui
|
||||
overlay.Size = UDim2.new(1,0,1,0)
|
||||
overlay.Position = UDim2.new(0,0,0,0)
|
||||
overlay.Visible = true
|
||||
|
||||
-- now tween the hide
|
||||
if overlay:IsDescendantOf(Game) then
|
||||
overlay:TweenSizeAndPosition(newSize,newPos,Enum.EasingDirection.Out,Enum.EasingStyle.Quad,10,false,function()
|
||||
overlay.Visible = false
|
||||
end)
|
||||
else
|
||||
overlay.Size = newSize
|
||||
overlay.Position = newPos
|
||||
end
|
||||
end)
|
||||
else
|
||||
overlay.Size = newSize
|
||||
overlay.Position = newPos
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function humanoidDied()
|
||||
UpdateGui(0)
|
||||
end
|
||||
|
||||
function disconnectPlayerConnections()
|
||||
if characterAddedConnection then characterAddedConnection:disconnect() end
|
||||
if humanoidDiedConnection then humanoidDiedConnection:disconnect() end
|
||||
if healthChangedConnection then healthChangedConnection:disconnect() end
|
||||
end
|
||||
|
||||
function newPlayerCharacter()
|
||||
disconnectPlayerConnections()
|
||||
startGui()
|
||||
end
|
||||
|
||||
function startGui()
|
||||
characterAddedConnection = Game:GetService("Players").LocalPlayer.CharacterAdded:connect(newPlayerCharacter)
|
||||
|
||||
local character = Game:GetService("Players").LocalPlayer.Character
|
||||
if not character then
|
||||
return
|
||||
end
|
||||
|
||||
currentHumanoid = character:WaitForChild("Humanoid")
|
||||
if not currentHumanoid then
|
||||
return
|
||||
end
|
||||
|
||||
if not Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
|
||||
return
|
||||
end
|
||||
|
||||
healthChangedConnection = currentHumanoid.HealthChanged:connect(UpdateGui)
|
||||
humanoidDiedConnection = currentHumanoid.Died:connect(humanoidDied)
|
||||
UpdateGui(currentHumanoid.Health)
|
||||
|
||||
CreateGui()
|
||||
end
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Start Script
|
||||
|
||||
HealthGui = Instance.new("Frame")
|
||||
HealthGui.Name = "HealthGui"
|
||||
HealthGui.BackgroundTransparency = 1
|
||||
HealthGui.Size = UDim2.new(1,0,1,0)
|
||||
|
||||
Game:GetService("StarterGui").CoreGuiChangedSignal:connect(function(coreGuiType,enabled)
|
||||
if coreGuiType == Enum.CoreGuiType.Health or coreGuiType == Enum.CoreGuiType.All then
|
||||
if guiEnabled and not enabled then
|
||||
if HealthGui then
|
||||
HealthGui.Parent = nil
|
||||
end
|
||||
disconnectPlayerConnections()
|
||||
elseif not guiEnabled and enabled then
|
||||
startGui()
|
||||
end
|
||||
|
||||
guiEnabled = enabled
|
||||
end
|
||||
end)
|
||||
|
||||
if Game:GetService("StarterGui"):GetCoreGuiEnabled(Enum.CoreGuiType.Health) then
|
||||
guiEnabled = true
|
||||
startGui()
|
||||
end
|
||||
@@ -0,0 +1,565 @@
|
||||
function waitForProperty(instance, name)
|
||||
while not instance[name] do
|
||||
instance.Changed:wait()
|
||||
end
|
||||
end
|
||||
|
||||
function waitForChild(instance, name)
|
||||
while not instance:FindFirstChild(name) do
|
||||
instance.ChildAdded:wait()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local mainFrame
|
||||
local choices = {}
|
||||
local lastChoice
|
||||
local choiceMap = {}
|
||||
local currentConversationDialog
|
||||
local currentConversationPartner
|
||||
local currentAbortDialogScript
|
||||
|
||||
local tooFarAwayMessage = "You are too far away to chat!"
|
||||
local tooFarAwaySize = 300
|
||||
local characterWanderedOffMessage = "Chat ended because you walked away"
|
||||
local characterWanderedOffSize = 350
|
||||
local conversationTimedOut = "Chat ended because you didn't reply"
|
||||
local conversationTimedOutSize = 350
|
||||
|
||||
local player
|
||||
local screenGui
|
||||
local chatNotificationGui
|
||||
local messageDialog
|
||||
local timeoutScript
|
||||
local reenableDialogScript
|
||||
local dialogMap = {}
|
||||
local dialogConnections = {}
|
||||
|
||||
local gui = nil
|
||||
waitForChild(game,"CoreGui")
|
||||
waitForChild(game:GetService("CoreGui"),"RobloxGui")
|
||||
if game:GetService("CoreGui").RobloxGui:FindFirstChild("ControlFrame") then
|
||||
gui = game:GetService("CoreGui").RobloxGui.ControlFrame
|
||||
else
|
||||
gui = game:GetService("CoreGui").RobloxGui
|
||||
end
|
||||
local touchEnabled = game:GetService("UserInputService").TouchEnabled
|
||||
|
||||
function currentTone()
|
||||
if currentConversationDialog then
|
||||
return currentConversationDialog.Tone
|
||||
else
|
||||
return Enum.DialogTone.Neutral
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function createChatNotificationGui()
|
||||
chatNotificationGui = Instance.new("BillboardGui")
|
||||
chatNotificationGui.Name = "ChatNotificationGui"
|
||||
chatNotificationGui.ExtentsOffset = Vector3.new(0,1,0)
|
||||
chatNotificationGui.Size = UDim2.new(4, 0, 5.42857122, 0)
|
||||
chatNotificationGui.SizeOffset = Vector2.new(0,0)
|
||||
chatNotificationGui.StudsOffset = Vector3.new(0.4, 4.3, 0)
|
||||
chatNotificationGui.Enabled = true
|
||||
chatNotificationGui.RobloxLocked = true
|
||||
chatNotificationGui.Active = true
|
||||
|
||||
local image = Instance.new("ImageLabel")
|
||||
image.Name = "Image"
|
||||
image.Active = false
|
||||
image.BackgroundTransparency = 1
|
||||
image.Position = UDim2.new(0,0,0,0)
|
||||
image.Size = UDim2.new(1.0,0,1.0,0)
|
||||
image.Image = ""
|
||||
image.RobloxLocked = true
|
||||
image.Parent = chatNotificationGui
|
||||
|
||||
|
||||
local button = Instance.new("ImageButton")
|
||||
button.Name = "Button"
|
||||
button.AutoButtonColor = false
|
||||
button.Position = UDim2.new(0.0879999995, 0, 0.0529999994, 0)
|
||||
button.Size = UDim2.new(0.829999983, 0, 0.460000008, 0)
|
||||
button.Image = ""
|
||||
button.BackgroundTransparency = 1
|
||||
button.RobloxLocked = true
|
||||
button.Parent = image
|
||||
end
|
||||
|
||||
function getChatColor(tone)
|
||||
if tone == Enum.DialogTone.Neutral then
|
||||
return Enum.ChatColor.Blue
|
||||
elseif tone == Enum.DialogTone.Friendly then
|
||||
return Enum.ChatColor.Green
|
||||
elseif tone == Enum.DialogTone.Enemy then
|
||||
return Enum.ChatColor.Red
|
||||
end
|
||||
end
|
||||
|
||||
function styleChoices(tone)
|
||||
for i, obj in pairs(choices) do
|
||||
resetColor(obj, tone)
|
||||
end
|
||||
resetColor(lastChoice, tone)
|
||||
end
|
||||
|
||||
function styleMainFrame(tone)
|
||||
if tone == Enum.DialogTone.Neutral then
|
||||
mainFrame.Style = Enum.FrameStyle.ChatBlue
|
||||
mainFrame.Tail.Image = "ayaasset://textures/chatBubble_botBlue_tailRight.png"
|
||||
elseif tone == Enum.DialogTone.Friendly then
|
||||
mainFrame.Style = Enum.FrameStyle.ChatGreen
|
||||
mainFrame.Tail.Image = "ayaasset://textures/chatBubble_botGreen_tailRight.png"
|
||||
elseif tone == Enum.DialogTone.Enemy then
|
||||
mainFrame.Style = Enum.FrameStyle.ChatRed
|
||||
mainFrame.Tail.Image = "ayaasset://textures/chatBubble_botRed_tailRight.png"
|
||||
end
|
||||
|
||||
styleChoices(tone)
|
||||
end
|
||||
function setChatNotificationTone(gui, purpose, tone)
|
||||
if tone == Enum.DialogTone.Neutral then
|
||||
gui.Image.Image = "ayaasset://textures/chatBubble_botBlue_notify_bkg.png"
|
||||
elseif tone == Enum.DialogTone.Friendly then
|
||||
gui.Image.Image = "ayaasset://textures/chatBubble_botGreen_notify_bkg.png"
|
||||
elseif tone == Enum.DialogTone.Enemy then
|
||||
gui.Image.Image = "ayaasset://textures/chatBubble_botRed_notify_bkg.png"
|
||||
end
|
||||
if purpose == Enum.DialogPurpose.Quest then
|
||||
gui.Image.Button.Image = "ayaasset://textures/chatBubble_bot_notify_bang.png"
|
||||
elseif purpose == Enum.DialogPurpose.Help then
|
||||
gui.Image.Button.Image = "ayaasset://textures/chatBubble_bot_notify_question.png"
|
||||
elseif purpose == Enum.DialogPurpose.Shop then
|
||||
gui.Image.Button.Image = "ayaasset://textures/chatBubble_bot_notify_money.png"
|
||||
end
|
||||
end
|
||||
|
||||
function createMessageDialog()
|
||||
messageDialog = Instance.new("Frame");
|
||||
messageDialog.Name = "DialogScriptMessage"
|
||||
messageDialog.Style = Enum.FrameStyle.RobloxRound
|
||||
messageDialog.Visible = false
|
||||
|
||||
local text = Instance.new("TextLabel")
|
||||
text.Name = "Text"
|
||||
text.Position = UDim2.new(0,0,0,-1)
|
||||
text.Size = UDim2.new(1,0,1,0)
|
||||
text.FontSize = Enum.FontSize.Size14
|
||||
text.BackgroundTransparency = 1
|
||||
text.TextColor3 = Color3.new(1,1,1)
|
||||
text.RobloxLocked = true
|
||||
text.Parent = messageDialog
|
||||
end
|
||||
|
||||
function showMessage(msg, size)
|
||||
messageDialog.Text.Text = msg
|
||||
messageDialog.Size = UDim2.new(0,size,0,40)
|
||||
messageDialog.Position = UDim2.new(0.5, -size/2, 0.5, -40)
|
||||
messageDialog.Visible = true
|
||||
wait(2)
|
||||
messageDialog.Visible = false
|
||||
end
|
||||
|
||||
function variableDelay(str)
|
||||
local length = math.min(string.len(str), 100)
|
||||
wait(0.75 + ((length/75) * 1.5))
|
||||
end
|
||||
|
||||
function resetColor(frame, tone)
|
||||
if tone == Enum.DialogTone.Neutral then
|
||||
frame.BackgroundColor3 = Color3.new(0/255, 0/255, 179/255)
|
||||
frame.Number.TextColor3 = Color3.new(45/255, 142/255, 245/255)
|
||||
elseif tone == Enum.DialogTone.Friendly then
|
||||
frame.BackgroundColor3 = Color3.new(0/255, 77/255, 0/255)
|
||||
frame.Number.TextColor3 = Color3.new(0/255, 190/255, 0/255)
|
||||
elseif tone == Enum.DialogTone.Enemy then
|
||||
frame.BackgroundColor3 = Color3.new(140/255, 0/255, 0/255)
|
||||
frame.Number.TextColor3 = Color3.new(255/255,88/255, 79/255)
|
||||
end
|
||||
end
|
||||
|
||||
function highlightColor(frame, tone)
|
||||
if tone == Enum.DialogTone.Neutral then
|
||||
frame.BackgroundColor3 = Color3.new(2/255, 108/255, 255/255)
|
||||
frame.Number.TextColor3 = Color3.new(1, 1, 1)
|
||||
elseif tone == Enum.DialogTone.Friendly then
|
||||
frame.BackgroundColor3 = Color3.new(0/255, 128/255, 0/255)
|
||||
frame.Number.TextColor3 = Color3.new(1, 1, 1)
|
||||
elseif tone == Enum.DialogTone.Enemy then
|
||||
frame.BackgroundColor3 = Color3.new(204/255, 0/255, 0/255)
|
||||
frame.Number.TextColor3 = Color3.new(1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function wanderDialog()
|
||||
mainFrame.Visible = false
|
||||
endDialog()
|
||||
showMessage(characterWanderedOffMessage, characterWanderedOffSize)
|
||||
end
|
||||
|
||||
function timeoutDialog()
|
||||
mainFrame.Visible = false
|
||||
endDialog()
|
||||
showMessage(conversationTimedOut, conversationTimedOutSize)
|
||||
end
|
||||
function normalEndDialog()
|
||||
endDialog()
|
||||
end
|
||||
|
||||
function endDialog()
|
||||
if currentAbortDialogScript then
|
||||
currentAbortDialogScript:Remove()
|
||||
currentAbortDialogScript = nil
|
||||
end
|
||||
|
||||
local dialog = currentConversationDialog
|
||||
currentConversationDialog = nil
|
||||
if dialog and dialog.InUse then
|
||||
local reenableScript = reenableDialogScript:Clone()
|
||||
reenableScript.archivable = false
|
||||
reenableScript.Disabled = false
|
||||
reenableScript.Parent = dialog
|
||||
end
|
||||
|
||||
for dialog, gui in pairs(dialogMap) do
|
||||
if dialog and gui then
|
||||
gui.Enabled = not dialog.InUse
|
||||
end
|
||||
end
|
||||
|
||||
currentConversationPartner = nil
|
||||
end
|
||||
|
||||
function sanitizeMessage(msg)
|
||||
if string.len(msg) == 0 then
|
||||
return "..."
|
||||
else
|
||||
return msg
|
||||
end
|
||||
end
|
||||
|
||||
function selectChoice(choice)
|
||||
renewKillswitch(currentConversationDialog)
|
||||
|
||||
--First hide the Gui
|
||||
mainFrame.Visible = false
|
||||
if choice == lastChoice then
|
||||
game:GetService("Chat"):Chat(game:GetService("Players").LocalPlayer.Character, "Goodbye!", getChatColor(currentTone()))
|
||||
|
||||
normalEndDialog()
|
||||
else
|
||||
local dialogChoice = choiceMap[choice]
|
||||
|
||||
game:GetService("Chat"):Chat(game:GetService("Players").LocalPlayer.Character, sanitizeMessage(dialogChoice.UserDialog), getChatColor(currentTone()))
|
||||
wait(1)
|
||||
currentConversationDialog:SignalDialogChoiceSelected(player, dialogChoice)
|
||||
game:GetService("Chat"):Chat(currentConversationPartner, sanitizeMessage(dialogChoice.ResponseDialog), getChatColor(currentTone()))
|
||||
|
||||
variableDelay(dialogChoice.ResponseDialog)
|
||||
presentDialogChoices(currentConversationPartner, dialogChoice:GetChildren())
|
||||
end
|
||||
end
|
||||
|
||||
function newChoice(numberText)
|
||||
local frame = Instance.new("TextButton")
|
||||
frame.BackgroundColor3 = Color3.new(0/255, 0/255, 179/255)
|
||||
frame.AutoButtonColor = false
|
||||
frame.BorderSizePixel = 0
|
||||
frame.Text = ""
|
||||
frame.MouseEnter:connect(function() highlightColor(frame, currentTone()) end)
|
||||
frame.MouseLeave:connect(function() resetColor(frame, currentTone()) end)
|
||||
frame.MouseButton1Click:connect(function() selectChoice(frame) end)
|
||||
frame.RobloxLocked = true
|
||||
|
||||
local number = Instance.new("TextLabel")
|
||||
number.Name = "Number"
|
||||
number.TextColor3 = Color3.new(127/255, 212/255, 255/255)
|
||||
number.Text = numberText
|
||||
number.FontSize = Enum.FontSize.Size14
|
||||
number.BackgroundTransparency = 1
|
||||
number.Position = UDim2.new(0,4,0,2)
|
||||
number.Size = UDim2.new(0,20,0,24)
|
||||
number.TextXAlignment = Enum.TextXAlignment.Left
|
||||
number.TextYAlignment = Enum.TextYAlignment.Top
|
||||
number.RobloxLocked = true
|
||||
number.Parent = frame
|
||||
|
||||
local prompt = Instance.new("TextLabel")
|
||||
prompt.Name = "UserPrompt"
|
||||
prompt.BackgroundTransparency = 1
|
||||
prompt.TextColor3 = Color3.new(1,1,1)
|
||||
prompt.FontSize = Enum.FontSize.Size14
|
||||
prompt.Position = UDim2.new(0,28, 0, 2)
|
||||
prompt.Size = UDim2.new(1,-32, 1, -4)
|
||||
prompt.TextXAlignment = Enum.TextXAlignment.Left
|
||||
prompt.TextYAlignment = Enum.TextYAlignment.Top
|
||||
prompt.TextWrap = true
|
||||
prompt.RobloxLocked = true
|
||||
prompt.Parent = frame
|
||||
|
||||
return frame
|
||||
end
|
||||
function initialize(parent)
|
||||
choices[1] = newChoice("1)")
|
||||
choices[2] = newChoice("2)")
|
||||
choices[3] = newChoice("3)")
|
||||
choices[4] = newChoice("4)")
|
||||
|
||||
lastChoice = newChoice("5)")
|
||||
lastChoice.UserPrompt.Text = "Goodbye!"
|
||||
lastChoice.Size = UDim2.new(1,0,0,28)
|
||||
|
||||
mainFrame = Instance.new("Frame")
|
||||
mainFrame.Name = "UserDialogArea"
|
||||
mainFrame.Size = UDim2.new(0, 350, 0, 200)
|
||||
mainFrame.Style = Enum.FrameStyle.ChatBlue
|
||||
mainFrame.Visible = false
|
||||
|
||||
imageLabel = Instance.new("ImageLabel")
|
||||
imageLabel.Name = "Tail"
|
||||
imageLabel.Size = UDim2.new(0,62,0,53)
|
||||
imageLabel.Position = UDim2.new(1,8,0.25)
|
||||
imageLabel.Image = "ayaasset://textures/chatBubble_botBlue_tailRight.png"
|
||||
imageLabel.BackgroundTransparency = 1
|
||||
imageLabel.RobloxLocked = true
|
||||
imageLabel.Parent = mainFrame
|
||||
|
||||
for n, obj in pairs(choices) do
|
||||
obj.RobloxLocked = true
|
||||
obj.Parent = mainFrame
|
||||
end
|
||||
lastChoice.RobloxLocked = true
|
||||
lastChoice.Parent = mainFrame
|
||||
|
||||
mainFrame.RobloxLocked = true
|
||||
mainFrame.Parent = parent
|
||||
end
|
||||
|
||||
function presentDialogChoices(talkingPart, dialogChoices)
|
||||
if not currentConversationDialog then
|
||||
return
|
||||
end
|
||||
|
||||
currentConversationPartner = talkingPart
|
||||
sortedDialogChoices = {}
|
||||
for n, obj in pairs(dialogChoices) do
|
||||
if obj:IsA("DialogChoice") then
|
||||
table.insert(sortedDialogChoices, obj)
|
||||
end
|
||||
end
|
||||
table.sort(sortedDialogChoices, function(a,b) return a.Name < b.Name end)
|
||||
|
||||
if #sortedDialogChoices == 0 then
|
||||
normalEndDialog()
|
||||
return
|
||||
end
|
||||
|
||||
local pos = 1
|
||||
local yPosition = 0
|
||||
choiceMap = {}
|
||||
for n, obj in pairs(choices) do
|
||||
obj.Visible = false
|
||||
end
|
||||
|
||||
for n, obj in pairs(sortedDialogChoices) do
|
||||
if pos <= #choices then
|
||||
--3 lines is the maximum, set it to that temporarily
|
||||
choices[pos].Size = UDim2.new(1, 0, 0, 24*3)
|
||||
choices[pos].UserPrompt.Text = obj.UserDialog
|
||||
local height = math.ceil(choices[pos].UserPrompt.TextBounds.Y/24)*24
|
||||
|
||||
choices[pos].Position = UDim2.new(0, 0, 0, yPosition)
|
||||
choices[pos].Size = UDim2.new(1, 0, 0, height)
|
||||
choices[pos].Visible = true
|
||||
|
||||
choiceMap[choices[pos]] = obj
|
||||
|
||||
yPosition = yPosition + height
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
|
||||
lastChoice.Position = UDim2.new(0,0,0,yPosition)
|
||||
lastChoice.Number.Text = pos .. ")"
|
||||
|
||||
mainFrame.Size = UDim2.new(0, 350, 0, yPosition+24+32)
|
||||
mainFrame.Position = UDim2.new(0,20,1.0, -mainFrame.Size.Y.Offset-20)
|
||||
styleMainFrame(currentTone())
|
||||
mainFrame.Visible = true
|
||||
end
|
||||
|
||||
function doDialog(dialog)
|
||||
while not Instance.Lock(dialog, player) do
|
||||
wait()
|
||||
end
|
||||
|
||||
if dialog.InUse then
|
||||
Instance.Unlock(dialog)
|
||||
return
|
||||
else
|
||||
dialog.InUse = true
|
||||
Instance.Unlock(dialog)
|
||||
end
|
||||
|
||||
currentConversationDialog = dialog
|
||||
game:GetService("Chat"):Chat(dialog.Parent, dialog.InitialPrompt, getChatColor(dialog.Tone))
|
||||
variableDelay(dialog.InitialPrompt)
|
||||
|
||||
presentDialogChoices(dialog.Parent, dialog:GetChildren())
|
||||
end
|
||||
|
||||
function renewKillswitch(dialog)
|
||||
if currentAbortDialogScript then
|
||||
currentAbortDialogScript:Remove()
|
||||
currentAbortDialogScript = nil
|
||||
end
|
||||
|
||||
currentAbortDialogScript = timeoutScript:Clone()
|
||||
currentAbortDialogScript.archivable = false
|
||||
currentAbortDialogScript.Disabled = false
|
||||
currentAbortDialogScript.Parent = dialog
|
||||
end
|
||||
|
||||
function checkForLeaveArea()
|
||||
while currentConversationDialog do
|
||||
if currentConversationDialog.Parent and (player:DistanceFromCharacter(currentConversationDialog.Parent.Position) >= currentConversationDialog.ConversationDistance) then
|
||||
wanderDialog()
|
||||
end
|
||||
wait(1)
|
||||
end
|
||||
end
|
||||
|
||||
function startDialog(dialog)
|
||||
if dialog.Parent and dialog.Parent:IsA("BasePart") then
|
||||
if player:DistanceFromCharacter(dialog.Parent.Position) >= dialog.ConversationDistance then
|
||||
showMessage(tooFarAwayMessage, tooFarAwaySize)
|
||||
return
|
||||
end
|
||||
|
||||
for dialog, gui in pairs(dialogMap) do
|
||||
if dialog and gui then
|
||||
gui.Enabled = false
|
||||
end
|
||||
end
|
||||
|
||||
renewKillswitch(dialog)
|
||||
|
||||
delay(1, checkForLeaveArea)
|
||||
doDialog(dialog)
|
||||
end
|
||||
end
|
||||
|
||||
function removeDialog(dialog)
|
||||
if dialogMap[dialog] then
|
||||
dialogMap[dialog]:Remove()
|
||||
dialogMap[dialog] = nil
|
||||
end
|
||||
if dialogConnections[dialog] then
|
||||
dialogConnections[dialog]:disconnect()
|
||||
dialogConnections[dialog] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function addDialog(dialog)
|
||||
if dialog.Parent then
|
||||
if dialog.Parent:IsA("BasePart") then
|
||||
local chatGui = chatNotificationGui:clone()
|
||||
chatGui.Enabled = not dialog.InUse
|
||||
chatGui.Adornee = dialog.Parent
|
||||
chatGui.RobloxLocked = true
|
||||
chatGui.Parent = game:GetService("CoreGui")
|
||||
chatGui.Image.Button.MouseButton1Click:connect(function() startDialog(dialog) end)
|
||||
setChatNotificationTone(chatGui, dialog.Purpose, dialog.Tone)
|
||||
|
||||
dialogMap[dialog] = chatGui
|
||||
|
||||
dialogConnections[dialog] = dialog.Changed:connect(function(prop)
|
||||
if prop == "Parent" and dialog.Parent then
|
||||
--This handles the reparenting case, seperate from removal case
|
||||
removeDialog(dialog)
|
||||
addDialog(dialog)
|
||||
elseif prop == "InUse" then
|
||||
chatGui.Enabled = not currentConversationDialog and not dialog.InUse
|
||||
if dialog == currentConversationDialog then
|
||||
timeoutDialog()
|
||||
end
|
||||
elseif prop == "Tone" or prop == "Purpose" then
|
||||
setChatNotificationTone(chatGui, dialog.Purpose, dialog.Tone)
|
||||
end
|
||||
end)
|
||||
else -- still need to listen to parent changes even if current parent is not a BasePart
|
||||
dialogConnections[dialog] = dialog.Changed:connect(function(prop)
|
||||
if prop == "Parent" and dialog.Parent then
|
||||
--This handles the reparenting case, seperate from removal case
|
||||
removeDialog(dialog)
|
||||
addDialog(dialog)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function fetchScripts()
|
||||
local model = game:GetService("InsertService"):LoadPrivateAsset("ayaasset://avatar/scripts/dialogTimeout.rbxmx")
|
||||
if type(model) == "string" then -- load failed, lets try again
|
||||
wait(0.1)
|
||||
model = game:GetService("InsertService"):LoadPrivateAsset("ayaasset://avatar/scripts/dialogTimeout.rbxmx")
|
||||
end
|
||||
if type(model) == "string" then -- not going to work, lets bail
|
||||
return
|
||||
end
|
||||
|
||||
waitForChild(model,"TimeoutScript")
|
||||
timeoutScript = model.TimeoutScript
|
||||
waitForChild(model,"ReenableDialogScript")
|
||||
reenableDialogScript = model.ReenableDialogScript
|
||||
end
|
||||
|
||||
function onLoad()
|
||||
waitForProperty(game:GetService("Players"), "LocalPlayer")
|
||||
player = game:GetService("Players").LocalPlayer
|
||||
waitForProperty(player, "Character")
|
||||
|
||||
--print("Fetching Scripts")
|
||||
fetchScripts()
|
||||
|
||||
--print("Creating Guis")
|
||||
createChatNotificationGui()
|
||||
|
||||
--print("Creating MessageDialog")
|
||||
createMessageDialog()
|
||||
messageDialog.RobloxLocked = true
|
||||
messageDialog.Parent = gui
|
||||
|
||||
--print("Waiting for BottomLeftControl")
|
||||
waitForChild(gui, "BottomLeftControl")
|
||||
|
||||
--print("Initializing Frame")
|
||||
local frame = Instance.new("Frame")
|
||||
frame.Name = "DialogFrame"
|
||||
frame.Position = UDim2.new(0,0,0,0)
|
||||
frame.Size = UDim2.new(0,0,0,0)
|
||||
frame.BackgroundTransparency = 1
|
||||
frame.RobloxLocked = true
|
||||
|
||||
if (touchEnabled) then
|
||||
frame.Position = UDim2.new(0,20,0.5,0)
|
||||
frame.Size = UDim2.new(0.25,0,0.1,0)
|
||||
frame.Parent = gui
|
||||
else
|
||||
frame.Parent = gui.BottomLeftControl
|
||||
end
|
||||
initialize(frame)
|
||||
|
||||
--print("Adding Dialogs")
|
||||
game:GetService("CollectionService").ItemAdded:connect(function(obj) if obj:IsA("Dialog") then addDialog(obj) end end)
|
||||
game:GetService("CollectionService").ItemRemoved:connect(function(obj) if obj:IsA("Dialog") then removeDialog(obj) end end)
|
||||
for i, obj in pairs(game:GetService("CollectionService"):GetCollection("Dialog")) do
|
||||
if obj:IsA("Dialog") then
|
||||
addDialog(obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
onLoad()
|
||||
@@ -0,0 +1,464 @@
|
||||
--[[
|
||||
Filename: NotificationScript2.lua
|
||||
Description: Handles notification gui for the following in game events
|
||||
Badge Awarded
|
||||
Player Points Awarded
|
||||
Friend Request Recieved/New Friend
|
||||
Graphics Quality Changed
|
||||
Teleport Failed (studio only)
|
||||
CreatePlaceInPlayerInventoryAsync
|
||||
--]]
|
||||
|
||||
--[[ Services ]]--
|
||||
local BadgeService = game:GetService('BadgeService')
|
||||
local GuiService = game:GetService('GuiService')
|
||||
local Players = game:GetService('Players')
|
||||
local PointsService = game:GetService('PointsService')
|
||||
local MarketplaceService = game:GetService('MarketplaceService')
|
||||
local TeleportService = game:GetService('TeleportService')
|
||||
local Settings = UserSettings()
|
||||
local GameSettings = Settings.GameSettings
|
||||
local UsingInstance = game:GetService("AyaService"):IsUsingInstance()
|
||||
|
||||
--[[ Script Variables ]]--
|
||||
local LocalPlayer = nil
|
||||
while not Players.LocalPlayer do
|
||||
wait()
|
||||
end
|
||||
LocalPlayer = Players.LocalPlayer
|
||||
local RbxGui = script.Parent
|
||||
local NotificationQueue = {}
|
||||
local OverflowQueue = {}
|
||||
local FriendRequestBlacklist = {}
|
||||
local CurrentGraphicsQualityLevel = GameSettings.SavedQualityLevel.Value
|
||||
local BindableEvent_SendNotification = Instance.new('BindableFunction')
|
||||
BindableEvent_SendNotification.Name = "SendNotification"
|
||||
BindableEvent_SendNotification.Parent = RbxGui
|
||||
|
||||
--[[ Constants ]]--
|
||||
local BG_TRANSPARENCY = 0.7
|
||||
local MAX_NOTIFICATIONS = 3
|
||||
local NOTIFICATION_Y_OFFSET = 64
|
||||
local IMAGE_SIZE = 48
|
||||
local EASE_DIR = Enum.EasingDirection.InOut
|
||||
local EASE_STYLE = Enum.EasingStyle.Sine
|
||||
local TWEEN_TIME = 0.35
|
||||
local DEFAULT_NOTIFICATION_DURATION = 5
|
||||
|
||||
--[[ Images ]]--
|
||||
local PLAYER_POINTS_IMG = 'ayaasset://textures/PlayerPoint.png'
|
||||
local BADGE_IMG = 'ayaasset://textures/2015/NotificationScript/BADGE_IMG.png'
|
||||
local FRIEND_IMAGE = game:GetService("ContentProvider").BaseUrl .. 'thumbnail/avatar?id='
|
||||
|
||||
--[[ Gui Creation ]]--
|
||||
local function createFrame(name, size, position, bgt)
|
||||
local frame = Instance.new('Frame')
|
||||
frame.Name = name
|
||||
frame.Size = size
|
||||
frame.Position = position
|
||||
frame.BackgroundTransparency = bgt
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
local function createTextButton(name, text, position)
|
||||
local button = Instance.new('TextButton')
|
||||
button.Name = name
|
||||
button.Size = UDim2.new(0.5, -2, 0.5, 0)
|
||||
button.Position = position
|
||||
button.BackgroundTransparency = BG_TRANSPARENCY
|
||||
button.BackgroundColor3 = Color3.new(0, 0, 0)
|
||||
button.Font = Enum.Font.SourceSansBold
|
||||
button.FontSize = Enum.FontSize.Size18
|
||||
button.TextColor3 = Color3.new(1, 1, 1)
|
||||
button.Text = text
|
||||
|
||||
return button
|
||||
end
|
||||
|
||||
local NotificationFrame = createFrame("NotificationFrame", UDim2.new(0, 200, 0.42, 0), UDim2.new(1, -204, 0.58, -10), 1)
|
||||
NotificationFrame.Parent = RbxGui
|
||||
|
||||
local DefaultNotifcation = createFrame("Notifcation", UDim2.new(1, 0, 0, NOTIFICATION_Y_OFFSET), UDim2.new(0, 0, 0, 0), BG_TRANSPARENCY)
|
||||
DefaultNotifcation.BackgroundColor3 = Color3.new(0, 0, 0)
|
||||
DefaultNotifcation.BorderSizePixel = 0
|
||||
|
||||
local NotificationTitle = Instance.new('TextLabel')
|
||||
NotificationTitle.Name = "NotificationTitle"
|
||||
NotificationTitle.Size = UDim2.new(0, 0, 0, 0)
|
||||
NotificationTitle.Position = UDim2.new(0.5, 0, 0.5, -12)
|
||||
NotificationTitle.BackgroundTransparency = 1
|
||||
NotificationTitle.Font = Enum.Font.SourceSansBold
|
||||
NotificationTitle.FontSize = Enum.FontSize.Size18
|
||||
NotificationTitle.TextColor3 = Color3.new(0.97, 0.97, 0.97)
|
||||
|
||||
local NotificationText = Instance.new('TextLabel')
|
||||
NotificationText.Name = "NotificationText"
|
||||
NotificationText.Size = UDim2.new(1, -20, 0, 28)
|
||||
NotificationText.Position = UDim2.new(0, 10, 0.5, 1)
|
||||
NotificationText.BackgroundTransparency = 1
|
||||
NotificationText.Font = Enum.Font.SourceSans
|
||||
NotificationText.FontSize = Enum.FontSize.Size14
|
||||
NotificationText.TextColor3 = Color3.new(0.92, 0.92, 0.92)
|
||||
NotificationText.TextWrap = true
|
||||
NotificationText.TextYAlignment = Enum.TextYAlignment.Top
|
||||
|
||||
local NotificationImage = Instance.new('ImageLabel')
|
||||
NotificationImage.Name = "NotificationImage"
|
||||
NotificationImage.Size = UDim2.new(0, IMAGE_SIZE, 0, IMAGE_SIZE)
|
||||
NotificationImage.Position = UDim2.new(0, 8, 0.5, -24)
|
||||
NotificationImage.BackgroundTransparency = 1
|
||||
NotificationImage.Image = ""
|
||||
|
||||
-- Would really like to get rid of this but some events still require this
|
||||
local PopupFrame = createFrame("PopupFrame", UDim2.new(0, 360, 0, 160), UDim2.new(0.5, -180, 0.5, -50), 0)
|
||||
PopupFrame.Style = Enum.FrameStyle.DropShadow
|
||||
PopupFrame.ZIndex = 4
|
||||
PopupFrame.Visible = false
|
||||
PopupFrame.Parent = RbxGui
|
||||
|
||||
local PopupAcceptButton = Instance.new('TextButton')
|
||||
PopupAcceptButton.Name = "PopupAcceptButton"
|
||||
PopupAcceptButton.Size = UDim2.new(0, 100, 0, 50)
|
||||
PopupAcceptButton.Position = UDim2.new(0.5, -102, 1, -58)
|
||||
PopupAcceptButton.Style = Enum.ButtonStyle.RobloxRoundButton
|
||||
PopupAcceptButton.Font = Enum.Font.SourceSansBold
|
||||
PopupAcceptButton.FontSize = Enum.FontSize.Size24
|
||||
PopupAcceptButton.TextColor3 = Color3.new(1, 1, 1)
|
||||
PopupAcceptButton.Text = "Accept"
|
||||
PopupAcceptButton.ZIndex = 5
|
||||
PopupAcceptButton.Parent = PopupFrame
|
||||
|
||||
local PopupDeclineButton = PopupAcceptButton:Clone()
|
||||
PopupDeclineButton.Name = "PopupDeclineButton"
|
||||
PopupDeclineButton.Position = UDim2.new(0.5, 2, 1, -58)
|
||||
PopupDeclineButton.Text = "Decline"
|
||||
PopupDeclineButton.Parent = PopupFrame
|
||||
|
||||
local PopupOKButton = PopupAcceptButton:Clone()
|
||||
PopupOKButton.Name = "PopupOKButton"
|
||||
PopupOKButton.Position = UDim2.new(0.5, -50, 1, -58)
|
||||
PopupOKButton.Text = "OK"
|
||||
PopupOKButton.Visible = false
|
||||
PopupOKButton.Parent = PopupFrame
|
||||
|
||||
local PopupText = Instance.new('TextLabel')
|
||||
PopupText.Name = "PopupText"
|
||||
PopupText.Size = UDim2.new(1, -16, 0.8, 0)
|
||||
PopupText.Position = UDim2.new(0, 8, 0, 8)
|
||||
PopupText.BackgroundTransparency = 1
|
||||
PopupText.Font = Enum.Font.SourceSansBold
|
||||
PopupText.FontSize = Enum.FontSize.Size36
|
||||
PopupText.TextColor3 = Color3.new(0.97, 0.97, 0.97)
|
||||
PopupText.TextWrap = true
|
||||
PopupText.ZIndex = 5
|
||||
PopupText.TextYAlignment = Enum.TextYAlignment.Top
|
||||
PopupText.Text = "This is a popup"
|
||||
PopupText.Parent = PopupFrame
|
||||
|
||||
--[[ Helper Functions ]]--
|
||||
local insertNotifcation = nil
|
||||
local removeNotification = nil
|
||||
--
|
||||
local function createNotification(title, text, image)
|
||||
local notificationFrame = DefaultNotifcation:Clone()
|
||||
notificationFrame.Position = UDim2.new(0, 0, 1, 0)
|
||||
--
|
||||
local notificationTitle = NotificationTitle:Clone()
|
||||
notificationTitle.Text = title
|
||||
notificationTitle.Parent = notificationFrame
|
||||
|
||||
local notificationText = NotificationText:Clone()
|
||||
notificationText.Text = text
|
||||
notificationText.Parent = notificationFrame
|
||||
|
||||
if image and image ~= "" then
|
||||
local notificationImage = NotificationImage:Clone()
|
||||
notificationImage.Image = image
|
||||
notificationImage.Parent = notificationFrame
|
||||
--
|
||||
notificationTitle.Position = UDim2.new(0, NotificationImage.Size.X.Offset + 16, 0.5, -12)
|
||||
notificationTitle.TextXAlignment = Enum.TextXAlignment.Left
|
||||
--
|
||||
notificationText.Size = UDim2.new(1, -IMAGE_SIZE - 16, 0, 28)
|
||||
notificationText.Position = UDim2.new(0, IMAGE_SIZE + 16, 0.5, 1)
|
||||
notificationText.TextXAlignment = Enum.TextXAlignment.Left
|
||||
end
|
||||
|
||||
return notificationFrame
|
||||
end
|
||||
|
||||
local function findNotification(notification)
|
||||
local index = nil
|
||||
for i = 1, #NotificationQueue do
|
||||
if NotificationQueue[i] == notification then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function updateNotifications()
|
||||
local pos = 1
|
||||
local yOffset = 0
|
||||
for i = #NotificationQueue, 1, -1 do
|
||||
local currentNotification = NotificationQueue[i]
|
||||
if currentNotification then
|
||||
local frame = currentNotification.Frame
|
||||
if frame and frame.Parent then
|
||||
local thisOffset = currentNotification.IsFriend and (NOTIFICATION_Y_OFFSET + 2) * 1.5 or NOTIFICATION_Y_OFFSET
|
||||
yOffset = yOffset + thisOffset
|
||||
frame:TweenPosition(UDim2.new(0, 0, 1, -yOffset - (pos * 4)), EASE_DIR, EASE_STYLE, TWEEN_TIME, true)
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local lastTimeInserted = 0
|
||||
insertNotifcation = function(notification)
|
||||
local size = #NotificationQueue
|
||||
if size == MAX_NOTIFICATIONS then
|
||||
OverflowQueue[#OverflowQueue + 1] = notification
|
||||
return
|
||||
end
|
||||
--
|
||||
size = size + 1
|
||||
NotificationQueue[size] = notification
|
||||
notification.Frame.Parent = NotificationFrame
|
||||
delay(notification.Duration, function()
|
||||
removeNotification(notification)
|
||||
end)
|
||||
while tick() - lastTimeInserted < TWEEN_TIME do
|
||||
wait()
|
||||
end
|
||||
lastTimeInserted = tick()
|
||||
--
|
||||
updateNotifications()
|
||||
end
|
||||
|
||||
removeNotification = function(notification)
|
||||
if not notification then return end
|
||||
--
|
||||
local index = findNotification(notification)
|
||||
table.remove(NotificationQueue, index)
|
||||
local frame = notification.Frame
|
||||
if frame and frame.Parent then
|
||||
frame:TweenPosition(UDim2.new(1, 0, 1, frame.Position.Y.Offset), EASE_DIR, EASE_STYLE, TWEEN_TIME, true,
|
||||
function()
|
||||
frame:Destroy()
|
||||
end)
|
||||
end
|
||||
if #OverflowQueue > 0 then
|
||||
local nextNofication = OverflowQueue[1]
|
||||
table.remove(OverflowQueue, 1)
|
||||
insertNotifcation(nextNofication)
|
||||
else
|
||||
updateNotifications()
|
||||
end
|
||||
end
|
||||
|
||||
local function sendNotification(title, text, image, duration, callback)
|
||||
local notification = {}
|
||||
local notificationFrame = createNotification(title, text, image)
|
||||
--
|
||||
notification.Frame = notificationFrame
|
||||
notification.Duration = duration
|
||||
insertNotifcation(notification)
|
||||
end
|
||||
BindableEvent_SendNotification.OnInvoke = function(title, text, image, duration, callback)
|
||||
sendNotification(title, text, image, duration, callback)
|
||||
end
|
||||
|
||||
local function sendFriendNotification(fromPlayer)
|
||||
if not UsingInstance then return end
|
||||
local notification = {}
|
||||
local notificationFrame = createNotification(fromPlayer.Name, "Sent you a friend request!",
|
||||
FRIEND_IMAGE..tostring(fromPlayer.userId).."&x=48&y=48")
|
||||
--
|
||||
local acceptButton = createTextButton("AcceptButton", "Accept", UDim2.new(0, 0, 1, 2))
|
||||
acceptButton.Parent = notificationFrame
|
||||
|
||||
local declineButton = createTextButton("DeclineButton", "Decline", UDim2.new(0.5, 2, 1, 2))
|
||||
declineButton.Parent = notificationFrame
|
||||
|
||||
acceptButton.MouseButton1Click:connect(function()
|
||||
if notification then
|
||||
removeNotification(notification)
|
||||
end
|
||||
LocalPlayer:RequestFriendship(fromPlayer)
|
||||
end)
|
||||
|
||||
declineButton.MouseButton1Click:connect(function()
|
||||
if notification then
|
||||
removeNotification(notification)
|
||||
end
|
||||
LocalPlayer:RevokeFriendship(fromPlayer)
|
||||
FriendRequestBlacklist[fromPlayer] = true
|
||||
end)
|
||||
|
||||
notification.Frame = notificationFrame
|
||||
notification.Duration = 8
|
||||
notification.IsFriend = true
|
||||
insertNotifcation(notification)
|
||||
end
|
||||
|
||||
--[[ Friend Notifications ]]--
|
||||
local function onFriendStatusChanged(otherPlayer, status)
|
||||
if status == Enum.FriendStatus.FriendRequestReceived then
|
||||
if FriendRequestBlacklist[otherPlayer] then return end
|
||||
sendFriendNotification(otherPlayer)
|
||||
elseif status == Enum.FriendStatus.Friend then
|
||||
sendNotification("New Friend", "You are now friends with "..otherPlayer.Name.."!",
|
||||
FRIEND_IMAGE..tostring(otherPlayer.userId).."&x=48&y=48", DEFAULT_NOTIFICATION_DURATION, nil)
|
||||
end
|
||||
end
|
||||
LocalPlayer.FriendStatusChanged:connect(onFriendStatusChanged)
|
||||
|
||||
--[[ Player Points Notifications ]]--
|
||||
local function onPointsAwarded(userId, pointsAwarded, userBalanceInGame, userTotalBalance)
|
||||
if not UsingInstance then return end
|
||||
if userId == LocalPlayer.userId then
|
||||
if pointsAwarded == 1 then
|
||||
sendNotification("Point Awarded", "You received "..tostring(pointsAwarded).." point!", PLAYER_POINTS_IMG, DEFAULT_NOTIFICATION_DURATION, nil)
|
||||
elseif pointsAwarded > 0 then
|
||||
sendNotification("Points Awarded", "You received "..tostring(pointsAwarded).." points!", PLAYER_POINTS_IMG, DEFAULT_NOTIFICATION_DURATION, nil)
|
||||
elseif pointsAwarded < 0 then
|
||||
sendNotification("Points Lost", "You lost "..tostring(-pointsAwarded).." points!", PLAYER_POINTS_IMG, DEFAULT_NOTIFICATION_DURATION, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
PointsService.PointsAwarded:connect(onPointsAwarded)
|
||||
|
||||
--[[ Badge Notification ]]--
|
||||
local function onBadgeAwarded(message, userId, badgeId)
|
||||
if not UsingInstance then return end
|
||||
if userId == LocalPlayer.userId then
|
||||
sendNotification("Badge Awarded", message, BADGE_IMG, DEFAULT_NOTIFICATION_DURATION, nil)
|
||||
end
|
||||
end
|
||||
BadgeService.BadgeAwarded:connect(onBadgeAwarded)
|
||||
|
||||
--[[ Graphics Changes Notification ]]--
|
||||
GameSettings.Changed:connect(function(property)
|
||||
if property == "SavedQualityLevel" then
|
||||
local level = GameSettings.SavedQualityLevel.Value
|
||||
-- value of 0 is automatic, we do not want to send a notification in that case
|
||||
if level > 0 and level ~= CurrentGraphicsQualityLevel then
|
||||
if level > CurrentGraphicsQualityLevel then
|
||||
sendNotification("Graphics Quality", "Increased to ("..tostring(level)..")", "", 2, nil)
|
||||
else
|
||||
sendNotification("Graphics Quality", "Decreased to ("..tostring(level)..")", "", 2, nil)
|
||||
end
|
||||
CurrentGraphicsQualityLevel = level
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--[[ Teleport Notifications ]]--
|
||||
local TeleportMessage = nil
|
||||
local function sendTeleportNotification(msg, time)
|
||||
if TeleportMessage then
|
||||
TeleportMessage:Destroy()
|
||||
end
|
||||
if not UsingInstance then return end
|
||||
local playerGui = LocalPlayer:FindFirstChild('PlayerGui')
|
||||
if playerGui then
|
||||
TeleportMessage = Instance.new('Message')
|
||||
TeleportMessage.Text = msg
|
||||
TeleportMessage.Parent = playerGui
|
||||
--
|
||||
if time > 0 then
|
||||
delay(time, function()
|
||||
TeleportMessage:Destroy()
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function onTeleport(state, placeId, spawnName)
|
||||
if not UsingInstance then return end
|
||||
if not TeleportService.CustomizedTeleportUI then
|
||||
if state == Enum.TeleportState.Started then
|
||||
sendTeleportNotification("Teleport Started...", 0)
|
||||
elseif state == Enum.TeleportState.WaitingForServer then
|
||||
sendTeleportNotification("Requesting Server...", 0)
|
||||
elseif state == Enum.TeleportState.InProgress then
|
||||
sendTeleportNotification("Teleporting...", 0)
|
||||
elseif state == Enum.TeleportState.Failed then
|
||||
sendTeleportNotification("Teleport failed. Insufficient privileges or target place does not exist.", 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
LocalPlayer.OnTeleport:connect(onTeleport)
|
||||
local function onTeleportErrorCallback(msg)
|
||||
PopupAcceptButton.Visible = false
|
||||
PopupDeclineButton.Visible = false
|
||||
PopupOKButton.Visible = true
|
||||
PopupText.Text = msg
|
||||
--
|
||||
local okCn = nil
|
||||
okCn = PopupOKButton.MouseButton1Click:connect(function()
|
||||
TeleportService:TeleportCancel()
|
||||
if okCn then okCn:disconnect() end
|
||||
--
|
||||
GuiService:RemoveCenterDialog(PopupFrame)
|
||||
PopupFrame.Visible = false
|
||||
end)
|
||||
GuiService:AddCenterDialog(PopupFrame, Enum.CenterDialogType.QuitDialog,
|
||||
function()
|
||||
PopupFrame.Visible = true
|
||||
end,
|
||||
function()
|
||||
PopupFrame.Visible = false
|
||||
end)
|
||||
end
|
||||
TeleportService.ErrorCallback = onTeleportErrorCallback
|
||||
|
||||
--[[ Market Place Events ]]--
|
||||
-- This is used for when a player calls CreatePlaceInPlayerInventoryAsync
|
||||
local function onClientLuaDialogRequested(msg, accept, decline)
|
||||
PopupText.Text = msg
|
||||
--
|
||||
local acceptCn, declineCn = nil, nil
|
||||
local function disconnectCns()
|
||||
if acceptCn then acceptCn:disconnect() end
|
||||
if declineCn then declineCn:disconnect() end
|
||||
--
|
||||
GuiService:RemoveCenterDialog(PopupFrame)
|
||||
PopupFrame.Visible = false
|
||||
end
|
||||
|
||||
acceptCn = PopupAcceptButton.MouseButton1Click:connect(function()
|
||||
disconnectCns()
|
||||
MarketplaceService:SignalServerLuaDialogClosed(true)
|
||||
end)
|
||||
declineCn = PopupDeclineButton.MouseButton1Click:connect(function()
|
||||
disconnectCns()
|
||||
MarketplaceService:SignalServerLuaDialogClosed(false)
|
||||
end)
|
||||
|
||||
local centerDialogSuccess = pcall(
|
||||
function()
|
||||
GuiService:AddCenterDialog(PopupFrame, Enum.CenterDialogType.QuitDialog,
|
||||
function()
|
||||
PopupOKButton.Visible = false
|
||||
PopupAcceptButton.Visible = true
|
||||
PopupDeclineButton.Visible = true
|
||||
PopupAcceptButton.Text = accept
|
||||
PopupDeclineButton.Text = decline
|
||||
PopupFrame.Visible = true
|
||||
end,
|
||||
function()
|
||||
PopupFrame.Visible = false
|
||||
end)
|
||||
end)
|
||||
|
||||
if not centerDialogSuccess then
|
||||
PopupFrame.Visible = true
|
||||
PopupAcceptButton.Text = accept
|
||||
PopupDeclineButton.Text = decline
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
MarketplaceService.ClientLuaDialogRequested:connect(onClientLuaDialogRequested)
|
||||
1901
client/common/content/scripts/CoreScripts/2015/PlayerListScript.lua
Normal file
1901
client/common/content/scripts/CoreScripts/2015/PlayerListScript.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
--build our gui
|
||||
|
||||
local popupFrame = Instance.new("Frame")
|
||||
popupFrame.Position = UDim2.new(0.5,-165,0.5,-175)
|
||||
popupFrame.Size = UDim2.new(0,330,0,350)
|
||||
popupFrame.Style = Enum.FrameStyle.DropShadow
|
||||
popupFrame.ZIndex = 4
|
||||
popupFrame.Name = "Popup"
|
||||
popupFrame.Visible = false
|
||||
popupFrame.Parent = script.Parent
|
||||
|
||||
local darken = popupFrame:clone()
|
||||
darken.Size = UDim2.new(1,16,1,16)
|
||||
darken.Position = UDim2.new(0,-8,0,-8)
|
||||
darken.Name = "Darken"
|
||||
darken.ZIndex = 1
|
||||
darken.Parent = popupFrame
|
||||
|
||||
local acceptButton = Instance.new("TextButton")
|
||||
acceptButton.Position = UDim2.new(0,20,0,270)
|
||||
acceptButton.Size = UDim2.new(0,100,0,50)
|
||||
acceptButton.Font = Enum.Font.ArialBold
|
||||
acceptButton.FontSize = Enum.FontSize.Size24
|
||||
acceptButton.Style = Enum.ButtonStyle.RobloxRoundButton
|
||||
acceptButton.TextColor3 = Color3.new(248/255,248/255,248/255)
|
||||
acceptButton.Text = "Yes"
|
||||
acceptButton.ZIndex = 5
|
||||
acceptButton.Name = "AcceptButton"
|
||||
acceptButton.Parent = popupFrame
|
||||
|
||||
local declineButton = acceptButton:clone()
|
||||
declineButton.Position = UDim2.new(1,-120,0,270)
|
||||
declineButton.Text = "No"
|
||||
declineButton.Name = "DeclineButton"
|
||||
declineButton.Parent = popupFrame
|
||||
|
||||
local okButton = acceptButton:clone()
|
||||
okButton.Name = "OKButton"
|
||||
okButton.Text = "OK"
|
||||
okButton.Position = UDim2.new(0.5,-50,0,270)
|
||||
okButton.Visible = false
|
||||
okButton.Parent = popupFrame
|
||||
|
||||
local popupImage = Instance.new("ImageLabel")
|
||||
popupImage.BackgroundTransparency = 1
|
||||
popupImage.Position = UDim2.new(0.5,-140,0,10)
|
||||
popupImage.Size = UDim2.new(0,280,0,280)
|
||||
popupImage.ZIndex = 3
|
||||
popupImage.Name = "PopupImage"
|
||||
popupImage.Parent = popupFrame
|
||||
|
||||
local backing = Instance.new("ImageLabel")
|
||||
backing.BackgroundTransparency = 1
|
||||
backing.Size = UDim2.new(1,0,1,0)
|
||||
backing.Image = "ayaasset://textures/2012/PopupScript/Backing.png"
|
||||
backing.Name = "Backing"
|
||||
backing.ZIndex = 2
|
||||
backing.Parent = popupImage
|
||||
|
||||
local popupText = Instance.new("TextLabel")
|
||||
popupText.Name = "PopupText"
|
||||
popupText.Size = UDim2.new(1,0,0.8,0)
|
||||
popupText.Font = Enum.Font.ArialBold
|
||||
popupText.FontSize = Enum.FontSize.Size36
|
||||
popupText.BackgroundTransparency = 1
|
||||
popupText.Text = "Hello I'm a popup"
|
||||
popupText.TextColor3 = Color3.new(248/255,248/255,248/255)
|
||||
popupText.TextWrap = true
|
||||
popupText.ZIndex = 5
|
||||
popupText.Parent = popupFrame
|
||||
|
||||
script:remove()
|
||||
File diff suppressed because it is too large
Load Diff
2793
client/common/content/scripts/CoreScripts/2015/Settings.lua
Normal file
2793
client/common/content/scripts/CoreScripts/2015/Settings.lua
Normal file
File diff suppressed because it is too large
Load Diff
1678
client/common/content/scripts/CoreScripts/2015/TouchControls.lua
Normal file
1678
client/common/content/scripts/CoreScripts/2015/TouchControls.lua
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user