Модификации:Редактирование XNB файлов

Версия от 15:41, 11 августа 2018; GIDMYRT (обсуждение | вклад) (Новая страница: «← Модификации {{Stub}} На этой странице объясняется, как редактировать файлы игры для из…»)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)

Модификации

Axe.png
Это заготовка статьи.

Вы можете помочь Stardew Valley Wiki, дополнив её!

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

Введение

Что такое XNB файл?

Игра хранит свои данные в сжатом .xnb формате внутри директории Content. Например, портреты Абигейл, отображаемые во время диалога, упакованы в файлContent\Portraits\Abigail.xnb. Каждый .xnb файл содержит два файла: файл с данными (например, изображение), и файл с метаданными (информация о файле с данными). К примеру, вот что находится внутри Content\Portraits\Abigail.xnb:

Abigail.xnb
   Abigail.png
   Abigail.yaml

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

  • Abigail.png содержит портреты Абигейл. Отредактировав этот файл можно изменить портреты в игре:
     
  • Abigail.yaml содержит метаданные о файле Abigail.png (например, какого он типа). Не нужно беспокоиться об этом файле, так как обычно он не изменяется.

Как внести изменения в игру?

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

  1. Создать с помощью Content Patcher контент пакет. Таким образом можно изменить XNB файл игры без использования программирования (просто отредактировать файл JSON), а также не заменять оригинальный файл игры.
  2. Создание SMAPI мода и использование его Content API. Требуются навыки программирования.
  3. Создание XNB мода и замена оригинальных файлов. Этот метод крайне не рекомендуется; смотрите использование XNB модификаций для получения дополнительной информации.

Где получить помощь?

Сообщество мододелов Stardew Valley дружелюбно. Спросите совета у других мододелов.

Начало работы

Первоначальная настройка

Перед началом, необходимо установить:

на Windows
  • XNB Extract 0.2.2 для распаковки и упаковки XNB файлов. (Смотрите тему на форуме.)
  • Paint.NET для редактирования изображений (или другой любимый графический редактор).
на Linux/Mac

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

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 game's Content 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.

Getting started (experimental alternative)

xnbcli is a new tool for packing and unpacking XNB files. It's open-source and natively crossplatform, but still new. Try it out and let us know how it goes!

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 xnbcli.
  2. Unpack the file for editing:
    1. Find the file you want to edit in the game's Content folder.
    2. Copy it into xnbcli's packed folder.
    3. Double-click unpack.bat (Windows) or unpack.sh (Linux/Mac).
  3. Edit the unpacked file (see below).
  4. Repack the file for the game:
    1. Double-click pack.bat (Windows) or pack.sh (Linux/Mac).
    2. Move the repacked .xnb file back to the original location.

Making changes

Data

Each data XNB has its own format. See the documentation at Modding:Index#Advanced topics.

Images

 
An example tilesheet, which consists of a grid of tiles like this:  

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 Content\Maps\spring_objects.xnb.
  • 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 Content\Characters\*.xnb spritesheets.

Spritesheets are easy to edit:

  1. Unpack the file you want to change.
  2. Open the unpacked .png file in an image editor (like Paint.NET on Windows, or GIMP on Linux/Mac).
  3. Make changes directly to the image.
  4. 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 Модификации:Карты.