462 lines
65 KiB
C
462 lines
65 KiB
C
// 编年史仓库界面:储藏箱第六个页签「编年史」。
|
||
// 布局 dm/ios/tools/wide_stash.py vault_widgets(控件 TouchVault,缺省在屏外),固定表 dm_vault_tab.h(gen_vault_table.py 生成)。全在游戏主线程(dm_actions.c 每帧泵)。
|
||
// 第六页(页签条 +0xdc4 = 5)游戏照常画魔盒那套格子与「提取」钮:这里每帧把它们设成不可见、不收点击,TouchVault 挪回 (0, 0);离开第六页挪回屏外。
|
||
// 格子三种样子(设计第二节):存着 = 编年史奖励格第 1 帧(金框)+ 亮图;编年史收录过没存 = 第 0 帧 + 半透明图 + 金点;没遇到过 = 第 2 帧(暗)+ 更淡的图。
|
||
// 原版事实(宿主实测 / 读码):
|
||
// 图片控件(ImageWidget)+0x90 此刻的帧、+0x94 透明度(布局 frame / transparency,逐字节差分);换图 main+0xac1704(原版编年史列表项 0xb05190 那处),换上后 +0x78 / +0x7c 自动变成图的大小。
|
||
// 编年史收录:玩家数据 +0x220 起三张散列表(+0 套装件 / +0x20 暗金 / +0x40 符文之语),表 {桶数, 桶数组},节点 {下一个, u32 行号},散列 = murmur3 收尾(同登记 main+0x6bd760)。
|
||
// 文字控件字色 +0xbc / +0xc0 / +0xc4(红 / 绿 / 蓝,各 32 位;布局 fontColor,逐字节差分)。这个文字控件不认 ÿc 颜色码(照字画出来)。
|
||
// 勾选框 +0xa88 勾上标志、+0x6e8.. 四个帧号、+0x610 此刻的帧(dm_custom.c);下拉自带文字控件嵌在 +0x718(dm_kills.c kb_sort);文字控件 串 +0x88 / 长 +0x90,改完 main+0xadc434 重排。
|
||
// Chronicle vault UI: the stash's sixth tab 「编年史」(Chronicle).
|
||
// Layout dm/ios/tools/wide_stash.py vault_widgets (widget TouchVault, off screen by default), fixed table dm_vault_tab.h (generated by gen_vault_table.py). All on the game main thread (pumped every frame by dm_actions.c).
|
||
// On page six (tab strip +0xdc4 = 5) the game still draws the cube's set of cells and the 「提取」(Withdraw) button as usual: here every frame they are set invisible and not receiving taps, and TouchVault is moved back to (0, 0); on leaving page six it is moved back off screen.
|
||
// Three looks for a cell (design section 2): stored = chronicle reward cell frame 1 (gold frame) + bright image; recorded in the chronicle but not stored = frame 0 + semi-transparent image + gold dot; never encountered = frame 2 (dark) + an even fainter image.
|
||
// Original game facts (measured on the host / from reading the code):
|
||
// Image widget (ImageWidget) +0x90 current frame, +0x94 transparency (layout frame / transparency, byte-by-byte diff); image swap main+0xac1704 (the site at the original game's chronicle list item 0xb05190), after which +0x78 / +0x7c automatically become the image size.
|
||
// Chronicle records: three hash tables starting at player data +0x220 (+0 set items / +0x20 uniques / +0x40 runewords), table {bucket count, bucket array}, node {next, u32 row number}, hash = murmur3 finalizer (same as the registration main+0x6bd760).
|
||
// Text widget color +0xbc / +0xc0 / +0xc4 (red / green / blue, 32 bits each; layout fontColor, byte-by-byte diff). This text widget does not understand ÿc color codes (it draws them literally).
|
||
// Checkbox +0xa88 checked flag, +0x6e8.. four frame numbers, +0x610 current frame (dm_custom.c); the dropdown's built-in text widget is embedded at +0x718 (dm_kills.c kb_sort); text widget string +0x88 / length +0x90, re-layout with main+0xadc434 after changing.
|
||
#include <ctype.h>
|
||
#include <stdatomic.h>
|
||
#include <time.h>
|
||
#include <stdint.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include "dm.h"
|
||
#include "dm_widget.h"
|
||
#include "dm_vault_tab.h"
|
||
#include "dm_cursor_item.h"
|
||
#include "dm_i18n.h"
|
||
|
||
enum { VCOLS = 3, VROWS = 4, VPER = VCOLS * VROWS, VSET_ROWS = 7, VSET_N = 6, VU_UNIQ_Y = 516, VX0 = 156, VW0 = 1372, VT_TIER_Y = 444 }; // VX0 / VW0 / VT_TIER_Y 同 wide_stash.py VX / VW / PT_Y + 2 × PT_PITCH // 同 wide_stash.py VAULT_* / UNIQ_Y | VX0 / VW0 / VT_TIER_Y same as wide_stash.py VX / VW / PT_Y + 2 × PT_PITCH // same as wide_stash.py VAULT_* / UNIQ_Y
|
||
enum { ST_NONE, ST_SEEN, ST_STORED };
|
||
int dm_vault_has(int kind, int idx); int dm_vault_gen(void); // dm_vault.c
|
||
static _Atomic int g_dirty = 1, g_flip, g_sub_req = -1;
|
||
static int g_sub, g_part, g_page[VT_NPART + 1], g_tiers = 7; // g_page[VT_NPART] = 套装页 | g_page[VT_NPART] = set page
|
||
static int g_pg_cur, g_pg_tot; // 底部页码:第几页(1 起)、共几页 | Bottom page number: which page (from 1), total pages
|
||
static int g_drop_id; // 拖进编年史页、等放回原格后存入的那件 | The item dragged into the chronicle page, to be stored once it is put back into its original cell
|
||
static char g_query[64]; static int g_page_q;
|
||
static int g_tip_on; // 说明框开着时 = 哪一格 + 1 // 搜索字(空 = 按部位看)、搜索结果翻到第几页 | While the tooltip is open = which cell + 1 // search text (empty = browse by slot), which page of the search results
|
||
static int g_cell_row[VPER], g_set_row[VSET_ROWS][VSET_N]; // 屏上每一格对应 vt_rows 的哪一行(−1 = 空),画的时候记,点按时查 | Which vt_rows row each on-screen cell corresponds to (−1 = empty); recorded when drawing, looked up on tap
|
||
|
||
static uint8_t *vu_base(void) { static uint8_t *b; if (!b) for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) b = (uint8_t *)g_mod[i].base; return b; }
|
||
static uint64_t vu_find(uint64_t w, const char *name, int dep) { // 按名字找控件:名字 +8、子控件数组 +0x58、个数 +0x60(同 dm_kills.c) | Find a widget by name: name +8, child array +0x58, count +0x60 (same as dm_kills.c)
|
||
if (!w || dep > 12) return 0; const char *nm = *(const char **)(w + 8); if (nm && !strcmp(nm, name)) return w;
|
||
uint64_t ch = *(uint64_t *)(w + 0x58), n = *(uint64_t *)(w + 0x60); if (!ch || n > 256) return 0;
|
||
for (uint64_t i = 0; i < n; i++) { uint64_t r = vu_find(*(uint64_t *)(ch + 8 * i), name, dep + 1); if (r) return r; }
|
||
return 0;
|
||
}
|
||
// 只许写我们自己的控件(编年史仓库是独立页面:原版储藏箱的任何控件一律不写可见性、位置、内容):
|
||
// 沿父链(+0x30)往上找,自己或某一层叫 TouchVault / TouchPgPage 才写;否则报红、不写(丢装备事故:写了原版 grid 的可见位、游戏从不重设)
|
||
// Only our own widgets may be written (the chronicle vault is a standalone page: no visibility, position or content of any original stash widget is ever written):
|
||
// walk up the parent chain (+0x30) and write only if the widget itself or some ancestor is named TouchVault / TouchPgPage; otherwise report a failure and do not write (the lost-gear incident: the visible bit of the original grid was written, and the game never resets it)
|
||
static int vu_ours(uint64_t w) {
|
||
for (int k = 0; w && k < 16; k++, w = *(uint64_t *)(w + 0x30)) { const char *nm = *(const char **)(w + 8); if (nm && (!strcmp(nm, "TouchVault") || !strcmp(nm, "TouchPgPage"))) return 1; }
|
||
return 0;
|
||
}
|
||
static int vu_guard(uint64_t w, const char *what) {
|
||
if (!w) return 0; if (vu_ours(w)) return 1;
|
||
static int n; if (n++ < 20) { const char *nm = *(const char **)(w + 8); LOG("【红】编年史仓库:%s 想写原版控件「%s」,拦下(只许写 TouchVault 底下的)", what, nm ? nm : "?"); }
|
||
return 0;
|
||
}
|
||
static void vu_show(uint64_t w, int on) { if (vu_guard(w, "改可见")) { *(uint8_t *)(w + 0x50) = (uint8_t)on; *(uint8_t *)(w + 0x51) = (uint8_t)on; } } // +0x50 可见、+0x51 收点击 | +0x50 visible, +0x51 receives taps
|
||
static void vu_move(uint64_t w, int x, int y) { if (!vu_guard(w, "挪位置")) return; int32_t *r = (int32_t *)(w + 0x70); if (r[0] == x && r[1] == y) return; r[0] = x; r[1] = y; ((void (*)(uint64_t))*(uint64_t *)(*(uint64_t *)w + 0x10))(w); } // 矩形 +0x70,改完虚表 +0x10 重排 | Rect +0x70; after changing, vtable +0x10 re-layout
|
||
// 图片控件换图:串对象 {指针, 长度, 容量 | 最高位 = 用内联缓冲} 交 main+0xac1704(控件, &串)。路径相对 hd/global/ui、不带扩展名
|
||
// Change an image widget's image: pass the string object {pointer, length, capacity | top bit = uses inline buffer} to main+0xac1704(widget, &string). The path is relative to hd/global/ui, without extension
|
||
static void vu_image(uint8_t *b, uint64_t w, const char *path) {
|
||
if (!vu_guard(w, "换图")) return; struct { char *p; uint64_t n, cap; char buf[0xa0]; } s; size_t n = strlen(path); if (n >= sizeof s.buf) return;
|
||
memcpy(s.buf, path, n + 1); s.p = s.buf; s.n = n; s.cap = (sizeof s.buf - 1) | 1ull << 63;
|
||
((void (*)(uint64_t, void *))(b + 0xac1704))(w, &s);
|
||
}
|
||
static void vu_text(uint8_t *b, uint64_t w, const char *s) { // 文字控件(虚表 main+0x20ba4c8)改字;没变不写(同 dm_kills.c kb_text) | Change a text widget's text (vtable main+0x20ba4c8); no write if unchanged (same as dm_kills.c kb_text)
|
||
if (!vu_guard(w, "改字") || *(uint64_t *)w - (uint64_t)(uintptr_t)b != 0x20ba4c8) return;
|
||
size_t n = strlen(s); if (*(uint64_t *)(w + 0x90) == n && !memcmp(*(const char **)(w + 0x88), s, n)) return;
|
||
((void *(*)(uint64_t, const char *, uint64_t))(b + 0x136e5c))(w + 0x88, s, n); ((void (*)(uint64_t))(b + 0xadc434))(w);
|
||
}
|
||
static int vu_is(uint64_t w, uint64_t vt);
|
||
static void vu_frame(uint64_t w, int f) { // 图片控件换帧(+0x90 此刻的帧);只写我们自己的控件 | Change an image widget's frame (+0x90 current frame); only writes our own widgets
|
||
if (!w || !vu_guard(w, "换帧") || !vu_is(w, DM_VT_IMAGE) || *(int32_t *)(w + 0x90) == f) return; *(int32_t *)(w + 0x90) = f;
|
||
}
|
||
static void vu_color(uint8_t *b, uint64_t w, int r, int g, int bl) { // 文字控件改字色(+0xbc 起 RGB 三个 32 位);变了才重排 | Change a text widget's color (three 32-bit RGB values from +0xbc); re-layout only when changed
|
||
if (!vu_guard(w, "改字色") || *(uint64_t *)w - (uint64_t)(uintptr_t)b != 0x20ba4c8) return; int32_t *c = (int32_t *)(w + 0xbc); if (c[0] == r && c[1] == g && c[2] == bl) return;
|
||
c[0] = r; c[1] = g; c[2] = bl; ((void (*)(uint64_t))(b + 0xadc434))(w);
|
||
}
|
||
static const char *vu_str(uint8_t *b, const char *key) { struct { const char *k; uint64_t n; } s = { key, strlen(key) }; const char *r = ((const char *(*)(void *))(b + 0x7f5630))(&s); return r && *r ? r : key; } // 取本地化串(旧译名开着时游戏自己换) | Get a localized string (the game swaps it itself when legacy translations are on)
|
||
// 格子里只写名字本身:开了「物品注释」(自定义页,annot_strings.py)时名字串是多行「[范围行\n]ÿc2点评\n<名字色>名字」(游戏倒着画,最后一行在最上面),
|
||
// 取最后一行、去掉开头的颜色码(ÿc + 一个字符:UTF-8 C3 BF 63,或游戏内部的 U+E07E = EE 81 BE),格子里放不下多行(Mac 上的 iOS 包实测整格被注释占满)
|
||
// Only the name itself goes in the cell: with 「物品注释」(Item Annotations) on (custom page, annot_strings.py) the name string is the multi-line "[range line\
|
||
// ]ÿc2comment\
|
||
// <name color>name" (the game draws in reverse, with the last line on top),
|
||
// so take the last line and strip the leading color code (ÿc + one character: UTF-8 C3 BF 63, or the game's internal U+E07E = EE 81 BE); multiple lines do not fit in a cell (measured with the iOS app on Mac: the whole cell was filled by the annotation)
|
||
static const char *vu_name(uint8_t *b, const char *key) {
|
||
static char out[160]; const char *s = vu_str(b, key), *nl = strrchr(s, '\n'); if (nl) s = nl + 1;
|
||
for (;;) { if ((uint8_t)s[0] == 0xc3 && (uint8_t)s[1] == 0xbf && s[2] == 'c' && s[3]) s += 4; else if ((uint8_t)s[0] == 0xee && (uint8_t)s[1] == 0x81 && (uint8_t)s[2] == 0xbe && s[3]) s += 4; else break; }
|
||
strlcpy(out, s, sizeof out); return out;
|
||
}
|
||
// 按偏移读写控件字段之前核它确是那个类(虚表相对 main 的偏移):「是我们自己布局里的控件」只是今天的事实,不是不变式——
|
||
// 名字对上而类不对(布局改了类型、重建中的半成品)时按偏移取到的是别的字段。不是就不读不写,记一次红
|
||
// Before reading or writing widget fields by offset, check that it really is that class (vtable offset relative to main): "it is a widget from our own layout" is only today's fact, not an invariant --
|
||
// when the name matches but the class does not (the layout changed the type, or a half-built widget during a rebuild), what is fetched by offset is some other field. If it is not that class, neither read nor write, and report a failure once
|
||
enum { VT_TOGGLE = DM_VT_TOGGLE, VT_TABBAR = DM_VT_TABBAR }; // 勾选框 / 子页签(ToggleButtonWidget);页签条(TabBarWidget,同 dm_cursor.c) | Checkbox / sub-tab (ToggleButtonWidget); tab bar (TabBarWidget, same as dm_cursor.c)
|
||
static int vu_is(uint64_t w, uint64_t vt) { uint8_t *b = vu_base(); if (!w || !b) return 0; if (dm_widget_is(b, w, vt)) return 1;
|
||
static int n; if (n++ < 10) { const char *nm = *(const char **)(w + 8); LOG("【红】编年史仓库:控件「%s」不是预期的类(虚表 main+0x%llx,应为 0x%llx),不按偏移读写", nm ? nm : "?", (unsigned long long)(*(uint64_t *)w - (uint64_t)(uintptr_t)b), (unsigned long long)vt); }
|
||
return 0; }
|
||
static void vu_toggle(uint64_t w, int on) { // 同 dm_kills.c kb_toggle(勾选框四帧 / 子页签两帧) | Same as dm_kills.c kb_toggle (checkbox four frames / sub-tab two frames)
|
||
if (!vu_guard(w, "改勾选") || !vu_is(w, VT_TOGGLE)) return; static const int32_t fr[2][4] = { { 0, 1, 3, 2 }, { 4, 5, 6, -1 } }; int32_t f[4]; int k = *(int32_t *)(w + 0x6f0) == 3 || *(int32_t *)(w + 0x6e8) == 4;
|
||
if (k) memcpy(f, fr[on != 0], sizeof f); else for (int i = 0; i < 4; i++) f[i] = on ? 1 : 0;
|
||
*(uint8_t *)(w + 0xa88) = on != 0; memcpy((void *)(w + 0x6e8), f, sizeof f); *(int32_t *)(w + 0x610) = f[0];
|
||
}
|
||
// 编年史收录过没有:客户端玩家(main+0x45f9d0([main+0x2d20e4c]))的玩家数据 +0x220 起三张散列表
|
||
// Whether the chronicle has recorded it: three hash tables starting at player data +0x220 of the client player (main+0x45f9d0([main+0x2d20e4c]))
|
||
static int vu_seen(uint8_t *b, int kind, int row) {
|
||
uint64_t pl = ((uint64_t (*)(uint32_t))(b + 0x45f9d0))(*(uint32_t *)(b + 0x2d20e4c)), pd = pl ? *(uint64_t *)(pl + 0x10) : 0; if (!pd) return 0;
|
||
uint64_t t = pd + 0x220 + (kind == 1 ? 0x20 : 0), nb = *(uint64_t *)t, bk = *(uint64_t *)(t + 8); if (!bk || !nb || (nb & (nb - 1))) return 0;
|
||
uint64_t h = (uint64_t)(uint16_t)row * 0xff51afd7ed558ccdull; h ^= h >> 33; h *= 0xc4ceb9fe1a85ec53ull; h ^= h >> 33;
|
||
for (uint64_t n = *(uint64_t *)(bk + 8 * (h & (nb - 1))), k = 0; n && k < 4096; n = *(uint64_t *)n, k++) if (*(uint32_t *)(n + 8) == (uint32_t)row) return 1;
|
||
return 0;
|
||
}
|
||
// 测试(出/ 验排版用,只影响显示):DM_TEST_VAULT_SETS=N——前 N 套套装的每一件都当作「存着」,套装页前 N 行就是集齐的样子
|
||
// Test (for producing / checking the layout, affects display only): DM_TEST_VAULT_SETS=N -- every piece of the first N sets is treated as "stored", so the first N rows of the set page look the way they do when completed
|
||
static int vu_state(uint8_t *b, const vt_row *r) { static int tn = -1; if (tn < 0) { const char *e = getenv("DM_TEST_VAULT_SETS"); tn = e ? atoi(e) : 0; }
|
||
if (r->kind == 0 && r->set < tn) return ST_STORED;
|
||
return dm_vault_has(r->kind, r->row) ? ST_STORED : vu_seen(b, r->kind, r->row) ? ST_SEEN : ST_NONE; }
|
||
// 一格的图:底图帧(状态)+ 物品图(换图后按图的大小缩进格子框里、居中)+ 透明度
|
||
// One cell's images: background frame (state) + item image (after the image swap, scaled to fit inside the cell frame by the image size and centered) + transparency
|
||
static void vu_tile(uint8_t *b, uint64_t cell, const char *tile, const vt_row *r, int st) {
|
||
char nm[24]; uint64_t t = vu_find(cell, tile, 0); snprintf(nm, sizeof nm, "%sBox", tile); uint64_t box = vu_find(cell, nm, 0); snprintf(nm, sizeof nm, "%sImg", tile); uint64_t im = vu_find(cell, nm, 0);
|
||
if (!t || !box || !im) return;
|
||
uint64_t cg = vu_find(cell, "CellGold", 0); snprintf(nm, sizeof nm, "%sGold", tile); vu_show(vu_find(cell, nm, 0), st == ST_STORED && !cg); vu_show(cg, st == ST_STORED); // 暗金格:整格金框(只一个框);套装件格:那一件自己的框 // 存着 = 金框(暗金页整格、套装页那一件) | Unique cell: gold frame around the whole cell (one frame only); set item cell: that piece's own frame // stored = gold frame (whole cell on the unique page, that piece on the set page)
|
||
static struct { uint64_t w; const char *icon; } cache[VPER + VSET_ROWS * VSET_N]; int ci = -1, fr = -1;
|
||
for (int i = 0; i < (int)(sizeof cache / sizeof cache[0]); i++) { if (cache[i].w == im) { ci = i; break; } if (fr < 0 && !cache[i].w) fr = i; }
|
||
if (ci < 0 && fr >= 0) { ci = fr; cache[ci].w = im; cache[ci].icon = NULL; }
|
||
if (ci >= 0 && cache[ci].icon != r->icon) { cache[ci].icon = r->icon; vu_image(b, im, r->icon); *(int32_t *)(im + 0x70) = 0; *(int32_t *)(im + 0x74) = 0; *(float *)(im + 0x80) = 1.0f; }
|
||
int bw = *(int32_t *)(box + 0x78), bh = *(int32_t *)(box + 0x7c), iw = *(int32_t *)(im + 0x78), ih = *(int32_t *)(im + 0x7c);
|
||
if (iw > 0 && ih > 0 && bw > 0 && bh > 0) { float s = (float)bw / iw < (float)bh / ih ? (float)bw / iw : (float)bh / ih; if (s > 1.0f) s = 1.0f;
|
||
*(float *)(im + 0x80) = s; vu_move(im, (int)((bw - iw * s) / 2), (int)((bh - ih * s) / 2)); }
|
||
*(float *)(im + 0x94) = st == ST_STORED ? 1.0f : st == ST_SEEN ? 0.55f : 0.3f;
|
||
}
|
||
static void vu_uniques(uint8_t *b, uint64_t vt) {
|
||
int list[128], n = 0, nst = 0, nseen = 0;
|
||
for (int i = 0; i < VT_NROW && n < 128; i++) { const vt_row *r = &vt_rows[i]; if (r->kind != 1 || r->part != g_part || !(g_tiers >> r->tier & 1)) continue; list[n++] = i; int st = vu_state(b, r); nst += st == ST_STORED; nseen += st != ST_NONE; }
|
||
int pages = n ? (n + VPER - 1) / VPER : 1; int *pg = &g_page[g_part]; if (*pg >= pages) *pg = pages - 1; if (*pg < 0) *pg = 0;
|
||
char buf[160]; snprintf(buf, sizeof buf, dm_str(b, "dmVaultStats"), n, nst, nseen); vu_text(b, vu_find(vt, "TouchV_Stats", 0), buf); // 部位名在下拉里(大字号下整行放不下) | The slot name is in the dropdown (the whole line does not fit at the large font size)
|
||
uint64_t u = vu_find(vt, "TouchV_Uniq", 0);
|
||
for (int k = 0; k < VPER; k++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_U%d", k); uint64_t c = vu_find(u, nm, 0); if (!c) continue;
|
||
int j = *pg * VPER + k; g_cell_row[k] = j < n ? list[j] : -1; if (j >= n) { vu_show(c, 0); continue; } vu_show(c, 1);
|
||
const vt_row *r = &vt_rows[list[j]]; int st = vu_state(b, r); vu_tile(b, c, "Tile", r, st);
|
||
uint64_t nw = vu_find(c, "Name", 0), dm = vu_find(c, "Sub", 0); // 字色照:存着 金 / 收录过 暗金 + 蓝字 / 没遇到过 灰 | Text color follows: stored gold / recorded dark gold + blue text / never encountered gray
|
||
if (st == ST_STORED) { vu_color(b, nw, 199, 179, 119); vu_color(b, dm, 232, 210, 150); } else if (st == ST_SEEN) { vu_color(b, nw, 170, 160, 130); vu_color(b, dm, 150, 190, 255); } else { vu_color(b, nw, 110, 108, 100); vu_color(b, dm, 120, 118, 110); }
|
||
vu_text(b, nw, vu_name(b, r->key)); vu_text(b, dm, st == ST_STORED ? dm_str(b, "dmVaultStored") : st == ST_SEEN ? dm_str(b, "dmVaultSeen") : dm_str(b, "dmVaultNone"));
|
||
vu_text(b, vu_find(c, "Dot", 0), st == ST_SEEN ? "●" : ""); }
|
||
g_pg_cur = *pg + 1; g_pg_tot = pages;
|
||
}
|
||
static void vu_sets(uint8_t *b, uint64_t vt) {
|
||
int pages = (VT_NSET + VSET_ROWS - 1) / VSET_ROWS, *pg = &g_page[VT_NPART]; if (*pg >= pages) *pg = pages - 1; if (*pg < 0) *pg = 0;
|
||
int tot = 0, nst = 0; for (int i = 0; i < VT_NROW; i++) if (vt_rows[i].kind == 0) { tot++; nst += dm_vault_has(0, vt_rows[i].row); }
|
||
char buf[160]; snprintf(buf, sizeof buf, dm_str(b, "dmVaultSetStats"), VT_NSET, nst, tot); vu_text(b, vu_find(vt, "TouchV_Stats", 0), buf);
|
||
uint64_t sg = vu_find(vt, "TouchV_Sets", 0);
|
||
for (int r = 0; r < VSET_ROWS; r++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_S%d", r); uint64_t row = vu_find(sg, nm, 0); if (!row) continue;
|
||
int s = *pg * VSET_ROWS + r; for (int j = 0; j < VSET_N; j++) g_set_row[r][j] = -1; if (s >= VT_NSET) { vu_show(row, 0); continue; } vu_show(row, 1);
|
||
int k = 0, have = 0;
|
||
for (int i = 0; i < VT_NROW && k < VSET_N; i++) { const vt_row *e = &vt_rows[i]; if (e->kind != 0 || e->set != s) continue; int st = vu_state(b, e); have += st == ST_STORED;
|
||
g_set_row[r][k] = i; char tn[16]; snprintf(tn, sizeof tn, "Tile%dDot", k); vu_text(b, vu_find(row, tn, 0), st == ST_SEEN ? "●" : ""); snprintf(tn, sizeof tn, "Tile%d", k); vu_show(vu_find(row, tn, 0), 1); snprintf(nm, sizeof nm, "Tile%dBox", k); vu_show(vu_find(row, nm, 0), 1); vu_tile(b, row, tn, e, st); k++; }
|
||
int n = k; for (; k < VSET_N; k++) { static const char *const sfx[] = { "", "Gold", "Box", "Dot" }; for (int q = 0; q < 4; q++) { char tn[20]; snprintf(tn, sizeof tn, "Tile%d%s", k, sfx[q]); vu_show(vu_find(row, tn, 0), 0); } }
|
||
vu_text(b, vu_find(row, "Name", 0), vu_name(b, vt_set_key[s]));
|
||
uint64_t cw = vu_find(row, "Count", 0); if (have == n) vu_color(b, cw, 199, 179, 119); else vu_color(b, cw, 191, 191, 191); // 存齐了金字、整行金框(「存齐的那一行高亮」) | Fully collected: gold text and a gold frame around the whole row ("the fully collected row is highlighted")
|
||
vu_show(vu_find(row, "BgGold", 0), have == n);
|
||
snprintf(buf, sizeof buf, dm_str(b, have == n ? "dmVaultSetFull" : "dmVaultSetHave"), have, n); vu_text(b, cw, buf); }
|
||
g_pg_cur = *pg + 1; g_pg_tot = pages;
|
||
}
|
||
// 说明框(第 5 步,设计第二节「看一件」):照原版编年史出说明那条路(main+0xafa85c,dm_runeword.c rw_desc 同法)——
|
||
// main+0x367890(类型 1 暗金 / 0 套装件, 表行号, 1, 1) 造临时预览物品(经 x8 返回 {删除器, …, +0x28 物品});属性 = 记录 +0x98 起 {属性, 参数, 最小, 最大}(暗金 12 条、套装件 9 条,属性 < 0 止,
|
||
// 宿主按 UniqueItems / SetItems 第 0 行逐字节对出);main+0x374f00(玩家, 玩家, 物品, 0, 1, 0, 属性列表, &{条数, 1}) 经 x8 返回整段说明(带范围,行序倒排);照 0xafaee8 销毁预览物品。
|
||
// Tooltip (step 5, design section 2 "viewing one item"): follows the original game's chronicle description path (main+0xafa85c, same approach as dm_runeword.c rw_desc) -
|
||
// main+0x367890(type 1 unique / 0 set item, table row number, 1, 1) builds a temporary preview item (returning via x8 {deleter, ..., +0x28 item}); properties = {property, param, min, max} starting at record +0x98 (12 entries for uniques, 9 for set items, stops at property < 0,
|
||
// matched byte by byte on the host against row 0 of UniqueItems / SetItems); main+0x374f00(player, player, item, 0, 1, 0, property list, &{count, 1}) returns the whole description via x8 (with ranges, line order reversed); destroy the preview item following 0xafaee8.
|
||
typedef struct { char *p; uint64_t len, cap; } gstr_t;
|
||
typedef struct { uint64_t d[5]; uint64_t item; } preview_t;
|
||
static void vu_gfree(uint8_t *b, void *p) { if (!(*(volatile uint8_t *)(b + 0x3211700) & 1)) return; uint64_t a = *(uint64_t *)(b + 0x32116f8); ((void (*)(uint64_t, void *))(*(uint64_t *)(*(uint64_t *)a + 0x28)))(a, p); }
|
||
static void vu_preview_drop(uint8_t *b, preview_t *h) { // 同 dm_runeword.c preview_drop | Same as dm_runeword.c preview_drop
|
||
uint64_t *obj = (h->d[0] & 1) ? (uint64_t *)(h->d[0] & ~1ull) : (uint64_t *)h;
|
||
if (h->item) { uint64_t it = h->item; ((void (*)(void *, uint64_t *))(*(uint64_t *)(*obj + 0x10)))(obj, &it); h->item = 0; }
|
||
obj = (h->d[0] & 1) ? (uint64_t *)(h->d[0] & ~1ull) : (uint64_t *)h;
|
||
if (obj) { ((void (*)(void *))(*(uint64_t *)(*obj)))(obj); if (h->d[0] & 1) vu_gfree(b, obj); }
|
||
h->d[0] = 1;
|
||
}
|
||
static int vu_desc(uint8_t *b, const vt_row *e, char *out, size_t n) {
|
||
out[0] = 0; uint8_t ver = *(uint8_t *)(b + 0x2127c48); if (ver < 1 || ver > 3) return 0;
|
||
uint64_t t = *(uint64_t *)(b + 0x2d64a18 + ver * 16), pl = ((uint64_t (*)(uint32_t))(b + 0x45f9d0))(*(uint32_t *)(b + 0x2d20e4c)); if (!t || !pl) return 0;
|
||
uint64_t rr = *(uint64_t *)(t + (e->kind ? 0x13e8 : 0x13c8)), rn = *(uint64_t *)(t + (e->kind ? 0x13f0 : 0x13d0)); if (!rr || e->row >= rn) return 0;
|
||
const uint8_t *rec = (const uint8_t *)(rr + (uint64_t)e->row * (e->kind ? 0x15c : 0x1cc));
|
||
preview_t h = ((preview_t (*)(int, int, int, int))(b + 0x367890))(e->kind ? 1 : 0, e->row, 1, 1);
|
||
if (!h.item) { vu_preview_drop(b, &h); return 0; }
|
||
uint8_t props[16 * 12]; uint64_t np = 0; for (int k = 0; k < (e->kind ? 12 : 9) && *(int32_t *)(rec + 0x98 + 16 * k) >= 0; k++) memcpy(props + 16 * np++, rec + 0x98 + 16 * k, 16);
|
||
struct { uint64_t n; uint8_t has; } cnt = { np, 1 };
|
||
gstr_t r = ((gstr_t (*)(uint64_t, uint64_t, uint64_t, int, int, int, void *, void *))(b + 0x374f00))(pl, pl, h.item, 0, 1, 0, props, &cnt);
|
||
size_t k = r.p && r.len < n ? r.len : (r.p ? n - 1 : 0); if (k) memcpy(out, r.p, k); out[k] = 0;
|
||
if (r.p && !(r.cap >> 63)) vu_gfree(b, r.p);
|
||
vu_preview_drop(b, &h);
|
||
return (int)k;
|
||
}
|
||
static void vu_tip_place(uint64_t tb, uint64_t bg) { // 说明框按字的大小摆在编年史页正中、底框包住字;文字控件量尺寸(fitToText)要晚一两帧,开着时每帧对齐 | The tooltip is placed at the center of the chronicle page according to the text size, with the background frame enclosing the text; the text widget's size measurement (fitToText) lags a frame or two, so align every frame while open
|
||
int w = *(int32_t *)(tb + 0x78), h = *(int32_t *)(tb + 0x7c); if (w <= 0 || h <= 0) return;
|
||
int x = 156 + (1372 - w) / 2, y = 296 + (820 - h) / 2; if (y < 150) y = 150;
|
||
int32_t *r = (int32_t *)(bg + 0x70); if (r[2] != w + 80 || r[3] != h + 60) { r[2] = w + 80; r[3] = h + 60; r[0] = -1; }
|
||
vu_move(bg, x - 40, y - 30); vu_move(tb, x, y);
|
||
}
|
||
static void vu_tip_exact(uint8_t *b, uint64_t vt) { // 存着那件的说明到了(dm_vault.c 服务端拍里出的):换上,顶行照旧 | The stored item's description has arrived (produced in the server tick by dm_vault.c): swap it in, top line unchanged
|
||
static char d[4096]; int dm_vault_take_desc(char *, size_t); if (!dm_vault_take_desc(d, sizeof d - 64)) return; size_t n = strlen(d);
|
||
snprintf(d + n, sizeof d - n, "\n%s", dm_str(b, "dmVaultStoredTip")); vu_text(b, vu_find(vt, "TouchV_Tip", 0), d); LOG("编年史仓库:说明框换成存着那件自己的数(%zu 字节)", n);
|
||
}
|
||
static void vu_tip(uint8_t *b, uint64_t vt, const vt_row *e) { // e = NULL 收起说明框 | e = NULL closes the tooltip
|
||
uint64_t tb = vu_find(vt, "TouchV_Tip", 0), bg = vu_find(vt, "TouchV_TipBg", 0); if (!tb || !bg) return;
|
||
if (!e) { vu_move(tb, 99999, 0); vu_move(bg, 99999, 0); return; }
|
||
static char d[4096]; int n = vu_desc(b, e, d, sizeof d - 160); int st = vu_state(b, e);
|
||
if (st == ST_STORED) { void dm_vault_request_desc(int, int); dm_vault_request_desc(e->kind, e->row); } // 存着的:先出范围版,服务端拍里拿它自己的数,到了替换(vu_tip_exact) | Stored: show the range version first, the server tick fetches the item's own numbers, and it is replaced when they arrive (vu_tip_exact)
|
||
snprintf(d + n, sizeof d - n, "%s%s", n ? "\n" : "", st == ST_STORED ? dm_str(b, "dmVaultStoredTip") : st == ST_SEEN ? dm_str(b, "dmVaultSeen") : dm_str(b, "dmVaultNone")); // 行序倒排:串尾这一行显示在最上面 | Line order reversed: this line at the end of the string is displayed at the top
|
||
vu_text(b, tb, d); vu_tip_place(tb, bg);
|
||
}
|
||
static int vu_hit(uint64_t w, int x, int y) { return w && *(uint8_t *)(w + 0x50) && (((int (*)(uint64_t, uint64_t))*(uint64_t *)(*(uint64_t *)w + 0x48))(w, (uint64_t)(uint32_t)x | ((uint64_t)(uint32_t)y << 32)) & 1); } // 控件命中(虚表 +0x48,同 dm_cursor.c) | Widget hit test (vtable +0x48, same as dm_cursor.c)
|
||
// 交互层(dm_cursor.c 界面点击入口,游戏主线程):第六页上点了一下。命中某一格 = 吃掉这一下(不发鼠标):同一格 0.4 秒内(同 DM_TC_DOUBLE_TAP_S)第二下 = 取出(存着的才取,
|
||
// 空格不动);单击留给说明框(第 5 步)。没命中格子返回 0,照常发鼠标(子页签、下拉、勾选、箭头由游戏自己收)
|
||
// Interaction layer (dm_cursor.c UI tap entry, game main thread): a tap on page six. Hitting a cell = swallow this tap (no mouse event sent): a second tap on the same cell within 0.4 seconds (same as DM_TC_DOUBLE_TAP_S) = withdraw (only stored ones are withdrawn,
|
||
// empty cells do nothing); a single tap is left for the tooltip (step 5). Returns 0 when no cell is hit, and the mouse event is sent as usual (sub-tabs, dropdown, checkboxes, arrows are handled by the game itself)
|
||
int dm_vault_ui_over(int x, int y);
|
||
int dm_vault_ui_blocks(int x, int y);
|
||
static int vu_cell_at(uint64_t vt, int x, int y, int *cell) { // 视口像素点落在哪一格:返回 vt_rows 行(−1 = 没有),cell = 屏上格号(套装 100 + 行 × 6 + 件) | Which cell a viewport pixel point falls in: returns the vt_rows row (−1 = none), cell = on-screen cell number (sets: 100 + row × 6 + piece)
|
||
int row = -1; *cell = -1;
|
||
if (g_sub == 0 || g_query[0]) { uint64_t u = vu_find(vt, "TouchV_Uniq", 0); for (int k = 0; k < VPER && row < 0; k++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_U%d", k); uint64_t c = vu_find(u, nm, 0); if (vu_hit(c ? vu_find(c, "Bg", 0) : 0, x, y) && g_cell_row[k] >= 0) { row = g_cell_row[k]; *cell = k; } } }
|
||
else { uint64_t sg = vu_find(vt, "TouchV_Sets", 0); for (int r = 0; r < VSET_ROWS && row < 0; r++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_S%d", r); uint64_t rw = vu_find(sg, nm, 0);
|
||
for (int j = 0; rw && j < VSET_N && row < 0; j++) { char tn[16]; snprintf(tn, sizeof tn, "Tile%d", j); if (vu_hit(vu_find(rw, tn, 0), x, y) && g_set_row[r][j] >= 0) { row = g_set_row[r][j]; *cell = 100 + r * VSET_N + j; } } } }
|
||
return row;
|
||
}
|
||
// 交互层查询(游戏主线程):这一点在编年史页上、又不是我们自己的可点控件(子页签、下拉、勾选、搜索框)——鼠标的点击和悬停都不许发给游戏:
|
||
// 底下是原版魔盒容器,点会点到它、悬停会冒出它「提取」钮的原版说明(宿主截图:点底部盖板后弹出「从上赛季高级储藏箱提取物品」)
|
||
// Interaction layer query (game main thread): this point is on the chronicle page and is not one of our own tappable widgets (sub-tabs, dropdown, checkboxes, search box) - neither mouse clicks nor hovers may be sent to the game:
|
||
// underneath is the original game's cube container; a tap would hit it, and a hover would bring up the original tooltip of its 「提取」(Withdraw) button (host screenshot: after tapping the bottom cover, 「从上赛季高级储藏箱提取物品」(Extract items from last season's advanced stash) popped up)
|
||
int dm_vault_ui_blocks(int x, int y) {
|
||
if (!dm_vault_ui_over(x, y)) return 0;
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0; if (!vt) return 0;
|
||
static const char *const ours[] = { "TouchV_SubU", "TouchV_SubS", "TouchV_T0", "TouchV_T1", "TouchV_T2", "TouchV_SearchBg" };
|
||
for (unsigned i = 0; i < sizeof ours / sizeof ours[0]; i++) if (vu_hit(vu_find(vt, ours[i], 1), x, y)) return 0;
|
||
return 1;
|
||
}
|
||
int dm_vault_ui_tap(int x, int y) {
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0; if (!vt) return 0;
|
||
{ uint64_t dl = vu_find(root, "DropdownListContents", 1); if (dl && *(uint8_t *)(dl + 0x50)) return 0; } // 下拉选项开着:这一下归选项(压在格子上,宿主实测:点选项被当成点了底下那格) | Dropdown options open: this tap belongs to the options (they sit on top of the cells; measured on the host: tapping an option was treated as tapping the cell underneath)
|
||
// 翻页条的点按区(比箭头图形大的两块命中框):宿主自己收。要排在格子判定之前——后面的格子逻辑有 0.4 秒双击判定,连点翻页不能落进去;说明框开着先收
|
||
// Tap areas of the page bar (two hit boxes larger than the arrow graphics): handled by the host itself. Must come before the cell check -- the cell logic further down has a 0.4-second double-tap check, and repeated page-turn taps must not fall into it; if a tooltip is open, close it first
|
||
{ int dm_vault_ui_pager_hit(int, int); void dm_vault_ui_flip(int); int d = dm_vault_ui_pager_hit(x, y);
|
||
if (d) { if (g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; } dm_vault_ui_flip(d); return 1; } }
|
||
if (g_sub == 0) for (int p = 0; p < VT_NPART; p++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_PT%d", p); uint64_t t = vu_find(vt, nm, 1); // 部位页签:宿主自己收,不发鼠标 | Slot tabs: handled by the host itself, no mouse event sent
|
||
if (t && vu_hit(vu_find(t, "Hit", 0), x, y)) { if (g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; } if (p != g_part) { g_part = p; atomic_store(&g_dirty, 1); LOG("编年史仓库:点部位页签 %s", vt_part_name[p]); } return 1; } }
|
||
int cell = -1, row = vu_cell_at(vt, x, y, &cell);
|
||
if (row < 0) { if (g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; }
|
||
// 我们自己的可点控件(子页签、下拉、勾选、搜索框)照常发鼠标给游戏;编年史页上别的地方一律吃掉:底下是原版魔盒容器,不许点到它(独立页面)
|
||
// Our own tappable widgets (sub-tabs, dropdown, checkboxes, search box) send mouse events to the game as usual; everywhere else on the chronicle page is swallowed: underneath is the original game's cube container, which must not be tapped (standalone page)
|
||
return dm_vault_ui_blocks(x, y); }
|
||
struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); double now = ts.tv_sec + ts.tv_nsec / 1e9; static double last; static int lcell = -1;
|
||
const vt_row *e = &vt_rows[row]; int dbl = cell == lcell && now - last < 0.40;
|
||
if (dbl) { last = 0; lcell = -1;
|
||
if (dm_vault_has(e->kind, e->row)) { void dm_vault_request_withdraw(int, int); dm_vault_request_withdraw(e->kind, e->row); LOG("编年史仓库:双击 %s(%s %d)→ 取出", e->key, e->kind ? "暗金" : "套装件", e->row); }
|
||
else LOG("编年史仓库:双击 %s —— 这一格没存,不动", e->key); }
|
||
else { last = now; lcell = cell; LOG("编年史仓库:点了 %s(%s)", e->key, dm_vault_has(e->kind, e->row) ? "存着" : "没存"); }
|
||
if (dbl || g_tip_on == cell + 1) { vu_tip(b, vt, NULL); g_tip_on = 0; } else { vu_tip(b, vt, e); g_tip_on = cell + 1; } // 单击出说明,再点同一格 / 双击收起 | Single tap shows the description; tapping the same cell again / double-tapping closes it
|
||
return 1;
|
||
}
|
||
uint32_t dm_vault_ui_held(void) { // 客户端玩家光标上那件的 id(物品栏 +0x40 = 光标上的物品,+8 = id;同 diag.c HUD 读数),没拿着 0 | id of the item on the client player's cursor (inventory structure +0x40 = item on the cursor, +8 = id; same as the diag.c HUD reading), 0 when nothing is held
|
||
uint8_t *b = vu_base(); uint64_t pl = b ? ((uint64_t (*)(uint32_t))(b + 0x45f9d0))(*(uint32_t *)(b + 0x2d20e4c)) : 0, inv = pl ? *(uint64_t *)(pl + 0x90) : 0, cur = inv ? *(uint64_t *)(inv + 0x40) : 0;
|
||
return cur && *(uint32_t *)cur == 4 ? *(uint32_t *)(cur + 8) : 0;
|
||
}
|
||
// 交互层查询(游戏主线程):这一点在编年史页上(第六页开着、页在屏上;暗底或底部那块盖板 TouchV_Cover)。下拉展开的选项(另一个面板 DropdownListContents)开着时不算,让它收点击
|
||
// Interaction layer query (game main thread): this point is on the chronicle page (page six open, page on screen; the dark background or the bottom cover TouchV_Cover). It does not count while the expanded dropdown options (another panel, DropdownListContents) are open, so that they receive the tap
|
||
int dm_vault_ui_over(int x, int y) {
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0;
|
||
if (!vt || *(int32_t *)(vt + 0x70) != 0) return 0;
|
||
uint64_t dl = vu_find(root, "DropdownListContents", 1); if (dl && *(uint8_t *)(dl + 0x50)) return 0;
|
||
return vu_hit(vu_find(vt, "TouchV_Back", 0), x, y) || vu_hit(vu_find(vt, "TouchV_Cover", 0), x, y); // 原版翻页箭头压在盖板下面,这一页不用(翻页条是我们的控件,见 dm_vault_ui_pager_hit) | The original page arrows sit under the cover and are not used on this page (the page bar is our widget, see dm_vault_ui_pager_hit)
|
||
}
|
||
// 交互层(游戏主线程,按下那一刻的命中查询,dm_cursor.c):说明框开着时,这一下不是点在出说明的那一格上(再点收起 / 双击取出照旧走 dm_vault_ui_tap)就吃掉:
|
||
// 点在说明框上 = 不动;点别处(别的格子、我们的控件、页签、背包、面板外)= 收起说明框,这一下不触发别的(原先只有点空格才收)。返回 1 = 吃掉
|
||
// Interaction layer (game main thread, the hit query at the moment of press, dm_cursor.c): while the tooltip is open, a tap that is not on the cell showing the tooltip (tap again to close / double-tap to withdraw still go through dm_vault_ui_tap as before) is swallowed:
|
||
// a tap on the tooltip = nothing happens; a tap elsewhere (another cell, our widgets, tabs, inventory, outside the panel) = close the tooltip, and this tap triggers nothing else (previously only a tap on an empty cell closed it). Returns 1 = swallowed
|
||
int dm_vault_ui_tip_gate(int x, int y) {
|
||
if (!g_tip_on) return 0;
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0;
|
||
if (!vt || *(int32_t *)(vt + 0x70) != 0) return 0;
|
||
{ uint64_t dl = vu_find(root, "DropdownListContents", 1); if (dl && *(uint8_t *)(dl + 0x50)) return 0; }
|
||
int cell = -1; if (vu_cell_at(vt, x, y, &cell) >= 0 && cell + 1 == g_tip_on) return 0;
|
||
if (vu_hit(vu_find(vt, "TouchV_TipBg", 0), x, y)) return 1;
|
||
vu_tip(b, vt, NULL); g_tip_on = 0; LOG("编年史仓库:点了说明框外 → 收起说明框,这一下不做别的"); return 1;
|
||
}
|
||
// 名字里含搜索字,英文字母不分大小写(英文版:物品名是 Harlequin Crest 这种首字母大写的写法,玩家打小写也要搜到);中文等多字节字符逐字节比,不受影响
|
||
// The name contains the search text, case-insensitive for English letters (English version: item names are capitalized like Harlequin Crest,
|
||
// and a player typing lowercase must still find them); multi-byte characters such as Chinese are compared byte by byte and are not affected
|
||
static int vu_has(const char *name, const char *q) {
|
||
if (!name || !q) return 0; size_t n = strlen(q); if (!n) return 1;
|
||
for (; *name; name++) { size_t i = 0; while (i < n && name[i] && ((unsigned char)name[i] < 0x80 && (unsigned char)q[i] < 0x80 ? tolower((unsigned char)name[i]) == tolower((unsigned char)q[i]) : name[i] == q[i])) i++; if (i == n) return 1; }
|
||
return 0;
|
||
}
|
||
// 搜索:名字包含搜索字(游戏此刻显示的名字:开了旧译名就是旧译名)的暗金与套装件,跨部位;存着 → 收录过 → 没遇到过,同状态按表里的次序。放在暗金那张 3×6 格里,套装件名字绿色
|
||
// Search: unique and set items whose name contains the search text (the name the game currently displays: with legacy translations on, that is the legacy name), across slots; stored → recorded → never encountered, and within the same state in table order. Placed in the unique 3×6 grid, with set item names in green
|
||
static void vu_search(uint8_t *b, uint64_t vt) {
|
||
static int list[VT_NROW]; int n = 0, nu = 0, ns = 0;
|
||
for (int st = ST_STORED; st >= ST_NONE; st--) for (int i = 0; i < VT_NROW; i++) { const vt_row *r = &vt_rows[i]; if (vu_state(b, r) != st || !vu_has(vu_name(b, r->key), g_query)) continue; list[n++] = i; if (r->kind) nu++; else ns++; }
|
||
int pages = n ? (n + VPER - 1) / VPER : 1; if (g_page_q >= pages) g_page_q = pages - 1; if (g_page_q < 0) g_page_q = 0;
|
||
char buf[160]; snprintf(buf, sizeof buf, dm_str(b, "dmVaultSearch"), g_query, n, nu, ns); vu_text(b, vu_find(vt, "TouchV_Stats", 0), buf);
|
||
uint64_t u = vu_find(vt, "TouchV_Uniq", 0);
|
||
for (int k = 0; k < VPER; k++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_U%d", k); uint64_t c = vu_find(u, nm, 0); if (!c) continue;
|
||
int j = g_page_q * VPER + k; g_cell_row[k] = j < n ? list[j] : -1; if (j >= n) { vu_show(c, 0); continue; } vu_show(c, 1);
|
||
const vt_row *r = &vt_rows[list[j]]; int st = vu_state(b, r); vu_tile(b, c, "Tile", r, st); uint64_t nw = vu_find(c, "Name", 0), dm = vu_find(c, "Sub", 0);
|
||
if (r->kind == 0) vu_color(b, nw, st == ST_NONE ? 60 : 0, st == ST_NONE ? 120 : st == ST_SEEN ? 190 : 252, st == ST_NONE ? 60 : 0); // 套装件:原版套装绿,没存的压暗 | Set item: the original game's set green, dimmed when not stored
|
||
else if (st == ST_STORED) vu_color(b, nw, 199, 179, 119); else if (st == ST_SEEN) vu_color(b, nw, 170, 160, 130); else vu_color(b, nw, 110, 108, 100);
|
||
if (st == ST_STORED) vu_color(b, dm, 232, 210, 150); else if (st == ST_SEEN) vu_color(b, dm, 150, 190, 255); else vu_color(b, dm, 120, 118, 110);
|
||
vu_text(b, nw, vu_name(b, r->key)); vu_text(b, dm, st == ST_STORED ? dm_str(b, "dmVaultStored") : st == ST_SEEN ? dm_str(b, "dmVaultSeen") : dm_str(b, "dmVaultNone")); vu_text(b, vu_find(c, "Dot", 0), st == ST_SEEN ? "●" : ""); }
|
||
g_pg_cur = g_page_q + 1; g_pg_tot = pages;
|
||
}
|
||
// 从格子拖回背包(与仓库页规则一致):交互层把起手在编年史格子上的界面拖动交给这里(dm_cursor.c ui_drag_pump,游戏主线程,视口像素)。
|
||
// 0 = 起手:只有存着的格子接(返回 1);物品图跟手(TouchV_Drag,画在手指上方:同拖放「落点 = 物品图位置」规则,抬起量由前端报(dm_ui_drag_lift)),原格压暗。
|
||
// 1 = 移动;2 = 松手:物品图中心落在背包格上 = 请服务端按这个落点取出(放不下 / 压到别的物品就不取、播错误音,dm_vault.c bag_fits);落在别处 = 不取、播错误音。
|
||
// 不会穿到身上、不会丢到地上:取出只走「放进背包指定格」那一条
|
||
// Dragging from a cell back to the inventory (consistent with the stash page rules): the interaction layer hands UI drags that start on a chronicle cell to this function (dm_cursor.c ui_drag_pump, game main thread, viewport pixels).
|
||
// 0 = start: only stored cells accept it (return 1); the item image follows the finger (TouchV_Drag, drawn above the finger: same as the drag-and-drop rule "drop point = item image position", with the lift amount reported by the front end (dm_ui_drag_lift)), and the original cell is dimmed.
|
||
// 1 = move; 2 = release: item image center landing on an inventory cell = ask the server to withdraw at this drop point (if it does not fit / overlaps another item, no withdraw and the error sound plays, dm_vault.c bag_fits); landing anywhere else = no withdraw, play the error sound.
|
||
// It can never get equipped or dropped on the ground: withdraw only goes through the single "put into a specified inventory cell" path
|
||
static struct { int on, row, bx0, by0; float ax, ay; } g_dg;
|
||
static void vu_drag_place(uint64_t vt, int x, int y) {
|
||
uint64_t im = vu_find(vt, "TouchV_Drag", 0); if (!im || g_dg.ax <= 0 || g_dg.ay <= 0) return;
|
||
int ux = 142 + (int)((x - g_dg.bx0) / g_dg.ax), uy = 136 + (int)((y - g_dg.by0) / g_dg.ay), w = *(int32_t *)(im + 0x78), h = *(int32_t *)(im + 0x7c);
|
||
vu_move(im, ux - (w > 0 ? w / 2 : 49), uy - (h > 0 ? h / 2 : 49));
|
||
}
|
||
int dm_vault_ui_drag(int phase, int x, int y) {
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0; if (!vt) { g_dg.on = 0; return 0; }
|
||
float dm_ui_drag_lift_get(void); int vh = *(int32_t *)(b + 0x211da3c), lift = (int)(vh * dm_ui_drag_lift_get()); // 抬起量由前端报(同各自拖放落点) | The lift amount is reported by the front end (same as each of the other drag-and-drop drop points)
|
||
if (phase == 0) { int cell; int row = vu_cell_at(vt, x, y, &cell); if (row < 0 || !dm_vault_has(vt_rows[row].kind, vt_rows[row].row)) return 0;
|
||
uint64_t bg = vu_find(vt, "TouchV_Back", 0); if (!bg) return 0; int a, c, x0, x1, y0, y1, vw = *(int32_t *)(b + 0x211da38); // 面板单位 ↔ 视口像素:探暗底的四条边(暗底在布局里是 x 142–1542、y 136–1136) | Panel units ↔ viewport pixels: probe the four edges of the dark background (in the layout the dark background is x 142–1542, y 136–1136)
|
||
for (a = 0, c = x; a < c;) { int mid = (a + c) / 2; if (vu_hit(bg, mid, y)) c = mid; else a = mid + 1; } x0 = a;
|
||
for (a = x, c = vw - 1; a < c;) { int mid = (a + c + 1) / 2; if (vu_hit(bg, mid, y)) a = mid; else c = mid - 1; } x1 = a;
|
||
for (a = 0, c = y; a < c;) { int mid = (a + c) / 2; if (vu_hit(bg, x, mid)) c = mid; else a = mid + 1; } y0 = a;
|
||
for (a = y, c = vh - 1; a < c;) { int mid = (a + c + 1) / 2; if (vu_hit(bg, x, mid)) a = mid; else c = mid - 1; } y1 = a;
|
||
g_dg = (typeof(g_dg)){ 1, row, x0, y0, (x1 - x0 + 1) / 1400.0f, (y1 - y0 + 1) / 1000.0f };
|
||
if (g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; }
|
||
uint64_t im = vu_find(vt, "TouchV_Drag", 0); if (im) { vu_image(b, im, vt_rows[row].icon); *(float *)(im + 0x80) = 1.0f; *(float *)(im + 0x94) = 1.0f; }
|
||
if (cell >= 0 && cell < VPER) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_U%d", cell); uint64_t c2 = vu_find(vt, nm, 1), ti = c2 ? vu_find(c2, "TileImg", 0) : 0; if (ti) *(float *)(ti + 0x94) = 0.2f; }
|
||
vu_drag_place(vt, x, y - lift); LOG("编年史仓库:从格子拖 %s", vt_rows[row].key); return 1; }
|
||
if (!g_dg.on) return 0;
|
||
if (phase == 1) { vu_drag_place(vt, x, y - lift); return 1; }
|
||
g_dg.on = 0; vu_move(vu_find(vt, "TouchV_Drag", 0), 99999, 0); atomic_store(&g_dirty, 1); // 原格的压暗随重画复原 | The dimming of the original cell is restored by the redraw
|
||
const vt_row *e = &vt_rows[g_dg.row]; int fx, fy, cols, rows, dm_ui_bag_point(int, int, int *, int *, int *, int *);
|
||
if (dm_ui_bag_point(x, y - lift, &fx, &fy, &cols, &rows)) { void dm_vault_request_withdraw_at(int, int, int, int, int, int); dm_vault_request_withdraw_at(e->kind, e->row, fx, fy, cols, rows);
|
||
LOG("编年史仓库:%s 拖到背包格 (%.2f, %.2f)(背包 %d×%d)→ 取出", e->key, fx / 100.0, fy / 100.0, cols, rows); }
|
||
else { ((void (*)(int, uint64_t, int, int, int))(b + 0x35f120))(3, 0, 0, 0, 0); LOG("编年史仓库:%s 没拖到背包格上 → 不取(原版错误音)", e->key); }
|
||
return 1;
|
||
}
|
||
// 交互层(游戏主线程,按下那一刻的命中查询,dm_cursor.c):这一点落在翻页条的哪个点按区上——-1 上一页 / +1 下一页 / 0 都不是。
|
||
// 点按区是布局里两块透明命中框 TouchV_PgLHit / PgRHit(比箭头图形大,≥ 44 点见方);第六页不在屏上返回 0
|
||
// Interaction layer (game main thread, hit query at the moment of press, dm_cursor.c): which tap area of the page bar this point falls on -- -1 previous page / +1 next page / 0 neither.
|
||
// The tap areas are two transparent hit boxes in the layout, TouchV_PgLHit / PgRHit (larger than the arrow graphics, ≥ 44 points square); returns 0 when the sixth page is not on screen
|
||
int dm_vault_ui_pager_hit(int x, int y) {
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0, vt = bk ? vu_find(bk, "TouchVault", 1) : 0;
|
||
if (!vt || *(int32_t *)(vt + 0x70) != 0) return 0;
|
||
return vu_hit(vu_find(vt, "TouchV_PgLHit", 0), x, y) ? -1 : vu_hit(vu_find(vt, "TouchV_PgRHit", 0), x, y) ? 1 : 0;
|
||
}
|
||
void dm_vault_ui_flip(int dir) { atomic_store(&g_flip, dir < 0 ? -1 : 1); } // 交互层:第六页上点了左右箭头(dm_cursor.c ui_classify) | Interaction layer: a left / right arrow was tapped on page six (dm_cursor.c ui_classify)
|
||
void dm_vault_on_uimsg(const char *cat, const char *act, const char *arg) { // 界面消息回调(diag.c):子页签、勾选框点了发 ClosePanel:TouchV_*;下拉选了一项发 DropdownListWidgetMessage | UI message callback (diag.c): tapping a sub-tab or checkbox sends ClosePanel:TouchV_*; picking a dropdown entry sends DropdownListWidgetMessage
|
||
if (!strcmp(cat, "DropdownListWidgetMessage") || !strcmp(cat, "TouchVaultMessage")) { atomic_store(&g_dirty, 1); return; }
|
||
if (strcmp(cat, "PanelManager") || strcmp(act, "ClosePanel") || strncmp(arg, "TouchV_", 7)) return;
|
||
if (!strcmp(arg + 7, "SubU")) atomic_store(&g_sub_req, 0); else if (!strcmp(arg + 7, "SubS")) atomic_store(&g_sub_req, 1);
|
||
atomic_store(&g_dirty, 1);
|
||
}
|
||
void dm_vault_ui_pump(void) {
|
||
uint8_t *b = vu_base(); uint64_t root = b ? *(uint64_t *)(b + 0x2f05458) : 0, bk = root ? vu_find(root, "BankExpansionLayout", 1) : 0;
|
||
static int was; if (!bk || !*(uint8_t *)(bk + 0x50)) { was = 0; return; }
|
||
uint64_t tabs = vu_find(bk, "BankTabs", 0), vt = vu_find(bk, "TouchVault", 1); if (!tabs || !vt) return;
|
||
if (!vu_is(tabs, VT_TABBAR)) return;
|
||
int on = *(int32_t *)(tabs + 0xdc4) == 5;
|
||
vu_move(vt, on ? 0 : 99999, 0);
|
||
if (!on) { if (g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; } was = 0; return; }
|
||
|
||
if (!was) { was = 1; atomic_store(&g_dirty, 1); LOG("编年史仓库:进第六页(%s,部位 %d)", g_sub ? "套装" : "暗金", g_part); }
|
||
// 手柄模式:这一页上没有原版能给焦点的东西,摇杆推着原版光标圈在页上自由走——A = 在光标处点一下,走触屏点按同一条路(dm_ui_touch:格子单击出说明 / 连按两次取出、
|
||
// 部位页签、子页签、勾选、下拉都照旧);L / R = 上 / 下一页(触屏的翻页箭头手柄版布局里没有)。光标不在编年史页上时 A 照旧归原版(页签条、背包那一侧)
|
||
// Controller mode: nothing on this page can receive the original focus, so the stick moves the original cursor ring freely over the page. A = tap at the
|
||
// cursor, through the same path as a touch tap (dm_ui_touch: single tap on a cell shows the tooltip / two taps in a row take the item out,
|
||
// and slot tabs, sub-tabs, checkboxes and dropdowns all work as before); L / R = previous / next page (the touch page arrows do not exist in the controller
|
||
// layout). When the cursor is not on the Chronicle page, A goes to the original as before (tab bar, inventory side)
|
||
{ int dm_padmode_current(void); uint64_t dm_padmode_page_keys(uint64_t); void dm_ui_touch(int, float, float); unsigned long long dm_guest_frame(void);
|
||
static unsigned long long up_at; static float ux, uy; unsigned long long fr = dm_guest_frame();
|
||
if (up_at && fr >= up_at) { up_at = 0; dm_ui_touch(2, ux, uy); }
|
||
if (dm_padmode_current()) { int cx = *(int32_t *)(b + 0x2d128f8), cy = *(int32_t *)(b + 0x2d128fc), w = *(int32_t *)(b + 0x211da38), h = *(int32_t *)(b + 0x211da3c), over = w > 0 && h > 0 && dm_vault_ui_over(cx, cy);
|
||
// Y 在这一页一律接管:原版把第六页当魔盒页,按住 Y(移到另一侧)会把背包物品送进看不见的魔盒格(触屏双击同一个坑,dm_cursor.c ui_use_pump)。
|
||
// 照原版这一键的两段式:短按(不到 Y_HOLD 帧就松开)还给原版——替玩家按一下,仍是原版的「丢弃」;按住满 Y_HOLD 帧 = 光标下的背包物品存进编年史仓库(同触屏双击)。
|
||
// 原版提示条对背包物品显示「丢弃(按住移动到私人储藏箱)」,后半句由 dm_padmode_vault_hint 换成「存入」,与实际一致
|
||
// Y is always taken over on this page: the original treats the sixth page as the Horadric Cube page, and holding Y (move to the other side) would send
|
||
// an inventory item into an invisible Cube cell (touch double-tap has the same pitfall, dm_cursor.c ui_use_pump).
|
||
// Following the original's two-stage behavior of this button: a short press (released before Y_HOLD frames) is given back to the original, pressed once
|
||
// on the player's behalf and still the original "Drop"; holding for Y_HOLD frames = deposit the inventory item under the cursor into the Chronicle vault
|
||
// (same as touch double-tap).
|
||
// For an inventory item the original button legend shows "Drop (hold to move to personal stash)"; dm_padmode_vault_hint replaces the second half with
|
||
// "Deposit" so that it matches what actually happens
|
||
enum { Y_HOLD = 20 }; uint64_t dm_padmode_page_held(void); void dm_padmode_page_pulse(uint64_t), dm_padmode_vault_hint(int); dm_padmode_vault_hint(1);
|
||
uint64_t ev = dm_padmode_page_keys(0x40 | 0x80 | 0x8 | (over ? 0x1 : 0)); // L 0x40、R 0x80、Y 0x8、A 0x1(dm_input.h)
|
||
{ static unsigned long long y0; static int fired; int held = (dm_padmode_page_held() & 0x8) != 0;
|
||
if (ev & 0x8) { y0 = fr; fired = 0; }
|
||
if (held && y0 && !fired && fr - y0 >= Y_HOLD) { fired = 1; dm_cursor_item_info ci;
|
||
if (dm_cursor_item(&ci) && ci.container == DM_ITEM_AT_INVENTORY) { void dm_vault_request_deposit(uint32_t); dm_vault_request_deposit(ci.id); LOG("编年史仓库:手柄按住 Y,背包的 %s(id %u)→ 存进编年史仓库", ci.code, ci.id); }
|
||
else LOG("编年史仓库:手柄按住 Y,光标下不是背包物品,不动"); }
|
||
if (!held && y0) { if (!fired) { dm_padmode_page_pulse(0x8); LOG("编年史仓库:手柄短按 Y → 还给原版(丢弃)"); } y0 = 0; } }
|
||
{ void dm_padmode_legend(int, const char *); // 按键提示走原版底部提示条(dm_padmode.c):A = 0、L = 19、R = 20;Y 那一条原版自己每帧按光标下的物品重建,不由我们登记。文字等中英表(的 dm/i18n)进主干后挪进表 | Button hints go through the original bottom button legend (dm_padmode.c): A = 0, L = 19, R = 20; the Y entry is rebuilt by the original every frame from the item under the cursor and is not registered by us. Move the text into the Chinese-English table (dm/i18n) once that table lands on the main branch
|
||
if (over) dm_padmode_legend(0, dm_str(b, "dmPadLegView")); dm_padmode_legend(19, dm_str(b, "dmPadLegPrev")); dm_padmode_legend(20, dm_str(b, "dmPadLegNext")); }
|
||
if (ev & 0x40) dm_vault_ui_flip(-1); else if (ev & 0x80) dm_vault_ui_flip(1);
|
||
if ((ev & 0x1) && over && !up_at) { ux = (float)cx / (float)w; uy = (float)cy / (float)h; dm_ui_touch(0, ux, uy); up_at = fr + 2; LOG("编年史仓库:手柄 A → 在光标处 (%d,%d) 点一下", cx, cy); } } }
|
||
int sr = atomic_exchange(&g_sub_req, -1); if (sr >= 0 && sr != g_sub) { g_sub = sr; atomic_store(&g_dirty, 1); }
|
||
int fl = atomic_exchange(&g_flip, 0); if (fl && g_query[0]) { g_page_q += fl; atomic_store(&g_dirty, 1); fl = 0; }
|
||
if (fl) { g_page[g_sub ? VT_NPART : g_part] += fl; atomic_store(&g_dirty, 1); LOG("编年史仓库:%s翻%s一页", g_sub ? "套装" : vt_part_name[g_part], fl > 0 ? "下" : "上"); }
|
||
{ static int pinit; const char *e; if (!pinit && (e = getenv("DM_TEST_VAULT_PART"))) { int p = atoi(e); if (p >= 0 && p < VT_NPART) { g_part = p; atomic_store(&g_dirty, 1); LOG("编年史仓库:测试开关先选部位 %d", p); } } pinit = 1; } // 测试开关 DM_TEST_VAULT_PART=<部位>(造现场) | Test switch DM_TEST_VAULT_PART=<slot> (test setup)
|
||
{ int tm = 0; for (int i = 0; i < 3; i++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_T%d", i); uint64_t c = vu_find(vt, nm, 1); if (c && vu_is(c, VT_TOGGLE) && *(uint8_t *)(c + 0xa88)) tm |= 1 << i; }
|
||
// 面板新建(首次打开、重进局后游戏重建储藏箱)时勾选框是布局里的缺省「不勾」:按当前筛选(首次 = 全勾)写回去,画面和筛选对上
|
||
// (vt1:原先只在本进程第一次写,重进局后三个框全不勾、列表却照全看显示)
|
||
// When the panel is newly built (first open, or the game rebuilds the stash after re-entering a run) the checkboxes are at the layout default "unchecked": write them back from the current filter (first time = all checked) so the picture matches the filter
|
||
// (vt1: previously this was written only the first time in the process; after re-entering a run all three boxes were unchecked while the list still showed everything)
|
||
static uint64_t lastvt; if (vt != lastvt) { lastvt = vt; for (int i = 0; i < 3; i++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_T%d", i); vu_toggle(vu_find(vt, nm, 1), g_tiers >> i & 1); } tm = g_tiers; }
|
||
if (!tm) tm = 7; // 三个都不勾 = 全看(同原版编年史) | None of the three checked = show all (same as the original game's chronicle)
|
||
if (tm != g_tiers) { g_tiers = tm; atomic_store(&g_dirty, 1); } }
|
||
{ int dm_ui_vault_drop(void); static uint32_t held; static int wait; // 拖进编年史页:手上那件放回原格(手空了)再隔几帧(等服务端也放好)请求存入 | Dragged into the chronicle page: put the item in hand back into its original cell (hand now empty), then a few frames later (waiting for the server to finish placing it too) request the store
|
||
uint32_t h = dm_vault_ui_held(); if (held && !h && (uint32_t)dm_ui_vault_drop() == held) { wait = 8; g_drop_id = (int)held; } held = h;
|
||
if (wait && !--wait) { void dm_vault_request_deposit(uint32_t); dm_vault_request_deposit((uint32_t)g_drop_id); LOG("编年史仓库:拖进来的物品 id %u → 存入", (unsigned)g_drop_id); } }
|
||
{ int dm_vault_take_full_sound(void); if (dm_vault_take_full_sound()) ((void (*)(int, uint64_t, int, int, int))(b + 0x35f120))(3, 0, 0, 0, 0); } // 取不出(背包满)/ 存不进:原版错误音(同物品栏放不下,dm_actions.c) | Cannot withdraw (inventory full) / cannot store: the original game's error sound (same as when the original inventory is full, dm_actions.c)
|
||
// 搜索框里的字:读输入框控件自己的正式文字串 +0x558 {指针, 长度}(原版「把键盘结果写进输入框」0xac2058 用通用串赋值 0x136e5c 写的就是它,控件构造时即初始化)。
|
||
// 原先读的 +0x12a8 / +0x12b0 是键盘结果的待处理缓冲:系统键盘线程写、控件更新函数 0xac2944 在标志 +0x12d0 置位时持锁(+0x1288)取走交给 0xac2058,
|
||
// 其余时候是没初始化 / 已释放的内存——值碰巧像指针且长度落在 1–63 就在下面的拷贝里崩(手柄新局切到第六页 10 遍崩 3 遍,memmove 源地址 0x100000007;
|
||
// 本机实测控件新建时那两格读到过 0 / 0x800000000000000f、0xffffffffffffffff / 255)。另核控件确是输入框那个类(虚表 main+0x20b8718,触屏 / 手柄两种布局实测同一个)
|
||
// Text in the search box: read the input box widget's own official text string +0x558 {pointer, length} (this is what the original game's "write the keyboard result into the input box" 0xac2058 writes, using the generic string assignment 0x136e5c, and it is initialized as soon as the widget is constructed).
|
||
// The +0x12a8 / +0x12b0 read previously are the pending buffer of the keyboard result: written by the system keyboard thread, and taken under the lock (+0x1288) by the widget update function 0xac2944 when flag +0x12d0 is set, then handed to 0xac2058,
|
||
// at all other times it is uninitialized / freed memory -- when the value happens to look like a pointer and the length falls in 1–63, the copy below crashes (switching to the sixth page in a new controller run crashed 3 times out of 10, memmove source address 0x100000007;
|
||
// measured locally, those two fields read 0 / 0x800000000000000f and 0xffffffffffffffff / 255 when the widget was newly created). Also check that the widget really is of the input box class (vtable main+0x20b8718, measured to be the same in both the touch / controller layouts)
|
||
{ uint64_t in = vu_find(vt, "TouchV_Search", 1); if (in && *(uint64_t *)in - (uint64_t)(uintptr_t)b != 0x20b8718) in = 0;
|
||
const char *q = in ? *(const char **)(in + 0x558) : NULL; uint64_t qn = in ? *(uint64_t *)(in + 0x560) : 0; char nq[sizeof g_query] = "";
|
||
if (q && qn && qn < sizeof nq) { memcpy(nq, q, qn); nq[qn] = 0; } if (strcmp(nq, g_query)) { strlcpy(g_query, nq, sizeof g_query); g_page_q = 0; atomic_store(&g_dirty, 1); LOG("编年史仓库:搜索「%s」", g_query); } }
|
||
static int gen = -1; int g = dm_vault_gen(); if (g != gen) { gen = g; atomic_store(&g_dirty, 1); }
|
||
if (g_tip_on) { vu_tip_exact(b, vt); vu_tip_place(vu_find(vt, "TouchV_Tip", 0), vu_find(vt, "TouchV_TipBg", 0)); }
|
||
static int fr; int dirty = atomic_exchange(&g_dirty, 0); if (!dirty && ++fr % 30) return; // 编年史收录在服务端拍里变:开着时每半秒重写一次(字没变不写) | Chronicle records change in the server tick: while open, rewrite once every half second (no write if the text did not change)
|
||
vu_toggle(vu_find(vt, "TouchV_SubU", 1), g_sub == 0); vu_toggle(vu_find(vt, "TouchV_SubS", 1), g_sub == 1);
|
||
vu_show(vu_find(vt, "TouchV_Parts", 0), g_sub == 0); vu_show(vu_find(vt, "TouchV_Tiers", 0), g_sub == 0 && !g_query[0]);
|
||
{ // 档次勾选的排法跟语言走(英文版):中文照布局(wide_stash.py:块右对齐宽 590、三格间距 200);英文三个标签宽窄不一、统计行也长, | the layout of the quality tier checkboxes follows the language (English version): Chinese follows the layout (wide_stash.py: block right-aligned and 590 wide, three cells spaced 200 apart); in English the three labels differ in width and the stats row is longer too,
|
||
// 块改宽 650、各格按标签宽排(Norm 140 / Exc 100 / Elite 136 单位,Mac 上的 iOS 包截图量,标签后各留 15),让出的地方给统计行(左对齐,宽到 780)。勾选框在 x、标签在 x + 75、y − 5(同 _vt_check)
|
||
// The block is widened to 650 and each cell is laid out by its label width (Norm 140 / Exc 100 / Elite 136 units, measured from screenshots of the iOS
|
||
// package on Mac, with 15 left after each label), and the freed space goes to the stats row (left-aligned, up to 780 wide). Checkbox at x, label at x +
|
||
// 75, y - 5 (same as _vt_check)
|
||
static const int zx[3] = { 0, 200, 400 }, ex[3] = { 0, 240, 430 }; int zh = dm_lang_zh(); const int *xs = zh ? zx : ex;
|
||
vu_move(vu_find(vt, "TouchV_Tiers", 0), VX0 + VW0 - (zh ? 590 : 650), VT_TIER_Y);
|
||
for (int i = 0; i < 3; i++) { char nm[24]; snprintf(nm, sizeof nm, "TouchV_T%d", i); vu_move(vu_find(vt, nm, 1), xs[i], 0); snprintf(nm, sizeof nm, "TouchV_T%d_Text", i); vu_move(vu_find(vt, nm, 1), xs[i] + 75, -5); } }
|
||
for (int p = 0; p < VT_NPART; p++) { char nm[16]; snprintf(nm, sizeof nm, "TouchV_PT%d", p); uint64_t t = vu_find(vt, nm, 1); if (!t) continue; // 部位页签:选中那个换原版页签的选中帧(带菱形)、白字 | Slot tabs: the selected one switches to the original game's selected tab frame (with the diamond) and white text
|
||
vu_frame(vu_find(t, "Img", 0), p == g_part); vu_show(vu_find(t, "TextOn", 0), p == g_part); vu_show(vu_find(t, "Text", 0), p != g_part); } // 搜索跨档次,不看勾选(统计行也要这块地方) | Search spans tiers and ignores the checkboxes (the stats line also needs this space)
|
||
int grid = g_sub == 0 || g_query[0]; vu_move(vu_find(vt, "TouchV_Uniq", 0), grid ? 156 : 99999, VU_UNIQ_Y); vu_move(vu_find(vt, "TouchV_Sets", 0), grid ? 99999 : 156, 296);
|
||
if (dirty && g_tip_on) { vu_tip(b, vt, NULL); g_tip_on = 0; } // 内容变了(翻页、切子页、搜索、存取):说明框收起;每半秒的例行重画不收 | Contents changed (page flip, sub-page switch, search, store / withdraw): the tooltip is closed; the routine half-second redraw does not close it
|
||
if (g_query[0]) vu_search(b, vt); else if (g_sub == 0) vu_uniques(b, vt); else vu_sets(b, vt);
|
||
{ struct { const char *s; uint64_t n; } key = { "SharedStashPage", 15 }; uint64_t fmt = ((uint64_t (*)(void *))(b + 0x7f5630))(&key); char pt[256]; memset(pt, 0, sizeof pt); // 原版共享页页码的写法「第 n/m 页」(同 dm_cursor.c pages_text): | The original game's way of writing the shared page number, 「第 n/m 页」(Page n/m) (same as dm_cursor.c pages_text):
|
||
((void (*)(void *, uint64_t, int64_t, int64_t))(b + 0x399130))(pt, fmt, g_pg_cur, g_pg_tot); vu_text(b, vu_find(vt, "TouchV_Page", 0), pt);
|
||
vu_frame(vu_find(vt, "TouchV_PgL", 0), g_pg_cur > 1 ? 0 : 3); vu_frame(vu_find(vt, "TouchV_PgR", 0), g_pg_cur < g_pg_tot ? 0 : 3); } // 到头的那一侧箭头换成原版「不可用」那一帧 // 部位名已在下拉里,原先「鞋子与腰带 1 / 2」超出页码框被截成「鞋子与腰…」 | The arrow on the side that has reached the end switches to the original "disabled" frame // the body location name is already in the dropdown; previously 「鞋子与腰带 1 / 2」(Boots & Belts 1 / 2) overflowed the page number box and was truncated to 「鞋子与腰…」(Boots and Be...)
|
||
}
|