25 lines
898 B
Python
25 lines
898 B
Python
# -*- coding: utf-8 -*-
|
|
"""战斗屏布局表读取(`game/data/tables/battle_layout.tres` 单点)。
|
|
|
|
样张渲染工具不另立布局常量:B 区高 / C 区宽 / AP 条高 / 明细带两态高一律读该表,
|
|
与游戏侧 `ConfigDb.presentation.battle_layout` 同源。
|
|
"""
|
|
import os
|
|
import re
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
TABLE_PATH = os.path.join(ROOT, "game", "data", "tables", "battle_layout.tres")
|
|
FIELDS = ("stage_h", "info_panel_w", "ap_bar_h", "log_band_h_dig", "log_band_h_settle")
|
|
|
|
|
|
def load(path=TABLE_PATH):
|
|
with open(path, encoding="utf-8") as f:
|
|
text = f.read()
|
|
vals = {}
|
|
for key in FIELDS:
|
|
m = re.search(r"^%s\s*=\s*(\d+)\s*$" % key, text, re.M)
|
|
if m is None:
|
|
raise ValueError("battle_layout.tres 缺字段或非整数值: %s" % key)
|
|
vals[key] = int(m.group(1))
|
|
return vals
|