feat(bunsik): 휴대폰·태블릿 화면 배치

- Layout 모듈: 안전 영역(상단 바·노치 제외) 크기와 터치 여부로 배율·위치 계산
- 휴대폰: 기준 화면 900x400으로 글자·버튼 크게, 결제 버튼은 왼쪽 위, 사기 버튼은
  조이스틱(왼쪽 40%×아래 2/3)과 점프 버튼 자리 사이, 마우스 회전 줄 숨김
- 루트가 화면을 꽉 채우고, 배율을 상단 바 뺀 영역 기준으로 계산(아래 카드 잘림 수정)
- 개발자 테스트 버튼을 설정 창 안으로 이동
- 기기 12종 배치 단위 테스트, 배치 미리보기 도구(tools/hud_preview.py)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-12 13:57:32 +09:00
parent 4d861b8fd3
commit 998b2467d6
8 changed files with 524 additions and 52 deletions

View File

@@ -0,0 +1,108 @@
-- 화면 UI 배치 검사: 기기별 화면에서 UI가 화면 안에 있고, 서로 겹치지 않고,
-- 휴대폰에서는 누르는 버튼이 조이스틱·점프 버튼 자리를 피하고 손가락으로 누를 만큼 큰지. lune run tests/Layout.spec.luau
local Layout = require("../src/client/Layout")
local T = require("./check")
type Rect = Layout.Rect
-- 가로 화면 크기(포인트)에서 로블록스 상단 바(58)와 노치(좌우)를 뺀 UI 영역
local DEVICES: { { name: string, w: number, h: number, touch: boolean } } = {
{ name = "iPhone SE", w = 667, h = 375 - 58, touch = true },
{ name = "iPhone 15", w = 844 - 94, h = 390 - 58, touch = true },
{ name = "iPhone 15 Pro Max", w = 932 - 118, h = 430 - 58, touch = true },
{ name = "Android 640x360", w = 640, h = 360 - 58, touch = true },
{ name = "Android 800x360", w = 800, h = 360 - 58, touch = true },
{ name = "Galaxy S 915x412", w = 915, h = 412 - 58, touch = true },
{ name = "iPad 1024x768", w = 1024, h = 768 - 58, touch = true },
{ name = "iPad Pro 11", w = 1194, h = 834 - 58, touch = true },
{ name = "PC 1280x720", w = 1280, h = 720 - 58, touch = false },
{ name = "PC 1366x768", w = 1366, h = 768 - 58, touch = false },
{ name = "PC 1920x1080", w = 1920, h = 1080 - 58, touch = false },
{ name = "PC 작은 창 800x600", w = 800, h = 600 - 58, touch = false },
}
local function inside(r: Rect, W: number, H: number): boolean
return r.x >= 0 and r.y >= 0 and r.x + r.w <= W + 1e-6 and r.y + r.h <= H + 1e-6
end
local function overlap(a: Rect, b: Rect): boolean
return a.x < b.x + b.w and b.x < a.x + a.w and a.y < b.y + b.h and b.y < a.y + a.h
end
local function px(r: Rect, s: number): Rect
return { x = r.x * s, y = r.y * s, w = r.w * s, h = r.h * s }
end
for _, d in DEVICES do
for _, dev in { false, true } do
local L = Layout.compute(d.w, d.h, d.touch, dev)
local tag = `{d.name}{if dev then "(개발자)" else ""}`
T.check(
math.abs(L.width * L.scale - d.w) < 1e-6 and math.abs(L.height * L.scale - d.h) < 1e-6,
`{tag}: 화면 꽉 채움`
)
-- 늘 보이는 요소: 화면 안, 서로 안 겹침
local hud: { [string]: Rect } = {
money = L.money,
carry = L.carry,
hint = L.hint,
toasts = L.toasts,
card = L.card,
settings = L.settings,
list = L.list,
double = L.double,
boost = L.boost,
}
for name, r in hud do
T.check(inside(r, L.width, L.height), `{tag}: {name} 화면 안`)
end
T.check(inside(L.buy, L.width, L.height), `{tag}: 사기 버튼 화면 안`)
local names = {}
for name in hud do
table.insert(names, name)
end
table.sort(names)
for i, a in names do
for j = i + 1, #names do
local b = names[j]
T.check(not overlap(hud[a], hud[b]), `{tag}: {a}와 {b} 안 겹침`)
end
end
T.check(L.toasts.h >= 46, `{tag}: 알림 한 줄 이상 자리`)
-- 창(업그레이드 목록, 설정)은 화면 안에 다 들어감
T.check(inside(L.panel, L.width, L.height), `{tag}: 업그레이드 창 화면 안`)
T.check(inside(L.settingsPanel, L.width, L.height), `{tag}: 설정 창 화면 안`)
T.eq(L.rows.devY ~= nil, dev, `{tag}: 개발자 줄은 주인에게만`)
T.eq(L.rows.mouseY == nil, d.touch, `{tag}: 마우스 회전 줄은 PC만`)
if d.touch then
local zones = Layout.touchZones(d.w, d.h)
local buttons: { [string]: Rect } = {
buy = L.buy,
settings = L.settings,
list = L.list,
double = L.double,
boost = L.boost,
}
for name, r in buttons do
local p = px(r, L.scale)
T.check(not overlap(p, zones.stick), `{tag}: {name} 버튼이 조이스틱 자리 피함`)
T.check(not overlap(p, zones.jump), `{tag}: {name} 버튼이 점프 버튼 자리 피함`)
T.check(p.h >= 36, `{tag}: {name} 버튼 높이 {math.floor(p.h)}px ≥ 36`)
end
T.check(L.rows.langButtonH * L.scale >= 36, `{tag}: 언어 버튼 누르기 쉬움`)
T.check(L.rows.toggleH * L.scale >= 34, `{tag}: 켜기/끄기 버튼 누르기 쉬움`)
end
end
end
-- PC는 예전과 같은 기준 화면(1100x620), 휴대폰은 더 크게
T.eq(Layout.scaleFor(1100, 620, false), 1, "PC 기준 배율")
T.check(
Layout.scaleFor(750, 332, true) > Layout.scaleFor(750, 332, false),
"휴대폰은 같은 화면에서 더 크게"
)
T.done("Layout")

