From 2e7177c08048ebf9335fea102cbd1357eaf92832 Mon Sep 17 00:00:00 2001 From: jhaizhou <258432107+jhaizhou-ops@users.noreply.github.com> Date: Wed, 14 Oct 2026 10:34:48 +0800 Subject: [PATCH] Greater Rift: two Guardians from level 75, overtime status spelled out (#33); item descriptions stay open on touch (#32); Mac: click monsters to attack, items take the mouse, Share Log The overtime status (#33) was reported with a clear direction by Joe Hu, who also sent a patch along the same lines (#34). Co-authored-by: Joe Hu <12777592+hubeiqiao@users.noreply.github.com> --- README.md | 2 +- README.zh-CN.md | 2 +- dm/host/app_mac.m | 39 +++++++++++ dm/host/dm_cursor.c | 12 +++- dm/host/dm_i18n_tab.h | 6 ++ dm/host/dm_padmode.c | 4 ++ dm/host/dm_rift.c | 112 +++++++++++++++++++++++++----- dm/host/dm_rift.h | 4 +- dm/host/dm_rift_ui.c | 16 +++-- dm/host/dm_update.c | 18 +++++ dm/host/dm_world.c | 31 ++++++++- dm/host/front_mac.m | 66 +++++++++++++++++- dm/host/tests/t_rift_next.c | 11 +++ dm/host/tests/t_rift_oldrun.c | 6 ++ dm/host/tests/t_touch_mac.c | 2 +- dm/host/tests/t_touch_tick_stub.c | 2 +- dm/host/touch_mac.c | 14 +++- dm/i18n/literal_whitelist.tsv | 2 + dm/i18n/ui_text.tsv | 6 ++ dm/ios/Sources/dm_rift_hud.m | 2 +- dm/ios/Sources/front_ios.m | 8 ++- dm/ios/tools/touch_layout.py | 25 +++++-- dm/tools/mac_app.sh | 5 +- docs/MAC.md | 13 ++-- docs/MAC.zh-CN.md | 13 ++-- 25 files changed, 364 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index d4445ea..0081a6b 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ dm/tools/mac_app.sh # macOS 26 or later: produces ~/dm-work/out DM_MAC_M3=1 dm/tools/mac_app.sh # macOS 15 – 25: produces D2R Mobile M3.app ``` -The interface is the original's gamepad interface. Keyboard: Space confirms, Esc goes back, Return, the `=` key opens the menu / a new character, W A S D moves, and every other gamepad button has a key. Mouse: clicking a monster, NPC or object walks over and interacts, and the skill slots, potion cells and key hints at the bottom, buttons and tabs in panels, the class figures when creating a character and the minimap can all be clicked; clicking empty ground walks there and holding keeps walking; attacking by clicking a monster and dragging items are not there yet. With a keyboard, the prompts on screen show keyboard keys. Saves stay on this Mac (an App you build yourself has no iCloud sync) and can be imported by hand from an iPhone / iPad. The key table, how to create a character, what the mouse can do, the import steps and the known shortcomings are in [docs/MAC.md](docs/MAC.md). Keyboard and a physical gamepad have not been operated by a person yet — if you try it, please tell us how it went. +The interface is the original's gamepad interface. Keyboard: Space confirms, Esc goes back, Return, the `=` key opens the menu / a new character, W A S D moves, and every other gamepad button has a key. Mouse: clicking a monster, NPC or object walks over and interacts, and the skill slots, potion cells and key hints at the bottom, buttons and tabs in panels, the class figures when creating a character and the minimap can all be clicked; clicking empty ground walks there and holding keeps walking, clicking a monster attacks it, and items take double clicks and drags. With a keyboard, the prompts on screen show keyboard keys. Saves stay on this Mac (an App you build yourself has no iCloud sync) and can be imported by hand from an iPhone / iPad. The key table, how to create a character, what the mouse can do, the import steps and the known shortcomings are in [docs/MAC.md](docs/MAC.md). Keyboard and a physical gamepad have not been operated by a person yet — if you try it, please tell us how it went. ### Without a Mac: the shell plus the packaging tool diff --git a/README.zh-CN.md b/README.zh-CN.md index b92e8fa..4f2fdef 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -250,7 +250,7 @@ dm/tools/mac_app.sh # macOS 26 及以上:产出 ~/dm-work/out DM_MAC_M3=1 dm/tools/mac_app.sh # macOS 15 – 25:产出 D2R Mobile M3.app ``` -界面用原版的手柄版界面。键盘:空格确认、Esc 返回、回车、`=` 键开菜单 / 新角色,W A S D 移动,其余手柄键各有对应。鼠标:点怪、NPC、物件会走过去交互,底部的技能格、药水格、按键提示、面板里的按钮和页签、建角时的职业、小地图都能点;点空地会走过去、按住一直走;点怪攻击和物品的拖放还没有。用键盘时屏上的按键提示直接显示键盘键名。存档在这台 Mac 上(自己构建的 App 没有 iCloud 同步),可以从 iPhone / iPad 手工导入。键位表、建角怎么按、鼠标能做什么、导入步骤和已知不足,见 [docs/MAC.zh-CN.md](docs/MAC.zh-CN.md)。键盘、实体手柄这几项还未经真人操作,你试过的话,请告诉我们结果。 +界面用原版的手柄版界面。键盘:空格确认、Esc 返回、回车、`=` 键开菜单 / 新角色,W A S D 移动,其余手柄键各有对应。鼠标:点怪、NPC、物件会走过去交互,底部的技能格、药水格、按键提示、面板里的按钮和页签、建角时的职业、小地图都能点;点空地会走过去、按住一直走,点怪是攻击,物品的双击和拖放也认鼠标。用键盘时屏上的按键提示直接显示键盘键名。存档在这台 Mac 上(自己构建的 App 没有 iCloud 同步),可以从 iPhone / iPad 手工导入。键位表、建角怎么按、鼠标能做什么、导入步骤和已知不足,见 [docs/MAC.zh-CN.md](docs/MAC.zh-CN.md)。键盘、实体手柄这几项还未经真人操作,你试过的话,请告诉我们结果。 ### 没有 Mac:壳 + 做包工具 diff --git a/dm/host/app_mac.m b/dm/host/app_mac.m index 07ea2f0..19ca632 100644 --- a/dm/host/app_mac.m +++ b/dm/host/app_mac.m @@ -62,6 +62,7 @@ static NSString *res_item(NSString *name) { for (NSString *ln in [txt componentsSeparatedByString:@"\n"]) { NSString *pre = [name stringByAppendingString:@"="]; if ([ln hasPrefix:pre]) { d = [ln substringFromIndex:pre.length]; return [fm fileExistsAtPath:d] ? d : nil; } } return nil; } +static void upd_start(void); // 更新检查(在文件后面) | update check (later in this file) // main() 最前面调。是 App 形态就把环境与参数备好并返回 1;不是返回 0、什么都不动 // Called at the very start of main(). In App form it prepares the environment and arguments and returns 1; otherwise it returns 0 and touches nothing int dm_app_bootstrap(int *argc, char ***argv) { @@ -119,11 +120,49 @@ int dm_app_bootstrap(int *argc, char ***argv) { if (ov) setenv("DM_ROMFS_OVERLAY", ov.fileSystemRepresentation, 1); static char *av[5]; av[0] = (*argv)[0]; av[1] = strdup(prod.fileSystemRepresentation); av[2] = "main"; av[3] = "sdk"; av[4] = NULL; *argv = av; *argc = 4; + upd_start(); LOG("App:存档 %s;资源 %s;程序文件 %s;界面覆盖层 %s;日志 %s", save.UTF8String, rom.UTF8String, prod.UTF8String, getenv("DM_ROMFS_OVERLAY") ?: "(没有,原版界面)", lf.UTF8String); return 1; } } +// ---- 更新检查 ---- +// 包的 Info.plist 里带了 SWUpdateURL(打包脚本 DM_MAC_UPDATE_URL;内测包指向下载站的 latest_mac.json)才检查;公开版 / 自己构建的包不带 = 不联网、不提示。 +// 版本文件:{"build": 整数构建号, "note": "一句说明", "note_en": "English", "url": "下载页"}。主菜单出现时读一次(两次之间至少隔 60 秒),2 秒超时; +// build 比包内构建号大 → 交给两端共用的提示核心(host/dm_update.c:手柄版主菜单右上角「构建 N」下面一行「有新版本 N · 说明」,按 Y / 键盘 I 打开下载页); +// 读不到 / 超时 / 格式不对一律静默(只记日志),不影响启动。不自动下载、不替换。下载页地址只认与版本文件同一个主机的 http(s) 地址 +// ---- Update check ---- +// Checked only when the package's Info.plist carries SWUpdateURL (the packaging script's DM_MAC_UPDATE_URL); public builds / packages you build yourself do not carry it = no network access, no hint. +// Version file: {"build": integer build number, "note": "one sentence", "note_en": "English", "url": "download page"}. Read once when the main menu appears (at least 60 seconds between two reads), with a 2-second timeout; +// build larger than the package's build number -> handed to the hint core shared by both platforms (host/dm_update.c: one line "New version N - note" under "Build N" at the top right of the gamepad-layout main menu; Y / keyboard I opens the download page); +// unreadable / timed out / malformed are all silent (logged only) and do not affect startup. Nothing is downloaded or replaced automatically. The download page address is accepted only if it is an http(s) address on the same host as the version file +void dm_update_init(int own_build, void (*on_select)(void), void (*on_click)(void)); void dm_update_offer(int new_build, const char *note, int urgent); void dm_update_safe_left(int units); +static NSString *g_upd_url, *g_upd_page; static int g_upd_own; static double g_upd_last; +static void upd_check(void) { + double now = CFAbsoluteTimeGetCurrent(); if (g_upd_last && now - g_upd_last < 60) return; g_upd_last = now; + NSURL *u = [NSURL URLWithString:g_upd_url]; if (!u) return; + NSURLSessionConfiguration *cf = NSURLSessionConfiguration.ephemeralSessionConfiguration; cf.timeoutIntervalForRequest = 2; cf.timeoutIntervalForResource = 2; cf.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData; + [[[NSURLSession sessionWithConfiguration:cf] dataTaskWithURL:u completionHandler:^(NSData *d, NSURLResponse *r, NSError *e) { + NSInteger code = [r isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)r).statusCode : 0; + NSDictionary *j = (!e && code == 200 && d) ? [NSJSONSerialization JSONObjectWithData:d options:0 error:nil] : nil; + NSNumber *b = [j isKindOfClass:NSDictionary.class] ? j[@"build"] : nil; + if (![b isKindOfClass:NSNumber.class] || b.intValue < 1) { LOG("更新:读版本文件没成(%s,HTTP %ld),本次不提示", e ? e.localizedDescription.UTF8String : "格式不对", (long)code); return; } + NSString *zh = [j[@"note"] isKindOfClass:NSString.class] ? j[@"note"] : @"", *en = [j[@"note_en"] isKindOfClass:NSString.class] ? j[@"note_en"] : zh, *pg = [j[@"url"] isKindOfClass:NSString.class] ? j[@"url"] : nil; + NSURL *pu = pg ? [NSURL URLWithString:pg] : nil; BOOL okpg = pu && ([pu.scheme isEqualToString:@"https"] || [pu.scheme isEqualToString:@"http"]) && [pu.host isEqualToString:u.host]; + g_upd_page = okpg ? [pg copy] : nil; + if (b.intValue > g_upd_own) { const char *l = getenv("DM_LANG"); NSString *note = (l && !strncmp(l, "zh", 2)) ? zh : en; LOG("更新:最新构建 %d 比自己(%d)新 → 主菜单提示(下载页 %s)", b.intValue, g_upd_own, okpg ? "有" : "没给或不同主机,不可点"); dm_update_offer(b.intValue, note.UTF8String, 0); } + else { LOG("更新:最新构建 %d,不比自己(%d)新,不提示", b.intValue, g_upd_own); dm_update_offer(0, "", 0); } + }] resume]; +} +static void upd_click(void) { NSString *pg = g_upd_page; if (!pg) return; dispatch_async(dispatch_get_main_queue(), ^{ LOG("更新:打开下载页"); if (!getenv("DM_TEST_UPDATE_NOOPEN")) [NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:pg]]; }); } +static void upd_start(void) { + NSDictionary *inf = NSBundle.mainBundle.infoDictionary; const char *te = getenv("DM_TEST_UPDATE_URL"); // 测试:换一个版本文件地址(本机起的小服务 / 不存在的地址) | test: use a different version file address (a small local server / a non-existent address) + g_upd_url = te ? @(te) : [inf[@"SWUpdateURL"] description]; g_upd_own = [[inf[@"CFBundleVersion"] description] intValue]; + if (!g_upd_url.length || g_upd_own < 1) { LOG("更新:包里没配版本文件地址,不检查"); return; } + dm_update_init(g_upd_own, upd_check, upd_click); dm_update_safe_left(0); + dispatch_async(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), ^{ upd_check(); }); // 启动时查一次:手柄版主菜单不发「选角页出现」那条消息(核心靠它叫外壳去查),不能只等回调;回调若来了也照查(两次之间隔 60 秒) | check once at launch: the gamepad-layout main menu does not send the "character selection appeared" message (which the core relies on to ask the shell to check), so waiting for the callback alone is not enough; if the callback does come it checks as well (at least 60 seconds apart) +} + // 手柄代码(ios/Sources/dm_gamepad.m,两边共用)问「现在是不是面板 / 读取画面开着」:只用来决定空着的 ZR 格要不要当免费回城。 // 宿主没有 iOS 壳那套面板栈;一律答「是」= ZR 整颗交给原版(面板里它是翻页签键),手柄上的免费回城这一版没有(记在已知不足里) // The gamepad code (ios/Sources/dm_gamepad.m, shared by both sides) asks "is a panel / loading screen open right now": used only to decide whether the empty ZR slot should act as the free town portal. diff --git a/dm/host/dm_cursor.c b/dm/host/dm_cursor.c index 4f052f8..87ebd31 100644 --- a/dm/host/dm_cursor.c +++ b/dm/host/dm_cursor.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -2438,6 +2439,15 @@ static void ui_panel_state_pump(uint64_t root) { // 游戏主线程,每帧 | // ui_safe_pump / ui_lift_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center (screen geometry, independent of input method), ui_boss_pct_pump, ui_npcdlg_pump, // ui_widestash_pump, mv_audit_pump, ui_pages_pump (including controller L / R paging), ui_watch_pump, ui_panel_heal, ui_panel_state_pump, rs_pump (Quick Restart, called from the front-end pump) static int ui_touch_mode(void) { int dm_padmode_current(void), dm_padmode_busy(void); return !dm_padmode_current() && !dm_padmode_busy(); } +// Mac App:界面是手柄版(上面答「不是触屏模式」),但真鼠标走的是触屏那套物品手势(touch_mac.c 把鼠标事件喂给触屏状态机)。 +// 只把物品手势的四个执行泵(长按 / 双击使用 / 买 / 拖放)在真鼠标模式下补跑一遍;绑定框、技能页签对调、佣兵页这些改触屏布局的泵不跑。没有请求时这四个什么都不做,手柄玩家不受影响 +// Mac App: the interface is the gamepad layout (the answer above is "not touch mode"), but the real mouse uses the touch layout's item gestures (touch_mac.c feeds mouse events to the touch state machine). +// Only the four execution pumps of the item gestures (long press / double-click use / buy / drag and drop) are additionally run in real-mouse mode; the pumps that change the touch layout - binding box, skill tab swap, mercenary page - are not run. With no request these four do nothing, so gamepad players are unaffected +#if TARGET_OS_OSX +#define UI_MOUSE_ITEM_PUMPS(pm, proot, pw, phh) do { int dm_touch_host_is_live(void), dm_padmode_busy(void); if (!tm && dm_touch_host_is_live() && !dm_padmode_busy()) { ui_long_pump(); ui_use_pump(); ui_buy_pump(pw, phh); ui_drag_pump(pm, proot, pw, phh); } } while (0) +#else +#define UI_MOUSE_ITEM_PUMPS(pm, proot, pw, phh) do { } while (0) +#endif void dm_ui_mouse_pump(void) { // 游戏取手柄处调(hle_hid fill,主线程);每个出图帧做一次 | called where the game fetches the controller (hle_hid fill, main thread); done once per presented frame static uint64_t last_frame = UINT64_MAX; uint64_t fr = dm_guest_frame(); if (fr == last_frame) return; @@ -2479,7 +2489,7 @@ void dm_ui_mouse_pump(void) { // 游戏取手柄处调(hle_hid fill,主线 else fix = 0; } if (th) { ui_auto_key(th); tnext = fr + 8; } } } } { module_t *pm = main_module(); uint64_t proot = 0; if (pm) { memcpy(&proot, pm->base + 0x2f05458, 8); int32_t pw = *(int32_t *)(pm->base + 0x211da38), phh = *(int32_t *)(pm->base + 0x211da3c); - static uint64_t pf = UINT64_MAX; if (proot && pw > 0 && phh > 0 && pf != fr) { pf = fr; { static int dd; const char *dn; if (!dd && (dn = getenv("DM_UI_DUMP")) && atomic_load(&g_taps_base) && fr >= atomic_load(&g_taps_base) + (getenv("DM_UI_DUMP_AT") ? atoi(getenv("DM_UI_DUMP_AT")) : 45)) { dd = 1; ui_dump(proot, 0, dn, 0, pm); } } int tm = ui_touch_mode(); if (tm) ui_wtap_pump(pm, proot, pw, phh); if (tm) ui_long_pump(); ui_target_pump(pm, fr); if (tm) ui_use_pump(); if (tm) ui_buy_pump(pw, phh); ui_item_pump(proot, pw, phh); ui_ptr_pump(pm, proot, pw, phh); if (tm) ui_drag_pump(pm, proot, pw, phh); { int lu = atomic_load(&g_load_up); dm_uiscreen_set_ingame(ui_panel(proot, "HUDPanel") && !(lu < 0 ? ui_find(proot, "LoadScreenPanel", 0) != 0 : lu)); } ui_safe_pump(pm, proot, fr); ui_lift_pump(proot, fr); ui_trove_tabs_pump(pm, proot, fr); ui_minimap_pump(pm, proot, pw, phh, fr); ui_map_pump(pm); ui_map_geom_pump(pm, proot); ui_boss_pct_pump(pm, proot); ui_npcdlg_pump(proot); ui_map_center(pm, proot, *(volatile int32_t *)(pm->base + 0x2d5c748)); if (tm) ui_bind_pump(proot, fr); if (tm) swaptab_pump(proot); if (tm) ui_mercpg_pump(pm, proot, fr); ui_widestash_pump(proot); mv_audit_pump(proot, fr); ui_pages_pump(pm, proot); } } } + static uint64_t pf = UINT64_MAX; if (proot && pw > 0 && phh > 0 && pf != fr) { pf = fr; { static int dd; const char *dn; if (!dd && (dn = getenv("DM_UI_DUMP")) && atomic_load(&g_taps_base) && fr >= atomic_load(&g_taps_base) + (getenv("DM_UI_DUMP_AT") ? atoi(getenv("DM_UI_DUMP_AT")) : 45)) { dd = 1; ui_dump(proot, 0, dn, 0, pm); } } int tm = ui_touch_mode(); if (tm) ui_wtap_pump(pm, proot, pw, phh); if (tm) ui_long_pump(); ui_target_pump(pm, fr); if (tm) ui_use_pump(); if (tm) ui_buy_pump(pw, phh); ui_item_pump(proot, pw, phh); ui_ptr_pump(pm, proot, pw, phh); if (tm) ui_drag_pump(pm, proot, pw, phh); UI_MOUSE_ITEM_PUMPS(pm, proot, pw, phh); { int lu = atomic_load(&g_load_up); dm_uiscreen_set_ingame(ui_panel(proot, "HUDPanel") && !(lu < 0 ? ui_find(proot, "LoadScreenPanel", 0) != 0 : lu)); } ui_safe_pump(pm, proot, fr); ui_lift_pump(proot, fr); ui_trove_tabs_pump(pm, proot, fr); ui_minimap_pump(pm, proot, pw, phh, fr); ui_map_pump(pm); ui_map_geom_pump(pm, proot); ui_boss_pct_pump(pm, proot); ui_npcdlg_pump(proot); ui_map_center(pm, proot, *(volatile int32_t *)(pm->base + 0x2d5c748)); if (tm) ui_bind_pump(proot, fr); if (tm) swaptab_pump(proot); if (tm) ui_mercpg_pump(pm, proot, fr); ui_widestash_pump(proot); mv_audit_pump(proot, fr); ui_pages_pump(pm, proot); } } } if (atomic_load(&g_fe_name_open) && atomic_load(&g_ut_phase) == 2) { // 起名页:点输入框(底板 / 文本框)= 重新弹系统键盘,不发鼠标点击 | naming page: tapping the input box (backplate / text box) = pop up the system keyboard again, no mouse click is sent module_t *nm = main_module(); uint64_t nroot = 0; if (nm) memcpy(&nroot, nm->base + 0x2f05458, 8); uint64_t pn = nroot ? ui_find(nroot, "CharacterCreateNamePanel", 0) : 0; if (pn && nm) { int32_t w = *(int32_t *)(nm->base + 0x211da38), h = *(int32_t *)(nm->base + 0x211da3c); uint64_t v = atomic_load(&g_ut_xy); diff --git a/dm/host/dm_i18n_tab.h b/dm/host/dm_i18n_tab.h index f692116..42cbbac 100644 --- a/dm/host/dm_i18n_tab.h +++ b/dm/host/dm_i18n_tab.h @@ -206,6 +206,7 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmRiftSayStart", "第 %d 层开始,限时 15 分钟", "Level %d: 15 minute time limit" }, { "dmRiftSayGift", "赠彩虹刻面一颗,已掉在脚下", "A Rainbow Facet has dropped" }, { "dmRiftSayTimeout", "时间到:本层未过关,守护者仍会掉落", "Time's up: level not cleared" }, + { "dmRiftSayGuardians", "进度已满:两位守护者现身!", "Two Rift Guardians appear!" }, { "dmRiftSayGuardian", "进度已满:守护者现身!", "The Rift Guardian appears!" }, { "dmElyToaGround", "背包已满,赦免之证掉在脚边", "Inventory full: Token of Absolution dropped" }, { "dmMercSlotLocked", "通关地狱后打通秘境10层解锁", "Clear Greater Rift Level 10 to unlock" }, @@ -259,6 +260,7 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmRiftHudGuard", "守护者现身", "Rift Guardian" }, { "dmRiftHudNext", "下次第 %d 层", "Next: Level %d" }, { "dmRiftHudTop", "已通关最高层", "Highest level cleared" }, + { "dmRiftHudOver", "已超时:打完仍有掉落,不计通关", "Overtime: drops, no clear" }, { "dmRiftHudSame", "下次仍是这一层", "Next: same level" }, { "dmRiftHudKill", "击败守护者", "Slay the Rift Guardian" }, { "dmRiftHudGoal", "消灭秘境中的怪物 %d%%", "Slay the monsters %d%%" }, @@ -298,6 +300,7 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmRiftBtnStart", "开始", "Enter Rift" }, { "dmRiftBtnAbandon", "放弃", "Quit" }, { "dmRiftBtnResel", "重新选层", "Select Level" }, + { "dmRiftCapContOver", "有掉落,不计通关", "Loot only, no clear" }, { "dmRiftCapCont", "回到离开时的位置", "Resume your run" }, { "dmRiftBtnCont", "继续", "Continue" }, { "dmRiftMsT", "首通奖励", "First Clear" }, @@ -329,4 +332,7 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmAppMenuHelp", "帮助", "Help" }, { "dmAppKeysTitle", "键盘与手柄按键对照", "Keyboard and Controller Buttons" }, { "dmAppKeysText", "用键盘时,界面上的按键提示显示的就是键盘上的键;接上手柄按一下,提示换成手柄字母。\n\n确认:J(空格也可以)  返回:K(Esc 也可以)\n回车也可以确认;页面底部有「=」提示时回车当 =(如起名后的「接受」)\n=:菜单 / 新角色  Tab:地图\n移动:W A S D  十字键:方向键\nU I Q E Z C:手柄的 X Y L R ZL ZR\nF:按左摇杆  G:按右摇杆\n\n鼠标:左键点空地走过去,按住不放一直朝光标走;点目标、界面、底部的按键提示和技能 / 药水格;右键 = 返回;滚轮滚列表。\n接上手柄可以直接用。这一页以后在「帮助」菜单里。", "With a keyboard, on-screen button hints show keyboard keys; press anything on a connected controller and they switch to controller letters.\n\nConfirm: J (Space also works) Back: K (Esc also works)\nReturn also confirms; acts as = when the page shows an = hint (e.g. Accept after naming)\n=: menu / new character Tab: map\nMove: W A S D D-pad: arrow keys\nU I Q E Z C: controller X Y L R ZL ZR\nF: press left stick G: press right stick\n\nMouse: left click the ground to walk there, hold to keep walking toward the cursor; click targets, the interface, the button hints at the bottom and skill / potion slots; right click = back; wheel scrolls lists.\nA connected controller works right away. This page stays in the Help menu." }, + { "dmAppShareLog", "分享日志…", "Share Logs…" }, + { "dmAppShareInfo", "版本信息", "Version Info" }, + { "dmAppShareFail", "日志打包失败", "Could Not Pack the Logs" }, }; diff --git a/dm/host/dm_padmode.c b/dm/host/dm_padmode.c index c2f532e..20cb124 100644 --- a/dm/host/dm_padmode.c +++ b/dm/host/dm_padmode.c @@ -470,6 +470,10 @@ void dm_padmode_step(uint8_t *b, uint64_t frame) { // 游戏主线程每帧( L += (size_t)snprintf(o + L, L < sizeof o ? sizeof o - L : 0, "%s%s=「%s」", i ? "、" : "", g_str[i].key, r ? r : "(空)"); } LOG("DM_TEST_PADMODE:帧 %llu 模式 %s,原版取串 %s", (unsigned long long)frame, g_cur ? "手柄" : "触屏", o); } } #if TARGET_OS_OSX + // 建角模式页「极乐世界」那行左边写死的手柄键帽(布局 touch_layout.py 的 TouchBlissKey,原位 x −1665):Mac 的覆盖层同位带了一个键盘键帽 TouchBlissKeyK,按当前键帽对调 + // The hard-coded gamepad key cap to the left of the "Elysium" row on the character-creation mode page (TouchBlissKey in the layout touch_layout.py, original position x -1665): the Mac overlay carries a keyboard key cap TouchBlissKeyK at the same position, and the two are swapped according to the current key caps + if (g_kbd_have && frame % 10 == 0) { uint64_t root = rd8((uint64_t)(uintptr_t)(b + 0x2f05458)), a = root ? pm_find(root, "TouchBlissKey", 0) : 0, k = a ? pm_find(root, "TouchBlissKeyK", 0) : 0; + for (int i = 0; i < 2 && a && k; i++) { uint64_t w = i ? k : a; int32_t *r = (int32_t *)(uintptr_t)(w + 0x70), x = (i ? g_kbd : !g_kbd) ? -1665 : 99999; if (r[0] != x) { r[0] = x; ((void (*)(uint64_t))rd8(rd8(w) + 0x10))(w); } } } // 测试开关 DM_TEST_KBDCAPS=<帧>:<0|1>[,…]:到帧当作「实体手柄有输入(0)/ 键盘有输入(1)」(无人值守的局没有实体手柄) // Test switch DM_TEST_KBDCAPS=:<0|1>[,...]: at that frame act as if "a physical gamepad had input (0) / the keyboard had input (1)" (unattended runs have no physical gamepad) { static int n = -1, k; static struct { uint64_t f; int m; } ev[8]; diff --git a/dm/host/dm_rift.c b/dm/host/dm_rift.c index cb9b5dc..e9e016f 100644 --- a/dm/host/dm_rift.c +++ b/dm/host/dm_rift.c @@ -100,7 +100,7 @@ enum { ST_IDLE, ST_RUN, ST_DONE }; static struct { _Atomic int st; int tier, maps[3], nmaps, cur; // 本次层数、串起来的图、正在第几张 | This rift's level, the chained maps, which map we are on _Atomic int score, need; uint64_t t0_ns; _Atomic int timeout, guard_dead; // 分数(客户端加)、开局时刻(客体时钟)、超时、守护者已死 | Score (added by the client), start time (guest clock), timed out, guardian dead - uint32_t guard; int guard_cls, inc; // 守护者单位 id;成功涨了几层 | Guardian unit id; how many levels were gained on success + uint32_t guard, guards[3]; int guard_cls, gcls[3], nplan, inc; // 守护者:guards[] 各位的单位 id(guard = 第一位,非 0 即「已刷出」)、gcls[] 开局抽好的类号、nplan 本场几位;inc 成功涨了几层 | Guardians: guards[] unit id of each (guard = the first, non-zero meaning "spawned"), gcls[] class ids drawn at the start, nplan how many in this run; inc how many levels were gained on success int players_old; // 开局前的 /players 档 | The /players setting from before the start of the run char who[64]; // 角色名(层数侧文件) | Character name (level sidecar file) int resume_tier; // 图用完 → 一键重开后新局里要直接开的层(0 = 无) | Maps ran out -> the level to open directly in the new run after the one-tap restart (0 = none) @@ -286,13 +286,18 @@ int dm_rift_active(void) { return atomic_load(&K.st) == ST_RUN; } // The next level after this one is completed: completing within the time limit goes up K.inc levels (capped at 100), completing overtime does not go up. The next level is computed in this one place only - the door at the Guardian, the completion log and "next: level N" on the progress bar at the top all take it from here // (the top bar used to compute tier + inc by itself without the cap, and wrote "next: level 103" after a timed clear of level 100) static int next_tier(void) { int nt = K.inc ? K.tier + K.inc : K.tier; return nt > 100 ? 100 : nt; } +// 「进行中且已超时」:限时到了但守护者还没倒——还能打完、有掉落,但不计通关。只有这一处算;顶部条与城里入口菜单都读它,不各自拿剩余秒数去猜 +// (公开仓库 超时后只弹一次提示,之后顶部条只剩红色 0:00 和平常的目标,城里菜单仍叫「进行中」,分不清是超时还是还在限时内) +// "In progress and overtime": the time limit has passed but the Guardian is not down yet - the run can still be finished and still drops loot, but does not count as a clear. Computed in this one place only; the top bar and the town entrance menu both read it instead of each guessing from the seconds left +// (after timing out only one message was shown, then the top bar was left with a red 0:00 and the usual goal, and the town menu still said "in progress", so overtime could not be told from still being within the limit) +static int rift_overtime(void) { return atomic_load(&K.st) == ST_RUN && K.t0_ns && guest_ns() - K.t0_ns >= (uint64_t)RIFT_SECS * 1000000000ull; } static int g_left_done; // 结算时剩余秒数:打倒守护者后顶部条与面板都显示它,不再往下走 | Seconds left at completion: after the guardian is defeated both the top bar and the panel show it, and it no longer counts down int dm_rift_hud(dm_rift_hud_t *o) { int st = atomic_load(&K.st); if (st != ST_RUN && st != ST_DONE) return 0; uint64_t now = guest_ns(); int el = K.t0_ns ? (int)((now - K.t0_ns) / 1000000000ull) : 0; int need = atomic_load(&K.need); o->tier = K.tier; o->progress = need > 0 ? (float)atomic_load(&K.score) / need : 0; if (o->progress > 1) o->progress = 1; - o->secs_left = st == ST_DONE ? g_left_done : RIFT_SECS - el; o->done = st == ST_DONE; o->guardian = K.guard != 0 && !atomic_load(&K.guard_dead); o->inc = K.inc; o->next = next_tier(); + o->secs_left = st == ST_DONE ? g_left_done : RIFT_SECS - el; o->done = st == ST_DONE; o->guardian = K.guard != 0 && !atomic_load(&K.guard_dead); o->inc = K.inc; o->next = next_tier(); o->overtime = rift_overtime(); return 1; } @@ -301,7 +306,54 @@ int dm_rift_hud(dm_rift_hud_t *o) { enum { NQ = 256 }; static _Atomic uint32_t g_newq[NQ]; static _Atomic uint32_t g_newq_w; // 新见到的敌对怪 id(服务端按目标等级改属性) | Newly seen hostile monster ids (the server changes stats by target level) static uint32_t g_swept[1024]; int dm_rift_swept(uint32_t id) { return id && g_swept[id & 1023] == id; } // 这只是结算后清掉的(积分牌不计击杀) | This one was cleared after completion (the kill board does not count the kill) +// ---- 75 层以上的内容(设计稿)。总开关 DM_RIFT_HI=0 整体关回原状;测试开关 DM_RIFT_TEST_HI=<段名,…> 在任意层强制某一段(duo = 双守护者) +// ---- Content above level 75 (design draft). The master switch DM_RIFT_HI=0 turns it all back to the previous behaviour; the test switch DM_RIFT_TEST_HI= forces a segment at any level (duo = dual Guardians) +static int hi_on(const char *seg, int from) { static int off = -1; if (off < 0) { const char *e = getenv("DM_RIFT_HI"); off = e && !strcmp(e, "0"); } if (off) return 0; + const char *f = getenv("DM_RIFT_TEST_HI"); return (f && strstr(f, seg)) || K.tier >= from; } +// 双守护者每位的生命系数 s、伤害系数 d(×1000):75 层 0.51 / 0.75,线性到 100 层 0.775 / 1.0;低于 75 层被测试开关强制时取 75 层的值。 +// s 的两端:75 层双守护者期望总量 = 74 层单守护者的 1.16 倍(不跳变;双守护者的池是四位,见 k_duo);100 层最大的单体(巴尔)正好不过属性上限。d 未用读数校过 +// Life factor s and damage factor d of each of two Guardians (x1000): 0.51 / 0.75 at level 75, linear to 0.775 / 1.0 at level 100; below level 75 (forced by a test switch) the level-75 values are used. +// The two ends of s: the expected total of two Guardians at level 75 = 1.16 times a single Guardian at level 74 (no jump; the dual pool has four bosses, see k_duo); at level 100 the largest single one (Baal) stays just within the stat limit. d has not been calibrated with readouts +static int hi_duo_x1000(int which) { int t = K.tier < 75 ? 75 : K.tier > 100 ? 100 : K.tier; return which ? 750 + 250 * (t - 75) / 25 : 510 + 265 * (t - 75) / 25; } +// 多位首领同场的池不含安达利尔(156):她死后十几到四十拍,同场的另一位首领会跟着死——与巴尔、迪亚波罗各试过,3 + 1 局必现,那时另一位还剩大半生命、 +// 不是被伤害打死的;带不带任务事件门都一样;对照组(都瑞尔 + 迪亚波罗)没有这回事。看起来是她原版的死亡过程带的,没读到那段代码。单守护者(74 层及以下)仍是五位 +// The pool for several bosses in one fight does not include Andariel (156): ten-odd to forty ticks after she dies, the other boss in the same fight dies too - tried with Baal and with Diablo, reproduced in 3 + 1 runs, with the other one still at most of its life at that point, +// not killed by damage; the same with or without the quest-event gate; the control pair (Duriel + Diablo) shows nothing of the kind. It appears to come with her original death sequence; that code has not been read. A single Guardian (level 74 and below) is still drawn from all five +static const int k_duo[] = { 211, 242, 243, 544 }; +static int is_guard(uint32_t id) { return id && (id == K.guards[0] || id == K.guards[1] || id == K.guards[2]); } static int pts_of(uint8_t fl) { return fl & 0x02 ? 15 : fl & 0x08 ? 10 : fl & 0x04 ? 5 : fl & 0x10 ? 2 : 1; } // 怪物数据 +0x1a:超级独特 / 金怪 / 冠军 / 随从 / 普通(同 hle_target.c) | Monster data +0x1a: super unique / unique (gold) monster / champion / minion / normal (same as hle_target.c) +// ---- 每场读数(75 层以上内容曲线的量具,docs 设计稿第 0 步):只记、不改任何玩法。结算时打一行: +// 用时;击杀只数与这些怪的生命上限之和(按层改完之后的值,守护者另加);本场认作敌对并改过属性的怪的只数与生命和; +// 玩家受到的伤害和(当前生命逐拍下降量之和,回血不抵)、每秒峰值(连续 25 拍内的最大和)、死亡次数; +// 玩家 40 格内活着的敌对单位数的峰值与均值(每 25 拍数一次,只在秘境图里数)。 +// 生命以点计(原始定点 >> 8)。表按单位号记,每开一层清一次。击杀在客户端每帧函数里认(另一条线程),所以两个累加量用原子量;其余只在服务端拍里读写 +// ---- Per-run readouts (the measuring tool for the content curve above level 75, step 0 of the design): record only, change no gameplay. One line at completion: +// time taken; number of kills and the sum of those monsters' maximum life (the values after per-level scaling, Guardian added separately); number and life total of the monsters recognised as hostile and scaled in this run; +// total damage the player took (sum of per-tick drops in current life, healing not offset), the per-second peak (largest sum within 25 consecutive ticks), number of deaths; +// peak and mean of the number of living hostile units within 40 tiles of the player (counted every 25 ticks, only on rift maps). +// Life is in points (raw fixed point >> 8). The table is keyed by unit id and cleared at the start of every level. Kills are recognised in the client's per-frame function (another thread), so the two accumulators are atomics; everything else is read and written only on server ticks +static struct { int seq; uint32_t id[4096]; int hp[4096]; _Atomic long long kill_hp; _Atomic int kills; long long spawn_hp, guard_hp, dmg, win[25], win_sum, dmg_peak, near_sum; int spawns, wi, last_hp, deaths0, near_peak, near_n; } HS; +static int unit_align(uint64_t u); +static void hs_sync(void) { int sq = atomic_load(&g_run_seq); if (sq == HS.seq) return; memset(&HS, 0, sizeof HS); HS.seq = sq; HS.deaths0 = R.deaths; } +static void hs_spawn(uint32_t id, int hp) { hs_sync(); HS.id[id & 4095] = id; HS.hp[id & 4095] = hp; HS.spawns++; HS.spawn_hp += hp; } +static void hs_kill(uint32_t id) { if (HS.id[id & 4095] != id) return; atomic_fetch_add(&HS.kill_hp, HS.hp[id & 4095]); atomic_fetch_add(&HS.kills, 1); } +static void hs_tick(uint64_t G, uint64_t player, uint32_t t, int lv) { + hs_sync(); int hp = gs(player, 6) >> 8, d = HS.last_hp > 0 && hp < HS.last_hp ? HS.last_hp - hp : 0; HS.last_hp = hp; + HS.dmg += d; HS.win_sum += d - HS.win[HS.wi]; HS.win[HS.wi] = d; HS.wi = (HS.wi + 1) % 25; if (HS.win_sum > HS.dmg_peak) HS.dmg_peak = HS.win_sum; + // 测试读数 DM_RIFT_TEST_HSLOG=1:每 750 拍打一行进行中的读数(自动跑的局打不完一整场时,用「击杀生命和 ÷ 已得分数」推算整场) + // Test readout DM_RIFT_TEST_HSLOG=1: print one line of in-progress readouts every 750 ticks (when an automated run cannot finish a whole run, the whole run is estimated from "killed life total / score so far") + { static int on = -1; if (on < 0) on = getenv("DM_RIFT_TEST_HSLOG") != NULL; if (on && t % 750 == 0 && atomic_load(&K.st) == ST_RUN) { int sc = atomic_load(&K.score); + LOG("秘境:读数(进行中)第 %d 层 拍 %u:分数 %d / %d,击杀 %d 只、生命和 %lld 点(每分 %.0f 点);改过属性的敌对怪 %d 只、生命和 %lld 点;40 格内敌对单位 峰值 %d / 均值 %.1f", K.tier, t, sc, atomic_load(&K.need), atomic_load(&HS.kills), atomic_load(&HS.kill_hp), sc ? (double)atomic_load(&HS.kill_hp) / sc : 0.0, HS.spawns, HS.spawn_hp, HS.near_peak, HS.near_n ? (double)HS.near_sum / HS.near_n : 0.0); } } + if (t % 25 || !in_rift_map(lv)) return; + int px, py, n = 0; if (!unit_xy(player, &px, &py)) return; + for (int b = 0; b < 128; b++) for (uint64_t u = rd(G + 0x2230 + 1 * 0x400 + 8 * b); u; u = rd(u + 0x158)) { uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); int x, y; + if (m == 0 || m == 12 || unit_level(u) != lv || !unit_xy(u, &x, &y) || abs(x - px) > 40 || abs(y - py) > 40 || unit_align(u)) continue; n++; } + HS.near_sum += n; HS.near_n++; if (n > HS.near_peak) HS.near_peak = n; +} +static void hs_report(int secs) { + LOG("秘境:读数 第 %d 层 用时 %d 秒:击杀 %d 只、生命和 %lld 点(另守护者 %lld 点);改过属性的敌对怪 %d 只、生命和 %lld 点;承伤和 %lld 点、每秒峰值 %lld 点、死亡 %d 次;40 格内敌对单位 峰值 %d / 均值 %.1f(采样 %d 次)", + K.tier, secs, atomic_load(&HS.kills), atomic_load(&HS.kill_hp), HS.guard_hp, HS.spawns, HS.spawn_hp, HS.dmg, HS.dmg_peak, R.deaths - HS.deaths0, HS.near_peak, HS.near_n ? (double)HS.near_sum / HS.near_n : 0.0, HS.near_n); +} void dm_rift_client_pump(uint8_t *b) { static uint32_t seen[4096], dead[4096]; static int lvp = -1; // 每开一层清一次「见过 / 已算死」两张表:表按单位号记,而单位号每局从头编——上一局(一键重开、退出再进)或上一层留下的记录会让新局里 @@ -329,13 +381,13 @@ void dm_rift_client_pump(uint8_t *b) { if (!in_rift_map(lv)) return; for (int k = 0; k < 128; k++) for (uint64_t u = rd((uint64_t)(uintptr_t)(b + 0x2d603a0 + 1 * 0x400 + k * 8)); u; u = rd(u + 0x158)) { uint32_t id = *(uint32_t *)(uintptr_t)(u + 8), m = *(uint32_t *)(uintptr_t)(u + 0xc), h = id & 4095; - if (id == K.guard) continue; // 守护者另算 | The guardian is counted separately + if (is_guard(id)) continue; // 守护者另算 | The guardian is counted separately int alive = m != 0 && m != 12; if (alive) { if (seen[h] == id) continue; if (((int (*)(int, uint64_t, uint64_t))(b + 0x2f7b7c))(0x165, pl, u) != 1) continue; seen[h] = id; uint32_t w = atomic_fetch_add(&g_newq_w, 1); atomic_store(&g_newq[w % NQ], id); continue; } if (seen[h] != id || dead[h] == id) continue; // 只算活着时见过、认作敌对的 | Count only those seen alive and identified as hostile - dead[h] = id; uint64_t md = rd(u + 0x10); uint8_t fl = md ? *(uint8_t *)(uintptr_t)(md + 0x1a) : 0; int p = pts_of(fl); + dead[h] = id; hs_kill(id); uint64_t md = rd(u + 0x10); uint8_t fl = md ? *(uint8_t *)(uintptr_t)(md + 0x1a) : 0; int p = pts_of(fl); int s = atomic_fetch_add(&K.score, p) + p; static int ln; if (ln++ < 40 || s % 50 < p) LOG("秘境:击杀 id %u(标志 %#x,+%d)→ 分数 %d / %d", id, fl, p, s, atomic_load(&K.need)); } } @@ -400,12 +452,13 @@ static uint32_t monlvl(uint64_t G, int lvl, int grp) { uint64_t T = tables(G), a // for a unit with a percentage life bonus, writing the base up to the limit makes the total overflow to a negative number, which is read as 1 point (this is how minions fell back to 1). So headroom is left according to the current total / base. // base / full = the base entry and the total at this moment (raw fixed-point values); with no bonus (total not greater than base) or when the base entry cannot be read, it is the stat limit itself static long long hp_base_limit(int base, int full) { return base > 0 && full > base ? 0x7fffff00LL * base / full : 0x7fffff00LL; } +static int g_hp_mul = 1000; // scale_monster 的生命额外系数(×1000):双守护者的 s 在截顶之前乘进去——先截顶再乘的话,规则值过上限的那位(巴尔)会被多砍一刀 | extra life factor of scale_monster (x1000): the dual-Guardian s is multiplied in before the clamp - clamping first and multiplying afterwards would cut the one whose rule value exceeds the limit (Baal) a second time static void scale_monster(uint64_t G, uint64_t u, int lt, int l9) { // lt = 本层的等级(守护者 + 3)、l9 = 起算层的等级 | lt = this level's level (Guardian + 3), l9 = the baseline level's level int l0 = gs(u, 12); if (l0 <= 0) return; if (lt > lvl_cap()) lt = lvl_cap(); if (l9 > lt) l9 = lt; int tx = tier_total_x1000(K.tier, 0), lb = l0 > l9 ? l0 : l9, le = l0 > lt ? l0 : lt; // lb:「起算层那只怪」的等级;le:写进单位的等级(不降级) | lb: the level of "that monster at the baseline level"; le: the level written into the unit (never lowered) if (le == l0 && lb == l0 && tx == 1000) return; // 9 层、原生等级已不低于目标:什么都不用改 | level 9 and the native level is already no lower than the target: nothing to change uint32_t h0 = monlvl(G, l0, 2), hb = monlvl(G, lb, 2), d0 = monlvl(G, l0, 3), db = monlvl(G, lb, 3), a0 = monlvl(G, l0, 0), a1 = monlvl(G, le, 0); if (!h0 || !d0 || !a0) return; - long long want = (long long)gs(u, 7) * hb / h0 * tx / 1000, hp = want, lim = hp_base_limit(gsb(u, 7), gs(u, 7)); if (hp > lim) hp = lim; // 定点 ×256;原版上限 2²³ 点,带百分比生命加成的怪按比例留余量(hp_base_limit) | fixed point x256; the original's limit is 2^23 points, and monsters with a percentage life bonus get proportional headroom (hp_base_limit) + long long want = (long long)gs(u, 7) * hb / h0 * tx / 1000 * g_hp_mul / 1000, hp = want, lim = hp_base_limit(gsb(u, 7), gs(u, 7)); if (hp > lim) hp = lim; // 定点 ×256;原版上限 2²³ 点,带百分比生命加成的怪按比例留余量(hp_base_limit) | fixed point x256; the original's limit is 2^23 points, and monsters with a percentage life bonus get proportional headroom (hp_base_limit) // 顶到上限不静默:这只怪(多半是守护者)的生命没按线涨足,只剩伤害在涨。每开一层记前 3 只 // Hitting the cap is not silent: this monster (most likely the Guardian) did not get its full life according to the line, and only its damage keeps // growing. The first 3 are logged for each level opened @@ -921,6 +974,7 @@ static void milestone(uint64_t G, uint64_t player, int m) { static void finish(uint64_t G, uint64_t player, uint64_t guard) { uint64_t now = guest_ns(); int left = RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull); g_left_done = left; // 结算这一拍停表 | Stop the clock on the completion tick + hs_report(RIFT_SECS - left); K.inc = left >= 600 ? 3 : left >= 300 ? 2 : left > 0 ? 1 : 0; int next = next_tier(); if (K.inc) { R.clears++; if (K.tier > R.best) R.best = K.tier; } if (K.inc && (!R.fast[K.tier] || RIFT_SECS - left < R.fast[K.tier])) R.fast[K.tier] = RIFT_SECS - left; if (K.inc) pts_grant(player); // 通关点数:R.best 更新之后、下面 rec_save 之前。只算限时内通关(「超时通关不算过关,15 分钟内才是过关」),与上一行最高通关层同一口径 | clear points: after R.best is updated and before rec_save below. Only clears within the time limit count ("a clear after the time limit does not count as passing; only within 15 minutes does"), same rule as the highest cleared level on the previous line @@ -995,7 +1049,7 @@ static void finish(uint64_t G, uint64_t player, uint64_t guard) { static void menu_fill(dm_rift_menu_t *o, int m) { uint64_t now = guest_ns(); int need = atomic_load(&K.need); o->menu = m; o->best = R.best; o->unlock = R.unlock < 1 ? 1 : R.unlock; o->def = R.tier; o->ms = R.ms; o->clvl = atomic_load(&M.clvl); - o->tier = K.tier; o->done = atomic_load(&K.st) == ST_DONE; o->inc = K.inc; o->next = next_tier(); o->secs_left = o->done ? g_left_done : K.t0_ns ? RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull) : RIFT_SECS; if (o->secs_left < 0) o->secs_left = 0; + o->tier = K.tier; o->done = atomic_load(&K.st) == ST_DONE; o->inc = K.inc; o->next = next_tier(); o->overtime = rift_overtime(); o->secs_left = o->done ? g_left_done : K.t0_ns ? RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull) : RIFT_SECS; if (o->secs_left < 0) o->secs_left = 0; o->progress = need > 0 ? (float)atomic_load(&K.score) / need : 0; if (o->progress > 1) o->progress = 1; } int dm_rift_menu(dm_rift_menu_t *o) { int m = atomic_load(&M.menu); if (m == MENU_NONE) return 0; menu_fill(o, m); return 1; } @@ -1047,7 +1101,13 @@ static int start_rift(uint64_t G, uint64_t player, uint32_t t, int tier) { for (int q = 0; q < K.nmaps && L.nused < 24; q++) L.used[L.nused++] = K.maps[q]; atomic_fetch_add(&g_run_seq, 1); rift_setup(G); K.cur = 0; atomic_store(&K.score, getenv("DM_RIFT_TEST_SCORE") ? atoi(getenv("DM_RIFT_TEST_SCORE")) : 0); // 测试:初始分数(看进度条) | Test: initial score (to see the progress bar) - atomic_store(&K.guard_dead, 0); atomic_store(&K.timeout, 0); K.guard = 0; K.inc = 0; + atomic_store(&K.guard_dead, 0); atomic_store(&K.timeout, 0); K.guard = 0; memset(K.guards, 0, sizeof K.guards); K.inc = 0; + // 本场的守护者开局就抽好(之后回城再来、继续,都是这几位):75 层起两位不同的。测试开关 DM_RIFT_TEST_GUARDS=<类号>[,<类号>] 指定(逐对验收用) + // This run's Guardians are drawn at the start (returning to town and coming back, or continuing, gives the same ones): from level 75 two different ones. Test switch DM_RIFT_TEST_GUARDS=[,] specifies them (for pair-by-pair acceptance) + { K.nplan = hi_on("duo", 75) ? 2 : 1; K.gcls[2] = 0; + if (K.nplan == 2) { int a = rnd(4), b = (a + 1 + rnd(3)) % 4; K.gcls[0] = k_duo[a]; K.gcls[1] = k_duo[b]; } else { K.gcls[0] = k_guard[rnd(5)]; K.gcls[1] = 0; } + const char *e = getenv("DM_RIFT_TEST_GUARDS"); if (e) { int x = 0, y = 0, n = sscanf(e, "%d,%d", &x, &y); if (n >= 1 && x > 0) K.gcls[0] = x; if (n >= 2 && y > 0) K.gcls[1] = y; } + K.guard_cls = K.gcls[0]; if (K.nplan == 2) LOG("秘境:本场守护者两位,类号 %d 与 %d(生命 ×%d.%03d、伤害 ×%d.%03d)", K.gcls[0], K.gcls[1], hi_duo_x1000(0) / 1000, hi_duo_x1000(0) % 1000, hi_duo_x1000(1) / 1000, hi_duo_x1000(1) % 1000); } K.t0_ns = guest_ns(); if (getenv("DM_RIFT_TEST_LATE")) { K.t0_ns -= (uint64_t)RIFT_SECS * 1000000000ull; LOG("秘境:测试 DM_RIFT_TEST_LATE 开局即超时"); } // 造「超时打倒守护者」现场 | set up the "Guardian defeated after time ran out" test case K.players_old = dm_hud_requested_players(); if (!K.players_old) K.players_old = 1; @@ -1126,7 +1186,7 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { { static int at = -1; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_SAVE"); at = e ? atoi(e) : 0; } if (at > 0 && t >= (uint32_t)at) { at = 0; int dm_request_save(void); LOG("秘境:测试 DM_RIFT_TEST_SAVE 拍 %u 请游戏存盘 → %d", t, dm_request_save()); } } // 测试开关 DM_RIFT_TEST_SAVE=<拍>:到这一拍请游戏存一次盘(验放大着的随从生命进不进角色档) | test switch DM_RIFT_TEST_SAVE=: ask the game to save once at this tick (to check whether boosted minion life gets into the character save) { static int at = -1; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_ABANDON"); at = e ? atoi(e) : 0; } if (at > 0 && t >= (uint32_t)at && st == ST_RUN) { at = 0; LOG("秘境:测试 DM_RIFT_TEST_ABANDON 拍 %u 替玩家放弃本层", t); atomic_store(&M.req_abandon, 1); } } // 测试开关 DM_RIFT_TEST_ABANDON=<拍>:秘境进行中到这一拍替玩家放弃(裸宿主上点不了「放弃」) | test switch DM_RIFT_TEST_ABANDON=: during a rift run, abandon on the player's behalf at this tick ("Abandon" cannot be clicked on the bare host) if (atomic_exchange(&M.req_abandon, 0) && (st == ST_RUN || st == ST_DONE)) { // 放弃:本层作废(不涨层、不发奖),写回改过的表,回选层页 | Abandon: this level is void (no level increase, no rewards); write back the modified tables and return to the level selection page - region_set(G, 0); if (K.players_old) dm_hud_request_players(K.players_old); K.guard = 0; L.next_door = L.town_door = 0; L.nd_lv = 0; atomic_store(&K.st, ST_IDLE); st = ST_IDLE; + region_set(G, 0); if (K.players_old) dm_hud_request_players(K.players_old); K.guard = 0; memset(K.guards, 0, sizeof K.guards); L.next_door = L.town_door = 0; L.nd_lv = 0; atomic_store(&K.st, ST_IDLE); st = ST_IDLE; LOG("秘境:放弃第 %d 层", K.tier); atomic_store(&M.menu, MENU_SELECT); pet_hp_pump(G, player, t); // 随从生命当拍设回基数,同结算处:放弃后回到选层页会走原版暂停,等下一拍的话要到玩家关掉面板才设回 | minion life is set back to base on this very tick, as at completion: after abandoning, returning to the level-selection page goes through the original's pause, and waiting for the next tick would delay it until the player closes the panel return; } @@ -1209,8 +1269,8 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { // Newly spawned hostile monsters get their stats changed by level (from level 9). Test switch DM_RIFT_TEST_LOWHP=1: change to 1 life point (hold the main attack button and kill all the way through; verifies scoring / guardian / level increase) static int lowhp = -1; if (lowhp < 0) lowhp = getenv("DM_RIFT_TEST_LOWHP") != NULL; if (K.tier >= 9 || lowhp) { static uint32_t r_; uint32_t w = atomic_load(&g_newq_w); if (w - r_ > NQ) r_ = w - NQ; int lt = target_level(player); - for (; r_ != w; r_++) { uint32_t id = atomic_load(&g_newq[r_ % NQ]); uint64_t u = find_unit(G, 1, id); if (u && id != K.guard) { if (K.tier >= 9) scale_monster(G, u, lt, dm_rift_tier_level(9, gs(player, 12))); if (lowhp) ss(u, 6, 256); dmg_probe_add(id, t); } } } - dmg_probe_pump(G, t); + for (; r_ != w; r_++) { uint32_t id = atomic_load(&g_newq[r_ % NQ]); uint64_t u = find_unit(G, 1, id); if (u && !is_guard(id)) { if (K.tier >= 9) scale_monster(G, u, lt, dm_rift_tier_level(9, gs(player, 12))); if (lowhp) ss(u, 6, 256); dmg_probe_add(id, t); hs_spawn(id, gs(u, 7) >> 8); } } } + dmg_probe_pump(G, t); hs_tick(G, player, t, lv); // 测试读数 DM_RIFT_TEST_ILVL=1:每 10 秒数一次地上的物品(服务端物品表 G+0x2e30,模式 3),报物品等级(数据块 +0x38)范围——验 B 方案下掉落物品等级跟不跟改过的怪物等级 // Test readout DM_RIFT_TEST_ILVL=1: every 10 seconds count the items on the ground (server item table G+0x2e30, mode 3) and report the item level (data block +0x38) range -- verifies whether drop item levels follow the modified monster level under plan B { static int il = -1; if (il < 0) il = getenv("DM_RIFT_TEST_ILVL") != NULL; @@ -1220,7 +1280,7 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { // 测试开关 DM_RIFT_TEST_PULL=1:每 3 秒用原版传送 0x7cc530 把人放到一只还活着的敌对怪(客户端认的)旁边——脚本按主攻击键就能一路打(验计分 / 守护者) // Test switch DM_RIFT_TEST_PULL=1: every 3 seconds use the original game's teleport 0x7cc530 to put the player next to a still-living hostile monster (as recognized by the client) -- a script only has to press the main attack button to fight all the way through (verifies scoring / guardian) { static int pull = -1; if (pull < 0) pull = getenv("DM_RIFT_TEST_PULL") != NULL; - if (pull && t % 38 == 0 && in_rift_map(lv) && K.guard && !atomic_load(&K.guard_dead)) { uint64_t g = find_unit(G, 1, K.guard); int x, y; if (g && unit_xy(g, &x, &y)) dm_teleport(B, G, player, unit_room(g), x + 2, y + 2); } + if (pull && t % 38 == 0 && in_rift_map(lv) && K.guard && !atomic_load(&K.guard_dead)) { uint64_t g = 0; for (int i = 0; i < 3 && !g; i++) { uint64_t gu = K.guards[i] ? find_unit(G, 1, K.guards[i]) : 0; uint32_t gm = gu ? *(uint32_t *)(uintptr_t)(gu + 0xc) : 0; if (gu && gm != 0 && gm != 12) g = gu; } int x, y; if (g && unit_xy(g, &x, &y)) dm_teleport(B, G, player, unit_room(g), x + 2, y + 2); } else if (pull && t % 38 == 0 && in_rift_map(lv)) { uint32_t w = atomic_load(&g_newq_w); int px, py, bd = 1 << 30, bx = 0, by = 0; unit_xy(player, &px, &py); // 最近的那只 | The nearest one for (uint32_t k = 0; k < NQ && k < w; k++) { uint64_t u = find_unit(G, 1, atomic_load(&g_newq[(w - 1 - k) % NQ])); if (!u || unit_level(u) != lv) continue; uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) continue; int x, y; if (!unit_xy(u, &x, &y)) continue; int d = abs(x - px) + abs(y - py); if (d < bd) { bd = d; bx = x; by = y; } } @@ -1233,11 +1293,27 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { // 守护者 // Guardian if (!K.guard && atomic_load(&K.score) >= atomic_load(&K.need) && in_rift_map(lv)) { - int x, y; unit_xy(player, &x, &y); int32_t pos[2] = { x + 6, y + 6 }; uint64_t rr = free_spot(G, unit_room(player), pos); - K.guard_cls = k_guard[rnd(5)]; - uint64_t u = rr ? ((uint64_t (*)(uint64_t, uint64_t, int, int, int, int, int, int, uint64_t))(B + 0x7ce630))(G, rr, 1, K.guard_cls, pos[0], pos[1], 1, 0, 0x10) : 0; - if (u) { K.guard = *(uint32_t *)(uintptr_t)(u + 8); if (lowhp) ss(u, 6, 256); else if (K.tier >= 9) scale_monster(G, u, target_level(player) + 3, dm_rift_tier_level(9, gs(player, 12)) + 3); // 守护者 = 本层怪物等级 + 3(110 封顶),起算层也按 + 3 算,同吃本层总倍率 | Guardian = this level's monster level + 3 (capped at 110); the baseline level is computed with + 3 as well, and the same total multiplier of this level applies - say("dmRiftSayGuardian"); LOG("秘境:拍 %u 刷守护者 类号 %d id %u 等级 %d 生命 %d", t, K.guard_cls, K.guard, gs(u, 12), gs(u, 7) >> 8); } } - if (K.guard && !atomic_load(&K.guard_dead)) { uint64_t u = find_unit(G, 1, K.guard); - if (u) { uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者死亡", t); finish(G, player, u); } } } + // 一位:人右下 6 格;两位:一左一右各 6 格。每位先照常按层改(守护者 = 本层怪物等级 + 3,起算层也 + 3,同吃本层总倍率),两位时再各乘 s(生命)与 d(伤害) + // One Guardian: 6 tiles to the lower right of the player; two: 6 tiles to the left and to the right. Each is first scaled by level as usual (Guardian = this level's monster level + 3, the starting level + 3 as well, with this level's total multiplier), and with two each is additionally multiplied by s (life) and d (damage) + static const int ox[2][2] = { { 6, 0 }, { 6, -6 } }, oy[2][2] = { { 6, 0 }, { 6, 6 } }; int x, y, n = 0; unit_xy(player, &x, &y); hs_sync(); + for (int i = 0; i < K.nplan && i < 2; i++) { int32_t pos[2] = { x + ox[K.nplan - 1][i], y + oy[K.nplan - 1][i] }; uint64_t rr = free_spot(G, unit_room(player), pos); + uint64_t u = rr ? ((uint64_t (*)(uint64_t, uint64_t, int, int, int, int, int, int, uint64_t))(B + 0x7ce630))(G, rr, 1, K.gcls[i], pos[0], pos[1], 1, 0, 0x10) : 0; + if (!u) { LOG("【红】秘境:守护者第 %d 位(类号 %d)没刷出来", i + 1, K.gcls[i]); continue; } + K.guards[i] = *(uint32_t *)(uintptr_t)(u + 8); if (!K.guard) K.guard = K.guards[i]; n++; + if (lowhp) ss(u, 6, 256); else if (K.tier >= 9) { g_hp_mul = K.nplan == 2 ? hi_duo_x1000(0) : 1000; scale_monster(G, u, target_level(player) + 3, dm_rift_tier_level(9, gs(player, 12)) + 3); g_hp_mul = 1000; } + if (K.nplan == 2 && !lowhp) ss(u, 25, (int)((100LL + gs(u, 25)) * hi_duo_x1000(1) / 1000 - 100)); // 伤害:属性 25 是「伤害 +N%」,整体乘 d 即 (100 + N) × d − 100 | damage: stat 25 is "damage +N%", so multiplying the whole by d gives (100 + N) x d - 100 + HS.guard_hp += gs(u, 7) >> 8; + LOG("秘境:拍 %u 刷守护者%s 类号 %d id %u 等级 %d 生命 %d 伤害百分比 %d", t, K.nplan == 2 ? (i ? "(第二位)" : "(第一位)") : "", K.gcls[i], K.guards[i], gs(u, 12), gs(u, 7) >> 8, gs(u, 25)); } + if (n) say(K.nplan == 2 && n == 2 ? "dmRiftSayGuardians" : "dmRiftSayGuardian"); } + // 测试替身 DM_RIFT_TEST_DUMMY=<每秒点数>:对在场的每位守护者按固定输出扣当前生命(留 1 点,由随从补最后一下)——人物不用真打,用来出「承伤每秒峰值」的相对值 + // Test stand-in DM_RIFT_TEST_DUMMY=: deduct current life from every Guardian present at a fixed output (leaving 1 point, with a minion delivering the last hit) - the character does not have to fight for real; used to obtain relative values of the "per-second peak of damage taken" + { static int dps = -1; if (dps < 0) { const char *e = getenv("DM_RIFT_TEST_DUMMY"); dps = e ? atoi(e) : 0; } + if (dps > 0 && K.guard && !atomic_load(&K.guard_dead)) for (int i = 0; i < 3; i++) { uint64_t u = K.guards[i] ? find_unit(G, 1, K.guards[i]) : 0; uint32_t m = u ? *(uint32_t *)(uintptr_t)(u + 0xc) : 0; if (!u || m == 0 || m == 12) continue; + long long h = (long long)gs(u, 6) - (long long)dps * 256 / 25; ss(u, 6, h < 256 ? 256 : (int)h); } } + // 结算条件:本场刷出的守护者全部死亡。任一位还活着(或还在单位表里没判死)都不结算、不开门 + // Completion condition: all the Guardians spawned in this run are dead. While any one is alive (or still in the unit table and not judged dead) there is no completion and no door + if (K.guard && !atomic_load(&K.guard_dead)) { int alive = 0; uint64_t last = 0; + for (int i = 0; i < 3; i++) { if (!K.guards[i]) continue; uint64_t u = find_unit(G, 1, K.guards[i]); if (!u) { alive++; continue; } /* 不在单位表里(房间卸载):不当它死了 | not in the unit table (room unloaded): do not treat it as dead */ + uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { last = u; static uint32_t said[3]; if (said[i] != K.guards[i]) { said[i] = K.guards[i]; LOG("秘境:拍 %u 守护者死亡(类号 %d id %u)", t, K.gcls[i], K.guards[i]); } } else alive++; } + if (!alive && last) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者全部死亡 → 结算", t); finish(G, player, last); } } } diff --git a/dm/host/dm_rift.h b/dm/host/dm_rift.h index 3bf0ddd..7778874 100644 --- a/dm/host/dm_rift.h +++ b/dm/host/dm_rift.h @@ -2,14 +2,14 @@ // Rift tower climb (dm_rift.c) #pragma once #include -typedef struct { int tier; float progress; int secs_left, done, guardian, inc, next; } dm_rift_hud_t; // next = 本层完成后下一次打第几层(封顶 100;等于 tier = 不涨:超时,或已在最高层)。显示方只读它,不自己用 tier + inc 算 | next = which level will be played after this one is completed (capped at 100; equal to tier = no increase: overtime, or already at the highest level). Display code only reads it and does not compute tier + inc itself +typedef struct { int tier; float progress; int secs_left, done, guardian, inc, next, overtime; } dm_rift_hud_t; // overtime = 进行中且限时已到(还能打完拿掉落,不计通关);与菜单里的同名量同源;next = 本层完成后下一次打第几层(封顶 100;等于 tier = 不涨:超时,或已在最高层)。显示方只读它,不自己用 tier + inc 算 | overtime = in progress and the time limit has passed (can still be finished for loot, does not count as a clear); the same source as the quantity of the same name in the menu; next = which level will be played after this one is completed (capped at 100; equal to tier = no increase: overtime, or already at the highest level). Display code only reads it and does not compute tier + inc itself void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base); // 服务端拍(diag.c) | Server tick (diag.c) void dm_rift_c2s(uint64_t G, const uint8_t *pkt, uint32_t len); // 客户端命令(点门) | Client command (door tap) void dm_rift_client_pump(uint8_t *main_base); // 取手柄处(dm_world.c):认击杀、新刷出的怪 | At the controller sampling point (dm_world.c): recognize kills and newly spawned monsters int dm_rift_hud(dm_rift_hud_t *out); // 前端每帧:秘境进行中 / 刚完成返回 1 | Front end every frame: returns 1 while a rift is in progress / just completed int dm_rift_active(void); void dm_rift_gamble_vals(int best, uint32_t *uniq, uint32_t *set); // 赌博加成:最高通关层 → 地狱暗金 / 套装值(十万分之一);best < 1 = 0(不加) | Gambling bonus: highest cleared level -> Hell unique / set values (in units of 1/100000); best < 1 = 0 (no bonus) -typedef struct { int menu, best, unlock, def; unsigned ms; int clvl, tier, done, secs_left; float progress; int inc, next; } dm_rift_menu_t; // menu 1 = 选层页、2 = 继续 / 放弃、3 = 守护者处那扇门的确认页(next = 要进的层);inc = 0 且 done = 超时打倒守护者(没过关) | menu 1 = level-selection page, 2 = Continue / Abandon, 3 = confirmation page of the door at the Guardian (next = the level to enter); inc = 0 and done = Guardian defeated overtime (not passed) +typedef struct { int menu, best, unlock, def; unsigned ms; int clvl, tier, done, secs_left; float progress; int inc, next, overtime; } dm_rift_menu_t; // menu 1 = 选层页、2 = 继续 / 放弃、3 = 守护者处那扇门的确认页(next = 要进的层);inc = 0 且 done = 超时打倒守护者(没过关) | menu 1 = level-selection page, 2 = Continue / Abandon, 3 = confirmation page of the door at the Guardian (next = the level to enter); inc = 0 and done = Guardian defeated overtime (not passed) int dm_rift_cleared_any(void); // 这个角色打通过任意一层秘境没有(限时内过关才算:最高通关层 ≥ 1)——技能硬点上限的解锁条件(dm_actions.c) | has this character cleared any Greater Rift level (only clears within the time limit count: highest cleared level ≥ 1): the unlock condition for the hard skill point cap (dm_actions.c) int dm_rift_merc_unlocked(void); // 佣兵新装备位解没解锁(秘境最高通关 ≥ 10 层) | Whether the new mercenary equipment slots are unlocked (highest rift level cleared ≥ 10) void dm_rift_merc_locked_hint(void); // 没解锁时的提示「通关地狱后打通秘境10层解锁」 | Hint when not unlocked: 「通关地狱后打通秘境10层解锁」(Clear Greater Rift Level 10 to unlock) diff --git a/dm/host/dm_rift_ui.c b/dm/host/dm_rift_ui.c index 18dfde3..73d4ed3 100644 --- a/dm/host/dm_rift_ui.c +++ b/dm/host/dm_rift_ui.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "dm.h" #include "dm_widget.h" #include "dm_rift.h" @@ -138,8 +139,15 @@ void dm_rift_ui_pump(void) { // level (quitting is irreversible, so it is not on A); B is not taken over = the original game closes the panel. // The key legend uses the original bottom button legend (action number 0 = A, 2 = X), with the same strings as on the buttons { int dm_padmode_current(void); uint64_t dm_padmode_page_keys(uint64_t); void dm_padmode_legend(int, const char *); - { int kx = dm_padmode_current() ? 52 : 99999; rect(find(bw, "TouchRF_KeyA", 0), kx, 1181); rect(find(bw, "TouchRF_KeyA2", 0), kx, 1181); rect(find(bw, "TouchRF_KeyX", 0), m.menu == 3 ? 99999 : kx, 844); } // 确认页上面那个钮不在,它的键帽也不显示 // 按钮左端的原版键帽:只在手柄模式显示 | the upper button is absent on the confirmation page, so its key cap is not shown either - rect(find(panel(), "TouchCloseBox", 1), dm_padmode_current() ? 99999 : -998, 256); // 右上角的触屏关闭 X(布局同编年史 _chronicle_touch):手柄模式挪到屏外(按 B 关),触屏模式放回布局里的位置;同 dm_kills.c | the touch close X in the top-right corner (layout same as the Chronicle _chronicle_touch): moved off screen in controller mode (B closes), put back at its layout position in touch mode; same as dm_kills.c + { int kx = dm_padmode_current() ? 52 : 99999, px = kx; +#if TARGET_OS_OSX + // Mac App:玩家用键盘时按钮左端显示键盘键帽(布局里名字加 K 的那几个,只有 Mac 的覆盖层带),手柄有输入时显示手柄键帽;两套同位,一套在屏上另一套挪出屏 + // Mac App: when the player uses the keyboard, the left end of a button shows the keyboard key cap (the ones whose layout names end in K, carried only by the Mac overlay), and when a gamepad has input the gamepad key cap is shown; the two sets share a position, one on screen and the other moved off screen + { int dm_padmode_kbd(void); int qx = 99999; if (dm_padmode_kbd()) { qx = kx; px = 99999; } + rect(find(bw, "TouchRF_KeyAK", 0), qx, 1181); rect(find(bw, "TouchRF_KeyA2K", 0), qx, 1181); rect(find(bw, "TouchRF_KeyXK", 0), m.menu == 3 ? 99999 : qx, 844); } +#endif + rect(find(bw, "TouchRF_KeyA", 0), px, 1181); rect(find(bw, "TouchRF_KeyA2", 0), px, 1181); rect(find(bw, "TouchRF_KeyX", 0), m.menu == 3 ? 99999 : px, 844); } // 确认页上面那个钮不在,它的键帽也不显示 // 按钮左端的原版键帽:只在手柄模式显示 | the upper button is absent on the confirmation page, so its key cap is not shown either + { uint64_t an = find(panel(), "TouchRF_Anchor", 1); int pad = dm_padmode_current(); rect(find(an, "TouchRF_CloseX", 1), pad ? 99999 : 1766, 64); rect(find(an, "TouchClose", 1), pad ? 99999 : 1705, -11); rect(find(an, "TouchRF_CloseBtn", 1), pad ? 1868 : 99999, 8); } // 外框右上角的关闭钮只留一个:手柄 / 键鼠显示原版红框(按 B 或鼠标点),触屏显示金色 X(与别的面板同图同处),另一个挪出屏 | only one close button stays at the top right of the frame: gamepad / keyboard-and-mouse show the original red frame (press B or click it), touch shows the gold X (same image and place as other panels), and the other one is moved off screen if (dm_padmode_current()) { int ch = m.menu >= 2, cf = m.menu == 3; // cf:确认页,只有 A = 继续;取消 = B 关面板(原版) | cf: confirmation page, only A = continue; cancel = B closes the panel (as in the original) uint64_t ev = dm_padmode_page_keys(DM_BTN_A | DM_BTN_X | DM_BTN_LEFT | DM_BTN_RIGHT | DM_BTN_UP | DM_BTN_DOWN); dm_padmode_legend(0, dm_str(b, ch ? "dmRiftBtnCont" : "dmRiftBtnStart")); if (ch && !cf) dm_padmode_legend(2, dm_str(b, m.done ? "dmRiftBtnResel" : "dmRiftBtnAbandon")); @@ -200,8 +208,8 @@ void dm_rift_ui_pump(void) { // uncompleted page = "this level is void / Abandon" and "return to the position at the time of leaving / Continue". "Reselect level" is a separate // button at the same position as "Abandon", moved in and out (the host cannot write button text) rect(find(bw, "TouchRF_Abandon", 0), m.done ? 99999 : 0, 818); rect(find(bw, "TouchRF_Resel", 0), m.done ? 0 : 99999, 818); - text(find(bw, en ? "TouchRF_ContTE" : "TouchRF_ContT", 0), dm_str(rb(), m.done ? "dmRiftCapGuard" : "dmRiftCapCont")); - text(find(bw, "TouchRF_ChNote", 0), ""); text(find(bw, "TouchRF_ChT", 0), dm_str(rb(), m.done ? (m.inc ? "dmRiftTitleDone" : "dmRiftTitleLate") : "dmRiftTitleRun")); + text(find(bw, en ? "TouchRF_ContTE" : "TouchRF_ContT", 0), dm_str(rb(), m.done ? "dmRiftCapGuard" : m.overtime ? "dmRiftCapContOver" : "dmRiftCapCont")); + text(find(bw, "TouchRF_ChNote", 0), ""); text(find(bw, "TouchRF_ChT", 0), dm_str(rb(), m.done ? (m.inc ? "dmRiftTitleDone" : "dmRiftTitleLate") : m.overtime ? "dmRiftTitleLate" : "dmRiftTitleRun")); // 进行中但已超时:标题同「超时未过关」 | in progress but overtime: the title is the same as "Time's Up" if (m.done) { text(find(bw, "TouchRF_ChLeftL", 0), dm_str(rb(), "dmRiftGuardDown")); text(find(bw, "TouchRF_ChLeft", 0), ""); text(find(bw, "TouchRF_ChProgL", 0), dm_str(rb(), m.inc ? "dmRiftNextOpen" : "dmRiftRetryOpen")); text(find(bw, "TouchRF_ChProg", 0), ""); text(find(bw, "TouchRF_ChNoteL", 0), dm_str(rb(), m.inc ? "dmRiftSaved" : "dmRiftNotCounted")); } else { int s = m.secs_left; text(find(bw, "TouchRF_ChLeftL", 0), dm_str(rb(), "dmRiftTimeLeft")); snprintf(t, sizeof t, "%d:%02d", s / 60, s % 60); text(find(bw, "TouchRF_ChLeft", 0), t); text(find(bw, "TouchRF_ChProgL", 0), dm_str(rb(), "dmRiftProgress")); snprintf(t, sizeof t, "%d%%", (int)(m.progress * 100)); text(find(bw, "TouchRF_ChProg", 0), t); text(find(bw, "TouchRF_ChNoteL", 0), ""); } diff --git a/dm/host/dm_update.c b/dm/host/dm_update.c index e089f09..3076d5b 100644 --- a/dm/host/dm_update.c +++ b/dm/host/dm_update.c @@ -19,6 +19,7 @@ #include #include #include +#include static int g_own = -1; static void (*g_on_select)(void), (*g_on_click)(void); static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER; static struct { int build, urgent; char note[160]; } g_offer; // g_mu 护 g_offer | g_mu guards g_offer @@ -115,6 +116,23 @@ void dm_update_pump(void) { // 取手柄处每帧调(游戏主线程) | Ca static uint64_t lw; static int ls = -1, lnw; int st = normal ? 1 : urg ? 2 : fail ? 2 + fail : 0; if (lw != bw || ls != st || (normal && lnw != nw)) { lw = bw; ls = st; lnw = nw; LOG("更新:选角页写上构建 %d%s(提示字宽 %d)", g_own, normal ? ",普通更新提示" : urg ? ",建议立即更新提示" : fail == 1 ? ",查更新失败提示(无线数据许可)" : fail ? ",查更新失败提示(浏览器手动更新)" : ",无提示", normal ? nw : 0); } } +#if TARGET_OS_OSX +// Mac App:鼠标点主菜单右上角那行「有新版本…」= 按 Y(打开下载页)。Mac 玩家第一反应是点它;这一行在手柄版里是纯文字、没有按钮可点,所以按位置认: +// 提示字的文字框摆在 (屏宽 − 2000 − 边距, 130)、宽 2000、字靠右(见上面 pad 那一支),认它靠右的 1400 单位、上下各放宽到 100–230(布局单位:屏高 = 2160)。 +// 条件同 Y 键那条:有普通更新提示、主菜单面板显示着、选角 / 建角 / 设置页没开。游戏主线程调(touch_mac.c 取手柄处);nx / ny = 画面归一化坐标。返回 1 = 点中并已处理 +// Mac App: a mouse click on the "New version..." line at the top right of the main menu = pressing Y (open the download page). A Mac player's first reaction is to click it; in the gamepad layout this line is plain text with no button to click, so it is recognised by position: +// the hint's text box sits at (screen width - 2000 - margin, 130), 2000 wide, right-aligned (see the pad branch above), and the right-hand 1400 units are recognised, widened vertically to 100–230 (layout units: screen height = 2160). +// Same conditions as the Y key: an ordinary update hint exists, the main menu panel is showing, and character selection / creation / settings are not open. Called on the game main thread (where touch_mac.c reads the gamepad); nx / ny = normalised picture coordinates. Returns 1 = hit and handled +int dm_update_click_at(float nx, float ny) { + if (g_own < 0) return 0; int have, dm_padmode_busy(void); pthread_mutex_lock(&g_mu); have = g_offer.build > 0 && !g_offer.urgent; pthread_mutex_unlock(&g_mu); + uint8_t *b = tb(); uint64_t pr = b ? *(uint64_t *)(b + 0x2f05458) : 0; if (!have || !pr || dm_padmode_busy()) return 0; // 不另判是不是手柄版:只有 Mac App 会初始化更新提示(g_own ≥ 0),它一直是手柄版 | no separate check for the gamepad layout: only the Mac App initialises the update hint (g_own >= 0), and it is always the gamepad layout + uint64_t mm = find(pr, "MainMenuPanel", 0), cs = find(pr, "CharacterSelectPanel", 0), cc = find(pr, "CharacterCreatePanel", 0), st = find(pr, "SettingsPanel", 0); + if (!mm || !*(uint8_t *)(mm + 0x50) || !find(mm, "TouchBuild", 0) || (cs && *(uint8_t *)(cs + 0x50)) || (cc && *(uint8_t *)(cc + 0x50)) || (st && *(uint8_t *)(st + 0x50))) return 0; + int vw = *(int32_t *)(b + 0x211da38), vh = *(int32_t *)(b + 0x211da3c), xr = vh > 0 ? (int)((long)vw * 2160 / vh) : 3840, sl = atomic_load(&g_safe_l), bx = sl + 6 > 79 ? sl + 6 : 79; + float x = nx * xr, y = ny * 2160; if (x < xr - 1400 - bx || x > xr - bx + 20 || y < 100 || y > 230) return 0; + LOG("更新:鼠标点了主菜单的新版本提示"); if (g_on_click) g_on_click(); return 1; +} +#endif // 文字框(TextBoxWidget,虚表 main+0x20ba4c8)设文本 = 游戏自己到处内联的两步(如 0x38f5bc–0x38f5cc、0x3d8480–0x3d849c): // 字符串赋值 0x136e5c(控件+0x88, 字节, 字节数),再 0xadc434(控件) 刷新省略号截断串。绘制每帧现取 +0x88 现量现画,不用另调重排。不是文字框就不动 // Setting text on a text box (TextBoxWidget, vtable main+0x20ba4c8) = the two steps the game itself inlines everywhere (e.g. 0x38f5bc-0x38f5cc, 0x3d8480–0x3d849c): diff --git a/dm/host/dm_world.c b/dm/host/dm_world.c index 4ef143c..f8a6d7e 100644 --- a/dm/host/dm_world.c +++ b/dm/host/dm_world.c @@ -52,10 +52,13 @@ static int w_interact(uint64_t u) { // 就近交互:游戏的点击入口( #if TARGET_OS_OSX #define W_GROUND 99 // g_go.type 的特殊值:目标不是单位,是地面上的一格(Mac 鼠标点空地走过去;只有 macOS 宿主有) | special value of g_go.type: the target is not a unit but a tile on the ground (Mac mouse click-to-walk; macOS host only) #define W_NEAREST_OK(t) ((t) == 2 || (t) == W_GROUND) +static int g_hit_mon; // 这一次命中把敌对怪也算进来(Mac 鼠标点怪 = 攻击;触屏不算,攻击归技能键) | this hit test also counts hostile monsters (Mac mouse click on a monster = attack; touch does not, attacking belongs to the skill buttons) +#define W_MON_OK(cat) (g_hit_mon && ((cat) == 1 || (cat) == 0xa)) // 交互类别 1 = 普通怪、0xa = 另一类可攻击的(同下面测试开关 monster 的认法) | interaction category 1 = ordinary monster, 0xa = another attackable kind (the same recognition as the monster test switch below) static int g_gnd_x, g_gnd_y; // 地面目标格 | ground target tile static uint64_t g_gnd_stick_seen, g_gnd_stick_at; // 摇杆时间戳上次读到的值、它变化的时刻(本文件的时钟;那个时间戳是别的时钟记的,只能比变没变) | the last value read of the stick timestamp and the moment it changed (this file's clock; that timestamp is recorded by another clock, so only whether it changed can be compared) #else #define W_NEAREST_OK(t) ((t) == 2) +#define W_MON_OK(cat) 0 #endif static struct { uint32_t type, id; uint64_t until_ns, stick, next_fr, still_fr; int on, lx, ly; int n, i, tx, ty, replans, stop_at, empty, direct, alt, alt_on, ax, ay, nearest; uint16_t node[24][2]; } g_go; // stop_at > 0:只走到这么多格内就停、不交互(测试开关「走到怪旁」用) | stop_at > 0: only walk to within this many cells and stop, without interacting (used by the test switch "walk next to a monster") static uint64_t w_find(uint32_t type, uint32_t id) { uint8_t *b = wb(); return type <= 5 ? ((uint64_t (*)(uint64_t, uint32_t, uint32_t, uint32_t))(b + 0x45f5f0))((uint64_t)(uintptr_t)(b + 0x2d603a0 + type * 0x400), id & 0x7f, id, type) : 0; } @@ -324,7 +327,7 @@ static uint64_t w_hit(uint8_t *b, float sx, float sy, float min, float *dist, in if (t == 4 && *(uint32_t *)(u + 0xc) != 3) continue; // 物品只认在地上的 | items only count when on the ground if (!(((int (*)(uint64_t, int, int, int, int))(b + 0x464a70))(u, 0, 0, -1, -1) & 1)) continue; if (t == 0 && u == pl) continue; - int cat = ((int (*)(int, uint64_t, uint64_t))(b + 0x2f7b7c))(0x165, pl, u); if (t == 0 ? cat != 9 : t == 1 ? cat != 5 : t == 2 ? cat != 2 : 0) continue; // 类别 9 = 死亡状态的玩家单位(0x2f7c28–0x2f7c34:main+0x4667a0 对玩家类判模式 0x11)= 尸体,点它 = 取回装备(游戏点击入口对玩家类发 0x13) | category 9 = a player unit in the dead state (0x2f7c28–0x2f7c34: main+0x4667a0 checks mode 0x11 for the player type) = corpse, tapping it = retrieve equipment (the game's click entry sends 0x13 for the player type) + int cat = ((int (*)(int, uint64_t, uint64_t))(b + 0x2f7b7c))(0x165, pl, u); if (t == 0 ? cat != 9 : t == 1 ? (cat != 5 && !W_MON_OK(cat)) : t == 2 ? cat != 2 : 0) continue; // 类别 9 = 死亡状态的玩家单位(0x2f7c28–0x2f7c34:main+0x4667a0 对玩家类判模式 0x11)= 尸体,点它 = 取回装备(游戏点击入口对玩家类发 0x13) | category 9 = a player unit in the dead state (0x2f7c28–0x2f7c34: main+0x4667a0 checks mode 0x11 for the player type) = corpse, tapping it = retrieve equipment (the game's click entry sends 0x13 for the player type) float f[2], h[2]; if (!w_project(b, scene, u, f, 0)) continue; if (t == 4 || !w_project(b, scene, u, h, 1)) { h[0] = f[0]; h[1] = f[1]; } float hh = fabsf(f[1] - h[1]), ww = hh * (t == 1 ? 0.44f : 1.0f), cx = (f[0] + h[0]) / 2, cy = (f[1] + h[1]) / 2, dhw = 0, dhv = 0, sbx = 0, sby = 0, sbw = 0, sbh = 0; @@ -366,9 +369,13 @@ unsigned dm_world_tap(float nx, float ny) { if (nx < 0) nx = 0; if (nx > 1) nx = int dm_world_tap_result(unsigned seq) { return atomic_load(&g_tap_done) == seq ? atomic_load(&g_tap_res) : -1; } // -1 还没执行;0 没有目标(什么都没发);1 物品 2 NPC 3 物件 4 出口 | -1 not executed yet; 0 no target (nothing sent); 1 item 2 NPC 3 object 4 exit int dm_world_has_target(void) { return atomic_load(&g_has_target); } // 按主键会去交互的目标存在(游戏手柄版自己的选择,main+0x2f7a0c);任意线程读 | a target that the primary button would interact with exists (the game's own controller-version selection, main+0x2f7a0c); read from any thread #if TARGET_OS_OSX +static int w_hostile(uint8_t *b, uint64_t u) { if (*(uint32_t *)u != 1) return 0; uint64_t pl = w_player(); int c = pl ? ((int (*)(int, uint64_t, uint64_t))(b + 0x2f7b7c))(0x165, pl, u) : 0; return c == 1 || c == 0xa; } +static void w_attack(uint64_t u, const char *how) { if (g_go.on) g_go.on = 0; int r = w_interact(u); static int lg; if (lg++ < 300) LOG("鼠标攻击:%s 类型 1 cls %u id %u → 点击入口 %d", how, *(uint32_t *)(u + 4), *(uint32_t *)(u + 8), r); } static void w_walk_step(uint8_t *b) { uint64_t t = atomic_exchange(&g_walk, 0); if (!t) return; uint64_t dm_stick_last_ns(void); uint64_t pl = w_player(), scene = *(uint64_t *)(b + 0x2e2a698); int W = 0, H = 0, px = 0, py = 0; float f[2]; dm_screen_real(&W, &H); if (!pl || !scene || W <= 0 || H <= 0 || !w_unit_xy(pl, &px, &py) || !w_project(b, scene, pl, f, 0)) return; + { float d0 = 0; int lab0 = 0; g_hit_mon = 1; uint64_t mu = w_hit(b, ((t >> 16) & 0xffff) / 65535.0f * W, (t & 0xffff) / 65535.0f * H, H * 0.10f, &d0, &lab0); g_hit_mon = 0; + if (mu && w_hostile(b, mu)) { if (w_now_ns() - g_gnd_stick_at >= 300000000ull) w_attack(mu, "按住"); return; } } // 按住时光标下是敌对怪:再打一下(摇杆 / W A S D 刚动过就让给它) | while held with a hostile monster under the pointer: hit once more (yielding to the stick / W A S D if they have just moved) if (g_go.on && g_go.type != W_GROUND) return; // 正走向某个目标去交互:不打断 | walking towards some target to interact: do not interrupt if (w_now_ns() - g_gnd_stick_at < 300000000ull) return; // 摇杆 / W A S D 0.3 秒内动过:让给它 | the stick / W A S D moved within 0.3 s: yield to it float sx = ((t >> 16) & 0xffff) / 65535.0f * W, sy = (t & 0xffff) / 65535.0f * H, k = H * 0.00206f, a = (sx - f[0]) / k / 16, c = (sy - f[1]) / k / 8; @@ -383,13 +390,30 @@ static void w_walk_step(uint8_t *b) { g_go.n = g_go.i = g_go.replans = g_go.empty = g_go.direct = g_go.alt = g_go.alt_on = 0; g_go.stop_at = 0; g_gnd_x = x; g_gnd_y = y; g_go.on = 1; } #endif +#if TARGET_OS_OSX +// ---- Mac 鼠标:点怪 = 攻击 ---- +// 发令走游戏自己的点击入口(同 w_interact:手柄主键与键鼠左键共用的 main+0x4ace20,带上这只怪当指定目标):近战它自己走过去打,主键上绑的是技能就对它放那个技能,不另写攻击逻辑。 +// 按住不放时 touch_mac.c 每 0.2 秒来一次「朝光标走」的请求(dm_world_walk):光标下是敌对怪就改成对它再发一次攻击(追着打),不是怪才走路。 +// ---- Mac mouse: clicking a monster = attack ---- +// The order goes through the game's own click entry (same as w_interact: main+0x4ace20, shared by the gamepad main button and the keyboard-and-mouse left button, with this monster as the designated target): for melee it walks over and hits by itself, and if a skill is bound to the main button it uses that skill on it; no separate attack logic is written. +// While held, touch_mac.c sends a "walk towards the pointer" request every 0.2 s (dm_world_walk): when a hostile monster is under the pointer it becomes another attack order on it (chasing it), and only otherwise is it walking. +static _Atomic int g_tap_mouse; +unsigned dm_world_click(float nx, float ny) { atomic_store(&g_tap_mouse, 1); return dm_world_tap(nx, ny); } // 任意线程:鼠标左键点世界(比触屏的点按多认敌对怪) | any thread: left mouse click on the world (recognises hostile monsters in addition to what a touch tap does) +#endif static void w_tap_step(uint8_t *b) { uint64_t t = atomic_exchange(&g_tap, 0); if (!t) return; unsigned seq = (unsigned)(t >> 32); int res = 0; int W = 0, H = 0; dm_screen_real(&W, &H); // 命中框按真实画面算,不能用游戏的「屏幕宽高」全局量(界面改成 16:9 后它的高是界面高,dm_uiscreen.c) | hit boxes are computed against the real picture, not the game's "screen width/height" globals (after the UI was changed to 16:9 its height is the UI height, dm_uiscreen.c) float sx = ((t >> 16) & 0xffff) / 65535.0f * W, sy = (t & 0xffff) / 65535.0f * H, d = 0; int lab = 0; +#if TARGET_OS_OSX + g_hit_mon = atomic_exchange(&g_tap_mouse, 0); +#endif uint64_t u = W > 0 && H > 0 ? w_hit(b, sx, sy, H * 0.10f, &d, &lab) : 0; +#if TARGET_OS_OSX + g_hit_mon = 0; + if (u && w_hostile(b, u)) { w_attack(u, "点"); u = 0; res = 6; } // 鼠标点到敌对怪:攻击(见 w_attack),不走「走过去交互」 | the mouse clicked a hostile monster: attack (see w_attack), not "walk over and interact" +#endif if (u) { uint32_t ty = *(uint32_t *)u; res = ty == 4 ? 1 : ty == 1 ? 2 : ty == 2 ? 3 : ty == 0 ? 5 : 4; w_go(u); } - static int logged; if (logged++ < 200) { if (u) LOG("世界目标:点 (%.0f,%.0f) → 类型 %u cls %u id %u(%s,离框中心 %.0f 像素)", sx, sy, *(uint32_t *)u, *(uint32_t *)(u + 4), *(uint32_t *)(u + 8), lab ? "名字标签" : "命中框", d); else LOG("世界目标:点 (%.0f,%.0f) → 没有目标,不发令", sx, sy); } + static int logged; if (logged++ < 200) { if (u) LOG("世界目标:点 (%.0f,%.0f) → 类型 %u cls %u id %u(%s,离框中心 %.0f 像素)", sx, sy, *(uint32_t *)u, *(uint32_t *)(u + 4), *(uint32_t *)(u + 8), lab ? "名字标签" : "命中框", d); else if (res != 6) LOG("世界目标:点 (%.0f,%.0f) → 没有目标,不发令", sx, sy); } atomic_store(&g_tap_res, res); atomic_store(&g_tap_done, seq); } // 测试量具(触点脚本 tap_unit):盯住某一类单位,主线程每帧把它身体框中心的屏幕位置(出图画面归一化)发布出来,脚本线程读了去落真实触点。 @@ -403,6 +427,9 @@ static void w_watch_step(uint8_t *b) { uint32_t w = atomic_load(&g_watch); if (!w) return; int t = (w >> 24) & 0x7f; uint32_t cls = w & 0xffffff; uint64_t scene = *(uint64_t *)(b + 0x2e2a698), v = 0; int W = 0, H = 0; dm_screen_real(&W, &H); for (int k = 0; scene && W > 0 && H > 0 && t <= 5 && k < 128 && !v; k++) for (uint64_t u = *(uint64_t *)(b + 0x2d603a0 + t * 0x400 + k * 8); u; u = *(uint64_t *)(u + 0x158)) { +#if TARGET_OS_OSX + if (cls == 0xfffffe) { if (!(((int (*)(uint64_t, int, int, int, int))(b + 0x464a70))(u, 0, 0, -1, -1) & 1) || !w_hostile(b, u)) continue; } else // 类号 0xfffffe(Mac 合成鼠标脚本的 unit 1,hostile)= 敌对且可选中的怪 | class 0xfffffe (unit 1,hostile in the Mac synthetic mouse script) = hostile and selectable monster +#endif if (cls != 0xffffff ? *(uint32_t *)(u + 4) != cls : (t == 4 && *(uint32_t *)(u + 0xc) != 3)) continue; // 类号 0xffffff(开关里写 any)= 这一类里任意一个;物品只认在地上的 | class number 0xffffff (written as any in the switch) = any one of this type; items only count when on the ground float f[2], h[2]; if (!w_project(b, scene, u, f, 0)) continue; if (!w_project(b, scene, u, h, 1)) { h[0] = f[0]; h[1] = f[1]; } diff --git a/dm/host/front_mac.m b/dm/host/front_mac.m index 845ae92..5ab983e 100644 --- a/dm/host/front_mac.m +++ b/dm/host/front_mac.m @@ -5,6 +5,7 @@ // Without DM_WINDOW: the guest runs directly on the current thread, behaving the same as with no front end (windowless tests use this). // Key map (Nintendo layout): WASD left stick, arrow keys D-pad, J=A K=B U=X I=Y, Q=L E=R, Z=ZL C=ZR, F=press left stick G=press right stick, Return=+ Tab=−. #import +#include #import #import #include "dm.h" @@ -56,6 +57,43 @@ static void app_quit(const char *why) { } static const char *ui(const char *k) { const char *dm_ui(const char *key); return dm_ui(k); } static void show_keys(void) { NSAlert *a = [NSAlert new]; a.messageText = @(ui("dmAppKeysTitle")); a.informativeText = @(ui("dmAppKeysText")); [a addButtonWithTitle:@(ui("dmAppOK"))]; [a runModal]; } +// 帮助 → 分享日志…:把本次与上一次的日志(~/Library/Logs/D2R Mobile/host.log、host.prev.log)和一份版本信息打成一个压缩包,弹系统的存储面板让玩家选位置(缺省桌面),存好后在访达里选中它。 +// 不上传、不发邮件;包里只有这三份文件——不放存档、不放 iCloud 目录里的任何东西。日志里的家目录前缀一律换成 ~(同 iOS 的分享日志 dm_sharelog.m scrub_home:不把用户名带出去)。 +// to 非空 = 测试(DM_TEST_SHARELOG):不弹面板,直接写到这个路径。返回 nil 成功,否则是失败原因 +// Help -> Share Log...: pack the logs of this run and the previous one (~/Library/Logs/D2R Mobile/host.log, host.prev.log) and a version-information file into one archive, show the system save panel for the player to choose a location (Desktop by default), and select it in Finder once saved. +// Nothing is uploaded or mailed; the archive contains only these three files - no saves, nothing from the iCloud directory. The home-directory prefix in the logs is always replaced with ~ (same as the iOS share-log dm_sharelog.m scrub_home: the user name is not carried out). +// to non-empty = test (DM_TEST_SHARELOG): no panel, write directly to this path. Returns nil on success, otherwise the reason for failure +static NSString *share_logs(NSString *to) { + NSFileManager *fm = NSFileManager.defaultManager; NSString *home = NSHomeDirectory(), *logd = [home stringByAppendingPathComponent:@"Library/Logs/D2R Mobile"]; + NSDictionary *inf = NSBundle.mainBundle.infoDictionary; NSString *build = [inf[@"CFBundleVersion"] description] ?: @"0", *ver = [inf[@"CFBundleShortVersionString"] description] ?: @"?"; + NSDateFormatter *df = [NSDateFormatter new]; df.dateFormat = @"yyyyMMdd-HHmm"; NSString *name = [NSString stringWithFormat:@"D2RMobile-logs-%@-%@", build, [df stringFromDate:NSDate.date]]; + NSString *tmp = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"dm_share_%d", getpid()]], *dir = [tmp stringByAppendingPathComponent:name]; + [fm removeItemAtPath:tmp error:nil]; if (![fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil]) return @"mkdir"; + fflush(stderr); + NSData *hb = [home dataUsingEncoding:NSUTF8StringEncoding]; NSData *tilde = [@"~" dataUsingEncoding:NSUTF8StringEncoding]; + NSData *(^scrub)(NSData *) = ^NSData *(NSData *d) { if (!d || hb.length < 2) return d; NSMutableData *o = [NSMutableData dataWithCapacity:d.length]; NSRange all = NSMakeRange(0, d.length), r; + while ((r = [d rangeOfData:hb options:0 range:all]).location != NSNotFound) { [o appendData:[d subdataWithRange:NSMakeRange(all.location, r.location - all.location)]]; [o appendData:tilde]; all = NSMakeRange(NSMaxRange(r), d.length - NSMaxRange(r)); } + [o appendData:[d subdataWithRange:all]]; return o; }; + int n = 0; for (NSString *f in @[@"host.log", @"host.prev.log"]) { NSData *d = [NSData dataWithContentsOfFile:[logd stringByAppendingPathComponent:f] options:NSDataReadingMappedIfSafe error:nil]; if (d) { [scrub(d) writeToFile:[dir stringByAppendingPathComponent:f] atomically:YES]; n++; } } + NSString *bt = [NSString stringWithContentsOfFile:[NSBundle.mainBundle.resourcePath stringByAppendingPathComponent:@"build.txt"] encoding:NSUTF8StringEncoding error:nil] ?: @""; + char hw[64] = "?"; size_t hn = sizeof hw; sysctlbyname("hw.model", hw, &hn, NULL, 0); NSProcessInfo *pi = NSProcessInfo.processInfo; + NSString *info = [NSString stringWithFormat:@"%@\nD2R Mobile (macOS) %@ (%@)\n%@\n%@\nmacOS %@\n%@ %.0f GB\n%@\n", @(ui("dmAppShareInfo")), ver, build, inf[@"CFBundleIdentifier"] ?: @"", [bt stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet], + pi.operatingSystemVersionString, @(hw), pi.physicalMemory / 1073741824.0, [NSLocale.preferredLanguages componentsJoinedByString:@","]]; + [[scrub([info dataUsingEncoding:NSUTF8StringEncoding]) copy] writeToFile:[dir stringByAppendingPathComponent:@"info.txt"] atomically:YES]; + NSString *zip = [tmp stringByAppendingPathComponent:[name stringByAppendingString:@".zip"]]; + NSTask *t = [NSTask new]; t.executableURL = [NSURL fileURLWithPath:@"/usr/bin/ditto"]; t.arguments = @[@"-c", @"-k", @"--keepParent", dir, zip]; NSError *err = nil; + if (![t launchAndReturnError:&err]) { [fm removeItemAtPath:tmp error:nil]; return err.localizedDescription ?: @"ditto"; } [t waitUntilExit]; + if (t.terminationStatus != 0 || ![fm fileExistsAtPath:zip]) { [fm removeItemAtPath:tmp error:nil]; return [NSString stringWithFormat:@"ditto %d", t.terminationStatus]; } + NSURL *dst = to ? [NSURL fileURLWithPath:to] : nil; + if (!dst) { NSSavePanel *sp = [NSSavePanel savePanel]; sp.nameFieldStringValue = zip.lastPathComponent; sp.directoryURL = [fm URLsForDirectory:NSDesktopDirectory inDomains:NSUserDomainMask].firstObject; sp.canCreateDirectories = YES; + if ([sp runModal] != NSModalResponseOK) { [fm removeItemAtPath:tmp error:nil]; LOG("分享日志:玩家取消"); return nil; } dst = sp.URL; } + [fm removeItemAtURL:dst error:nil]; BOOL ok = [fm moveItemAtPath:zip toPath:dst.path error:&err]; [fm removeItemAtPath:tmp error:nil]; + if (!ok) return err.localizedDescription ?: @"move"; + LOG("分享日志:已存(日志 %d 份 + 版本信息,%llu 字节)", n, [[fm attributesOfItemAtPath:dst.path error:nil] fileSize]); + if (!to) [NSWorkspace.sharedWorkspace activateFileViewerSelectingURLs:@[dst]]; + return nil; +} +static void share_logs_ui(void) { NSString *e = share_logs(nil); if (e) { LOG("【红】分享日志:打包失败 %s", e.UTF8String); NSAlert *a = [NSAlert new]; a.messageText = @(ui("dmAppShareFail")); a.informativeText = e; [a addButtonWithTitle:@(ui("dmAppOK"))]; [a runModal]; } } @interface DmWinCtl : NSObject @end @implementation DmWinCtl - (BOOL)windowShouldClose:(NSWindow *)w { (void)w; app_quit("关窗口"); return NO; } @@ -63,6 +101,7 @@ static void show_keys(void) { NSAlert *a = [NSAlert new]; a.messageText = @(ui(" - (void)windowDidChangeBackingProperties:(NSNotification *)n { (void)n; layout_game(); } - (void)quit:(id)s { (void)s; app_quit("菜单退出"); } - (void)keys:(id)s { (void)s; show_keys(); } +- (void)share:(id)s { (void)s; share_logs_ui(); } @end static uint64_t g_btn; static int g_w, g_a, g_s, g_d; @@ -76,6 +115,7 @@ uint64_t front_game_res(int docked) { return docked ? 900ull << 32 | 1600 : 720ull << 32 | 1280; } +static NSPoint g_test_last; // 合成鼠标脚本:上一条带坐标的指令落在视图里的点(dragto 从这里起拖) | synthetic mouse script: the point in the view where the last instruction with coordinates landed (dragto starts dragging from here) static int g_wheel; // 滚轮:+1 / −1 = 右摇杆向上 / 向下推一小会儿(原版手柄版用右摇杆滚列表) | Wheel: +1 / -1 = push the right stick up / down for a short while (the original gamepad UI scrolls lists with the right stick) static void push(void) { int32_t lx = (g_d - g_a) * 32767, ly = (g_w - g_s) * 32767; @@ -136,7 +176,7 @@ void front_run(void (*guest)(void)) { NSMenu *(^add)(const char *) = ^NSMenu *(const char *t) { NSMenuItem *it = [NSMenuItem new]; [bar addItem:it]; NSMenu *m = [[NSMenu alloc] initWithTitle:@(t)]; it.submenu = m; return m; }; [[add("") addItemWithTitle:@(ui("dmAppQuit")) action:@selector(quit:) keyEquivalent:@"q"] setTarget:ctl]; NSMenuItem *fs = [add(ui("dmAppMenuView")) addItemWithTitle:@(ui("dmAppFullscreen")) action:@selector(toggleFullScreen:) keyEquivalent:@"f"]; fs.keyEquivalentModifierMask = NSEventModifierFlagControl | NSEventModifierFlagCommand; - [[add(ui("dmAppMenuHelp")) addItemWithTitle:@(ui("dmAppKeysTitle")) action:@selector(keys:) keyEquivalent:@""] setTarget:ctl]; + { NSMenu *hm = add(ui("dmAppMenuHelp")); [[hm addItemWithTitle:@(ui("dmAppKeysTitle")) action:@selector(keys:) keyEquivalent:@""] setTarget:ctl]; [[hm addItemWithTitle:@(ui("dmAppShareLog")) action:@selector(share:) keyEquivalent:@""] setTarget:ctl]; } NSApp.mainMenu = bar; } { void dm_gamepad_start(void (*on_mode)(int pad)); dm_gamepad_start(NULL); } // 手柄(与 iOS 壳共用 ios/Sources/dm_gamepad.m):连上即用,与键盘并存 | Gamepad (ios/Sources/dm_gamepad.m, shared with the iOS shell): works as soon as it is connected, alongside the keyboard [win makeKeyAndOrderFront:nil]; @@ -202,13 +242,35 @@ void front_run(void (*guest)(void)) { if (dn) LOG("DM_TEST_NSMOUSE:%.2f 秒投 键盘 %s%s(键窗口%s)", NSProcessInfo.processInfo.systemUptime - t0, ty ? "字 " : "键码 ", ty ? one.UTF8String : [NSString stringWithFormat:@"%d", (int)x].UTF8String, kw == win ? "是游戏窗口" : kw ? "是别的窗口(弹框)" : "没有:App 里没有键窗口"); [NSApp postEvent:[NSEvent keyEventWithType:dn ? NSEventTypeKeyDown : NSEventTypeKeyUp location:NSZeroPoint modifierFlags:0 timestamp:NSProcessInfo.processInfo.systemUptime windowNumber:(kw ?: win).windowNumber context:nil characters:one charactersIgnoringModifiers:one isARepeat:NO keyCode:ty ? 0 : (unsigned short)x] atStart:NO]; }); } continue; } + if (!strcmp(op, "unit") || !strcmp(op, "unith")) { // 「秒 unit <类型>,<类号>」:盯住这类单位(类号 16777214 = 敌对且可选中的怪、16777215 = 任意),它一在画面里就在它身体框中心投一次真正的鼠标点击;unith = 按住 2.5 秒才抬起 | " unit ,": watch for units of this kind (class 16777214 = hostile and selectable monster, 16777215 = any) and post one real mouse click at the centre of its body box as soon as it is on screen; unith = hold for 2.5 seconds before releasing + double hold = !strcmp(op, "unith") ? 2.5 : 0.1; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(sec * NSEC_PER_SEC)), tq, ^{ void dm_world_watch(int, uint32_t); int dm_world_watch_pos(float *, float *); float nx = 0, ny = 0; int ok = 0; + dm_world_watch((int)x, (uint32_t)y); for (int i = 0; i < 60 && !(ok = dm_world_watch_pos(&nx, &ny)); i++) usleep(50000); dm_world_watch(-1, 0); + if (!ok) { LOG("DM_TEST_NSMOUSE:unit %d,%u 3 秒内没进画面,不点", (int)x, (unsigned)y); return; } + __block NSPoint pt; dispatch_sync(dispatch_get_main_queue(), ^{ pt = [v convertPoint:NSMakePoint(nx * v.bounds.size.width, (1 - ny) * v.bounds.size.height) toView:nil]; }); + LOG("DM_TEST_NSMOUSE:%.2f 秒 unit %d,%u 在画面 (%.3f,%.3f) → 投按下,%.1f 秒后抬起", NSProcessInfo.processInfo.systemUptime - t0, (int)x, (unsigned)y, nx, ny, hold); + for (int dn = 1; dn >= 0; dn--) { if (!dn) usleep((useconds_t)(hold * 1e6)); + [NSApp postEvent:[NSEvent mouseEventWithType:dn ? NSEventTypeLeftMouseDown : NSEventTypeLeftMouseUp location:pt modifierFlags:0 timestamp:NSProcessInfo.processInfo.systemUptime windowNumber:win.windowNumber context:nil eventNumber:0 clickCount:1 pressure:dn ? 1 : 0] atStart:NO]; } }); + continue; } + if (!strcmp(op, "dbl") || !strcmp(op, "dragto")) { // 「秒 dbl x,y」:同一点连点两下(间隔 0.15 秒,时刻自己掐,不靠两条定时——定时有零点几秒的误差,凑不出双击); | " dbl x,y": click the same point twice (0.15 s apart, timed by itself rather than by two scheduled lines - scheduling is off by a few tenths of a second and cannot produce a double click); + // 「秒 dragto x,y」:从上一条 down 的位置拖到这里(0.6 秒里匀速 12 步)再抬起,前面要先有一条 down + // " dragto x,y": drag from the position of the previous down to here (12 even steps within 0.6 s) and release; a down must come before it + int dbl = !strcmp(op, "dbl"); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(sec * NSEC_PER_SEC)), tq, ^{ __block NSPoint from, to; dispatch_sync(dispatch_get_main_queue(), ^{ from = g_test_last; to = NSMakePoint(x, v.bounds.size.height - y); if (dbl) from = to; g_test_last = to; }); + NSEvent *(^mk)(NSEventType, NSPoint, int) = ^(NSEventType t, NSPoint p, int cc) { __block NSPoint wp; dispatch_sync(dispatch_get_main_queue(), ^{ wp = [v convertPoint:p toView:nil]; }); + return [NSEvent mouseEventWithType:t location:wp modifierFlags:0 timestamp:NSProcessInfo.processInfo.systemUptime windowNumber:win.windowNumber context:nil eventNumber:0 clickCount:cc pressure:t == NSEventTypeLeftMouseUp ? 0 : 1]; }; + LOG("DM_TEST_NSMOUSE:%.2f 秒 %s 内容区 (%.0f,%.0f)", NSProcessInfo.processInfo.systemUptime - t0, dbl ? "双击" : "拖到", x, y); + if (dbl) { for (int i = 0; i < 2; i++) { [NSApp postEvent:mk(NSEventTypeLeftMouseDown, to, i + 1) atStart:NO]; usleep(60000); [NSApp postEvent:mk(NSEventTypeLeftMouseUp, to, i + 1) atStart:NO]; usleep(150000); } } + else { for (int i = 1; i <= 12; i++) { [NSApp postEvent:mk(NSEventTypeLeftMouseDragged, NSMakePoint(from.x + (to.x - from.x) * i / 12, from.y + (to.y - from.y) * i / 12), 1) atStart:NO]; usleep(50000); } usleep(200000); [NSApp postEvent:mk(NSEventTypeLeftMouseUp, to, 1) atStart:NO]; } }); + continue; } NSEventType ty = !strcmp(op, "down") ? NSEventTypeLeftMouseDown : !strcmp(op, "up") ? NSEventTypeLeftMouseUp : NSEventTypeLeftMouseDragged; int has = !strcmp(op, "up") ? 0 : 1; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(sec * NSEC_PER_SEC)), tq, ^{ static NSPoint last; - if (has) last = NSMakePoint(x, v.bounds.size.height - y); // 内容区的点 → 窗口坐标(原点左下) | point in the content area -> window coordinates (origin at bottom-left) + if (has) { last = NSMakePoint(x, v.bounds.size.height - y); g_test_last = last; } // 内容区的点 → 窗口坐标(原点左下) | point in the content area -> window coordinates (origin at bottom-left) NSEvent *ev = [NSEvent mouseEventWithType:ty location:[v convertPoint:last toView:nil] modifierFlags:0 timestamp:NSProcessInfo.processInfo.systemUptime windowNumber:win.windowNumber context:nil eventNumber:0 clickCount:1 pressure:ty == NSEventTypeLeftMouseUp ? 0 : 1]; LOG("DM_TEST_NSMOUSE:%.2f 秒投 %s 内容区 (%.0f,%.0f)(窗口%s是主窗口,App %s在前台,背板缩放 %.1f)", NSProcessInfo.processInfo.systemUptime - t0, ty == NSEventTypeLeftMouseDown ? "按下" : ty == NSEventTypeLeftMouseUp ? "抬起" : "拖动", last.x, v.bounds.size.height - last.y, win.isKeyWindow ? "" : "不", NSApp.isActive ? "" : "不", win.backingScaleFactor); [NSApp postEvent:ev atStart:NO]; }); } LOG("DM_TEST_NSMOUSE:%d 条排好", n); } + if ((e = getenv("DM_TEST_SHARELOG"))) { NSString *to = @(e); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ NSString *er = share_logs(to); LOG("DM_TEST_SHARELOG:第 8 秒打包到 %s → %s", to.lastPathComponent.UTF8String, er ? er.UTF8String : "OK"); }); } // 测试:不弹存储面板,第 8 秒直接把压缩包写到这个路径 | test: no save panel, write the archive directly to this path at second 8 if ((e = getenv("DM_TEST_QUIT_AT"))) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(atof(e) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ app_quit("DM_TEST_QUIT_AT"); }); } // 生命周期(hle.h / dm.h):失焦 → 2、拿回焦点 → 1;最小化 → 3 + 音频暂停 + GPU 挂起,还原 → 恢复(随后拿回焦点 → 1) // Lifecycle (hle.h / dm.h): focus lost → 2, focus regained → 1; minimized → 3 + audio paused + GPU suspended, restored → resume (followed by focus regained → 1) diff --git a/dm/host/tests/t_rift_next.c b/dm/host/tests/t_rift_next.c index 608c529..15d21e1 100644 --- a/dm/host/tests/t_rift_next.c +++ b/dm/host/tests/t_rift_next.c @@ -40,6 +40,17 @@ int main(void) { for (int i = 0; i < hn; i++) { long long got = hp_base_limit(hc[i].base, hc[i].full), tot = hc[i].base > 0 ? got * hc[i].full / hc[i].base : got; if (got != hc[i].want || (hc[i].full > hc[i].base && hc[i].base > 0 && tot > 2147483392LL)) { fails++; printf(" ✗ 基础 %d 合计 %d:可写上限应为 %lld,得 %lld(写满后合计 %lld)\n", hc[i].base, hc[i].full, hc[i].want, got, tot); } } printf("hp_base_limit %s:%d 格,带百分比加成时写满基础项合计不过属性上限\n", fails ? "失败" : "OK", hn); + // 双守护者的生命系数 s、伤害系数 d(hi_duo_x1000,×1000):75 层 510 / 750,100 层 775 / 1000,中间线性;低于 75 层(被测试开关强制)取 75 层的值。 + // 手算:87 层 s = 510 + 265 × 12 ÷ 25 = 637,d = 750 + 250 × 12 ÷ 25 = 870。 + // 并核「任何单体不过属性上限」:100 层最大的规则值是巴尔 10819454 点,× 0.775 = 8385076 ≤ 8388607 + // Life factor s and damage factor d of dual Guardians (hi_duo_x1000, x1000): 510 / 750 at level 75, 775 / 1000 at level 100, linear in between; below level 75 (forced by a test switch) the level-75 values. + // By hand: level 87 s = 510 + 265 x 12 / 25 = 637, d = 750 + 250 x 12 / 25 = 870. + // Also checks "no single unit exceeds the stat limit": the largest rule value at level 100 is Baal's 10819454 points, x 0.775 = 8385076 <= 8388607 + static const struct { int tier, s, d; } dc[] = { { 30, 510, 750 }, { 75, 510, 750 }, { 87, 637, 870 }, { 100, 775, 1000 } }; + for (unsigned i = 0; i < sizeof dc / sizeof *dc; i++) { K.tier = dc[i].tier; if (hi_duo_x1000(0) != dc[i].s || hi_duo_x1000(1) != dc[i].d) { fails++; printf(" ✗ 第 %d 层 s / d 应为 %d / %d,得 %d / %d\n", dc[i].tier, dc[i].s, dc[i].d, hi_duo_x1000(0), hi_duo_x1000(1)); } } + K.tier = 100; if (10819454LL * hi_duo_x1000(0) / 1000 > 8388607LL) { fails++; printf(" ✗ 100 层巴尔 × s 过了属性上限\n"); } + K.guards[0] = 7; K.guards[1] = 9; K.guards[2] = 0; if (!is_guard(7) || !is_guard(9) || is_guard(0) || is_guard(8)) { fails++; printf(" ✗ is_guard 认错\n"); } + printf("hi_duo %s:4 格系数 + 巴尔不过上限 + 认守护者\n", fails ? "失败" : "OK"); printf("t_rift_next %s:%d 格(层 × 晋级量)下一层 = 手写期望且 ≤ 100,宿主与顶部条同值\n", fails ? "失败" : "OK", n); return fails != 0; } diff --git a/dm/host/tests/t_rift_oldrun.c b/dm/host/tests/t_rift_oldrun.c index ad4dd71..3f0c502 100644 --- a/dm/host/tests/t_rift_oldrun.c +++ b/dm/host/tests/t_rift_oldrun.c @@ -27,6 +27,12 @@ int main(void) { if (town_menu(c[i].st) != c[i].want || m.menu != c[i].want) { fails++; printf(" ✗ %s:应给页 %d,town_menu %d、peek %d\n", c[i].what, c[i].want, town_menu(c[i].st), m.menu); } } atomic_store(&M.req_start, 7); atomic_store(&M.req_cont, 1); atomic_store(&M.req_abandon, 1); atomic_store(&M.menu, MENU_CHOICE); menu_reset(); if (atomic_load(&M.req_start) || atomic_load(&M.req_cont) || atomic_load(&M.req_abandon) || atomic_load(&M.menu) != MENU_NONE) { fails++; printf(" ✗ 新局重置后仍有残留:开始 %d 继续 %d 放弃 %d 页 %d\n", atomic_load(&M.req_start), atomic_load(&M.req_cont), atomic_load(&M.req_abandon), atomic_load(&M.menu)); } + // 「进行中且已超时」(rift_overtime):= 状态是进行中 ∧ 开局至今 ≥ 900 秒;顶部条与菜单拿到的是同一个量。开局时刻摆在 N 秒前(客体时钟) + // "In progress and overtime" (rift_overtime): = state is in progress AND at least 900 seconds since the start; the top bar and the menu receive the same quantity. The start moment is placed N seconds in the past (guest clock) + static const struct { int st; int ago; int want; } oc[] = { { ST_RUN, 100, 0 }, { ST_RUN, 899, 0 }, { ST_RUN, 901, 1 }, { ST_RUN, 5000, 1 }, { ST_DONE, 901, 0 }, { ST_IDLE, 901, 0 } }; + for (unsigned i = 0; i < sizeof oc / sizeof *oc; i++) { atomic_store(&K.st, oc[i].st); K.t0_ns = guest_ns() - (uint64_t)oc[i].ago * 1000000000ull; dm_rift_hud_t h = {0}; dm_rift_menu_t m = {0}; dm_rift_hud(&h); menu_fill(&m, 2); + if (rift_overtime() != oc[i].want || m.overtime != oc[i].want || (oc[i].st != ST_IDLE && h.overtime != oc[i].want)) { fails++; printf(" ✗ 状态 %d 开局 %d 秒前:超时量应为 %d,得 %d(顶部条 %d、菜单 %d)\n", oc[i].st, oc[i].ago, oc[i].want, rift_overtime(), h.overtime, m.overtime); } } + printf("rift_overtime %s:6 格\n", fails ? "失败" : "OK"); printf("t_rift_oldrun %s:%d 格城里入口给页 + 新局重置清请求\n", fails ? "失败" : "OK", n); return fails != 0; } diff --git a/dm/host/tests/t_touch_mac.c b/dm/host/tests/t_touch_mac.c index d9fa316..6aeb7b3 100644 --- a/dm/host/tests/t_touch_mac.c +++ b/dm/host/tests/t_touch_mac.c @@ -10,7 +10,7 @@ uint64_t guest_ns(void) { return 0; } uint64_t dm_guest_frame(void) { return 0; } // 界面鼠标 / 前端路径按出图帧节拍走;本单测不测它们 | the UI mouse / front-end paths run on the presented-frame cadence; this unit test does not test them int dm_world_has_target(void) { return 1; } // 点世界(dm_world.c)的桩:有目标 = 主按钮照常发键 | stub for world tapping (dm_world.c): has a target = the primary button sends its key as usual unsigned dm_world_tap(float nx, float ny) { (void)nx; (void)ny; return 0; } -void dm_world_walk(float nx, float ny) { (void)nx; (void)ny; } int dm_world_tap_result(unsigned q) { (void)q; return -1; } +void dm_world_walk(float nx, float ny) { (void)nx; (void)ny; } unsigned dm_world_click(float nx, float ny) { (void)nx; (void)ny; return 0; } int dm_update_click_at(float nx, float ny) { (void)nx; (void)ny; return 0; } int dm_world_tap_result(unsigned q) { (void)q; return -1; } uint64_t dm_padmode_legend_click(float nx, float ny) { (void)nx; (void)ny; return 0; } int dm_padmode_hud_click(float nx, float ny, uint64_t *b) { (void)nx; (void)ny; (void)b; return 0; } int dm_padmode_legend_has(uint32_t g) { (void)g; return 0; } int dm_game_paused(void) { return 0; } int dm_shop_open(void) { return 0; } // 商人页(dm_actions.c)的桩:没开 | stub for the vendor page (dm_actions.c): not open int dm_padmode_current(void) { return 0; } // 手柄 / 触屏模式(dm_padmode.c)的桩:触屏 | Stub for controller / touch mode (dm_padmode.c): touch diff --git a/dm/host/tests/t_touch_tick_stub.c b/dm/host/tests/t_touch_tick_stub.c index f4bfa84..d8d1f4d 100644 --- a/dm/host/tests/t_touch_tick_stub.c +++ b/dm/host/tests/t_touch_tick_stub.c @@ -7,7 +7,7 @@ int dm_loadscreen_down(void) { return 1; } // 读取画面判定在 diag.c; void dm_world_pump(void) {} int dm_world_has_target(void) { return 1; } unsigned dm_world_tap(float nx, float ny) { (void)nx; (void)ny; return 0; } -void dm_world_walk(float nx, float ny) { (void)nx; (void)ny; } int dm_world_tap_result(unsigned q) { (void)q; return -1; } +void dm_world_walk(float nx, float ny) { (void)nx; (void)ny; } unsigned dm_world_click(float nx, float ny) { (void)nx; (void)ny; return 0; } int dm_update_click_at(float nx, float ny) { (void)nx; (void)ny; return 0; } int dm_world_tap_result(unsigned q) { (void)q; return -1; } void dm_textinput_pump(void) {} // 文本框接法(dm_textinput.c):同上,给空桩 | text box hookup (dm_textinput.c): same as above, an empty stub void dm_update_pump(void) {} // 选角页构建号与新版本提示(dm_update.c):同上,给空桩 | build number and new-version notice on the character select page (dm_update.c): same as above, an empty stub void dm_num_set(int n) { (void)n; } diff --git a/dm/host/touch_mac.c b/dm/host/touch_mac.c index 20f82ca..df8bffe 100644 --- a/dm/host/touch_mac.c +++ b/dm/host/touch_mac.c @@ -17,6 +17,7 @@ int dm_loadscreen_down(void); // Tick number: script playback goes by server ticks (deterministic); a real mouse (App form) converts wall clock into 30 ticks per second - the game stops ticking while the pause menu / settings page / Greater Rift panel is open, // and with server ticks the mouse events would sit in the queue unprocessed, so nothing on those pages could be clicked static int g_live_on; +int dm_touch_host_is_live(void) { return g_live_on; } // 真鼠标模式(Mac App):dm_cursor.c 据此在手柄版界面下也跑触屏的物品手势泵 | real-mouse mode (Mac App): based on this dm_cursor.c runs the touch layout's item gesture pumps under the gamepad interface as well static uint32_t touch_cur_tick(void) { return g_live_on ? (uint32_t)(now_ns() / 33333333ull) : dm_cur_tick(); } typedef struct { uint64_t beat; int op, slot; float x, y; } touch_event; @@ -196,6 +197,9 @@ void dm_touch_host_step(uint64_t now, uint64_t *buttons, int32_t *lx, int32_t *l else if (dm_ui_minimap_rect(mr)) { float band = (mr[3] - mr[1]) / 4; if (band < 0.042f) band = 0.042f; if (band > (mr[3] - mr[1]) * 0.4f) band = (mr[3] - mr[1]) * 0.4f; if (px >= mr[0] && px <= mr[2] && py >= mr[1] && py <= mr[1] + band) { dm_ui_map_full(1); eat = 1; hold = 0; fprintf(stderr, "[dm] 鼠标:点在小地图顶上那一条 → 切到全屏地图\n"); } } } if (eat) { if (op == 2) { eat = 0; if (hold) { hold = 0; g_live_btn_until = touch_cur_tick() + 3; } } atomic_store(&g_live.head, h + 1); continue; } } + if (!in) { static int upd_eat; int dm_update_click_at(float, float); // 主菜单右上角的「有新版本…」那行:点它 = 打开下载页(dm_update.c),这一下从按下到抬起都不再交给界面 | the "New version..." line at the top right of the main menu: clicking it = open the download page (dm_update.c); this click is no longer passed to the interface from press to release + if (op == 0 && dm_update_click_at(px, py)) upd_eat = 1; + if (upd_eat) { if (op == 2) upd_eat = 0; atomic_store(&g_live.head, h + 1); continue; } } if (!in) { // 前端页:抬起时先问一次命中——落在页签上就走「点页签 = 按对应的手柄键」(页签不认鼠标点击;局内由手势层做同一件事),其余照旧发鼠标点击 | front-end pages: on release, hit-test once first - landing on a tab goes through "clicking a tab = pressing the corresponding gamepad key" (tabs do not take mouse clicks; in game the gesture layer does the same), everything else sends a mouse click as before if (op == 2 && dm_ui_item_at_now(px, py) == 2) { dm_ui_touch(3, px, py); dm_ui_tab_go(); } else dm_ui_touch(op, px, py); atomic_store(&g_live.head, h + 1); continue; } @@ -262,7 +266,13 @@ apply_input: touch_event *e = &g_touch.event[g_touch.next++]; if (e->slot < 0 || e->slot >= DM_TC_MAX_TOUCH) continue; if (e->op == TOUCH_DOWN) { dm_tc_begin(&g_touch.state, e->slot, e->x, e->y); if (g_touch.state.navigation_mode && e->slot == g_touch.state.pointer_slot) dm_tc_pointer_item(&g_touch.state, dm_ui_item_at_now(e->x / 2868, e->y / 1320)); } - else if (e->op == TOUCH_MOVE) { dm_tc_move(&g_touch.state, e->slot, e->x, e->y); + else if (e->op == TOUCH_MOVE) { + // 真鼠标拖物品:触屏层把物品图抬在「手指」上方 DM_TC_POINTER_LIFT_PT(手指会挡住图),落点也按抬起后的图算;鼠标不挡东西,物品图应当就在光标上。 + // 所以拖动已经起了之后,把光标位置下移同样的量当「手指位置」喂给触屏层:抬起后的图正好落在光标上,松手落点 = 光标。起拖前不移(不然一下单击会被这段位移当成拖) + // Dragging an item with the real mouse: the touch layer lifts the item image DM_TC_POINTER_LIFT_PT above the "finger" (a finger would cover the image) and computes the drop point from the lifted image; a mouse covers nothing, so the item image should sit right on the pointer. + // So once a drag has started, the pointer position shifted down by the same amount is fed to the touch layer as the "finger position": the lifted image lands exactly on the pointer, and the drop point = the pointer. No shift before the drag starts (otherwise a plain click would be taken as a drag because of this displacement) + if (g_live_on && g_touch.state.navigation_mode && e->slot == g_touch.state.pointer_slot && g_touch.state.finger[e->slot].pointer_dragged) e->y += DM_TC_POINTER_LIFT_PT; + dm_tc_move(&g_touch.state, e->slot, e->x, e->y); // 界面连续手势(同 iOS 前端 front_ios.m):手势层定型后把起手点与当前点交给宿主;起拖时报一次物品图的抬起量(同上面拖放落点的 DM_TC_POINTER_LIFT_PT / 1320) // Continuous UI gestures (same as the iOS front end front_ios.m): once the gesture layer has settled the gesture, hand the start point and current point to the host; when a drag starts report the lift amount of the item image once (same as DM_TC_POINTER_LIFT_PT / 1320 of the drag-and-drop landing point above) dm_tc_finger *f = &g_touch.state.finger[e->slot]; @@ -289,7 +299,7 @@ apply_input: // 真鼠标:手势层认为没有面板开着(它按名单认面板,大秘境选层页这类借壳的面板不在名单里),这一下却落在某个面板里 → 发界面点击,不当点世界 // Real mouse: the gesture layer believes no panel is open (it recognises panels by a list, and panels that borrow another shell, such as the Greater Rift level-selection page, are not on it), yet this click lands inside some panel -> send a UI click instead of a world click if (g_live_on && dm_ui_item_at_now(wx, wy) == 0) { dm_ui_touch(0, wx, wy); dm_ui_touch(2, wx, wy); } - else { unsigned q = dm_world_tap(wx, wy); if (g_live_on) { g_lm.tap_seq = q; g_lm.tap_x = wx; g_lm.tap_y = wy; } } } // 真鼠标:记下这一笔,答案是「没有目标」就改成走到那一点 | real mouse: remember this click, and if the answer is "no target" turn it into walking to that point + else if (g_live_on) { unsigned dm_world_click(float, float); g_lm.tap_seq = dm_world_click(wx, wy); g_lm.tap_x = wx; g_lm.tap_y = wy; } else dm_world_tap(wx, wy); } // 真鼠标:记下这一笔,答案是「没有目标」就改成走到那一点 | real mouse: remember this click, and if the answer is "no target" turn it into walking to that point if (g_touch.state.mouse_click_seq != mc) { float nx = g_touch.state.mouse_click_x / 2868, ny = g_touch.state.mouse_click_y / 1320; dm_ui_touch(0, nx, ny); dm_ui_touch(2, nx, ny); } } } diff --git a/dm/i18n/literal_whitelist.tsv b/dm/i18n/literal_whitelist.tsv index b9d1194..3033677 100644 --- a/dm/i18n/literal_whitelist.tsv +++ b/dm/i18n/literal_whitelist.tsv @@ -106,6 +106,8 @@ host/dm_rift.c @merc_dump 佣兵装备位的测试读数(DM_TEST_MERC_DUMP) host/dm_rift.c 部位 %u 模式 %u id %u 佣兵装备位的测试读数,只进日志 host/dm_rift.c [%.3s 部位 %u] 同上 host/dm_rift.c [类型 %u 类号 %u id %u 等级 %d 生命上限 %d(基础 %d)当前 %d] 随从生命的测试读数(DM_RIFT_TEST_PETDUMP),只进日志 +host/dm_rift.c (第一位) 刷守护者的日志行里标第几位,只进日志 +host/dm_rift.c (第二位) 同上 host/dm_kills.c @DM_WIDGET_OK 控件类型核对的日志标签(dm_widget.h),不上屏 host/dm_custom.c @DM_WIDGET_OK 同上 host/dm_rift_ui.c @DM_WIDGET_OK 同上 diff --git a/dm/i18n/ui_text.tsv b/dm/i18n/ui_text.tsv index 32f6d91..39a5611 100644 --- a/dm/i18n/ui_text.tsv +++ b/dm/i18n/ui_text.tsv @@ -204,6 +204,7 @@ dmRiftSayErr 秘境出错了,这次没开 The Rift could not be opened 秘境 dmRiftSayStart 第 %d 层开始,限时 15 分钟 Level %d: 15 minute time limit 秘境系统提示(dm_rift.c);英文:Greater Rift level / time limit 取自暗黑 3 官方 2.1.0 补丁说明(news.blizzard.com/en-us/article/14569138)「complete the current Greater Rift level within the designated time limit」 dmRiftSayGift 赠彩虹刻面一颗,已掉在脚下 A Rainbow Facet has dropped 秘境系统提示(dm_rift.c);「彩虹刻面」是旧译名(原版现行「彩虹魔石」);英文物品名 = 原版键 Rainbow Facet 的 enUS;英文:物品名 = 暗黑 2 原版 item-names[Rainbow Facet] dmRiftSayTimeout 时间到:本层未过关,守护者仍会掉落 Time's up: level not cleared 秘境系统提示(dm_rift.c);超时打倒守护者不算过关;英文:not cleared,不用 Failed(没死也没失败,只是不计) +dmRiftSayGuardians 进度已满:两位守护者现身! Two Rift Guardians appear! 秘境系统提示(dm_rift.c):75 层起守护者是两位;英文:同 dmRiftSayGuardian 的用词 dmRiftSayGuardian 进度已满:守护者现身! The Rift Guardian appears! 秘境系统提示(dm_rift.c);英文:Rift Guardian 取自暗黑 3 官方 2.1.0 补丁说明(news.blizzard.com/en-us/article/14569138);出现时的界面原句没查到,拟 dmElyToaGround 背包已满,赦免之证掉在脚边 Inventory full: Token of Absolution dropped 极乐世界新角色补齐(dm_elysium.c):背包放不下时的系统提示;英文物品名 = 暗黑 2 原版 Token of Absolution dmMercSlotLocked 通关地狱后打通秘境10层解锁 Clear Greater Rift Level 10 to unlock 佣兵新装备位没解锁时的系统提示(dm_rift.c;中文是 原句);英文:Greater Rift 取暗黑 3 原文 @@ -257,6 +258,7 @@ dmRiftHudLate 第 %d 层超时 Level %d overtime 秘境顶部进度条(dm_rift dmRiftHudGuard 守护者现身 Rift Guardian 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:见 dmRiftSayGuardian dmRiftHudNext 下次第 %d 层 Next: Level %d 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟 dmRiftHudTop 已通关最高层 Highest level cleared 秘境顶部进度条(dm_rift_hud.m,UIKit):第 100 层限时内通关,没有下一层了(公开仓库);英文:拟 +dmRiftHudOver 已超时:打完仍有掉落,不计通关 Overtime: drops, no clear 秘境顶部进度条(dm_rift_hud.m,UIKit)第二行:限时已到、守护者还没倒(公开仓库);英文:拟 dmRiftHudSame 下次仍是这一层 Next: same level 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟 dmRiftHudKill 击败守护者 Slay the Rift Guardian 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟;任务目标原句没查到 dmRiftHudGoal 消灭秘境中的怪物 %d%% Slay the monsters %d%% 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟;任务目标原句没查到 @@ -296,6 +298,7 @@ dmRiftGamT 安亚赌博 Gamble at Anya 大秘境面板(touch_layout.py _rift_p dmRiftBtnStart 开始 Enter Rift 大秘境面板(touch_layout.py _rift_panel);英文:拟;方尖碑面板按钮原文没查到;暗黑 3 方尖碑面板的进入按钮原文为 ACCEPT;我们的面板没有它那句前置说明,单一个 Accept 不知接受什么,未采用,留 Enter Rift(看过认可) dmRiftBtnAbandon 放弃 Quit 大秘境面板(touch_layout.py _rift_panel);英文用 Quit(「放弃用 quit 不是 abandon」) dmRiftBtnResel 重新选层 Select Level 大秘境面板(touch_layout.py _rift_panel)已完成页上组按钮;英文与选层页标题同词 +dmRiftCapContOver 有掉落,不计通关 Loot only, no clear 大秘境面板进行中页「继续」钮上方的说明,已超时时用(公开仓库);英文:拟 dmRiftCapCont 回到离开时的位置 Resume your run 大秘境面板(touch_layout.py _rift_panel);英文:拟 dmRiftBtnCont 继续 Continue 大秘境面板(touch_layout.py _rift_panel) dmRiftMsT 首通奖励 First Clear 大秘境面板(touch_layout.py _rift_panel) @@ -327,3 +330,6 @@ dmAppFullscreen 全屏 Toggle Full Screen 显示菜单的全屏项 dmAppMenuHelp 帮助 Help 帮助菜单 dmAppKeysTitle 键盘与手柄按键对照 Keyboard and Controller Buttons 帮助菜单的键位对照项,也是那一页的标题 dmAppKeysText 用键盘时,界面上的按键提示显示的就是键盘上的键;接上手柄按一下,提示换成手柄字母。\n\n确认:J(空格也可以)  返回:K(Esc 也可以)\n回车也可以确认;页面底部有「=」提示时回车当 =(如起名后的「接受」)\n=:菜单 / 新角色  Tab:地图\n移动:W A S D  十字键:方向键\nU I Q E Z C:手柄的 X Y L R ZL ZR\nF:按左摇杆  G:按右摇杆\n\n鼠标:左键点空地走过去,按住不放一直朝光标走;点目标、界面、底部的按键提示和技能 / 药水格;右键 = 返回;滚轮滚列表。\n接上手柄可以直接用。这一页以后在「帮助」菜单里。 With a keyboard, on-screen button hints show keyboard keys; press anything on a connected controller and they switch to controller letters.\n\nConfirm: J (Space also works) Back: K (Esc also works)\nReturn also confirms; acts as = when the page shows an = hint (e.g. Accept after naming)\n=: menu / new character Tab: map\nMove: W A S D D-pad: arrow keys\nU I Q E Z C: controller X Y L R ZL ZR\nF: press left stick G: press right stick\n\nMouse: left click the ground to walk there, hold to keep walking toward the cursor; click targets, the interface, the button hints at the bottom and skill / potion slots; right click = back; wheel scrolls lists.\nA connected controller works right away. This page stays in the Help menu. 键位对照正文(首次启动弹一次) +dmAppShareLog 分享日志… Share Logs… 帮助菜单:把两份日志与版本信息打成压缩包,玩家选位置存下(不上传) +dmAppShareInfo 版本信息 Version Info 分享日志压缩包里版本信息那份文件的标题行 +dmAppShareFail 日志打包失败 Could Not Pack the Logs 分享日志失败时提示框的标题 diff --git a/dm/ios/Sources/dm_rift_hud.m b/dm/ios/Sources/dm_rift_hud.m index e67cd20..5fb740d 100644 --- a/dm/ios/Sources/dm_rift_hud.m +++ b/dm/ios/Sources/dm_rift_hud.m @@ -75,7 +75,7 @@ void dm_rift_hud_draw(UIView *host, CGRect wr, BOOL hide) { NSString *st = h.done ? (h.inc ? [NSString stringWithFormat:@(dm_ui("dmRiftHudDone")), h.tier] : [NSString stringWithFormat:@(dm_ui("dmRiftHudLate")), h.tier]) : g ? @(dm_ui("dmRiftHudGuard")) : [NSString stringWithFormat:@(dm_ui("dmRiftTierN")), h.tier]; set_text(sub, st, d2font(14 * u), white, CGRectMake(48 * u, 9 * u, 130 * u, 19 * u), kCAAlignmentLeft); set_text(timer, [NSString stringWithFormat:@"%d:%02d", s / 60, s % 60], d2font(17 * u), (s <= 60 && !h.done) ? red : gold, CGRectMake(W - 90 * u, 6 * u, 80 * u, 22 * u), kCAAlignmentRight); - NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : g ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; + NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : h.overtime ? @(dm_ui("dmRiftHudOver")) : g ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; // 已超时:第二行换成这一句,优先于「击败守护者」/ 进度目标(第一行照旧写第几层 / 守护者现身) | overtime: the second line becomes this sentence, taking priority over "Slay the Rift Guardian" / the progress goal (the first line still says which level / that the Guardian has appeared) set_text(goal, gl, d2font(12 * u), grey, CGRectMake(10 * u, 32 * u, W - 20 * u, 17 * u), kCAAlignmentLeft); CGRect tr = CGRectMake(11 * u, 55 * u, W - 22 * u, 10 * u); // 含 1 单位外框(条 8 + 外框各 1) // 进度条:外框暗边 + 深底,填充金褐(守护者转暗红),每 10% 一道刻痕,两端菱形钉 | Includes the 1-unit outer frame (bar 8 + frame 1 on each side) // Progress bar: dark-edged outer frame + deep background, golden-brown fill (turns dark red for the guardian), a notch every 10%, diamond studs at both ends track.frame = tr; track.backgroundColor = rgb(25, 20, 14, 1).CGColor; track.borderColor = rgb(95, 78, 48, 1).CGColor; track.borderWidth = MAX(1, u); diff --git a/dm/ios/Sources/front_ios.m b/dm/ios/Sources/front_ios.m index ac06dcb..cb3aaae 100644 --- a/dm/ios/Sources/front_ios.m +++ b/dm/ios/Sources/front_ios.m @@ -609,6 +609,7 @@ static BOOL touch_done(UITouch *t) { UITouchPhase ph=t.phase; return ph==UITouch if(_controls.navigation_mode && _controls.pointer_slot==i && _itemAsked) { _itemAsked=NO; dm_tc_pointer_item(&_controls,dm_ui_item_result(_itemSeq)); [self bindTapSync]; } // 松手时还没告诉过:现在取(没答上 = 按别处处理) | Not yet told at release: fetch now (no answer = handle as elsewhere) unsigned wt=_controls.world_tap_seq; unsigned mc=_controls.mouse_click_seq; unsigned tt=_controls.tab_tap_seq; unsigned us=_controls.use_seq; unsigned ids=_controls.ident_seq; unsigned sts=_controls.stack_take_seq; unsigned lps=_controls.long_press_seq; unsigned its=_controls.item_tap_seq; + BOOL dragged=_uiDragOn && _controls.pointer_slot==i; if(_uiDragOn && _controls.pointer_slot==i) { _uiDragOn=NO; dm_ui_drag_end(); } BOOL wasPtr=_controls.pointer_slot==i; unsigned tm=_controls.tap_move_seq; // 按下 / 移动 / 抬起都取事件这一刻的时间(同 tick 的时钟):面板开着时显示节拍降到 2 次 / 秒,原先取「上一拍的时刻」,0.12 秒的点按会被量成 0.5 秒、不算点按(点页签不切) @@ -627,7 +628,12 @@ static BOOL touch_done(UITouch *t) { UITouchPhase ph=t.phase; return ph==UITouch if(_controls.ident_seq!=ids) dm_ui_identify_hovered(); // 物品区双击未鉴定物品 = 免费鉴定(宿主走游戏自己的鉴定函数) | Double tap on an unidentified item in the item area = free identify (the host calls the game's own identify function) if(_controls.use_seq!=us) dm_ui_use_item(); // 物品区双击 = 使用 / 购买 / 装备(宿主按光标下物品走原生入口) | Double tap in the item area = use / buy / equip (the host goes through the native entry for the item under the cursor) if(_controls.world_tap_seq!=wt && self.bounds.size.width>0) { float wx,wy; world_norm(self,_controls.world_tap_x,_controls.world_tap_y,&wx,&wy); dm_ui_world_tap((float)(_controls.world_tap_x/self.bounds.size.width),(float)(_controls.world_tap_y/self.bounds.size.height),wx,wy); } // 游戏态点世界:点目标 = 交互,点空地不发令 | World tap in game mode: tapping a target = interact; tapping empty ground issues no command - if(wasPtr && _controls.navigation_mode) _tipUntil=_controls.tap_move_seq!=tm ? -1 : _controls.last_time_s+(_controls.mouse_click_seq!=mc ? 0.05 : 2.8); // 点的是技能图标 / 属性「+」(选中待确认):光标留在上面,原版高亮和说明框一直在,点别处 / 点另一个 / 关面板才收 // 说明框:松手后 2.8 秒自己收(游戏的说明框要点后约 0.8 秒才出来,实测;留约 2 秒看);点的是空处 / 普通按钮 = 立即收 | Tapped a skill icon / stat "+" (selected, awaiting confirmation): the cursor stays on it and the original game's highlight and tooltip stay until tapping elsewhere / tapping another / closing the panel // Tooltip: closes by itself 2.8 seconds after release (the game's tooltip takes about 0.8 seconds after the tap to appear, measured; leaving about 2 seconds to read); tapped empty space / an ordinary button = close immediately + // 单纯点了一件物品(没拖、没触发使用 / 鉴定 / 取一件 / 长按):光标留在它上面,说明框一直在,点别处 / 点另一件 / 关面板才收——同下面的技能图标。 + // 原先一律松手后 2.8 秒收,玩家读长说明读到一半框没了、要再点一次。拖放、使用之后光标停在落点上的那种仍按 2.8 秒收(不然放完东西说明框一直盖着) + // A plain tap on an item (no drag, no use / identify / take-one / long press triggered): the cursor stays on it and the description stays up until a tap elsewhere / on another item / the panel closes - same as the skill icons below. + // It used to be put away 2.8 seconds after release in every case, so a player reading a long description lost it halfway and had to tap again. When the cursor rests on the drop point after a drag or a use, it is still put away after 2.8 seconds (otherwise the description would keep covering things after an item is placed) + BOOL itemTap=_controls.item_tap_seq!=its && !dragged && _controls.use_seq==us && _controls.ident_seq==ids && _controls.stack_take_seq==sts && _controls.long_press_seq==lps && _controls.mouse_click_seq==mc; + if(wasPtr && _controls.navigation_mode) _tipUntil=(_controls.tap_move_seq!=tm || itemTap) ? -1 : _controls.last_time_s+(_controls.mouse_click_seq!=mc ? 0.05 : 2.8); // 点的是技能图标 / 属性「+」(选中待确认):光标留在上面,原版高亮和说明框一直在,点别处 / 点另一个 / 关面板才收 // 说明框:松手后 2.8 秒自己收(游戏的说明框要点后约 0.8 秒才出来,实测;留约 2 秒看);点的是空处 / 普通按钮 = 立即收 | Tapped a skill icon / stat "+" (selected, awaiting confirmation): the cursor stays on it and the original game's highlight and tooltip stay until tapping elsewhere / tapping another / closing the panel // Tooltip: closes by itself 2.8 seconds after release (the game's tooltip takes about 0.8 seconds after the tap to appear, measured; leaving about 2 seconds to read); tapped empty space / an ordinary button = close immediately if(_controls.mouse_click_seq!=mc && self.bounds.size.width>0) { float nx=_controls.mouse_click_x/self.bounds.size.width, ny=_controls.mouse_click_y/self.bounds.size.height; dm_ui_touch(0,nx,ny); dm_ui_touch(2,nx,ny); } // 非物品区点按 = 界面鼠标点击 | Tap outside the item area = UI mouse click break; } [self recordTouch:t slot:slot phase:phase]; diff --git a/dm/ios/tools/touch_layout.py b/dm/ios/tools/touch_layout.py index 86ebe96..54be0bc 100644 --- a/dm/ios/tools/touch_layout.py +++ b/dm/ios/tools/touch_layout.py @@ -195,6 +195,8 @@ def pad_bliss(s): # 手柄版建角模式页(原版布局原样)+ 「极 s, n = re.subn(r'\{\s*"action"\s*:\s*"option2"\s*,\s*"description"\s*:\s*"@LegacyGameVersionSwitch"\s*\}\s*,?', '', s); assert n == 1, n at, add = INSERT['controller/console/characteroptionspanelhd.json']; ms = list(re.finditer(at, s)); assert len(ms) == 1 key = ' { "type": "ImageWidget", "name": "TouchBlissKey", "fields": { "rect": { "x": -1665, "y": 1330, "scale": 1.5 }, "filename": "Controller/ControllerButtons/Switch/ButtonLeft" } },\n' + if os.environ.get('DM_OVERLAY_MAC'): # Mac App:同位再带一个键盘键帽(缺省在屏外,玩家用键盘时宿主把两个对调,dm_padmode.c) | Mac App: one more keyboard key cap at the same position (off screen by default; when the player uses the keyboard the host swaps the two, dm_padmode.c) + key += ' { "type": "ImageWidget", "name": "TouchBlissKeyK", "fields": { "rect": { "x": 99999, "y": 1330, "scale": 1.5 }, "filename": "Ztouch_controller_buttons_ui/switchKButtonLeft" } },\n' return s[:ms[0].start()] + add.lstrip() + key + ' ' + s[ms[0].start():] def set_rect(s, name, x, y, w, h): m = re.search(r'"name"\s*:\s*"%s"' % re.escape(name), s); assert m, name @@ -808,6 +810,8 @@ def _rf_div(name, x, y, w=500): # 分隔金线按所在栏宽缩放 | The gold return {'type': 'ImageWidget', 'name': name, 'fields': {'rect': {'x': x, 'y': y, 'scale': round(w / RF_DIV_W, 4)}, 'filename': 'PauseMenu\\Divider'}} def _rf_key(name, cap, by): # 手柄模式下贴在按钮左端的原版键帽(Switch 手柄:右 = A、上 = X;48×45 原图放大 1.5)。缺省在屏外,宿主在手柄模式挪进来(dm_rift_ui.c);这一页原版底部提示条不在屏上 | The original button glyph placed at the left end of the button in controller mode (Switch controller: right = A, top = X; the 48x45 source image scaled by 1.5). Off screen by default, moved in by the host in controller mode (dm_rift_ui.c); on this page the original bottom button legend is not on screen return {'type': 'ImageWidget', 'name': name, 'fields': {'rect': {'x': 99999, 'y': by + 26, 'scale': 1.5}, 'filename': 'Controller/ControllerButtons/Switch/' + cap}} +def _rf_keys(name, cap, by): # Mac App 的覆盖层(DM_OVERLAY_MAC)再带一个同位的键盘键帽(名字加 K,图在 kbd_glyphs.py 那一套里):玩家用键盘时宿主显示它、藏手柄那个。iOS 的覆盖层不带 | the Mac App's overlay (DM_OVERLAY_MAC) additionally carries a keyboard key cap at the same position (name with K appended, images from the kbd_glyphs.py set): when the player uses the keyboard the host shows it and hides the gamepad one. The iOS overlay does not carry it + k = _rf_key(name, cap, by); return [k] + ([dict(k, name=name + 'K', fields=dict(k['fields'], filename='Ztouch_controller_buttons_ui/switchK' + cap))] if os.environ.get('DM_OVERLAY_MAC') else []) def _rift_board(): # 左栏:标题 0–65 → 箭头组 80–188(大厅大箭头 94×108 原尺寸,层数大字在两箭头正中)→ ±10 两个等宽钮 212–267(前端小按钮 366×92 × 0.596 = 218×55,间隔 24,左右与箭头组对齐) # → 本层信息 5 行(行距 64)307–627 → 组间 40 → 安亚赌博 667–851 → 「开始」贴底:底边 = 右列列表底边 1280,宽 460(前端中按钮 470×118 × 0.979) @@ -827,7 +831,7 @@ def _rift_board(): # Four rows (row pitch 64, same as 「本层」(This Level)): gray label on the left (unique / set / unique after clear / set after clear) + right-aligned value (one widget each in unique gold and set green; the host fills one of them). # Two rows of full sentences and two side-by-side columns both exceed the column width (Mac screenshot: truncated / overlapping each other); five rows with a subtitle are too cramped on the real device (row pitch 56, last row touching 「开始」(Enter Rift)) for n in range(4): sel += [_kb_text('TouchRF_Gam%dL' % n, 0, 842 + 64 * n, 300, 56, '$FontColorMoreLightGray', '$MediumFontSize', 'left'), _kb_text('TouchRF_Gam%dLE' % n, 99999, 842 + 64 * n, 330, 56, '$FontColorMoreLightGray', RF_EN_PT, 'left'), _kb_text('TouchRF_Gam%dU' % n, 230, 842 + 64 * n, 250, 56, '$FontColorGoldYellow', '$MediumFontSize', 'right'), _kb_text('TouchRF_Gam%dS' % n, 230, 842 + 64 * n, 250, 56, '$FontColorGreen', '$MediumFontSize', 'right')] - sel += [_rf_btn('TouchRF_Start', 0, 1155, 'FrontEnd/HD/Final/FrontEnd_ButtonMed', _RF_BTN, 1.064, '@dmRiftBtnStart'), _rf_key('TouchRF_KeyA', 'ButtonRight', 1155)] + sel += [_rf_btn('TouchRF_Start', 0, 1155, 'FrontEnd/HD/Final/FrontEnd_ButtonMed', _RF_BTN, 1.064, '@dmRiftBtnStart')] + _rf_keys('TouchRF_KeyA', 'ButtonRight', 1155) # 进行中页:层数大字 96–204 → 「本层」小节(标题 332、金线 394、三行 414 / 478 / 542,与选层页同位)→ 放弃一组(说明 746、按钮 818–943)→ 继续一组贴底(说明 1083、按钮 1155,同「开始」)。 # 信息—放弃—继续三段间距相等(各 140);按钮上方的说明都是四到八个字的短句、居中(放弃那句与「本层」三行宿主按「守护者打倒没有」换说法) # In-progress page: large level number text 96–204 → 「本层」(This Level) section (title 332, gold line 394, three rows 414 / 478 / 542, same positions as the level selection page) → abandon group (caption 746, button 818–943) → continue group flush against the bottom (caption 1083, button 1155, same as 「开始」(Enter Rift)). @@ -848,7 +852,7 @@ def _rift_board(): # When this level is completed the secondary button becomes "Reselect level" (progress is already recorded, so "Abandon" reads wrong). The host cannot # change button text, so a button is placed at the same position and the host moves it in and out according to "has the Guardian been defeated" _rf_btn('TouchRF_Resel', 99999, 818, 'FrontEnd/HD/Final/FrontEnd_ButtonMed', _RF_BTN, 1.064, '@dmRiftBtnResel'), - _rf_key('TouchRF_KeyA2', 'ButtonRight', 1155), _rf_key('TouchRF_KeyX', 'ButtonTop', 818)] + ] + _rf_keys('TouchRF_KeyA2', 'ButtonRight', 1155) + _rf_keys('TouchRF_KeyX', 'ButtonTop', 818) right = [_kb_text('TouchRF_MsT', 530, RF_T0, 500, 60, '$FontColorGoldYellow', '$MediumFontSize', 'left', '@dmRiftMsT'), _rf_div('TouchRF_DivR', 530, 62, 1157), _kb_text('TouchRF_MsN', 1030, RF_T0, 657, 60, '$FontColorMoreLightGray', '$SmallFontSize', 'right', '@dmRiftMsN'), # 英文版的这一句写物品原名(Token of Absolution),比中文长一倍:另放一个更宽、字号更小的控件,缺省在屏外,英文时宿主换用 @@ -893,12 +897,19 @@ def _rift_panel(s): {'type': 'ImageWidget', 'name': 'TouchRF_FrameBg', 'fields': {'filename': '\\PANEL\\Options\\FrontEndOptionsBG'}}, {'type': 'TextBoxWidget', 'name': 'TouchRF_Title', 'fields': {'rect': {'x': 0, 'y': 45, 'width': 1950, 'height': 103}, 'text': '@dmRiftPanelTitle', 'style': '$StyleTitleBlock'}}, {'type': 'ButtonWidget', 'name': 'TouchRF_CloseBtn', 'fields': {'rect': {'x': 1868, 'y': 8}, 'filename': 'PANEL\\closebtn_4x', 'hoveredFrame': 3, 'onClickMessage': close, - 'tooltipString': '@strClose', 'sound': 'cursor_close_window_hd', 'acceptsEscKeyEverywhere': True}}]}]}, + 'tooltipString': '@strClose', 'sound': 'cursor_close_window_hd', 'acceptsEscKeyEverywhere': True}}, + # 触摸关闭钮:外框右上角同一处只留一个——手柄 / 键鼠显示上面那个原版红框,触屏显示这个金色 X(与别的面板同图),宿主按模式把另一个挪出屏(dm_rift_ui.c)。 + # 位置:标题条(y 45 起、高 103,深色底)那一行的右端、面板内侧——金 X(24×33 像素 = 48×66 单位,单位是外框贴图像素的 2 倍)垂直居中于标题条: + # y = 45 + 103 / 2 − 33 = 64;x = 1766:整个 X 落在标题条右端角花(约 1832 起)以左的深色底上,不伸出外框、不压角花。原先对准红框中心,一半伸出外框、压着石角花纹,几乎看不见 + # 点按热区:金 X 本体只有约 10×13 点,另放一个透明的按钮罩在它上面当热区(借触屏那套透明键帽图 48×45 像素,放大 2.4 倍 = 约 46×43 点),中心对准 X 的中心(x 1705 是按「按名字取到的控件中心」实测校的:1675 时偏左 6 点) + # Touch close button: only one stays at the same place at the top right of the frame - gamepad / keyboard-and-mouse show the original red frame above, touch shows this gold X (same image as other panels), and the host moves the other one off screen by mode (dm_rift_ui.c). + # Position: at the right end of the title bar row (starting at y 45, 103 high, dark background), inside the panel - the gold X (24x33 pixels = 48x66 units, a unit being twice a pixel of the frame texture) is centred vertically on the title bar: + # y = 45 + 103 / 2 - 33 = 64; x = 1766: the whole X sits on the dark background to the left of the corner ornament at the right end of the title bar (starting at about 1832), neither sticking out of the frame nor covering the ornament. It used to be aligned with the centre of the red frame, half outside the frame and on top of the stone corner pattern, nearly invisible + # Tap hot zone: the gold X itself is only about 10x13 points, so a transparent button is placed over it as the hot zone (borrowing the touch layout's transparent key-cap image of 48x45 pixels, enlarged 2.4 times = about 46x43 points), centred on the centre of the X (x 1705 was calibrated by measuring "the widget centre fetched by name": at 1675 it was 6 points to the left) + {'type': 'ImageWidget', 'name': 'TouchRF_CloseX', 'fields': {'rect': {'x': 1766, 'y': 64}, 'filename': 'PANEL\\HUD_02\\front_panel'}}, + {'type': 'ButtonWidget', 'name': 'TouchClose', 'fields': {'rect': {'x': 1705, 'y': -11, 'scale': 2.4}, 'filename': 'Ztouch_controller_buttons_ui/switch_ButtonRight', 'sound': 'cursor_close_window_hd', 'onClickMessage': close}}]}]}, {'type': 'ImageWidget', 'name': 'TouchRF_ContentBg', 'fields': {'rect': '$SettingsPanelBackgroundRect', 'anchor': {'x': 0.5}, 'filename': 'Controller/Panel/Options/Panel_Options_BG'}}, - # 触摸关闭钮:同编年史 _chronicle_touch(右上角) - # Touch close button: same as the chronicle's _chronicle_touch (top-right corner) - {'type': 'Widget', 'name': 'TouchCloseBox', 'fields': {'rect': {'x': -998, 'y': 256, 'width': 2600, 'height': 121, 'scale': '$ConsoleUIScale'}, 'anchor': {'x': 0.5}}, 'children': [ - {'type': 'ButtonWidget', 'name': 'TouchClose', 'fields': {'rect': {'x': 2236, 'y': -171}, 'filename': 'PANEL\\HUD_02\\front_panel', 'sound': 'cursor_close_window_hd', 'onClickMessage': close}}]}] + ] board = _rift_board(); board['children'][0]['fields']['rect']['x'] = 0; board['children'][0]['fields']['rect']['y'] = -54 # 没有页签条:内容上移 54,吃掉标题下的空带,底边留出与左边距相当的空(原先上空下贴底) # 内容缺省就在屏上(编年史版要切页签才挪进来) | No tab strip: content moves up 54, taking up the empty band under the title, leaving a gap at the bottom edge comparable to the left margin (previously empty at the top and flush against the bottom) # the content is on screen by default (the chronicle version only moves it in when the tab is switched) lay = {'basedOn': 'MessageLogPanel_800x600HD.json', 'type': 'MessageLogPanel', 'name': 'MessageLogPanel', 'fields': {'priority': 9002, 'fitToParent': True, 'defaultWidget': 'TouchRF_Start'}, 'children': native + frame + [board]} diff --git a/dm/tools/mac_app.sh b/dm/tools/mac_app.sh index daac778..27e5132 100755 --- a/dm/tools/mac_app.sh +++ b/dm/tools/mac_app.sh @@ -4,12 +4,14 @@ # DM_MAC_LINK=1:不带派生物的出法——改写后的游戏程序、着色器库、界面覆盖层都是从游戏内容派生的,公开发布的包不能带; # 这样出的包里只有宿主程序和 Resources/paths.txt(三项各指向本机构建产物的路径),只在构建它的这台机器上能跑。 # 版本:给人看的版本号 DM_MAC_VERSION(缺省 1.0,与 iOS 包同叫法);构建号 DM_MAC_BUILD(缺省取当前月日时分,同 iOS 包格式)。产物代号与提交号写在包里的 Resources/build.txt。 +# 更新检查:DM_MAC_UPDATE_URL=<版本文件地址>(如下载站的 latest_mac.json)写进 Info.plist 的 SWUpdateURL,App 启动后读它、比包内构建号新就在主菜单提示;不给 = 不检查(公开版 / 自己构建的包)。 # 游戏资源不进包:第一次启动请玩家选资源文件夹(host/app_mac.m)。签名用本地临时签名,本机直接能跑。 # Wrap the Mac host into a macOS App that starts on double-click: mac_app.sh [output directory] produces /D2R Mobile.app (default $DM_ROOT/out/macapp) # The package holds: the host program, the rewritten game program (build output directory, kind DM_MAC_PRODUCT, default touch), and the UI overlay when there is one (DM_MAC_OVERLAY=). # DM_MAC_LINK=1: build without derived content - the rewritten game program, the shader libraries and the UI overlay are all derived from game content and must not be in a publicly released package; # a package built this way holds only the host program and Resources/paths.txt (three entries, each pointing at a build output on this machine), and runs only on the machine that built it. # Version: the human-readable version DM_MAC_VERSION (default 1.0, named the same way as the iOS package); the build number DM_MAC_BUILD (default: current month-day-hour-minute, same format as the iOS package). The build output generation and the commit are written to Resources/build.txt in the package. +# Update check: DM_MAC_UPDATE_URL= is written into SWUpdateURL in Info.plist; after launch the App reads it and shows a hint on the main menu when it is newer than the build number in the package; not given = no check (public builds / packages you build yourself). # Game resources do not go into the package: on first launch the player is asked to choose the resource folder (host/app_mac.m). Signing is local ad-hoc signing, which runs directly on this machine. set -eu HERE=$(cd "$(dirname "$0")" && pwd); DM=$HERE/..; ROOT=${DM_ROOT:-$HOME/dm-work} @@ -59,7 +61,8 @@ cat > "$APP/Contents/Info.plist" <CFBundleShortVersionString$VER CFBundleVersion$BUILD LSMinimumSystemVersion$MIN -NSHighResolutionCapable +${DM_MAC_UPDATE_URL:+SWUpdateURL$DM_MAC_UPDATE_URL +}NSHighResolutionCapable LSApplicationCategoryTypepublic.app-category.role-playing-games GCSupportsControllerUserInteraction diff --git a/docs/MAC.md b/docs/MAC.md index bc22246..e27dcd9 100644 --- a/docs/MAC.md +++ b/docs/MAC.md @@ -69,7 +69,9 @@ What it can do now: - **Click empty ground to walk there**: a left click on empty ground walks the character to that point, finding its way around obstacles; a click inside a wall or water walks to the nearest reachable spot. - **Hold to keep walking**: hold the left button and the character keeps walking towards the pointer, following it as it moves. W A S D / the gamepad stick take priority: press a direction key while walking and the keyboard takes over at once. +- **Click a monster = attack**: a left click on a monster attacks it with whatever is bound to the main attack key (J) — a melee character walks over and hits, spells and ranged attacks are used on it directly. Holding keeps attacking and chasing; when it is not a monster under the pointer, holding walks towards it as before. Right click is still back. - **Click a target in the world** (NPC, chest, waypoint, item on the ground): the character walks over and interacts. With a panel open, a click outside it only closes the panel. +- **Items take the mouse now**: a click selects and shows the description; a double click = use / put on / take off (a potion in the belt = drink, the cube = open, a vendor's goods = buy); press and drag = pick up, release = put down (move between cells, equip, into the stash / cube, into the inventory = buy, onto the vendor's shelf = sell), with the item image right on the pointer; press and hold on an empty cell = tidy this page. - **Click the bottom row**: a skill icon = use that skill (the same as pressing the key shown under it), a potion cell = drink it, the middle button = open the inventory group of pages, the run / walk button = toggle. - **Click the interface**: buttons, checkboxes and tabs in panels (including the in-page tabs of the skill tree), the pause menu, the settings pages, and "Start" and the close X on the rift level-selection page. - **Click a key hint at the bottom**: clicking an entry presses that key. @@ -79,17 +81,16 @@ What it can do now: What it cannot do yet: -- **Clicking a monster does not attack**; attack with the skill keys (J K U I). - Click-to-walk was verified only in the camp, on empty ground and the waypoint; complex terrain in the wild and clicking NPCs are unverified. - Switching input device (keyboard ↔ gamepad) while the settings page or the stash is open: the prompts change only after the panel closes. -- **Long press / double click / drag / buying on items do not take the mouse.** Use the keyboard or gamepad cursor: move the cursor onto the item with W A S D and press the key shown in the bottom bar. For example, buying from a vendor: cursor onto the goods (the bottom bar shows "A Buy") → press Space (or J) → press it again in the confirmation. +- A **long press** on an item (more details / take one) is press-and-hold with the mouse; these are the same gestures as on touch. - "Hold …" key hints need longer than a click, so hold the key on the keyboard; a hint with two key caps is not recognised. - The life orb, mana orb and experience bar do nothing when clicked. ## Saves, logs and iCloud - Saves: `~/Library/Application Support/D2R Mobile/save` -- Log: `~/Library/Logs/D2R Mobile/host.log` (the previous run is `host.prev.log`). Please attach it when reporting a problem. +- Log: `~/Library/Logs/D2R Mobile/host.log` (the previous run is `host.prev.log`). When reporting a problem use Help → Share Log… in the menu bar: it packs these two logs and a version-information file into one archive and lets you choose where to save it; nothing is uploaded, no saves are included, and the user name in the logs is replaced with `~`. - The older-API build (`D2R Mobile M3.app`) uses a separate pair of directories with M3 in the name. **iCloud save sync: not available in an App you build from this repository.** The program has the same sync as on iPhone / iPad wired in, but it needs the App to carry the iCloud signing entitlement; an App you build yourself is signed locally without it, so saves stay on this Mac, the log records one line saying iCloud is unavailable and only local saves are used, and the game runs as usual. To bring your phone's progress over, import it by hand as below. @@ -133,10 +134,10 @@ After a forced quit or a crash, the system's "reopen windows?" dialog no longer ## Known shortcomings - The five things from the top have not been operated by a person: keyboard keys, a physical gamepad, the resource-folder dialog, ⌘Q and menu clicks, how it feels in the hand. The key mapping was written from the key-code table. -- Clicking a monster does not attack; long press / double click / drag / buying on items do not take the mouse; click-to-walk was verified only in the camp (see "Mouse" above). +- Click-to-walk was verified only in the camp. Clicking a distant monster through a wall may stop the character at the obstacle; step around and click again. Clicking monsters with a ranged class, and the trove's auto-placement under mouse drags, are unverified. There is no right-click skill as on PC. +- The Share Log menu item and save panel have not been operated by a person; what was verified is the archive it produces. - "Prompts switch back to gamepad letters when a gamepad is used" was verified by simulation; no physical gamepad has been connected. -- On a few pages (the rift confirmation page and level-selection page) the key cap drawn inside a button is still the gamepad "A"; press J or Space. - The free town portal on ZR + Space of a gamepad is not there. - The quest bar on the left in rifts is not there. -- An App you build yourself has no iCloud save sync; there are no update checks and no sharing of the diagnostic log. +- An App you build yourself has no iCloud save sync and does no update check (it does not go online). - The older-API build was played on macOS 15 by one player in our test group (Mac mini M4, macOS 15.7, using a package built elsewhere); building it from this repository on a Mac running macOS 15 has not been operated by a person. diff --git a/docs/MAC.zh-CN.md b/docs/MAC.zh-CN.md index d00abc7..76f61e6 100644 --- a/docs/MAC.zh-CN.md +++ b/docs/MAC.zh-CN.md @@ -69,7 +69,9 @@ DM_MAC_M3=1 dm/tools/mac_app.sh # macOS 15 – 25 - **点空地走过去**:左键点一下空地,角色走到那一点,会自己绕开障碍;点在墙里、水里就走到能到的最近处。 - **按住一直走**:左键按住不放,角色一直朝鼠标所在的地方走,鼠标挪到哪跟到哪。W A S D / 手柄摇杆优先:走着的时候按方向键,立刻听键盘的。 +- **点怪 = 攻击**:左键点一只怪,用主攻击键(J)上绑的技能打它——近战会自己走过去打,法术 / 远程直接对它放。按住不放一直打、追着打;光标下不是怪时照旧朝光标走。右键仍是返回。 - **点世界里的目标**(NPC、箱子、传送点、地上的物品):走过去交互。面板开着时点面板外只关面板。 +- **物品认鼠标了**:单击选中看说明;双击 = 使用 / 穿上 / 卸下(腰带里的药 = 喝,魔盒 = 打开,商人的货 = 买);按住拖 = 拿起、松手放下(换格、穿到身上、进储藏箱 / 魔盒、拖进背包 = 买、拖到货架 = 卖),物品图就在光标上;在空格上按住 = 整理这一页。 - **点底部那一排**:技能图标 = 放那个技能(等于按它下面标的键),药水格 = 喝那格药,中间的钮 = 打开物品栏那组页面,跑 / 走钮 = 切换。 - **点界面**:面板里的按钮、勾选框、页签(含技能树页里的分页)、暂停菜单、设置页、秘境选层页的「开始」与右上角的关闭 X。 - **点底部的按键提示**:点哪一条,等于按那个键。 @@ -79,17 +81,16 @@ DM_MAC_M3=1 dm/tools/mac_app.sh # macOS 15 – 25 还不能的: -- **点怪攻击没有**,攻击用技能键(J K U I)。 - 点地走只在营地验过空地与小站;野外复杂地形、点 NPC 未经验证。 - 设置页、储藏箱开着时换输入设备(键盘 ↔ 手柄),按键提示要等面板关掉才换。 -- **物品的长按 / 双击 / 拖放 / 购买不认鼠标**,用键盘或手柄的光标操作:W A S D 把光标移到物品上,按底栏提示的键。例如在商人处买东西:光标移到货物上(底栏出现「A 购买」)→ 按空格(或 J)→ 确认框里再按一次。 +- 物品的**长按**(看更多说明 / 取一件)在鼠标上是按住不动;这些手势和触屏上的是同一套。 - 「按住…」类的按键提示点一下不够长,用键盘按住;一条提示带两个键帽的不认。 - 血球、魔球、经验条点了没有反应。 ## 存档、日志与 iCloud - 存档:`~/Library/Application Support/D2R Mobile/save` -- 日志:`~/Library/Logs/D2R Mobile/host.log`(上一次运行的是 `host.prev.log`)。报问题时请附上它。 +- 日志:`~/Library/Logs/D2R Mobile/host.log`(上一次运行的是 `host.prev.log`)。报问题时用菜单栏「帮助 → 分享日志…」:它把这两份日志和一份版本信息打成一个压缩包,让你选保存位置;不上传、不带存档,日志里的用户名会换成 `~`。 - 老接口版(`D2R Mobile M3.app`)用的是名字里带 M3 的另一对目录。 **iCloud 存档同步:从本仓库自己构建的 App 没有。**程序里接了与 iPhone / iPad 相同的同步,但它需要 App 带着 iCloud 的签名权限;自己构建的 App 用的是本机临时签名,没有这项权限,所以存档只留在这台 Mac 上,日志里会记一行「iCloud 不可用…只用本地存档」,游戏照常。要把手机上的进度带过来,用下面的手工导入。 @@ -133,10 +134,10 @@ DM_MAC_M3=1 dm/tools/mac_app.sh # macOS 15 – 25 ## 已知不足 - 开头说的五项未经真人操作:键盘按键、实体手柄、选资源文件夹的对话框、⌘Q 与菜单点击、真人手感。键位是照键码表写的。 -- 鼠标点怪攻击没有;物品的长按 / 双击 / 拖放 / 购买不认鼠标;点地走只在营地验过(见上面「鼠标」一节)。 +- 点地走只在营地验过。隔着墙点远处的怪,角色可能走到障碍前就停,绕一步再点。远程职业点怪、珍宝匣自动归位在鼠标拖放下,未经验证。PC 版的右键技能没有。 +- 「分享日志」的菜单项与保存面板未经真人操作,验过的是打出来的压缩包。 - 「接上手柄提示换回手柄字母」是模拟验的,实体手柄没接过。 -- 个别页面(秘境的确认页、选层页)按钮里画的键帽还是手柄的「A」,实际按 J 或空格即可。 - 手柄上 ZR 空格的免费回城没有。 - 秘境左侧的任务栏没有。 -- 自己构建的 App 没有 iCloud 存档同步;没有更新检查和分享诊断日志。 +- 自己构建的 App 没有 iCloud 存档同步,也不做更新检查(它不联网)。 - 老接口版在 macOS 15 上由一位内测玩家实际玩过(Mac mini M4,macOS 15.7,用的是出好的包);在 macOS 15 的 Mac 上从本仓库自己构建,未经真人操作。