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

From Custom Mario Kart
Jump to navigation Jump to search
Line 21: Line 21:
 
; Some syntax rules:
 
; Some syntax rules:
 
* The encoding is UTF-8
 
* The encoding is UTF-8
* The first 8 characters must be '''#BGM-TXT'''!
+
* The first 8 characters must be &raquo;'''<tt>#BGM-TXT</tt>'''&laquo; (without quotes)!
 
* Lines may be in Unix (LF) or Windows (CR+LF) style.
 
* Lines may be in Unix (LF) or Windows (CR+LF) style.
 
* Empty lines and lines starting with an hash ('#') are ignored.
 
* Empty lines and lines starting with an hash ('#') are ignored.

Revision as of 07:19, 22 April 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.

Replace Track Names

Track Name File

First prepare a text file with the following content:

#BGM-TXT

 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
Some syntax rules
  • The encoding is UTF-8
  • The first 8 characters 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.
  • 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.