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:
11
bunsik-tycoon/tools/hud_layout.luau
Normal file
11
bunsik-tycoon/tools/hud_layout.luau
Normal file
@@ -0,0 +1,11 @@
|
||||
-- 화면 UI 배치를 JSON으로 출력합니다(tools/hud_preview.py가 그림으로 그림). lune run tools/hud_layout.luau 너비 높이 touch|pc
|
||||
local process = require("@lune/process")
|
||||
local serde = require("@lune/serde")
|
||||
local Layout = require("../src/client/Layout")
|
||||
|
||||
local w = tonumber(process.args[1]) or 750
|
||||
local h = tonumber(process.args[2]) or 332
|
||||
local touch = process.args[3] == "touch"
|
||||
local out = Layout.compute(w, h, touch, true) :: any
|
||||
out.zones = Layout.touchZones(w, h)
|
||||
print(serde.encode("json", out))
|
||||
88
bunsik-tycoon/tools/hud_preview.py
Normal file
88
bunsik-tycoon/tools/hud_preview.py
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""화면 UI 배치 미리보기: 기기 화면 크기별로 UI 상자와 로블록스 조이스틱·점프 버튼 자리를 그립니다.
|
||||
실제 글자·색은 아니고 위치·크기만 맞습니다.
|
||||
|
||||
python3 tools/hud_preview.py out.png
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
DEVICES = [
|
||||
("iPhone SE", 667, 375 - 58, True),
|
||||
("iPhone 15", 844 - 94, 390 - 58, True),
|
||||
("Android 800x360", 800, 360 - 58, True),
|
||||
("iPad 1024x768", 1024, 768 - 58, True),
|
||||
("PC 1366x768", 1366, 768 - 58, False),
|
||||
]
|
||||
BOXES = [
|
||||
("money", "돈", (255, 130, 50)),
|
||||
("carry", "들고 있는 접시", (200, 160, 120)),
|
||||
("hint", "튜토리얼 안내", (255, 235, 120)),
|
||||
("toasts", "알림 자리", (120, 120, 150)),
|
||||
("card", "다음 업그레이드", (255, 248, 235)),
|
||||
("buy", "사기", (70, 190, 90)),
|
||||
("settings", "설정", (80, 140, 230)),
|
||||
("list", "업그레이드 목록", (255, 130, 50)),
|
||||
("double", "2배 수익", (150, 80, 220)),
|
||||
("boost", "돈 부스트", (240, 170, 30)),
|
||||
]
|
||||
|
||||
|
||||
def font(size):
|
||||
for path in ("/usr/share/fonts/truetype/nanum/NanumGothicBold.ttf",
|
||||
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
|
||||
"/usr/share/fonts/truetype/noto/NotoSansCJK-Bold.ttc"):
|
||||
if os.path.exists(path):
|
||||
return ImageFont.truetype(path, size)
|
||||
return ImageFont.load_default()
|
||||
|
||||
|
||||
def layout(w, h, touch):
|
||||
out = subprocess.run(["lune", "run", "tools/hud_layout.luau", str(w), str(h), "touch" if touch else "pc"],
|
||||
cwd=ROOT, capture_output=True, text=True, check=True).stdout
|
||||
return json.loads(out)
|
||||
|
||||
|
||||
def draw_device(name, w, h, touch):
|
||||
L = layout(w, h, touch)
|
||||
s = L["scale"]
|
||||
img = Image.new("RGB", (w, h + 30), (40, 40, 40))
|
||||
d = ImageDraw.Draw(img, "RGBA")
|
||||
d.rectangle([0, 30, w - 1, h + 29], fill=(110, 160, 110))
|
||||
d.text((6, 4), f"{name} UI 영역 {w}x{h} 배율 {s:.2f}", fill=(255, 255, 255), font=font(18))
|
||||
if touch:
|
||||
for key, label in (("stick", "조이스틱 자리"), ("jump", "점프 버튼 자리")):
|
||||
z = L["zones"][key]
|
||||
d.rectangle([z["x"], z["y"] + 30, z["x"] + z["w"], z["y"] + z["h"] + 30], fill=(255, 0, 0, 60),
|
||||
outline=(255, 60, 60), width=2)
|
||||
d.text((z["x"] + 6, z["y"] + z["h"] + 30 - 22), label, fill=(255, 220, 220), font=font(14))
|
||||
for key, label, color in BOXES:
|
||||
r = L[key]
|
||||
x0, y0 = r["x"] * s, r["y"] * s + 30
|
||||
x1, y1 = x0 + r["w"] * s, y0 + r["h"] * s
|
||||
alpha = 90 if key == "toasts" else 230
|
||||
d.rounded_rectangle([x0, y0, x1, y1], radius=6, fill=color + (alpha,), outline=(255, 255, 255), width=2)
|
||||
d.text((x0 + 4, y0 + 2), label, fill=(20, 20, 20), font=font(max(10, int(15 * s))))
|
||||
return img
|
||||
|
||||
|
||||
def main(argv):
|
||||
out = argv[1] if len(argv) > 1 else "hud_preview.png"
|
||||
imgs = [draw_device(*dev) for dev in DEVICES]
|
||||
width = max(i.width for i in imgs)
|
||||
sheet = Image.new("RGB", (width, sum(i.height + 10 for i in imgs)), (25, 25, 25))
|
||||
y = 0
|
||||
for i in imgs:
|
||||
sheet.paste(i, (0, y))
|
||||
y += i.height + 10
|
||||
sheet.save(out)
|
||||
print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
Reference in New Issue
Block a user