Изменения

Новая страница: «← Модификации {{Stub}} На этой странице объясняется, как редактировать файлы игры для из…»
← [[Модификации]]
{{Stub}}

На этой странице объясняется, как редактировать файлы игры для изменения внутриигровых данных, изображений и карт.

==Введение==
===Что такое XNB файл?===
Игра хранит свои данные в сжатом <tt>.xnb</tt> формате внутри директории <tt>Content</tt>. Например, [[Абигейл#Портреты|портреты Абигейл]], отображаемые во время диалога, упакованы в файл<tt>Content\Portraits\Abigail.xnb</tt>. Каждый <tt>.xnb</tt> файл содержит два файла: файл с данными (например, изображение), и файл с метаданными (информация о файле с данными). К примеру, вот что находится внутри <tt>Content\Portraits\Abigail.xnb</tt>:

<pre>
Abigail.xnb
Abigail.png
Abigail.yaml
</pre>

В примере выше:

* <tt>Abigail.png</tt> содержит портреты Абигейл. Отредактировав этот файл можно изменить портреты в игре:<br />[[File:Modding - creating an XNB mod - example portraits.png]]
* <tt>Abigail.yaml</tt> содержит метаданные о файле <tt>Abigail.png</tt> (например, какого он типа). Не нужно беспокоиться об этом файле, так как обычно он не изменяется.

===Как внести изменения в игру?===
Существуют три способа создания изменений:

# Создать с помощью [https://www.nexusmods.com/stardewvalley/mods/1915 Content Patcher] контент пакет. Таким образом можно изменить XNB файл игры без использования программирования (просто отредактировать файл JSON), а также не заменять оригинальный файл игры.
# [[Руководство по созданию модификаций|Создание SMAPI мода]] и использование его [[Modding:Modder_Guide/APIs/Content|Content API]]. Требуются навыки программирования.
# Создание XNB мода и замена оригинальных файлов. Этот метод крайне не рекомендуется; смотрите [[Использование XNB модификаций|использование XNB модификаций]] для получения дополнительной информации.

===Где получить помощь?===
Сообщество мододелов Stardew Valley дружелюбно. Спросите совета у [[Modding:Community|других мододелов]].

==Начало работы==
===Первоначальная настройка===
Перед началом, необходимо установить:

:; на Windows

::* '''[https://www.mediafire.com/?b86xecd27yti6f6 XNB Extract 0.2.2]''' для распаковки и упаковки XNB файлов. <small>(Смотрите [http://community.playstarbound.com/threads/beginners-guide-to-xnb-node-and-graphics-editing.110976/ тему на форуме].)</small>
::* '''[http://www.getpaint.net/download.html Paint.NET]''' для редактирования изображений (или другой любимый графический редактор).

:; на Linux/Mac

::* '''[https://www.winehq.org/download Wine 1.7 или позднее]''' для запуска XNB Extract.
::* '''[https://www.dropbox.com/s/oj5tch8np74nk4d/XNBExtract0.2.2.zip?dl=0 XNB Extract 0.2.2 for Linux/Mac]''' для распаковки и упаковки XNB файлов.
::* '''[https://www.gimp.org/downloads/ GIMP]''' для редактирования изображений (или другой любимый графический редактор).

Также необходимо создать резервную копию директорию <tt>Content</tt> вашей игры, чтобы восстановить оригинальные файлы в случае ошибки.

===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 [[Modding:Game folder|game's <tt>Content</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.

==Getting started (experimental alternative)==
xnbcli is a new tool for packing and unpacking XNB files. It's [https://github.com/LeonBlade/xnbcli open-source] and natively crossplatform, but still new. Try it out and [[Modding:Community#Discord|let us know]] how it goes!

<div style="border:2px solid gray; padding:0.5em;">
===Unpack & pack game files===
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 [https://github.com/LeonBlade/xnbcli/releases xnbcli].
# Unpack the file for editing:
## Find the file you want to edit in the [[Modding:Game folder|game's <tt>Content</tt> folder]].
## Copy it into xnbcli's <tt>packed</tt> folder.
## Double-click <tt>unpack.bat</tt> (Windows) or <tt>unpack.sh</tt> (Linux/Mac).
# Edit the unpacked file (see below).
# Repack the file for the game:
## Double-click <tt>pack.bat</tt> (Windows) or <tt>pack.sh</tt> (Linux/Mac).
## Move the repacked <tt>.xnb</tt> file back to the original location.
</div>

==Making changes==
===Data===
Each data XNB has its own format. See the documentation at [[Modding:Index#Advanced topics]].

===Images===
[[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]]]]
A few definitions:
* A '''spritesheet''' is a PNG file containing small images (usually 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 (like [http://www.getpaint.net/download.html Paint.NET] on Windows, or [https://www.gimp.org/downloads/ GIMP] on Linux/Mac).
# 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.

===Maps===
See [[Модификации:Карты]].

[[Category:Modding]]

[[zh:使用模组:制作一个XNB模组]]
5

правок