“模组:制作一个XNB模组”的版本间的差异

来自Stardew Valley Wiki
跳到导航 跳到搜索
(创建页面,内容为“←目录 {{翻译}} 本页介绍如何创建一个替换游戏原文件的MOD,以便更改游戏数据,图像和地图。 ==介绍== =...”)
 
(重定向页面至模组:编辑 XNB 文件
标签新重定向
 
(未显示5个用户的10个中间版本)
第1行: 第1行:
[[ 使用 模组: 目录|目录]]
+
#重定向 [[模组: 编辑 XNB 文件]]
{{翻译}}
 
 
 
  本页介绍如何创建一个替换游戏原 文件 的MOD,以便更改游戏数据,图像和地图。
 
 
 
==介绍==
 
===XNB模组的工作原理===
 
The game stores data in a compressed format with the <tt>.xnb</tt> file extension inside its <tt>Content</tt> folder. For example, Abigail's portrait shown during dialogue is from <tt>Content\Portraits\Abigail.xnb</tt>. Each <tt>.xnb</tt> file contains two files: the data file (like an image), and a metadata file (information about the data file). For example, here's what's inside <tt>Content\Portraits\Abigail.xnb</tt>:
 
 
 
<pre>
 
Abigail.xnb
 
  Abigail.png
 
  Abigail.yaml
 
</pre>
 
 
 
In the above example:
 
 
 
* <tt>Abigail.png</tt> contains Abigail's portraits. This is the file you would edit if you wanted to change her portraits in the game:<br />[[File:Modding - creating an XNB mod - example portraits.png]]
 
* <tt>Abigail.yaml</tt> contains metadata about <tt>Abigail.png</tt> (like what type of file it is). You don't need to worry about this file, since you generally won't be changing it.
 
 
 
An XNB mod replaces some of the game's XNB data files, which lets you change images (like portraits, NPCs, or buildings), data (like crop information or dialogue), or maps (including map behaviour like warps and minigames). XNB mods can also add entirely new content (like new NPCs).
 
 
 
===XNB vs SMAPI mods===
 
SMAPI is a modding API that lets you change the game using code. SMAPI mods are more powerful, easier to install and remove, and allow multiple mods to change the same content. On the other hand, SMAPI requires you to write code which some modders aren't comfortable with. If you have programming experience, [[Modding:Creating a SMAPI mod|creating a SMAPI mod]] is recommended instead if feasible.
 
 
 
有关这两种mod的更多信息,请看:[[使用模组:玩家常见问题]]。
 
 
 
===在哪里可以获得帮助?===
 
The Stardew Valley modding community is very welcoming. Feel free [https://discord.gg/stardewvalley come chat on Discord] or [http://community.playstarbound.com/forums/mods.215/ post in the forums].
 
 
 
==入门==
 
===First-time setup===
 
Before you start, you should install these:
 
 
 
:; on Windows
 
 
 
::* '''[https://www.mediafire.com/?b86xecd27yti6f6 XNB Extract 0.2.2]''' to unpack and pack the game's XNB files. <small>(See [http://community.playstarbound.com/threads/beginners-guide-to-xnb-node-and-graphics-editing.110976/ forum post].)</small>
 
::* '''[http://www.getpaint.net/download.html Paint.NET]''' to edit image files (or use your favourite image editor).
 
 
 
:; on Linux/Mac
 
 
 
::* '''[https://www.winehq.org/download Wine 1.7 or later]''' to run Windows programs like XNB Extract.
 
::* '''[https://www.dropbox.com/s/oj5tch8np74nk4d/XNBExtract0.2.2.zip?dl=0 XNB Extract 0.2.2 for Linux/Mac]''' to unpack and pack the game's XNB files.
 
::* '''[https://www.gimp.org/downloads/ GIMP]''' to edit image files (or use your favourite image editor).
 
 
 
You should also back up your game's <tt>Content</tt> folder, so you can recover the original files if you make a mistake.
 
 
 
===Unpack & pack game files===
 
<span id="unpacking"></span>
 
 
 
You can't edit an <tt>.xnb</tt> 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:
 
 
 
# Download XNB Extract (see [[#First-time setup]]).
 
# Unpack the file for editing:
 
## Find the file you want to edit in the <tt>Contents</tt> folder.
 
## Copy it into XNB Extract's <tt>Packed</tt> folder.
 
## Double-click <tt>UnpackFiles.bat</tt> (Windows) or <tt>UnpackFiles.sh</tt> (Linux/Mac).
 
# Edit the unpacked file (see below).
 
# Repack the file for the game:
 
## Double-click <tt>PackFiles.bat</tt> (Windows) or <tt>PackFiles.sh</tt> (Linux/Mac).
 
## Move the repacked <tt>.xnb</tt> file back to the original location.
 
 
 
==Making changes==
 
===Spritesheets, tilesheets, or portraits===
 
[[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:
 
* 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.
 
 
 
Spritesheets are easy to edit:
 
# [[#unpacking|Unpack the file]] you want to change.
 
# Open the unpacked <tt>.png</tt> file in an image editor (see [[#Getting started]]).
 
# Make changes directly to the image.
 
# [[#unpacking|Repack the file]] and copy it back to the original location.
 
 
 
That's it! You can launch the game to see your changes.
 
 
 
===地图===
 
请见:[[使用模组:地图]]
 
 
 
[[Category:使用模组]]
 
[[en:Modding:Creating an XNB mod]]
 

2021年4月12日 (一) 05:37的最新版本