Wiimms SZS Tools/How To

From Custom Mario Kart
Jump to navigation Jump to search

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!
  • Lines may be in Unix (LF) or Windows (CR+LF) style.
  • Empty liens and lines are starting with an hash ('#') are ignored.
  • Indention is ok.
  • Leave out not replaced tracks.
  • "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 teh pacthed version.
DEST_UI_DIR="$SRC_UI_DIR"

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

# Remove the command 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

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

rm -rf "$TEMP"
  • Edit the first section of the script and run it.