#wine #linux #war #公会 #文件 #x11 #json-file

程序+库 jokolink

一个通过在 wine 中运行并复制到 Linux 文件系统,以便 Linux 应用程序原生访问的 Guild Wars 2 MumbleLink 复制程序

13 个版本

0.4.0 2022 年 8 月 26 日
0.3.0 2021 年 9 月 25 日
0.2.6 2021 年 9 月 25 日
0.2.1 2021 年 7 月 21 日
0.1.23 2021 年 6 月 26 日

#163游戏

Download history 2/week @ 2024-03-10 110/week @ 2024-03-31

每月 72 次下载
jokolay 中使用

MIT 许可证

67KB
1K SLoC

jokolink

一个用于从 Guild Wars 2 MumbleLink 提取信息并将其复制到 Linux 的 /dev/shm 文件夹,以便原生 Linux 应用程序(主要是 jokolay)访问的程序

它还会获取 gw2 窗口的 x11 窗口 ID,并将其粘贴到 /dev/shm 中 mumblelink 数据的末尾。格式仅仅是 1193 字节的 useful mumblelink 数据和一个 isize(用于 gw2 的 x11 窗口 ID)。每帧将睡眠 5 毫秒(可配置),因此每秒最多复制 200 次。

命令行

以配置 json 文件的路径作为参数。例如:./jokolink.exe ./config.json 假设 jokolink.execonfig.json 都在当前目录中。

配置

乔克链接配置以 json 格式存储。

* loglevel: 
  default: "info"
  type: string
  possible_values: ["trace", "debug", "info", "warn", "error"]
  help: the log level of the application. 

* logdir: 
    default: "." // current working directory 
    type: directory path
    help: a path to a directory, where jokolink will create jokolink.log file

* mumble_link_names:
    default: ["MumbleLink"]
    type: array of strings
    help: names of mumble links to create and listen for. useful if you provide `-mumble` option to Guild Wars 2 for custom link name or if you use multi-boxing within the same prefix

* interval
    default: 5
    type: unsigned integer (positive integer)
    help: the interval to sleep after updating mumble link data. in milliseconds. 5 milliseconds is roughly 200 times per second which should be enough. 

* copy_dest_dir: 
    default: "z:\\dev\\shm"
    type: directory path
    help: the directory under which we will create files with the provided `mumble_link_names` and write the mumble data from the shared memory inside wine. lutris uses "z" drive to represent linux root "/". and /dev/shm is an in memory directory, so writing to files is basically just writing bytes to ram (not cached to disk filesystem).

提供的示例脚本为 run_jokolink.sh

#!/bin/bash
# WARNING!!! Jokolink will run forever unless someone else force closes it. 
# This behavior is necessary because gw2 might crash/restart itself within the same wine / lutris session. 
# so, we have no way of knowing when gw2 has quit completely within the same wine session or just restarting. 
# fortunately, lutris force closes all scripts when game exits. 


# copy this script and jokolink.exe into the wine prefix folder of gw2. and set it as the prelaunch script for gw2 in lutris. 
# lutris uses wine prefix folder as the current working directory, so keeping 
# everything relative to that will make things simpler. 

# We use a json file for configuration. if the path to config file provided doesn't exist, we just create a new config file in that place.
# Users can edit that configuration file as they see fit. documentation for the configuration can be found on the README page
# path to config file for jokolink. current directory is wine prefix, so a json file under that directory.
export config_path=./jokolink_config.json

# if jokolink crashes before initailizing logging (eg: due to bad config file), we have no way of getting errors from lutris, so 
# we output the crash stderr to this file, for easier debugging. 
# this command will use $WINE (set by lutris) and use the above options to run jokolink in background.
# remember that current directory is wine prefix, so jokolink.exe should be in that directory and the jokolink_cmd_output.txt will be created in that directory too.
$WINE './jokolink.exe' $config_path &>  jokolink_cmd_output.txt

Lutris 指令

  1. 在 Lutris 中右键单击 Guild Wars 2,然后单击“浏览文件”以打开前缀文件夹。
  2. jokolink.exerun_jokolink.sh 复制到该文件夹中。
  3. 再次在 Lutris 中右键单击 Guild Wars 2,然后单击“配置”。确保窗口底部的“显示高级选项”已勾选。
  4. 转到“系统选项”选项卡,向下滚动直至找到 Pre-launch script,单击“浏览”并选择我们粘贴到前缀文件夹中的 run_jokolink.sh 文件。
  5. 启动 Guild Wars 2,你应该会看到一个 /dev/shm/{link_name} 文件,其中 link_name 由 mumble link 名称替换(默认为 "MumbleLink")。
  6. 如果你找不到这样的文件,这意味着乔克链接可能未能启动,你可以检查前缀文件夹中的 jokolink.log 文件。
  7. 附带日志提出问题。

特性

当《 Guild Wars 2》关闭之前,Jokolink.exe 将持续在后台运行。然后,lutris 将使用 SIGTERM 信号杀死所有预启动脚本及其子进程。

没有 Lutris 的 Wine

