Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,9 @@ The generated `.dat` files are found at
...

For information on adding and modifying LTexts, see the [Translation & LText Guide](ltext/README.md#maintaining-ltext-sources).

### Assembling a Build

To assemble the .jar installer, use the script [src/scripts/build-installer-jar.sh](src/scripts/build-installer-jar.sh).

The accompanying read-first document for the final release is maintaned at [src/scripts/installer-resources/read-first-nam.html](src/scripts/installer-resources/read-first-nam.html).
3 changes: 1 addition & 2 deletions ltext/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This guide covers translation of the mod's [LText](https://wiki.sc4devotion.com/

## Translating the NAM

The NAM uses the [gettext](https://en.wikipedia.org/wiki/Gettext) standard for internationalization,
so any compatible tool can be used for translating, such as Poedit.
The NAM uses the [gettext](https://en.wikipedia.org/wiki/Gettext) standard for internationalization and recommends the use of Poedit for translation tasks.

### Poedit

Expand Down
348 changes: 0 additions & 348 deletions src/scripts/RUL2_IID_structure_noRHW.xml

This file was deleted.

120 changes: 120 additions & 0 deletions src/scripts/build-installer-jar.sh
Comment thread
jflann marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash
# Builds a release-ready jar installer, taking as input:
# --version <version> (preferably no spaces)
# --data <installation-dir> (path to dat files)
# --sidebar <png> (installer sidebar image file)
# --splash <jpg> (installer splash image file)
# --output <dir> (optional output folder, defaults to `target/installer`)
#
# Example:
# ./src/scripts/build-installer-jar.sh --version 50.rc1 --data "installation" --sidebar "sidebar.png" --splash "splash.jpg"

set -e

if [ ! -e "Controller" ]
then
echo "Error: Call this script from the root directory of the Network-Addon-Mod repository."
exit 2
fi

# Initialize variables
version=""
data_dir=""
sidebar_image=""
splash_image=""
license_file="src/scripts/installer-resources/license.txt"
settings_file="src/scripts/installer-resources/settings.txt"
output_dir=""

# Function to display usage
usage() {
echo "Usage: $(basename "$0") --version <version> --data <installation-dir> --sidebar <png> --splash <jpg> [--output <dir>]"
exit 2
}

# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--version|--data|--sidebar|--splash|--output)
option_name="$1"
shift
if [[ -z "$1" ]]; then
echo "Error: $1 requires a value"
usage
fi
case "$option_name" in
--version) version="$1" ;;
--data) data_dir="$1" ;;
--sidebar) sidebar_image="$1" ;;
--splash) splash_image="$1" ;;
--output) output_dir="$1" ;;
esac
shift
;;
*)
echo "Unknown argument: $1"
usage
;;
esac
done

# Check for missing mandatory arguments
if [[ -z "$version" || -z "$data_dir" || -z "$sidebar_image" || -z "$splash_image" ]]; then
echo "Error: Missing required arguments."
usage
fi

if [[ "$sidebar_image" != *.png || "$splash_image" != *.jpg ]]
then
echo "Error: sidebar image should be png, splash image jpg: $sidebar_image, $splash_image"
exit 2
fi

check_exists() {
if [ ! -e "$1" ]
then
echo "Error: file/directory does not exist: $1"
exit 2
fi
}

# Check existence of files
for f in "$data_dir" "$sidebar_image" "$splash_image" "$license_file" "$settings_file"
do
check_exists "$f"
done

if [[ -z "$output_dir" ]]; then
output_dir="target/installer"
fi

INSTALLER_URL="https://github.com/NAMTeam/nam-installer/releases/download/47.0.4/NAM-installer-version47.0.4.jar"
INSTALLER_ARCHIVE="target/NAM-installer-version47.0.4.jar"

if [ ! -e "$INSTALLER_ARCHIVE" ]
then
# download installer if it does not yet exist
curl -L --output "$INSTALLER_ARCHIVE" "$INSTALLER_URL"
fi
echo "a447a06a759dccf13bbb6fce2657317a326035419dab74029e395a11a99cc8b6 $INSTALLER_ARCHIVE" | sha256sum --check

TEMP="target/installer/temp"
rm -rf "$TEMP"
mkdir -p "$TEMP"
unzip -q -d "$TEMP/jar" "$INSTALLER_ARCHIVE"
rm -rf "$TEMP/jar/installation"

cp "$splash_image" "$TEMP/jar/splash.jpg"
cp "$sidebar_image" "$TEMP/jar/sidebar.png"
sed "s/__NAMVERSION__/$version/g" "$license_file" > "$TEMP/jar/license.txt"
sed "s/__NAMVERSION__/$version/g" "$settings_file" > "$TEMP/jar/settings.txt"

mkdir -p "$output_dir"
out_jar="$output_dir/NetworkAddonMod_Setup_Version$version.jar"
jar cfm "$out_jar" "$TEMP/jar/META-INF/MANIFEST.MF" -C "$TEMP/jar" .
# add dat files to jar (without copying them into the TEMP folder as intermediate step)
ln -s "$(realpath "$data_dir")" "$TEMP/installation"
jar uf "$out_jar" -C "$TEMP" "installation"

rm -rf "$TEMP"
echo "Jar installer has been created: $out_jar"
24 changes: 4 additions & 20 deletions src/scripts/compile-release-controllers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# ./src/scripts/compile-release-controllers.sh
#
# The compiled controllers are located at `./target/controllers/`.
# The selections for Full/Low-RAM variants are taken from these files:
# The controller-compiler selections are taken from this file:
# src/scripts/RUL2_IID_structure_full.xml
# src/scripts/RUL2_IID_structure_noRHW.xml
set -e

