diff --git a/README.md b/README.md index 4e50f22..007402a 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,26 @@ This repository contains a bare development environment for creating a new mod/g ### Creating a new mod The `example` mod included in this repository provides the bare minimum structure to launch to the in-game main menu for the sole purpose of demonstrating the environment. -It is not recommended or supported to use this as the basis of a new OpenRA mod. -Instead, you should copy one of the default OpenRA mods from `engine/mods/` to the `mods` subdirectory and make the following changes: +It is not recommended or supported to use the `example` mod as the basis for a new OpenRA mod; you should instead adapt one of the official mods using the following procedure: * Delete the `mods/example` directory. * Choose one of the default OpenRA mods to use as a base for your mod. In this example we will assume you are copying `cnc`. * Choose a new internal name / id for you mod. In this example we will assume you are using `mynewmod`. * Copy `engine/mods/cnc` to `mods/mynewmod`. * Open `mods/mynewmod/mod.yaml` and make the following changes: - * In the `Metadata` section set your mod title, version, and author. + * In the `Metadata` section set your mod title and version. * In the `Packaging` section replace `$cnc: cnc` with `$mynewmod: mynewmod`. This tells OpenRA that the explicit mount `mymod` should refer to the root of your mod package. * Change all lines that start with `cnc|` to `mynewmod|`. This updates the explicit mount references to account for the change that you have just made above. -* Open `launch-mod.sh` and replace `MODID="template"` near the top of the file with `MODID="mynewmod"`. +* Open `mod.config` and replace `MOD_ID="example"` near the top of the file with `MOD_ID="mynewmod"`. You should now have a functioning stand-alone clone of the `cnc` mod that you can adapt / replace piece by piece with your own project. -If you don't plan on including any custom C# logic in your mod then you should delete `OpenRA.Mods.Example.sln` and the `OpenRA.Mods.Example` directory. If you do plan on including custom logic, then you will need to make some futher changes: +If you don't plan on including any custom C# logic in your mod then you should delete `ExampleMod.sln`, `OpenRA.Mods.Example.sln`, and the `OpenRA.Mods.Example` directory. If you do plan on including custom logic, then you will need to make some futher changes: * TODO: Explain updating the GUIDs, project name, and changing the build output to `mods/mynewmod/` ### Developing / running your in-development mod -Run the `launch-mod.sh` (Linux/macOS) or `TODO` (Windows) scripts to run your mod in development mode. +Run the `launch-game.sh` (Linux/macOS) or `launch-game.cmd` (Windows) scripts to run your mod in development mode. Before you run this for the first time you must fetch and compile the engine code by running the `TODO` (Linux/macOS) or `TODO` (Windows) script. The first run scripts will automate the following: diff --git a/launch-dedicated.cmd b/launch-dedicated.cmd new file mode 100644 index 0000000..2109b33 --- /dev/null +++ b/launch-dedicated.cmd @@ -0,0 +1,27 @@ +:: example launch script, see https://github.com/OpenRA/OpenRA/wiki/Dedicated for details + +@echo on + +set Name="Dedicated Server" +set ListenPort=1234 +set ExternalPort=1234 +set AdvertiseOnline=True +set EnableSingleplayer=False +set Password="" + +@echo off + +title %Name% +FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B) + +set MOD_SEARCH_PATHS=%~dp0mods +if %INCLUDE_DEFAULT_MODS% neq "True" goto start +set MOD_SEARCH_PATHS=%MOD_SEARCH_PATHS%,./mods + +:start +cd engine + +:loop +OpenRA.Server.exe Game.Mod=%MOD_ID% Server.Name=%Name% Server.ListenPort=%ListenPort% Server.ExternalPort=%ExternalPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% + +goto loop \ No newline at end of file diff --git a/launch-dedicated.sh b/launch-dedicated.sh new file mode 100755 index 0000000..ca8425f --- /dev/null +++ b/launch-dedicated.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# example launch script, see https://github.com/OpenRA/OpenRA/wiki/Dedicated for details + +# Usage: +# $ ./launch-dedicated.sh # Launch a dedicated server with default settings +# $ Mod="d2k" ./launch-dedicated.sh # Launch a dedicated server with default settings but override the Mod +# Read the file to see which settings you can override + +TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))") +TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}") +source ${TEMPLATE_ROOT}/mod.config + +MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods" +if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then + MOD_SEARCH_PATHS="${TEMPLATE_PATHS},./mods" +fi + +LAUNCH_MOD="${Mod:-"${MOD_ID}"}" + +Name="${Name:-"Dedicated Server"}" +Mod="${Mod:-"${MOD_ID}"}" +ListenPort="${ListenPort:-"1234"}" +ExternalPort="${ExternalPort:-"1234"}" +AdvertiseOnline="${AdvertiseOnline:-"True"}" +EnableSingleplayer="${EnableSingleplayer:-"False"}" +Password="${Password:-""}" + +cd engine +while true; do + MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" mono --debug OpenRA.Server.exe Game.Mod=$Mod \ + Server.Name="$Name" Server.ListenPort=$ListenPort Server.ExternalPort=$ExternalPort \ + Server.AdvertiseOnline=$AdvertiseOnline \ + Server.EnableSingleplayer=$EnableSingleplayer Server.Password=$Password +done diff --git a/launch-game.cmd b/launch-game.cmd new file mode 100644 index 0000000..04134a7 --- /dev/null +++ b/launch-game.cmd @@ -0,0 +1,21 @@ +@echo off +title OpenRA +FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B) + +set TEMPLATE_LAUNCHER=%0 +set MOD_SEARCH_PATHS=%~dp0mods +if %INCLUDE_DEFAULT_MODS% neq "True" goto launch +set MOD_SEARCH_PATHS=%MOD_SEARCH_PATHS%,./mods + +:launch +cd engine +OpenRA.Game.exe Game.Mod=%MOD_ID% Engine.LaunchPath="%TEMPLATE_LAUNCHER%" "Engine.ModSearchPaths=%MOD_SEARCH_PATHS%" "%*" +if %errorlevel% neq 0 goto crashdialog +exit +:crashdialog +echo ---------------------------------------- +echo OpenRA has encountered a fatal error. +echo * Log Files are available in Documents\OpenRA\Logs +echo * FAQ is available at https://github.com/OpenRA/OpenRA/wiki/FAQ +echo ---------------------------------------- +pause \ No newline at end of file diff --git a/launch-game.sh b/launch-game.sh new file mode 100755 index 0000000..1c613de --- /dev/null +++ b/launch-game.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))") +TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}") +source ${TEMPLATE_ROOT}/mod.config + +MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods" +if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then + MOD_SEARCH_PATHS="${TEMPLATE_PATHS},./mods" +fi + +cd engine +mono OpenRA.Game.exe Engine.LaunchPath="${TEMPLATE_LAUNCHER}" "Engine.ModSearchPaths=${MOD_SEARCH_PATHS}" Game.Mod=${MOD_ID} "$@" diff --git a/launch-mod.sh b/launch-mod.sh deleted file mode 100755 index 4c06884..0000000 --- a/launch-mod.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# Change this to match your mod -MODID="example" - -# Don't edit below this line -MODLAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))") -MODROOT=$(dirname "$MODLAUNCHER") - -cd engine -# TODO: Remove ./mods from the search path after we deprecate cross-mod references -mono OpenRA.Game.exe Engine.LaunchPath="$MODLAUNCHER" "Engine.ModSearchPaths=./mods,$MODROOT/mods" Engine.DefaultMod=$MODID Game.Mod=$MODID "$@" diff --git a/mod.config b/mod.config new file mode 100644 index 0000000..a46a545 --- /dev/null +++ b/mod.config @@ -0,0 +1,8 @@ +# The id of the mod to launch by default. This must exist as a directory in the mods directory +MOD_ID="example" + +# Import the default OpenRA mods for use as external mod references +# in your mod.yaml. Accepts values "True" or "False". +# WARNING: This setting is provided to simplify early mod development +# and must be disabled before installers can be generated +INCLUDE_DEFAULT_MODS="False" diff --git a/utility.cmd b/utility.cmd new file mode 100644 index 0000000..fa5f9c8 --- /dev/null +++ b/utility.cmd @@ -0,0 +1,29 @@ +@echo off + +FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B) + +title OpenRA.Utility.exe %MOD_ID% + +set MOD_SEARCH_PATHS=%~dp0mods +if %INCLUDE_DEFAULT_MODS% neq "True" goto start +set MOD_SEARCH_PATHS=%MOD_SEARCH_PATHS%,./mods + +:start +cd engine + +:loop +echo. +echo ---------------------------------------- +echo. +echo Enter a utility command or --exit to exit. +echo Press enter to view a list of valid utility commands. +echo. + +set /P command=Please enter a command: OpenRA.Utility.exe %MOD_ID% +if /I "%command%" EQU "--exit" (exit) +echo. +echo ---------------------------------------- +echo. +echo OpenRA.Utility.exe %MOD_ID% %command% +call OpenRA.Utility.exe %MOD_ID% %command% +goto loop \ No newline at end of file diff --git a/utility.sh b/utility.sh new file mode 100755 index 0000000..1d823e9 --- /dev/null +++ b/utility.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Usage: +# $ ./utility.sh # Launch the OpenRA.Utility with the default mod +# $ Mod="d2k" ./launch-utility.sh # Launch a dedicated server with a specific mod + +TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))") +TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}") +source ${TEMPLATE_ROOT}/mod.config + +MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods" +if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then + MOD_SEARCH_PATHS="${TEMPLATE_PATHS},./mods" +fi + +LAUNCH_MOD="${Mod:-"${MOD_ID}"}" + +cd engine +MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" mono --debug OpenRA.Utility.exe ${LAUNCH_MOD} $@