“模组:编辑 XNB 文件”的版本间的差异

来自Stardew Valley Wiki
跳到导航 跳到搜索
第66行: 第66行:
 
[[File:Modding - creating an XNB mod - example tilesheet.png|thumb|An example tilesheet, which consists of a grid of tiles like this: [[File:Modding - creating an XNB mod - example tile 1.png]]]]
 
[[File:Modding - creating an XNB mod - example tilesheet.png|thumb|An example tilesheet, which consists of a grid of tiles like this: [[File:Modding - creating an XNB mod - example tile 1.png]]]]
 
Definitions:
 
Definitions:
* A '''spritesheet''' is a PNG file containing small images in a regular grid pattern. Each square in the spritesheet's grid pattern is called a '''sprite'''. For example, each in-game item has a sprite in <tt>Content\Maps\spring_objects.xnb</tt>.
 
* A '''tilesheet''' is a synonym for spritesheet when used for map tiles. In a tilesheet, each square is called a ''tile'' and is 16×16 pixels.
 
* A '''portrait''' is a sprite from the <tt>Content\Characters\*.xnb</tt> spritesheets.
 

2021年4月12日 (一) 08:57的版本

目录

本页描述了如何编辑游戏文件以更改游戏中的数据、图像和地图。

介绍

什么是 XNB 文件?

游戏将数据、地图和纹理 存储在 .xnb 这种压缩数据文件中,它们在游戏的 Content 文件夹中。
例如,对话期间显示的阿比盖尔的头像来自这个文件: Content\Portraits\Abigail.xnb。解包这个文件,你会得到 Abigail.png 这个图片文件,内容如下:
Modding - creating an XNB mod - example portraits.png

(如果你使用 xnbcli 来解包,你通常会得到 Abigail.json 文件。 那只是用来打包回 .xnb 所需的文件,通常不需要更改它。)

如何将更改应用到游戏中?

有3个方法可以使你的修改应用到游戏中:

  1. 创建一个 Content Patcher 内容包。这不需要编程,仅编辑 JSON 文件就可以更改游戏的 XNB 数据,也无需替换实际的游戏文件。
  2. 制作一个 SMAPI 模组 并使用 内容 API。不过,这需要编程。
  3. 通过替换原始游戏文件来创建 XNB 模组。不再建议使用,本页面没有讲解; 访问 使用 XNB 模组 获取更多信息。

在哪里可以得到帮助?

欢迎访问星露谷模组社区。Feel free to ask the community for help.

解包游戏文件

你无法编辑 .xnb 文件其本身,你需要编辑其中的文件
将文件从中取出叫做 解包
把文件放入其中叫做 打包
有两个主要的 XNB 解包工具可用:

StardewXnbHack

StardewXnbHack 是用于解包 XNB 文件的开源且跨平台的工具
它不能打包回 .xnb 不过你会需要 创建内容包

如何操作:

  1. 安装 SMAPI
  2. 下载 StardewXnbHack(确保你下载的文件适合你的系统,例如文件名: StardewXnbHack-*-for-windows.zip 而不是 source code!)
  3. 解压缩并放进 你的游戏文件夹, 也就是 StardewXnbHack.exe 文件位于与 StardewValley.exe 相同的目录下.
  4. 双击运行 StardewXnbHack.exe (Windows)、StardewXnbHack.sh (Linux)、 StardewXnbHack.command (MacOS) 来解包游戏文件夹中 Content 文件夹下的所有 XNB 文件。

就是这样!它将会把解包的内容放入游戏文件夹下的 Content (unpacked) 文件夹。解包出的文件可用于创建 Content Patcher 的内容包。

xnbcli

xnbcli 是用于打包和解包 XNB 文件的开源且跨平台的工具。它无法解包带有数据模型的 XNB 文件 (例如 Data\FishPondData 或者 Data\Movies),并且需要手动编辑数据文件才能与 Content Patcher 等模组一起使用。

You should also back up your game's Content folder, so you can recover the original files if you make a mistake.

Unpack & pack game files

You can't edit an .xnb file itself, you need to edit the file that's inside it. Pulling out that inner file is called unpacking, and putting it back is called packing. Here's how to do it:

  1. Download XNB Extract (see #First-time setup).
  2. Unpack the file for editing:
    1. Find the file you want to edit in the Contents folder.
    2. Copy it into XNB Extract's Packed folder.
    3. Double-click UnpackFiles.bat (Windows) or UnpackFiles.sh (Linux/Mac).
  3. Edit the unpacked file (see below).
  4. Repack the file for the game:
    1. Double-click PackFiles.bat (Windows) or PackFiles.sh (Linux/Mac).
    2. Move the repacked .xnb file back to the original location.

Making changes

Spritesheets, tilesheets, or portraits

An example tilesheet, which consists of a grid of tiles like this: Modding - creating an XNB mod - example tile 1.png

Definitions: