-- ShopWindow: "Магазин" — decorations for the player's plot, paid in shards (frame, tabs, buttons: ShopKit). -- Tabs: Все товары / Украшения / Развлечения / Как это работает. "Все товары" shows a badge with the number of -- things you can buy right now. Card button: ready "Купить" -> busy -> "Поставить" (blue, starts placing right -- away through K.nav.Place = OrnamentCraftUI's startPlacing; the garland opens the "string it on the tree" mode); -- off "Нужно ещё N" when you are short of shards. local K = require(script.Parent:WaitForChild("ShopKit")) local S = {} local WHITE, GOLD, SOFT, OK, BODY = K.WHITE, K.GOLD, K.SOFT, K.OK, K.BODY local new, corner, art, label, maxText, pill, pricePlate = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.pricePlate -- product pictures (GUI/магазин/roblox) + card colour + tab local PRODUCTS = { Tree = { img = "rbxassetid://103785076834354", card = "cardGreen", tab = "Decor", short = "Decorate it with your ornaments" }, PullUpBar = { img = "rbxassetid://103992671287296", card = "cardCyan", tab = "Fun", short = "XP, +1 shard per 10 in a row, up to 60 per set" }, Bench = { img = "rbxassetid://83102967647787", card = "cardViolet", tab = "Fun", short = "A workout corner" }, Fireworks = { img = "rbxassetid://102801089134457", card = "cardOrange", tab = "Decor", short = "The whole server sees the show" }, Garland = { card = "cardViolet", tab = "Decor", short = "Wrap your tree in lights" }, -- no picture yet: 3D preview } -- 3D preview for products without a picture (a tree item is shown on the tree) local function preview(card, it) local vp = K.new("ViewportFrame", { Position = UDim2.fromOffset(26, 44), Size = UDim2.fromOffset(230, 210), BackgroundTransparency = 1, Ambient = Color3.fromRGB(165, 165, 180), LightColor = Color3.fromRGB(255, 245, 230), LightDirection = Vector3.new(-1, -1.3, -1), ZIndex = 5, Parent = card }) task.spawn(function() local decor = game:GetService("ReplicatedStorage"):WaitForChild("OrnamentMachine"):WaitForChild("Decor") local template = decor:FindFirstChild(it.Model) if not template then return end local tree = it.OnTree and decor:FindFirstChild("ChristmasTree") pcall(function() game:GetService("ContentProvider"):PreloadAsync({ template, tree }) end) local model = Instance.new("Model") if tree then local t = tree:Clone(); t:PivotTo(CFrame.new()); t.Parent = model end local m = template:Clone() m:PivotTo(CFrame.new()) m.Parent = model model.WorldPivot = CFrame.new() -- pivot at the foot, not the box centre model:PivotTo(CFrame.Angles(0, math.rad(-30), 0)) model.Parent = vp local _, size = model:GetBoundingBox() local cam = Instance.new("Camera") cam.FieldOfView = 40 cam.CFrame = CFrame.lookAt(Vector3.new(0, size.Y * 0.62, math.max(size.X, size.Y, size.Z) * 1.5), Vector3.new(0, size.Y * 0.47, 0)) cam.Parent = vp vp.CurrentCamera = cam end) end function S.install(ctx) local Config, player, remote = ctx.Config, ctx.player, ctx.remote local fmt = ctx.fmtNum local function attr(n, d) local v = player:GetAttribute(n); if v == nil then return d end return v end local win = ctx.win local refresh local TABS = { { id = "All", text = "All items", icon = "🛍", tip = "Purchases appear on your plot and stay forever." }, { id = "Decor", text = "Decorations", icon = "🎄", tip = "The tree is the main decoration: you hang generator ornaments on it." }, { id = "Fun", text = "Activities", icon = "🎉", tip = "Workout gear gives XP — that unlocks the market and trading faster." }, { id = "Help", text = "How It Works", icon = "📖", tip = "You can move bought items or store them in your inventory any time." }, } local ch = K.chrome({ win = win, title = "SHOP", subtitle = "Decorations and activities\nfor your plot", tabs = TABS, closeWindow = ctx.closeWindow, fmtNum = fmt, onTab = function() refresh() end }) local cards = {} local busy = {} local function productCard(parent, it, order) local p = PRODUCTS[it.Id] or { card = "cardGreen", short = "" } local card = art(p.card, { LayoutOrder = order, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = parent }) if p.img then new("ImageLabel", { Position = UDim2.fromOffset(26, 44), Size = UDim2.fromOffset(230, 210), BackgroundTransparency = 1, Image = p.img, ScaleType = Enum.ScaleType.Fit, ZIndex = 5, Parent = card }) else preview(card, it) end maxText(label({ Position = UDim2.fromOffset(270, 40), Size = UDim2.fromOffset(320, 46), Text = it.Name, TextScaled = true, ZIndex = 5, Parent = card }, 3), 38) maxText(label({ Position = UDim2.fromOffset(272, 88), Size = UDim2.fromOffset(318, 62), Text = it.Desc or p.short, TextScaled = true, TextWrapped = true, FontFace = BODY, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 21) local status = maxText(label({ Position = UDim2.fromOffset(272, 152), Size = UDim2.fromOffset(318, 28), Text = "", TextScaled = true, FontFace = BODY, ZIndex = 5, Parent = card }, 1.5), 21) local plate, price = pricePlate(card, UDim2.fromOffset(268, 196), UDim2.fromOffset(140, 50), 5) price.Text = fmt(it.Price) local c = { it = it, card = card, status = status, plate = plate, price = price } local btn btn = pill(card, { Position = UDim2.fromOffset(420, 188), Size = UDim2.fromOffset(176, 64), ZIndex = 5, TextMax = 28 }, function(state) if state == "alt" then -- already bought: go straight to placing it (garland: stringing it on the tree), not to the inventory if K.nav.Place then K.nav.Place(it.Id) else K.go("Inventory", "Items") end return end busy[it.Id] = true refresh() task.spawn(function() local ok, res = pcall(remote.InvokeServer, remote, "Buy", it.Id) res = (ok and type(res) == "table") and res or { ok = false, msg = "No connection to the shop" } busy[it.Id] = nil ctx.toast(res.msg or (res.ok and "Bought" or "Failed"), res.ok and OK or K.WARN) if res.ok then for _, other in cards do if other.it == it then K.flash(other.card); K.floatText(other.card, "Bought!") end end end refresh() end) end) c.btn = btn table.insert(cards, c) end local GRID = function(scroll) new("UIGridLayout", { CellSize = UDim2.fromOffset(615, 272), CellPadding = UDim2.fromOffset(18, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = scroll }) new("UIPadding", { PaddingLeft = UDim.new(0, 2), PaddingTop = UDim.new(0, 2), Parent = scroll }) end for _, tabId in { "All", "Decor", "Fun" } do local _, scroll = ch.makePage(tabId, true) GRID(scroll) for _, it in Config.SHOP do local p = PRODUCTS[it.Id] if tabId == "All" or (p and p.tab == tabId) then productCard(scroll, it, it.Order) end end end -- help page local _, heScroll = ch.makePage("Help", true) new("UIGridLayout", { CellSize = UDim2.fromOffset(404, 540), CellPadding = UDim2.fromOffset(20, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = heScroll }) new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 4), Parent = heScroll }) local HELP = { { card = "cardCyan", icon = "🛍", title = "Buy", btn = "To Items", go = function() ch.showTab("All") end, text = "Everything costs shards. You buy each item once — it's yours forever." }, { card = "cardViolet", icon = "🏠", title = "Place on your plot", btn = "Inventory", go = function() K.go("Inventory", "Items") end, text = "Bought items are in your inventory. “Place” — pick a spot: click places, R rotates, Esc cancels." }, { card = "cardOrange", icon = "🎄", title = "Decorate the tree", btn = "My Ornaments", go = function() K.go("Inventory", "Toys") end, text = "Place a tree, hold an ornament from your inventory and click a glowing dot on the tree." }, } for i, h in HELP do local card = art(h.card, { LayoutOrder = i, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = heScroll }) label({ AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 44), Size = UDim2.fromOffset(120, 110), Text = h.icon, TextSize = 84, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 0) maxText(label({ Position = UDim2.fromOffset(24, 160), Size = UDim2.new(1, -48, 0, 50), Text = h.title, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 42) maxText(label({ Position = UDim2.fromOffset(30, 218), Size = UDim2.new(1, -60, 0, 190), Text = h.text, TextScaled = true, TextWrapped = true, FontFace = BODY, TextColor3 = WHITE, TextXAlignment = Enum.TextXAlignment.Center, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 24) local go = pill(card, { Position = UDim2.fromOffset(62, 420), Size = UDim2.fromOffset(280, 70), ZIndex = 5, TextMax = 30 }, h.go) go.set("alt", h.btn) end refresh = function() local shards = attr("Shards", 0) ch.setBalance(shards) local can = {} for _, c in cards do local owned = attr("Decor_" .. c.it.Id, false) local placed = attr("Placed_" .. c.it.Id, false) c.plate.Visible = not owned c.price.TextColor3 = shards >= c.it.Price and WHITE or K.WARN if owned then local onTree = c.it.OnTree c.status.Text = placed and (onTree and "on the tree" or "on your plot") or "bought · in inventory" c.status.TextColor3 = OK c.btn.set("alt", onTree and (placed and "Rehang" or "On Tree") or (placed and "Move" or "Place")) elseif busy[c.it.Id] then c.btn.set("busy") elseif shards >= c.it.Price then c.status.Text, c.status.TextColor3 = "available", GOLD c.btn.set("ready", "Buy") can[c.it.Id] = true else c.status.Text, c.status.TextColor3 = "not enough shards", SOFT c.btn.set("off", "Need " .. fmt(c.it.Price - shards)) end end local n = 0 for _ in can do n += 1 end ch.tabs.All.setBadge(n) end local function live() if win.overlay.Visible then refresh() end end player:GetAttributeChangedSignal("Shards"):Connect(live) for _, it in Config.SHOP do player:GetAttributeChangedSignal("Decor_" .. it.Id):Connect(live) player:GetAttributeChangedSignal("Placed_" .. it.Id):Connect(live) end ch.showTab("All") return { open = function(tab) ch.setBalance(attr("Shards", 0), true) if tab then ch.showTab(tab) end refresh() end, showTab = ch.showTab, } end return S