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:
+15
-6
@@ -132,7 +132,10 @@ void dm_custom_ui_pump(unsigned long long root) {
|
||||
if (pad) { uint64_t ev = dm_padmode_page_keys(DM_BTN_UP | DM_BTN_DOWN | DM_BTN_A);
|
||||
if (ev & DM_BTN_DOWN) sel = sel + 1 < NK ? sel + 1 : sel; else if (ev & DM_BTN_UP) sel = sel > 0 ? sel - 1 : 0;
|
||||
snprintf(nm, sizeof nm, "TouchCustom_%s", k_keys[sel]); cw = find_w(sp, nm, 0); snprintf(nm, sizeof nm, "TouchCustom_%s_Text", k_keys[sel]); tw = find_w(sp, nm, 0);
|
||||
if ((ev & DM_BTN_A) && cw && seen[sel] == cw) set_toggle(cw, !TOGGLED(cw)); }
|
||||
if ((ev & DM_BTN_A) && cw && seen[sel] == cw) {
|
||||
if (sel == 0) { int p0 = atomic_load(&g_pend[0]), sh = p0 >= 0 ? p0 : atomic_load(&g_val[0]); atomic_store(&g_pend[0], !sh); set_toggle(cw, !sh); { uint64_t z = find_w(sp, "TouchCustom_lang_zh", 0); if (z) set_toggle(z, sh); } // 语言行是单选的两项:两个框当场摆好(只改待定值的话,下面读框状态会把没跟上的框当成玩家点的) | The language row is a single choice between two items: both boxes are set on the spot (if only the pending value were changed, the code below that reads the box states would take the box that has not caught up as a player tap)
|
||||
LOG("自定义设置:语言 → %s(手柄 A 在两项间切换;点「应用」生效)", !sh ? "English" : "中文"); }
|
||||
else set_toggle(cw, !TOGGLED(cw)); } }
|
||||
if (dm) { int32_t *r = (int32_t *)(dm + 0x70), want[4] = { 99999, 0, r[2], r[3] }; /* 不用时只把 x 挪出屏:它在滚动区里,y 放远了会撑大可滚范围 | when unused only x is moved off screen: it is inside the scroll area, and a far-away y would enlarge the scrollable range */
|
||||
if (dm_padmode_current() && tw && cw) { int32_t *t = (int32_t *)(tw + 0x70), *c = (int32_t *)(cw + 0x70); int top = t[1] < c[1] ? t[1] : c[1], bot = t[1] + t[3] > c[1] + c[3] ? t[1] + t[3] : c[1] + c[3]; // 框住整行:文字与勾选框两者的上下沿取并,再各放 10 单位(原先只按文字框的高度算,文字框比字矮,框成了横穿文字中线的一条) | Frame the whole row: take the union of the top and bottom edges of the text and the checkbox, then pad 10 units on each side (previously computed from the text box height only; the text box is shorter than the glyphs, so the frame became a strip cutting across the middle of the text)
|
||||
want[0] = t[0] - 30; want[1] = top - 10; want[2] = c[0] + c[2] + 30 - want[0]; want[3] = bot - top + 20;
|
||||
@@ -149,13 +152,19 @@ void dm_custom_ui_pump(unsigned long long root) {
|
||||
for (int i = 0; i < NK; i++) { char nm[48]; snprintf(nm, sizeof nm, "TouchCustom_%s", k_keys[i]);
|
||||
uint64_t w = find_w(sp, nm, 0); if (!w || !*(uint8_t *)(w + 0x50)) continue;
|
||||
int pd0 = atomic_load(&g_pend[i]), want = pd0 >= 0 ? pd0 : atomic_load(&g_val[i]);
|
||||
if (seen[i] != w) { seen[i] = w; set_toggle(w, want); continue; } // 页刚出现(布局里一律是没勾):先摆成该显示的值,这一帧不当玩家点了 | The page has just appeared (in the layout everything is unchecked): first set it to the value it should show, and do not treat this frame as a player tap
|
||||
uint64_t z = i == 0 ? find_w(sp, "TouchCustom_lang_zh", 0) : 0; // 语言行:并排的「中文」「English」两个勾选框,单选——存的仍是 lang_en 一个键,「中文」那格是它的反面 | Language row: two checkboxes side by side, 「中文」 and "English", single choice -- what is stored is still the one key lang_en, and the 「中文」 box is its opposite
|
||||
if (seen[i] != w) { seen[i] = w; set_toggle(w, want); if (z) set_toggle(z, !want); continue; } // 页刚出现(布局里一律是没勾):先摆成该显示的值,这一帧不当玩家点了 | The page has just appeared (in the layout everything is unchecked): first set it to the value it should show, and do not treat this frame as a player tap
|
||||
int on = TOGGLED(w), pd = atomic_load(&g_pend[i]), shown = pd >= 0 ? pd : atomic_load(&g_val[i]);
|
||||
if (i == 0 && z) { // 点没选中的那一项 = 选它;点已选中的那一项不变(摆回勾上) | Tapping the item that is not selected = select it; tapping the one already selected changes nothing (it is put back to checked)
|
||||
int zon = TOGGLED(z), to = on != shown ? (on ? 1 : shown) : zon != !shown ? (zon ? 0 : shown) : shown;
|
||||
if (to != shown) { atomic_store(&g_pend[0], to); LOG("自定义设置:语言 → %s(点「应用」生效)", to ? "English" : "中文"); }
|
||||
if (TOGGLED(w) != to) set_toggle(w, to); if (TOGGLED(z) != !to) set_toggle(z, !to); continue; }
|
||||
if (on != shown) { atomic_store(&g_pend[i], on); LOG("自定义设置:%s 勾选框 → %s(点「应用」生效)", k_keys[i], on ? "勾上" : "取消"); } }
|
||||
// 语言那一格下面的「重启游戏后生效」提示(TouchCustomLangHint,布局里先放在屏外):勾选框此刻显示的值与正在跑的语言不一致时挪到标签正下方(横坐标取标签的)
|
||||
// The 「重启游戏后生效」(Takes effect after restarting the game) hint under the language cell (TouchCustomLangHint, initially placed off-screen in the layout): when the value the checkbox currently shows differs from the running language it is moved directly below the label (x taken from the label)
|
||||
{ uint64_t hw = find_w(sp, "TouchCustomLangHint", 0), lw = find_w(sp, "TouchCustom_lang_en_Text", 0);
|
||||
if (hw && lw) { int pd = atomic_load(&g_pend[0]), shown = pd >= 0 ? pd : atomic_load(&g_val[0]), x = shown != !dm_lang_zh() ? ((int32_t *)(lw + 0x70))[0] : 99999; int32_t *r = (int32_t *)(hw + 0x70);
|
||||
// 语言那一行下面的「点应用后把 App 关掉重开」提示(TouchCustomLangHint,布局里先放在屏外):勾选框此刻显示的值与正在跑的语言不一致时挪到标签正下方(横坐标取标签的)
|
||||
// The "tap Apply, then close and reopen the app" hint under the language row (TouchCustomLangHint, placed off screen in the layout): moved right under the label (taking the label's x) when the value the checkboxes currently show differs from the language now running
|
||||
{ uint64_t lw = find_w(sp, "TouchCustom_lang_en_Text", 0); int pd = atomic_load(&g_pend[0]), shown = pd >= 0 ? pd : atomic_load(&g_val[0]), diff = shown != !dm_lang_zh();
|
||||
for (int k = 0; k < 2 && lw; k++) { uint64_t hw = find_w(sp, k ? "TouchCustomLangHintEn" : "TouchCustomLangHintZh", 0); if (!hw) continue; // 提示用「选中的那种语言」写:选了中文显示中文那句,选了 English 显示英文那句 | The hint is written in "the language that was chosen": choosing 中文 shows the Chinese sentence, choosing English shows the English one
|
||||
int x = diff && shown == k ? ((int32_t *)(lw + 0x70))[0] : 99999; int32_t *r = (int32_t *)(hw + 0x70);
|
||||
if (r[0] != x) { r[0] = x; ((void (*)(uint64_t))*(uint64_t *)(*(uint64_t *)hw + 0x10))(hw); } } }
|
||||
// 「应用 / 放弃」亮不亮(自定义页改了勾选,「应用」仍是灰的):原版各选项子页的每帧更新 main+0xae5f28 把自己 +0x1a0「有未应用的改动」
|
||||
// 交给 main+0xaed9e4(设置页, 亮否),按钮 +0x57a 是灰的标志;原版的勾选框一改就由面板置 +0x1a0,我们的勾选框原版面板不认识,这一位一直是 0。
|
||||
|
||||
Reference in New Issue
Block a user