Custom page: language is now two explicit choices, 中文 / English (#12)
The single "Language: English" checkbox becomes two side-by-side options, readable in both UIs, with a hint under the row in the chosen language: tap Apply, then close and reopen the app. Storage is unchanged (still one key). Suggested in #12.
This commit is contained in:
@@ -1190,7 +1190,7 @@ _CUSTOM_ROWS = tuple((k, '@' + _custom_key(k)) for k in _CUSTOM_KEYS)
|
||||
# Dimensions are taken from the values the table lays out in the same widget tree: row height 180; text 1000×180; checkbox at x 1315 within the row, 70×70, vertically centered. Header row 180 (the gold divider line below it is placed for a 180 row height).
|
||||
# The first row is the language switch (also first in the host's key table), followed by the rows of _CUSTOM_KEYS; adding a row = adding a key to _CUSTOM_KEYS (and to k_keys in the host's dm_custom.c in the same order)
|
||||
_CUSTOM_TITLE_H, _CUSTOM_LINE_H = 180, 180
|
||||
_CUSTOM_ALL = (('lang_en', '@dmCustomLangEn'),) + _CUSTOM_ROWS
|
||||
_CUSTOM_ALL = (('lang_en', '@dmCustomLang'),) + _CUSTOM_ROWS
|
||||
_CUSTOM_TEST_ROWS = int(os.environ.get('DM_CUSTOM_TEST_ROWS', '0')) # 测试(造现场):末尾多摆这么多行假行,验更多行时的滚动;产品不设 | test (test setup): append this many dummy rows at the end, to verify scrolling with more rows; not set in the product
|
||||
_CUSTOM_Y = [_CUSTOM_TITLE_H + _CUSTOM_LINE_H * i for i in range(len(_CUSTOM_ALL) + _CUSTOM_TEST_ROWS)]
|
||||
_CUSTOM_H = _CUSTOM_TITLE_H + _CUSTOM_LINE_H * (len(_CUSTOM_ALL) + _CUSTOM_TEST_ROWS)
|
||||
@@ -1208,8 +1208,28 @@ def _custom_toggle_row(i, key, label):
|
||||
# 「重启游戏后生效」那句先放在屏外,勾选与当前语言不一致时宿主挪到这一行文字的下半(横坐标取标签的)
|
||||
# Language switch (first row, an ordinary row): checked = English UI + English voice, effective at the next launch (lang_en in the host's dm_custom.c, settings_lang_apply in hle_fs.c).
|
||||
# The line 「重启游戏后生效」(Takes effect after restarting the game) is first placed off screen; when the checkbox does not match the current language the host moves it to the lower half of this row's text (x taken from the label)
|
||||
_CUSTOM_LANG_HINT = (' { "type": "TextBoxWidget", "name": "TouchCustomLangHint", "fields": { "rect": { "x": 99999, "y": %d, "width": 1000, "height": 60 }, "text": "@dmCustomLangHint", "style": "$StyleSettingsText" } },\n'
|
||||
% (_CUSTOM_Y[0] + 112))
|
||||
_CUSTOM_LANG_HINT = ''.join(' { "type": "TextBoxWidget", "name": "TouchCustomLangHint%s", "fields": { "rect": { "x": 99999, "y": %d, "width": 1400, "height": 60 }, "text": "@dmCustomLangHint%s", "style": "$StyleSettingsText", "style/fontFace": "BlizzardGlobal" } },\n'
|
||||
% (n, _CUSTOM_Y[0] + 112, n) for n in ('Zh', 'En')) # 两句各一个控件,宿主按选中的语言摆其中一句 | One control per sentence; the host places one of them according to the chosen language
|
||||
# 语言那一行是并排的两个选项「中文 / English」(单选:宿主 dm_custom.c 让两个勾选框互斥,存的仍是 lang_en 一个键)。
|
||||
# 这一行的字两种界面都要写汉字:英文界面缺省的 Formal 字体没有汉字(缺字画不出),所以这几个文字控件指定原版的全球字体 BlizzardGlobal
|
||||
# (原版标题页、队伍名等同样按控件指定它)。English 的勾选框留在各行勾选框那一列,「中文」的在它左边
|
||||
# The language row is two options side by side, 「中文 / English」 (single choice: the host dm_custom.c makes the two checkboxes mutually exclusive, and what is stored is still the one key lang_en).
|
||||
# The text of this row has to show Chinese characters in both UIs: the default Formal font of the English UI has no Chinese characters (missing glyphs cannot be drawn), so these text controls specify the original global font BlizzardGlobal
|
||||
# (the original title page, party names and so on specify it per control in the same way). The checkbox of English stays in the column where every row has its checkbox; the one of 「中文」 is to its left
|
||||
_LANG_ZH_X, _LANG_EN_X = (770, 905), (1100, 1315) # (文字 x,勾选框 x) | (text x, checkbox x)
|
||||
def _custom_lang_row():
|
||||
y, h = _CUSTOM_Y[0], 112; cy = y + (h - 70) // 2 # 标签、两个选项排在这一行的上 112,下面 68 留给提示那一句 | The label and the two options go in the top 112 of this row; the bottom 68 is left for the hint sentence
|
||||
def text(name, x, w, key): return (' { "type": "TextBoxWidget", "name": "%s", "fields": { "rect": { "x": %d, "y": %d, "width": %d, "height": %d }, "text": "@%s", "style": "$StyleSettingsText", "style/fontFace": "BlizzardGlobal" } },\n' % (name, x, y, w, h, key))
|
||||
def box(name, x): return (' { "type": "ToggleButtonWidget", "name": "%s", "fields": {\n'
|
||||
' "rect": { "x": %d, "y": %d, "width": 70, "height": 70 }, "sound": "cursor_menu_select_hd",\n'
|
||||
' "focusIndicatorPadding": "$OptionsToggleFocusIndicatorPadding", "focusIndicatorFilename": "$OptionsToggleFocusIndicatorFilename", "focusIndicatorOffset": { "x": 0, "y": -4 },\n'
|
||||
' "filename": "Lobby\\\\CreateGame\\\\CreateGame_AdvancedCheckbox",\n'
|
||||
' "untoggledFrame": 0, "untoggledPressedFrame": 1, "untoggledHoveredFrame": 3, "untoggledDisabledFrame": 2,\n'
|
||||
' "toggledFrame": 4, "toggledPressedFrame": 5, "toggledHoveredFrame": 6,\n'
|
||||
' "onClickMessage": "PanelManager:ClosePanel:%s" } },\n') % (name, x, cy, name)
|
||||
return (text('TouchCustom_lang_en_Text', 0, 700, 'dmCustomLang')
|
||||
+ text('TouchCustomLangZh_Text', _LANG_ZH_X[0], _LANG_ZH_X[1] - _LANG_ZH_X[0] - 10, 'dmCustomLangZh') + box('TouchCustom_lang_zh', _LANG_ZH_X[1])
|
||||
+ text('TouchCustomLangEn_Text', _LANG_EN_X[0], _LANG_EN_X[1] - _LANG_EN_X[0] - 10, 'dmCustomLangEnOpt') + box('TouchCustom_lang_en', _LANG_EN_X[1]))
|
||||
def _custom_page(text):
|
||||
if '"name": "VideoOptionsPanel"' not in text or '"name": "OptionsTable"' not in text: raise SystemExit('touch_layout:主机版视频页不是原样(原版布局变了?),自定义页没换')
|
||||
title = ('{ "type": "TableRowWidget", "name": "Row TouchCustomTitle", "children": [\n'
|
||||
@@ -1223,7 +1243,7 @@ def _custom_page(text):
|
||||
' { "type": "TableWidget", "name": "OptionsTable", "fields": { "columns": [ "$OptionsTableColumn1", "$OptionsTableColumn2" ], "rowHeight": %d }, "children": [\n' % _CUSTOM_TITLE_H
|
||||
+ title + ' ] },\n'
|
||||
+ ' { "type": "Widget", "name": "TouchCustomRows", "fields": { "rect": { "x": 0, "y": 0, "width": 1500, "height": %d } }, "children": [\n' % _CUSTOM_H
|
||||
+ ''.join(_custom_toggle_row(i, k, l) for i, (k, l) in enumerate(_CUSTOM_ALL)) + _CUSTOM_LANG_HINT
|
||||
+ _custom_lang_row() + ''.join(_custom_toggle_row(i, k, l) for i, (k, l) in enumerate(_CUSTOM_ALL) if i) + _CUSTOM_LANG_HINT
|
||||
+ ''.join(' { "type": "TextBoxWidget", "name": "TouchCustomTest%d_Text", "fields": { "rect": { "x": 0, "y": %d, "width": 1000, "height": %d }, "text": "@KeyBindingTypeCustom", "style": "$StyleSettingsText" } },\n'
|
||||
% (n, _CUSTOM_Y[len(_CUSTOM_ALL) + n], _CUSTOM_LINE_H) for n in range(_CUSTOM_TEST_ROWS)) +
|
||||
# 手柄模式的选中框(同符文之语清单 TouchRwSel):框住十字键选中的那一行,宿主摆(dm_custom.c);触屏模式一直在屏外(只把 x 挪出去、y 留在内容范围内:滚动区按子控件的范围算内容高度,y 放到 99999 会把可滚范围撑到十万)。和各行在同一个容器里,跟着滚
|
||||
|
||||
Reference in New Issue
Block a user