Native macOS App (first version): dm/tools/mac_app.sh, docs/MAC.md

The Mac host can now be packaged as a double-click macOS App with keyboard, mouse and gamepad input, saves under Application Support, a first-launch resource-folder picker and save-before-quit. dm/tools/mac_app.sh builds it after ./setup.sh; by default the package carries no derived content and points at this machine's build outputs, so it runs only on the Mac that built it and needs only a local ad-hoc signature.

Nobody has played this version by hand yet; what was verified was run unattended. See docs/MAC.md.
This commit is contained in:
jhaizhou
2026-10-13 16:49:19 +08:00
parent e0f3bba1da
commit 6a2474d917
18 changed files with 548 additions and 23 deletions
+66
View File
@@ -0,0 +1,66 @@
# Playing on a Mac (macOS App, first version)
中文:[MAC.zh-CN.md](MAC.zh-CN.md)
On an Apple silicon Mac this project can be built into a native macOS App, `D2R Mobile.app`: double-click to start, with keyboard, mouse and gamepad all working. It runs the same game and the same features we added (rifts, the trove, the chronicle, the Custom page and so on), using the original game's gamepad UI.
**Up front: nobody has actually sat down and played this version yet.** Keyboard keys, a physical gamepad, the resource-folder dialog, ⌘Q and menu clicks, and how it feels in the hand — none of these five has been operated by a person. Everything described as "verified" below was run unattended: keys injected by a test script, the mouse through a test entry point, quit / full screen / window resizing through test switches. If you are among the first to try it, please open an issue and tell us how it went.
## Build
The prerequisites are the same as for the iOS route: your game files in place and `./setup.sh` finished (see "Getting started" on the front page). Then:
```bash
source ~/dm-work/build/cache/dm/venv/bin/activate
dm/tools/mac_app.sh
```
It takes a dozen seconds or so and produces `~/dm-work/out/macapp/D2R Mobile.app` (about 3 MB). To put it elsewhere: `dm/tools/mac_app.sh <output directory>`.
The App contains only our own program. The rewritten game program, the shader library and the UI overlay are made from your game files; they stay in your workspace (`~/dm-work`) and the App only records where they are — so **this App runs only on the Mac that built it**. Please do not copy it to anyone else, and do not delete the workspace. It is signed with a local ad-hoc signature: no developer account and no device registration are needed.
## First launch
Double-click `D2R Mobile.app`. The first launch asks you to choose the **game resource folder**: pick `~/dm-work/data/switch/3.3.94012/Update` (or the `RomFS` inside it); it must contain a `data` folder. A wrong choice is explained and you can pick again; a right one is remembered and not asked for again.
The key mapping is then shown once; afterwards it is always available under Help in the menu bar.
## Where things are
- 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.
## Keyboard ↔ gamepad
Button prompts on screen show gamepad letters; the keyboard keys are:
| Gamepad | Keyboard |
|---|---|
| Left stick (move) | W A S D |
| D-pad | Arrow keys |
| A confirm / B back / X / Y | J / K / U / I |
| L / R | Q / E |
| ZL / ZR | Z / C |
| Left stick press / right stick press | F / G |
| + (menu) / − (map) | Return / Tab |
Mouse: left click on a target or on the UI, right click = B (back / close panel), wheel scrolls lists. A gamepad works as soon as it is connected, alongside the keyboard.
The menu bar has View → Full Screen (⌃⌘F) and Quit (⌘Q). The window can be resized freely; the game picture stays 16:9 and centred.
## Quitting and saving
Closing the window, ⌘Q and Quit in the menu all save first and then quit, in any state: in game, with the pause menu open, with a panel open, in a loading screen and with the rift panel open were each verified once. It waits at most 3 seconds; if the save has not completed by then, the log records "quit without saving".
## How this version is operated
- **Move** with W A S D or the gamepad stick. A mouse click on a monster, NPC or object walks over and interacts; a click on empty ground does not move.
- **Items** — sorting, equipping, buying and selling — are handled with 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 J → press J again in the confirmation.
- **The UI** is the original gamepad UI, and the pages we added (the Custom page, the trove, the chronicle, rift floor selection and so on) are all in it.
## Not in this version yet
- Mouse click-to-move on the ground, and long-press / double-click / drag-and-drop on items with the mouse.
- The free town portal on the empty ZR slot of the gamepad.
- The rift task list on the left.
- iCloud save sync, update checks, sharing the diagnostic log.
+66
View File
@@ -0,0 +1,66 @@
# 在 Mac 上玩(macOS App,第一版)
English: [MAC.md](MAC.md)
Apple 芯片的 Mac 可以把本项目构建成一个原生的 macOS App:`D2R Mobile.app`,双击启动,键盘、鼠标、手柄都能用。它跑的是同一份游戏、同一套我们加的功能(秘境、珍宝匣、编年史、自定义页等),界面用的是原版的手柄版界面。
**先说在前面:这一版还没有人真的坐下来玩过。**键盘按键、实体手柄、选资源文件夹的对话框、⌘Q 与菜单点击、真人手感——这五项都没有人实际操作过。下面写「验过」的,都是无人值守跑出来的:按键用测试脚本注入,鼠标用测试入口注入,退出、全屏、改窗口大小用测试开关。欢迎第一批试用的人把结果开 Issue 告诉我们。
## 构建
前提与 iOS 那条路相同:游戏文件放到位,`./setup.sh` 跑完(见首页「开始使用」)。然后:
```bash
source ~/dm-work/build/cache/dm/venv/bin/activate
dm/tools/mac_app.sh
```
约十几秒,产出 `~/dm-work/out/macapp/D2R Mobile.app`(约 3 MB)。想放到别处:`dm/tools/mac_app.sh <输出目录>`。
这个 App 里只有我们自己的程序。改写后的游戏程序、着色器库、界面覆盖层都是从你的游戏文件做出来的,它们留在你的工作区(`~/dm-work`)里,App 只记着它们的位置——所以**这个 App 只能在构建它的这台 Mac 上跑**,请不要拷给别人,也不要删掉工作区。签名用的是本机临时签名,不需要开发者账号,也不需要登记设备。
## 第一次打开
双击 `D2R Mobile.app`。第一次启动会请你选**游戏资源文件夹**:选 `~/dm-work/data/switch/3.3.94012/Update`(或它里面的 `RomFS`)即可,里面要有 `data` 文件夹。选错了会说明原因并让你重选;选对之后会记住,下次不再问。
接着会弹一次键位对照表,之后在菜单栏「帮助」里随时能看。
## 东西放在哪
- 存档:`~/Library/Application Support/D2R Mobile/save`
- 日志:`~/Library/Logs/D2R Mobile/host.log`(上一次运行的是 `host.prev.log`)。报问题时请附上它。
## 键盘 ↔ 手柄
界面上的按键提示显示的是手柄字母,对应的键盘按键如下:
| 手柄 | 键盘 |
|---|---|
| 左摇杆(移动) | W A S D |
| 十字键 | 方向键 |
| A 确认 / B 返回 / X / Y | J / K / U / I |
| L / R | Q / E |
| ZL / ZR | Z / C |
| 按左摇杆 / 按右摇杆 | F / G |
| +(菜单)/ −(地图) | 回车 / Tab |
鼠标:左键点目标或界面,右键 = B(返回 / 关面板),滚轮滚列表。接上手柄直接可用,与键盘并存。
菜单栏有「显示 → 全屏(⌃⌘F)」和「退出(⌘Q)」。窗口可以随意拉大小,游戏画面保持 16:9 居中。
## 退出与存盘
关窗口、⌘Q、菜单里点退出,在任何状态下都会先存盘再退:局内、暂停菜单开着、面板开着、读取画面、秘境面板开着各验过一局。最多等 3 秒;到点还没存成,会在日志里记一行「未存盘退出」。
## 这一版的操作方式
- **移动**用 W A S D 或手柄摇杆。鼠标点到怪物、NPC、物件会走过去交互;点空地不会走。
- **物品**的整理、穿脱、买卖用键盘或手柄的光标操作:W A S D 把光标移到物品上,按底栏提示的键。例如在商人处买东西:光标移到货物上(底栏出现「A 购买」)→ 按 J → 确认框里再按 J。
- **界面**是原版的手柄版界面,我们加的页面(自定义页、珍宝匣、编年史、秘境选层等)都在里面。
## 这一版还没有的
- 鼠标点地面走路、鼠标对物品的长按 / 双击 / 拖放。
- 手柄上 ZR 空格的免费回城。
- 秘境左侧的任务栏。
- iCloud 存档同步、更新检查、分享诊断日志。