if [ ! -e "Controller" ]
Expand All @@ -42,13 +41,12 @@ unzip -d "$TEMP" "$COMPILER_ARCHIVE"

VERSION="$1"
DRIVESIDE='XHD'
VARIANT=''
DATESTRING="$(date --utc)"
ltext() {
if [ ! -z "$VERSION" ]
then
# If an argument was passed to the script, the version is non-empty.
printf "NAM Version $VERSION $DRIVESIDE $VARIANT compiled on $DATESTRING"
printf "NAM Version $VERSION $DRIVESIDE compiled on $DATESTRING"
else
# Otherwise pass the empty string to the compiler.
printf ""
Expand All @@ -57,27 +55,13 @@ ltext() {


# RHD 4GB Full
VARIANT='(4GB Full)'
DRIVESIDE='RHD'
cp "src/scripts/RUL2_IID_structure_full.xml" "$TEMP/resources/xml/RUL2_IID_structure.xml"
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@0=0 NAM Controller_RHD_4GB_Full' 1 "$(ltext)")
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@0=0 NAM Controller_RHD' 1 "$(ltext)")

# LHD 4GB Full
VARIANT='(4GB Full)'
DRIVESIDE='LHD'
cp "src/scripts/RUL2_IID_structure_full.xml" "$TEMP/resources/xml/RUL2_IID_structure.xml"
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@1-0 NAM Controller_LHD_4GB_Full' 0 "$(ltext)")

# RHD no-RHW
VARIANT='(Low-RAM no-RHW)'
DRIVESIDE='RHD'
cp "src/scripts/RUL2_IID_structure_noRHW.xml" "$TEMP/resources/xml/RUL2_IID_structure.xml"
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@2-0 NAM Controller_RHD_LowRAM_NoRHW' 1 "$(ltext)")

# LHD no-RHW
VARIANT='(Low-RAM no-RHW)'
DRIVESIDE='LHD'
cp "src/scripts/RUL2_IID_structure_noRHW.xml" "$TEMP/resources/xml/RUL2_IID_structure.xml"
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@3-0 NAM Controller_LHD_LowRAM_NoRHW' 0 "$(ltext)")
(cd "$TEMP" && java -jar NAMControllerCompiler.jar "$PROJECT_ROOT/Controller" '../@1-0 NAM Controller_LHD' 0 "$(ltext)")

rm -rf "$TEMP"
14 changes: 2 additions & 12 deletions src/scripts/compile-release-inruls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,12 @@ unzip -d "$TEMP" "$BUILDRULS_ARCHIVE"
(cd "$TEMP/BuildRULs_01" && java -jar BuildRULs.jar -f "$PROJECT_ROOT/Controller/INRULs/" "$PROJECT_ROOT/Controller/INRULs/")

# RHD 4GB Full
DESTDIR="target/controllers/@0=0 NAM Controller_RHD_4GB_Full/"
DESTDIR="target/controllers/@0=0 NAM Controller_RHD/"
mkdir -p "$DESTDIR"
cp -p "$PROJECT_ROOT/Controller/INRULs/NetworkAddonMod_IndividualNetworkRULs_RHD.dat" "$DESTDIR"

# LHD 4GB Full
DESTDIR="target/controllers/@1-0 NAM Controller_LHD_4GB_Full/"
mkdir -p "$DESTDIR"
cp -p "$PROJECT_ROOT/Controller/INRULs/NetworkAddonMod_IndividualNetworkRULs_LHD.dat" "$DESTDIR"

# RHD no-RHW
DESTDIR="target/controllers/@2-0 NAM Controller_RHD_LowRAM_NoRHW/"
mkdir -p "$DESTDIR"
cp -p "$PROJECT_ROOT/Controller/INRULs/NetworkAddonMod_IndividualNetworkRULs_RHD.dat" "$DESTDIR"

# LHD no-RHW
DESTDIR="target/controllers/@3-0 NAM Controller_LHD_LowRAM_NoRHW/"
DESTDIR="target/controllers/@1-0 NAM Controller_LHD/"
mkdir -p "$DESTDIR"
cp -p "$PROJECT_ROOT/Controller/INRULs/NetworkAddonMod_IndividualNetworkRULs_LHD.dat" "$DESTDIR"

Expand Down
38 changes: 38 additions & 0 deletions src/scripts/installer-resources/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Welcome to the ${appname} installer application!

Please read the following carefully, then select "I agree with these conditions" to continue.

---------------------------------------------------------------------------------------------

Network Addon Mod is compatible with the following versions of SimCity 4.exe:

1.1.641

The following versions are unsupported:

1.1.640, 1.1.638, 1.1.613, 1.1.610, and all macOS versions

See the read-first-nam-__NAMVERSION__.html document for more details.

---------------------------------------------------------------------------------------------

Please observe the following instructions when installing or upgrading the NAM:

- Manually copy the NAM.dll into the root of your Plugins folder.

- If upgrading, remove the previous installation in its entirety before running the installer.

Previous versions are not removed automatically and may conflict with this version.

- Consider applying the 4GB Patch to SimCity 4.exe if you have not already done so (recommended, but optional).

---------------------------------------------------------------------------------------------

Users download, install, and run this software completely and solely at their own risk.
Maxis, Electronic Arts, the creators, and its individual contributors are not responsible for
any errors, crashes, problems, or any other issue that you may have if you have downloaded and
applied this software to your game. The use of this software, the information within, and the
Network Addon Mod is conditional upon the acceptance of this disclaimer and all that is within
this software.

---------------------------------------------------------------------------------------------
Loading
Loading