Files
roblox-project/bunsik-tycoon/src/client/Hud.luau
EJClaw 05848d19d6 feat(bunsik): 화면 UI 전면 개편 — 시뮬레이터 스타일(굵은 테두리·그러데이션·입체 버튼·직접 그린 아이콘·애니메이션)
- Theme 모듈: 색, 테두리, 입체 버튼(누르면 들어감, PC 마우스 올리면 커짐), 반짝임, 배지
- 아이콘 32개를 직접 그린 한 장(art/ui_icons.png, tools/icons.py)으로 올리고 Icons 모듈로 잘라 씀
- 돈 알약+동전, +돈 떠오름, 네모 아이콘 버튼, 다음 업그레이드 카드(이름표·아이콘·진행 막대),
  업그레이드/설정 창(리본 제목·빨간 X·뒤 어둡게·튀어나오며 열림·다음 줄로 자동 스크롤)
- 손님 말풍선·+돈 글자 테두리 색 통일
- 미리보기 도구: tests/cloud/dump_gui.luau + tools/gui_render.py + tools/preview.sh
- 통합 테스트 668/668, Layout 1522 검사 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 17:24:16 +09:00

950 lines
33 KiB
Lua

--!strict
-- 화면 UI: 돈, 다음 업그레이드 카드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음·개발자 테스트),
-- 안내 문구, 알림. 모양은 Theme(굵은 테두리, 그러데이션, 입체 버튼, 아이콘), 배치는 Layout 모듈이 정합니다.
-- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Shared = ReplicatedStorage:WaitForChild("Shared")
local Economy = require(Shared:WaitForChild("Economy"))
local Locale = require(Shared:WaitForChild("Locale"))
local Products = require(Shared:WaitForChild("Products"))
local Layout = require(script.Parent:WaitForChild("Layout"))
local Theme = require(script.Parent:WaitForChild("Theme"))
local Hud = {}
export type HudHandle = {
gui: ScreenGui,
refresh: () -> (),
notify: (key: string, args: { [string]: any }?) -> (),
-- UI가 쓸 수 있는 화면 크기(픽셀, 상단 바 제외)와 터치 화면 여부로 배치를 다시 잡습니다.
setLayout: (size: Vector2, touch: boolean) -> (),
layout: () -> Layout.Result,
open: (which: string?) -> (), -- "shop", "settings", nil(닫기)
menuOpen: () -> boolean, -- 업그레이드·설정 창이 열려 있으면 true(마우스 커서를 풀어 줌)
destroy: () -> (),
}
local INK = Theme.INK
-- 업그레이드 id → 아이콘
local function itemIcon(id: string): string
local menu = id:match("^Unlock(%a+)$")
if menu then
return menu
end
for prefix, icon in
{ Table = "table", Sign = "sign", Stove = "flame", Sauce = "sauce", Tray = "tray" } :: { [string]: string }
do
if id:sub(1, #prefix) == prefix then
return icon
end
end
if id == "Helper" then
return "chef"
elseif id == "Expand" then
return "store"
end
return "star"
end
-- 알림 종류별 아이콘과 색
local TOAST_STYLE: { [string]: { icon: string, color: Color3 } } = {
purchased = { icon = "check", color = Color3.fromRGB(70, 190, 70) },
newMenu = { icon = "star", color = Color3.fromRGB(255, 140, 40) },
expanded = { icon = "store", color = Color3.fromRGB(240, 170, 20) },
boostGot = { icon = "bolt", color = Color3.fromRGB(240, 170, 20) },
guestBonus = { icon = "coin", color = Color3.fromRGB(70, 190, 70) },
guestArrived = { icon = "chef", color = Color3.fromRGB(60, 150, 240) },
devResetDone = { icon = "wrench", color = Color3.fromRGB(110, 110, 130) },
}
local function attr(state: Instance, key: string, default: any): any
local v = state:GetAttribute(key)
if v == nil then
return default
end
return v
end
local function at(o: GuiObject, x: number, y: number, w: number, h: number)
o.Position = UDim2.fromOffset(x, y)
o.Size = UDim2.fromOffset(w, h)
end
-- 네모 아이콘 버튼: 큰 아이콘 위, 이름은 아래 테두리에 걸쳐 놓입니다.
local function squareButton(parent: Instance, name: string, color: Color3, icon: string): (Theme.Button, TextLabel)
local b = Theme.button(parent, name, color, 18)
local ic = Theme.icon(b.face, "Icon", icon)
ic.AnchorPoint = Vector2.new(0.5, 0)
ic.Position = UDim2.fromScale(0.5, 0.03)
ic.Size = UDim2.fromScale(0.74, 0.7)
ic.ZIndex = 4
local label = Theme.text(b.button, "Label", false, 2.5)
label.AnchorPoint = Vector2.new(0.5, 1)
label.Position = UDim2.new(0.5, 0, 1, -2)
label.Size = UDim2.fromScale(1.08, 0.32)
label.ZIndex = 5
return b, label
end
-- 창 틀: 뒤에 비스듬한 판, 크림색 본문, 왼쪽 위 이름표 리본, 오른쪽 위 빨간 X 버튼.
local function panelShell(parent: Instance, name: string, color: Color3): (Frame, Frame, TextLabel, Theme.Button)
local p = Theme.frame(parent, name)
p.Visible = false
p.ZIndex = 20
local scale = Instance.new("UIScale")
scale.Parent = p
local back = Theme.frame(p, "Back", Theme.darken(color, 0.1))
back.Position = UDim2.fromOffset(10, 30)
back.Size = UDim2.new(1, -20, 1, -36)
back.Rotation = 2.5
Theme.corner(back, 24)
Theme.stroke(back, INK, 4)
local body = Theme.frame(p, "Body", Theme.WHITE)
body.Position = UDim2.fromOffset(0, 24)
body.Size = UDim2.new(1, 0, 1, -24)
body.ZIndex = 2
Theme.corner(body, 24)
Theme.stroke(body, INK, 4)
Theme.gradient(body, Color3.fromRGB(255, 252, 244), Color3.fromRGB(255, 236, 205))
-- 본문 위쪽 색 띠
local band = Theme.frame(body, "Band", color)
band.Size = UDim2.new(1, 0, 0, 44)
band.ZIndex = 2
Theme.corner(band, 24)
Theme.gradient(band, Theme.lighten(color, 0.15), color)
local bandFill = Theme.frame(band, "Fill", color)
bandFill.Position = UDim2.fromOffset(0, 24)
bandFill.Size = UDim2.new(1, 0, 0, 20)
bandFill.BorderSizePixel = 0
bandFill.ZIndex = 2
bandFill.BackgroundColor3 = color
local ribbon = Theme.frame(p, "Ribbon", Theme.WHITE)
ribbon.Position = UDim2.fromOffset(18, 2)
ribbon.Size = UDim2.fromOffset(250, 50)
ribbon.Rotation = -2
ribbon.ZIndex = 4
Theme.corner(ribbon, 14)
Theme.stroke(ribbon, INK, 4)
Theme.gradient(ribbon, Theme.lighten(color, 0.25), Theme.darken(color, 0.1))
local title = Theme.text(ribbon, "Title", false, 3)
title.Position = UDim2.fromOffset(14, 6)
title.Size = UDim2.new(1, -28, 1, -12)
title.ZIndex = 5
local close = Theme.button(p, "Close", Theme.RED, 14, 3.5)
close.button.AnchorPoint = Vector2.new(0.5, 0.5)
close.button.Rotation = 6
close.button.ZIndex = 6
local x = Theme.icon(close.face, "X", "close")
x.Size = UDim2.fromScale(0.62, 0.62)
x.AnchorPoint = Vector2.new(0.5, 0.5)
x.Position = UDim2.fromScale(0.5, 0.5)
x.ZIndex = 4
return p, body, title, close
end
local function popIn(o: GuiObject)
local s = o:FindFirstChildOfClass("UIScale")
if s then
s.Scale = 0.6
TweenService:Create(s, TweenInfo.new(0.32, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 })
:Play()
end
end
-- 켜기/끄기 버튼(설정 창)
local function toggleButton(parent: Instance, name: string): (Theme.Button, TextLabel)
local b = Theme.button(parent, name, Theme.GREEN, 14)
local label = Theme.text(b.face, "Label", false, 2.5)
label.Size = UDim2.new(1, -16, 0.7, 0)
label.Position = UDim2.fromScale(0.5, 0.5)
label.AnchorPoint = Vector2.new(0.5, 0.5)
label.ZIndex = 4
return b, label
end
local function textButton(parent: Instance, name: string, color: Color3, radius: number): (Theme.Button, TextLabel)
local b = Theme.button(parent, name, color, radius)
local label = Theme.text(b.face, "Label", false, 2.5)
label.Size = UDim2.new(1, -14, 0.66, 0)
label.Position = UDim2.fromScale(0.5, 0.5)
label.AnchorPoint = Vector2.new(0.5, 0.5)
label.ZIndex = 4
return b, label
end
local function settingRow(parent: Instance, name: string, icon: string): (Frame, TextLabel)
local row = Theme.frame(parent, name)
row.ZIndex = 3
local ic = Theme.icon(row, "Icon", icon)
ic.Size = UDim2.fromOffset(36, 36)
ic.Position = UDim2.fromScale(0, 0.5)
ic.AnchorPoint = Vector2.new(0, 0.5)
ic.ZIndex = 4
local t = Theme.text(row, "Text", true)
t.Position = UDim2.new(0, 44, 0.5, 0)
t.AnchorPoint = Vector2.new(0, 0.5)
t.Size = UDim2.new(1, -44, 0, 30)
t.TextXAlignment = Enum.TextXAlignment.Left
t.ZIndex = 4
return row, t
end
function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> ()): HudHandle
local gui = Instance.new("ScreenGui")
gui.Name = "BunsikHud"
gui.ResetOnSpawn = false
gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
gui.Parent = parent
local tweens: { Tween } = {}
local function loop(t: Tween)
t:Play()
table.insert(tweens, t)
end
-- 루트는 기준 단위(화면 픽셀 / 배율) 크기로 만들고 UIScale로 키워 화면을 꽉 채웁니다.
local root = Theme.frame(gui, "Root")
root.Size = UDim2.fromOffset(1100, 620)
local scale = Instance.new("UIScale")
scale.Parent = root
-- 돈: 금색 알약 + 왼쪽에 튀어나온 동전
local money = Theme.frame(root, "Money")
local moneyScale = Instance.new("UIScale")
moneyScale.Parent = money
local pill = Theme.frame(money, "Pill", Theme.WHITE)
pill.AnchorPoint = Vector2.new(0, 0.5)
pill.Position = UDim2.new(0, 30, 0.5, 0)
pill.Size = UDim2.new(1, -30, 0, 50)
Theme.corner(pill, 1, 1)
Theme.stroke(pill, INK, 4)
Theme.gradient(pill, Color3.fromRGB(255, 226, 90), Color3.fromRGB(255, 160, 30))
local pillGloss = Theme.frame(pill, "Gloss", Theme.WHITE)
pillGloss.BackgroundTransparency = 0.65
pillGloss.Position = UDim2.fromOffset(36, 5)
pillGloss.Size = UDim2.new(1, -60, 0, 12)
Theme.corner(pillGloss, 1, 1)
local moneyText = Theme.text(pill, "Text", false, 3)
moneyText.Position = UDim2.fromOffset(40, 6)
moneyText.Size = UDim2.new(1, -56, 1, -12)
moneyText.ZIndex = 2
local coin = Theme.icon(money, "Coin", "coin")
coin.Size = UDim2.fromOffset(66, 66)
coin.Position = UDim2.new(0, -2, 0.5, 0)
coin.AnchorPoint = Vector2.new(0, 0.5)
coin.Rotation = -10
coin.ZIndex = 3
loop(
TweenService:Create(
coin,
TweenInfo.new(1.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{ Rotation = 8 }
)
)
-- 들고 있는 접시
local carry = Theme.frame(root, "Carry", Theme.NAVY)
carry.BackgroundTransparency = 0.25
Theme.corner(carry, 1, 1)
Theme.stroke(carry, INK, 2.5)
local plateIcon = Theme.icon(carry, "Icon", "plate")
plateIcon.Size = UDim2.fromOffset(34, 34)
plateIcon.Position = UDim2.new(0, -4, 0.5, 0)
plateIcon.AnchorPoint = Vector2.new(0, 0.5)
local carryText = Theme.text(carry, "Text", false, 2)
carryText.Position = UDim2.fromOffset(32, 3)
carryText.Size = UDim2.new(1, -40, 1, -6)
-- 안내 문구(튜토리얼)
local hint = Theme.frame(root, "Hint", Theme.WHITE)
Theme.corner(hint, 16)
Theme.stroke(hint, INK, 4)
Theme.gradient(hint, Color3.fromRGB(255, 244, 150), Color3.fromRGB(255, 205, 60))
local hintIcon = Theme.icon(hint, "Icon", "arrowDown")
hintIcon.Size = UDim2.fromOffset(46, 46)
hintIcon.AnchorPoint = Vector2.new(0, 0.5)
hintIcon.Position = UDim2.new(0, 8, 0.5, 0)
loop(
TweenService:Create(
hintIcon,
TweenInfo.new(0.45, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{ Position = UDim2.new(0, 8, 0.5, 6) }
)
)
local hintText = Theme.text(hint, "Text", true)
hintText.Position = UDim2.fromOffset(60, 7)
hintText.Size = UDim2.new(1, -72, 1, -14)
-- 알림
local toasts = Theme.frame(root, "Toasts")
local list = Instance.new("UIListLayout")
list.HorizontalAlignment = Enum.HorizontalAlignment.Center
list.Padding = UDim.new(0, 8)
list.SortOrder = Enum.SortOrder.LayoutOrder
list.Parent = toasts
-- 다음 업그레이드 카드(아래): 이름표, 아이콘 상자, 이름, 진행 막대, [사기]
local card = Theme.frame(root, "Next")
local cardBody = Theme.frame(card, "Body", Theme.WHITE)
cardBody.Position = UDim2.fromOffset(0, 16)
cardBody.Size = UDim2.new(1, 0, 1, -16)
Theme.corner(cardBody, 20)
Theme.stroke(cardBody, INK, 4)
Theme.gradient(cardBody, Color3.fromRGB(255, 252, 244), Color3.fromRGB(255, 232, 196))
local tab = Theme.frame(card, "Tab", Theme.WHITE)
tab.Position = UDim2.fromOffset(16, 0)
tab.Size = UDim2.fromOffset(190, 30)
tab.ZIndex = 3
Theme.corner(tab, 10)
Theme.stroke(tab, INK, 3)
Theme.gradient(tab, Color3.fromRGB(255, 130, 90), Color3.fromRGB(230, 60, 40))
local tabText = Theme.text(tab, "Text", false, 2)
tabText.Position = UDim2.fromOffset(10, 4)
tabText.Size = UDim2.new(1, -20, 1, -8)
tabText.ZIndex = 4
local iconBox = Theme.frame(cardBody, "IconBox", Theme.WHITE)
iconBox.AnchorPoint = Vector2.new(0, 0.5)
iconBox.Position = UDim2.new(0, 12, 0.5, 4)
iconBox.Size = UDim2.fromOffset(68, 68)
Theme.corner(iconBox, 16)
Theme.stroke(iconBox, INK, 3)
Theme.gradient(iconBox, Color3.fromRGB(255, 255, 255), Color3.fromRGB(255, 214, 160))
local itemImg = Theme.icon(iconBox, "Icon", "table")
itemImg.Size = UDim2.fromScale(0.86, 0.86)
itemImg.AnchorPoint = Vector2.new(0.5, 0.5)
itemImg.Position = UDim2.fromScale(0.5, 0.5)
local cardTitle = Theme.text(cardBody, "Title", true)
cardTitle.TextXAlignment = Enum.TextXAlignment.Left
cardTitle.Position = UDim2.fromOffset(92, 14)
cardTitle.Size = UDim2.new(1, -258, 0, 34)
local bar = Theme.frame(cardBody, "Bar", Color3.fromRGB(110, 70, 45))
bar.Position = UDim2.fromOffset(92, 54)
bar.Size = UDim2.new(1, -258, 0, 28)
Theme.corner(bar, 1, 1)
Theme.stroke(bar, INK, 3)
local barFill = Theme.frame(bar, "Fill", Theme.WHITE)
barFill.Size = UDim2.fromScale(0, 1)
Theme.corner(barFill, 1, 1)
Theme.gradient(barFill, Color3.fromRGB(160, 245, 90), Color3.fromRGB(60, 185, 40))
local cardCost = Theme.text(bar, "Cost", false, 2.2)
cardCost.Position = UDim2.fromOffset(8, 3)
cardCost.Size = UDim2.new(1, -16, 1, -6)
cardCost.ZIndex = 3
local buy, buyLabel = textButton(card, "Buy", Theme.GREEN, 18)
buy.button.AnchorPoint = Vector2.new(0.5, 0.5)
buy.button.ZIndex = 3
local buyShine = Theme.shine(buy.face, 18, 1.8)
table.insert(tweens, buyShine)
local buyGlow = Theme.icon(buy.button, "Glow", "glow")
buyGlow.Size = UDim2.fromScale(1.7, 2.2)
buyGlow.AnchorPoint = Vector2.new(0.5, 0.5)
buyGlow.Position = UDim2.fromScale(0.5, 0.5)
buyGlow.ImageColor3 = Color3.fromRGB(255, 240, 120)
buyGlow.ZIndex = 0
loop(
TweenService:Create(
buyGlow,
TweenInfo.new(0.6, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{ ImageTransparency = 0.6 }
)
)
local pointer = Theme.icon(card, "Pointer", "hand")
pointer.Size = UDim2.fromOffset(54, 54)
pointer.AnchorPoint = Vector2.new(0.5, 1)
pointer.Rotation = 180
pointer.ZIndex = 8
pointer.Visible = false
-- 네모 아이콘 버튼들
local listBtn, listLabel = squareButton(root, "ListButton", Theme.ORANGE, "scroll")
local listBadge, listBadgeText = Theme.badge(listBtn.button, "Badge")
listBadgeText.Text = "!"
loop(
TweenService:Create(
listBadge,
TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true),
{ Rotation = 12 }
)
)
local settingsBtn, settingsLabel = squareButton(root, "Settings", Theme.BLUE, "gear")
local function premium(name: string, color: Color3, icon: string): (Theme.Button, TextLabel, ImageLabel)
local b, label = squareButton(root, name, color, icon)
local rays = Theme.icon(b.button, "Rays", "rays")
rays.Size = UDim2.fromScale(1.45, 1.45)
rays.AnchorPoint = Vector2.new(0.5, 0.5)
rays.Position = UDim2.fromScale(0.5, 0.5)
rays.ImageColor3 = Color3.fromRGB(255, 236, 140)
rays.ImageTransparency = 0.15
rays.ZIndex = 0
loop(
TweenService:Create(
rays,
TweenInfo.new(9, Enum.EasingStyle.Linear, Enum.EasingDirection.In, -1),
{ Rotation = 360 }
)
)
table.insert(tweens, Theme.shine(b.face, 18, 2.6))
return b, label, rays
end
local passBtn, passLabel, passRays = premium("Double", Theme.PURPLE, "moneyBag")
local x2 = Theme.text(passBtn.face, "X2", false, 3)
x2.Text = "x2"
x2.TextColor3 = Color3.fromRGB(255, 230, 60)
x2.AnchorPoint = Vector2.new(1, 0)
x2.Position = UDim2.new(1, -2, 0, 2)
x2.Size = UDim2.fromScale(0.5, 0.36)
x2.Rotation = 12
x2.ZIndex = 6
local passCheck = Theme.icon(passBtn.button, "Owned", "check")
passCheck.Size = UDim2.fromScale(0.42, 0.42)
passCheck.AnchorPoint = Vector2.new(0.5, 0.5)
passCheck.Position = UDim2.new(1, -8, 0, 8)
passCheck.ZIndex = 8
local boostBtn, boostLabel = premium("Boost", Theme.YELLOW, "bolt")
local boostTag = Theme.frame(boostBtn.button, "Tag", Theme.WHITE)
boostTag.AnchorPoint = Vector2.new(0.5, 0.5)
boostTag.Position = UDim2.new(0.5, 0, 0, 13)
boostTag.Size = UDim2.new(0.8, 0, 0, 24)
boostTag.Rotation = -6
boostTag.ZIndex = 8
Theme.corner(boostTag, 1, 1)
Theme.stroke(boostTag, INK, 2.5)
Theme.gradient(boostTag, Color3.fromRGB(150, 245, 90), Color3.fromRGB(60, 185, 40))
local boostAmount = Theme.text(boostTag, "Text", false, 2)
boostAmount.Position = UDim2.fromOffset(6, 2)
boostAmount.Size = UDim2.new(1, -12, 1, -4)
boostAmount.ZIndex = 9
-- 창 뒤 어둡게
local dim = Theme.frame(root, "Dim", Color3.new(0, 0, 0))
dim.BackgroundTransparency = 0.55
dim.Size = UDim2.fromScale(1, 1)
dim.Visible = false
dim.ZIndex = 10
-- 업그레이드 목록 창
local panel, panelBody, panelTitle, closeBtn = panelShell(root, "Panel", Color3.fromRGB(255, 120, 50))
local stageText = Theme.text(panelBody, "Stage", false, 2.5)
stageText.Position = UDim2.fromOffset(280, 8)
stageText.Size = UDim2.new(1, -350, 0, 30)
stageText.TextXAlignment = Enum.TextXAlignment.Right
stageText.ZIndex = 4
local scroll = Instance.new("ScrollingFrame")
scroll.Name = "List"
scroll.Position = UDim2.fromOffset(14, 56)
scroll.Size = UDim2.new(1, -24, 1, -68)
scroll.BackgroundTransparency = 1
scroll.BorderSizePixel = 0
scroll.ScrollBarThickness = 8
scroll.ScrollBarImageColor3 = INK
scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y
scroll.CanvasSize = UDim2.new()
scroll.ZIndex = 3
scroll.Parent = panelBody
local rows = Instance.new("UIListLayout")
rows.Padding = UDim.new(0, 8)
rows.SortOrder = Enum.SortOrder.LayoutOrder
rows.HorizontalAlignment = Enum.HorizontalAlignment.Center
rows.Parent = scroll
local rowPad = Instance.new("UIPadding")
rowPad.PaddingTop = UDim.new(0, 6)
rowPad.PaddingBottom = UDim.new(0, 8)
rowPad.Parent = scroll
-- 설정 창(언어, 마우스로 화면 돌리기, 효과음, 개발자 테스트)
local settings, _settingsBody, settingsTitle, settingsClose =
panelShell(root, "SettingsPanel", Color3.fromRGB(60, 160, 245))
local langRow, langLabel = settingRow(settings, "LangRow", "globe")
langRow.ZIndex = 3
at(langRow, 18, 68, 300, 32)
-- 언어 버튼: 자동("") + 네 언어
local langChoices = { "" }
for _, l in Locale.LANGS do
table.insert(langChoices, l)
end
local langButtons: { [string]: Theme.Button } = {}
local langLabels: { [string]: TextLabel } = {}
for _, l in langChoices do
local b, t = textButton(settings, "Lang_" .. (if l == "" then "auto" else l), Theme.GRAY, 14)
b.button.ZIndex = 3
langButtons[l] = b
langLabels[l] = t
end
local mouseRow, mouseLabel = settingRow(settings, "MouseRow", "mouse")
local mouseBtn, mouseValue = toggleButton(settings, "MouseLook")
mouseBtn.button.ZIndex = 3
local mouseHint = Theme.text(settings, "MouseHint", true)
mouseHint.TextColor3 = Theme.BROWN
mouseHint.TextXAlignment = Enum.TextXAlignment.Left
mouseHint.ZIndex = 3
local sfxRow, sfxLabel = settingRow(settings, "SfxRow", "speaker")
local sfxBtn, sfxValue = toggleButton(settings, "Sfx")
sfxBtn.button.ZIndex = 3
-- 개발자(게임 주인)만 보는 테스트 버튼 줄
local devRow, devTitle = settingRow(settings, "DevLabel", "wrench")
local devButtons: { [string]: Theme.Button } = {}
local devLabels: { [string]: TextLabel } = {}
for _, key in { "devMoney", "devDouble", "devReset" } do
local b, t = textButton(settings, key, Color3.fromRGB(110, 115, 140), 12)
b.button.ZIndex = 3
devButtons[key] = b
devLabels[key] = t
end
for _, o in { mouseRow, sfxRow, devRow } :: { GuiObject } do
o.ZIndex = 3
end
-- 화면 크기에 맞춰 배치합니다(Layout 모듈). 버튼은 가운데 기준이라 누르면 제자리에서 작아집니다.
local function place(o: GuiObject, r: Layout.Rect)
o.AnchorPoint = Vector2.new(0.5, 0.5)
o.Position = UDim2.fromOffset(r.x + r.w / 2, r.y + r.h / 2)
o.Size = UDim2.fromOffset(r.w, r.h)
end
local screen = Vector2.new(1100, 620)
local touch = false
local layoutNow: Layout.Result
local function relayout()
local dev = attr(state, "Dev", false) == true
local lay = Layout.compute(screen.X, screen.Y, touch, dev)
layoutNow = lay
scale.Scale = lay.scale
-- Offset은 정수라서 올림해 화면을 다 덮습니다(1 기준 단위 미만 차이).
root.Size = UDim2.fromOffset(math.ceil(lay.width), math.ceil(lay.height))
place(money, lay.money)
place(carry, lay.carry)
place(hint, lay.hint)
place(toasts, lay.toasts)
place(card, lay.card)
place(listBtn.button, lay.list)
place(settingsBtn.button, lay.settings)
place(passBtn.button, lay.double)
place(boostBtn.button, lay.boost)
place(panel, lay.panel)
place(settings, lay.settingsPanel)
-- [사기] 버튼은 카드 안 좌표로
local b = lay.buy
buy.button.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y + b.h / 2)
buy.button.Size = UDim2.fromOffset(b.w, b.h)
pointer.Position = UDim2.fromOffset(b.x - lay.card.x + b.w / 2, b.y - lay.card.y - 2)
local r = lay.rows
local closeK = r.closeH + 4
at(closeBtn.button, 0, 0, closeK, closeK)
closeBtn.button.Position = UDim2.new(1, -closeK / 2 - 4, 0, closeK / 2 + 2)
at(settingsClose.button, 0, 0, closeK, closeK)
settingsClose.button.Position = UDim2.new(1, -closeK / 2 - 4, 0, closeK / 2 + 2)
local i = 0
for _, l in langChoices do
at(langButtons[l].button, 18 + i * 102, 104, 94, r.langButtonH)
i += 1
end
local mouseY = r.mouseY
mouseRow.Visible = mouseY ~= nil
mouseBtn.button.Visible = mouseY ~= nil
mouseHint.Visible = mouseY ~= nil
if mouseY then
at(mouseRow, 18, mouseY, 360, r.toggleH)
at(mouseBtn.button, 0, 0, 116, r.toggleH)
mouseBtn.button.Position = UDim2.new(1, -134, 0, mouseY)
at(mouseHint, 62, mouseY + r.toggleH + 6, 440, 24)
end
at(sfxRow, 18, r.sfxY, 360, r.toggleH)
at(sfxBtn.button, 0, 0, 116, r.toggleH)
sfxBtn.button.Position = UDim2.new(1, -134, 0, r.sfxY)
local devY = r.devY
devRow.Visible = devY ~= nil
if devY then
at(devRow, 18, devY, 360, 34)
end
local j = 0
for _, key in { "devMoney", "devDouble", "devReset" } do
local db = devButtons[key].button
db.Visible = devY ~= nil
if devY then
at(db, 18 + j * 170, devY + 38, 160, r.devButtonH)
end
j += 1
end
end
relayout()
local function lang(): string
return attr(state, "Lang", "ko")
end
local function L(key: string, args: { [string]: any }?): string
return Locale.t(lang(), key, args)
end
local function pname(p: Economy.Purchase): string
return Locale.itemName(lang(), p.id)
end
local function toggle(b: Theme.Button, label: TextLabel, on: boolean)
label.Text = L(if on then "on" else "off")
b.setColor(if on then Theme.GREEN else Theme.GRAY)
end
local listKey = ""
local lastMoney: number? = nil
-- 돈이 늘면 "+N원"이 떠오르고 돈 알약이 통 튑니다.
local function moneyPop(gain: number)
moneyScale.Scale = 1.12
TweenService:Create(moneyScale, TweenInfo.new(0.35, Enum.EasingStyle.Back), { Scale = 1 }):Play()
local f = Theme.text(root, "Gain", false, 2.5)
f.Text = "+" .. L("money", { money = Locale.number(gain) })
f.TextColor3 = Color3.fromRGB(150, 255, 110)
local m = layoutNow.money
f.AnchorPoint = Vector2.new(0.5, 0)
f.Size = UDim2.fromOffset(200, 34)
f.Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 2)
f.ZIndex = 9
TweenService:Create(f, TweenInfo.new(0.9, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
Position = UDim2.fromOffset(m.x + m.w / 2 + 20, m.y + m.h + 34),
TextTransparency = 1,
}):Play()
local st = f:FindFirstChildOfClass("UIStroke")
if st then
TweenService:Create(st, TweenInfo.new(0.9), { Transparency = 1 }):Play()
end
task.delay(1, function()
f:Destroy()
end)
end
local function refresh()
local m = attr(state, "Money", 0)
local bought = attr(state, "Bought", 0)
local stats = Economy.statsAt(bought)
moneyText.Text = L("money", { money = Locale.number(m) })
if lastMoney and m > lastMoney then
moneyPop(m - lastMoney)
end
lastMoney = m
local held = attr(state, "Carry", 0)
carry.Visible = held > 0
carryText.Text = `{held}/{stats.carry}`
local nextP = Economy.PURCHASES[bought + 1]
local can = false
tabText.Text = L("nextUp")
if nextP then
cardTitle.Text = pname(nextP)
cardCost.Text = `{Locale.number(math.min(m, nextP.cost))} / `
.. L("money", { money = Locale.number(nextP.cost) })
barFill.Size = UDim2.fromScale(math.clamp(m / nextP.cost, 0, 1), 1)
barFill.Visible = m > 0
Theme.setIcon(itemImg, itemIcon(nextP.id))
can = m >= nextP.cost
buyLabel.Text = L("buy")
buy.setColor(if can then Theme.GREEN else Theme.GRAY)
buy.button.Visible = true
else
cardTitle.Text = L("maxed")
cardCost.Text = ""
barFill.Size = UDim2.fromScale(1, 1)
barFill.Visible = true
Theme.setIcon(itemImg, "star")
buy.button.Visible = false
end
local shine = buy.face:FindFirstChild("Shine") :: Frame
shine.Visible = can
buyGlow.Visible = can
listBadge.Visible = can
-- 튜토리얼 안내
local tut = attr(state, "Tut", 0)
if tut == 1 or tut == 2 or tut == 3 then
hint.Visible = true
hintText.Text = L("tut" .. tut)
else
hint.Visible = false
end
pointer.Visible = tut == 3 and nextP ~= nil
if (layoutNow.rows.devY ~= nil) ~= (attr(state, "Dev", false) == true) then
relayout()
end
devTitle.Text = L("devTitle")
for key, t in devLabels do
t.Text = L(key)
end
listLabel.Text = L("shop")
settingsLabel.Text = L("settings")
panelTitle.Text = L("shop")
settingsTitle.Text = L("settings")
langLabel.Text = L("language")
local current = attr(state, "LangSetting", "")
for l, b in langButtons do
langLabels[l].Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l]
b.setColor(if l == current then Theme.BLUE else Theme.GRAY)
end
mouseLabel.Text = L("mouseLook")
mouseHint.Text = L("mouseHint")
toggle(mouseBtn, mouseValue, attr(state, "MouseLook", true) == true)
sfxLabel.Text = L("sfx")
toggle(sfxBtn, sfxValue, attr(state, "Sfx", true) == true)
local double = attr(state, "Double", false)
passBtn.button.Visible = Products.DOUBLE_MONEY_PASS ~= 0
passLabel.Text = if double then L("doubleOn") else L("double")
passCheck.Visible = double
x2.Visible = not double
passRays.Visible = not double
passBtn.button.Active = not double
boostBtn.button.Visible = Products.MONEY_BOOST_PRODUCT ~= 0 and nextP ~= nil
boostLabel.Text = L("boost")
boostAmount.Text = "+" .. Locale.number(attr(state, "Boost", Economy.BOOST_MIN))
-- 업그레이드 목록(지금 단계 것만). 산 개수, 언어, 살 수 있는지가 바뀔 때만 다시 그립니다.
local key = `{bought}:{lang()}:{can}`
if key == listKey then
return
end
listKey = key
local stage = stats.stage
stageText.Text = L(if stage >= 2 then "stage2" else "stage1")
for _, c in scroll:GetChildren() do
if c:IsA("Frame") then
c:Destroy()
end
end
local from = if stage >= 2 then 11 else 1
local to = if stage >= 2 then #Economy.PURCHASES else 10
local rowH = if layoutNow.touch then 64 else 58
for i = from, to do
local p = Economy.PURCHASES[i]
local done = i <= bought
local isNext = i == bought + 1
local row = Theme.frame(scroll, "Row" .. i, Theme.WHITE)
row.Size = UDim2.new(1, -16, 0, rowH)
row.LayoutOrder = i
row.ZIndex = 3
Theme.corner(row, 14)
Theme.stroke(row, INK, if isNext then 3.5 else 2.5)
if done then
Theme.gradient(row, Color3.fromRGB(232, 255, 220), Color3.fromRGB(190, 240, 170))
elseif isNext then
Theme.gradient(row, Color3.fromRGB(255, 248, 190), Color3.fromRGB(255, 210, 100))
else
Theme.gradient(row, Color3.fromRGB(245, 240, 232), Color3.fromRGB(222, 214, 202))
end
local box = Theme.frame(row, "IconBox", Theme.WHITE)
box.AnchorPoint = Vector2.new(0, 0.5)
box.Position = UDim2.new(0, 8, 0.5, 0)
box.Size = UDim2.fromOffset(rowH - 14, rowH - 14)
box.ZIndex = 3
Theme.corner(box, 10)
Theme.stroke(box, INK, 2)
local img = Theme.icon(box, "Icon", itemIcon(p.id))
img.Size = UDim2.fromScale(0.9, 0.9)
img.AnchorPoint = Vector2.new(0.5, 0.5)
img.Position = UDim2.fromScale(0.5, 0.5)
img.ZIndex = 4
if not done and not isNext then
img.ImageTransparency = 0.45
local lockImg = Theme.icon(box, "Lock", "lock")
lockImg.Size = UDim2.fromScale(0.5, 0.5)
lockImg.Position = UDim2.fromScale(0.55, 0.55)
lockImg.ZIndex = 5
end
local name = Theme.text(row, "Name", true)
name.TextXAlignment = Enum.TextXAlignment.Left
name.Position = UDim2.new(0, rowH + 4, 0.18, 0)
name.Size = UDim2.new(1, -(rowH + 4) - 150, 0.64, 0)
name.ZIndex = 4
name.Text = `{i}. {pname(p)}`
if done then
local ok = Theme.icon(row, "Done", "check")
ok.Size = UDim2.fromOffset(34, 34)
ok.AnchorPoint = Vector2.new(1, 0.5)
ok.Position = UDim2.new(1, -96, 0.5, 0)
ok.ZIndex = 4
local t = Theme.text(row, "Cost", false, 2)
t.TextColor3 = Color3.fromRGB(120, 230, 90)
t.AnchorPoint = Vector2.new(1, 0.5)
t.Position = UDim2.new(1, -12, 0.5, 0)
t.Size = UDim2.new(0, 80, 0.5, 0)
t.ZIndex = 4
t.Text = L("bought")
elseif isNext then
local rb, rl = textButton(row, "BuyRow", if can then Theme.GREEN else Theme.GRAY, 12)
rb.button.AnchorPoint = Vector2.new(1, 0.5)
rb.button.Position = UDim2.new(1, -8, 0.5, 2)
rb.button.Size = UDim2.new(0, 134, 1, -12)
rb.button.ZIndex = 4
rl.Text = L("money", { money = Locale.number(p.cost) })
rb.button.Activated:Connect(function()
send("buy")
end)
else
local t = Theme.text(row, "Cost", true)
t.TextColor3 = Color3.fromRGB(130, 110, 95)
t.TextXAlignment = Enum.TextXAlignment.Right
t.AnchorPoint = Vector2.new(1, 0.5)
t.Position = UDim2.new(1, -16, 0.5, 0)
t.Size = UDim2.new(0, 120, 0.46, 0)
t.ZIndex = 4
t.Text = L("money", { money = Locale.number(p.cost) })
end
end
end
local toastN = 0
local function notify(key: string, args: { [string]: any }?)
-- 서버는 메뉴·업그레이드를 키(menu, item)로 보내고, 이름은 내 언어로 바꿔 씁니다.
if args then
args = table.clone(args)
if typeof(args.menu) == "string" then
args.menuName = Locale.menuName(lang(), args.menu)
end
if typeof(args.item) == "string" then
args.name = Locale.itemName(lang(), args.item)
end
end
local style = TOAST_STYLE[key] or { icon = "sparkle", color = Color3.fromRGB(70, 80, 120) }
toastN += 1
local toast = Theme.frame(toasts, "Toast", Theme.WHITE)
toast.Size = UDim2.new(1, -20, 0, 50)
toast.LayoutOrder = -toastN -- 새 알림이 위에
Theme.corner(toast, 16)
local st = Theme.stroke(toast, INK, 3.5)
Theme.gradient(toast, Theme.lighten(style.color, 0.18), Theme.darken(style.color, 0.12))
local sc = Instance.new("UIScale")
sc.Parent = toast
local ic = Theme.icon(toast, "Icon", style.icon)
ic.Size = UDim2.fromOffset(46, 46)
ic.AnchorPoint = Vector2.new(0, 0.5)
ic.Position = UDim2.new(0, 4, 0.5, 0)
ic.ZIndex = 2
local t = Theme.text(toast, "Text", false, 2.5)
t.Position = UDim2.fromOffset(54, 7)
t.Size = UDim2.new(1, -66, 1, -14)
t.ZIndex = 2
t.Text = L(key, args)
popIn(toast)
task.delay(2.8, function()
local info = TweenInfo.new(0.4)
TweenService:Create(toast, info, { BackgroundTransparency = 1 }):Play()
TweenService:Create(t, info, { TextTransparency = 1 }):Play()
TweenService:Create(ic, info, { ImageTransparency = 1 }):Play()
TweenService:Create(st, info, { Transparency = 1 }):Play()
local ts = t:FindFirstChildOfClass("UIStroke")
if ts then
TweenService:Create(ts, info, { Transparency = 1 }):Play()
end
task.wait(0.45)
toast:Destroy()
end)
end
-- 목록을 열면 다음에 살 업그레이드가 보이게(바로 위에 산 것 한 줄) 내려 둡니다.
local function scrollToNext()
local bought = attr(state, "Bought", 0)
local from = if bought >= 10 then 11 else 1
local rowH = (if layoutNow.touch then 64 else 58) + 8
scroll.CanvasPosition = Vector2.new(0, math.max(0, (bought - from) * rowH - rowH))
end
local function show(p: Frame?)
panel.Visible = p == panel
settings.Visible = p == settings
dim.Visible = p ~= nil
if p then
popIn(p)
end
if p == panel then
scrollToNext()
task.defer(scrollToNext) -- 줄을 막 다시 그렸으면 캔버스 크기가 다음 프레임에 정해집니다.
end
end
local conns: { RBXScriptConnection } = {}
local function on(sig: RBXScriptSignal, fn: (...any) -> ())
table.insert(conns, sig:Connect(fn))
end
on(buy.button.Activated, function()
send("buy")
end)
on(listBtn.button.Activated, function()
show(if panel.Visible then nil else panel)
end)
on(closeBtn.button.Activated, function()
show(nil)
end)
on(settingsBtn.button.Activated, function()
show(if settings.Visible then nil else settings)
end)
on(settingsClose.button.Activated, function()
show(nil)
end)
for l, b in langButtons do
on(b.button.Activated, function()
send("lang", l)
end)
end
on(mouseBtn.button.Activated, function()
send("mouseLook", attr(state, "MouseLook", true) ~= true)
end)
on(sfxBtn.button.Activated, function()
send("sfx", attr(state, "Sfx", true) ~= true)
end)
on(passBtn.button.Activated, function()
if not attr(state, "Double", false) then
send("pass")
end
end)
on(boostBtn.button.Activated, function()
send("boost")
end)
local devKinds: { [string]: string } = { devMoney = "dev_money", devDouble = "dev_double", devReset = "dev_reset" }
for key, kind in devKinds do
on(devButtons[key].button.Activated, function()
send(kind)
end)
end
on(state.AttributeChanged, refresh)
refresh()
return {
gui = gui,
refresh = refresh,
notify = notify,
setLayout = function(size: Vector2, isTouch: boolean)
screen = size
local changed = touch ~= isTouch
touch = isTouch
relayout()
if changed then
listKey = "" -- 목록 줄 높이가 터치 여부로 달라집니다.
refresh()
end
end,
layout = function(): Layout.Result
return layoutNow
end,
open = function(which: string?)
show(if which == "shop" then panel elseif which == "settings" then settings else nil)
end,
menuOpen = function(): boolean
return panel.Visible or settings.Visible
end,
destroy = function()
for _, c in conns do
c:Disconnect()
end
for _, t in tweens do
t:Cancel()
end
gui:Destroy()
end,
}
end
return Hud