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

+199
View File
@@ -0,0 +1,199 @@
-- SettingsWindow: "Settings" — sound volumes, background music on/off, interface language (frame, tabs: ShopKit).
-- Tabs: Sound / Language.
-- Sound: sliders Master / Music / Effects / Interface (drag or click the track, 0..100 %) + a Background music
-- On/Off switch.
-- Language: Auto (Roblox translates to the device language) / English / Русский.
-- Values: player attributes Set_* (from the profile, see OrnamentPlayerData.Settings). A change is applied at once
-- by setting the attribute locally (PlayerSettings listens to it) and is sent to the server
-- (OrnamentMachine.Settings) 0.6 s after the player stops changing things, so it is saved in the profile.
local UIS = game:GetService("UserInputService")
local K = require(script.Parent:WaitForChild("ShopKit"))
local S = {}
local WHITE, GOLD, SOFT, BODY, NAVY, INK = K.WHITE, K.GOLD, K.SOFT, K.BODY, K.NAVY, K.INK
local new, corner, art, label, maxText, pill, tween = K.new, K.corner, K.art, K.label, K.maxText, K.pill, K.tween
local DEFAULTS = { Master = 1, Music = 1, Effects = 1, UI = 1, MusicOn = true, Lang = "auto" }
function S.install(ctx)
local player, win, remote = ctx.player, ctx.win, ctx.remote
local function get(k) local v = player:GetAttribute("Set_" .. k); if v == nil then return DEFAULTS[k] end return v end
-- local apply + debounced save
local pending, stamp = {}, 0
local function set(k, v)
player:SetAttribute("Set_" .. k, v)
pending[k] = v
stamp += 1
local my = stamp
task.delay(0.6, function()
if my ~= stamp or next(pending) == nil then return end
local patch = pending
pending = {}
remote:FireServer(patch)
end)
end
local TABS = {
{ id = "Sound", text = "Sound", icon = "🔊", tip = "Drag the sliders — settings are saved to your profile and come back on every server." },
{ id = "Language", text = "Language", icon = "🌐", tip = "Pick the interface language — it is saved to your profile." },
}
local refresh
local ch = K.chrome({ win = win, title = "SETTINGS", subtitle = "Sound and language", tabs = TABS,
closeWindow = ctx.closeWindow, fmtNum = ctx.fmtNum, onTab = function() refresh() end })
-- the "Language" tab always says "Language" (in every interface language and with Roblox auto-translation),
-- so a player who switched to a language they can not read still finds the way back
for _, d in ch.tabs.Language.button:GetDescendants() do
if d:IsA("TextLabel") and d.Text == "Language" then
d:SetAttribute("NoTranslate", true)
d.AutoLocalize = false
end
end
---------------------------------------------------------------- sound page
local page = ch.makePage("Sound")
local ROW_W, ROW_H, GAP = 1180, 98, 10
local function row(i)
return new("Frame", { Position = UDim2.fromOffset(40, 6 + (i - 1) * (ROW_H + GAP)), Size = UDim2.fromOffset(ROW_W, ROW_H), BackgroundColor3 = NAVY,
BackgroundTransparency = 0.25, ZIndex = 4, Parent = page }, { corner(UDim.new(0, 24)), new("UIStroke", { Color = GOLD, Thickness = 2, Transparency = 0.45 }) })
end
local function caption(r, icon, title, sub)
label({ Position = UDim2.fromOffset(18, 14), Size = UDim2.fromOffset(70, 70), Text = icon, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = r }, 0)
maxText(label({ Position = UDim2.fromOffset(100, 12), Size = UDim2.fromOffset(330, 44), Text = title, TextScaled = true, ZIndex = 5, Parent = r }, 2.5), 36)
maxText(label({ Position = UDim2.fromOffset(100, 58), Size = UDim2.fromOffset(330, 28), Text = sub, TextScaled = true, FontFace = BODY, TextColor3 = SOFT, ZIndex = 5, Parent = r }, 1.5), 22)
end
local sliders = {}
local dragging -- { s = slider, input = InputObject? }
local function slider(i, key, icon, title, sub)
local r = row(i)
caption(r, icon, title, sub)
local TRACK_X, TRACK_W = 470, 540
local hit = new("TextButton", { Text = "", AutoButtonColor = false, BackgroundTransparency = 1, Position = UDim2.fromOffset(TRACK_X - 20, 14),
Size = UDim2.fromOffset(TRACK_W + 40, 70), ZIndex = 5, Parent = r })
hit:SetAttribute("NoSound", true)
local track = new("Frame", { Position = UDim2.fromOffset(20, 24), Size = UDim2.fromOffset(TRACK_W, 22), BackgroundColor3 = Color3.fromRGB(6, 30, 16), ZIndex = 5, Parent = hit }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = Color3.fromRGB(255, 220, 120), Thickness = 2, Transparency = 0.3 }),
})
local fill = new("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = WHITE, ZIndex = 6, Parent = track }, {
corner(UDim.new(0.5, 0)), new("UIGradient", { Color = ColorSequence.new(Color3.fromRGB(255, 240, 150), Color3.fromRGB(240, 165, 30)) }),
})
local knob = new("Frame", { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(1, 0.5), Size = UDim2.fromOffset(54, 54), BackgroundColor3 = WHITE, ZIndex = 8, Parent = track }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = INK, Thickness = 3 }),
new("UIGradient", { Rotation = 90, Color = ColorSequence.new(Color3.fromRGB(255, 244, 190), Color3.fromRGB(236, 170, 40)) }),
})
local knobScale = new("UIScale", { Parent = knob })
local pct = maxText(label({ Position = UDim2.fromOffset(1050, 22), Size = UDim2.fromOffset(110, 54), Text = "100%", TextScaled = true,
TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = r }, 2.5), 36)
local s = { key = key, track = track, hover = false }
function s.show(v)
fill.Size = UDim2.fromScale(v, 1)
fill.Visible = v > 0.001
knob.Position = UDim2.fromScale(v, 0.5)
pct.Text = math.floor(v * 100 + 0.5) .. "%"
end
function s.paint()
local active = dragging and dragging.s == s
tween(knobScale, 0.12, { Scale = active and 1.18 or s.hover and 1.1 or 1 }, Enum.EasingStyle.Back)
end
function s.setFromX(x)
local a, w = track.AbsolutePosition.X, track.AbsoluteSize.X
if w <= 0 then return end
local v = math.clamp((x - a) / w, 0, 1)
v = math.floor(v * 100 + 0.5) / 100
s.show(v)
if v ~= get(key) then set(key, v) end
end
hit.MouseEnter:Connect(function() s.hover = true; s.paint() end)
hit.MouseLeave:Connect(function() s.hover = false; s.paint() end)
hit.InputBegan:Connect(function(input)
if K.isPress(input) then
dragging = { s = s, input = input.UserInputType == Enum.UserInputType.Touch and input or nil }
s.setFromX(input.Position.X)
s.paint()
end
end)
sliders[key] = s
return s
end
UIS.InputChanged:Connect(function(input)
if not dragging then return end
if input.UserInputType == Enum.UserInputType.MouseMovement or (dragging.input and input == dragging.input) or input.UserInputType == Enum.UserInputType.Touch then
dragging.s.setFromX(input.Position.X)
end
end)
UIS.InputEnded:Connect(function(input)
if dragging and (input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch) then
local s = dragging.s
dragging = nil
s.paint()
end
end)
slider(1, "Master", "🔊", "Master volume", "All game sounds")
slider(2, "Music", "🎵", "Music", "Background tracks")
slider(3, "Effects", "✨", "Effects", "Machines, fireworks, steps")
slider(4, "UI", "🖱", "Interface", "Clicks and notifications")
local musicRow = row(5)
caption(musicRow, "🎶", "Background music", "Play the background tracks")
local musicBtn = pill(musicRow, { Position = UDim2.fromOffset(880, 12), Size = UDim2.fromOffset(260, 74), ZIndex = 5, TextMax = 32 }, function()
set("MusicOn", not get("MusicOn"))
refresh()
end)
---------------------------------------------------------------- language page
local _, langScroll = ch.makePage("Language", true)
new("UIGridLayout", { CellSize = UDim2.fromOffset(404, 540), CellPadding = UDim2.fromOffset(20, 18), SortOrder = Enum.SortOrder.LayoutOrder, Parent = langScroll })
new("UIPadding", { PaddingLeft = UDim.new(0, 4), PaddingTop = UDim.new(0, 4), Parent = langScroll })
local LANGS = {
{ id = "auto", card = "cardCyan", badge = "AUTO", title = "Auto", text = "Roblox translates the game into your device language." },
{ id = "en", card = "cardViolet", badge = "EN", title = "English", text = "The original English text." },
{ id = "ru", card = "cardOrange", badge = "RU", title = "Русский", text = "Весь интерфейс на русском.", native = true },
}
local langButtons = {}
for i, l in LANGS do
local card = art(l.card, { LayoutOrder = i, ScaleType = Enum.ScaleType.Slice, SliceCenter = K.CARD_SLICE, ZIndex = 4, Parent = langScroll })
local disc = new("Frame", { AnchorPoint = Vector2.new(0.5, 0), Position = UDim2.new(0.5, 0, 0, 48), Size = UDim2.fromOffset(150, 150), BackgroundColor3 = NAVY, ZIndex = 5, Parent = card }, {
corner(UDim.new(0.5, 0)), new("UIStroke", { Color = GOLD, Thickness = 5 }),
})
local b = maxText(label({ Position = UDim2.fromScale(0.12, 0.25), Size = UDim2.fromScale(0.76, 0.5), Text = l.badge, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 6, Parent = disc }, 3), 60)
b:SetAttribute("NoTranslate", true)
local t = maxText(label({ Position = UDim2.fromOffset(24, 214), Size = UDim2.new(1, -48, 0, 54), Text = l.title, TextScaled = true, TextXAlignment = Enum.TextXAlignment.Center, ZIndex = 5, Parent = card }, 3), 46)
local d = maxText(label({ Position = UDim2.fromOffset(34, 276), Size = UDim2.new(1, -68, 0, 120), Text = l.text, TextScaled = true, TextWrapped = true, FontFace = BODY,
TextColor3 = WHITE, TextXAlignment = Enum.TextXAlignment.Center, TextYAlignment = Enum.TextYAlignment.Top, ZIndex = 5, Parent = card }, 1.5), 26)
if l.id ~= "auto" then t:SetAttribute("NoTranslate", true) end -- language names stay in their own language
if l.native then d:SetAttribute("NoTranslate", true) end
langButtons[l.id] = pill(card, { Position = UDim2.fromOffset(62, 420), Size = UDim2.fromOffset(280, 74), ZIndex = 5, TextMax = 30 }, function()
set("Lang", l.id)
K.flash(card)
refresh()
end)
end
---------------------------------------------------------------- refresh
refresh = function()
ch.setBalance(player:GetAttribute("Shards") or 0)
for key, s in sliders do if not (dragging and dragging.s == s) then s.show(get(key)) end end
local on = get("MusicOn")
musicBtn.set(on and "ready" or "alt", on and "On" or "Off")
local lang = get("Lang")
for id, btn in langButtons do
if id == lang then btn.set("done", "Selected") else btn.set("ready", "Select") end
end
end
for _, k in { "Master", "Music", "Effects", "UI", "MusicOn", "Lang" } do
player:GetAttributeChangedSignal("Set_" .. k):Connect(function() if win.overlay.Visible then refresh() end end)
end
ch.showTab("Sound")
return {
open = function(tab)
ch.setBalance(player:GetAttribute("Shards") or 0, true)
if tab then ch.showTab(tab) end
refresh()
end,
showTab = ch.showTab,
}
end
return S