интерфейс

This commit is contained in:
listik committed 2026-11-04 22:37:21 +03:00
1 parent d7ccebb788
commit 838a118f98
10 files changed
+583 -86

No files matched your search

@@ -0,0 +1,405 @@
-- HudBar (LocalScript) -> StarterPlayer > StarterPlayerScripts
-- Нижняя панель и правый верх в стиле игры (вместо стандартных панелей Roblox):
-- слоты удочек со стрелками (клик / клавиши 1–3 — выбрать удочку и взять её в руки),
-- карточка удочки в руке (клик — взять или убрать), карточка наживки (⇄ — вкладка наживки гильдии),
-- кнопка «Рюкзак» с заполненностью сумки, таблица игроков (уровень, серебро, улов) справа сверху —
-- под ней встают плашка погоды и баннер события.
-- Стиль и помощники — из FishingClient (Theme.kit), всё лежит в его холсте и прячется вместе с ним.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local player = Players.LocalPlayer
local Config = require(ReplicatedStorage:WaitForChild("FishConfig"))
local Models = require(ReplicatedStorage:WaitForChild("GameModels"))
local Theme = require(script.Parent:WaitForChild("UiTheme"))
local remote = ReplicatedStorage:WaitForChild("GameEvent")
while not Theme.kit do
task.wait(0.1)
end
local K = Theme.kit
local C = Theme.C
local new, text, btn, corner, stroke, gradient, fmt = K.new, K.text, K.btn, K.corner, K.stroke, K.gradient, K.fmt
local TITLE, BODY2 = K.TITLE, K.BODY2
local CENTER = Enum.TextXAlignment.Center
local WHITE = Color3.new(1, 1, 1)
-- стандартные рюкзак и список игроков Roblox заменены своими
local function hideCore()
for _ = 1, 20 do
local ok = pcall(function()
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end)
if ok then
return
end
task.wait(0.5)
end
end
task.spawn(hideCore)
-- деревянная панель в стиле HUD
local function woodPanel(props)
local f = new("Frame", props, { corner(10), stroke(C.goldDark, 2.5, 0), Theme.woodGradient(C.wood, C.woodDark) })
Theme.innerBorder(f, 4, 7, C.gold, 0.55)
return f
end
---------------------------------------------------------------- удочки и наживка (низ по центру)
local SLOTS = 3
local bar = woodPanel({
Name = "HotBar", Size = UDim2.fromOffset(0, 74), AutomaticSize = Enum.AutomaticSize.X, AnchorPoint = Vector2.new(0.5, 1),
Position = UDim2.new(0.5, 0, 1, -10), BackgroundColor3 = WHITE, Parent = K.screen,
})
Theme.rivets(bar, 7, 6)
new("UIPadding", { PaddingLeft = UDim.new(0, 12), PaddingRight = UDim.new(0, 12), Parent = bar })
local row = new("Frame", { Size = UDim2.fromScale(0, 1), AutomaticSize = Enum.AutomaticSize.X, BackgroundTransparency = 1, Parent = bar }, {
new("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, VerticalAlignment = Enum.VerticalAlignment.Center, Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }),
})
-- ярлычок над слотами
do
local tag = new("Frame", {
Size = UDim2.fromOffset(0, 24), AutomaticSize = Enum.AutomaticSize.X, AnchorPoint = Vector2.new(0, 1), Position = UDim2.new(0, 34, 0, 6),
BackgroundColor3 = WHITE, ZIndex = 3, Parent = bar,
}, { corner(8), stroke(C.goldDark, 2, 0), Theme.woodGradient(C.woodLight, C.wood), new("UIPadding", { PaddingLeft = UDim.new(0, 10), PaddingRight = UDim.new(0, 10) }) })
text({ Size = UDim2.fromScale(0, 1), AutomaticSize = Enum.AutomaticSize.X, Font = BODY2, TextSize = 13, TextColor3 = C.parchment, Text = "Выбрать удочку", ZIndex = 4, Parent = tag })
end
local page = 0 -- какие удочки видны в слотах: page*SLOTS + 1 …
local refresh -- обновление панели, объявлена ниже
local function ownedRods()
local set = {}
for id in string.gmatch(player:GetAttribute("OwnedRods") or "Basic", "[^,]+") do
set[id] = true
end
local list = {}
for _, r in ipairs(Config.Rods) do
if set[r.id] then
table.insert(list, r)
end
end
return list
end
local function rodLevel(id)
for pair in string.gmatch(player:GetAttribute("RodLevels") or "", "[^,]+") do
local k, v = pair:match("^(%w+):(%d+)$")
if k == id then
return tonumber(v)
end
end
return 0
end
local function rodTool()
for _, container in ipairs({ player.Character, player:FindFirstChild("Backpack") }) do
if container then
for _, t in ipairs(container:GetChildren()) do
if t:IsA("Tool") and t:GetAttribute("IsRod") then
return t
end
end
end
end
end
local function inHand()
local t = rodTool()
return t ~= nil and t.Parent == player.Character
end
local function equip(on)
local hum = player.Character and player.Character:FindFirstChildOfClass("Humanoid")
if not hum then
return
end
if on then
local t = rodTool()
if t then
hum:EquipTool(t)
end
else
hum:UnequipTools()
end
end
-- 3D-модель удочки (как в магазине): картинки-иконки удочек могут быть недоступны (права на ассет),
-- модель строится из деталей и видна всегда. В квадрате удочка наклонена по диагонали, иначе она — тонкая черта
local function rodView(holder, rodId, lvl)
local key = rodId and (rodId .. ":" .. lvl) or ""
if holder:GetAttribute("Shown") == key then
return
end
holder:SetAttribute("Shown", key)
for _, c in ipairs(holder:GetChildren()) do
if c:IsA("ViewportFrame") then
c:Destroy()
end
end
if rodId and K.viewport then
local ok, model = pcall(Models.buildRod, rodId, lvl, true)
if ok and model then
local p = model:GetPivot()
model:PivotTo(CFrame.new(p.Position) * CFrame.Angles(math.rad(42), 0, 0) * (p - p.Position))
K.viewport(holder, model, K.VIEW.rod, 0.62)
end
end
end
local function arrow(order, label, dir)
local b = btn({ Size = UDim2.fromOffset(26, 56), BackgroundColor3 = C.woodLight, Text = label, TextSize = 18, LayoutOrder = order, Parent = row }, function()
local count = #ownedRods()
local pages = math.max(1, math.ceil(count / SLOTS))
page = (page + dir) % pages
refresh()
end)
return b
end
arrow(1, "‹", -1)
local slots = {}
for i = 1, SLOTS do
local s = btn({ Size = UDim2.fromOffset(56, 56), BackgroundColor3 = C.wood, Text = "", LayoutOrder = 1 + i, Parent = row }, function()
local rod = slots[i].rod
if rod then
if rod.id ~= player:GetAttribute("Rod") then
remote:FireServer("Buy", "Rod", rod.id) -- своя удочка — бесплатно, сервер выдаёт её в руки
task.delay(0.4, equip, true)
else
equip(not inHand())
end
end
end)
local icon = new("Frame", { Size = UDim2.new(1, -6, 1, -6), Position = UDim2.fromOffset(3, 3), BackgroundTransparency = 1, Parent = s })
local num = new("Frame", { Size = UDim2.fromOffset(18, 18), AnchorPoint = Vector2.new(0.5, 1), Position = UDim2.new(0.5, 0, 1, 6), BackgroundColor3 = C.bg, ZIndex = 3, Parent = s },
{ corner(9), stroke(C.gold, 1.2) })
text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 11, TextXAlignment = CENTER, TextColor3 = C.goldBright, Text = tostring(i), ZIndex = 4, Parent = num })
slots[i] = { button = s, icon = icon, stroke = s:FindFirstChildOfClass("UIStroke") }
end
arrow(10, "›", 1)
-- разделитель
new("Frame", { Size = UDim2.fromOffset(2, 52), BackgroundColor3 = C.goldDark, BorderSizePixel = 0, LayoutOrder = 11, Parent = row })
-- удочка в руке
local rodCard = btn({ Size = UDim2.fromOffset(196, 60), BackgroundColor3 = C.woodLight, Text = "", LayoutOrder = 12, Parent = row }, function()
equip(not inHand())
end)
local rodIcon = new("Frame", { Size = UDim2.fromOffset(52, 52), Position = UDim2.fromOffset(4, 4), BackgroundTransparency = 1, Parent = rodCard })
local rodName = text({ Size = UDim2.new(1, -66, 1, -8), Position = UDim2.fromOffset(58, 4), Font = TITLE, TextScaled = true, TextWrapped = true, Text = "", Parent = rodCard })
new("UITextSizeConstraint", { MaxTextSize = 17, Parent = rodName })
local rodCheck = new("Frame", { Size = UDim2.fromOffset(22, 22), AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.new(1, -4, 0, 4), BackgroundColor3 = C.forest, ZIndex = 3, Parent = rodCard },
{ corner(11), stroke(WHITE, 2) })
text({ Size = UDim2.fromScale(1, 1), Font = TITLE, TextSize = 13, TextXAlignment = CENTER, Text = "✓", ZIndex = 4, Parent = rodCheck })
-- наживка
local baitCard = new("Frame", { Size = UDim2.fromOffset(190, 60), BackgroundColor3 = WHITE, LayoutOrder = 13, Parent = row },
{ corner(8), stroke(C.gold, 1.5, 0.15), Theme.woodGradient(C.woodLight, C.wood) })
local baitIcon = text({ Size = UDim2.fromOffset(44, 44), Position = UDim2.fromOffset(6, 8), TextScaled = true, TextXAlignment = CENTER, Text = "🐛", Parent = baitCard })
local baitName = text({ Size = UDim2.new(1, -104, 0, 24), Position = UDim2.fromOffset(54, 6), Font = TITLE, TextScaled = true, Text = "", Parent = baitCard })
new("UITextSizeConstraint", { MaxTextSize = 17, Parent = baitName })
local baitCount = text({ Size = UDim2.new(1, -104, 0, 20), Position = UDim2.fromOffset(54, 32), Font = BODY2, TextSize = 14, TextColor3 = C.muted, Text = "", Parent = baitCard })
btn({ Size = UDim2.fromOffset(40, 40), AnchorPoint = Vector2.new(1, 0.5), Position = UDim2.new(1, -8, 0.5, 0), BackgroundColor3 = C.wood, Text = "⇄", TextSize = 20, Parent = baitCard }, function()
if K.openBait then
K.openBait()
end
end)
---------------------------------------------------------------- рюкзак (правый низ)
local pack = btn({
Name = "BackpackButton", Size = UDim2.fromOffset(170, 70), AnchorPoint = Vector2.new(1, 1), Position = UDim2.new(1, -12, 1, -12),
BackgroundColor3 = C.woodLight, Text = "", Parent = K.screen,
}, function()
if K.bagWin then
K.bagWin.toggle("fish")
end
end)
pack:FindFirstChildOfClass("UIStroke").Color = C.goldDark
pack:FindFirstChildOfClass("UIStroke").Thickness = 2.5
text({ Size = UDim2.fromOffset(52, 52), Position = UDim2.fromOffset(8, 9), TextScaled = true, TextXAlignment = CENTER, Text = "🎒", Parent = pack })
text({ Size = UDim2.new(1, -70, 0, 30), Position = UDim2.fromOffset(64, 8), Font = TITLE, TextSize = 22, Text = "Рюкзак", TextStrokeColor3 = C.ink, TextStrokeTransparency = 0.3, Parent = pack })
local packCount = text({ Size = UDim2.new(1, -70, 0, 22), Position = UDim2.fromOffset(64, 38), Font = BODY2, TextSize = 15, Text = "", Parent = pack })
---------------------------------------------------------------- таблица игроков (правый верх)
local ROW_H, MAX_ROWS = 26, 6
local board = woodPanel({
Name = "PlayersBoard", Size = UDim2.fromOffset(310, 34), AnchorPoint = Vector2.new(1, 0), Position = UDim2.new(1, -12, 0, 8),
BackgroundColor3 = WHITE, Parent = K.screen,
})
local function cols(parent, y, a, b, c, d, color, font)
local function cell(x, w, t, align)
text({ Size = UDim2.fromOffset(w, ROW_H), Position = UDim2.fromOffset(x, y), Font = font or BODY2, TextSize = 13, TextColor3 = color,
TextXAlignment = align or CENTER, TextTruncate = Enum.TextTruncate.AtEnd, Text = t, Parent = parent })
end
cell(12, 130, a, Enum.TextXAlignment.Left)
cell(142, 46, b)
cell(188, 62, c)
cell(250, 50, d)
end
local header = new("Frame", { Size = UDim2.new(1, 0, 0, 30), BackgroundTransparency = 1, Parent = board })
cols(header, 3, "👥 Игроки", "Уровень", "Серебро", "Улов", C.muted)
local rowsFrame = new("Frame", { Size = UDim2.new(1, 0, 1, -32), Position = UDim2.fromOffset(0, 30), BackgroundTransparency = 1, Parent = board })
local collapsed = false
local function stat(p, name)
local ls = p:FindFirstChild("leaderstats")
local v = ls and ls:FindFirstChild(name)
return v and v.Value or 0
end
local function placeBelowBoard()
-- плашку погоды (Ambience) и баннер события (FishingClient) ставим под таблицей
local y = 8 + board.Size.Y.Offset + 8
local weather = player.PlayerGui:FindFirstChild("WeatherHud")
local pill = weather and weather:FindFirstChild("Root") and weather.Root:FindFirstChildOfClass("Frame")
if pill then
pill.Position = UDim2.new(1, -12, 0, y)
y += pill.Size.Y.Offset + 8
end
local ev = K.screen:FindFirstChild("EventBanner")
if ev then
ev.Position = UDim2.new(1, -12, 0, y)
end
end
local function refreshBoard()
for _, c in ipairs(rowsFrame:GetChildren()) do
c:Destroy()
end
local list = Players:GetPlayers()
table.sort(list, function(a, b)
local la, lb = stat(a, "Уровень"), stat(b, "Уровень")
if la ~= lb then
return la > lb
end
return stat(a, "Серебро") > stat(b, "Серебро")
end)
local shown = collapsed and 0 or math.min(#list, MAX_ROWS)
for i = 1, shown do
local p = list[i]
local me = p == player
local r = new("Frame", { Size = UDim2.new(1, -12, 0, ROW_H - 2), Position = UDim2.fromOffset(6, (i - 1) * ROW_H), BackgroundColor3 = me and C.goldDark or C.woodDark,
BackgroundTransparency = me and 0.55 or 0.6, Parent = rowsFrame }, { corner(5) })
cols(r, -1, p.DisplayName, fmt(stat(p, "Уровень")), fmt(stat(p, "Серебро")), fmt(stat(p, "Улов")), me and C.goldBright or C.parchment, me and TITLE or BODY2)
end
board.Size = UDim2.fromOffset(310, 34 + shown * ROW_H + (shown > 0 and 6 or 0))
placeBelowBoard()
end
-- Tab — свернуть/развернуть, как стандартный список
UserInputService.InputBegan:Connect(function(input, processed)
if not processed and input.KeyCode == Enum.KeyCode.Tab then
collapsed = not collapsed
refreshBoard()
end
end)
---------------------------------------------------------------- обновление
refresh = function()
-- слоты удочек
local rods = ownedRods()
local pages = math.max(1, math.ceil(#rods / SLOTS))
page = math.clamp(page, 0, pages - 1)
local current = player:GetAttribute("Rod") or "Basic"
local hand = inHand()
for i, s in ipairs(slots) do
local rod = rods[page * SLOTS + i]
s.rod = rod
rodView(s.icon, rod and rod.id, rod and rodLevel(rod.id) or 0)
s.button.BackgroundColor3 = rod and C.woodLight or C.woodDark
s.button.AutoButtonColor = rod ~= nil
local on = rod and rod.id == current
s.stroke.Color = on and Color3.fromRGB(120, 230, 255) or C.goldDark
s.stroke.Thickness = on and 3 or 1.5
end
-- удочка в руке
local rod = Config.Find(Config.Rods, current) or Config.Rods[1]
local lvl = rodLevel(rod.id)
rodView(rodIcon, rod.id, lvl)
rodName.Text = rod.name .. (lvl > 0 and (" +" .. lvl) or "")
rodCheck.Visible = hand
rodCard:FindFirstChildOfClass("UIStroke").Color = hand and Color3.fromRGB(120, 230, 255) or C.gold
-- наживка
local id = player:GetAttribute("Bait")
local b = id and id ~= "" and Config.Find(Config.Baits, id)
baitIcon.Text = b and b.icon or "🐛"
baitName.Text = b and b.name or "Наживка"
baitCount.Text = b and ("×%d"):format(player:GetAttribute("BaitCount") or 0) or "не выбрана"
-- рюкзак
local count, cap = player:GetAttribute("BagCount") or 0, player:GetAttribute("BagCap") or 10
packCount.Text = ("📦 %d / %d"):format(count, cap)
packCount.TextColor3 = count >= cap and Color3.fromRGB(255, 130, 120) or C.parchment
end
-- клавиши 1–3: удочка из слота (взять в руки; повторно — убрать)
UserInputService.InputBegan:Connect(function(input, processed)
if processed then
return
end
local n = ({ [Enum.KeyCode.One] = 1, [Enum.KeyCode.Two] = 2, [Enum.KeyCode.Three] = 3 })[input.KeyCode]
local rod = n and slots[n].rod
if rod then
if rod.id ~= player:GetAttribute("Rod") then
remote:FireServer("Buy", "Rod", rod.id)
task.delay(0.4, equip, true)
else
equip(not inHand())
end
end
end)
Theme.onLayout(function(compact)
local function scale(obj, s)
local sc = obj:FindFirstChild("LayoutScale") or new("UIScale", { Name = "LayoutScale", Parent = obj })
sc.Scale = s
end
-- телефон: всё мельче; рюкзак левее кнопки прыжка, таблица игроков — компактнее
scale(bar, compact and 0.62 or 1)
bar.Position = compact and UDim2.new(0.5, 0, 1, -4) or UDim2.new(0.5, 0, 1, -10)
scale(pack, compact and 0.7 or 1)
pack.Position = compact and UDim2.new(1, -140, 1, -6) or UDim2.new(1, -12, 1, -12)
scale(board, compact and 0.75 or 1)
MAX_ROWS = compact and 4 or 6
refreshBoard()
end)
player.AttributeChanged:Connect(refresh)
local function watchChar(char)
char.ChildAdded:Connect(refresh)
char.ChildRemoved:Connect(refresh)
end
if player.Character then
watchChar(player.Character)
end
player.CharacterAdded:Connect(watchChar)
refresh()
-- таблица: игроки приходят и уходят, значения меняются
local function watchPlayer(p)
local ls = p:WaitForChild("leaderstats", 30)
if ls then
for _, v in ipairs(ls:GetChildren()) do
v.Changed:Connect(refreshBoard)
end
ls.ChildAdded:Connect(function(v)
v.Changed:Connect(refreshBoard)
end)
end
refreshBoard()
end
for _, p in ipairs(Players:GetPlayers()) do
task.spawn(watchPlayer, p)
end
Players.PlayerAdded:Connect(function(p)
task.spawn(watchPlayer, p)
end)
Players.PlayerRemoving:Connect(function()
task.defer(refreshBoard)
end)
refreshBoard()
-- плашка погоды создаётся другим скриптом — подождать её
task.delay(3, placeBelowBoard)