diff --git a/bunsik-tycoon/PLAYTEST.md b/bunsik-tycoon/PLAYTEST.md index 01ac153..5209daa 100644 --- a/bunsik-tycoon/PLAYTEST.md +++ b/bunsik-tycoon/PLAYTEST.md @@ -9,10 +9,10 @@ ## 해 볼 것 (15~20분) 1. 튜토리얼: 노란 줄과 ⬇️ 화살표를 따라 조리대로 가서 버튼을 꾹 누르고(PC는 E 키), 접시를 손님 자리로 가져갑니다. 손님 근처에 가면 접시가 자동으로 놓입니다. -2. 돈이 생기면 아래 가운데 카드의 [사기] 버튼으로 다음 업그레이드를 삽니다. 오른쪽 [📋 업그레이드]에서 전체 목록을 봅니다. +2. 돈이 생기면 아래 가운데 "다음 업그레이드" 카드의 초록 [사기] 버튼으로 삽니다. 살 수 있을 때는 버튼이 반짝이고, 오른쪽 주황 [업그레이드] 버튼에 빨간 `!` 배지가 붙습니다. [업그레이드] 버튼을 누르면 전체 목록이 열리고, 다음에 살 줄로 자동으로 내려갑니다(그 줄에서도 바로 살 수 있음). 3. 8번째 구매(알바생)부터는 알바생이 카운터(조리대 오른쪽)에 접시를 만들어 둡니다. 카운터 근처에 가면 접시를 자동으로 집습니다. 4. 10번째 구매(실내 분식집 확장)를 하면 건물이 생기고 2단계 업그레이드 10개가 열립니다. -5. 오른쪽 위 `⚙️ 설정` 버튼을 눌러 봅니다. +5. 오른쪽 위 파란 톱니바퀴 [설정] 버튼을 눌러 봅니다. - 언어: 자동(계정 언어)·한국어·English·日本語·中文 중에서 고릅니다. 이름판·메뉴판·버튼 글자가 모두 바뀝니다. - 마우스로 화면 돌리기(PC, 기본 켜짐): 우클릭 없이 마우스만 움직여도 화면이 돕니다. 버튼을 누를 땐 Ctrl을 누르고 있거나, 업그레이드·설정 창을 열면 커서가 나옵니다. - 효과음 켜기/끄기. @@ -25,20 +25,28 @@ ## 휴대폰에서 해 볼 것 휴대폰·태블릿은 화면을 가로로 두고 합니다. 화면을 터치하면 휴대폰 배치로 바뀝니다. -- 왼쪽 위: `💰x2 2배 수익`, `⚡ 돈 부스트`. 왼쪽 아래 조이스틱 자리와 겹치지 않게 위로 올렸습니다. -- 오른쪽 위: `⚙️ 설정`, `📋 업그레이드`. 오른쪽 아래 점프 버튼 자리는 비워 두었습니다. +- 왼쪽 위: 보라 [2배 수익], 노랑 [돈 부스트]. 왼쪽 아래 조이스틱 자리와 겹치지 않게 위로 올렸습니다. +- 오른쪽 위: 파랑 [설정], 주황 [업그레이드]. 오른쪽 아래 점프 버튼 자리는 비워 두었습니다. - 아래: 다음 업그레이드 카드. [사기] 버튼은 조이스틱과 점프 버튼 사이에 옵니다. - 설정 창에는 마우스 회전 줄이 없습니다(휴대폰에는 필요 없음). - 조이스틱으로 걸을 때 버튼이 눌리지 않는지, 글자가 너무 작지 않은지 봐 주세요. +## 새 화면 UI에서 봐 줄 것 + +- 버튼을 누르면 쏙 들어갔다 나오는지, PC에서 마우스를 올리면 살짝 커지는지 +- 돈을 벌면 돈 표시가 통 튀고 아래에 초록 `+돈` 글자가 떠오르는지 +- 업그레이드·설정 창이 튀어나오듯 열리고 뒤 화면이 어두워지는지 +- 아이콘(동전, 메뉴 음식, 테이블 등)이 깨지거나 빈 네모로 나오지 않는지 +- 글자가 버튼 밖으로 넘치거나 너무 작은 곳이 없는지(영어·일본어·중국어도) + ## 개발자 테스트 버튼(주인 계정에만 보임) -`⚙️ 설정` 창 맨 아래의 `🛠 개발자 테스트` 줄: +[설정] 창 맨 아래의 렌치 아이콘 `개발자 테스트` 줄: - `+1,000원`: 돈을 바로 넣습니다. 뒤쪽 업그레이드를 빨리 확인할 때 씁니다. - `2배 켜기/끄기`: 2배 수익 게임패스를 산 것처럼 켭니다(이번 접속에만 적용). - `처음부터`: 돈·업그레이드·튜토리얼을 처음으로 되돌립니다. -`💰x2 2배 수익`, `⚡ 돈 부스트` 버튼은 진짜 결제 창이 뜹니다. 누르면 실제 로벅스가 나가니, 결제 테스트가 필요할 때만 쓰세요. +[2배 수익], [돈 부스트] 버튼은 진짜 결제 창이 뜹니다. 누르면 실제 로벅스가 나가니, 결제 테스트가 필요할 때만 쓰세요. ## 알려 주시면 좋은 것 diff --git a/bunsik-tycoon/art/ui_icons.png b/bunsik-tycoon/art/ui_icons.png new file mode 100644 index 0000000..19ca6b4 Binary files /dev/null and b/bunsik-tycoon/art/ui_icons.png differ diff --git a/bunsik-tycoon/src/client/Hud.luau b/bunsik-tycoon/src/client/Hud.luau index b59a79f..a2f98a7 100644 --- a/bunsik-tycoon/src/client/Hud.luau +++ b/bunsik-tycoon/src/client/Hud.luau @@ -1,6 +1,6 @@ --!strict --- 화면 UI: 돈, 다음 업그레이드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음·개발자 테스트), 안내 문구, 알림. --- 배치는 Layout 모듈이 화면 크기와 터치 여부로 정합니다(휴대폰은 조이스틱·점프 버튼 자리를 피함). +-- 화면 UI: 돈, 다음 업그레이드 카드, 업그레이드 목록, 2배 수익·돈 부스트 버튼, 설정(언어·마우스 회전·효과음·개발자 테스트), +-- 안내 문구, 알림. 모양은 Theme(굵은 테두리, 그러데이션, 입체 버튼, 아이콘), 배치는 Layout 모듈이 정합니다. -- 상태는 `state` 인스턴스(실제 게임에서는 Player)의 속성에서 읽습니다. 서버에서도 만들 수 있어서 원격 테스트로 검사합니다. local ReplicatedStorage = game:GetService("ReplicatedStorage") @@ -11,6 +11,7 @@ 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 = {} @@ -21,90 +22,44 @@ export type HudHandle = { -- UI가 쓸 수 있는 화면 크기(픽셀, 상단 바 제외)와 터치 화면 여부로 배치를 다시 잡습니다. setLayout: (size: Vector2, touch: boolean) -> (), layout: () -> Layout.Result, + open: (which: string?) -> (), -- "shop", "settings", nil(닫기) menuOpen: () -> boolean, -- 업그레이드·설정 창이 열려 있으면 true(마우스 커서를 풀어 줌) destroy: () -> (), } -local ORANGE = Color3.fromRGB(255, 130, 50) -local GREEN = Color3.fromRGB(70, 190, 90) -local GRAY = Color3.fromRGB(150, 150, 150) -local DARK = Color3.fromRGB(45, 35, 35) -local CREAM = Color3.fromRGB(255, 248, 235) +local INK = Theme.INK -local function corner(parent: Instance, r: number) - local c = Instance.new("UICorner") - c.CornerRadius = UDim.new(0, r) - c.Parent = parent +-- 업그레이드 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 function stroke(parent: Instance, color: Color3, thickness: number): UIStroke - local s = Instance.new("UIStroke") - s.Color = color - s.Thickness = thickness - s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border - s.Parent = parent - return s -end - -local function frame(parent: Instance, name: string, size: UDim2, pos: UDim2, anchor: Vector2, color: Color3?): Frame - local f = Instance.new("Frame") - f.Name = name - f.Size = size - f.Position = pos - f.AnchorPoint = anchor - f.BackgroundColor3 = color or CREAM - f.BackgroundTransparency = if color then 0 else 1 - f.BorderSizePixel = 0 - f.Parent = parent - return f -end - -local function text(parent: Instance, name: string, size: UDim2, pos: UDim2, color: Color3?): TextLabel - local t = Instance.new("TextLabel") - t.Name = name - t.Size = size - t.Position = pos - t.BackgroundTransparency = 1 - t.TextColor3 = color or DARK - t.Font = Enum.Font.FredokaOne - t.TextScaled = true - t.AutoLocalize = false - t.Text = "" - t.Parent = parent - return t -end - -local function button( - parent: Instance, - name: string, - size: UDim2, - pos: UDim2, - anchor: Vector2, - color: Color3 -): TextButton - local b = Instance.new("TextButton") - b.Name = name - b.Size = size - b.Position = pos - b.AnchorPoint = anchor - b.BackgroundColor3 = color - b.TextColor3 = Color3.new(1, 1, 1) - b.Font = Enum.Font.FredokaOne - b.TextScaled = true - b.AutoLocalize = false - b.AutoButtonColor = true - b.Text = "" - b.Parent = parent - corner(b, 14) - stroke(b, Color3.fromRGB(255, 255, 255), 3) - local pad = Instance.new("UIPadding") - pad.PaddingTop = UDim.new(0.14, 0) - pad.PaddingBottom = UDim.new(0.14, 0) - pad.PaddingLeft = UDim.new(0, 8) - pad.PaddingRight = UDim.new(0, 8) - pad.Parent = b - return b -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) @@ -114,6 +69,132 @@ local function attr(state: Instance, key: string, default: any): any 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" @@ -121,194 +202,309 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () 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 = frame(gui, "Root", UDim2.fromOffset(1100, 620), UDim2.fromScale(0, 0), Vector2.zero) + local root = Theme.frame(gui, "Root") + root.Size = UDim2.fromOffset(1100, 620) local scale = Instance.new("UIScale") scale.Parent = root - -- 돈 - local money = frame(root, "Money", UDim2.fromOffset(300, 62), UDim2.new(0.5, 0, 0, 6), Vector2.new(0.5, 0), ORANGE) - corner(money, 31) - stroke(money, Color3.new(1, 1, 1), 4) - local moneyText = text(money, "Text", UDim2.new(1, -24, 1, -14), UDim2.fromOffset(12, 7), Color3.new(1, 1, 1)) - local carry = text(root, "Carry", UDim2.fromOffset(160, 28), UDim2.new(0.5, -80, 0, 72), DARK) + -- 돈: 금색 알약 + 왼쪽에 튀어나온 동전 + 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 = frame( - root, - "Hint", - UDim2.fromOffset(640, 54), - UDim2.new(0.5, 0, 0, 104), - Vector2.new(0.5, 0), - Color3.fromRGB(255, 235, 120) + 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) } + ) ) - corner(hint, 14) - stroke(hint, ORANGE, 3) - local hintText = text(hint, "Text", UDim2.new(1, -20, 1, -10), UDim2.fromOffset(10, 5)) + local hintText = Theme.text(hint, "Text", true) + hintText.Position = UDim2.fromOffset(60, 7) + hintText.Size = UDim2.new(1, -72, 1, -14) -- 알림 - local toasts = frame(root, "Toasts", UDim2.fromOffset(560, 200), UDim2.new(0.5, 0, 0, 166), Vector2.new(0.5, 0)) + local toasts = Theme.frame(root, "Toasts") local list = Instance.new("UIListLayout") list.HorizontalAlignment = Enum.HorizontalAlignment.Center - list.Padding = UDim.new(0, 6) + list.Padding = UDim.new(0, 8) + list.SortOrder = Enum.SortOrder.LayoutOrder list.Parent = toasts - -- 다음 업그레이드 카드(아래 가운데) - local card = frame(root, "Next", UDim2.fromOffset(500, 96), UDim2.new(0.5, 0, 1, -8), Vector2.new(0.5, 1), CREAM) - corner(card, 18) - stroke(card, ORANGE, 4) - local cardTitle = text(card, "Title", UDim2.new(1, -170, 0, 40), UDim2.fromOffset(14, 8)) + -- 다음 업그레이드 카드(아래): 이름표, 아이콘 상자, 이름, 진행 막대, [사기] + 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 - local cardCost = - text(card, "Cost", UDim2.new(1, -170, 0, 26), UDim2.fromOffset(14, 48), Color3.fromRGB(120, 90, 60)) - cardCost.TextXAlignment = Enum.TextXAlignment.Left - local barBg = frame( - card, - "Bar", - UDim2.new(1, -170, 0, 10), - UDim2.fromOffset(14, 78), - Vector2.zero, - Color3.fromRGB(230, 220, 200) + 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 } + ) ) - corner(barBg, 5) - local barFill = frame(barBg, "Fill", UDim2.fromScale(0, 1), UDim2.fromScale(0, 0), Vector2.zero, GREEN) - corner(barFill, 5) - local buyBtn = button(card, "Buy", UDim2.fromOffset(140, 72), UDim2.new(1, -12, 0.5, 0), Vector2.new(1, 0.5), GREEN) - local buyStroke = buyBtn:FindFirstChildOfClass("UIStroke") :: UIStroke + 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 = - button(root, "ListButton", UDim2.fromOffset(150, 56), UDim2.new(1, -10, 0.5, -40), Vector2.new(1, 0.5), ORANGE) - local panel = - frame(root, "Panel", UDim2.fromOffset(520, 430), UDim2.fromScale(0.5, 0.48), Vector2.new(0.5, 0.5), CREAM) - panel.Visible = false - corner(panel, 20) - stroke(panel, ORANGE, 4) - local panelTitle = text(panel, "Title", UDim2.new(1, -120, 0, 44), UDim2.fromOffset(16, 10)) - panelTitle.TextXAlignment = Enum.TextXAlignment.Left - local closeBtn = button( - panel, - "Close", - UDim2.fromOffset(90, 42), - UDim2.new(1, -12, 0, 10), - Vector2.new(1, 0), - Color3.fromRGB(220, 80, 70) + -- 네모 아이콘 버튼들 + 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.Size = UDim2.new(1, -24, 1, -70) - scroll.Position = UDim2.fromOffset(12, 62) + 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.Parent = panel + scroll.ZIndex = 3 + scroll.Parent = panelBody local rows = Instance.new("UIListLayout") - rows.Padding = UDim.new(0, 6) + 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 - -- 왼쪽: 2배 수익, 돈 부스트 - local passBtn = button( - root, - "Double", - UDim2.fromOffset(170, 64), - UDim2.new(0, 10, 0.5, -40), - Vector2.new(0, 0.5), - Color3.fromRGB(150, 80, 220) - ) - local boostBtn = button( - root, - "Boost", - UDim2.fromOffset(170, 64), - UDim2.new(0, 10, 0.5, 34), - Vector2.new(0, 0.5), - Color3.fromRGB(240, 170, 30) - ) - - -- 오른쪽 위: 설정 버튼과 설정 창(언어, 마우스로 화면 돌리기, 효과음, 개발자 테스트) - local settingsBtn = button( - root, - "Settings", - UDim2.fromOffset(130, 44), - UDim2.new(1, -10, 0, 6), - Vector2.new(1, 0), - Color3.fromRGB(80, 140, 230) - ) - local settings = frame( - root, - "SettingsPanel", - UDim2.fromOffset(520, 330), - UDim2.fromScale(0.5, 0.48), - Vector2.new(0.5, 0.5), - CREAM - ) - settings.Visible = false - corner(settings, 20) - stroke(settings, Color3.fromRGB(80, 140, 230), 4) - local settingsTitle = text(settings, "Title", UDim2.new(1, -120, 0, 44), UDim2.fromOffset(16, 10)) - settingsTitle.TextXAlignment = Enum.TextXAlignment.Left - local settingsClose = button( - settings, - "Close", - UDim2.fromOffset(90, 42), - UDim2.new(1, -12, 0, 10), - Vector2.new(1, 0), - Color3.fromRGB(220, 80, 70) - ) - local function rowLabel(name: string, y: number): TextLabel - local t = text(settings, name, UDim2.new(1, -32, 0, 30), UDim2.fromOffset(16, y)) - t.TextXAlignment = Enum.TextXAlignment.Left - return t - end - local langLabel = rowLabel("LangLabel", 64) + -- 설정 창(언어, 마우스로 화면 돌리기, 효과음, 개발자 테스트) + 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]: TextButton } = {} - for i, l in langChoices do - local b = button( - settings, - "Lang_" .. (if l == "" then "auto" else l), - UDim2.fromOffset(92, 44), - UDim2.fromOffset(16 + (i - 1) * 98, 100), - Vector2.zero, - GRAY - ) + 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 mouseLabel = rowLabel("MouseLabel", 160) - local mouseBtn = - button(settings, "MouseLook", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 156), Vector2.new(1, 0), GRAY) - mouseLabel.Size = UDim2.new(1, -150, 0, 30) - local mouseHint = - text(settings, "MouseHint", UDim2.new(1, -32, 0, 22), UDim2.fromOffset(16, 200), Color3.fromRGB(120, 90, 60)) + 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 - local sfxLabel = rowLabel("SfxLabel", 246) - sfxLabel.Size = UDim2.new(1, -150, 0, 30) - local sfxBtn = - button(settings, "Sfx", UDim2.fromOffset(110, 40), UDim2.new(1, -16, 0, 242), Vector2.new(1, 0), GRAY) + mouseHint.ZIndex = 3 + local sfxRow, sfxLabel = settingRow(settings, "SfxRow", "speaker") + local sfxBtn, sfxValue = toggleButton(settings, "Sfx") + sfxBtn.button.ZIndex = 3 -- 개발자(게임 주인)만 보는 테스트 버튼 줄 - local devTitle = rowLabel("DevLabel", 0) - local devButtons: { [string]: TextButton } = {} - for i, key in { "devMoney", "devDouble", "devReset" } do - devButtons[key] = button( - settings, - key, - UDim2.fromOffset(157, 40), - UDim2.fromOffset(16 + (i - 1) * 165, 0), - Vector2.zero, - Color3.fromRGB(90, 90, 110) - ) + 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 모듈). 개발자 줄이 생기거나 없어질 때도 다시 잡습니다. + -- 화면 크기에 맞춰 배치합니다(Layout 모듈). 버튼은 가운데 기준이라 누르면 제자리에서 작아집니다. local function place(o: GuiObject, r: Layout.Rect) - o.AnchorPoint = Vector2.zero - o.Position = UDim2.fromOffset(r.x, r.y) + 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) @@ -326,41 +522,54 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () place(hint, lay.hint) place(toasts, lay.toasts) place(card, lay.card) - place(listBtn, lay.list) - place(settingsBtn, lay.settings) - place(passBtn, lay.double) - place(boostBtn, lay.boost) + 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 - closeBtn.Size = UDim2.fromOffset(90, r.closeH) - settingsClose.Size = UDim2.fromOffset(90, r.closeH) - for _, b in langButtons do - b.Size = UDim2.fromOffset(92, r.langButtonH) + 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 - mouseLabel.Visible = mouseY ~= nil - mouseBtn.Visible = mouseY ~= nil + mouseRow.Visible = mouseY ~= nil + mouseBtn.button.Visible = mouseY ~= nil mouseHint.Visible = mouseY ~= nil if mouseY then - mouseLabel.Position = UDim2.fromOffset(16, mouseY + 4) - mouseBtn.Position = UDim2.new(1, -16, 0, mouseY) - mouseHint.Position = UDim2.fromOffset(16, mouseY + 44) + 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 - sfxLabel.Position = UDim2.fromOffset(16, r.sfxY + (r.toggleH - 30) / 2) - sfxBtn.Position = UDim2.new(1, -16, 0, r.sfxY) - sfxBtn.Size = UDim2.fromOffset(110, r.toggleH) + 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 - devTitle.Visible = devY ~= nil + devRow.Visible = devY ~= nil if devY then - devTitle.Position = UDim2.fromOffset(16, devY) + at(devRow, 18, devY, 360, 34) end - for _, b in devButtons do - b.Visible = devY ~= nil + local j = 0 + for _, key in { "devMoney", "devDouble", "devReset" } do + local db = devButtons[key].button + db.Visible = devY ~= nil if devY then - b.Position = UDim2.fromOffset(b.Position.X.Offset, devY + 30) - b.Size = UDim2.fromOffset(157, r.devButtonH) + at(db, 18 + j * 170, devY + 38, 160, r.devButtonH) end + j += 1 end end relayout() @@ -374,37 +583,78 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () local function pname(p: Economy.Purchase): string return Locale.itemName(lang(), p.id) end - local function toggle(b: TextButton, on: boolean) - b.Text = L(if on then "on" else "off") - b.BackgroundColor3 = if on then GREEN else GRAY + 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 pulse: Tween? = nil 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) }) + 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.Text = if held > 0 then `🍽️ {held}/{stats.carry}` else "" + 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 = `{L("next")}: {pname(nextP)}` - cardCost.Text = L("money", { money = Locale.number(nextP.cost) }) + 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) - local can = m >= nextP.cost - buyBtn.Text = L("buy") - buyBtn.BackgroundColor3 = if can then GREEN else GRAY - buyBtn.Visible = true + 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) - buyBtn.Visible = false + 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) @@ -414,64 +664,51 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () else hint.Visible = false end - if tut == 3 and not pulse then - buyStroke.Color = Color3.fromRGB(255, 220, 0) - local tw = TweenService:Create( - buyStroke, - TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true), - { Thickness = 9 } - ) - tw:Play() - pulse = tw - elseif tut ~= 3 and pulse then - pulse:Cancel() - pulse = nil - buyStroke.Thickness = 3 - buyStroke.Color = Color3.new(1, 1, 1) - 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, b in devButtons do - b.Text = L(key) + devTitle.Text = L("devTitle") + for key, t in devLabels do + t.Text = L(key) end - listBtn.Text = "📋 " .. L("shop") - settingsBtn.Text = "⚙️ " .. L("settings") - closeBtn.Text = L("close") - - settingsTitle.Text = "⚙️ " .. L("settings") - settingsClose.Text = L("close") - langLabel.Text = "🌐 " .. L("language") + 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 - b.Text = if l == "" then L("langAuto") else Locale.LANG_NAMES[l] - b.BackgroundColor3 = if l == current then Color3.fromRGB(80, 140, 230) else GRAY + 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") + mouseLabel.Text = L("mouseLook") mouseHint.Text = L("mouseHint") - toggle(mouseBtn, attr(state, "MouseLook", true) == true) - sfxLabel.Text = "🔊 " .. L("sfx") - toggle(sfxBtn, attr(state, "Sfx", true) == true) + 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.Visible = Products.DOUBLE_MONEY_PASS ~= 0 - passBtn.Text = if double then "✅ " .. L("doubleOwned") else "💰x2 " .. L("double") - passBtn.Active = not double - passBtn.AutoButtonColor = not double - boostBtn.Visible = Products.MONEY_BOOST_PRODUCT ~= 0 and nextP ~= nil - boostBtn.Text = "⚡ " .. L("boost") .. "\n+" .. Locale.number(attr(state, "Boost", Economy.BOOST_MIN)) + 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()}` + -- 업그레이드 목록(지금 단계 것만). 산 개수, 언어, 살 수 있는지가 바뀔 때만 다시 그립니다. + local key = `{bought}:{lang()}:{can}` if key == listKey then return end listKey = key local stage = stats.stage - panelTitle.Text = L(if stage >= 2 then "stage2" else "stage1") + stageText.Text = L(if stage >= 2 then "stage2" else "stage1") for _, c in scroll:GetChildren() do if c:IsA("Frame") then c:Destroy() @@ -479,29 +716,86 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () 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 row = - frame(scroll, "Row" .. i, UDim2.new(1, -12, 0, 46), UDim2.new(), Vector2.zero, Color3.new(1, 1, 1)) - row.LayoutOrder = i - corner(row, 10) local done = i <= bought local isNext = i == bought + 1 - row.BackgroundColor3 = if done - then Color3.fromRGB(215, 245, 215) - elseif isNext then Color3.fromRGB(255, 240, 200) - else Color3.fromRGB(240, 240, 240) - local status = if done then "✅" elseif isNext then "👉" else "🔒" - local name = text(row, "Name", UDim2.new(0.66, -10, 1, -12), UDim2.fromOffset(10, 6)) + 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.Text = `{status} {pname(p)}` - local cost = - text(row, "Cost", UDim2.new(0.34, -10, 1, -12), UDim2.new(0.66, 0, 0, 6), Color3.fromRGB(120, 90, 60)) - cost.TextXAlignment = Enum.TextXAlignment.Right - cost.Text = if done then L("bought") else L("money", { money = Locale.number(p.cost) }) + 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 @@ -513,96 +807,108 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () args.name = Locale.itemName(lang(), args.item) end end - local toast = - frame(toasts, "Toast", UDim2.new(1, -20, 0, 46), UDim2.new(), Vector2.zero, Color3.fromRGB(45, 45, 60)) - corner(toast, 12) - local t = text(toast, "Text", UDim2.new(1, -20, 1, -10), UDim2.fromOffset(10, 5), Color3.new(1, 1, 1)) + 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) - task.delay(2.6, function() - TweenService:Create(toast, TweenInfo.new(0.4), { BackgroundTransparency = 1 }):Play() - TweenService:Create(t, TweenInfo.new(0.4), { TextTransparency = 1 }):Play() + 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 conns: { RBXScriptConnection } = {} - table.insert( - conns, - buyBtn.Activated:Connect(function() - send("buy") - end) - ) - table.insert( - conns, - listBtn.Activated:Connect(function() - panel.Visible = not panel.Visible - settings.Visible = false - end) - ) - table.insert( - conns, - closeBtn.Activated:Connect(function() - panel.Visible = false - end) - ) - table.insert( - conns, - settingsBtn.Activated:Connect(function() - settings.Visible = not settings.Visible - panel.Visible = false - end) - ) - table.insert( - conns, - settingsClose.Activated:Connect(function() - settings.Visible = false - end) - ) - for l, b in langButtons do - table.insert( - conns, - b.Activated:Connect(function() - send("lang", l) - 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 - table.insert( - conns, - mouseBtn.Activated:Connect(function() - send("mouseLook", attr(state, "MouseLook", true) ~= true) + + 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) - ) - table.insert( - conns, - sfxBtn.Activated:Connect(function() - send("sfx", attr(state, "Sfx", true) ~= true) - end) - ) - table.insert( - conns, - passBtn.Activated:Connect(function() - if not attr(state, "Double", false) then - send("pass") - end - end) - ) - table.insert( - conns, - boostBtn.Activated:Connect(function() - send("boost") - 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 - table.insert( - conns, - devButtons[key].Activated:Connect(function() - send(kind) - end) - ) + on(devButtons[key].button.Activated, function() + send(kind) + end) end - table.insert(conns, state.AttributeChanged:Connect(refresh)) + on(state.AttributeChanged, refresh) refresh() return { @@ -611,12 +917,20 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () 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, @@ -624,6 +938,9 @@ function Hud.build(parent: Instance, state: Instance, send: (string, any?) -> () for _, c in conns do c:Disconnect() end + for _, t in tweens do + t:Cancel() + end gui:Destroy() end, } diff --git a/bunsik-tycoon/src/client/Layout.luau b/bunsik-tycoon/src/client/Layout.luau index a2fb0f9..7af2f1f 100644 --- a/bunsik-tycoon/src/client/Layout.luau +++ b/bunsik-tycoon/src/client/Layout.luau @@ -38,9 +38,10 @@ export type Result = { }, } -local CARD_W, CARD_H = 500, 96 -local BUY_W, BUY_H = 140, 72 -local PANEL_W = 520 +local CARD_W, CARD_H = 500, 112 +local CARD_TAB = 16 -- 카드 위로 튀어나온 "다음 업그레이드" 이름표 높이(카드 사각형 안) +local BUY_W, BUY_H = 140, 70 +local PANEL_W = 540 local function rect(x: number, y: number, w: number, h: number): Rect return { x = x, y = y, w = w, h = h } @@ -70,26 +71,28 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res local W, H = w / s, h / s local cx = W / 2 - local money = rect(cx - 150, 6, 300, 62) - local carry = rect(cx - 80, 72, 160, 28) + -- 돈: 왼쪽에 동전 아이콘이 튀어나온 알약 모양 + local money = rect(cx - 160, 6, 320, 64) + local carry = rect(cx - 60, 74, 120, 30) + -- 네모 아이콘 버튼(아이콘 위, 이름 아래) local settings, list, double, boost local hintW if touch then - -- 오른쪽 위: 설정, 업그레이드 목록. 왼쪽 위: 2배 수익, 돈 부스트(조이스틱 자리 H/3 위쪽). - settings = rect(W - 160, 6, 150, 52) - list = rect(W - 160, 66, 150, 56) - double = rect(10, 6, 170, 58) - boost = rect(10, 70, 170, 58) - hintW = math.min(640, W - 2 * 190) + -- 왼쪽 위: 2배 수익, 돈 부스트(조이스틱 자리 H/3 위쪽). 오른쪽 위: 설정, 업그레이드 목록. + double = rect(8, 6, 84, 84) + boost = rect(100, 6, 84, 84) + list = rect(W - 92, 6, 84, 84) + settings = rect(W - 92 - 76, 6, 68, 68) + hintW = math.min(640, W - 2 * 196) else - settings = rect(W - 140, 6, 130, 44) - list = rect(W - 160, H / 2 - 68, 150, 56) - double = rect(10, H / 2 - 72, 170, 64) - boost = rect(10, H / 2 + 2, 170, 64) + settings = rect(W - 78, 6, 68, 68) + list = rect(W - 110, H / 2 - 50, 100, 100) + double = rect(10, H / 2 - 112, 100, 100) + boost = rect(10, H / 2 + 12, 100, 100) hintW = 640 end - local hint = rect(cx - hintW / 2, 104, hintW, 54) + local hint = rect(cx - hintW / 2, 110, hintW, 58) -- 아래 카드: 터치 화면에서는 점프 버튼 왼쪽까지 밀어 둡니다. local cardX = cx - CARD_W / 2 @@ -99,31 +102,32 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res end cardX = math.max(cardX, 10) local card = rect(cardX, H - 8 - CARD_H, CARD_W, CARD_H) - local buy = rect(card.x + CARD_W - 12 - BUY_W, card.y + (CARD_H - BUY_H) / 2, BUY_W, BUY_H) + local bodyH = CARD_H - CARD_TAB + local buy = rect(card.x + CARD_W - 12 - BUY_W, card.y + CARD_TAB + (bodyH - BUY_H) / 2, BUY_W, BUY_H) local toastsW = math.min(560, hintW) - local toasts = rect(cx - toastsW / 2, 166, toastsW, math.max(0, card.y - 6 - 166)) + local toasts = rect(cx - toastsW / 2, 176, toastsW, math.max(0, card.y - 6 - 176)) - local panelH = math.min(430, H - 20) + local panelH = math.min(450, H - 12) local panel = rect(cx - PANEL_W / 2, math.max(6, H * 0.48 - panelH / 2), PANEL_W, panelH) -- 설정 창 줄: 제목(10~54), 언어 이름(64), 언어 버튼(100~), 마우스(PC만), 효과음, 개발자(주인만) local langButtonH = if touch then 52 else 44 local toggleH = if touch then 48 else 40 - local y = 100 + langButtonH + 12 + local y = 104 + langButtonH + 16 local mouseY: number? = nil if not touch then mouseY = y - y += 90 + y += 92 end local sfxY = y - y += toggleH + 12 + y += toggleH + 14 local devY: number? = nil if dev then devY = y - y += 30 + toggleH + 12 + y += 34 + toggleH + 14 end - local setH = y + 4 + local setH = y + 8 local settingsPanel = rect(cx - PANEL_W / 2, math.max(6, H * 0.48 - setH / 2), PANEL_W, setH) return { @@ -150,7 +154,7 @@ function Layout.compute(w: number, h: number, touch: boolean, dev: boolean): Res toggleH = toggleH, devY = devY, devButtonH = toggleH, - closeH = if touch then 48 else 42, + closeH = if touch then 52 else 46, }, } end diff --git a/bunsik-tycoon/src/client/Theme.luau b/bunsik-tycoon/src/client/Theme.luau new file mode 100644 index 0000000..79478a5 --- /dev/null +++ b/bunsik-tycoon/src/client/Theme.luau @@ -0,0 +1,230 @@ +--!strict +-- 화면 UI 꾸미기 도구: 색, 굵은 테두리, 위아래 그러데이션, 입체 버튼(아래 그림자 판), 반짝 지나가는 빛, +-- 누르면 쏙 들어가는 애니메이션, 아이콘. 인기 시뮬레이터·타이쿤 게임의 "굵은 테두리 + 흰 글자" 스타일을 따릅니다. +-- 트윈만 쓰고 RenderStepped는 쓰지 않아서 서버(원격 테스트)에서도 만들 수 있습니다. + +local TweenService = game:GetService("TweenService") +local ReplicatedStorage = game:GetService("ReplicatedStorage") + +local Icons = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("Icons")) + +local Theme = {} + +Theme.INK = Color3.fromRGB(59, 30, 18) -- 테두리·글자 외곽선(진한 갈색) +Theme.CREAM = Color3.fromRGB(255, 246, 228) +Theme.WHITE = Color3.new(1, 1, 1) +Theme.BROWN = Color3.fromRGB(120, 72, 40) + +-- 버튼 색(위쪽 밝은 색). 아래쪽·그림자 판은 자동으로 어둡게 만듭니다. +Theme.RED = Color3.fromRGB(255, 84, 64) +Theme.ORANGE = Color3.fromRGB(255, 150, 40) +Theme.YELLOW = Color3.fromRGB(255, 205, 50) +Theme.GREEN = Color3.fromRGB(110, 225, 60) +Theme.BLUE = Color3.fromRGB(70, 175, 255) +Theme.PURPLE = Color3.fromRGB(180, 100, 255) +Theme.GRAY = Color3.fromRGB(175, 175, 180) +Theme.NAVY = Color3.fromRGB(40, 48, 80) + +Theme.FONT = Font.new("rbxasset://fonts/families/FredokaOne.json", Enum.FontWeight.Bold) + +function Theme.darken(c: Color3, k: number): Color3 + return c:Lerp(Color3.new(0, 0, 0), k) +end + +function Theme.lighten(c: Color3, k: number): Color3 + return c:Lerp(Color3.new(1, 1, 1), k) +end + +function Theme.corner(parent: Instance, r: number, scale: number?): UICorner + local c = Instance.new("UICorner") + c.CornerRadius = UDim.new(scale or 0, r) + c.Parent = parent + return c +end + +function Theme.stroke(parent: Instance, color: Color3, thickness: number, contextual: boolean?): UIStroke + local s = Instance.new("UIStroke") + s.Color = color + s.Thickness = thickness + s.LineJoinMode = Enum.LineJoinMode.Round + s.ApplyStrokeMode = if contextual then Enum.ApplyStrokeMode.Contextual else Enum.ApplyStrokeMode.Border + s.Parent = parent + return s +end + +-- 위(밝음) → 아래(어두움) 그러데이션. 배경색은 흰색으로 두고 색은 그러데이션이 냅니다. +function Theme.gradient(parent: GuiObject, top: Color3, bottom: Color3): UIGradient + local g = parent:FindFirstChildOfClass("UIGradient") or Instance.new("UIGradient") + g.Color = ColorSequence.new(top, bottom) + g.Rotation = 90 + g.Parent = parent + parent.BackgroundColor3 = Theme.WHITE + return g +end + +function Theme.frame(parent: Instance, name: string, color: Color3?): Frame + local f = Instance.new("Frame") + f.Name = name + f.BorderSizePixel = 0 + f.BackgroundColor3 = color or Theme.WHITE + f.BackgroundTransparency = if color then 0 else 1 + f.Parent = parent + return f +end + +-- 흰 글자 + 진한 테두리(기본). dark=true면 진한 갈색 글자(밝은 바탕용). +function Theme.text(parent: Instance, name: string, dark: boolean?, strokeK: number?): TextLabel + local t = Instance.new("TextLabel") + t.Name = name + t.BackgroundTransparency = 1 + t.FontFace = Theme.FONT + t.TextScaled = true + t.TextWrapped = true + t.AutoLocalize = false + t.Text = "" + t.TextColor3 = if dark then Theme.INK else Theme.WHITE + if not dark then + Theme.stroke(t, Theme.INK, strokeK or 2.5, true) + end + t.Parent = parent + return t +end + +function Theme.icon(parent: Instance, name: string, icon: string): ImageLabel + local i = Instance.new("ImageLabel") + i.Name = name + i.BackgroundTransparency = 1 + i.ScaleType = Enum.ScaleType.Fit + Icons.apply(i, icon) + i.Parent = parent + return i +end + +Theme.setIcon = Icons.apply + +-- 반짝 지나가는 빛: 같은 모양(둥근 모서리)의 흰 판 위에서 투명도 그러데이션이 왼쪽→오른쪽으로 지나갑니다. +function Theme.shine(face: GuiObject, radius: number, period: number): Tween + local s = Theme.frame(face, "Shine", Theme.WHITE) + s.Size = UDim2.fromScale(1, 1) + s.ZIndex = 6 + Theme.corner(s, radius) + local g = Instance.new("UIGradient") + g.Rotation = 20 + g.Transparency = NumberSequence.new({ + NumberSequenceKeypoint.new(0, 1), + NumberSequenceKeypoint.new(0.42, 1), + NumberSequenceKeypoint.new(0.5, 0.45), + NumberSequenceKeypoint.new(0.58, 1), + NumberSequenceKeypoint.new(1, 1), + }) + g.Offset = Vector2.new(-1, 0) + g.Parent = s + local tw = TweenService:Create( + g, + TweenInfo.new(0.7, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, -1, false, period), + { Offset = Vector2.new(1, 0) } + ) + tw:Play() + return tw +end + +export type Button = { + button: TextButton, -- 누르는 영역(투명). Layout 사각형이 여기에 들어갑니다. + face: Frame, -- 색 있는 윗면 + base: Frame, -- 아래 그림자 판(입체감) + scale: UIScale, + setColor: (Color3) -> (), +} + +-- 입체 버튼: 아래로 DEPTH만큼 어두운 판이 보이고, 누르면 윗면이 내려가며 살짝 작아집니다. +local DEPTH = 5 + +function Theme.button(parent: Instance, name: string, color: Color3, radius: number, strokeK: number?): Button + local b = Instance.new("TextButton") + b.Name = name + b.BackgroundTransparency = 1 + b.AutoButtonColor = false + b.Text = "" + b.AutoLocalize = false + b.Parent = parent + local scale = Instance.new("UIScale") + scale.Parent = b + + local base = Theme.frame(b, "Base", Theme.darken(color, 0.45)) + base.Size = UDim2.new(1, 0, 1, -DEPTH) + base.Position = UDim2.fromOffset(0, DEPTH) + Theme.corner(base, radius) + Theme.stroke(base, Theme.INK, strokeK or 3) + + local face = Theme.frame(b, "Face", Theme.WHITE) + face.Size = UDim2.new(1, 0, 1, -DEPTH) + face.ZIndex = 2 + Theme.corner(face, radius) + Theme.stroke(face, Theme.INK, strokeK or 3) + -- 윗부분 반사광(흰 반투명 띠) + local gloss = Theme.frame(face, "Gloss", Theme.WHITE) + gloss.BackgroundTransparency = 0.72 + gloss.Size = UDim2.new(1, -10, 0.36, 0) + gloss.Position = UDim2.fromOffset(5, 4) + gloss.ZIndex = 3 + Theme.corner(gloss, math.max(4, radius - 4)) + + local function setColor(c: Color3) + Theme.gradient(face, Theme.lighten(c, 0.12), Theme.darken(c, 0.12)) + base.BackgroundColor3 = Theme.darken(c, 0.45) + end + setColor(color) + + local down = false + local hover = false + local function animate() + local target = if down then 0.92 elseif hover then 1.06 else 1 + TweenService:Create( + scale, + TweenInfo.new(if down then 0.06 else 0.18, if down then Enum.EasingStyle.Quad else Enum.EasingStyle.Back), + { Scale = target } + ):Play() + face.Position = UDim2.fromOffset(0, if down then DEPTH - 1 else 0) + end + b.MouseButton1Down:Connect(function() + down = true + animate() + end) + b.MouseButton1Up:Connect(function() + down = false + animate() + end) + b.InputBegan:Connect(function(input: InputObject) + -- 터치에서는 MouseEnter가 같이 와서, 마우스일 때만 커집니다. + if input.UserInputType == Enum.UserInputType.MouseMovement then + hover = true + animate() + end + end) + b.MouseLeave:Connect(function() + down = false + hover = false + animate() + end) + + return { button = b, face = face, base = base, scale = scale, setColor = setColor } +end + +-- 빨간 동그라미 알림 배지(예: 살 수 있는 업그레이드가 있으면 "!") +function Theme.badge(parent: Instance, name: string): (Frame, TextLabel) + local f = Theme.frame(parent, name, Theme.RED) + f.Size = UDim2.fromOffset(30, 30) + f.AnchorPoint = Vector2.new(0.5, 0.5) + f.Position = UDim2.new(1, -12, 0, 12) + f.ZIndex = 8 + Theme.corner(f, 1, 1) + Theme.stroke(f, Theme.INK, 2.5) + Theme.gradient(f, Color3.fromRGB(255, 110, 90), Color3.fromRGB(220, 40, 30)) + local t = Theme.text(f, "Text", false, 2) + t.Size = UDim2.new(1, -6, 1, -6) + t.Position = UDim2.fromOffset(3, 3) + t.ZIndex = 9 + return f, t +end + +return Theme diff --git a/bunsik-tycoon/src/server/Build.luau b/bunsik-tycoon/src/server/Build.luau index c36c6eb..aee6888 100644 --- a/bunsik-tycoon/src/server/Build.luau +++ b/bunsik-tycoon/src/server/Build.luau @@ -123,12 +123,14 @@ function Build.billboard(adornee: Instance, text: string, size: UDim2, offset: V label.Text = text label.Parent = gui if not color then + -- 주문 말풍선: 흰 바탕 둘레에 화면 UI와 같은 진한 갈색 테두리(Theme.INK) local corner = Instance.new("UICorner") corner.CornerRadius = UDim.new(0.3, 0) corner.Parent = label local stroke = Instance.new("UIStroke") stroke.Thickness = 3 - stroke.Color = Color3.fromRGB(255, 140, 60) + stroke.Color = Color3.fromRGB(59, 30, 18) + stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border stroke.Parent = label end return gui diff --git a/bunsik-tycoon/src/server/PlotController.luau b/bunsik-tycoon/src/server/PlotController.luau index da0b9d7..f76e9b7 100644 --- a/bunsik-tycoon/src/server/PlotController.luau +++ b/bunsik-tycoon/src/server/PlotController.luau @@ -346,12 +346,13 @@ local function floatText(parent: BasePart, text: string) local label = gui:FindFirstChild("Text") :: TextLabel local stroke = Instance.new("UIStroke") stroke.Thickness = 3 - stroke.Color = Color3.fromRGB(120, 60, 0) + stroke.Color = Color3.fromRGB(59, 30, 18) -- 화면 UI와 같은 진한 갈색(Theme.INK) + stroke.LineJoinMode = Enum.LineJoinMode.Round stroke.Parent = label TweenService:Create(gui, TweenInfo.new(1.2, Enum.EasingStyle.Quad), { StudsOffset = Vector3.new(0, 6, 0) }):Play() - TweenService:Create(label, TweenInfo.new(1.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In), { - TextTransparency = 1, - }):Play() + local fade = TweenInfo.new(1.2, Enum.EasingStyle.Quad, Enum.EasingDirection.In) + TweenService:Create(label, fade, { TextTransparency = 1 }):Play() + TweenService:Create(stroke, fade, { Transparency = 1 }):Play() task.delay(1.3, function() gui:Destroy() end) diff --git a/bunsik-tycoon/src/shared/Icons.luau b/bunsik-tycoon/src/shared/Icons.luau new file mode 100644 index 0000000..c8a08c5 --- /dev/null +++ b/bunsik-tycoon/src/shared/Icons.luau @@ -0,0 +1,52 @@ +--!strict +-- 화면 UI 아이콘. 그림 한 장(art/ui_icons.png, tools/icons.py로 직접 그림)을 128px 칸으로 잘라 씁니다. +-- 칸 순서를 바꾸면 tools/icons.py --luau 출력으로 아래 표를 다시 맞추고, 그림을 새로 올려 ASSET을 바꿉니다. + +local Icons = {} + +Icons.ASSET = "rbxassetid://89649261251254" +Icons.CELL = Vector2.new(128, 128) + +Icons.OFFSET = { + coin = Vector2.new(0, 0), + moneyBag = Vector2.new(128, 0), + bolt = Vector2.new(256, 0), + gear = Vector2.new(384, 0), + upgrade = Vector2.new(512, 0), + plate = Vector2.new(640, 0), + lock = Vector2.new(768, 0), + check = Vector2.new(896, 0), + close = Vector2.new(0, 128), + table = Vector2.new(128, 128), + sign = Vector2.new(256, 128), + flame = Vector2.new(384, 128), + sauce = Vector2.new(512, 128), + chef = Vector2.new(640, 128), + store = Vector2.new(768, 128), + tray = Vector2.new(896, 128), + Tteokbokki = Vector2.new(0, 256), + Gimbap = Vector2.new(128, 256), + Sundae = Vector2.new(256, 256), + Eomuk = Vector2.new(384, 256), + Twigim = Vector2.new(512, 256), + globe = Vector2.new(640, 256), + speaker = Vector2.new(768, 256), + mouse = Vector2.new(896, 256), + wrench = Vector2.new(0, 384), + star = Vector2.new(128, 384), + sparkle = Vector2.new(256, 384), + rays = Vector2.new(384, 384), + glow = Vector2.new(512, 384), + arrowDown = Vector2.new(640, 384), + scroll = Vector2.new(768, 384), + hand = Vector2.new(896, 384), +} :: { [string]: Vector2 } + +-- ImageLabel/ImageButton에 아이콘을 씌웁니다. +function Icons.apply(image: ImageLabel, name: string) + image.Image = Icons.ASSET + image.ImageRectOffset = Icons.OFFSET[name] or Vector2.zero + image.ImageRectSize = Icons.CELL +end + +return Icons diff --git a/bunsik-tycoon/src/shared/Locale.luau b/bunsik-tycoon/src/shared/Locale.luau index d8c692b..0cf370f 100644 --- a/bunsik-tycoon/src/shared/Locale.luau +++ b/bunsik-tycoon/src/shared/Locale.luau @@ -17,6 +17,8 @@ local STRINGS: { [string]: { [string]: string } } = { stage1 = "1단계 · 포장마차", stage2 = "2단계 · 실내 분식집", next = "다음", + nextUp = "다음 업그레이드", + doubleOn = "적용 중", close = "닫기", cookAction = "{menu} 만들기", cookWait = "손님 기다리는 중", @@ -106,6 +108,8 @@ local STRINGS: { [string]: { [string]: string } } = { stage1 = "Stage 1 · Street Stall", stage2 = "Stage 2 · Indoor Shop", next = "Next", + nextUp = "Next Upgrade", + doubleOn = "Active", close = "Close", cookAction = "Cook {menu}", cookWait = "Waiting for customers", @@ -195,6 +199,8 @@ local STRINGS: { [string]: { [string]: string } } = { stage1 = "ステージ1 · 屋台", stage2 = "ステージ2 · 室内のお店", next = "次", + nextUp = "次のアップグレード", + doubleOn = "適用中", close = "閉じる", cookAction = "{menu}を作る", cookWait = "お客さんを待っています", @@ -284,6 +290,8 @@ local STRINGS: { [string]: { [string]: string } } = { stage1 = "第1阶段 · 路边摊", stage2 = "第2阶段 · 室内小吃店", next = "下一个", + nextUp = "下一个升级", + doubleOn = "已生效", close = "关闭", cookAction = "制作{menu}", cookWait = "等待客人中", diff --git a/bunsik-tycoon/tests/cloud/dump_gui.luau b/bunsik-tycoon/tests/cloud/dump_gui.luau new file mode 100644 index 0000000..27b2969 --- /dev/null +++ b/bunsik-tycoon/tests/cloud/dump_gui.luau @@ -0,0 +1,236 @@ +-- 화면 UI를 여러 상황(기기 크기, 창 열림)으로 서버에서 만들어 JSON으로 덤프합니다. +-- python3 tools/cloud.py run tests/cloud/dump_gui.luau --version N → 출력의 JSON을 tools/gui_render.py로 그림 +local HttpService = game:GetService("HttpService") +local StarterPlayer = game:GetService("StarterPlayer") + +local Client = StarterPlayer.StarterPlayerScripts.Client +local Hud = require(Client.Hud) +local Layout = require(Client.Layout) +local Icons = require(game:GetService("ReplicatedStorage").Shared.Icons) + +local function c3(c: Color3): { number } + return { c.R, c.G, c.B } +end +local function ud(u: UDim): { number } + return { u.Scale, u.Offset } +end +local function ud2(u: UDim2): { { number } } + return { ud(u.X), ud(u.Y) } +end + +local function gradient(g: UIGradient): { [string]: any } + local colors = {} + for _, kp in g.Color.Keypoints do + table.insert(colors, { kp.Time, c3(kp.Value) }) + end + local trans = {} + for _, kp in g.Transparency.Keypoints do + table.insert(trans, { kp.Time, kp.Value }) + end + return { + Color = colors, + Transparency = trans, + Rotation = g.Rotation, + Offset = { g.Offset.X, g.Offset.Y }, + Enabled = g.Enabled, + } +end + +local function fontName(f: Font): string + return (f.Family:match("families/(.-)%.json") or "FredokaOne") +end + +local function dump(o: Instance, i: number): { [string]: any }? + if not o:IsA("GuiBase2d") then + return nil + end + local d: { [string]: any } = { ClassName = o.ClassName, Name = o.Name, _i = i } + if o:IsA("GuiObject") then + d.Visible = o.Visible + d.Size = ud2(o.Size) + d.Position = ud2(o.Position) + d.AnchorPoint = { o.AnchorPoint.X, o.AnchorPoint.Y } + d.Rotation = o.Rotation + d.ZIndex = o.ZIndex + d.LayoutOrder = o.LayoutOrder + d.BackgroundColor3 = c3(o.BackgroundColor3) + d.BackgroundTransparency = o.BackgroundTransparency + d.ClipsDescendants = o.ClipsDescendants + end + if o:IsA("ScrollingFrame") then + d.CanvasPosition = { o.CanvasPosition.X, o.CanvasPosition.Y } + end + if o:IsA("TextLabel") or o:IsA("TextButton") or o:IsA("TextBox") then + d.Text = o.Text + d.TextColor3 = c3(o.TextColor3) + d.TextTransparency = o.TextTransparency + d.TextScaled = o.TextScaled + d.TextWrapped = o.TextWrapped + d.TextSize = o.TextSize + d.TextXAlignment = o.TextXAlignment.Name + d.TextYAlignment = o.TextYAlignment.Name + d.TextStrokeTransparency = o.TextStrokeTransparency + d.TextStrokeColor3 = c3(o.TextStrokeColor3) + d.Font = fontName(o.FontFace) + d.Weight = o.FontFace.Weight.Name + end + if o:IsA("ImageLabel") or o:IsA("ImageButton") then + d.Image = o.Image + d.ImageColor3 = c3(o.ImageColor3) + d.ImageTransparency = o.ImageTransparency + d.ImageRectOffset = { o.ImageRectOffset.X, o.ImageRectOffset.Y } + d.ImageRectSize = { o.ImageRectSize.X, o.ImageRectSize.Y } + d.ScaleType = o.ScaleType.Name + end + local strokes = {} + local children = {} + for j, ch in o:GetChildren() do + if ch:IsA("UICorner") then + d.UICorner = ud(ch.CornerRadius) + elseif ch:IsA("UIStroke") then + local s: { [string]: any } = { + Color = c3(ch.Color), + Thickness = ch.Thickness, + Transparency = ch.Transparency, + ApplyStrokeMode = ch.ApplyStrokeMode.Name, + Enabled = ch.Enabled, + } + local g = ch:FindFirstChildOfClass("UIGradient") + if g then + s.UIGradient = gradient(g) + end + table.insert(strokes, s) + elseif ch:IsA("UIGradient") then + if ch.Enabled then + d.UIGradient = gradient(ch) + end + elseif ch:IsA("UIPadding") then + d.UIPadding = { + Left = ud(ch.PaddingLeft), + Right = ud(ch.PaddingRight), + Top = ud(ch.PaddingTop), + Bottom = ud(ch.PaddingBottom), + } + elseif ch:IsA("UIListLayout") then + d.UIListLayout = { + FillDirection = ch.FillDirection.Name, + Padding = ud(ch.Padding), + HorizontalAlignment = ch.HorizontalAlignment.Name, + VerticalAlignment = ch.VerticalAlignment.Name, + SortOrder = ch.SortOrder.Name, + } + elseif ch:IsA("UIScale") then + d.UIScale = ch.Scale + elseif ch:IsA("UIAspectRatioConstraint") then + d.UIAspectRatio = ch.AspectRatio + elseif ch:IsA("UITextSizeConstraint") then + d.MaxTextSize = ch.MaxTextSize + else + local cd = dump(ch, j) + if cd then + table.insert(children, cd) + end + end + end + if #strokes > 0 then + d.UIStrokes = strokes + end + d.children = children + return d +end + +local SHOTS = { + { + name = "phone_iphone15", + w = 750, + h = 332, + inset = 58, + touch = true, + attrs = { Money = 1234, Bought = 4, Carry = 1, Tut = 0 }, + }, + { name = "phone_tut", w = 750, h = 332, inset = 58, touch = true, attrs = { Money = 12, Bought = 0, Tut = 3 } }, + { + name = "phone_shop", + w = 750, + h = 332, + inset = 58, + touch = true, + attrs = { Money = 150, Bought = 5 }, + open = "Panel", + }, + { + name = "phone_settings", + w = 750, + h = 332, + inset = 58, + touch = true, + attrs = { Money = 150, Bought = 5 }, + open = "SettingsPanel", + }, + { name = "pc_1366", w = 1366, h = 710, inset = 58, touch = false, attrs = { Money = 1234, Bought = 4, Carry = 1 } }, + { + name = "pc_shop", + w = 1366, + h = 710, + inset = 58, + touch = false, + attrs = { Money = 760, Bought = 12, Double = true }, + open = "Panel", + }, + { + name = "pc_settings", + w = 1366, + h = 710, + inset = 58, + touch = false, + attrs = { Money = 760, Bought = 12, Dev = true }, + open = "SettingsPanel", + }, + { + name = "tablet_ipad", + w = 1024, + h = 710, + inset = 58, + touch = true, + attrs = { Money = 98765, Bought = 15, Carry = 2 }, + }, +} + +local shots = {} +for _, s in SHOTS do + local state = Instance.new("Folder") + state:SetAttribute("Lang", "ko") + state:SetAttribute("Ready", true) + for k, v in s.attrs do + state:SetAttribute(k, v) + end + local holder = Instance.new("Folder") + local hud = Hud.build(holder, state, function() end) + hud.setLayout(Vector2.new(s.w, s.h), s.touch) + if s.attrs.Tut == nil then + state:SetAttribute("Tut", 0) + end + if s.name == "phone_iphone15" or s.name == "pc_1366" then + hud.notify("purchased", { item = "Stove1" }) + end + if s.open then + hud.open(if s.open == "Panel" then "shop" else "settings") + end + hud.refresh() + task.wait(0.2) + local zones = Layout.touchZones(s.w, s.h) + table.insert(shots, { + name = s.name, + width = s.w, + height = s.h, + inset = s.inset, + touch = s.touch, + zones = zones, + gui = dump(hud.gui, 1), + }) + hud.destroy() +end + +local images = {} +images[Icons.ASSET:match("%d+")] = "art/ui_icons.png" +return HttpService:JSONEncode({ shots = shots, images = images }) diff --git a/bunsik-tycoon/tests/cloud/integration.luau b/bunsik-tycoon/tests/cloud/integration.luau index 9329708..f39ed91 100644 --- a/bunsik-tycoon/tests/cloud/integration.luau +++ b/bunsik-tycoon/tests/cloud/integration.luau @@ -398,6 +398,7 @@ eq( section("화면 UI(서버에서 생성)") local Hud = require(StarterPlayer.StarterPlayerScripts.Client.Hud) +local Icons = require(ReplicatedStorage.Shared.Icons) local state = Instance.new("Folder") state:SetAttribute("Lang", "ko") state:SetAttribute("Money", 25) @@ -409,33 +410,77 @@ local hud = Hud.build(holder, state, function(kind, arg) table.insert(sent, { kind, arg }) end) local root = hud.gui:FindFirstChild("Root") :: Frame -local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text") :: TextLabel -eq(moneyText.Text, "💰 25원", "돈 표시") -local nextTitle = root:FindFirstChild("Next"):FindFirstChild("Title") :: TextLabel -eq(nextTitle.Text, "다음: 김밥 해금", "다음 업그레이드") +local function label(o: Instance?): string? + local t = o and o:FindFirstChild("Label", true) :: TextLabel? + return t and t.Text +end +local moneyText = root:FindFirstChild("Money"):FindFirstChild("Text", true) :: TextLabel +eq(moneyText.Text, "25원", "돈 표시") +local nextCard = root:FindFirstChild("Next") :: Frame +local nextTitle = nextCard:FindFirstChild("Title", true) :: TextLabel +eq(nextTitle.Text, "김밥 해금", "다음 업그레이드") +eq( + (nextCard:FindFirstChild("Tab", true):FindFirstChild("Text") :: TextLabel).Text, + "다음 업그레이드", + "카드 이름표" +) +local nextIcon = nextCard:FindFirstChild("IconBox", true):FindFirstChild("Icon") :: ImageLabel +eq(nextIcon.Image, Icons.ASSET, "다음 업그레이드 아이콘 그림") +eq(nextIcon.ImageRectOffset, Icons.OFFSET.Gimbap, "김밥 해금 아이콘") check((root:FindFirstChild("Hint") :: Frame).Visible, "튜토리얼 안내 보임") +check((nextCard:FindFirstChild("Pointer") :: ImageLabel).Visible, "튜토리얼 3: [사기] 가리키는 손") +local buyBtn = nextCard:FindFirstChild("Buy") :: TextButton +eq(label(buyBtn), "사기", "사기 버튼 글자") +check(not (buyBtn:FindFirstChild("Shine", true) :: Frame).Visible, "돈이 모자라면 반짝임 없음") +local listButton = root:FindFirstChild("ListButton") :: TextButton +check(not (listButton:FindFirstChild("Badge") :: Frame).Visible, "돈이 모자라면 업그레이드 배지 없음") +state:SetAttribute("Money", 60) +check((buyBtn:FindFirstChild("Shine", true) :: Frame).Visible, "살 수 있으면 [사기] 반짝임") +check((listButton:FindFirstChild("Badge") :: Frame).Visible, "살 수 있으면 업그레이드 버튼에 ! 배지") +check(root:FindFirstChild("Gain") ~= nil, "돈이 늘면 +돈 글자가 떠오름") +eq((root:FindFirstChild("Gain") :: TextLabel).Text, "+35원", "늘어난 돈") +for _, d in Icons.OFFSET do + check(d.X % 128 == 0 and d.Y % 128 == 0 and d.X < 1024 and d.Y < 1024, "아이콘 칸 위치") +end state:SetAttribute("Lang", "en") -eq(moneyText.Text, "💰 ₩25", "영어 돈 표시") -eq(nextTitle.Text, "Next: Unlock Gimbap", "영어 다음 업그레이드") +eq(moneyText.Text, "₩60", "영어 돈 표시") +eq(nextTitle.Text, "Unlock Gimbap", "영어 다음 업그레이드") state:SetAttribute("Lang", "zh") -eq(nextTitle.Text, "下一个: 解锁紫菜包饭", "중국어 다음 업그레이드") +eq(nextTitle.Text, "解锁紫菜包饭", "중국어 다음 업그레이드") state:SetAttribute("Lang", "en") -check(root:FindFirstChild("Lang") == nil, "언어 버튼 대신") local settingsBtn = root:FindFirstChild("Settings") :: TextButton check(settingsBtn ~= nil, "오른쪽 위 설정 버튼") -eq(settingsBtn and settingsBtn.Text, "⚙️ Settings", "설정 버튼 글자") +eq(label(settingsBtn), "Settings", "설정 버튼 글자") local settingsPanel = root:FindFirstChild("SettingsPanel") :: Frame check(settingsPanel ~= nil and not settingsPanel.Visible, "설정 창은 처음엔 닫힘") for _, l in { "auto", "ko", "en", "ja", "zh" } do check(settingsPanel:FindFirstChild("Lang_" .. l) ~= nil, `설정 창 언어 버튼 {l}`) end -eq((settingsPanel:FindFirstChild("Lang_ja") :: TextButton).Text, "日本語", "언어 이름은 그 나라 말") -eq((settingsPanel:FindFirstChild("MouseLook") :: TextButton).Text, "On", "마우스 회전 기본 켜짐") +eq(label(settingsPanel:FindFirstChild("Lang_ja")), "日本語", "언어 이름은 그 나라 말") +eq(label(settingsPanel:FindFirstChild("MouseLook")), "On", "마우스 회전 기본 켜짐") state:SetAttribute("Sfx", false) -eq((settingsPanel:FindFirstChild("Sfx") :: TextButton).Text, "Off", "효과음 끔 표시") +eq(label(settingsPanel:FindFirstChild("Sfx")), "Off", "효과음 끔 표시") check(not hud.menuOpen(), "창 닫힘") +hud.open("shop") +check(hud.menuOpen() and (root:FindFirstChild("Panel") :: Frame).Visible, "업그레이드 창 열기") +check((root:FindFirstChild("Dim") :: Frame).Visible, "창 뒤 어둡게") +local rowsFrame = root:FindFirstChild("Panel"):FindFirstChild("List", true) :: ScrollingFrame +check( + rowsFrame:FindFirstChild("Row2"):FindFirstChild("BuyRow") ~= nil, + "목록의 다음 업그레이드에 사기 버튼" +) +check(rowsFrame:FindFirstChild("Row1"):FindFirstChild("Done") ~= nil, "산 업그레이드는 체크 표시") +check( + rowsFrame:FindFirstChild("Row5"):FindFirstChild("IconBox"):FindFirstChild("Lock") ~= nil, + "잠긴 업그레이드 자물쇠" +) +hud.open("settings") +check(settingsPanel.Visible and not (root:FindFirstChild("Panel") :: Frame).Visible, "창은 하나만 열림") +hud.open(nil) +check(not hud.menuOpen() and not (root:FindFirstChild("Dim") :: Frame).Visible, "창 닫기") state:SetAttribute("Bought", #Economy.PURCHASES) -check(not (root:FindFirstChild("Next"):FindFirstChild("Buy") :: TextButton).Visible, "다 사면 사기 버튼 숨김") +check(not buyBtn.Visible, "다 사면 사기 버튼 숨김") +check(not (root:FindFirstChild("Boost") :: TextButton).Visible, "다 사면 돈 부스트 숨김") check(root:FindFirstChild("Dev") == nil, "개발자 버튼은 설정 창 안으로") local devMoneyBtn = settingsPanel:FindFirstChild("devMoney") :: TextButton check(not devMoneyBtn.Visible, "개발자 버튼은 기본으로 숨김") @@ -443,10 +488,20 @@ local setH = settingsPanel.Size.Y.Offset state:SetAttribute("Dev", true) check(devMoneyBtn.Visible, "게임 주인에게 개발자 버튼(설정 창)") check(settingsPanel.Size.Y.Offset > setH, "개발자 줄만큼 설정 창이 길어짐") -check((root:FindFirstChild("Double") :: TextButton).Visible, "2배 수익 버튼(상품 ID 설정됨)") +local doubleBtn = root:FindFirstChild("Double") :: TextButton +check(doubleBtn.Visible, "2배 수익 버튼(상품 ID 설정됨)") +eq(label(doubleBtn), "Double Money", "2배 수익 버튼 글자") +state:SetAttribute("Double", true) +eq(label(doubleBtn), "Active", "2배 수익 산 뒤") +check((doubleBtn:FindFirstChild("Owned") :: ImageLabel).Visible, "2배 수익 산 뒤 체크") hud.notify("purchased", { item = "Table2" }) local toastText = root.Toasts:FindFirstChild("Toast"):FindFirstChild("Text") :: TextLabel eq(toastText.Text, "Table 2 bought!", "구매 알림에 업그레이드 이름(내 언어)") +eq( + (root.Toasts:FindFirstChild("Toast"):FindFirstChild("Icon") :: ImageLabel).ImageRectOffset, + Icons.OFFSET.check, + "구매 알림 아이콘" +) -- 휴대폰 배치(아이폰 15 가로, 상단 바·노치 뺀 영역): 루트가 화면을 채우고, 결제 버튼은 왼쪽 위, 마우스 줄 숨김 hud.setLayout(Vector2.new(750, 332), true) local lay = hud.layout() @@ -460,10 +515,11 @@ check( "휴대폰: 루트 높이 = 화면" ) eq( - (root:FindFirstChild("Double") :: TextButton).Position.Y.Offset, - lay.double.y, - "휴대폰: 2배 수익 버튼 위치" + doubleBtn.Position.Y.Offset, + lay.double.y + lay.double.h / 2, + "휴대폰: 2배 수익 버튼 위치(가운데 기준)" ) +eq(doubleBtn.Size.Y.Offset, lay.double.h, "휴대폰: 2배 수익 버튼 크기") check(lay.double.y + lay.double.h < lay.height / 3, "휴대폰: 결제 버튼은 조이스틱 자리 위") check(not (settingsPanel:FindFirstChild("MouseLook") :: TextButton).Visible, "휴대폰: 마우스 회전 줄 숨김") check(scaleObj.Scale > 0.8, `휴대폰: 글자 배율 {scaleObj.Scale}`) @@ -500,6 +556,20 @@ for name, id in Sounds do end end +section("UI 아이콘 그림(직접 그린 이미지 에셋)") +do + local Icons = require(ReplicatedStorage.Shared.Icons) + local num = tonumber(string.match(Icons.ASSET, "%d+")) + local okInfo, info = pcall(function() + return game:GetService("MarketplaceService"):GetProductInfoAsync(num :: number, Enum.InfoType.Asset) + end) + check(okInfo, "아이콘 그림 정보 조회") + if okInfo then + eq(info.AssetTypeId, 1, "아이콘 그림은 이미지") + eq(info.Creator.CreatorTargetId, game.CreatorId, "아이콘 그림은 게임 주인 소유") + end +end + section("Products") local Products = require(ReplicatedStorage.Shared.Products) local MarketplaceService = game:GetService("MarketplaceService") diff --git a/bunsik-tycoon/tools/gui_render.py b/bunsik-tycoon/tools/gui_render.py new file mode 100644 index 0000000..bb744bc --- /dev/null +++ b/bunsik-tycoon/tools/gui_render.py @@ -0,0 +1,488 @@ +#!/usr/bin/env python3 +"""화면 UI 미리보기 그리기: 로블록스 서버에서 만든 ScreenGui를 JSON으로 덤프한 것(tests/cloud/dump_gui.luau)을 +cairo로 그립니다. 서버에서는 실제 화면을 볼 수 없어서 배치·색·글자 크기를 눈으로 확인하는 용도입니다. +로블록스 렌더러와 똑같지는 않습니다(글꼴 대체, 글자 크기 맞춤, 3D 배경 없음). + +지원: Frame/TextLabel/TextButton/ImageLabel/ImageButton/ScrollingFrame, UDim2·AnchorPoint·Rotation·ZIndex, +UICorner, UIStroke(테두리·글자), UIGradient(색·투명도·회전·오프셋), UIPadding, UIListLayout, UIScale, +UITextSizeConstraint, TextScaled/TextWrapped/정렬, ImageRectOffset/Size, ClipsDescendants. + + python3 tools/gui_render.py dump.json out_dir [--bg scene.png] +""" +import json +import math +import os +import sys + +import ctypes + +import cairo + +ROOT_UNUSED = None + + +class _Rect(ctypes.Structure): + _fields_ = [("x", ctypes.c_int), ("y", ctypes.c_int), ("width", ctypes.c_int), ("height", ctypes.c_int)] + + +class PangoLib: + """python3-gi-cairo가 없어서 libpangocairo를 ctypes로 직접 부릅니다(쓰는 함수만).""" + + SCALE = 1024 + + def __init__(self): + self.pc = ctypes.CDLL("libpangocairo-1.0.so.0") + self.p = ctypes.CDLL("libpango-1.0.so.0") + self.g = ctypes.CDLL("libgobject-2.0.so.0") + vp, ci, cs = ctypes.c_void_p, ctypes.c_int, ctypes.c_char_p + for lib, name, res, args in ( + (self.pc, "pango_cairo_create_layout", vp, [vp]), + (self.pc, "pango_cairo_show_layout", None, [vp, vp]), + (self.pc, "pango_cairo_layout_path", None, [vp, vp]), + (self.p, "pango_layout_set_text", None, [vp, cs, ci]), + (self.p, "pango_layout_set_width", None, [vp, ci]), + (self.p, "pango_layout_set_wrap", None, [vp, ci]), + (self.p, "pango_layout_set_alignment", None, [vp, ci]), + (self.p, "pango_layout_set_font_description", None, [vp, vp]), + (self.p, "pango_layout_get_pixel_extents", None, [vp, ctypes.POINTER(_Rect), ctypes.POINTER(_Rect)]), + (self.p, "pango_layout_get_line_count", ci, [vp]), + (self.p, "pango_font_description_from_string", vp, [cs]), + (self.p, "pango_font_description_set_weight", None, [vp, ci]), + (self.p, "pango_font_description_set_absolute_size", None, [vp, ctypes.c_double]), + (self.p, "pango_font_description_free", None, [vp]), + (self.g, "g_object_unref", None, [vp]), + ): + f = getattr(lib, name) + f.restype = res + f.argtypes = args + + @staticmethod + def cr(ctx): + # pycairo Context 객체 안의 cairo_t 포인터(PyObject 머리 16바이트 다음) + return ctypes.c_void_p.from_address(id(ctx) + 16).value + + +PANGO = PangoLib() +ALIGN = {"Left": 0, "Center": 1, "Right": 2} +WEIGHT = {"SemiBold": 600, "Bold": 700, "Heavy": 900, "Black": 900} + + +class Layout: + def __init__(self, ctx, family, weight, size, text, width, wrap, align): + P = PANGO + self.ctx = ctx + self.ptr = P.pc.pango_cairo_create_layout(P.cr(ctx)) + desc = P.p.pango_font_description_from_string(f"{family}, {FALLBACK}".encode()) + P.p.pango_font_description_set_weight(desc, weight) + P.p.pango_font_description_set_absolute_size(desc, max(1.0, size) * P.SCALE) + P.p.pango_layout_set_font_description(self.ptr, desc) + P.p.pango_font_description_free(desc) + P.p.pango_layout_set_text(self.ptr, text.encode(), -1) + if wrap: + P.p.pango_layout_set_width(self.ptr, int(max(1, width) * P.SCALE)) + P.p.pango_layout_set_wrap(self.ptr, 2) # WORD_CHAR + P.p.pango_layout_set_alignment(self.ptr, ALIGN.get(align, 1)) + + def extents(self): + ink, logical = _Rect(), _Rect() + PANGO.p.pango_layout_get_pixel_extents(self.ptr, ctypes.byref(ink), ctypes.byref(logical)) + return ink, logical + + def lines(self): + return PANGO.p.pango_layout_get_line_count(self.ptr) + + def path(self, ctx): + PANGO.pc.pango_cairo_layout_path(PANGO.cr(ctx), self.ptr) + + def show(self, ctx): + PANGO.pc.pango_cairo_show_layout(PANGO.cr(ctx), self.ptr) + + def __del__(self): + PANGO.g.g_object_unref(self.ptr) + + +ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +IMAGES = {} # rbxassetid 숫자 -> 로컬 png 경로 (Icons.luau의 ID와 art/ui_icons.png) + +FONT_FAMILY = { + "FredokaOne": "Fredoka SemiBold", + "LuckiestGuy": "Luckiest Guy", + "Bangers": "Luckiest Guy", + "GothamBlack": "Noto Sans Black", + "BuilderSans": "Noto Sans", + "Montserrat": "Noto Sans", +} +# 한글·한자·이모지는 로블록스도 대체 글꼴로 그립니다. +FALLBACK = "Noto Sans CJK KR, Noto Color Emoji" + + +def surface_png(path): + return cairo.ImageSurface.create_from_png(path) + + +_img_cache = {} + + +def image_surface(asset): + num = "".join(ch for ch in str(asset) if ch.isdigit()) + path = IMAGES.get(num) + if not path: + return None + if path not in _img_cache: + _img_cache[path] = surface_png(path) + return _img_cache[path] + + +def udim(u, size, k): + return u[0] * size + u[1] * k + + +def round_rect(c, x, y, w, h, r): + r = max(0, min(r, w / 2, h / 2)) + if r <= 0.01: + c.rectangle(x, y, w, h) + return + c.new_sub_path() + c.arc(x + w - r, y + r, r, -math.pi / 2, 0) + c.arc(x + w - r, y + h - r, r, 0, math.pi / 2) + c.arc(x + r, y + h - r, r, math.pi / 2, math.pi) + c.arc(x + r, y + r, r, math.pi, 3 * math.pi / 2) + c.close_path() + + +def gradient_pattern(g, x, y, w, h, base, alpha): + """UIGradient를 cairo 패턴으로. base(색)·alpha(불투명도)에 곱합니다.""" + rot = math.radians(g.get("Rotation", 0)) + ox, oy = g.get("Offset", [0, 0]) + cx, cy = x + w / 2 + ox * w, y + h / 2 + oy * h + dx, dy = math.cos(rot), math.sin(rot) + # 회전된 방향으로 상자를 덮는 길이 + half = (abs(dx) * w + abs(dy) * h) / 2 + pat = cairo.LinearGradient(cx - dx * half, cy - dy * half, cx + dx * half, cy + dy * half) + colors = g.get("Color") or [[0, [1, 1, 1]], [1, [1, 1, 1]]] + trans = g.get("Transparency") or [[0, 0], [1, 0]] + times = sorted(set([t for t, _ in colors] + [t for t, _ in trans])) + + def at(seq, t): + for i in range(len(seq) - 1): + t0, v0 = seq[i] + t1, v1 = seq[i + 1] + if t0 <= t <= t1: + f = 0 if t1 == t0 else (t - t0) / (t1 - t0) + if isinstance(v0, list): + return [v0[j] + (v1[j] - v0[j]) * f for j in range(3)] + return v0 + (v1 - v0) * f + return seq[-1][1] if t >= seq[-1][0] else seq[0][1] + + for t in times: + col = at(colors, t) + tr = at(trans, t) + pat.add_color_stop_rgba(t, base[0] * col[0], base[1] * col[1], base[2] * col[2], alpha * (1 - tr)) + return pat + + +class Renderer: + def __init__(self, c): + self.c = c + + # ---------------------------------------------------------------- 배치 + def children_rects(self, node, rect, k): + """자식 GuiObject의 (자식, x, y, w, h, k) 목록. UIListLayout·UIPadding·UIScale 반영.""" + x, y, w, h = rect + pad = node.get("UIPadding") + if pad: + pl = udim(pad["Left"], w, k) + pr = udim(pad["Right"], w, k) + pt = udim(pad["Top"], h, k) + pb = udim(pad["Bottom"], h, k) + x, y, w, h = x + pl, y + pt, w - pl - pr, h - pt - pb + out = [] + kids = [ch for ch in node.get("children", []) if ch.get("Visible", True)] + for ch in kids: + s = ch.get("UIScale", 1) + cw = udim(ch["Size"][0], w, k) * s + chh = udim(ch["Size"][1], h, k) * s + ar = ch.get("UIAspectRatio") + if ar: + if cw / max(chh, 1e-6) > ar: + cw = chh * ar + else: + chh = cw / ar + out.append([ch, cw, chh, k * s]) + lay = node.get("UIListLayout") + if lay: + horiz = lay.get("FillDirection") == "Horizontal" + gap = udim(lay.get("Padding", [0, 0]), w if horiz else h, k) + items = sorted(out, key=lambda o: (o[0].get("LayoutOrder", 0), o[0].get("_i", 0))) \ + if lay.get("SortOrder") == "LayoutOrder" else sorted(out, key=lambda o: o[0].get("Name", "")) + total = sum((o[1] if horiz else o[2]) for o in items) + gap * max(0, len(items) - 1) + ha = lay.get("HorizontalAlignment", "Left") + va = lay.get("VerticalAlignment", "Top") + if horiz: + cur = x + {"Left": 0, "Center": (w - total) / 2, "Right": w - total}[ha] + else: + cur = y + {"Top": 0, "Center": (h - total) / 2, "Bottom": h - total}[va] + res = [] + for ch, cw, chh, kk in items: + if horiz: + cy = y + {"Top": 0, "Center": (h - chh) / 2, "Bottom": h - chh}[va] + res.append((ch, cur, cy, cw, chh, kk)) + cur += cw + gap + else: + cx = x + {"Left": 0, "Center": (w - cw) / 2, "Right": w - cw}[ha] + res.append((ch, cx, cur, cw, chh, kk)) + cur += chh + gap + return res + res = [] + for ch, cw, chh, kk in out: + s = ch.get("UIScale", 1) + # UIScale은 AnchorPoint를 기준으로 크기를 바꿉니다. + bw, bh = cw / s, chh / s + ax, ay = ch.get("AnchorPoint", [0, 0]) + px = x + udim(ch["Position"][0], w, k) - ax * bw + py = y + udim(ch["Position"][1], h, k) - ay * bh + px -= (cw - bw) * ax + py -= (chh - bh) * ay + res.append((ch, px, py, cw, chh, kk)) + return res + + # ---------------------------------------------------------------- 그리기 + def draw_node(self, node, x, y, w, h, k): + c = self.c + c.save() + rot = node.get("Rotation", 0) + if rot: + c.translate(x + w / 2, y + h / 2) + c.rotate(math.radians(rot)) + c.translate(-(x + w / 2), -(y + h / 2)) + corner = node.get("UICorner") + r = udim(corner, min(w, h), k) if corner else 0 + grad = node.get("UIGradient") + bt = node.get("BackgroundTransparency", 1) + if bt < 1 and node["ClassName"] not in ("ScreenGui",): + base = node.get("BackgroundColor3", [1, 1, 1]) + round_rect(c, x, y, w, h, r) + if grad: + c.set_source(gradient_pattern(grad, x, y, w, h, base, 1 - bt)) + else: + c.set_source_rgba(*base, 1 - bt) + c.fill() + img = node.get("Image") + if img: + self.draw_image(node, x, y, w, h, r, grad) + if "Text" in node and node.get("Text"): + self.draw_text(node, x, y, w, h, k, grad) + for st in node.get("UIStrokes", []): + if st.get("ApplyStrokeMode") == "Border" and st.get("Enabled", True): + t = st["Thickness"] * k + round_rect(c, x - t / 2, y - t / 2, w + t, h + t, r + t / 2 if r > 0 else 0) + c.set_line_width(t) + c.set_line_join(cairo.LINE_JOIN_ROUND) + sg = st.get("UIGradient") + if sg: + c.set_source(gradient_pattern(sg, x, y, w, h, st["Color"], 1 - st.get("Transparency", 0))) + else: + c.set_source_rgba(*st["Color"], 1 - st.get("Transparency", 0)) + c.stroke() + if node.get("ClipsDescendants") or node["ClassName"] == "ScrollingFrame": + round_rect(c, x, y, w, h, r) + c.clip() + cpx, cpy = node.get("CanvasPosition", [0, 0]) + kids = self.children_rects(node, (x - cpx * k, y - cpy * k, w, h), k) + kids.sort(key=lambda t: (t[0].get("ZIndex", 1), t[0].get("_i", 0))) + for ch, cx, cy, cw, chh, kk in kids: + self.draw_node(ch, cx, cy, cw, chh, kk) + c.restore() + + def draw_image(self, node, x, y, w, h, r, grad): + surf = image_surface(node["Image"]) + c = self.c + if surf is None: + c.rectangle(x, y, w, h) + c.set_source_rgba(1, 0, 1, 0.5) + c.fill() + return + ox, oy = node.get("ImageRectOffset", [0, 0]) + sw, sh = node.get("ImageRectSize", [0, 0]) + if sw == 0 or sh == 0: + sw, sh = surf.get_width(), surf.get_height() + dw, dh = w, h + if node.get("ScaleType") == "Fit": + s = min(w / sw, h / sh) + dw, dh = sw * s, sh * s + dx, dy = x + (w - dw) / 2, y + (h - dh) / 2 + c.save() + round_rect(c, x, y, w, h, r) + c.clip() + c.translate(dx, dy) + c.scale(dw / sw, dh / sh) + c.translate(-ox, -oy) + alpha = 1 - node.get("ImageTransparency", 0) + col = node.get("ImageColor3", [1, 1, 1]) + c.rectangle(ox, oy, sw, sh) + c.clip() + if col != [1, 1, 1] or grad: + # 색 곱하기: 그림을 마스크로 쓰고 색을 곱한 그림을 그립니다. + tmp = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(sw), int(sh)) + tc = cairo.Context(tmp) + tc.set_source_surface(surf, -ox, -oy) + tc.paint() + tc.set_operator(cairo.OPERATOR_MULTIPLY) + if grad: + tc.set_source(gradient_pattern(grad, 0, 0, sw, sh, col, 1)) + else: + tc.set_source_rgb(*col) + tc.paint() + tc.set_operator(cairo.OPERATOR_DEST_IN) + tc.set_source_surface(surf, -ox, -oy) + tc.paint() + c.set_source_surface(tmp, ox, oy) + else: + c.set_source_surface(surf, 0, 0) + c.get_source().set_filter(cairo.FILTER_GOOD) + c.paint_with_alpha(alpha) + c.restore() + + def layout_text(self, node, size, width, wrap): + fam = FONT_FAMILY.get(node.get("Font", "FredokaOne"), "Noto Sans") + weight = WEIGHT.get(node.get("Weight", ""), 400) + if fam.startswith("Fredoka"): + weight = 600 + elif "Black" in fam: + weight = 900 + align = node.get("TextXAlignment", "Center") + return Layout(self.c, fam.replace(" SemiBold", "").replace(" Black", ""), weight, size, node["Text"], width, + wrap, align) + + def draw_text(self, node, x, y, w, h, k, grad): + c = self.c + pad = node.get("UIPadding") + if pad: + pl, pr = udim(pad["Left"], w, k), udim(pad["Right"], w, k) + pt, pb = udim(pad["Top"], h, k), udim(pad["Bottom"], h, k) + x, y, w, h = x + pl, y + pt, w - pl - pr, h - pt - pb + wrap = node.get("TextWrapped", False) or node.get("TextScaled", False) + maxsize = node.get("MaxTextSize", 100) + if node.get("TextScaled"): + lo, hi = 1, min(maxsize, 100) * k + best = lo + while hi - lo > 0.5: + mid = (lo + hi) / 2 + lay = self.layout_text(node, mid, w, wrap) + ink, logical = lay.extents() + # 단어 중간에서 줄이 끊기면 안 맞는 것으로 봅니다(로블록스 TextScaled와 비슷하게). + words_ok = lay.lines() <= max(1, len(node["Text"].split())) + node["Text"].count("\n") + if logical.width <= w + 0.5 and logical.height <= h + 0.5 and words_ok: + best = mid + lo = mid + else: + hi = mid + size = best + else: + size = node.get("TextSize", 14) * k + lay = self.layout_text(node, size, w, wrap) + ink, logical = lay.extents() + ya = node.get("TextYAlignment", "Center") + ty = y + {"Top": 0, "Center": (h - logical.height) / 2, "Bottom": h - logical.height}[ya] + tx = x + if not wrap: + xa = node.get("TextXAlignment", "Center") + tx = x + {"Left": 0, "Center": (w - logical.width) / 2, "Right": w - logical.width}[xa] + c.save() + c.move_to(tx, ty) + lay.path(c) + alpha = 1 - node.get("TextTransparency", 0) + for st in node.get("UIStrokes", []): + if st.get("ApplyStrokeMode", "Contextual") == "Contextual" and st.get("Enabled", True): + c.set_line_width(st["Thickness"] * k * 2) + c.set_line_join(cairo.LINE_JOIN_ROUND) + c.set_source_rgba(*st["Color"], alpha * (1 - st.get("Transparency", 0))) + c.stroke_preserve() + if node.get("TextStrokeTransparency", 1) < 1: + c.set_line_width(2 * k) + c.set_source_rgba(*node.get("TextStrokeColor3", [0, 0, 0]), alpha * (1 - node["TextStrokeTransparency"])) + c.stroke_preserve() + c.new_path() + c.restore() + # 글자 채우기(이모지 색을 살리려고 path 대신 show_layout) + c.save() + col = node.get("TextColor3", [0, 0, 0]) + if grad and node.get("TextGradient", True): + c.push_group() + c.move_to(tx, ty) + c.set_source_rgba(1, 1, 1, alpha) + lay.show(c) + mask = c.pop_group() + c.set_source(gradient_pattern(grad, x, y, w, h, col, 1)) + c.mask(mask) + else: + c.move_to(tx, ty) + c.set_source_rgba(*col, alpha) + lay.show(c) + c.restore() + + +def render(dump, out, bg=None): + W, H, inset = dump["width"], dump["height"], dump.get("inset", 0) + surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(W), int(H + inset)) + c = cairo.Context(surf) + if bg and os.path.exists(bg): + b = surface_png(bg) + c.save() + c.scale(W / b.get_width(), (H + inset) / b.get_height()) + c.set_source_surface(b, 0, 0) + c.paint() + c.restore() + else: + g = cairo.LinearGradient(0, 0, 0, H + inset) + g.add_color_stop_rgb(0, 0.55, 0.78, 0.95) + g.add_color_stop_rgb(0.55, 0.75, 0.88, 0.98) + g.add_color_stop_rgb(0.56, 0.42, 0.66, 0.36) + g.add_color_stop_rgb(1, 0.33, 0.55, 0.28) + c.set_source(g) + c.paint() + # 로블록스 상단 바(대략) + if inset: + c.set_source_rgba(0, 0, 0, 0.25) + for i, x in enumerate((12, 60)): + round_rect(c, x, 10, 40, 40, 10) + c.fill() + touch = dump.get("touch") + if touch and dump.get("zones"): + for z in dump["zones"].values(): + c.set_source_rgba(1, 1, 1, 0.12) + c.rectangle(z["x"], z["y"] + inset, z["w"], z["h"]) + c.fill() + # 조이스틱·점프 버튼 모양(대략) + st = dump["zones"]["stick"] + c.arc(st["x"] + 110, inset + H - 110, 60, 0, 2 * math.pi) + c.set_source_rgba(0, 0, 0, 0.3) + c.fill() + jp = dump["zones"]["jump"] + jr = min(jp["w"], jp["h"]) * 0.3 + c.arc(jp["x"] + jp["w"] * 0.55, inset + jp["y"] + jp["h"] * 0.55, jr, 0, 2 * math.pi) + c.fill() + r = Renderer(c) + gui = dump["gui"] + c.translate(0, inset) + for ch, x, y, w, h, k in r.children_rects(gui, (0, 0, W, H), 1): + r.draw_node(ch, x, y, w, h, k) + surf.write_to_png(out) + + +def main(argv): + src, outdir = argv[0], argv[1] + bg = argv[argv.index("--bg") + 1] if "--bg" in argv else None + with open(src) as f: + data = json.load(f) + for num, path in data.get("images", {}).items(): + IMAGES[str(num)] = os.path.join(ROOT, path) + os.makedirs(outdir, exist_ok=True) + for shot in data["shots"]: + out = os.path.join(outdir, shot["name"] + ".png") + render(shot, out, bg) + print(out) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/bunsik-tycoon/tools/icons.py b/bunsik-tycoon/tools/icons.py new file mode 100644 index 0000000..455e34a --- /dev/null +++ b/bunsik-tycoon/tools/icons.py @@ -0,0 +1,719 @@ +#!/usr/bin/env python3 +"""화면 UI 아이콘 모음(1024x1024, 128px 칸 8x8)을 직접 그립니다. 외부 그림을 쓰지 않습니다. +로블록스에는 이 한 장만 올리고, 각 아이콘은 ImageRectOffset/ImageRectSize로 잘라 씁니다. +칸 이름과 위치는 src/shared/Icons.luau 와 같아야 합니다(tools/icons.py --luau 로 확인). + + python3 tools/icons.py # art/ui_icons.png + python3 tools/icons.py --sheet x.png # 이름표가 붙은 확인용 그림 +""" +import math +import os +import sys + +import cairo + +OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "art", "ui_icons.png") +CELL = 128 +GRID = 8 +INK = (0.23, 0.12, 0.07) # 테두리(진한 갈색) +LW = 7 # 테두리 굵기 + + +def rgb(h): + h = h.lstrip("#") + return tuple(int(h[i:i + 2], 16) / 255 for i in (0, 2, 4)) + + +def lin(x0, y0, x1, y1, *stops): + g = cairo.LinearGradient(x0, y0, x1, y1) + for i, c in enumerate(stops): + g.add_color_stop_rgb(i / max(1, len(stops) - 1), *rgb(c)) + return g + + +def rad(cx, cy, r, *stops): + g = cairo.RadialGradient(cx - r * 0.3, cy - r * 0.35, r * 0.1, cx, cy, r) + for i, c in enumerate(stops): + g.add_color_stop_rgb(i / max(1, len(stops) - 1), *rgb(c)) + return g + + +def fill_stroke(c, paint, lw=LW): + c.set_source(paint) if isinstance(paint, cairo.Pattern) else c.set_source_rgb(*paint) + c.fill_preserve() + c.set_source_rgb(*INK) + c.set_line_width(lw) + c.set_line_join(cairo.LINE_JOIN_ROUND) + c.set_line_cap(cairo.LINE_CAP_ROUND) + c.stroke() + + +def rrect(c, x, y, w, h, r): + c.new_sub_path() + c.arc(x + w - r, y + r, r, -math.pi / 2, 0) + c.arc(x + w - r, y + h - r, r, 0, math.pi / 2) + c.arc(x + r, y + h - r, r, math.pi / 2, math.pi) + c.arc(x + r, y + r, r, math.pi, 3 * math.pi / 2) + c.close_path() + + +def shine(c, x, y, w, h, alpha=0.55): + """왼쪽 위 흰 반사광(타원 조각).""" + c.save() + c.translate(x, y) + c.scale(w, h) + c.arc(0, 0, 1, 0, 2 * math.pi) + c.restore() + c.set_source_rgba(1, 1, 1, alpha) + c.fill() + + +def polygon(c, pts): + c.move_to(*pts[0]) + for p in pts[1:]: + c.line_to(*p) + c.close_path() + + +def star_pts(cx, cy, r1, r2, n=5, rot=-math.pi / 2): + pts = [] + for i in range(n * 2): + r = r1 if i % 2 == 0 else r2 + a = rot + i * math.pi / n + pts.append((cx + r * math.cos(a), cy + r * math.sin(a))) + return pts + + +# ---------------------------------------------------------------- 아이콘들 (64x64 중심, 128 칸) + +def coin(c): + c.arc(64, 66, 50, 0, 2 * math.pi) + fill_stroke(c, rad(64, 66, 56, "#fff3a0", "#ffd23a", "#f59e0b")) + c.arc(64, 66, 36, 0, 2 * math.pi) + c.set_source(lin(0, 30, 0, 100, "#f5a70b", "#ffd84a")) + c.fill_preserve() + c.set_source_rgba(*INK, 0.35) + c.set_line_width(3) + c.stroke() + # ₩ + c.set_source_rgb(*rgb("#b45309")) + c.set_line_width(8) + c.set_line_cap(cairo.LINE_CAP_ROUND) + c.set_line_join(cairo.LINE_JOIN_ROUND) + c.move_to(44, 47) + c.line_to(53, 87) + c.line_to(64, 57) + c.line_to(75, 87) + c.line_to(84, 47) + c.stroke() + c.set_line_width(5) + for y in (64, 74): + c.move_to(41, y) + c.line_to(87, y) + c.stroke() + shine(c, 44, 40, 14, 8, 0.7) + + +def money_bag(c): + c.move_to(46, 30) + c.curve_to(30, 50, 14, 74, 22, 96) + c.curve_to(28, 116, 100, 116, 106, 96) + c.curve_to(114, 74, 98, 50, 82, 30) + c.close_path() + fill_stroke(c, rad(64, 76, 56, "#c7f59a", "#6cc63c", "#3f8f25")) + rrect(c, 42, 16, 44, 18, 8) + fill_stroke(c, lin(0, 16, 0, 34, "#a5e57a", "#4f9f2c")) + c.set_source_rgb(*rgb("#ffd23a")) + c.set_line_width(7) + c.move_to(44, 36) + c.line_to(84, 36) + c.stroke() + # ₩ 표시 + c.set_source_rgb(*rgb("#2f6f17")) + c.set_line_width(7) + c.set_line_cap(cairo.LINE_CAP_ROUND) + c.move_to(46, 62) + c.line_to(54, 94) + c.line_to(64, 70) + c.line_to(74, 94) + c.line_to(82, 62) + c.stroke() + c.set_line_width(4) + c.move_to(43, 76) + c.line_to(85, 76) + c.stroke() + shine(c, 40, 62, 8, 14, 0.5) + + +def bolt(c): + polygon(c, [(74, 8), (26, 72), (58, 72), (48, 120), (102, 50), (68, 50), (82, 8)]) + fill_stroke(c, lin(30, 10, 90, 120, "#fff6a8", "#ffd21f", "#ff9f0a")) + polygon(c, [(72, 18), (40, 64), (52, 64)]) + c.set_source_rgba(1, 1, 1, 0.6) + c.fill() + + +def gear(c): + teeth = 8 + pts = [] + for i in range(teeth * 4): + a = i * 2 * math.pi / (teeth * 4) - math.pi / 2 + r = 54 if (i % 4) in (0, 1) else 40 + pts.append((64 + r * math.cos(a + math.pi / (teeth * 4)), 64 + r * math.sin(a + math.pi / (teeth * 4)))) + polygon(c, pts) + c.new_sub_path() + c.arc_negative(64, 64, 17, 0, -2 * math.pi) + c.set_fill_rule(cairo.FILL_RULE_EVEN_ODD) + fill_stroke(c, rad(64, 64, 58, "#f1f5f9", "#a8b4c4", "#64748b")) + c.set_fill_rule(cairo.FILL_RULE_WINDING) + shine(c, 46, 42, 10, 6, 0.6) + + +def upgrade(c): + # 초록 위쪽 화살표 + polygon(c, [(64, 8), (114, 60), (84, 60), (84, 116), (44, 116), (44, 60), (14, 60)]) + fill_stroke(c, lin(0, 8, 0, 116, "#b6f774", "#46c937", "#178a2c")) + polygon(c, [(64, 22), (34, 54), (50, 54)]) + c.set_source_rgba(1, 1, 1, 0.55) + c.fill() + + +def plate(c): + c.save() + c.translate(64, 76) + c.scale(1, 0.5) + c.arc(0, 0, 56, 0, 2 * math.pi) + c.restore() + fill_stroke(c, lin(0, 50, 0, 104, "#ffffff", "#d7dde6")) + c.save() + c.translate(64, 74) + c.scale(1, 0.5) + c.arc(0, 0, 36, 0, 2 * math.pi) + c.restore() + c.set_source_rgba(*INK, 0.25) + c.set_line_width(3) + c.stroke() + # 김 나는 음식 + c.move_to(36, 72) + c.curve_to(36, 36, 92, 36, 92, 72) + c.close_path() + fill_stroke(c, lin(0, 40, 0, 72, "#ff7a59", "#e63b1f")) + for x in (52, 64, 76): + c.move_to(x, 30) + c.curve_to(x - 6, 22, x + 6, 16, x, 8) + c.set_source_rgba(1, 1, 1, 0.9) + c.set_line_width(4) + c.stroke() + + +def lock(c): + c.arc(64, 50, 26, math.pi, 2 * math.pi) + c.set_line_width(14 + LW) + c.set_source_rgb(*INK) + c.stroke() + c.arc(64, 50, 26, math.pi, 2 * math.pi) + c.set_line_width(13) + c.set_source_rgb(*rgb("#cbd5e1")) + c.stroke() + rrect(c, 26, 50, 76, 64, 14) + fill_stroke(c, lin(0, 50, 0, 114, "#ffe066", "#f59e0b")) + c.arc(64, 76, 9, 0, 2 * math.pi) + c.set_source_rgb(*INK) + c.fill() + rrect(c, 60, 78, 8, 20, 4) + c.fill() + + +def check(c): + c.set_line_cap(cairo.LINE_CAP_ROUND) + c.set_line_join(cairo.LINE_JOIN_ROUND) + for w, col in ((30, INK), (18, rgb("#4ade80"))): + c.move_to(22, 66) + c.line_to(52, 96) + c.line_to(106, 34) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + + +def close_x(c): + c.set_line_cap(cairo.LINE_CAP_ROUND) + for w, col in ((32, INK), (19, (1, 1, 1))): + c.set_line_width(w) + c.set_source_rgb(*col) + c.move_to(30, 30) + c.line_to(98, 98) + c.move_to(98, 30) + c.line_to(30, 98) + c.stroke() + + +def table(c): + # 다리 + for x in (30, 92): + rrect(c, x, 58, 12, 56, 4) + fill_stroke(c, lin(0, 58, 0, 114, "#b9763c", "#7a4a22"), 5) + c.save() + c.translate(64, 52) + c.scale(1, 0.42) + c.arc(0, 0, 58, 0, 2 * math.pi) + c.restore() + fill_stroke(c, lin(0, 28, 0, 76, "#f2b46b", "#c97b36")) + c.save() + c.translate(64, 50) + c.scale(1, 0.42) + c.arc(0, 0, 42, 0, 2 * math.pi) + c.restore() + c.set_source_rgba(1, 1, 1, 0.3) + c.fill() + + +def sign(c): + for x in (34, 90): + rrect(c, x, 70, 8, 50, 3) + fill_stroke(c, rgb("#7a4a22"), 5) + rrect(c, 10, 16, 108, 64, 14) + fill_stroke(c, lin(0, 16, 0, 80, "#ff6b4a", "#d92f1c")) + rrect(c, 20, 26, 88, 44, 8) + c.set_source_rgb(*rgb("#fff3d6")) + c.fill() + for i, x in enumerate((40, 64, 88)): + polygon(c, star_pts(x, 48, 13, 6)) + fill_stroke(c, rgb("#ffc61a"), 3) + + +def flame(c): + c.move_to(64, 6) + c.curve_to(96, 40, 112, 62, 108, 86) + c.curve_to(104, 112, 84, 122, 64, 122) + c.curve_to(40, 122, 20, 108, 20, 84) + c.curve_to(20, 64, 34, 52, 40, 34) + c.curve_to(48, 50, 52, 54, 56, 56) + c.curve_to(56, 36, 58, 22, 64, 6) + c.close_path() + fill_stroke(c, lin(0, 6, 0, 122, "#ffd23a", "#ff7a1a", "#e8341c")) + c.move_to(64, 58) + c.curve_to(82, 76, 88, 88, 84, 100) + c.curve_to(80, 114, 48, 114, 44, 100) + c.curve_to(42, 88, 54, 78, 64, 58) + c.close_path() + c.set_source(lin(0, 58, 0, 114, "#fff8c2", "#ffd23a")) + c.fill() + + +def sauce(c): + rrect(c, 52, 6, 24, 20, 6) + fill_stroke(c, rgb("#ffffff"), 5) + c.move_to(48, 26) + c.line_to(80, 26) + c.curve_to(80, 40, 100, 44, 100, 64) + c.line_to(100, 108) + c.curve_to(100, 118, 94, 122, 86, 122) + c.line_to(42, 122) + c.curve_to(34, 122, 28, 118, 28, 108) + c.line_to(28, 64) + c.curve_to(28, 44, 48, 40, 48, 26) + c.close_path() + fill_stroke(c, lin(28, 0, 100, 0, "#ff5a3c", "#d61f12", "#a8150b")) + rrect(c, 38, 66, 52, 36, 8) + c.set_source_rgb(*rgb("#fff3d6")) + c.fill() + polygon(c, [(64, 72), (72, 84), (64, 96), (56, 84)]) + c.set_source_rgb(*rgb("#e8341c")) + c.fill() + c.rectangle(36, 46, 8, 52) + c.set_source_rgba(1, 1, 1, 0.45) + c.fill() + + +def chef(c): + # 요리사 모자 + for x, y, r in ((40, 46, 24), (64, 34, 28), (88, 46, 24)): + c.arc(x, y, r, 0, 2 * math.pi) + c.set_source_rgb(*INK) + c.fill() + rrect(c, 34, 56, 60, 52, 8) + fill_stroke(c, lin(0, 56, 0, 108, "#ffffff", "#dfe5ee")) + for x, y, r in ((40, 46, 24 - LW / 2), (64, 34, 28 - LW / 2), (88, 46, 24 - LW / 2)): + c.arc(x, y, r, 0, 2 * math.pi) + c.set_source(rad(x, y, r + 4, "#ffffff", "#e6ebf2")) + c.fill() + rrect(c, 34 + LW / 2, 60, 60 - LW, 20, 4) + c.set_source_rgb(1, 1, 1) + c.fill() + for x in (52, 64, 76): + c.move_to(x, 86) + c.line_to(x, 104) + c.set_source_rgba(*INK, 0.3) + c.set_line_width(3) + c.stroke() + + +def store(c): + rrect(c, 18, 54, 92, 64, 6) + fill_stroke(c, lin(0, 54, 0, 118, "#fff3d6", "#f2d7a8")) + # 줄무늬 차양 + polygon(c, [(10, 56), (22, 18), (106, 18), (118, 56)]) + c.set_source_rgb(*INK) + c.set_line_width(LW) + c.stroke_preserve() + c.save() + c.clip() + for i in range(7): + polygon(c, [(10 + i * 18, 56), (22 + i * 12, 18), (34 + i * 12, 18), (28 + i * 18, 56)]) + c.set_source_rgb(*(rgb("#e8341c") if i % 2 == 0 else (1, 1, 1))) + c.fill() + c.restore() + polygon(c, [(10, 56), (22, 18), (106, 18), (118, 56)]) + c.set_source_rgb(*INK) + c.set_line_width(LW) + c.stroke() + rrect(c, 52, 76, 24, 42, 4) + fill_stroke(c, rgb("#b9763c"), 5) + rrect(c, 26, 70, 18, 18, 3) + fill_stroke(c, rgb("#8fd3ff"), 4) + rrect(c, 84, 70, 18, 18, 3) + fill_stroke(c, rgb("#8fd3ff"), 4) + + +def tray(c): + polygon(c, [(8, 70), (120, 70), (108, 98), (20, 98)]) + fill_stroke(c, lin(0, 70, 0, 98, "#e2e8f0", "#94a3b8")) + for x, col in ((40, "#ff6b4a"), (64, "#ffd23a"), (88, "#7dd36b")): + c.move_to(x - 16, 68) + c.curve_to(x - 16, 44, x + 16, 44, x + 16, 68) + c.close_path() + fill_stroke(c, rgb(col), 5) + shine(c, 30, 80, 14, 4, 0.6) + + +def tteokbokki(c): + # 그릇 + c.move_to(10, 58) + c.line_to(118, 58) + c.curve_to(116, 96, 92, 118, 64, 118) + c.curve_to(36, 118, 12, 96, 10, 58) + c.close_path() + fill_stroke(c, lin(0, 58, 0, 118, "#ffffff", "#cfd8e3")) + # 소스 + c.save() + c.translate(64, 58) + c.scale(1, 0.32) + c.arc(0, 0, 52, 0, 2 * math.pi) + c.restore() + c.set_source_rgb(*rgb("#e8341c")) + c.fill() + # 떡 + for x, y, a in ((40, 46, -0.5), (64, 40, 0.3), (86, 48, -0.2), (54, 56, 0.1), (78, 58, -0.4)): + c.save() + c.translate(x, y) + c.rotate(a) + rrect(c, -16, -8, 32, 16, 8) + c.restore() + fill_stroke(c, lin(0, y - 8, 0, y + 8, "#ff8a6a", "#d92f1c"), 4) + c.save() + c.translate(x, y) + c.rotate(a) + rrect(c, -10, -5, 14, 4, 2) + c.restore() + c.set_source_rgba(1, 1, 1, 0.6) + c.fill() + shine(c, 26, 80, 6, 12, 0.5) + + +def gimbap(c): + for x, y in ((40, 74), (88, 74), (64, 50)): + c.arc(x, y, 26, 0, 2 * math.pi) + fill_stroke(c, rgb("#1f2a1f"), 5) + c.arc(x, y, 19, 0, 2 * math.pi) + c.set_source_rgb(1, 1, 1) + c.fill() + for dx, dy, col in ((-6, -5, "#ff8c1a"), (6, -4, "#ffd23a"), (0, 6, "#4caf50"), (-7, 6, "#e8341c")): + c.arc(x + dx, y + dy, 5, 0, 2 * math.pi) + c.set_source_rgb(*rgb(col)) + c.fill() + + +def sundae(c): + for x, y in ((38, 80), (64, 60), (90, 80)): + c.arc(x, y, 26, 0, 2 * math.pi) + fill_stroke(c, rad(x, y, 30, "#8a5a6a", "#5a2e3c", "#3a1a24"), 5) + for dx, dy in ((-8, -6), (6, -8), (8, 6), (-6, 8), (0, 0)): + c.arc(x + dx, y + dy, 3, 0, 2 * math.pi) + c.set_source_rgba(1, 0.85, 0.8, 0.7) + c.fill() + + +def eomuk(c): + c.set_line_cap(cairo.LINE_CAP_ROUND) + for w, col in ((10 + LW, INK), (8, rgb("#e8c58f"))): + c.move_to(64, 6) + c.line_to(64, 124) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + # 꼬치에 접어 꽂은 어묵(지그재그 세 겹) + for i, (dx, a) in enumerate(((-8, -0.12), (8, 0.12), (-8, -0.12))): + y = 30 + i * 28 + c.save() + c.translate(64 + dx, y) + c.rotate(a) + rrect(c, -40, -14, 80, 28, 12) + c.restore() + fill_stroke(c, lin(0, y - 14, 0, y + 14, "#ffe2a8", "#f2b46b", "#d98a3a"), 6) + c.save() + c.translate(64 + dx, y) + c.rotate(a) + rrect(c, -32, -9, 40, 5, 2.5) + c.restore() + c.set_source_rgba(1, 1, 1, 0.55) + c.fill() + + +def twigim(c): + # 새우튀김 + c.save() + c.translate(64, 64) + c.rotate(-0.7) + c.move_to(-52, 0) + c.curve_to(-52, -26, 30, -26, 40, -6) + c.line_to(40, 6) + c.curve_to(30, 26, -52, 26, -52, 0) + c.close_path() + c.restore() + fill_stroke(c, lin(20, 20, 110, 110, "#ffe28a", "#f5a524", "#c9761a")) + c.save() + c.translate(64, 64) + c.rotate(-0.7) + polygon(c, [(38, -2), (60, -18), (54, 0), (60, 18), (38, 2)]) + c.restore() + fill_stroke(c, rgb("#ff6b4a"), 5) + for x, y in ((40, 74), (54, 62), (68, 50), (48, 86), (62, 74), (76, 62), (34, 62)): + c.arc(x, y, 3.5, 0, 2 * math.pi) + c.set_source_rgba(1, 1, 1, 0.55) + c.fill() + + +def globe(c): + c.arc(64, 64, 52, 0, 2 * math.pi) + fill_stroke(c, rad(64, 64, 58, "#a8e6ff", "#38a8f5", "#1769c4")) + c.save() + c.arc(64, 64, 52 - LW / 2, 0, 2 * math.pi) + c.clip() + c.set_source(lin(0, 0, 0, 128, "#86e06a", "#3fa33a")) + c.move_to(30, 30) + c.curve_to(50, 20, 60, 40, 52, 56) + c.curve_to(44, 70, 22, 64, 18, 52) + c.close_path() + c.fill() + c.move_to(70, 60) + c.curve_to(94, 50, 112, 70, 100, 92) + c.curve_to(90, 108, 70, 100, 72, 84) + c.close_path() + c.fill() + c.restore() + c.set_source_rgba(*INK, 0.35) + c.set_line_width(3) + c.save() + c.translate(64, 64) + c.scale(0.45, 1) + c.arc(0, 0, 52, 0, 2 * math.pi) + c.restore() + c.stroke() + c.move_to(12, 64) + c.line_to(116, 64) + c.stroke() + shine(c, 44, 40, 12, 8, 0.6) + + +def speaker(c): + polygon(c, [(14, 48), (38, 48), (68, 20), (68, 108), (38, 80), (14, 80)]) + fill_stroke(c, lin(0, 20, 0, 108, "#ffe066", "#f59e0b")) + c.set_line_cap(cairo.LINE_CAP_ROUND) + for r in (22, 40): + for w, col in ((9 + LW, INK), (9, (1, 1, 1))): + c.arc(70, 64, r, -0.8, 0.8) + c.set_line_width(w) + c.set_source_rgb(*col) + c.stroke() + + +def mouse(c): + rrect(c, 32, 14, 64, 100, 32) + fill_stroke(c, lin(32, 0, 96, 0, "#ffffff", "#cbd5e1")) + c.move_to(64, 16) + c.line_to(64, 52) + c.move_to(34, 52) + c.line_to(94, 52) + c.set_source_rgb(*INK) + c.set_line_width(5) + c.stroke() + rrect(c, 59, 28, 10, 18, 5) + c.set_source_rgb(*rgb("#38a8f5")) + c.fill() + + +def wrench(c): + c.save() + c.translate(64, 64) + c.rotate(-math.pi / 4) + rrect(c, -11, -6, 22, 66, 11) + c.restore() + fill_stroke(c, lin(0, 0, 128, 128, "#e2e8f0", "#7b8796")) + cx, cy, r, d = 46, 46, 30, -3 * math.pi / 4 + + def u(a, k): + return cx + k * math.cos(a), cy + k * math.sin(a) + + c.new_sub_path() + c.arc(cx, cy, r, d + 0.5, d - 0.5 + 2 * math.pi) + c.line_to(*u(d - 0.75, 12)) + c.line_to(*u(d + 0.75, 12)) + c.close_path() + fill_stroke(c, rad(cx, cy, r + 2, "#f1f5f9", "#94a3b8")) + + +def star(c): + polygon(c, star_pts(64, 68, 58, 26)) + fill_stroke(c, lin(0, 10, 0, 120, "#fff6a8", "#ffd21f", "#ff9f0a")) + polygon(c, star_pts(56, 56, 16, 7)) + c.set_source_rgba(1, 1, 1, 0.55) + c.fill() + + +def sparkle(c): + # 테두리 없는 반짝이(흰색, 버튼·카드 위 장식) + pts = star_pts(64, 64, 60, 12, n=4) + polygon(c, pts) + g = cairo.RadialGradient(64, 64, 4, 64, 64, 60) + g.add_color_stop_rgba(0, 1, 1, 1, 1) + g.add_color_stop_rgba(1, 1, 1, 0.85, 0.9) + c.set_source(g) + c.fill() + + +def rays(c): + # 햇살(흰색, 테두리 없음). 2배·부스트 버튼 뒤에서 천천히 돕니다. + g = cairo.RadialGradient(64, 64, 6, 64, 64, 64) + g.add_color_stop_rgba(0, 1, 1, 1, 1) + g.add_color_stop_rgba(0.6, 1, 1, 1, 0.55) + g.add_color_stop_rgba(1, 1, 1, 1, 0) + for i in range(12): + a0 = i * math.pi / 6 + a1 = a0 + math.pi / 12 + c.move_to(64, 64) + c.line_to(64 + 90 * math.cos(a0), 64 + 90 * math.sin(a0)) + c.line_to(64 + 90 * math.cos(a1), 64 + 90 * math.sin(a1)) + c.close_path() + c.set_source(g) + c.fill() + + +def glow(c): + # 둥근 빛(흰색). 버튼 뒤 후광·알림 빛 + g = cairo.RadialGradient(64, 64, 0, 64, 64, 64) + g.add_color_stop_rgba(0, 1, 1, 1, 1) + g.add_color_stop_rgba(0.45, 1, 1, 1, 0.6) + g.add_color_stop_rgba(1, 1, 1, 1, 0) + c.rectangle(0, 0, 128, 128) + c.set_source(g) + c.fill() + + +def arrow_down(c): + polygon(c, [(40, 8), (88, 8), (88, 64), (114, 64), (64, 120), (14, 64), (40, 64)]) + fill_stroke(c, lin(0, 8, 0, 120, "#fff6a8", "#ffd21f", "#ff8a0a")) + c.rectangle(48, 16, 10, 44) + c.set_source_rgba(1, 1, 1, 0.55) + c.fill() + + +def scroll(c): + # 업그레이드 목록(두루마리 메뉴판) + rrect(c, 24, 14, 80, 100, 10) + fill_stroke(c, lin(0, 14, 0, 114, "#fff8e6", "#f2d7a8")) + for y in (38, 58, 78): + c.arc(40, y, 6, 0, 2 * math.pi) + c.set_source_rgb(*rgb("#e8341c")) + c.fill() + rrect(c, 52, y - 4, 38, 8, 4) + c.set_source_rgba(*INK, 0.55) + c.fill() + rrect(c, 16, 98, 96, 22, 11) + fill_stroke(c, lin(0, 98, 0, 120, "#ff8a5a", "#d92f1c"), 6) + + +def hand(c): + # 누르는 손가락(튜토리얼) + c.move_to(50, 18) + c.curve_to(50, 6, 70, 6, 70, 18) + c.line_to(70, 56) + c.curve_to(92, 52, 110, 58, 110, 76) + c.line_to(108, 98) + c.curve_to(106, 116, 90, 122, 72, 122) + c.curve_to(54, 122, 42, 114, 34, 100) + c.line_to(20, 76) + c.curve_to(14, 64, 30, 58, 38, 68) + c.line_to(50, 80) + c.close_path() + fill_stroke(c, lin(0, 6, 0, 122, "#ffe9d0", "#f5c89a")) + + +ICONS = [ + ("coin", coin), ("moneyBag", money_bag), ("bolt", bolt), ("gear", gear), + ("upgrade", upgrade), ("plate", plate), ("lock", lock), ("check", check), + ("close", close_x), ("table", table), ("sign", sign), ("flame", flame), + ("sauce", sauce), ("chef", chef), ("store", store), ("tray", tray), + ("Tteokbokki", tteokbokki), ("Gimbap", gimbap), ("Sundae", sundae), ("Eomuk", eomuk), + ("Twigim", twigim), ("globe", globe), ("speaker", speaker), ("mouse", mouse), + ("wrench", wrench), ("star", star), ("sparkle", sparkle), ("rays", rays), + ("glow", glow), ("arrowDown", arrow_down), ("scroll", scroll), ("hand", hand), +] + + +def draw(): + surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, CELL * GRID) + for i, (name, fn) in enumerate(ICONS): + c = cairo.Context(surf) + c.translate((i % GRID) * CELL, (i // GRID) * CELL) + c.rectangle(0, 0, CELL, CELL) + c.clip() + # 테두리가 칸 밖으로 안 나가게 살짝 줄입니다. + c.translate(64, 64) + c.scale(0.9, 0.9) + c.translate(-64, -64) + fn(c) + return surf + + +def main(argv): + surf = draw() + if "--luau" in argv: + for i, (name, _) in enumerate(ICONS): + print(f"\t{name} = Vector2.new({(i % GRID) * CELL}, {(i // GRID) * CELL}),") + return + if "--sheet" in argv: + out = argv[argv.index("--sheet") + 1] + rows = (len(ICONS) + GRID - 1) // GRID + sheet = cairo.ImageSurface(cairo.FORMAT_ARGB32, CELL * GRID, (CELL + 20) * rows) + c = cairo.Context(sheet) + c.set_source_rgb(0.55, 0.75, 0.6) + c.paint() + for i, (name, _) in enumerate(ICONS): + x, y = (i % GRID) * CELL, (i // GRID) * (CELL + 20) + c.set_source_surface(surf, x - (i % GRID) * CELL + 0, y - (i // GRID) * CELL) + c.rectangle(x, y, CELL, CELL) + c.fill() + c.set_source_rgb(0, 0, 0) + c.move_to(x + 4, y + CELL + 15) + c.set_font_size(13) + c.show_text(name) + sheet.write_to_png(out) + print(out) + return + surf.write_to_png(OUT) + print(os.path.normpath(OUT)) + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/bunsik-tycoon/tools/preview.sh b/bunsik-tycoon/tools/preview.sh new file mode 100755 index 0000000..fef3fd6 --- /dev/null +++ b/bunsik-tycoon/tools/preview.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# 화면 UI 미리보기: 빌드 → 저장 버전 업로드 → 로블록스 서버에서 UI 덤프 → 그림(PNG)으로. +# tools/preview.sh 출력폴더 +set -euo pipefail +cd "$(dirname "$0")/.." +export PATH="$HOME/.rokit/bin:$PATH" +out=${1:-.cache/preview} +mkdir -p .cache "$out" +rojo build default.project.json -o build/BunsikTycoon.rbxl >/dev/null +ver=$(python3 tools/cloud.py publish build/BunsikTycoon.rbxl | awk '{print $2}') +python3 tools/cloud.py run tests/cloud/dump_gui.luau --version "$ver" >.cache/dump_raw.txt || { tail -20 .cache/dump_raw.txt; exit 1; } +python3 - <<'PY' +import json +raw = open(".cache/dump_raw.txt").read() +line = [l for l in raw.splitlines() if l.startswith("output: ")][-1] +out = json.loads(line[len("output: "):]) +data = out["results"][0] +open(".cache/gui_dump.json", "w").write(data) +PY +python3 tools/gui_render.py .cache/gui_dump.json "$out"