Jokolink 需要与 guild-wars-2 相同的 runner, prefix, env 运行。

  1. runner. 这是您用来运行 gw2 的 Wine 可执行文件。
  2. prefix. 这是 gw2 的 Wine 前缀文件夹,如果您在 gw2 运行时使用相同的前缀但不同的 runner 运行 jokolink,它将崩溃。
  3. 环境。主要是指变量,如 WINE_FSYNC。这些变量也必须匹配,否则 jokolink 在相同前缀下使用时会崩溃。

为了获得最佳结果,请使用如 lutris guild-wars-2 --output-script ./gw2env.sh 的提取命令,它将脚本输出到名为 gw2env.sh 的文件中。我已在此处发布我的示例以供参考。用户名是 puppy。我能够删除除 WINE, WINEPREFIX, WINEFSYNC 变量之外的所有内容,并从 gw2 独立启动 jokolink,并且它运行良好。因此,请从您的 wine 启动脚本中获取这些变量。用 jokolink.exe 替换最后一行,而不是 guild wars 2。

#!/bin/bash


# Environment variables
export SDL_VIDEO_FULLSCREEN_DISPLAY="off"
export VK_ICD_FILENAMES="/usr/share/vulkan/icd.d/nvidia_icd.json"
export STEAM_RUNTIME="/home/puppy/.local/share/lutris/runtime/steam"
export LD_LIBRARY_PATH="/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/lib:/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/lib64:/usr/lib/libfakeroot:/usr/lib/opencollada:/usr/lib/openmpi:/usr/lib32:/usr/lib:/usr/lib64:/home/puppy/.local/share/lutris/runtime/lib32:/home/puppy/.local/share/lutris/runtime/steam/i386/lib/i386-linux-gnu:/home/puppy/.local/share/lutris/runtime/steam/i386/lib:/home/puppy/.local/share/lutris/runtime/steam/i386/usr/lib/i386-linux-gnu:/home/puppy/.local/share/lutris/runtime/steam/i386/usr/lib:/home/puppy/.local/share/lutris/runtime/lib64:/home/puppy/.local/share/lutris/runtime/steam/amd64/lib/x86_64-linux-gnu:/home/puppy/.local/share/lutris/runtime/steam/amd64/lib:/home/puppy/.local/share/lutris/runtime/steam/amd64/usr/lib/x86_64-linux-gnu:/home/puppy/.local/share/lutris/runtime/steam/amd64/usr/lib:$LD_LIBRARY_PATH"
export DXVK_HUD="0"
export DXVK_LOG_LEVEL="none"
export STAGING_SHARED_MEMORY="1"
export __GL_SHADER_DISK_CACHE_PATH="/home/puppy/game/guild-wars-2"
export __NV_PRIME_RENDER_OFFLOAD="1"
export WINEDEBUG="-all"
export WINEARCH="win64"
export WINE="/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/bin/wine"
export GST_PLUGIN_SYSTEM_PATH_1_0="/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/lib64/gstreamer-1.0/:/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/lib/gstreamer-1.0/"
export WINEPREFIX="/home/puppy/game/guild-wars-2"
export WINEESYNC="1"
export WINEFSYNC="1"
export WINEDLLOVERRIDES="winemenubuilder.exe=d"
export WINE_LARGE_ADDRESS_AWARE="1"
export TERM="xterm"

# Command
/home/puppy/.local/share/lutris/runners/wine/lutris-gw2-6.14-3-x86_64/bin/wine '/home/puppy/game/guild-wars-2/drive_c/Program Files/Guild Wars 2/GW2-64.exe' -autologin -Windowed%       

没有 Lutris 的 Wine 的怪癖

jokolink 将无限期运行,除非有人强制关闭它。因此,如果您在脚本中以后台方式运行它,请确保在退出之前等待 gw2 退出并杀死 jokolink。

开发

请确保运行 cargo check --target=x86_64-pc-windows-gnu 以检查 Windows 功能是否正常(如果在 Linux 上开发)以及 cargo check --target=x86_64-unknown-linux-gnu 以检查 Linux 功能是否良好。

我在 .cargo/config.toml 中将默认目标设置为 x86_64-pc-windows-gnu,并附上链接器选项以使用 mingw 工具链。如果您使用另一个发行版并发现任何编译问题,您需要检查那里的问题。

Linux

您需要安装 mingw 工具链来交叉编译 jokolink.exe。我已经在 .cargo/config.toml 中设置了选项,并且只要您安装了 mingw 软件包,通常应该没问题。编辑 lutris 中的 run_jokolink.sh 预启动脚本,使其指向 ./jokolink.exe 路径为 ./target/x86_64-pc-windows-gnu/release/jokolink.exe 或调试版本,这样您就可以通过简单地执行 cargo build --release 来快速编译它并启动 gw2 以测试其是否工作。或者创建符号链接。尽量记录所有内容,这样您可以检查日志,而不是麻烦从 lutris 获取日志。

Windows

您需要编辑 .cargo/config.toml 并注释掉所有内容。您可能想使用 msvc 工具链而不是 gnu。默认情况下,如果注释掉上述内容,x86_64-pc-windows-msvc 是目标。您可能不会运行二进制部分的 crate,因为那是用于 wine 的,您主要对库部分感兴趣,因此不要触摸 main.rs。如果您想为 wine 开发,请使用 Linux,因为它可以更快地检查错误,而不是在 Linux 和 wine 之间来回双启动。

依赖项

~16–55MB
~891K SLoC