feat: translate flight tutorial for next in-game trial

This commit is contained in:
DragonHD
2026-09-20 12:00:54 +08:00
parent 997ae29355
commit 6cd5bcbfee
5 changed files with 48 additions and 4 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Flight tutorial text fits the existing dialog using actual engine layout."""
import json
from pathlib import Path
import unittest
from test_cjk_layout import layout
class FlightTests(unittest.TestCase):
def test_flight_instructions_fit_and_share_dialog_center(self):
mapping = json.loads(Path(__file__).with_name('tutorial_cn.json').read_text(encoding='utf-8'))
bodies = [v for k, v in mapping.items() if k.startswith('\fYou can fly')]
self.assertEqual(len(bodies), 2)
self.assertEqual(bodies[0], bodies[1])
for body in bodies:
for width in (360, 400, 480):
lines, _ = layout(body, width=width, alignment=0)
self.assertEqual(len(lines), 2)
for raw, x, y in lines:
text = raw.decode('gb2312')
self.assertEqual(x, (width - len(text) * 12) // 2)
self.assertNotIn(text[0], ',。;:、')
self.assertEqual(lines[1][2] - lines[0][2], 17)
if __name__ == '__main__':
unittest.main()