View File

@@ -436,14 +436,40 @@ eq((settingsPanel:FindFirstChild("Sfx") :: TextButton).Text, "Off", "효과음
check(not hud.menuOpen(), "창 닫힘")
state:SetAttribute("Bought", #Economy.PURCHASES)
check(not (root:FindFirstChild("Next"):FindFirstChild("Buy") :: TextButton).Visible, "다 사면 사기 버튼 숨김")
check(not (root:FindFirstChild("Dev") :: Frame).Visible, "개발자 버튼은 기본으로 숨김")
check(root:FindFirstChild("Dev") == nil, "개발자 버튼은 설정 창 안으로")
local devMoneyBtn = settingsPanel:FindFirstChild("devMoney") :: TextButton
check(not devMoneyBtn.Visible, "개발자 버튼은 기본으로 숨김")
local setH = settingsPanel.Size.Y.Offset
state:SetAttribute("Dev", true)
check((root:FindFirstChild("Dev") :: Frame).Visible, "게임 주인에게 개발자 버튼")
check(devMoneyBtn.Visible, "게임 주인에게 개발자 버튼(설정 창)")
check(settingsPanel.Size.Y.Offset > setH, "개발자 줄만큼 설정 창이 길어짐")
check((root:FindFirstChild("Double") :: TextButton).Visible, "2배 수익 버튼(상품 ID 설정됨)")
hud.notify("purchased", { item = "Table2" })
local toastText = root.Toasts:FindFirstChild("Toast"):FindFirstChild("Text") :: TextLabel
eq(toastText.Text, "Table 2 bought!", "구매 알림에 업그레이드 이름(내 언어)")
hud.setScale(Hud.scaleFor(Vector2.new(844, 390)))
-- 휴대폰 배치(아이폰 15 가로, 상단 바·노치 뺀 영역): 루트가 화면을 채우고, 결제 버튼은 왼쪽 위, 마우스 줄 숨김
hud.setLayout(Vector2.new(750, 332), true)
local lay = hud.layout()
local scaleObj = root:FindFirstChildOfClass("UIScale") :: UIScale
check(
root.Size.X.Offset * scaleObj.Scale - 750 >= -1e-3 and root.Size.X.Offset * scaleObj.Scale - 750 < scaleObj.Scale,
"휴대폰: 루트 너비 = 화면"
)
check(
root.Size.Y.Offset * scaleObj.Scale - 332 >= -1e-3 and root.Size.Y.Offset * scaleObj.Scale - 332 < scaleObj.Scale,
"휴대폰: 루트 높이 = 화면"
)
eq(
(root:FindFirstChild("Double") :: TextButton).Position.Y.Offset,
lay.double.y,
"휴대폰: 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}`)
hud.setLayout(Vector2.new(1366, 710), false)
check((settingsPanel:FindFirstChild("MouseLook") :: TextButton).Visible, "PC: 마우스 회전 줄 보임")
check(math.abs(scaleObj.Scale - math.min(1366 / 1100, 710 / 620)) < 1e-6, "PC: 배율(상단 바 뺀 높이 기준)")
hud.destroy()
section("조리 버튼(클라이언트 모듈)")