This commit is contained in:
listik committed 2026-11-16 23:50:40 +03:00
commit 2d6a8a867d
1093 files changed
+2424571

No files matched your search

+179
View File
@@ -0,0 +1,179 @@
-- PremiumWindow: "Премиум" — shard packs and booster packs for Robux (frame, tabs, buttons: ShopKit).
-- Tabs: Осколки / Бустеры / Как это работает. Button: ready "R$ N" -> busy while Roblox shows its purchase
-- dialog -> card flashes "+N" when bought; off "Скоро" while the Developer Product is not set up (ProductId 0).
-- Everything is granted on the server (ProcessReceipt); the client only opens PromptProductPurchase.
local MarketplaceService = game:GetService("MarketplaceService")
local K = require(script.Parent:WaitForChild("ShopKit"))
local P = {}
local WHITE, GOLD, SOFT, OK, BODY, NAVY = K.WHITE, K.GOLD, K.SOFT, K.OK, K.BODY, K.NAVY
local new, corner, art, label, maxText, pill, tween = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.tween
function P.install(ctx)
local Config, player = ctx.Config, ctx.player
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 TABS = {
{ id = "Shards", text = "Shards", icon = "💎", tip = "The bigger the pack, the better the value per shard." },
{ id = "Boosters", text = "Boosters", icon = "🍀", tip = "A booster goes in the generator slot — it multiplies the luck of one generation." },
{ id = "Help", text = "How It Works", icon = "📖", tip = "Robux purchase: Roblox shows its own confirmation window." },
}
local refresh
local ch = K.chrome({ win = win, title = "PREMIUM", subtitle = "Shards and boosters\nfor Robux", tabs = TABS,
closeWindow = ctx.closeWindow, fmtNum = fmt, onTab = function() refresh() end })
local buttons = {} -- productId -> { btn, card, item }
local waiting = {} -- productId -> true while the Roblox dialog is open
local function buyButton(card, item, props)
local btn
btn = pill(card, props, function()
waiting[item.ProductId] = true
btn.set("busy")
MarketplaceService:PromptProductPurchase(player, item.ProductId)
task.delay(30, function() if waiting[item.ProductId] then waiting[item.ProductId] = nil; refresh() end end)
end)
if item.ProductId ~= 0 then buttons[item.ProductId] = { btn = btn, card = card, item = item } end
return btn
end
local function paintButton(btn, item)
if item.ProductId == 0 then btn.set("off", "Soon")
elseif waiting[item.ProductId] then btn.set("busy")
else btn.set("ready", "R$ " .. item.Robux) end
end
local all = {}
-- shard packs: 4 tall cards
local _, shScroll = ch.makePage("Shards", true)
new("UIGridLayout", { CellSize = UDim2.fromOffset(300, 548), CellPadding = UDim2.fromOffset(18, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = shScroll })
new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 8), Parent = shScroll })
local cheapest
for _, item in Config.PREMIUM do
if item.Kind == "Shards" then
local per = item.Amount / item.Robux
cheapest = cheapest and math.min(cheapest, per) or per
end
end
local order = 0
for _, item in Config.PREMIUM do
if item.Kind == "Shards" then
order += 1
local card = art(order == 4 and "cardOrange" or order == 3 and "cardViolet" or "cardCyan", { LayoutOrder = order, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = shScroll })
if item.Tag then
local tag = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 44), Size = UDim2.fromOffset(220, 40), BackgroundColor3 = GOLD, ZIndex = 7, Parent = card }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = Color3.fromRGB(150, 90, 10), Thickness = 2 }),
})
maxText(label({ Position = UDim2.fromOffset(10, 5), Size = UDim2.new(1, -20, 1, -10), Text = item.Tag, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 8, Parent = tag }, 1.5), 24)
end
-- a pile of crystals: bigger pack, bigger pile
local n = item.Amount >= 3000 and 4 or item.Amount >= 1200 and 3 or item.Amount >= 500 and 2 or 1
local pile = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 96), Size = UDim2.fromOffset(240, 170), BackgroundTransparency = 1, ZIndex = 5, Parent = card })
for k = 1, n do
local off = k - (n + 1) / 2
local ic = art("crystal", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, off * 52, 0.5, (k % 2) * 16 - 4), Size = UDim2.fromOffset(120, 120),
Rotation = off * 12, ZIndex = 5 + (k % 2), Parent = pile })
local s = new("UIScale", { Parent = ic })
task.spawn(function()
task.wait(k * 0.3)
while ic.Parent do
tween(s, 1.4, { Scale = 1.06 }, Enum.EasingStyle.Sine).Completed:Wait()
tween(s, 1.4, { Scale = 1 }, Enum.EasingStyle.Sine).Completed:Wait()
end
end)
end
maxText(label({ Position = UDim2.fromOffset(20, 280), Size = UDim2.new(1, -40, 0, 46), Text = item.Name, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 36)
maxText(label({ Position = UDim2.fromOffset(20, 330), Size = UDim2.new(1, -40, 0, 50), Text = "+" .. fmt(item.Amount), TextScaled = true, TextColor3 = Color3.fromRGB(190, 230, 255),
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 48)
local bonus = math.floor((item.Amount / item.Robux / cheapest - 1) * 100 + 0.5)
maxText(label({ Position = UDim2.fromOffset(20, 384), Size = UDim2.new(1, -40, 0, 26), Text = bonus > 0 and ("shards · " .. bonus .. "% more per R$") or "shards", TextScaled = true,
FontFace = BODY, TextColor3 = bonus > 0 and GOLD or SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 1.5), 20)
local btn = buyButton(card, item, { Position = UDim2.fromOffset(30, 428), Size = UDim2.fromOffset(240, 74), ZIndex = 5, TextMax = 32 })
table.insert(all, { btn = btn, item = item })
end
end
-- booster packs: 2 wide cards
local _, boScroll = ch.makePage("Boosters", true)
new("UIGridLayout", { CellSize = UDim2.fromOffset(615, 470), CellPadding = UDim2.fromOffset(18, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = boScroll })
new("UIPadding", { PaddingLeft = UDim.new(0, 2), PaddingTop = UDim.new(0, 2), Parent = boScroll })
local owned = {}
order = 0
for _, item in Config.PREMIUM do
if item.Kind == "Booster" then
order += 1
local b = Config.BOOSTERS[item.Booster]
local card = art(order == 1 and "cardGreen" or "cardOrange", { LayoutOrder = order, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = boScroll })
local orb = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 52), Size = UDim2.fromOffset(170, 170), BackgroundColor3 = b.Color, ZIndex = 5, Parent = card }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = WHITE, Thickness = 6 }),
new("UIGradient", { Rotation = 90, Color = ColorSequence.new(WHITE, Color3.fromRGB(170, 170, 170)) }),
})
label({ Size = UDim2.fromScale(1, 1), Text = "x" .. b.Luck, TextSize = 76, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = orb }, 4)
local cnt = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(1, 4, 0, 26), Size = UDim2.fromOffset(70, 70), BackgroundColor3 = Color3.fromRGB(226, 40, 52), ZIndex = 7, Parent = orb }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = WHITE, Thickness = 4 }),
})
maxText(label({ Position = UDim2.fromScale(0.15, 0.2), Size = UDim2.fromScale(0.7, 0.6), Text = "×" .. item.Amount, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 8, Parent = cnt }, 2), 34)
maxText(label({ Position = UDim2.fromOffset(30, 236), Size = UDim2.new(1, -60, 0, 50), Text = item.Name, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 44)
maxText(label({ Position = UDim2.fromOffset(40, 288), Size = UDim2.new(1, -80, 0, 30), Text = item.Amount .. " boosters · one generation luck x" .. b.Luck, TextScaled = true, FontFace = BODY,
TextColor3 = SOFT, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 1.5), 22)
local chip = new("Frame", { AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -30, 0, 44), Size = UDim2.fromOffset(140, 50), BackgroundColor3 = NAVY,
BackgroundTransparency = 0.15, ZIndex = 6, Parent = card }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = GOLD, Thickness = 2 }) })
owned[item.Booster] = maxText(label({ Position = UDim2.fromOffset(8, 6), Size = UDim2.new(1, -16, 1, -12), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 7, Parent = chip }, 2), 26)
local btn = buyButton(card, item, { Position = UDim2.fromOffset(157, 344), Size = UDim2.fromOffset(300, 76), ZIndex = 5, TextMax = 34 })
table.insert(all, { btn = btn, item = item })
end
end
-- help
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 = "Safe", btn = "To Shards", tab = "Shards",
text = "Payment goes through Roblox: it shows its own confirmation window before charging Robux." },
{ card = "cardViolet", icon = "⚡", title = "Instant", btn = "To Shards", tab = "Shards",
text = "Shards and boosters arrive instantly and are saved with your progress." },
{ card = "cardOrange", icon = "🍀", title = "Boosters", btn = "To Boosters", tab = "Boosters",
text = "A booster goes in the generator slot. It multiplies the luck of one generation and is used up when you make an ornament." },
}
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 }, function() ch.showTab(h.tab) end)
go.set("alt", h.btn)
end
refresh = function()
ch.setBalance(attr("Shards", 0))
for _, e in all do paintButton(e.btn, e.item) end
for id, t in owned do t.Text = "you have: " .. attr("Booster_" .. id, 0) end
end
MarketplaceService.PromptProductPurchaseFinished:Connect(function(userId, productId, bought)
if userId ~= player.UserId or not waiting[productId] then return end
waiting[productId] = nil
local e = buttons[productId]
if bought and e and win.overlay.Visible then
K.flash(e.card)
K.floatText(e.card, e.item.Kind == "Shards" and ("+" .. fmt(e.item.Amount)) or ("+" .. e.item.Amount .. " boosters"))
end
refresh()
end)
player:GetAttributeChangedSignal("Shards"):Connect(function() if win.overlay.Visible then refresh() end end)
for id in Config.BOOSTERS do
player:GetAttributeChangedSignal("Booster_" .. id):Connect(function() if win.overlay.Visible then refresh() end end)
end
ch.showTab("Shards")
return {
open = function(tab)
ch.setBalance(attr("Shards", 0), true)
if tab then ch.showTab(tab) end
refresh()
end,
showTab = ch.showTab,
}
end
return P