Difference between revisions of "Wiimms SZS Tools/How To"

From Custom Mario Kart
Jump to navigation Jump to search
Line 107: Line 107:
 
* Edit the first section of the script and run it.
 
* Edit the first section of the script and run it.
 
* The patch is done in '''replace''' mode. This means, that only already existing message will be changes and no new message will be added. That's the reason that patching all message files will work.
 
* The patch is done in '''replace''' mode. This means, that only already existing message will be changes and no new message will be added. That's the reason that patching all message files will work.
 +
 +
== KMP ==
 +
→ [[Wiimms SZS Tools/KMP|Wiimms KMP How To]]
  
 
[[category:Software]]
 
[[category:Software]]
 
[[category:How To]]
 
[[category:How To]]

Revision as of 12:08, 16 August 2011

This is a How To for Wiimms SZS Tools. The scripts in this How To are bash Scripts. bash is one of the most popular scripting shells in the Unix world including Mac. Together with the standard Unix tools like grep, sort, awk, sed, tac and may more it is very powerful scripting host.

bash and all Linux tools are also available for Windows: Just install Cygwin.

Extracting All

It's very easy to extract a SZS or BRRES archive completely and recursively:

wszst extract --all my.szs
# or shorter
wszst x -a my.szs

A directory named "my.d" is created. it contains all extracted files and also some control file:

  • Known archives like SZS, U8, BRRES, BREFF and BREFT are extracted recursively.
  • BMG file are decoded and stored as BMG-Text files.
  • Images of TPL, TEX0 and BREFT subfiles files are stored as PNG files.
  • For recreating the archives a text file names 'wszst-setup.txt' is created. YOu can edit it to change the behavior.

You can add, remove and/or modify files in the extracted tree:

wszst create my.d

This command tries ti create a new my.szs, but it won't overwrite it. Add --overwrite to iverwrtie or --dest=new.szs to give it another filename.

Extracting all files

With Linux or Mac and also with Windows if using the Cygwin environment it is very easy to extract all SZS files with one command:

find -name '*.szs' | wszst extract --all --overwrite @-
  • The "@" means: Read the filename from a fie.
  • The "-" behind the "@" means: Use stdin (standard input) as file.


Replace Track Names

The following steps describes how to replace the track names of all message files of all supported languages of Mario Kart Wii without destroying any other message. The user must only provide one text file with the new track names, all other is done fully automatically by a bash script.

Track Name File

First prepare a text file with the following content:

#BGM-TXT

 # standard track names

 T11 = Track name for [[Slot]] 1.1 (cup 1 track 1)
 T12 = Name of track 1.2
 T13
 T14 = Name of track 1.4
 T21 = Name of track 2.1
 ...
 T84 = Name of last track

 # arena track names

 U11 = Track name for first arena (cup 1 arena 1)
 ...
 U15
 U21
 ...
 U25 = Name of last arena
Some syntax rules
  • The encoding is UTF-8
  • The very first 8 characters of the file must be »#BGM-TXT« (without quotes)!
  • Lines may be in Unix (LF) or Windows (CR+LF) style.
  • Empty lines and lines starting with an hash ('#') are ignored.
  • Indention is ok.
  • "Tnn" is only an other notation for message IDs. You can use any message id (MID, in hex notation) to set a message. "Tnn" will set both track related messages.
  • "Unn" is like "Tnn", but for arenas. (The letter 'A' cant be used because conflicting with a hex number.)
  • Leave out unmodified track and arena names.
  • The message order is irrelevant.
  • If a MID is defined twice, the second will override the first one.

Script

Use this script:

#!/bin/bash

#--- pre definitions: enter your local settings

# This is the directory with all message files (/Scene/UI)
SRC_UI_DIR="./ui"

# and this is the destination directory. If it is the same as the source
# than all files are replaced by the patched version.
DEST_UI_DIR="$SRC_UI_DIR"

# This is the path to the message file of above:
PATCH_FILE="bmg-patch.txt"

# Remove the the hash ('#') of the second line for fast operation.
# This makes the file about 25-30% larger but the operation is much faster 
FAST=
#FAST=--fast

#--- more automated setup

TEMP="$(mktemp -d)" || exit 1

#--- patch it in 3 steps: extract szs + patch bmg + create new szs

wszst extract --quiet "$SRC_UI_DIR/"*_?.szs --dest "$TEMP/%N.d"
wbmgt patch   --quiet "$TEMP/"*.d/message/*.bmg --patch "replace,$PATCH_FILE"
wszst create  --quiet --remove "$TEMP/"*.d --dest "$DEST_UI_DIR" $FAST

#--- clean up (remove temp dir)

rm -rf "$TEMP"
  • Edit the first section of the script and run it.
  • The patch is done in replace mode. This means, that only already existing message will be changes and no new message will be added. That's the reason that patching all message files will work.

KMP

Wiimms KMP How To