Older systems: iOS 18+ / macOS 15+ via the older-API build; floating left stick; runeword required level; Mac keyboard, mouse and docs; clearer older-device dialog
This commit is contained in:
+11
-1
@@ -7,7 +7,7 @@ MACOS_MIN ?= 26.0
|
||||
CFLAGS=-O1 -g -Wall -Wno-unused-function -mmacosx-version-min=$(MACOS_MIN)
|
||||
# 服务层接管 hle_*.c 按通配纳入:新增文件不改这一行(免合并冲突)
|
||||
# Service-layer takeover hle_*.c files are included by wildcard: adding a file does not touch this line (avoids merge conflicts)
|
||||
SRC=main.c loader.c hle.c crash.c diag.c thread.c memstat.m dm_cursor.c dm_cursor_item.c dm_world.c dm_textinput.c dm_update.c dm_actions.c dm_namegen.c dm_cloudsync.c dm_custom.c dm_elysium.c dm_bossrush.c dm_pages.c dm_vault.c dm_vault_ui.c dm_kills.c dm_textbox.c dm_turnsmooth.c dm_textbox_core.c dm_potpick.c dm_lootfilter.c dm_autobuff.c dm_beltauto.c dm_padmode.c dm_pouch.c dm_drophaptic.c dm_freetp.c dm_townwp.c dm_shoprefresh.c dm_runeword.c dm_uiscreen.c dm_dropfilter.c dm_hud.c dm_rift.c dm_rift_ui.c dm_bright.c touch_mac.c romfs_validate.c ../ios/Sources/dm_touch_controls.c $(sort $(wildcard hle_*.c)) front_mac.m app_mac.m ../ios/Sources/dm_gamepad.m entry.S dm_i18n.c
|
||||
SRC=main.c loader.c hle.c crash.c diag.c thread.c memstat.m dm_cursor.c dm_cursor_item.c dm_world.c dm_textinput.c dm_update.c dm_actions.c dm_namegen.c dm_cloudsync.c dm_custom.c dm_elysium.c dm_bossrush.c dm_pages.c dm_vault.c dm_vault_ui.c dm_kills.c dm_textbox.c dm_turnsmooth.c dm_textbox_core.c dm_potpick.c dm_lootfilter.c dm_autobuff.c dm_beltauto.c dm_padmode.c dm_pouch.c dm_drophaptic.c dm_freetp.c dm_townwp.c dm_shoprefresh.c dm_runeword.c dm_rwlv_core.c dm_uiscreen.c dm_dropfilter.c dm_hud.c dm_rift.c dm_rift_ui.c dm_bright.c touch_mac.c romfs_validate.c ../ios/Sources/dm_touch_controls.c $(sort $(wildcard hle_*.c)) front_mac.m app_mac.m ../ios/Sources/dm_gamepad.m ../ios/Sources/cloud_ios.m entry.S dm_i18n.c
|
||||
# NVN 空设备 + nn::vi(dm/gfx/)
|
||||
# 按通配纳入 dm/gfx 与 dm/gfx/nvn 下的源(tests/ metal/ 不进宿主):新增文件不改这一行
|
||||
# NVN null device + nn::vi (dm/gfx/)
|
||||
@@ -20,6 +20,12 @@ LIBDEFLATE=../third_party/libdeflate/lib/deflate_decompress.c ../third_party/lib
|
||||
.DEFAULT_GOAL := dmhost # 下面先写了表头生成规则,缺省目标要明说(否则 make 只生成表头、不编宿主) | The header generation rules are written first below, so the default goal must be stated explicitly (otherwise make only generates the headers and does not build the host)
|
||||
print-macos-min:
|
||||
@echo $(MACOS_MIN)
|
||||
# 老接口版(图形后端不用 Metal 4,见 gfx/nvn/nvn_mtl.m 的 DM_NVN_M3):最低系统单独一个数;包名另起,存档与日志目录跟着包名走、不与正式包共用
|
||||
# Older-API build (graphics backend without Metal 4, see DM_NVN_M3 in gfx/nvn/nvn_mtl.m): its minimum system is a separate number; the package gets its own name, and the save and log directory follows the package name instead of being shared with the regular package
|
||||
MACOS_MIN_M3 ?= 15.0
|
||||
CFLAGS_M3=$(subst -mmacosx-version-min=$(MACOS_MIN),-mmacosx-version-min=$(MACOS_MIN_M3),$(CFLAGS)) -DDM_NVN_M3=1 -DAPP_NAME='"D2R Mobile M3"'
|
||||
print-macos-min-m3:
|
||||
@echo $(MACOS_MIN_M3)
|
||||
# 由原版表生成的头文件:不进仓库,构建时从玩家自己的游戏文件(Switch 版 3.3.94012 的 Update/RomFS)生成;路径用环境变量 DM_ROMFS_SRC 指定
|
||||
# Headers generated from the original game's tables: not checked into the repository, generated at build time from the player's own game files (Update/RomFS of Switch version 3.3.94012); the path is given by the environment variable DM_ROMFS_SRC
|
||||
ROMFS?=$(or $(DM_ROMFS_SRC),$(DM_ROOT)/data/switch/3.3.94012/Update/RomFS)
|
||||
@@ -36,3 +42,7 @@ dm_bright_levels.inc: ../tools/gen_bright_levels.py ../ios/tools/touch_layout.py
|
||||
python3 ../tools/gen_bright_levels.py "$(ROMFS)" > $@.tmp && mv $@.tmp $@
|
||||
dmhost: $(SRC) $(GFX) $(LIBDEFLATE) dm.h hle.h dm_input.h front.h touch_mac.h dm_cursor.h dm_i18n_tab.h ../ios/Sources/dm_touch_controls.[ch] $(GFX_H) $(GENH)
|
||||
clang $(CFLAGS) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController
|
||||
# 老接口版宿主(图形后端不用 Metal 4,目标 macOS 15.0):同一棵树、同一份源码,只多一个编译开关;不在缺省目标里,要用时 make dmhost_m3
|
||||
# Older-API host (graphics backend without Metal 4, target macOS 15.0): the same tree and the same source, with just one more compile switch; not in the default targets, run make dmhost_m3 when needed
|
||||
dmhost_m3: $(SRC) $(GFX) $(LIBDEFLATE) dm.h hle.h dm_input.h front.h touch_mac.h dm_cursor.h dm_i18n_tab.h ../ios/Sources/dm_touch_controls.[ch] $(GFX_H) $(GENH)
|
||||
clang $(CFLAGS_M3) -I. -I../gfx/nvn/include -fobjc-arc -o $@ $(SRC) $(GFX) $(LIBDEFLATE) -framework Cocoa -framework QuartzCore -framework Metal -framework AudioToolbox -framework ImageIO -framework UniformTypeIdentifiers -framework GameController
|
||||
|
||||
+14
-1
@@ -14,7 +14,9 @@
|
||||
#include "dm_i18n.h"
|
||||
#define T(k) (@(dm_ui(k)))
|
||||
|
||||
#define APP_NAME "D2R Mobile"
|
||||
#ifndef APP_NAME
|
||||
#define APP_NAME "D2R Mobile" // 存档与日志目录名;老接口版构建时另给(host/Makefile CFLAGS_M3),两个包不共用存档 | name of the save and log directory; given separately when building the older-API version (host/Makefile CFLAGS_M3), so the two packages do not share saves
|
||||
#endif
|
||||
static NSString *const kRomfsKey = @"RomfsDir";
|
||||
|
||||
// 这个文件夹是不是游戏资源:认 data/build_manifest.psv。选到上一两层(解包目录的根、Update)也认,往里找一层
|
||||
@@ -79,12 +81,21 @@ int dm_app_bootstrap(int *argc, char ***argv) {
|
||||
[fm removeItemAtPath:[logd stringByAppendingPathComponent:@"host.prev.log"] error:nil];
|
||||
[fm moveItemAtPath:lf toPath:[logd stringByAppendingPathComponent:@"host.prev.log"] error:nil];
|
||||
if (!isatty(2)) { freopen(lf.fileSystemRepresentation, "w", stderr); setvbuf(stderr, NULL, _IOLBF, 0); }
|
||||
// 不要系统的「窗口状态恢复」:上次被强退 / 崩过之后,系统会在启动时弹「上次意外退出,要重新打开窗口吗」的模态框——游戏没有可恢复的窗口,
|
||||
// 框却挡着主窗口收不到鼠标键盘(游戏在后面照跑)。等同于带启动参数 -ApplePersistenceIgnoreState YES;要在建 NSApplication 之前设
|
||||
// No system "window state restoration": after a forced quit / crash the system shows a modal "the app quit unexpectedly, reopen windows?" at launch - the game has no window to restore,
|
||||
// yet the dialog covers the main window, which then receives no mouse or keyboard (the game keeps running behind it). Equivalent to the launch argument -ApplePersistenceIgnoreState YES; must be set before NSApplication is created
|
||||
[NSUserDefaults.standardUserDefaults setVolatileDomain:@{ @"ApplePersistenceIgnoreState": @YES } forName:NSArgumentDomain];
|
||||
[NSApplication sharedApplication]; [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; [NSApp activateIgnoringOtherApps:YES];
|
||||
NSString *prod = res_item(@"product");
|
||||
if (!prod || ![fm fileExistsAtPath:[prod stringByAppendingPathComponent:@"main.patched.bin"]]) {
|
||||
alert(T("dmAppBrokenTitle"), T("dmAppBroken")); exit(1);
|
||||
}
|
||||
NSUserDefaults *ud = NSUserDefaults.standardUserDefaults;
|
||||
// 包标识换过(内测正式包为了 iCloud 改用与 iOS 包同一个标识):偏好按包标识分域,选过的资源文件夹、看过键位对照这两项从旧域(公开口径的标识)接过来一次,免得再选一遍
|
||||
// The bundle identifier has changed (the internal build switched to the same identifier as the iOS package for iCloud): preferences are scoped by bundle identifier, so the two items - the chosen resource folder and having seen the key reference - are carried over once from the old domain (the identifier of public builds), to avoid choosing again
|
||||
if (![ud stringForKey:kRomfsKey] && ![NSBundle.mainBundle.bundleIdentifier isEqualToString:@"org.d2rmobile.mac"]) { NSUserDefaults *old = [[NSUserDefaults alloc] initWithSuiteName:@"org.d2rmobile.mac"]; NSString *r = [old stringForKey:kRomfsKey];
|
||||
if (r) { [ud setObject:r forKey:kRomfsKey]; if ([old boolForKey:@"KeysShown"]) [ud setBool:YES forKey:@"KeysShown"]; LOG("App:从旧包标识的偏好里接过资源文件夹 %s", r.UTF8String); } }
|
||||
NSString *saved = [ud stringForKey:kRomfsKey], *why = nil, *rom = saved ? romfs_root(saved, &why) : nil;
|
||||
if (getenv("DM_APP_ROMFS")) { // 测试(没人点对话框时用):直接给资源文件夹;不对就把同一句报错写进日志并退出,不弹框、不记进偏好 | Test (for when nobody is there to click the dialog): give the resource folder directly; if it is wrong, write the same error sentence to the log and exit, with no dialog and nothing saved to preferences
|
||||
rom = romfs_root(@(getenv("DM_APP_ROMFS")), &why);
|
||||
@@ -95,6 +106,8 @@ int dm_app_bootstrap(int *argc, char ***argv) {
|
||||
[ud setObject:rom forKey:kRomfsKey];
|
||||
}
|
||||
{ void dm_custom_init(const char *dir); dm_custom_init(sup.fileSystemRepresentation); } // 自定义设置文件的目录现在就给(同 iOS 壳):不给的话要等存档挂上才知道在哪,而语言开关正是在挂存档那一刻读它改游戏语言的——晚了开关就不生效 | the directory of the custom settings file is given right now (same as the iOS shell): otherwise it is only known once the save is mounted, and the language switch is read to change the game language at exactly that moment - too late and the switch has no effect
|
||||
if (!getenv("DM_TOUCH_DEFAULTS")) setenv("DM_TOUCH_DEFAULTS", "1", 1); // 产品缺省同 iOS 包(hle_fs.c settings_seed:玩家没碰过的设置键补上——小地图放右上角、进局自动打开、显示物品用开关式等;已有的键不动)。命令行宿主缺省不做,那边要对 Switch 真值比图 | product defaults same as the iOS package (hle_fs.c settings_seed: fills in settings keys the player has never touched - minimap in the top-right corner, opened automatically on entering a game, show-items as a toggle, and so on; existing keys are left alone). The command-line host does not do this by default, since it has to be compared against Switch ground-truth images
|
||||
if (!getenv("DM_APP_SUPPORT")) setenv("DM_CLOUD_REAL", "1", 1); // iCloud 同步(ios/Sources/cloud_ios.m,两端共用)只认玩家真实的存档目录;测试用的支持目录一律不同步 | iCloud sync (ios/Sources/cloud_ios.m, shared by both platforms) only recognises the player's real save directory; a support directory used for testing is never synced
|
||||
setenv("DM_WINDOW", "1", 1); setenv("DM_APP", "1", 1);
|
||||
setenv("DM_SAVE", save.fileSystemRepresentation, 1); setenv("DM_TEMP", temp.fileSystemRepresentation, 1);
|
||||
setenv("DM_ROMFS", rom.fileSystemRepresentation, 1); setenv("DM_ROOT", sup.fileSystemRepresentation, 1);
|
||||
|
||||
@@ -1197,6 +1197,9 @@ int dm_unpause_for_exit(void) {
|
||||
if (!b || !in_game()) return 0;
|
||||
volatile uint8_t *f = b + 0x2d5ff51, *g = b + 0x2d5ff67; int was = *f || *g; *f = 0; *g = 0; return was;
|
||||
}
|
||||
// 游戏是不是停着(暂停菜单 / 大秘境选层页这类开着:同上两个界面状态字节)。不在局内返回 0
|
||||
// Whether the game is stopped (pause menu / Greater Rift level-selection page and the like open: the same two UI state bytes as above). Returns 0 when not in a game
|
||||
int dm_game_paused(void) { uint8_t *b = NULL; for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) b = (uint8_t *)g_mod[i].base; return b && in_game() && (*(volatile uint8_t *)(b + 0x2d5ff51) | *(volatile uint8_t *)(b + 0x2d5ff67)); }
|
||||
// 测试用:按 id 取服务端物品单位(物品表 G+0x2e30,128 桶、next=+0x158);不在局内 / 没找到返回 0
|
||||
// For tests: get a server item unit by id (item table G+0x2e30, 128 buckets, next=+0x158); returns 0 when not in a run / not found
|
||||
uint64_t dm_diag_srv_item(uint32_t id) { if (!in_game()) return 0; uint64_t u = 0; tk_rd(g_lastG + 0x2e30 + 8 * (id & 0x7f), &u, 8); for (int k = 0; u && k < 4096; k++) { uint32_t ty = 0, uid = 0; if (!tk_rd(u, &ty, 4) || !tk_rd(u + 8, &uid, 4)) return 0; if (ty == 4 && uid == id) return u; if (!tk_rd(u + 0x158, &u, 8)) return 0; } return 0; }
|
||||
|
||||
+14
-2
@@ -446,6 +446,7 @@ static _Atomic uint64_t g_ut_xy; // 归一化坐标各 16 位
|
||||
// the global flag is cleared along with it, and this click can then select the new one. Confirming does not rely on tapping again; it uses the 「继续」(Continue) button in the layout (sends ToConsoleCharacterOptions, valid at any time).
|
||||
static _Atomic int g_cc_open;
|
||||
static _Atomic int g_fe_name_open, g_fe_name_tap; // 起名页开着;点了输入框(重新弹键盘) | Naming page open; the input box was tapped (bring the keyboard up again)
|
||||
static _Atomic int g_fe_name_has; // 起名页开着期间已经填过名字(输入框确认过非空的字,含留空取的随机名) | a name has been filled in while the naming page was open (the input field confirmed non-empty text, including the random name taken when left empty)
|
||||
static const char *const k_cc_class[8] = { "Amazon", "Assassin", "Necromancer", "Barbarian", "Paladin", "Sorceress", "Warlock", "Druid" };
|
||||
static _Atomic int g_fe_opt_open, g_fe_confirm_open, g_fe_back;
|
||||
static _Atomic int g_fe_opt_side; // 模式页最近一次点的是哪张牌:0 标准(左半屏)1 专家(右半屏) | Which card was tapped most recently on the mode page: 0 Standard (left half of the screen), 1 Hardcore (right half of the screen)
|
||||
@@ -1074,6 +1075,16 @@ static int ui_classify0(module_t *m, uint64_t root, int x, int y, char *hit, siz
|
||||
int yy = y + off[i] * vh / 2160; if (yy < 0 || yy >= vh) continue; int tl = ui_top_cover(m, root, x, yy); if (tl < 0) tl = 0;
|
||||
for (int k = (int)rn - 1; k >= tl && !th; k--) th = tab_walk(*(uint64_t *)(rch + 8 * k), (uint64_t)(uint32_t)x | ((uint64_t)(uint32_t)yy << 32), 1, (uint64_t)m->base + 0x20ba3a8, &d, &top); } }
|
||||
if (th) { atomic_store(&g_tab_delta, d); atomic_store(&g_tab_top, top); snprintf(hit, hn, "页签 %+d%s", d, top ? "(顶部)" : ""); return 2; }
|
||||
// 手柄版技能树的页内分页(防御光环 / 攻击光环…)不是页签条控件,是四个文字框 TextTabK,只认 ZL / ZR:点在第 K 个文字框上 = 按差值走。
|
||||
// 当前页 = TabK 里 Background 可见的那个(「综合技能」那页 Tab3 没有 Background:前三个都不可见就是它)。只在手柄版布局认(触屏版布局的技能树页签是可点的)
|
||||
// The in-page pagination of the gamepad-layout skill tree (Defensive Auras / Offensive Auras ...) is not a tab-bar widget but four text boxes TextTabK that only respond to ZL / ZR: a click on the K-th text box = step by the difference.
|
||||
// The current page = the TabK whose Background is visible (on the "general skills" page Tab3 has no Background: if none of the first three is visible, it is that one). Recognised only in the gamepad layout (in the touch layout the skill tree tabs are clickable)
|
||||
{ int dm_padmode_current(void); uint64_t sp = dm_padmode_current() ? ui_find(root, "SkillsTreePanel", 0) : 0;
|
||||
if (sp && *(uint8_t *)(sp + 0x50) && *(uint8_t *)(sp + 0x51)) { int tgt = -1, cur = 3; char nm[16];
|
||||
for (int k = 0; k < 4; k++) { snprintf(nm, sizeof nm, "TextTab%d", k); uint64_t tw = ui_find(sp, nm, 0);
|
||||
if (tw && *(uint8_t *)(tw + 0x50) && (((int (*)(uint64_t, uint64_t))*(uint64_t *)(*(uint64_t *)tw + 0x48))(tw, xy) & 1)) tgt = k;
|
||||
snprintf(nm, sizeof nm, "Tab%d", k); uint64_t tb = k < 3 ? ui_find(sp, nm, 0) : 0, bg = tb ? ui_find(tb, "Background", 0) : 0; if (bg && *(uint8_t *)(bg + 0x50)) cur = k; }
|
||||
if (tgt >= 0) { atomic_store(&g_tab_w, 0); atomic_store(&g_tab_delta, tgt - cur); atomic_store(&g_tab_top, 0); snprintf(hit, hn, "技能树分页 %+d", tgt - cur); return 2; } } }
|
||||
{ int sx = x, sy = y, sn = ui_snap(m, root, &sx, &sy); if (sn == 6) { snprintf(hit, hn, "盖:%s 不点", g_inside_name); return 6; }
|
||||
if (sn == 1) { if (snap_guarded(root, g_click_name)) snap_guard_near(g_click_w, g_click_name, x, y, sx, sy, *(int32_t *)(m->base + 0x211da38), *(int32_t *)(m->base + 0x211da3c)); // 只为留一行本体点数读数 | only to leave one line of readout of the widget body's size in points
|
||||
snprintf(hit, hn, " 可点控件 %s", g_click_name); bd_note_skill(m, root, sx, sy); return 0; }
|
||||
@@ -2634,7 +2645,7 @@ void dm_ui_on_uimsg(const char *cat, const char *act, const char *arg) {
|
||||
if (strcmp(cat, "InputMessage") && strcmp(cat, "MonsterHealth") && strcmp(cat, "PartyPanelMessage")) DM_LAT("ui %s %s %s", cat, act, arg ? arg : "");
|
||||
{ static const char *at; static int got; if (!got) { got = 1; at = getenv("DM_UI_TAPS_AT"); }
|
||||
if (at && !atomic_load(&g_taps_base)) { char k[160]; snprintf(k, sizeof k, "%s:%s", act, arg); if (strstr(k, at)) atomic_store(&g_taps_base, dm_guest_frame() | 1); } }
|
||||
if (!strcmp(cat, "PanelManager") && !strcmp(arg, "CharacterCreateNamePanel")) { int op = !strcmp(act, "OpenPanel"); if (op || !strcmp(act, "ClosePanel") || !strcmp(act, "UnloadPanel")) { atomic_store(&g_fe_name_open, op); if (op) atomic_store(&g_fe_name, 1); } }
|
||||
if (!strcmp(cat, "PanelManager") && !strcmp(arg, "CharacterCreateNamePanel")) { int op = !strcmp(act, "OpenPanel"); if (op || !strcmp(act, "ClosePanel") || !strcmp(act, "UnloadPanel")) { atomic_store(&g_fe_name_open, op); if (op) atomic_store(&g_fe_name_has, 0); if (op) atomic_store(&g_fe_name, 1); } }
|
||||
if (!strcmp(cat, "PanelManager") && (!strcmp(arg, "CharacterOptionsPanel") || !strcmp(arg, "ConfirmationModal"))) { int op = !strcmp(act, "OpenPanel"); if (op || !strcmp(act, "ClosePanel") || !strcmp(act, "UnloadPanel")) atomic_store(arg[1] == 'h' ? &g_fe_opt_open : &g_fe_confirm_open, op); }
|
||||
if (!strcmp(cat, "PanelManager") && !strcmp(arg, "DeleteCharacterModal")) { if (!strcmp(act, "OpenPanel")) atomic_store(&g_fe_del_open, 1); else if (!strcmp(act, "ClosePanel") || !strcmp(act, "UnloadPanel")) { atomic_store(&g_fe_del_open, 0); atomic_store(&g_del_hold, 0); } }
|
||||
if (!strcmp(cat, "PanelManager") && !strcmp(arg, "CharacterCreatePanel")) { if (!strcmp(act, "OpenExclusivePanel") || !strcmp(act, "OpenPanel")) atomic_store(&g_cc_open, 1); else if (!strcmp(act, "ClosePanel") || !strcmp(act, "UnloadPanel")) atomic_store(&g_cc_open, 0); }
|
||||
@@ -2665,7 +2676,8 @@ static uint64_t ui_find(uint64_t w, const char *name, int dep) { // 按名字
|
||||
static uint64_t fe_ms(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (uint64_t)t.tv_sec * 1000 + t.tv_nsec / 1000000; }
|
||||
static char g_fe_name_text[64]; static _Atomic uint64_t g_fe_name_ms; // 键盘交回的名字(写完后才置 g_fe_name_done);主线程第一次看到交回的时刻 | the name handed back by the keyboard (g_fe_name_done is set only after it is written); the moment the main thread first sees the hand-back
|
||||
_Atomic int g_fe_name_no_accept; // 前端置 1:这次返回的是替玩家抽的随机名(front_ios.m),只填进名字框、不自动「接受」——同原版「随机名字」键,玩家看到名字再自己点创建 | set to 1 by the front end: what is returned this time is a random name drawn for the player (front_ios.m), which is only filled into the name box without an automatic 「接受」(Accept) -- same as the original game's 「随机名字」(Random Name) button, the player sees the name and then taps create themselves
|
||||
void dm_ui_text_entered(const char *text) { if (atomic_exchange(&g_fe_name_no_accept, 0)) return; if (text && *text && atomic_load(&g_fe_name_open)) { strlcpy(g_fe_name_text, text, sizeof g_fe_name_text); atomic_store(&g_fe_name_done, 1); } } // 系统键盘返回(hle_swkbd.c):起名页输完名字 → 自动「接受」 | system keyboard returns (hle_swkbd.c): name entered on the naming page → automatic 「接受」(Accept)
|
||||
int dm_ui_fe_name_wants_input(void) { return atomic_load(&g_fe_name_open) && !atomic_load(&g_fe_name_has); } // 起名页开着、名字还没填:Mac 键盘的回车这时当「输入名称」(A)而不是「接受」(+),见 touch_mac.c | naming page open and the name not yet filled in: Return on a Mac keyboard then acts as "Enter Name" (A) instead of "Accept" (+), see touch_mac.c
|
||||
void dm_ui_text_entered(const char *text) { if (text && *text && atomic_load(&g_fe_name_open)) atomic_store(&g_fe_name_has, 1); if (atomic_exchange(&g_fe_name_no_accept, 0)) return; if (text && *text && atomic_load(&g_fe_name_open)) { strlcpy(g_fe_name_text, text, sizeof g_fe_name_text); atomic_store(&g_fe_name_done, 1); } } // 系统键盘返回(hle_swkbd.c):起名页输完名字 → 自动「接受」 | system keyboard returns (hle_swkbd.c): name entered on the naming page → automatic 「接受」(Accept)
|
||||
// 前端要宿主替玩家点一下某个手柄键(任意线程调):按住 frames 个客体帧后自动松开。目前只有一处用:进局后点一次「显示物品」键(front_ios.m item_labels_on)
|
||||
// The front end asks the host to press a controller button once for the player (callable from any thread): held for frames guest frames and then released automatically. Currently used in only one place: pressing the 「显示物品」(Show Items) button once after entering a run (front_ios.m item_labels_on)
|
||||
static _Atomic uint64_t g_pulse_mask, g_pulse_until;
|
||||
|
||||
@@ -152,8 +152,8 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = {
|
||||
{ "dmOldPackSize", "「%s」里的补充包大小不对(%.2f / %.2f GB),像是没拷完", "The pack in \"%s\" has the wrong size (%.2f / %.2f GB); the copy looks incomplete" },
|
||||
{ "dmOldPackBad", "「%s」里的补充包内容不对(和这个版本不配套,或拷坏了),请重新下载", "The pack in \"%s\" does not match this version or is corrupted; please download it again" },
|
||||
{ "dmOldPackNone", "没找到老机型补充包", "Supplementary pack for older devices not found" },
|
||||
{ "dmOldUnsupTitle", "暂不支持本机型", "Device Not Supported" },
|
||||
{ "dmOldUnsupMsg", "本机型(iPhone 14 及更早,A16 及以前芯片)暂不支持:显卡不支持游戏素材格式。iPhone 15 Pro 及以后可以玩。", "This device (iPhone 14 or earlier, A16 chip or older) is not supported yet: its GPU cannot read the game's texture format. iPhone 15 Pro and later can run the game." },
|
||||
{ "dmOldUnsupTitle", "这台设备要多做一步", "One More Step for This Device" },
|
||||
{ "dmOldUnsupMsg", "本机型(A16 及更早的芯片,如 iPhone 14 系列、iPhone 15 / 15 Plus)可以玩,但要多做一份「Legacy Device Pack」,并在做安装包时带上它——这个安装包没有带。\n\n怎么做:打开 github.com/jhaizhou-ops/d2r-mobile,照 docs/LEGACY_DEVICES 说明做好补充包,带着它重新做一次安装包,再装到手机上。", "This device (A16 chip or older, such as the iPhone 14 family and iPhone 15 / 15 Plus) can run the game, but it needs a supplementary pack for older devices, and the install package has to be made with it - this one was not.\n\nWhat to do: open github.com/jhaizhou-ops/d2r-mobile, follow docs/LEGACY_DEVICES to make the pack, make the install package again with it, then install it on the phone." },
|
||||
{ "dmOldNeedTitle", "需要老机型补充包", "Supplementary Pack Required" },
|
||||
{ "dmOldNeedMsg", "本机型需要老机型补充包(约 %.1f GB)。\n在「文件」里把「Legacy Device Pack」文件夹整个拷到「我的 iPhone → D2R Mobile」,再打开D2R Mobile。%@", "This device needs the supplementary pack for older devices (about %.1f GB).\nIn the Files app, copy the whole \"Legacy Device Pack\" folder into \"On My iPhone → D2R Mobile\", then open D2R Mobile again.%@" },
|
||||
{ "dmOldWhySuffix", "\n(%s)", "\n(%s)" },
|
||||
@@ -317,5 +317,5 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = {
|
||||
{ "dmAppFullscreen", "全屏", "Toggle Full Screen" },
|
||||
{ "dmAppMenuHelp", "帮助", "Help" },
|
||||
{ "dmAppKeysTitle", "键盘与手柄按键对照", "Keyboard and Controller Buttons" },
|
||||
{ "dmAppKeysText", "界面上的按键提示是手柄字母,键盘这样对应:\n\n移动:W A S D(左摇杆)\n十字键:方向键\nA 确认:J B 返回:K X:U Y:I\nL:Q R:E ZL:Z ZR:C\n按左摇杆:F 按右摇杆:G\n+(菜单):回车 −(地图):Tab\n\n鼠标:左键点目标或界面,右键 = B,滚轮滚列表。\n接上手柄可以直接用。这一页以后在「帮助」菜单里。", "On-screen button hints use controller letters. Keyboard mapping:\n\nMove: W A S D (left stick)\nD-pad: arrow keys\nA confirm: J B back: K X: U Y: I\nL: Q R: E ZL: Z ZR: C\nPress left stick: F Press right stick: G\n+ (menu): Return − (map): Tab\n\nMouse: left click a target or the interface, right click = B, wheel scrolls lists.\nA connected controller works right away. This page stays in the Help menu." },
|
||||
{ "dmAppKeysText", "界面上的按键提示是手柄字母,键盘这样对应:\n\n确认(A):空格 或 J 返回(B):Esc 或 K\n回车:确认;页面底部有「+」提示时是 +(如起名后的「接受」)\n+(菜单 / 新角色):= 键 −(地图):Tab\n移动:W A S D(左摇杆) 十字键:方向键\nX:U Y:I L:Q R:E ZL:Z ZR:C\n按左摇杆:F 按右摇杆:G\n\n鼠标:左键点目标、界面、底部的按键提示和技能 / 药水格;右键 = 返回;滚轮滚列表。\n接上手柄可以直接用。这一页以后在「帮助」菜单里。", "On-screen button hints use controller letters. Keyboard mapping:\n\nConfirm (A): Space or J Back (B): Esc or K\nReturn: confirm; acts as + when the page shows a + hint (e.g. Accept after naming)\n+ (menu / new character): = key − (map): Tab\nMove: W A S D (left stick) D-pad: arrow keys\nX: U Y: I L: Q R: E ZL: Z ZR: C\nPress left stick: F Press right stick: G\n\nMouse: left 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." },
|
||||
};
|
||||
|
||||
@@ -309,6 +309,21 @@ static uint64_t legend_at(uint8_t *b, uint64_t w, uint64_t xy, int dep) {
|
||||
uint64_t ch = rd8(w + 0x58), n = rd8(w + 0x60); for (uint64_t i = n < 256 ? n : 0; ch && i-- > 0; ) { uint64_t r = legend_at(b, rd8(ch + 8 * i), xy, dep + 1); if (r) return r; }
|
||||
return 0;
|
||||
}
|
||||
// 屏上最上面那条看得见的按键提示条里有没有某个键帽(如 + = 0xe005)。Mac 键盘的回车据此决定当 + 还是当确认(touch_mac.c)。只许游戏主线程调
|
||||
// Whether the topmost visible key-hint bar on screen contains a given key cap (e.g. + = 0xe005). Return on a Mac keyboard uses this to decide between + and confirm (touch_mac.c). Call only from the game main thread
|
||||
static uint64_t legend_top(uint8_t *b, uint64_t w, int dep) {
|
||||
if (!w || dep > 8 || !*(uint8_t *)(uintptr_t)(w + 0x50) || !*(uint8_t *)(uintptr_t)(w + 0x51)) return 0;
|
||||
uint64_t vt = rd8(w) - (uint64_t)(uintptr_t)b; if (vt == 0x20b7960 || vt == 0x20b7a30) return rd8(w + 0x88) && rd8(w + 0x90) && rd8(w + 0x90) <= 12 ? w : 0;
|
||||
uint64_t ch = rd8(w + 0x58), n = rd8(w + 0x60); for (uint64_t i = n < 256 ? n : 0; ch && i-- > 0; ) { uint64_t r = legend_top(b, rd8(ch + 8 * i), dep + 1); if (r) return r; }
|
||||
return 0;
|
||||
}
|
||||
int dm_padmode_legend_has(uint32_t glyph) {
|
||||
extern module_t g_mod[]; extern int g_nmod; uint8_t *b = NULL; for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) b = (uint8_t *)g_mod[i].base;
|
||||
uint64_t root = b ? rd8((uint64_t)(uintptr_t)(b + 0x2f05458)) : 0, lg = root ? legend_top(b, root, 0) : 0; if (!lg) return 0;
|
||||
{ const char *nm = (const char *)(uintptr_t)rd8(lg + 8); if (glyph == 0xe005 && nm && !strcmp(nm, "MainMenuLegend")) return 0; } // 主菜单例外:它的提示条有「+ 新角色」,但回车在主菜单要当确认(进入游戏);新角色用 = 键或鼠标点那一条 | main menu exception: its hint bar has "+ New Character", but Return on the main menu must act as confirm (enter the game); a new character uses the = key or a mouse click on that entry
|
||||
uint64_t arr = rd8(lg + 0x88), n = rd8(lg + 0x90); for (uint64_t i = 0; i < n; i++) if (*(int32_t *)(uintptr_t)(arr + 0x40 * i + 8) == 1 && *(uint32_t *)(uintptr_t)(arr + 0x40 * i) == glyph) return 1;
|
||||
return 0;
|
||||
}
|
||||
uint64_t dm_padmode_legend_click(float nx, float ny) {
|
||||
extern module_t g_mod[]; extern int g_nmod; uint8_t *b = NULL; for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) b = (uint8_t *)g_mod[i].base;
|
||||
if (!b || !g_cur) return 0; int W = *(int32_t *)(b + 0x211da38), H = *(int32_t *)(b + 0x211da3c); uint64_t root = rd8((uint64_t)(uintptr_t)(b + 0x2f05458)); if (!root || W <= 0 || H <= 0) return 0;
|
||||
@@ -325,10 +340,39 @@ uint64_t dm_padmode_legend_click(float nx, float ny) {
|
||||
if (*(int32_t *)(uintptr_t)(e + 8) == 1) for (unsigned k = 0; k < sizeof km / sizeof *km && !btn; k++) { // 键帽 → 键:照 legend_find 的比法,拿动作号建一个空字条目取它的键帽来比 | key cap -> key: the same comparison as legend_find, build an entry with empty text from the action number and take its key cap to compare
|
||||
uint64_t ent[8] = { 0 }; struct { const char *p; uint64_t n; } sv = { "", 0 }; ((void (*)(void *, int, int, void *))(b + 0xaa9358))(ent, km[k].act, 0, &sv); legend_free(b, ent);
|
||||
if ((int32_t)ent[1] == 1 && (uint32_t)ent[0] == gl) btn = km[k].btn; }
|
||||
if (!btn && gl == 0xe008) btn = DM_BTN_LS; // 按左摇杆(物品栏「打开魔盒」)同样没有动作号可比(实测 e008) | pressing the left stick (inventory "Open Cube") likewise has no action number to compare with (measured e008)
|
||||
if (!btn && gl == 0xe005) btn = DM_BTN_PLUS; // + 键没有对应的动作号可比(主菜单「+ 新角色」):直接认它的键帽码(实测 e005) | the + key has no action number to compare with (main menu "+ New Character"): recognise its key-cap code directly (measured e005)
|
||||
LOG("手柄提示条:鼠标点在第 %d 条(共 %llu 条,键帽 %x)→ %s", hit + 1, (unsigned long long)n, gl, btn ? "按它那个键" : "认不出是哪个键,不按");
|
||||
return btn;
|
||||
}
|
||||
// 鼠标点局内底部 HUD(Mac App):手柄版 HUD 上的东西不是可点控件(手柄各有专键),鼠标点上去原先被当成「点世界」。按在哪个控件上就按它对应的键:
|
||||
// 技能格 1–6 = A B Y X R ZR(屏上键帽的次序);腰带四格 = 十字键 左 上 下 右(原版对应,同 dm_touch_controls.c);中间的钮 = +(开功能页);跑 / 走钮 = 按左摇杆。
|
||||
// 血球、魔球、经验条、耐力条:没有对应的键,吃掉这一下(不许落到世界上去发令)。返回 0 = 没点在 HUD 上,1 = 按 *btn,2 = 吃掉不处理。只许游戏主线程调
|
||||
// Mouse clicks on the in-game bottom HUD (Mac App): the things on the gamepad-layout HUD are not clickable widgets (the gamepad has a dedicated key for each), and a mouse click on them used to be treated as "click the world". Pressing on a widget presses its corresponding key:
|
||||
// skill slots 1–6 = A B Y X R ZR (the order of the key caps on screen); the four belt cells = D-pad left up down right (as in the original, same as dm_touch_controls.c); the middle button = + (open the function page); the run / walk button = press the left stick.
|
||||
// Life orb, mana orb, experience bar, stamina bar: no corresponding key, so the click is swallowed (it must not fall through to the world and issue an order). Returns 0 = not on the HUD, 1 = press *btn, 2 = swallowed without action. Call only from the game main thread
|
||||
int dm_padmode_hud_click(float nx, float ny, uint64_t *btn) {
|
||||
extern module_t g_mod[]; extern int g_nmod; uint8_t *b = NULL; for (int i = 0; i < g_nmod; i++) if (!strcmp(g_mod[i].name, "main")) b = (uint8_t *)g_mod[i].base;
|
||||
if (!b || !g_cur) return 0; int W = *(int32_t *)(b + 0x211da38), H = *(int32_t *)(b + 0x211da3c); uint64_t root = rd8((uint64_t)(uintptr_t)(b + 0x2f05458)); if (!root || W <= 0 || H <= 0) return 0;
|
||||
if (*(volatile uint8_t *)(b + 0x2d5ff51) | *(volatile uint8_t *)(b + 0x2d5ff67)) return 0; // 游戏停着(暂停菜单、大秘境选层页这类借壳的面板开着——手势层的面板名单认不到后者):HUD 不认,免得点技能格变成在那一页上按 A | the game is stopped (pause menu, or a panel borrowing another shell such as the Greater Rift level-selection page is open - the gesture layer's panel list does not recognise the latter): the HUD is not recognised, so a click on a skill slot does not turn into pressing A on that page
|
||||
uint64_t hud = pm_find(root, "HUDPanel", 5); if (!hud || !*(uint8_t *)(uintptr_t)(hud + 0x50) || !*(uint8_t *)(uintptr_t)(hud + 0x51)) return 0; // pm_find 的第三个参数是起始深度:只看根的直接子面板 | the third argument of pm_find is the starting depth: look only at the direct child panels of the root
|
||||
uint64_t xy = (uint64_t)(uint32_t)(nx * W) | ((uint64_t)(uint32_t)(ny * H) << 32), ch = rd8(hud + 0x58), n = rd8(hud + 0x60);
|
||||
static const struct { const char *nm; uint64_t btn; } km[] = { { "SkillButton1", DM_BTN_A }, { "SkillButton2", DM_BTN_B }, { "SkillButton3", DM_BTN_Y }, { "SkillButton4", DM_BTN_X }, { "SkillButton5", DM_BTN_R }, { "SkillButton6", DM_BTN_ZR },
|
||||
{ "LevelUpButton", DM_BTN_PLUS }, { "RunButton", DM_BTN_LS }, { "RunButtonPrompt", DM_BTN_LS }, { "HealthBall", 0 }, { "ManaBall", 0 }, { "ExpBar", 0 }, { "StaminaBar", 0 }, { "SkillSwapIndicator", 0 }, { "LTButtonPrompt", 0 } };
|
||||
static const uint64_t belt[4] = { DM_BTN_LEFT, DM_BTN_UP, DM_BTN_DOWN, DM_BTN_RIGHT };
|
||||
#define HUD_HIT(w, q) (((int (*)(uint64_t, uint64_t))rd8(rd8(w) + 0x48))((w), (q)) & 1)
|
||||
int px = (int)(nx * W), py = (int)(ny * H);
|
||||
for (int pass = 0; pass < 2; pass++) // 先认有键的(跑 / 走钮被耐力条压着一部分),再认只吃掉的 | first recognise the ones with a key (the run / walk button is partly covered by the stamina bar), then the ones that are only swallowed
|
||||
for (uint64_t i = n < 64 ? n : 0; ch && i-- > 0; ) { uint64_t w = rd8(ch + 8 * i); if (!w || !*(uint8_t *)(uintptr_t)(w + 0x50)) continue; const char *nm = (const char *)(uintptr_t)rd8(w + 8); if (!nm) continue;
|
||||
if (!pass && !strcmp(nm, "Belt") && HUD_HIT(w, xy)) { // 腰带是一个控件、四格等宽(子控件只是四个键帽字):沿这一行量出它的左右边,按四等分取格 | the belt is one widget with four equal-width cells (the child widgets are only the four key-cap glyphs): measure its left and right edges along this row and pick the cell by quarters
|
||||
int l = px, r = px; while (l > 0 && HUD_HIT(w, (uint64_t)(uint32_t)(l - 2) | ((uint64_t)(uint32_t)py << 32))) l -= 2; while (r < W - 1 && HUD_HIT(w, (uint64_t)(uint32_t)(r + 2) | ((uint64_t)(uint32_t)py << 32))) r += 2;
|
||||
int k = r > l ? (px - l) * 4 / (r - l + 1) : 0; if (k < 0) k = 0; if (k > 3) k = 3; *btn = belt[k]; LOG("手柄 HUD:鼠标点在腰带第 %d 格(腰带 x %d–%d)→ 按十字键 %s", k + 1, l, r, k == 0 ? "LEFT" : k == 1 ? "UP" : k == 2 ? "DOWN" : "RIGHT"); return 1; }
|
||||
for (unsigned k = 0; k < sizeof km / sizeof *km; k++) if ((km[k].btn != 0) == !pass && !strcmp(nm, km[k].nm) && HUD_HIT(w, xy)) {
|
||||
*btn = km[k].btn; uint64_t kb = km[k].btn; const char *kn = kb == DM_BTN_A ? "A" : kb == DM_BTN_B ? "B" : kb == DM_BTN_Y ? "Y" : kb == DM_BTN_X ? "X" : kb == DM_BTN_R ? "R" : kb == DM_BTN_ZR ? "ZR" : kb == DM_BTN_PLUS ? "PLUS" : kb == DM_BTN_LS ? "LS" : "";
|
||||
if (kb) LOG("手柄 HUD:鼠标点在 %s → 按 %s", nm, kn); else LOG("手柄 HUD:鼠标点在 %s → 没有对应的键,这一下不处理", nm); return kb ? 1 : 2; } }
|
||||
#undef HUD_HIT
|
||||
return 0;
|
||||
}
|
||||
static void legend_pump(uint8_t *b, uint64_t frame) { // 游戏主线程每帧 | Game main thread, every frame
|
||||
static int miss, tot; static uint64_t logged; int test = getenv("DM_TEST_LEGEND") != NULL;
|
||||
// 测试开关 DM_TEST_LEGEND=<动作号>:<字>[,…]:手柄模式下一直声明这些条目;DM_TEST_LEGEND_OFF=<帧>:到这一帧起不再声明。DM_TEST_LEGEND_LOG=1:每 120 帧记一行提示条现状(不声明条目)
|
||||
|
||||
+15
-9
@@ -24,6 +24,7 @@
|
||||
// Get localized string main+0x7f5630(&{key, length}) (the game picks between the normal / legacy translation sets by setting). Client send packet main+0x2ceab0(packet, length).
|
||||
// Socket packets follow the client packets of a real socketing run (fm_ipadfull_k): 0x19 [item id][u32 x][u32 y][u32 page] (17 bytes, pick up to the cursor) → 0x28 [rune id][base id][u32 equipment slot 0][u32 page][u16 x][u16 y] (21 bytes, socket it).
|
||||
#include "hle.h"
|
||||
#include "dm_rwlv_core.h"
|
||||
#include "dm_i18n.h"
|
||||
#include "dm_actions.h"
|
||||
#include "dm_input.h"
|
||||
@@ -146,7 +147,7 @@ static uint64_t first_item(uint64_t u) { uint64_t c = u ? *(uint64_t *)(u + 0x90
|
||||
static struct { uint32_t base; int n; cand_t c[NROW]; int open; } g_list; // 打开着的清单 | The currently open list
|
||||
static int rune_lv(uint8_t *b, uint64_t t, int cls, int lvoff) { uint64_t ir = *(uint64_t *)(t + 0x15c0); uint32_t in = *(uint32_t *)(t + 0x15c8); return ir && cls >= 0 && (uint32_t)cls < in && lvoff >= 0 ? *(uint8_t *)(ir + (uint64_t)cls * 0x1c0 + lvoff) : 0; }
|
||||
static void rune_code(uint64_t t, int cls, char out[4]) { uint64_t ir = *(uint64_t *)(t + 0x15c0); uint32_t in = *(uint32_t *)(t + 0x15c8); memset(out, 0, 4); if (ir && cls >= 0 && (uint32_t)cls < in) memcpy(out, (const void *)(ir + (uint64_t)cls * 0x1c0 + 0x80), 3); }
|
||||
static int g_lvoff = -1; // 物品表行里「需要等级」的偏移:首次用到时按已知三颗符文的值(塔尔 17 / 艾斯 15 / 沙伊 29,misc.txt levelreq)在行里找,找不到就不显示等级 | Offset of "required level" in the item table row: on first use, searched for in the row using the known values of three runes (Tal 17 / Eth 15 / Shael 29, misc.txt levelreq); if not found, the level is not shown
|
||||
static int g_lvoff = -1; // 物品表行里「需求等级」(levelreq)的偏移:首次用到时按已知物品的原版值在行里找(dm_rwlv_core.c),找不到就不显示等级 | offset of "required level" (levelreq) in an item-table row: found on first use by the original values of known items (dm_rwlv_core.c); when not found no level is shown
|
||||
|
||||
// 这件物品能当符文之语底材吗(品质、孔、物品表标志;位置另判)
|
||||
// Can this item serve as a runeword base item (quality, sockets, item table flag; location is checked separately)
|
||||
@@ -163,10 +164,13 @@ static void count_have(uint8_t *b, uint64_t pl, int cls, have_t *h) {
|
||||
if (st) h->stack += st; else if (o) h->shared++; else if (pg == PG_INV) h->inv++; else if (pg == PG_CUBE) h->cube++; else h->stash++; }
|
||||
it = *(uint64_t *)(d + 0xb0); }
|
||||
}
|
||||
static int find_lvoff(uint64_t t) {
|
||||
uint64_t ir = *(uint64_t *)(t + 0x15c0); if (!ir || *(uint32_t *)(t + 0x15c8) < 640) return -1;
|
||||
for (int o = 0; o < 0x1c0; o++) if (*(uint8_t *)(ir + 631 * 0x1c0 + o) == 17 && *(uint8_t *)(ir + 629 * 0x1c0 + o) == 15 && *(uint8_t *)(ir + 637 * 0x1c0 + o) == 29) return o;
|
||||
return -1;
|
||||
static int find_lvoff(uint64_t t) { // 锚点与找法见 dm_rwlv_core.c;找不到(或不唯一)返回 -1,清单不显示等级 | anchors and the search are in dm_rwlv_core.c; returns -1 when not found (or not unique), and the list then shows no level
|
||||
uint64_t ir = *(uint64_t *)(t + 0x15c0); uint32_t in = *(uint32_t *)(t + 0x15c8); int o = ir ? dm_rw_find_lvoff((const uint8_t *)ir, in, 0x1c0) : -1;
|
||||
// 测试开关 DM_TEST_RW_LVDUMP=<文件>:把整张物品表逐行写成「物品码<TAB>读到的需求等级」,给 dm/ios/tools/rw_lvcheck.py 与原版 weapons / armor / misc 三张表全量核
|
||||
// Test switch DM_TEST_RW_LVDUMP=<file>: write the whole item table line by line as "item code<TAB>required level read", for dm/ios/tools/rw_lvcheck.py to check in full against the original weapons / armor / misc tables
|
||||
const char *e = getenv("DM_TEST_RW_LVDUMP"); FILE *f = e && o >= 0 ? fopen(e, "w") : NULL;
|
||||
if (f) { for (uint32_t i = 0; i < in; i++) { const uint8_t *r = (const uint8_t *)(ir + (uint64_t)i * 0x1c0); char c[5] = {0}; memcpy(c, r + 0x80, 4); for (int k = 0; k < 4; k++) if (c[k] == ' ') c[k] = 0; fprintf(f, "%s\t%u\n", c, r[o]); } fclose(f); LOG("符文之语:DM_TEST_RW_LVDUMP 写了 %u 行 → %s", in, e); }
|
||||
return o;
|
||||
}
|
||||
static int cand_cmp(const void *a, const void *b2) { const cand_t *x = a, *y = b2; if (x->ok != y->ok) return y->ok - x->ok; if (x->miss != y->miss) return x->miss - y->miss; return x->lv - y->lv; }
|
||||
// 列出这件底材能做的全部符文之语,并按此刻能取用的符文定 ok(能出按钮)
|
||||
@@ -174,7 +178,7 @@ static int cand_cmp(const void *a, const void *b2) { const cand_t *x = a, *y = b
|
||||
static int base_where(uint8_t *b, uint64_t pl, uint64_t it, int *page, int *x, int *y, int *slot);
|
||||
static int build_list(uint8_t *b, uint64_t it) {
|
||||
uint64_t t = tables(b, it), pl = player(b); if (!t || !pl || !base_ok(b, it, t)) return 0;
|
||||
if (g_lvoff < 0) { g_lvoff = find_lvoff(t); LOG("符文之语:物品表「需要等级」偏移 %#x", g_lvoff); }
|
||||
if (g_lvoff == -1) { g_lvoff = find_lvoff(t); if (g_lvoff < 0) LOG("【红】符文之语:物品表里没找到「需求等级」那一列(锚点物品对不上),清单不显示等级"); else LOG("符文之语:物品表「需求等级」偏移 %#x", g_lvoff); if (g_lvoff < 0) g_lvoff = -2; }
|
||||
int ns = sockets(b, it), stash_open = *(uint8_t *)(b + 0x2d5ff60) != 0, bp = 0, bx = 0, by = 0, bsl = 0, bw = base_where(b, pl, it, &bp, &bx, &by, &bsl);
|
||||
int can_put = bw && !(bw == 1 && bp == PG_STASH && !stash_open); // 底材在能镶的位置(储藏箱里的要箱子开着);共享仓库里的照列、不出按钮 | Base item is in a socketable location (one in the stash needs the stash open); one in the shared stash is still listed, without a button
|
||||
uint64_t rr = *(uint64_t *)(t + 0x1880), rn = *(uint64_t *)(t + 0x1888); g_list.n = 0;
|
||||
@@ -186,9 +190,11 @@ static int build_list(uint8_t *b, uint64_t it) {
|
||||
int good = 0; for (int k = 0; k < 6 && !good && !bad; k++) { int ty = *(const int16_t *)(e + 0x4a + 2 * k); if (ty && is_type(b, it, ty)) good = 1; }
|
||||
if (bad || !good) continue;
|
||||
cand_t *c = &g_list.c[g_list.n++]; memset(c, 0, sizeof *c); c->rec = (int)r; c->nr = nr; memcpy(c->cls, cls, sizeof cls); c->ok = can_put; int runes_ok = 1;
|
||||
c->lv = rune_lv(b, t, *(int32_t *)(it + 4), g_lvoff); // 需要等级 = 底材与各符文的最大值(原版做成以后的说明同此;物品单位 +4 = 物品类号) | Required level = max of the base item and each rune (same as the original game's description once formed; item unit +4 = item class id)
|
||||
int base_req = rune_lv(b, t, *(int32_t *)(it + 4), g_lvoff), rreq[6]; // 需要等级 = 底材与各符文需求等级的最大值(原版做成以后的说明同此;物品单位 +4 = 物品类号) | required level = the maximum of the required levels of the base item and each rune (the same as the original's description once made; item unit +4 = item class number)
|
||||
char key[64]; memcpy(key, e, 63); key[63] = 0; loc_tb(b, key, c->name, sizeof c->name);
|
||||
for (int k = 0; k < nr; k++) { int lv = rune_lv(b, t, cls[k], g_lvoff); if (lv > c->lv) c->lv = lv;
|
||||
for (int k = 0; k < nr; k++) rreq[k] = rune_lv(b, t, cls[k], g_lvoff);
|
||||
c->lv = dm_rw_need_level(base_req, rreq, nr);
|
||||
for (int k = 0; k < nr; k++) {
|
||||
int need = 0; for (int j = 0; j < nr; j++) need += cls[j] == cls[k]; have_t h; count_have(b, pl, cls[k], &h);
|
||||
int usable = h.inv + (stash_open ? h.stash + h.shared + h.stack : 0), total = h.inv + h.stash + h.shared + h.stack + h.cube;
|
||||
if (usable < need) { c->ok = 0; runes_ok = 0; }
|
||||
@@ -552,7 +558,7 @@ int dm_runeword_long_press(const dm_cursor_item_info *ci) { // 长按物品分
|
||||
uint64_t it = unit_item(b, ci->id); if (!it || *(uint32_t *)(it + 0xc) > 1) return 0;
|
||||
if (!build_list(b, it)) return 0;
|
||||
g_list.base = ci->id; g_list.open = 1; ui_show(b, 1); ui_fill(b, it); ui_layout(); g_check_at = 6;
|
||||
LOG("符文之语:长按 %s(id %u)→ 清单 %d 行(首行「%s」%s)", ci->code, ci->id, g_list.n, g_list.c[0].name, g_list.c[0].ok ? "可做" : "不可做");
|
||||
LOG("符文之语:长按 %s(id %u)→ 清单 %d 行(首行「%s」需要等级 %d %s)", ci->code, ci->id, g_list.n, g_list.c[0].name, g_list.c[0].lv, g_list.c[0].ok ? "可做" : "不可做");
|
||||
if (getenv("DM_TEST_RW_DESC") && !strcmp(getenv("DM_TEST_RW_DESC"), "all")) { // 测试开关 =all:表里每个 complete 的符文之语都生成一遍原版说明,记行数(定详情字号用) | Test switch =all: generate the original game's description once for every complete runeword in the table and log the line counts (used to pick the detail font size)
|
||||
uint8_t ver = *(uint8_t *)(b + 0x2127c48); uint64_t t = ver >= 1 && ver <= 3 ? *(uint64_t *)(b + 0x2d64a18 + ver * 16) : 0, rr = t ? *(uint64_t *)(t + 0x1880) : 0; uint32_t rn = t ? *(uint32_t *)(t + 0x1888) : 0;
|
||||
int mx = 0, mxr = -1, cnt = 0, fail = 0; static char d[4096];
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// 见 dm_rwlv_core.h。
|
||||
// 「需求等级」的偏移没有写死,按已知物品的原版值在行里找——锚点必须含「物品等级 ≠ 需求等级」的行:
|
||||
// 原先只用三颗符文(塔尔 17 / 艾斯 15 / 沙伊 29)当锚点,而符文的物品等级(misc.txt level)与需求等级(levelreq)33 颗里 32 颗是同一个数,
|
||||
// 先撞上的是排在前面的物品等级那一列;读符文没差,读底材就成了物品等级(塔盔 uhm:需求 59 被读成 79),清单里整页的需要等级偏高。
|
||||
// See dm_rwlv_core.h.
|
||||
// The offset of "required level" is not hard-coded; it is found in the row by the original values of known items - the anchors must include rows where "item level != required level":
|
||||
// previously only three runes (Tal 17 / Eth 15 / Shael 29) served as anchors, and for runes the item level (misc.txt level) and the required level (levelreq) are the same number for 32 of the 33,
|
||||
// so the first hit was the item-level column that comes earlier; reading runes made no difference, but reading a base item gave its item level (Spired Helm uhm: required 59 read as 79), and the whole page of required levels in the list was too high.
|
||||
#include "dm_rwlv_core.h"
|
||||
#include <string.h>
|
||||
|
||||
// 原版 armor.txt / misc.txt 的 levelreq(括号里是同一行的 level,两者不同的才分得开两列)
|
||||
// levelreq from the original armor.txt / misc.txt (in parentheses the level of the same row; only rows where the two differ can tell the two columns apart)
|
||||
static const struct { const char *code; uint8_t req; } k_anchor[] = {
|
||||
{ "uhm", 59 }, // 塔盔(79) | Spired Helm (79)
|
||||
{ "xhm", 25 }, // 翼盔(51) | Winged Helm (51)
|
||||
{ "ci3", 64 }, // 权冠(85) | Diadem (85)
|
||||
{ "urn", 66 }, // 宝冠(85) | Corona (85)
|
||||
{ "ulm", 51 }, // 武装盔(68) | Armet (68)
|
||||
{ "r07", 17 }, // 塔尔(17) | Tal (17)
|
||||
{ "r13", 29 }, // 沙伊(29) | Shael (29)
|
||||
};
|
||||
#define NANCHOR (int)(sizeof k_anchor / sizeof k_anchor[0])
|
||||
|
||||
int dm_rw_find_lvoff(const uint8_t *rows, uint32_t n, uint32_t rowsize) {
|
||||
const uint8_t *at[NANCHOR]; memset(at, 0, sizeof at);
|
||||
if (!rows || rowsize < 0x84) return -1;
|
||||
for (uint32_t i = 0; i < n; i++) { const uint8_t *r = rows + (uint64_t)i * rowsize;
|
||||
for (int k = 0; k < NANCHOR; k++) if (!at[k] && !memcmp(r + 0x80, k_anchor[k].code, 3) && (r[0x83] == 0 || r[0x83] == ' ')) at[k] = r; }
|
||||
for (int k = 0; k < NANCHOR; k++) if (!at[k]) return -1;
|
||||
int found = -1;
|
||||
for (uint32_t o = 0; o < rowsize; o++) { int ok = 1; for (int k = 0; k < NANCHOR && ok; k++) ok = at[k][o] == k_anchor[k].req;
|
||||
if (ok) { if (found >= 0) return -1; found = (int)o; } }
|
||||
return found;
|
||||
}
|
||||
|
||||
int dm_rw_need_level(int base_req, const int *rune_req, int n) { int lv = base_req; for (int i = 0; i < n; i++) if (rune_req[i] > lv) lv = rune_req[i]; return lv; }
|
||||
@@ -0,0 +1,12 @@
|
||||
// 符文之语清单的「需要等级」:纯算法部分(不碰游戏内存布局以外的东西,宿主单测 tests/t_rwlv.c 直接链)
|
||||
// "Required level" in the runeword list: the pure-algorithm part (touches nothing beyond the game's memory layout; the host unit test tests/t_rwlv.c links it directly)
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
// 在物品表(weapons + armor + misc 合成的一张,每行 rowsize 字节,行内 +0x80 起 3 字节是物品码)里找「需求等级」那一个字节的行内偏移。
|
||||
// 找不到或不唯一返回 -1。
|
||||
// Find the in-row offset of the one byte holding "required level" in the item table (weapons + armor + misc combined, rowsize bytes per row, with the 3-byte item code at +0x80 in the row).
|
||||
// Returns -1 when not found or not unique.
|
||||
int dm_rw_find_lvoff(const uint8_t *rows, uint32_t n, uint32_t rowsize);
|
||||
// 做成以后的需要等级 = 底材需求等级与各符文需求等级的最大值
|
||||
// Required level once made = the maximum of the base item's required level and each rune's required level
|
||||
int dm_rw_need_level(int base_req, const int *rune_req, int n);
|
||||
+43
-3
@@ -20,6 +20,7 @@ __attribute__((constructor)) static void ui_shift_reg(void) { mtl_set_ui_rect_fn
|
||||
void dm_touch_host_live_enable(void); void dm_touch_host_live(int op, float nx, float ny); // touch_mac.c
|
||||
static int g_live; // App 形态(或 DM_TOUCH_LIVE=1):鼠标进我们的触屏状态机;否则照旧当原版触摸屏的一个触点 | App form (or DM_TOUCH_LIVE=1): the mouse goes into our touch state machine; otherwise it stays a single touch point of the original touch screen as before
|
||||
static CAMetalLayer *g_layer;
|
||||
static NSWindow *g_win;
|
||||
static NSView *g_view;
|
||||
// 窗口不是 16:9(拉伸窗口、全屏到 16:10 的屏):游戏画面保持 16:9 居中,四周留黑边;鼠标位置按游戏画面这一块算
|
||||
// The window is not 16:9 (stretched window, full screen on a 16:10 display): the game picture stays 16:9 and centred with black bars around it; the mouse position is computed against the game picture
|
||||
@@ -50,6 +51,7 @@ static void app_quit(const char *why) {
|
||||
}
|
||||
if (last != c0 && asked) LOG("窗口:退出前等游戏存盘 %.0f ms,期间存档提交 %llu 次%s", (now_ns() - t0) / 1e6, (unsigned long long)(last - c0), paused ? "(原先停在暂停菜单 / 面板,已放开)" : "");
|
||||
else LOG("【红】窗口:未存盘退出——3 秒内没等到存档提交(%s%s)", asked ? "已请游戏存盘" : "一直没到能请存盘的状态(读取画面?)", paused ? ",原先暂停着、已放开" : "");
|
||||
{ int dm_cloud_flush_wait(double sec); dm_cloud_flush_wait(10); } // 存盘之后把这一局传上 iCloud 再退(没开同步时立即返回) | after saving, upload this session to iCloud before quitting (returns immediately when sync is off)
|
||||
dm_host_shutdown(why);
|
||||
}
|
||||
static const char *ui(const char *k) { const char *dm_ui(const char *key); return dm_ui(k); }
|
||||
@@ -84,7 +86,10 @@ static int key_bit(unsigned short code) {
|
||||
case 38: return 0; case 40: return 1; case 32: return 2; case 34: return 3; // J K U I → A B X Y
|
||||
case 3: return 4; case 5: return 5; // F G → 按摇杆 | F G → press stick
|
||||
case 12: return 6; case 14: return 7; case 6: return 8; case 8: return 9; // Q E Z C → L R ZL ZR
|
||||
case 36: return 10; case 48: return 11; // 回车 Tab → + − | Return Tab → + −
|
||||
case 36: return g_live ? 40 : 10; case 48: return 11; // 回车 Tab → + −(App 形态:回车交给 touch_mac.c 按当前页决定是 + 还是确认,见那里) | Return Tab -> + - (App form: Return is handed to touch_mac.c, which decides by the current page whether it is + or confirm, see there)
|
||||
case 24: case 69: return 10; // = 键(+ 那个键)、小键盘 + → + | the = key (the one with +) and keypad + -> +
|
||||
case 49: return 0; // 空格 → A(确认) | Space -> A (confirm)
|
||||
case 53: return g_live ? 41 : -1; // Esc → 返回(App 形态;局内没有面板时是开功能页,touch_mac.c) | Esc -> back (App form; with no panel open in game it opens the function page, touch_mac.c)
|
||||
case 123: return 12; case 126: return 13; case 124: return 14; case 125: return 15; // ← ↑ → ↓
|
||||
}
|
||||
return -1;
|
||||
@@ -113,7 +118,7 @@ void front_run(void (*guest)(void)) {
|
||||
NSWindow *win = [[NSWindow alloc] initWithContentRect:r
|
||||
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable
|
||||
backing:NSBackingStoreBuffered defer:NO];
|
||||
win.title = @"D2R Mobile";
|
||||
win.title = @"D2R Mobile"; win.restorable = NO; g_win = win;
|
||||
NSView *v = win.contentView; g_view = v;
|
||||
v.wantsLayer = YES; v.layer.backgroundColor = CGColorGetConstantColor(kCGColorBlack);
|
||||
win.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary; win.contentMinSize = NSMakeSize(640, 360);
|
||||
@@ -173,6 +178,36 @@ void front_run(void (*guest)(void)) {
|
||||
{ const char *e; // 测试(没人点窗口时用):DM_TEST_WINSIZE=宽x高 设内容区大小;DM_TEST_FULLSCREEN_AT=<秒> 进全屏;DM_TEST_QUIT_AT=<秒> 走一次退出 | Tests (for when nobody is there to click the window): DM_TEST_WINSIZE=WxH sets the content size; DM_TEST_FULLSCREEN_AT=<seconds> enters full screen; DM_TEST_QUIT_AT=<seconds> goes through one quit
|
||||
int w, h; if ((e = getenv("DM_TEST_WINSIZE")) && sscanf(e, "%dx%d", &w, &h) == 2) { [win setContentSize:NSMakeSize(w, h)]; layout_game(); }
|
||||
if ((e = getenv("DM_TEST_FULLSCREEN_AT"))) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(atof(e) * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [win toggleFullScreen:nil]; });
|
||||
// DM_TEST_NSMOUSE=<文件>:合成真正的系统鼠标事件(NSEvent)投进 App 的事件队列,走与真人点击同一条分发路(事件监视器 → 换算 → 状态机),不经测试入口。
|
||||
// 每行「秒 down|move|up x,y」,x,y 是内容区里的点(左上角为原点;窗口缺省 1280×720),时刻自窗口建好起算
|
||||
// DM_TEST_NSMOUSE=<file>: synthesise real system mouse events (NSEvent) and post them to the App's event queue, going through the same dispatch path as a person clicking (event monitor -> conversion -> state machine), not through the test entry.
|
||||
// Each line is "<seconds> down|move|up x,y", where x,y is a point in the content area (origin at top-left; the window defaults to 1280x720), and time counts from when the window is created
|
||||
if ((e = getenv("DM_TEST_NSMOUSE"))) { NSString *txt = [NSString stringWithContentsOfFile:@(e) encoding:NSUTF8StringEncoding error:nil]; NSTimeInterval t0 = NSProcessInfo.processInfo.systemUptime; int n = 0;
|
||||
dispatch_queue_t tq = dispatch_queue_create("dm.test.nsevent", DISPATCH_QUEUE_SERIAL); // 不排在主队列上:我们自己的弹框是在主队列的一个块里跑模态循环的,那期间主队列上别的块不执行,事件就投不进弹框 | not queued on the main queue: our own dialog runs its modal loop inside a block on the main queue, during which other blocks on the main queue do not execute, so events could not be delivered into the dialog
|
||||
for (NSString *ln in [txt componentsSeparatedByString:@"\n"]) { double sec, x = 0, y = 0; char op[8];
|
||||
if (sscanf(ln.UTF8String, "%lf %7s %lf,%lf", &sec, op, &x, &y) < 2 || ln.UTF8String[0] == '#') continue; n++;
|
||||
if (!strcmp(op, "key") || !strcmp(op, "type")) { // 「秒 key <键码>」:合成一次真正的键盘按下 / 0.08 秒后松开(键码 = 苹果的虚拟键码,如回车 36、Tab 48、J 38);「秒 type <字>」:逐字打字。 | "<seconds> key <key code>": synthesise a real key press / release 0.08 s later (key code = Apple virtual key code, e.g. Return 36, Tab 48, J 38); "<seconds> type <text>": type character by character.
|
||||
// 都投给当时的键窗口(真键盘就是这样:弹着输入框时进输入框),并记一行键窗口是不是游戏窗口
|
||||
// All are posted to the key window at that moment (which is what a real keyboard does: into the input field while it is shown), and one line records whether the key window is the game window
|
||||
int ty = !strcmp(op, "type"); char word[64] = ""; if (ty) sscanf(ln.UTF8String, "%*lf %*7s %63s", word); NSString *chars = ty ? @(word) : (x == 36 ? @"\r" : @"");
|
||||
if (ty) { // 打字:在主线程的运行循环里执行(模态框开着时也走——主队列那时不走),记下第一响应者是谁,再把字经响应链送进去(等于输入法提交了这些字) | typing: executed in the main thread's run loop (which also runs while a modal dialog is open - the main queue does not), noting who the first responder is, then sending the text through the responder chain (as if an input method committed it)
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(sec * NSEC_PER_SEC)), tq, ^{ CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, ^{
|
||||
NSWindow *kw = NSApp.keyWindow; id fr = kw.firstResponder; BOOL ok = [NSApp sendAction:@selector(insertText:) to:nil from:chars];
|
||||
LOG("DM_TEST_NSMOUSE:%.2f 秒打字「%s」(键窗口%s,第一响应者 %s,%s)", NSProcessInfo.processInfo.systemUptime - t0, chars.UTF8String, kw == win ? "是游戏窗口" : kw ? "是弹框" : "没有", fr ? NSStringFromClass([fr class]).UTF8String : "无", ok ? "有人收" : "没人收"); });
|
||||
CFRunLoopWakeUp(CFRunLoopGetMain()); });
|
||||
continue; }
|
||||
for (NSUInteger ci = 0; ci < (ty ? chars.length : 1); ci++) { NSString *one = ty ? [chars substringWithRange:NSMakeRange(ci, 1)] : chars; double at = sec + ci * 0.15;
|
||||
for (int dn = 1; dn >= 0; dn--) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)((at + (dn ? 0 : 0.08)) * NSEC_PER_SEC)), tq, ^{ NSWindow *kw = NSApp.keyWindow;
|
||||
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; }
|
||||
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)
|
||||
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_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)
|
||||
@@ -205,8 +240,13 @@ int front_text_input(const char *title, const char *sub, const char *guide, cons
|
||||
NSTextField *f = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 300, 24)];
|
||||
f.stringValue = initial ? @(initial) : @"";
|
||||
if (guide && *guide) f.placeholderString = @(guide);
|
||||
a.accessoryView = f; a.window.initialFirstResponder = f;
|
||||
a.accessoryView = f; [a layout]; a.window.initialFirstResponder = f;
|
||||
f.target = a.buttons.firstObject; f.action = @selector(performClick:); // 在输入框里按回车 = 点「确定」(明确接上,不靠系统把回车转给缺省按钮) | pressing Return in the input field = clicking "OK" (wired explicitly, not relying on the system forwarding Return to the default button)
|
||||
// 弹框出来后光标要在输入框里:只指定「初始第一响应者」不生效(实测弹出后第一响应者是弹框自己,要先点一下输入框才能打字),等模态循环转起来再显式指定一次
|
||||
// The cursor must be in the input field once the dialog appears: specifying only the "initial first responder" does not work (measured: after it appears the first responder is the dialog itself, and the field has to be clicked before typing), so it is specified explicitly once more after the modal loop starts running
|
||||
CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, ^{ [a.window makeFirstResponder:f]; });
|
||||
r = [a runModal] == NSAlertFirstButtonReturn;
|
||||
[g_win makeKeyAndOrderFront:nil]; // 弹框关掉后把游戏窗口显式设回键窗口(系统通常自己会还,保险) | after the dialog closes, explicitly make the game window key again (the system usually returns it by itself; this is for safety)
|
||||
text = f.stringValue;
|
||||
});
|
||||
if (!r) return 0;
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ void dm_host_preload_start(int argc, char **argv) {
|
||||
int dm_app_bootstrap(int *argc, char ***argv); // app_mac.m:包成 .app 双击起时备好环境与参数;命令行起原样 | app_mac.m: when packaged as an .app and started by double-click, prepare the environment and arguments; command-line starts are unchanged
|
||||
int main(int argc, char **argv) {
|
||||
#if TARGET_OS_OSX // iOS 包也编这个文件(入口由外壳调),那边没有 app_mac.m | The iOS package compiles this file too (the entry is called by the shell); there is no app_mac.m on that side
|
||||
dm_app_bootstrap(&argc, &argv);
|
||||
if (dm_app_bootstrap(&argc, &argv)) { void dm_cloud_boot(void); dm_cloud_boot(); } // App 形态:挂存档之前先做一次 iCloud 同步(同 iOS 壳的启动次序);取不到容器 / 测试存档时它自己记一行就返回 | App form: do one iCloud sync before mounting the save (same startup order as the iOS shell); when the container cannot be obtained / with a test save it logs one line and returns
|
||||
#endif
|
||||
if (getenv("DM_PRELOAD")) dm_host_preload_start(argc, argv); // Mac 上验证提前起跑的路径(iOS 由 App 的 main() 调) | Exercise the early-start path on Mac (on iOS it is called from the App's main())
|
||||
if (atomic_load(&g_pre.started)) {
|
||||
|
||||
@@ -4,7 +4,7 @@ DM_ROOT ?= $(HOME)/dm-work
|
||||
PY ?= $(DM_ROOT)/build/cache/dm/venv/bin/python
|
||||
EXEFS ?= $(DM_ROOT)/data/switch/3.3.94012/Update/ExeFS
|
||||
B = build
|
||||
run: $(B)/t_thread_leak $(B)/t_rift_clock $(B)/t_textbox $(B)/t_padmap $(B)/t_touch $(B)/t_hid_receipt $(B)/t_hid_script $(B)/t_touch_mac $(B)/t_oe $(B)/t_fs $(B)/t_fs_case $(B)/t_romfs_validate $(B)/t_audio $(B)/t_audio_spsc $(B)/t_swkbd $(B)/t_altstack $(B)/t_movie $(B)/t_condvar $(B)/t_condvar_old $(B)/t_target_rank $(B)/t_hud_dead $(B)/t_namegen $(B)/t_modetx $(B)/t_unit_level $(B)/t_widget $(B)/t_doorspot $(B)/t_cloudsync $(B)/t_i18n $(B)/main.orig.bin $(B)/subsdk0.orig.bin
|
||||
run: $(B)/t_thread_leak $(B)/t_rift_clock $(B)/t_textbox $(B)/t_rwlv $(B)/t_padmap $(B)/t_touch $(B)/t_hid_receipt $(B)/t_hid_script $(B)/t_touch_mac $(B)/t_oe $(B)/t_fs $(B)/t_fs_case $(B)/t_romfs_validate $(B)/t_audio $(B)/t_audio_spsc $(B)/t_swkbd $(B)/t_altstack $(B)/t_movie $(B)/t_condvar $(B)/t_condvar_old $(B)/t_target_rank $(B)/t_hud_dead $(B)/t_namegen $(B)/t_modetx $(B)/t_unit_level $(B)/t_widget $(B)/t_doorspot $(B)/t_cloudsync $(B)/t_i18n $(B)/main.orig.bin $(B)/subsdk0.orig.bin
|
||||
python3 native_write_scan.py --selftest ..
|
||||
python3 mode_scan.py ../..
|
||||
python3 ../../ios/tools/dm_i18n.py --check
|
||||
@@ -12,6 +12,7 @@ run: $(B)/t_thread_leak $(B)/t_rift_clock $(B)/t_textbox $(B)/t_padmap $(B)/t_to
|
||||
$(B)/t_thread_leak
|
||||
$(B)/t_rift_clock
|
||||
$(B)/t_textbox
|
||||
$(B)/t_rwlv
|
||||
$(B)/t_touch
|
||||
$(B)/t_hid_script 2>/dev/null
|
||||
$(B)/t_hid_receipt 2>/dev/null
|
||||
@@ -45,6 +46,8 @@ $(B)/t_hud_dead: t_hud_dead.c ../dm_hud.h | $(B)
|
||||
clang -O1 -Wall -Werror -I.. -o $@ t_hud_dead.c
|
||||
$(B)/t_textbox: t_textbox.c ../dm_textbox_core.c ../dm_textbox_core.h | $(B)
|
||||
clang -O1 -Wall -Werror -o $@ t_textbox.c ../dm_textbox_core.c
|
||||
$(B)/t_rwlv: t_rwlv.c ../dm_rwlv_core.c ../dm_rwlv_core.h | $(B)
|
||||
clang -O1 -Wall -Werror -o $@ t_rwlv.c ../dm_rwlv_core.c
|
||||
$(B)/t_doorspot: t_doorspot.c ../dm_doorspot.h | $(B)
|
||||
clang -O1 -Wall -Werror -I.. -o $@ t_doorspot.c
|
||||
$(B)/t_widget: t_widget.c ../dm_widget.h | $(B)
|
||||
|
||||
@@ -40,7 +40,7 @@ else:
|
||||
if name not in on_line and name not in both: red.append('dm_cursor.c 定义了 %s,但每帧那一行和「两种模式都跑」单子上都没有它' % name)
|
||||
|
||||
# ---- 2 ----
|
||||
PADMODE = {'host/dm_cursor.c': 8, 'host/dm_custom.c': 2, 'host/dm_kills.c': 2, 'host/dm_rift_ui.c': 4, 'host/dm_runeword.c': 3, 'host/dm_vault_ui.c': 1, 'host/dm_update.c': 2, 'host/hle_tact.c': 1}
|
||||
PADMODE = {'host/dm_cursor.c': 9, 'host/dm_custom.c': 2, 'host/dm_kills.c': 2, 'host/dm_rift_ui.c': 4, 'host/dm_runeword.c': 3, 'host/dm_vault_ui.c': 1, 'host/dm_update.c': 2, 'host/hle_tact.c': 1}
|
||||
AUTOKEY = {'host/dm_cursor.c': 38, 'host/dm_rift_ui.c': 6, 'host/hle_hid.c': 2, 'ios/Sources/front_ios.m': 4}
|
||||
def count(pat, skip_defs):
|
||||
out = {}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// 符文之语清单「需要等级」:找列与取最大值。期望值全部取自原版数据表手算(armor.txt / misc.txt 的 levelreq、runes.txt 的配方),不跑被测实现算。
|
||||
// 底材:塔盔 uhm 需求 59(物品等级 79)、翼盔 xhm 25(51)、权冠 ci3 64(85)、宝冠 urn 66(85)、武装盔 ulm 51(68)、头盔 hlm 0(11)
|
||||
// 符文:塔尔 r07 17、书尔 r10 23、索尔 r12 27、沙伊 r13 29、艾欧 r16 35、蓝姆 r20 43、伊斯特 r24 51
|
||||
// "Required level" in the runeword list: finding the column and taking the maximum. All expected values are worked out by hand from the original data tables (levelreq in armor.txt / misc.txt, recipes in runes.txt), not by running the implementation under test.
|
||||
// Bases: Spired Helm uhm requires 59 (item level 79), Winged Helm xhm 25 (51), Diadem ci3 64 (85), Corona urn 66 (85), Armet ulm 51 (68), Helm hlm 0 (11)
|
||||
// Runes: Tal r07 17, Thul r10 23, Sol r12 27, Shael r13 29, Io r16 35, Lem r20 43, Ist r24 51
|
||||
#include "../dm_rwlv_core.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
static int fails;
|
||||
#define CHECK(c) do { if (!(c)) { printf("FAIL %s:%d %s\n", __FILE__, __LINE__, #c); fails++; } } while (0)
|
||||
#define ROW 0x1c0
|
||||
static uint8_t tab[16][ROW]; static int nrow;
|
||||
// 造一行:物品码在 +0x80,「物品等级」放在 lv_off,「需求等级」放在 req_off;其余字节填与等级无关的值
|
||||
// Build one row: item code at +0x80, "item level" at lv_off, "required level" at req_off; the remaining bytes are filled with values unrelated to levels
|
||||
static void row(const char *code, uint8_t level, uint8_t req, int lv_off, int req_off) { uint8_t *r = tab[nrow++]; memset(r, 0xee, ROW); memset(r + 0x80, 0, 4); memcpy(r + 0x80, code, 3); r[lv_off] = level; r[req_off] = req; }
|
||||
static void build(int lv_off, int req_off) { nrow = 0; memset(tab, 0, sizeof tab);
|
||||
row("hlm", 11, 0, lv_off, req_off); row("xhm", 51, 25, lv_off, req_off); row("uhm", 79, 59, lv_off, req_off); row("ci3", 85, 64, lv_off, req_off); row("urn", 85, 66, lv_off, req_off); row("ulm", 68, 51, lv_off, req_off);
|
||||
row("r05", 15, 15, lv_off, req_off); row("r07", 17, 17, lv_off, req_off); row("r13", 29, 29, lv_off, req_off); }
|
||||
int main(void) {
|
||||
// 一、找列:物品等级那一列排在需求等级前面(线上缺陷的现场:旧找法只看符文,先撞上物品等级)——必须返回需求等级那一列
|
||||
// Part one, finding the column: the item-level column comes before the required-level column (the scene of the reported defect: the old search looked only at runes and hit item level first) - the required-level column must be returned
|
||||
build(0x57, 0x5b); CHECK(dm_rw_find_lvoff(&tab[0][0], (uint32_t)nrow, ROW) == 0x5b);
|
||||
// 两列次序反过来也一样
|
||||
// The same with the two columns in the opposite order
|
||||
build(0x5b, 0x57); CHECK(dm_rw_find_lvoff(&tab[0][0], (uint32_t)nrow, ROW) == 0x57);
|
||||
// 找到的那一列读塔盔必须是 59,不是 79
|
||||
// The column found must read 59 for the Spired Helm, not 79
|
||||
build(0x57, 0x5b); { int o = dm_rw_find_lvoff(&tab[0][0], (uint32_t)nrow, ROW); CHECK(o >= 0 && tab[2][o] == 59); }
|
||||
// 负对照:表里缺锚点物品(只剩符文)→ 找不到;需求等级那一列被改坏一行 → 找不到;空表 → 找不到
|
||||
// Negative controls: anchor items missing from the table (only runes left) -> not found; one row of the required-level column corrupted -> not found; empty table -> not found
|
||||
build(0x57, 0x5b); CHECK(dm_rw_find_lvoff(&tab[6][0], 3, ROW) == -1);
|
||||
build(0x57, 0x5b); tab[2][0x5b] = 60; CHECK(dm_rw_find_lvoff(&tab[0][0], (uint32_t)nrow, ROW) == -1);
|
||||
CHECK(dm_rw_find_lvoff(NULL, 0, ROW) == -1);
|
||||
// 二、需要等级 = max(底材需求, 各符文需求)。线上图里的四条(塔盔 3 孔):
|
||||
// Part two: required level = max(base requirement, each rune's requirement). The four entries in the reported screenshot (3-socket Spired Helm):
|
||||
{ int hearth[] = {29, 35, 23}, cure[] = {29, 35, 17}, bulwark[] = {29, 35, 27}, delirium[] = {43, 51, 35};
|
||||
CHECK(dm_rw_need_level(59, hearth, 3) == 59); // 壁炉:夏 + 艾欧 + 书尔 | Hearth: Shael + Io + Thul
|
||||
CHECK(dm_rw_need_level(59, cure, 3) == 59); // 解药:夏 + 艾欧 + 塔尔 | Cure: Shael + Io + Tal
|
||||
CHECK(dm_rw_need_level(59, bulwark, 3) == 59); // 壁垒:夏 + 艾欧 + 索尔 | Bulwark: Shael + Io + Sol
|
||||
CHECK(dm_rw_need_level(59, delirium, 3) == 59); // 迷狂:蓝姆 + 伊斯特 + 艾欧 | Delirium: Lem + Ist + Io
|
||||
// 别的底材:符文盖过底材 / 底材盖过符文各两条
|
||||
// Other bases: two cases each of runes outweighing the base / the base outweighing the runes
|
||||
CHECK(dm_rw_need_level(25, hearth, 3) == 35); // 壁炉做在翼盔(25)上:艾欧 35 | Hearth made in a Winged Helm (25): Io 35
|
||||
CHECK(dm_rw_need_level(25, delirium, 3) == 51); // 迷狂做在翼盔上:伊斯特 51 | Delirium made in a Winged Helm: Ist 51
|
||||
CHECK(dm_rw_need_level(66, delirium, 3) == 66); // 迷狂做在宝冠(66)上:底材 66 | Delirium made in a Corona (66): base 66
|
||||
CHECK(dm_rw_need_level(64, cure, 3) == 64); } // 解药做在权冠(64)上:底材 64 | Cure made in a Diadem (64): base 64
|
||||
CHECK(dm_rw_need_level(0, NULL, 0) == 0);
|
||||
if (fails) { printf("t_rwlv: %d 处失败\n", fails); return 1; }
|
||||
printf("t_rwlv OK\n"); return 0;
|
||||
}
|
||||
@@ -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; }
|
||||
uint64_t dm_padmode_legend_click(float nx, float ny) { (void)nx; (void)ny; return 0; }
|
||||
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
|
||||
uint64_t dm_padmode_page_keys(uint64_t m) { (void)m; return 0; } void dm_padmode_legend_hide(const char *l, int a) { (void)l; (void)a; } int dm_padmode_busy(void) { return 0; } uint64_t dm_padmode_page_held(void) { return 0; } void dm_padmode_page_pulse(uint64_t m) { (void)m; } void dm_padmode_ident_hint(int on) { (void)on; } void dm_padmode_legend(int a, const char *t) { (void)a; (void)t; } const char *dm_str(uint8_t *b, const char *k) { (void)b; return k; } // 手柄页键 / 提示条 / 取串的桩(个人仓库手柄翻页用,触屏下不走) | Stubs for controller page keys / button legend / string fetch (used by controller paging of the personal stash, not reached under touch)
|
||||
|
||||
@@ -90,4 +90,4 @@ int dm_runeword_long_press(const void *ci) { (void)ci; return 0; } // 符文
|
||||
int dm_runeword_list_open(void) { return 0; }
|
||||
void dm_runeword_button(const char *name) { (void)name; }
|
||||
void dm_runeword_list_close(void) {}
|
||||
uint64_t dm_padmode_legend_click(float nx, float ny) { (void)nx; (void)ny; return 0; } // 鼠标点按键提示条(dm_padmode.c):这些单测不带游戏映像,给空桩 | mouse click on the key-hint bar (dm_padmode.c): these unit tests carry no game image, so an empty stub is given
|
||||
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; } // 鼠标点按键提示条(dm_padmode.c):这些单测不带游戏映像,给空桩 | mouse click on the key-hint bar (dm_padmode.c): these unit tests carry no game image, so an empty stub is given
|
||||
|
||||
+26
-5
@@ -161,17 +161,38 @@ void dm_touch_host_game_start(uint64_t now) {
|
||||
|
||||
void dm_touch_host_step(uint64_t now, uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry) {
|
||||
if (!g_touch.ready) touch_init(now);
|
||||
if (g_live_on) { // Mac 键盘的回车与 Esc(front_mac.m 用两个游戏不认的高位送来):按下那一刻按当前页定成哪个手柄键,按住期间不变 | Return and Esc on a Mac keyboard (sent by front_mac.m as two high bits the game does not recognise): decided as a gamepad key by the current page at the moment of pressing, unchanged while held
|
||||
static uint64_t ent, esc; int dm_padmode_legend_has(uint32_t glyph), dm_game_paused(void), dm_uiscreen_ingame(void); uint64_t kb = *buttons; *buttons &= ~((1ull << 40) | (1ull << 41));
|
||||
// 回车:缺省 = 确认(A)——提示条写的是手柄字母,拿键盘的人按回车是想确认;当前页的提示条里有「+」这一条时 = +(起名页的「创建」等;主菜单除外,见 dm_padmode_legend_has)
|
||||
// 起名页另有一条:名字还没填时回车 = 输入名称(A),填过之后才是接受(+)——「回车弹框 → 打字 → 回车 → 回车创建」
|
||||
// Return: default = confirm (A) - the hint bar shows gamepad letters, and someone with a keyboard presses Return to confirm; when the current page's hint bar has a "+" entry = + ("Create" on the naming page and so on; except the main menu, see dm_padmode_legend_has)
|
||||
// The naming page has one more rule: before a name is filled in Return = Enter Name (A), and only afterwards is it Accept (+) - "Return opens the dialog -> type -> Return -> Return creates"
|
||||
if (!(kb & (1ull << 40))) ent = 0; else if (!ent) { int dm_ui_fe_name_wants_input(void); ent = !dm_ui_fe_name_wants_input() && dm_padmode_legend_has(0xe005) ? DM_BTN_PLUS : DM_BTN_A; }
|
||||
// Esc:返回(B);局内没有面板开着、游戏也没停着时 = 开功能页(+)——那时 B 是一格技能
|
||||
// Esc: back (B); with no panel open in game and the game not stopped = open the function page (+) - B is a skill slot then
|
||||
if (!(kb & (1ull << 41))) esc = 0; else if (!esc) esc = dm_uiscreen_ingame() && !g_touch.state.navigation_mode && !dm_game_paused() ? DM_BTN_PLUS : DM_BTN_B;
|
||||
*buttons |= ent | esc; }
|
||||
if (g_live_on) { // 真鼠标:前端页直通界面点击;局内并进事件表(拍 = 此刻),与脚本事件同一段处理 | Real mouse: on front-end pages it goes straight to a UI click; in game it joins the event table (tick = now) and is handled in the same pass as script events
|
||||
int dm_uiscreen_ingame(void); int in = dm_uiscreen_ingame(); static float px, py; unsigned h;
|
||||
if (in && !g_live_based) { g_live_based = 1; g_live_tick0 = touch_cur_tick(); if (!g_touch.based) { g_touch.started = 1; g_touch.based = 1; g_touch.loaded = 1; g_touch.tick_set = 1; g_touch.start_tick = g_live_tick0; g_touch.to_game_tick = g_live_tick0; } }
|
||||
if (!in) g_live_based = 0;
|
||||
while ((h = atomic_load(&g_live.head)) != atomic_load(&g_live.tail)) {
|
||||
int op = g_live.q[h % 64].op; float nx = g_live.q[h % 64].nx, ny = g_live.q[h % 64].ny; if (op != 2) { px = nx; py = ny; }
|
||||
// 按在按键提示条的某一条上:这一下不当点击,改成按那个键 4 拍(dm_padmode.c);吞到抬起为止
|
||||
// Pressed on an entry of the key-hint bar: this is not treated as a click but as pressing that key for 4 ticks (dm_padmode.c); swallowed until release
|
||||
{ uint64_t dm_padmode_legend_click(float, float); static int eat; uint64_t lb = op == 0 ? dm_padmode_legend_click(px, py) : 0;
|
||||
if (lb) { eat = 1; g_live_btn = lb; g_live_btn_until = touch_cur_tick() + 4; }
|
||||
if (eat) { if (op == 2) eat = 0; atomic_store(&g_live.head, h + 1); continue; } }
|
||||
// 按在按键提示条的某一条上:这一下不当点击,改成按那个键 4 拍(dm_padmode.c);按在局内底部 HUD 的技能格 / 腰带格 / 钮上:按住期间按着对应的键,抬起再放(至少 3 拍);
|
||||
// HUD 上没有对应键的东西(血球、魔球、经验条):吃掉。都吞到抬起为止
|
||||
// Pressed on an entry of the key-hint bar: this is not treated as a click but as pressing that key for 4 ticks (dm_padmode.c); pressed on a skill slot / belt cell / button of the in-game bottom HUD: the corresponding key is held while the mouse is down and released on mouse up (at least 3 ticks);
|
||||
// things on the HUD with no corresponding key (life orb, mana orb, experience bar): swallowed. All are swallowed until release
|
||||
{ uint64_t dm_padmode_legend_click(float, float); int dm_padmode_hud_click(float, float, uint64_t *); static int eat, hold; uint64_t lb = op == 0 ? dm_padmode_legend_click(px, py) : 0, hb = 0; int hk = op == 0 && !lb && in && !g_touch.state.navigation_mode ? dm_padmode_hud_click(px, py, &hb) : 0; /* 有面板开着:不认 HUD(面板底下那排 HUD 还画着) | a panel is open: the HUD is not recognised (the HUD row under the panel is still drawn) */
|
||||
if (lb) { eat = 1; hold = 0; g_live_btn = lb; g_live_btn_until = touch_cur_tick() + 4; }
|
||||
else if (hk == 1) { eat = 1; hold = 1; g_live_btn = hb; g_live_btn_until = touch_cur_tick() + 30 * 600; }
|
||||
else if (hk == 2) { eat = 1; hold = 0; }
|
||||
// 右上角小地图(同 iOS 壳):点它顶上区域名那一条(矩形高的 1/4)= 切到全屏地图;全屏地图开着时点 HUD 以外的任何地方 = 回到小地图。只在没有面板开着时认
|
||||
// Top-right minimap (same as the iOS shell): clicking the area-name strip at its top (1/4 of the rectangle's height) = switch to the full-screen map; with the full-screen map open, clicking anywhere outside the HUD = back to the minimap. Recognised only when no panel is open
|
||||
else if (op == 0 && in && !g_touch.state.navigation_mode) { int dm_ui_minimap_rect(float r[4]), dm_ui_map_is_full(void); void dm_ui_map_full(int on); float mr[4];
|
||||
if (dm_ui_map_is_full()) { dm_ui_map_full(0); eat = 1; hold = 0; fprintf(stderr, "[dm] 鼠标:全屏地图开着,点一下 → 回到小地图\n"); }
|
||||
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) { // 前端页:抬起时先问一次命中——落在页签上就走「点页签 = 按对应的手柄键」(页签不认鼠标点击;局内由手势层做同一件事),其余照旧发鼠标点击 | 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; }
|
||||
|
||||
Reference in New Issue
Block a user