Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Booth = Model & {Claim: ProximityPrompt, Edit: ProximityPrompt}
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local AvatarEditorService = game:GetService("AvatarEditorService")
- local AssetService = game:GetService("AssetService")
- local Players = game:GetService("Players")
- local Player = Players.LocalPlayer
- local Modules = ReplicatedStorage.Modules
- local ClaimedBooth: Model | nil = nil
- local Remotes = ReplicatedStorage.Remotes
- local boothCommunication = Remotes.BoothRemotes.boothCommunication
- local avatarEditor = Remotes.BoothRemotes.avatarEditor
- local publishAvatar = Remotes.BoothRemotes.publishAvatar
- local removeAvatar = Remotes.BoothRemotes.removeAvatar
- local AssetTypes = require(Modules.AssetTypes)
- local CatagoryTable = require(Modules.CatagoryTable)
- local getFilterType = require(Modules.getFilterType)
- local LayeredClothingOrder = require(Modules.LayeredClothingOrder)
- local SelectedStand = nil
- -- UI
- local PlayerGui = Player.PlayerGui
- local Core = PlayerGui:WaitForChild("Core")
- local Pages = Core:WaitForChild("Pages")
- local EditBooth = Pages:WaitForChild("EditBooth")
- local CatalogEditor = Pages:WaitForChild("NEW_CatalogEditor")
- local AvatarLeft = CatalogEditor.LeftSide.Top.ViewportFrame.WorldModel.HazelUGC
- local Booths = workspace.Booths
- local HumanoidDescription = Instance.new("HumanoidDescription")
- local FilterCatagory = nil
- local FilterSubCatagory = nil
- local function toggleProximitys(on: boolean, except: Model | nil)
- for _, Booth in pairs(Booths:GetChildren()) do
- if Booth == except then
- continue
- end
- local Claim: ProximityPrompt = Booth:FindFirstChild("Claim", true)
- if Claim then
- Claim.Enabled = on
- return
- end
- end
- end
- local function setupBooth(Booth)
- local Claim: ProximityPrompt = Booth:FindFirstChild("Claim", true)
- local Edit: ProximityPrompt = Booth:FindFirstChild("Edit", true)
- Claim.Triggered:Connect(function()
- if not Claim.Enabled then return end
- boothCommunication:FireServer(Booth, "Claim")
- end)
- Edit.Triggered:Connect(function()
- if not Edit.Enabled then return end
- PlayerGui.Core.Pages.EditBooth.Visible = not PlayerGui.Core.Pages.EditBooth.Visible
- end)
- end
- for _, Booth in pairs(Booths:GetChildren()) do
- setupBooth(Booth)
- end
- local function addProximitys(Booth)
- local ProximityTable = {}
- local Stands = Booth.Stands
- for _, Stand in pairs(Stands:GetChildren()) do
- local Main = Stand:FindFirstChild("Main", true)
- if Main then
- local ProximityPrompt = Instance.new("ProximityPrompt")
- ProximityPrompt.Name = "EditProx"
- ProximityPrompt.RequiresLineOfSight = false
- ProximityPrompt.UIOffset = Vector2.new(0,150)
- ProximityPrompt.Parent = Main
- ProximityTable[Stand] = ProximityPrompt
- end
- end
- return ProximityTable
- end
- local function setupProximitys(Proximitys)
- for _, Proximity in pairs(Proximitys) do
- local Stand = Proximity.Parent.Parent
- Proximity.Triggered:Connect(function()
- SelectedStand = Stand
- CatalogEditor.Visible = not CatalogEditor.Visible
- end)
- end
- end
- boothCommunication.OnClientEvent:Connect(function(Booth: Booth, Claimed: boolean, Message: string)
- local Claim: ProximityPrompt = Booth:FindFirstChild("Claim", true) :: Booth
- local Edit: ProximityPrompt = Booth:FindFirstChild("Edit", true) :: Booth
- local BoothProximitys = {}
- if Message == "Claimed!" then
- ClaimedBooth = Booth
- Claim.Enabled = false
- Edit.Enabled = true
- local Proximitys = addProximitys(Booth)
- setupProximitys(Proximitys)
- toggleProximitys(false, Booth)
- elseif Message == "Unclaimed!" then
- ClaimedBooth = nil
- setupBooth(Booth)
- toggleProximitys(true, nil)
- end
- end)
- -- EditBooth
- EditBooth.Container.TextSignBox.Confirm.MouseButton1Click:Connect(function()
- boothCommunication:FireServer(ClaimedBooth, "Edit", {
- ["TextSign"] = EditBooth.Container.TextSignBox.EnterTextBox.EnterText.Text
- })
- end)
- EditBooth.Container.Unclaim.MouseButton1Click:Connect(function()
- boothCommunication:FireServer(ClaimedBooth, "Unclaim")
- EditBooth.Visible = false
- end)
- EditBooth.Close.MouseButton1Click:Connect(function()
- EditBooth.Visible = false
- end)
- -- CatalogEditor
- local currentCost = 0
- local Banner = CatalogEditor.LeftSide.Top.Banner
- local CatalogScroll = CatalogEditor.RightSide.BrowseCatalog.Container.Main.Catalog.CatalogScroll
- local CatalogTemplate = CatalogScroll.UIGridLayout.Template
- local CurrentWearing = CatalogEditor.LeftSide.CurrentlyWearing.WearingScroll
- local CurrentWearingTemplate = CurrentWearing.UIListLayout.Template
- local ColorFrame = CatalogEditor.RightSide.BrowseCatalog.Container.Main.Colors
- local CurrentPageNum = 1
- local CurrentColorAim = "All"
- local PageNext = CatalogEditor.RightSide.BrowseCatalog.Container.PageNext
- local nextButton = PageNext.NextButton
- local backButton = PageNext.BackButton
- local pageNumber = PageNext.PageNumber
- local CharacterViewport = CatalogEditor.LeftSide.Top.ViewportFrame
- local SearchParams = CatalogSearchParams.new()
- local PageCache = {}
- local HumanoidData = {}
- local function clearWearingScroll()
- for _, Item in pairs(CurrentWearing:GetChildren()) do
- if Item:IsA("ImageButton") then
- Item:Destroy()
- end
- end
- end
- local function removeWearingScroll(ID)
- local Wearing = CurrentWearing:FindFirstChild(ID)
- if Wearing then
- Wearing:Destroy()
- end
- end
- local function addWearingScroll(ItemFrame, ID, Price, BundleType)
- local Wearing = CurrentWearingTemplate:Clone()
- Wearing.Parent = CurrentWearing
- Wearing.Icon.Image = ItemFrame.Box.Image
- Wearing.Name = ID
- Wearing.MouseButton1Click:Connect(function()
- if ItemFrame:FindFirstChild("Box") then
- ItemFrame.Box.Equipped.Visible = false
- end
- if BundleType then
- HumanoidData["BUNDLE"] = nil
- end
- HumanoidData[ID] = nil
- avatarEditor:FireServer(HumanoidData)
- currentCost -= Price
- Banner.Cost.Text = ""..tostring(currentCost)
- Wearing:Destroy()
- end)
- end
- local function clearCatalogScroll()
- for _, Item in pairs(CatalogScroll:GetChildren()) do
- if Item:IsA("Frame") then
- Item:Destroy()
- end
- end
- end
- local function updateCatalogScroll(Search, Page)
- local CurrentPage
- if Page then
- clearCatalogScroll()
- CurrentPage = Page
- else
- clearCatalogScroll()
- CurrentPage = Search:GetCurrentPage()
- table.insert(PageCache, {Search, CurrentPage})
- end
- for _, item in pairs(CurrentPage) do
- local AssetType = item.AssetType
- local BundleType = item.BundleType
- local ID = tostring(item.Id)
- local Price = item.Price or "Limited"
- local Name = item.Name
- local Image
- if AssetType then
- Image = "https://www.roblox.com/asset-thumbnail/image?assetId=".. ID .."&width=420&height=420&format=png"
- elseif BundleType then
- Image = "rbxthumb://type=BundleThumbnail&id="..ID.."&w=420&h=420"
- end
- local HumanoidAssetType = AssetTypes[AssetType]
- if typeof(HumanoidAssetType) == "EnumItem" then
- HumanoidAssetType = {
- ["AccessoryType"] = HumanoidAssetType;
- ["AssetId"] = ID;
- ["Order"] = 1; -- set this lateer TODO
- }
- end
- local ItemFrame = CatalogTemplate:Clone()
- ItemFrame.InfoDisplay.PriceBox.ItemPrice.Text = Price
- ItemFrame.InfoDisplay.ItemName.Text = Name
- ItemFrame.Box.Image = Image
- ItemFrame.Parent = CatalogScroll
- if HumanoidData[ID] then
- ItemFrame.Box.Equipped.Visible = true
- end
- local function addAccesory(Bundle)
- local equipAmount = #CurrentWearing:GetChildren()
- if equipAmount >= 20 then
- warn("Max accessories equipped!")
- return
- end
- HumanoidData[ID] = HumanoidAssetType
- if Bundle then
- HumanoidData["BUNDLE"] = Bundle
- end
- avatarEditor:FireServer(HumanoidData)
- if tonumber(Price) then
- currentCost += Price
- end
- addWearingScroll(ItemFrame, ID, Price, BundleType)
- Banner.Cost.Text = ""..tostring(currentCost)
- end
- ItemFrame.Box.MouseButton1Click:Connect(function()
- local equipAmount = #CurrentWearing:GetChildren() - 2
- if equipAmount >= 20 then
- warn("Max accessories equipped!")
- return
- end
- ItemFrame.Box.Equipped.Visible = not ItemFrame.Box.Equipped.Visible
- if ItemFrame.Box.Equipped.Visible then
- if HumanoidAssetType then
- addAccesory()
- elseif BundleType then
- local Details = AssetService:GetBundleDetailsAsync(tonumber(ID))
- for _, Item in pairs(Details.Items) do
- if Item.Type == "UserOutfit" then
- addAccesory(Item.Id)
- break
- end
- end
- else
- warn("Missing Type for: "..AssetType)
- end
- else
- HumanoidData[ID] = nil
- removeWearingScroll(ID)
- if BundleType then
- HumanoidData["BUNDLE"] = nil
- end
- if tonumber(Price) then
- currentCost -= Price
- Banner.Cost.Text = ""..tostring(currentCost)
- end
- avatarEditor:FireServer(HumanoidData)
- end
- end)
- end
- end --TODO clean tree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement