-- HudView: the player's always-on screen in the New Year shop style (ShopKit art + font). -- * status: two picture panels (panels-v2) — level (number on the star + XP bar) and shards (crystal + balance + -- free-regeneration bar with a timer); tap a panel for a short explanation -- * menu: round icon buttons (hover grows, press shrinks, gold ring while its window is open, red badge with -- "something to do" counts), added by OrnamentCraftUI through hud.addButton(...) -- * layout: wide screens = column at the top-left (scaled to the screen height); -- phones = one compact strip along the top under the Roblox top bar, so the thumbstick (bottom-left) -- and the jump button (bottom-right) stay free; the toast stack (gui.Toasts) moves under the strip. -- install(ctx) ctx = { gui, Config, player, fmtNum, toast(text, color) } -> -- { root, addButton(id, opts) -> GuiButton, setBadge(id, n), floatDelta(amount) } -- opts = { text, icon, color, order, window = "" } local TweenService = game:GetService("TweenService") local UIS = game:GetService("UserInputService") local K = require(script.Parent:WaitForChild("ShopKit")) local H = {} local FONT, BODY, INK, WHITE, GOLD, SOFT, OK, NAVY = K.FONT, K.BODY, K.INK, K.WHITE, K.GOLD, K.SOFT, K.OK, K.NAVY local new, corner, art, label, maxText, tween = K.new, K.corner, K.art, K.label, K.maxText, K.tween local ICE = Color3.fromRGB(150, 210, 255) local WARN = Color3.fromRGB(255, 120, 110) local BTN_W, BTN_H, GAP = 92, 92, 12 -- status panels (GUI/HUD/panels-v2): art 2172x724; green field ~ x 4..96 %, y 24..83 %; the level art has a star on the left local PANEL_LEVEL = "rbxassetid://118257080024564" -- level-panel.png local PANEL_SHARDS = "rbxassetid://112163222652816" -- shards-panel.png local PANEL_W, PANEL_H = 300, 100 local INNER_X, INNER_R = 76, 278 -- text / bar column inside the green field (right of the star / crystal) local STACK = 90 -- wide layout: second panel this far below the first (the snow overlaps a bit) local CARD_W, CARD_H = PANEL_W, STACK + PANEL_H -- wide: stacked local PHONE_CARD_W, PHONE_CARD_H = PANEL_W * 2 + 6, PANEL_H -- phone: side by side local SPRITE_SIZE = 92 -- menu button pictures (GUI/HUD/button-states-v2/-states.png): one image = 3 square frames in a row, -- normal | hover | pressed. "" = not uploaded yet -> the round emoji button is used instead. local SPRITES = { Workshop = "rbxassetid://81759885631212", -- workshop-states.png Inventory = "rbxassetid://110766324164374", -- inventory-states.png Shop = "rbxassetid://113249527829304", -- shop-states.png Market = "rbxassetid://139389044874341", -- market-states.png Trade = "rbxassetid://105223746048116", -- trade-states.png Premium = "rbxassetid://96790295599044", -- premium-states.png } local function grad(c1, c2, rot) return new("UIGradient", { Color = ColorSequence.new(c1, c2), Rotation = rot or 90 }) end ---------------------------------------------------------------- notifications (toasts) -- GUI/HUD/panels-v2/notification-panel.png (2172x724, green field ~ x 5..95 %, y 26..82 %). "" = not uploaded yet -> -- a plain navy plate is drawn instead. makeToast(gui) creates gui.Toasts (HudView's layout moves it under the HUD) -- and returns toast(message, color, big): newest on top, at most TOAST_MAX on screen, fade + slide out. local NOTIFY_PANEL = "rbxassetid://123152751080177" -- notification-panel.png local TOAST_MAX = 3 -- one soft, quiet sound per kind of notification (free Creator Store sounds). Every sound also goes through an -- equalizer that cuts the highs (that is what makes UI sounds feel sharp) — TOAST_EQ. -- info - plain hint / message soft bells (UI_Notification_3x_Soft_Bells) -- ok - success, purchase, coins one marimba note -- warn - refused action, not enough shards the same marimba note, lower: a soft "bonk", no buzz -- result - big toast: new toy, fusion result Magic Glows, soft chiming cluster (Pro Sound Effects) -- level - big green toast: level up Teeny Tiny, short light-hearted sting (APM Music) -- action - clickable toast: fusion set collected Fairy Dust (Pro Sound Effects, cut to 1.6 s) local TOAST_SOUNDS = { info = { id = "rbxassetid://95469323096995", volume = 0.22 }, ok = { id = "rbxassetid://104421055647409", volume = 0.25, speed = 1.12 }, warn = { id = "rbxassetid://104421055647409", volume = 0.22, speed = 0.75 }, result = { id = "rbxassetid://9116395089", volume = 0.25 }, level = { id = "rbxassetid://9040173538", volume = 0.25 }, action = { id = "rbxassetid://9114369623", volume = 0.25, maxTime = 1.6 }, } local TOAST_EQ = { HighGain = -12, MidGain = -2, LowGain = 0 } -- colours the game's modules pass to toast() -> kind (anything else = info) local function near(a, r, g, b) return math.abs(a.R * 255 - r) + math.abs(a.G * 255 - g) + math.abs(a.B * 255 - b) < 12 end local function toastKind(color, big, onClick) if onClick then return "action" end local green = color and (near(color, 140, 255, 160) or near(color, 150, 255, 160)) if big then return green and "level" or "result" end if not color then return "info" end if near(color, 255, 120, 110) or near(color, 255, 196, 120) then return "warn" end if green or near(color, 255, 205, 70) then return "ok" end return "info" end function H.makeToast(gui) local holder = new("Frame", { Name = "Toasts", AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 74), Size = UDim2.fromOffset(480, 420), BackgroundTransparency = 1, ZIndex = 20, Parent = gui }, { new("UIListLayout", { HorizontalAlignment = Enum.HorizontalAlignment.Center, Padding = UDim.new(0, -34), SortOrder = Enum.SortOrder.LayoutOrder }), }) local order, live = 0, {} -- sounds (one Sound per kind, played locally; the same kind is not restarted within 0.15 s) local sounds, lastPlay = {}, {} for kind, d in TOAST_SOUNDS do sounds[kind] = new("Sound", { Name = "Toast_" .. kind, SoundId = d.id, Volume = d.volume, PlaybackSpeed = d.speed or 1, Parent = holder }, { new("EqualizerSoundEffect", TOAST_EQ), }) end local function playKind(kind) local s, d = sounds[kind], TOAST_SOUNDS[kind] if not s or os.clock() - (lastPlay[kind] or 0) < 0.15 then return end lastPlay[kind] = os.clock() s.Volume = d.volume s.TimePosition = 0 s:Play() if d.maxTime then local stamp = lastPlay[kind] task.delay(d.maxTime - 0.4, function() if lastPlay[kind] == stamp then tween(s, 0.4, { Volume = 0 }) end end) task.delay(d.maxTime, function() if lastPlay[kind] == stamp then s:Stop() end end) end end -- load the panel art and the sounds right away, so the very first notification is complete task.spawn(function() local list = {} for _, s in sounds do table.insert(list, s) end if NOTIFY_PANEL ~= "" then table.insert(list, new("ImageLabel", { Name = "Probe", Image = NOTIFY_PANEL, Size = UDim2.fromOffset(1, 1), BackgroundTransparency = 1, ImageTransparency = 1, Parent = holder })) end pcall(function() game:GetService("ContentProvider"):PreloadAsync(list) end) local probe = holder:FindFirstChild("Probe") if probe then probe:Destroy() end end) local function dismiss(t) if t.gone then return end t.gone = true local i = table.find(live, t) if i then table.remove(live, i) end tween(t.sc, 0.3, { Scale = 0.85 }) tween(t.frame, 0.3, { ImageTransparency = 1, BackgroundTransparency = 1 }) tween(t.text, 0.3, { TextTransparency = 1 }) tween(t.text.UIStroke, 0.3, { Transparency = 1 }) tween(t.accent, 0.3, { BackgroundTransparency = 1 }) task.delay(0.32, function() t.frame:Destroy() end) end -- onClick (optional): the panel becomes a button (hover grows it); a click runs onClick and closes the toast return function(message, color, big, onClick) order -= 1 local w = big and 470 or 410 local h = math.floor(w / 3 + 0.5) local useArt = NOTIFY_PANEL ~= "" local frame = new(onClick and "ImageButton" or "ImageLabel", { Size = UDim2.fromOffset(w, h), BackgroundTransparency = useArt and 1 or 0.05, BackgroundColor3 = NAVY, Image = useArt and NOTIFY_PANEL or "", ScaleType = Enum.ScaleType.Stretch, LayoutOrder = order, ZIndex = 20, Parent = holder }) if not useArt then corner(UDim.new(0, 14)).Parent = frame end -- small coloured stripe at the left end of the green field = the kind of message (gold / ok / warning ...) local accent = new("Frame", { AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(0.075, 0, 0.54, 0), Size = UDim2.new(0, 6, 0.36, 0), BackgroundColor3 = color or GOLD, ZIndex = 21, Parent = frame }, { corner(UDim.new(0.5, 0)) }) local text = maxText(label({ Position = UDim2.new(0.105, 0, 0.28, 0), Size = UDim2.new(0.82, 0, 0.52, 0), Text = message, TextScaled = true, TextWrapped = true, FontFace = big and FONT or BODY, TextColor3 = big and (color or WHITE) or WHITE, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 21, Parent = frame }, big and 2.5 or 2), big and 26 or 19) local sc = new("UIScale", { Scale = 0.6, Parent = frame }) tween(sc, 0.3, { Scale = 1 }, Enum.EasingStyle.Back) playKind(toastKind(color, big, onClick)) local t = { frame = frame, text = text, accent = accent, sc = sc } table.insert(live, 1, t) while #live > TOAST_MAX do dismiss(live[#live]) end if onClick then frame.AutoButtonColor = false frame.MouseEnter:Connect(function() if not t.gone then tween(sc, 0.12, { Scale = 1.05 }, Enum.EasingStyle.Back) end end) frame.MouseLeave:Connect(function() if not t.gone then tween(sc, 0.12, { Scale = 1 }) end end) frame.Activated:Connect(function() if t.gone then return end dismiss(t); onClick() end) end task.delay(onClick and 7 or big and 4.5 or 3.4, function() dismiss(t) end) end end -- blur the 3D world behind open windows (BlurEffect does not touch the GUI): watchBlur(overlay) for every window -- overlay; while any of them is visible the local "WindowBlur" in Lighting fades in local blurSet = {} function H.watchBlur(frame) local Lighting = game:GetService("Lighting") local function update() local any = false for f in blurSet do if f.Parent and f.Visible then any = true; break end end local b = Lighting:FindFirstChild("WindowBlur") or new("BlurEffect", { Name = "WindowBlur", Size = 0, Parent = Lighting }) tween(b, any and 0.25 or 0.2, { Size = any and 16 or 0 }) end blurSet[frame] = true frame:GetPropertyChangedSignal("Visible"):Connect(update) frame.Destroying:Connect(function() blurSet[frame] = nil; update() end) update() end function H.install(ctx) local Config, player, fmt = ctx.Config, ctx.player, ctx.fmtNum local gui = ctx.gui local function attr(n, d) local v = player:GetAttribute(n); if v == nil then return d end return v end local root = new("Frame", { Name = "Hud", BackgroundTransparency = 1, Size = UDim2.fromOffset(CARD_W, CARD_H), Parent = gui }) local scale = new("UIScale", { Parent = root }) ---------------------------------------------------------------- status: two picture panels (level / shards) -- panels are PANEL_W x PANEL_H (art 2172x724 = 3:1); wide screens stack them, phones put them side by side local card = new("Frame", { Name = "Status", Size = UDim2.fromOffset(CARD_W, CARD_H), BackgroundTransparency = 1, Parent = root }) local function panel(name, img) return new("ImageButton", { Name = name, Image = img, AutoButtonColor = false, BackgroundTransparency = 1, ScaleType = Enum.ScaleType.Stretch, AnchorPoint = Vector2.new(0.5, 0.5), Size = UDim2.fromOffset(PANEL_W, PANEL_H), ZIndex = 2, Parent = card }) end local BAR_BG, BAR_EDGE = Color3.fromRGB(6, 30, 16), Color3.fromRGB(255, 220, 120) local function bar(parent, y, h) return new("Frame", { Position = UDim2.fromOffset(INNER_X, y), Size = UDim2.fromOffset(INNER_R - INNER_X, h), BackgroundColor3 = BAR_BG, ZIndex = 3, Parent = parent }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = BAR_EDGE, Thickness = 1.5, Transparency = 0.35 }), }) end -- level panel (tap = what levels are for): the number sits on the gold star local levelHit = panel("LevelRow", PANEL_LEVEL) local badge = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(37, 58), Size = UDim2.fromOffset(40, 34), BackgroundTransparency = 1, ZIndex = 4, Parent = levelHit }) local badgeScale = new("UIScale", { Parent = badge }) local levelNum = maxText(label({ Size = UDim2.fromScale(1, 1), Text = "1", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = badge }, 2.5), 30) local levelTitle = maxText(label({ Position = UDim2.fromOffset(INNER_X + 2, 26), Size = UDim2.fromOffset(INNER_R - INNER_X - 4, 26), Text = "Level 1", TextScaled = true, ZIndex = 3, Parent = levelHit }, 2.5), 26) local xpBar = bar(levelHit, 55, 20) local xpFill = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = WHITE, ZIndex = 4, Parent = xpBar }, { corner(UDim.new(0.5, 0)), grad(Color3.fromRGB(255, 240, 150), Color3.fromRGB(240, 165, 30)), }) local xpText = maxText(label({ Size = UDim2.fromScale(1, 1), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = xpBar }, 1.5), 15) new("UIPadding", { PaddingTop = UDim.new(0, 2), PaddingBottom = UDim.new(0, 2), Parent = xpText }) -- shards panel (tap = how regeneration works): crystal in the left end of the green field local shardHit = panel("ShardRow", PANEL_SHARDS) local crystal = art("crystal", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromOffset(44, 54), Size = UDim2.fromOffset(56, 56), ZIndex = 3, Parent = shardHit }) local crystalScale = new("UIScale", { Parent = crystal }) local shardCount = maxText(label({ Position = UDim2.fromOffset(INNER_X + 2, 24), Size = UDim2.fromOffset(INNER_R - INNER_X - 4, 30), Text = "0", TextScaled = true, ZIndex = 3, Parent = shardHit }, 2.5), 30) local regenBar = bar(shardHit, 56, 20) local regenFill = new("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = WHITE, ZIndex = 4, Parent = regenBar }, { corner(UDim.new(0.5, 0)) }) local regenGrad = grad(Color3.fromRGB(200, 240, 255), Color3.fromRGB(70, 150, 255)) regenGrad.Parent = regenFill local regenText = maxText(label({ Size = UDim2.fromScale(1, 1), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = regenBar }, 1.5), 15) new("UIPadding", { PaddingTop = UDim.new(0, 2), PaddingBottom = UDim.new(0, 2), Parent = regenText }) -- white flash over the green field of a panel (level up) local function glow(p) local f = new("Frame", { Position = UDim2.fromOffset(12, 25), Size = UDim2.fromOffset(PANEL_W - 24, 57), BackgroundColor3 = WHITE, BackgroundTransparency = 0.4, ZIndex = 8, Parent = p }, { corner(UDim.new(0.5, 0)) }) tween(f, 0.5, { BackgroundTransparency = 1 }) task.delay(0.55, function() f:Destroy() end) end -- hover / press feel for the two panels: grow a little and brighten, shrink on press for _, row in { levelHit, shardHit } do local sc = new("UIScale", { Parent = row }) local st = { hover = false, down = false } local function paint() tween(sc, st.down and 0.06 or 0.14, { Scale = st.down and 0.97 or st.hover and 1.04 or 1 }, st.down and Enum.EasingStyle.Quad or Enum.EasingStyle.Back) tween(row, 0.12, { ImageColor3 = st.hover and Color3.fromRGB(255, 255, 255) or Color3.fromRGB(232, 232, 232) }) end row.ImageColor3 = Color3.fromRGB(232, 232, 232) row.MouseEnter:Connect(function() st.hover = true; paint() end) row.MouseLeave:Connect(function() st.hover, st.down = false, false; paint() end) row.InputBegan:Connect(function(i) if K.isPress(i) then st.down = true; paint() end end) row.InputEnded:Connect(function(i) if K.isPress(i) then st.down = false; paint() end end) end levelHit.Activated:Connect(function() ctx.toast("You get XP from generating, fusing and workout gear. New levels unlock ornaments, the market and trading.", GOLD) end) shardHit.Activated:Connect(function() local lvl = attr("Upg_Regen", 0) ctx.toast(string.format("Shards build up on their own: +1 every %ds while you have fewer than %d. Get more by recycling ornaments in the shredder.", math.floor(Config.RegenSeconds(lvl) + 0.5), Config.RegenCap(lvl)), ICE) end) ---------------------------------------------------------------- floating +N / -N local function floatDelta(amount) local t = label({ AnchorPoint = Vector2.new(0, 0.5), Position = UDim2.new(1, 4, 0.5, 0), Size = UDim2.fromOffset(160, 40), Text = (amount > 0 and "+" or "-") .. fmt(math.abs(amount)), TextSize = 32, TextColor3 = amount > 0 and OK or WARN, ZIndex = 10, Parent = shardHit }, 2.5) local sc = new("UIScale", { Scale = 0.5, Parent = t }) tween(sc, 0.25, { Scale = 1 }, Enum.EasingStyle.Back) tween(t, 1.2, { Position = UDim2.new(1, 4, 0.5, -42), TextTransparency = 1 }) tween(t.UIStroke, 1.2, { Transparency = 1 }) task.delay(1.25, function() t:Destroy() end) end ---------------------------------------------------------------- live values local shownShards = attr("Shards", 0) local lastShards, lastLevel, lastXP = shownShards, attr("Level", 1), attr("XP", 0) local rolling = 0 local function rollShards(target) rolling += 1 local my, from = rolling, shownShards task.spawn(function() local t0, dur = os.clock(), math.clamp(math.abs(target - from) / 60, 0.25, 0.8) while my == rolling do local a = math.clamp((os.clock() - t0) / dur, 0, 1) a = 1 - (1 - a) ^ 3 shownShards = math.floor(from + (target - from) * a + 0.5) shardCount.Text = fmt(shownShards) if a >= 1 then break end task.wait() end end) end shardCount.Text = fmt(shownShards) local function updateLevel() local level, xp, need = attr("Level", 1), attr("XP", 0), attr("XPNeed", 0) levelNum.Text = tostring(level) levelTitle.Text = "Level " .. level xpText.Text = need > 0 and (fmt(xp) .. " / " .. fmt(need) .. " XP") or "max" tween(xpFill, 0.4, { Size = UDim2.fromScale(need > 0 and math.clamp(xp / need, 0.03, 1) or 1, 1) }) if level > lastLevel then -- level up: the badge jumps and shines badgeScale.Scale = 1.5 tween(badgeScale, 0.6, { Scale = 1 }, Enum.EasingStyle.Elastic) glow(levelHit) K.floatText(card, "Level up!", GOLD) elseif xp > lastXP and level == lastLevel then badgeScale.Scale = 1.12 tween(badgeScale, 0.3, { Scale = 1 }, Enum.EasingStyle.Back) end lastLevel, lastXP = level, xp end for _, n in { "Level", "XP", "XPNeed" } do player:GetAttributeChangedSignal(n):Connect(updateLevel) end updateLevel() player:GetAttributeChangedSignal("Shards"):Connect(function() local v = attr("Shards", 0) if v ~= lastShards then floatDelta(v - lastShards) end lastShards = v rollShards(v) crystalScale.Scale = 1.25 tween(crystalScale, 0.35, { Scale = 1 }, Enum.EasingStyle.Back) end) task.spawn(function() while root.Parent do local at = attr("ShardRegenAt", 0) local lvl = attr("Upg_Regen", 0) local cap, every = Config.RegenCap(lvl), Config.RegenSeconds(lvl) if at == 0 then regenFill.Size = UDim2.fromScale(1, 1) regenGrad.Color = ColorSequence.new(Color3.fromRGB(255, 235, 150), Color3.fromRGB(235, 160, 40)) regenText.Text = attr("Shards", 0) > cap and ("regen paused: more than " .. cap) or ("cap full · " .. cap) else local left = math.max(0, at - workspace:GetServerTimeNow()) local s = math.ceil(left) regenFill.Size = UDim2.fromScale(math.clamp(1 - left / every, 0.04, 1), 1) regenGrad.Color = ColorSequence.new(Color3.fromRGB(200, 240, 255), Color3.fromRGB(70, 150, 255)) regenText.Text = string.format("+1 in %d:%02d · up to %d", s // 60, s % 60, cap) end task.wait(0.1) end end) ---------------------------------------------------------------- menu buttons -- ZIndex 3: above the status panels, so a badge "+N" floats over them local menu = new("Frame", { Name = "Menu", BackgroundTransparency = 1, ZIndex = 3, Size = UDim2.fromOffset(CARD_W, BTN_H * 2 + GAP), Parent = root }) local grid = new("UIGridLayout", { CellSize = UDim2.fromOffset(BTN_W, BTN_H), CellPadding = UDim2.fromOffset(GAP, GAP), SortOrder = Enum.SortOrder.LayoutOrder, FillDirectionMaxCells = 3, Parent = menu }) -- phones: the second half of the buttons moves into a column on the right edge local menuR = new("Frame", { Name = "MenuRight", BackgroundTransparency = 1, ZIndex = 3, Visible = false, Size = UDim2.fromOffset(BTN_W, BTN_H), Parent = root }) new("UIGridLayout", { CellSize = UDim2.fromOffset(BTN_W, BTN_H), CellPadding = UDim2.fromOffset(GAP, GAP), SortOrder = Enum.SortOrder.LayoutOrder, FillDirectionMaxCells = 1, Parent = menuR }) local menuScale = new("UIScale", { Parent = menu }) local menuRScale = new("UIScale", { Parent = menuR }) local buttons = {} local function addButton(id, o) local b = new("TextButton", { Name = id .. "Button", Text = "", AutoButtonColor = false, BackgroundTransparency = 1, LayoutOrder = o.order or 0, Parent = menu }) local sheet = SPRITES[id] local disc, setFrame, ringRound if sheet and sheet ~= "" then -- sprite sheet: 3 square frames side by side (normal | hover | pressed); a clipping window shows one of them disc = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, -2), Size = UDim2.fromOffset(SPRITE_SIZE, SPRITE_SIZE), BackgroundTransparency = 1, Parent = b }) local window = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, ClipsDescendants = true, Parent = disc }) local strip = new("ImageLabel", { Size = UDim2.fromScale(3, 1), BackgroundTransparency = 1, Image = sheet, ScaleType = Enum.ScaleType.Stretch, Parent = window }) setFrame = function(k) strip.Position = UDim2.fromScale(-k, 0) end ringRound = UDim.new(0.24, 0) else -- fallback (no picture yet): round gradient disc with an emoji disc = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 2), Size = UDim2.fromOffset(78, 78), BackgroundColor3 = WHITE, Parent = b }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = INK, Thickness = 3 }), grad(o.color:Lerp(WHITE, 0.35), o.color:Lerp(Color3.new(0, 0, 0), 0.25)), }) new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.new(1, -8, 1, -8), BackgroundTransparency = 1, ZIndex = 2, Parent = disc }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = GOLD, Thickness = 3, Transparency = 0.15 }), }) new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 6), Size = UDim2.new(0.56, 0, 0.2, 0), BackgroundColor3 = WHITE, BackgroundTransparency = 0.82, ZIndex = 2, Parent = disc }, { corner(UDim.new(0.5, 0)), }) label({ Size = UDim2.fromScale(1, 1), Text = o.icon, TextSize = 40, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 3, Parent = disc }, 0) ringRound = UDim.new(0.5, 0) end local sc = new("UIScale", { Parent = disc }) -- glowing ring while the window is open local ring = new("UIStroke", { Color = Color3.fromRGB(255, 240, 170), Thickness = 0, Transparency = 0, Parent = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Size = UDim2.new(1, setFrame and -2 or 10, 1, setFrame and -2 or 10), BackgroundTransparency = 1, Parent = disc }, { corner(ringRound) }) }) -- big caption across the middle of the button; it lives inside `disc`, so it grows / shrinks with the button's UIScale local cap = maxText(label({ AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.56), Size = UDim2.new(1, 10, 0, 34), Text = o.text, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 4, Parent = disc }, 3.5), 30) local badge2 = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(0.5, 30, 0, 10), Size = UDim2.fromOffset(28, 28), BackgroundColor3 = Color3.fromRGB(225, 40, 50), Visible = false, ZIndex = 5, Parent = b }, { corner(UDim.new(0.5, 0)), new("UIStroke", { Color = WHITE, Thickness = 2.5 }) }) local badgeText = maxText(label({ Size = UDim2.fromScale(1, 1), Text = "", TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = badge2 }, 1.5), 18) new("UIPadding", { PaddingTop = UDim.new(0, 4), PaddingBottom = UDim.new(0, 4), PaddingLeft = UDim.new(0, 3), PaddingRight = UDim.new(0, 3), Parent = badgeText }) local st = { hover = false, down = false, open = false } local function paint() if setFrame then setFrame(st.down and 2 or (st.hover or st.open) and 1 or 0) end local target = setFrame and (st.down and 0.96 or st.hover and 1.05 or 1) -- the art already shows hover / press or (st.down and 0.9 or st.hover and 1.1 or st.open and 1.06 or 1) tween(sc, st.down and 0.06 or 0.14, { Scale = target }, st.down and Enum.EasingStyle.Quad or Enum.EasingStyle.Back) cap.TextColor3 = (st.hover or st.open) and GOLD or WHITE tween(ring, 0.15, { Thickness = st.open and 4 or 0 }) end b.MouseEnter:Connect(function() st.hover = true; paint() end) b.MouseLeave:Connect(function() st.hover, st.down = false, false; paint() end) b.InputBegan:Connect(function(i) if K.isPress(i) then st.down = true; paint() end end) b.InputEnded:Connect(function(i) if K.isPress(i) then st.down = false; paint() end end) if o.window then task.spawn(function() local w = gui:WaitForChild(o.window, 30) if not w then return end local function sync() st.open = w.Visible; paint() end w:GetPropertyChangedSignal("Visible"):Connect(sync) sync() end) end buttons[id] = { button = b, badge = badge2, badgeText = badgeText } return b end -- red count badge; when the count grows (not on the first value after joining) the badge pops and a gold -- "+N" floats up from it local function setBadge(id, n) local e = buttons[id] if not e then return end n = n or 0 local old = e.n e.n = n e.badge.Visible = n > 0 e.badgeText.Text = n > 99 and "99+" or tostring(n) if old == nil or n <= old then return end local s2 = e.badge:FindFirstChildOfClass("UIScale") or new("UIScale", { Parent = e.badge }) s2.Scale = old == 0 and 0.3 or 1.6 tween(s2, old == 0 and 0.35 or 0.5, { Scale = 1 }, old == 0 and Enum.EasingStyle.Back or Enum.EasingStyle.Elastic) local plus = label({ AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 30, 0, 0), Size = UDim2.fromOffset(70, 34), Text = "+" .. (n - old), TextSize = 30, TextColor3 = GOLD, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 8, Parent = e.button }, 2.5) local ps = new("UIScale", { Scale = 0.4, Parent = plus }) tween(ps, 0.25, { Scale = 1 }, Enum.EasingStyle.Back) tween(plus, 1.3, { Position = UDim2.new(0.5, 30, 0, -30) }) task.delay(0.6, function() tween(plus, 0.7, { TextTransparency = 1 }) tween(plus.UIStroke, 0.7, { Transparency = 1 }) end) task.delay(1.35, function() plus:Destroy() end) end -- "something to do" counts (recomputed when the player's attributes change) local function recount() -- (the Workshop badge = upgrades + fusions + boosters comes from WorkshopWindow through setBadge) local shards = attr("Shards", 0) local buy, waiting = 0, 0 for _, it in Config.SHOP do local owned = attr("Decor_" .. it.Id, false) if not owned and shards >= it.Price then buy += 1 end if owned and not attr("Placed_" .. it.Id, false) then waiting += 1 end end setBadge("Shop", buy) setBadge("Inventory", waiting) end local queued = false player.AttributeChanged:Connect(function() if queued then return end queued = true task.delay(0.3, function() queued = false; recount() end) end) task.defer(recount) ---------------------------------------------------------------- layout (wide column / phone strip) local function layout() local cam = workspace.CurrentCamera local v = cam and cam.ViewportSize or Vector2.new(1280, 720) local inset = game:GetService("GuiService"):GetGuiInset() local h = v.Y - inset.Y local force = gui:GetAttribute("ForceLayout") -- QA: "phone" / "wide" local phone = force == "phone" or (force ~= "wide" and UIS.TouchEnabled and math.min(v.X, h) < 560) local nBtn = 0 for _ in buttons do nBtn += 1 end nBtn = math.max(nBtn, 6) local s, toastY if phone then -- panels side by side up in the Roblox top bar (right of the Roblox buttons); the menu buttons go into two -- columns along the left and right screen edges, so the middle of the screen stays free local list = {} for _, e in buttons do table.insert(list, e.button) end table.sort(list, function(a, b) return a.LayoutOrder < b.LayoutOrder end) local half = math.ceil(#list / 2) for i, b in list do b.Parent = i <= half and menu or menuR end local rows = math.max(half, 3) local colH = rows * BTN_H + (rows - 1) * GAP local GS = game:GetService("GuiService") local tb = GS.TopbarInset -- free part of the top bar, screen pixels -- gui (0,0) in screen pixels: AbsolutePosition is counted from under the top bar, TopbarInset from the -- real screen corner, so the inset is added back (otherwise the panels end up under the bar, not in it) local origin = gui.AbsolutePosition + (gui.IgnoreGuiInset and Vector2.zero or inset) local barTop, barH, barL, barR if tb.Height >= 20 then barTop, barH, barL, barR = tb.Min.Y, tb.Height, tb.Min.X, tb.Max.X else barTop, barH, barL, barR = 0, math.max(inset.Y, 44), v.X * 0.3, v.X - 8 end local below = math.max(barTop + barH, origin.Y) - origin.Y -- first free gui pixel under the top bar s = math.clamp(math.min((barH - 4) / PANEL_H, (h - below - 16) * 0.68 / colH), 0.36, 0.7) root.Size = UDim2.fromOffset(v.X / s, (h + origin.Y) / s) root.Position = UDim2.fromOffset(0, 0) -- panels: centred in the free top-bar area (not left of it), vertically on the bar's middle local cardW = PHONE_CARD_W * s local cx = math.max((barL + barR) / 2, barL + cardW / 2 + 4) - origin.X cx = math.min(cx, v.X - cardW / 2 - 6) local cy = barTop + barH / 2 - origin.Y card.Size = UDim2.fromOffset(PHONE_CARD_W, PHONE_CARD_H) card.Position = UDim2.fromOffset(cx / s - PHONE_CARD_W / 2, cy / s - PHONE_CARD_H / 2) levelHit.Position = UDim2.fromOffset(PANEL_W / 2, PANEL_H / 2) shardHit.Position = UDim2.fromOffset(PANEL_W * 1.5 + 6, PANEL_H / 2) -- button columns: own scale (the panels are limited by the thin top bar, the buttons are not) local sb = math.clamp((h - below - 16) * 0.7 / colH, 0.36, 0.7) menuScale.Scale = sb / s menuRScale.Scale = sb / s grid.FillDirectionMaxCells = 1 local colTop = (below + 12) / s menu.Size = UDim2.fromOffset(BTN_W, colH) menu.Position = UDim2.fromOffset(6 / s, colTop) menuR.Size = UDim2.fromOffset(BTN_W, colH) menuR.Position = UDim2.fromOffset((v.X - 6 - BTN_W * sb) / s, colTop) menuR.Visible = true toastY = cy + PANEL_H * s / 2 + 8 else for _, e in buttons do e.button.Parent = menu end menuR.Visible = false menuScale.Scale = 1 card.Size = UDim2.fromOffset(CARD_W, CARD_H) card.Position = UDim2.fromOffset(0, 0) levelHit.Position = UDim2.fromOffset(PANEL_W / 2, PANEL_H / 2) shardHit.Position = UDim2.fromOffset(PANEL_W / 2, STACK + PANEL_H / 2) -- column at the top-left: card, then a 3 x N grid local rows = math.ceil(nBtn / 3) local colH = CARD_H + GAP + 6 + rows * BTN_H + (rows - 1) * GAP s = math.clamp(math.min(h * 0.6 / colH, 1.05), 0.55, 1.05) grid.FillDirectionMaxCells = 3 menu.Size = UDim2.fromOffset(CARD_W, rows * BTN_H + (rows - 1) * GAP) menu.Position = UDim2.fromOffset(0, CARD_H + GAP + 6) root.Size = UDim2.fromOffset(CARD_W, colH) root.Position = UDim2.fromOffset(14, 12) toastY = 14 end scale.Scale = s local toasts = gui:FindFirstChild("Toasts") if toasts then toasts.Position = UDim2.new(0.5, 0, 0, toastY) local ts = toasts:FindFirstChildOfClass("UIScale") or new("UIScale", { Parent = toasts }) ts.Scale = phone and math.clamp(s * 1.25, 0.55, 0.9) or math.clamp(h / 900, 0.75, 1) end end local function watchCam() local cam = workspace.CurrentCamera if cam then cam:GetPropertyChangedSignal("ViewportSize"):Connect(layout) end layout() end workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(watchCam) watchCam() UIS.LastInputTypeChanged:Connect(layout) game:GetService("GuiService"):GetPropertyChangedSignal("TopbarInset"):Connect(layout) gui:GetAttributeChangedSignal("ForceLayout"):Connect(layout) return { root = root, addButton = function(id, o) local b = addButton(id, o); task.defer(layout); task.defer(recount); return b end, setBadge = setBadge, floatDelta = floatDelta, } end return H