diff --git a/Directory.Build.props b/Directory.Build.props index 9868a17..4fbf8b2 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,7 +1,7 @@ - 0.1.0 + 0.1.1 net48;net8.0 x86 x64 diff --git a/README.md b/README.md index 12471c8..4cfc3e7 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ To build from source, you'll need: - Visual Studio 2022 or newer with the C++ build tools. - XNA Framework 4.0 for Terraria builds, installed with the game. -Set `TerrariaDir` and `TModLoaderDir` in `Directory.Build.props` to your game folders. The build and auto-load scripts use these paths. Environment variables with the same names also work. +Set `TerrariaDir` and `TModLoaderDir` in `Directory.Build.props` to your game folders for source builds. Environment variables with the same names also work. 1. Run `build.bat` from the project folder. The files go into `bin\`. 2. Start Terraria or tModLoader, then run `bin\TerraSharp.Injector.exe`. @@ -51,9 +51,11 @@ The same injector works with both games. Keep it beside the DLLs produced by the You can also have the menu load when the game starts. Close the game, run `autoload.bat` and choose Install. +The script uses the default Steam folders under `Program Files (x86)`. For games installed elsewhere, set the `TerrariaDir` or `TModLoaderDir` environment variable to the game's folder before running it. + For Terraria, the script installs the DLL and adds its AppDomainManager entries to the existing game configuration. Uninstall removes those entries and the DLL while preserving other settings. Installation stops if another AppDomainManager is already configured. A game verify/update on Steam may remove the configuration; run the installer again if the menu stops loading. -For tModLoader, the script prints a launch option to paste into Steam under **Properties > General > Launch Options**. Steam also uses `autoload.bat` as the Windows launcher: it sets `DOTNET_STARTUP_HOOKS`, preserves any existing hooks and runs Steam's game command. Keep the project folder in place while using this option. When updating from an earlier version, run Install again and replace the launch option. Remove the option to stop auto-loading. It does not appear in tModLoader's mod list. +For tModLoader, the script prints a launch option to paste into Steam under **Properties > General > Launch Options**. Steam also uses `autoload.bat` as the Windows launcher: it sets `DOTNET_STARTUP_HOOKS`, preserves any existing hooks and runs Steam's game command. Keep the TerraSharp folder in place while using this option. When updating from an earlier version, run Install again and replace the launch option. Remove the option to stop auto-loading. It does not appear in tModLoader's mod list. ## Settings diff --git a/autoload.bat b/autoload.bat index 5ff5a91..2ed40d6 100644 --- a/autoload.bat +++ b/autoload.bat @@ -6,9 +6,9 @@ set "HOOK=%ROOT%bin\TerraSharp.tModLoader.dll" set "TERRASHARP_AUTOLOAD_SCRIPT=%~f0" if not "%~1"=="" goto launcher -set "GamePathsLoaded=" -for /f "usebackq tokens=1,* delims==" %%a in (`powershell -NoProfile -NonInteractive -Command "$ErrorActionPreference = 'Stop'; try { $properties = [xml](Get-Content -LiteralPath ($env:ROOT + 'Directory.Build.props') -Raw); foreach ($name in 'TerrariaDir', 'TModLoaderDir') { $value = $properties.SelectSingleNode('/Project/PropertyGroup/' + $name).InnerText; Write-Output ($name + '=' + $value) }; 'GamePathsLoaded=1' } catch { [Console]::Error.WriteLine($_.Exception.Message); exit 1 }"`) do if not defined %%a set "%%a=%%b" -if not defined GamePathsLoaded exit /b 1 +if not defined TerrariaDir set "TerrariaDir=%ProgramFiles(x86)%\Steam\steamapps\common\Terraria" +if not defined TModLoaderDir set "TModLoaderDir=%ProgramFiles(x86)%\Steam\steamapps\common\tModLoader" +if not exist "%TerrariaDir%\Terraria.exe" if not exist "%TModLoaderDir%\tModLoader.dll" (echo No game found. Set TerrariaDir or TModLoaderDir to your game folder and run again & goto fail) echo TerraSharp auto-load echo Terraria folder: "%TerrariaDir%" @@ -25,7 +25,7 @@ if errorlevel 2 goto uninstall :install echo. if not exist "%TerrariaDir%\Terraria.exe" goto tmodloader -if not exist "%DLL%" (echo "%DLL%" not found, run build.bat first & goto fail) +if not exist "%DLL%" (echo "%DLL%" not found, keep the bin folder beside autoload.bat & goto fail) echo Terraria: call :configure Install 1 if errorlevel 1 goto fail @@ -41,7 +41,7 @@ echo tModLoader: add this to its Steam launch options (Properties ^> General ^> echo. powershell -NoProfile -NonInteractive -Command "[Console]::WriteLine(' cmd /d /s /c ' + [char]34 + [char]34 + $env:ROOT + 'autoload.bat' + [char]34 + ' %%command%%' + [char]34)" echo. -if not exist "%HOOK%" echo (build the tModLoader DLL first: build.bat) +if not exist "%HOOK%" echo ("%HOOK%" not found, keep the bin folder beside autoload.bat) goto done :uninstall @@ -72,7 +72,7 @@ powershell -NoProfile -NonInteractive -Command "$source = [IO.File]::ReadAllText exit /b %errorlevel% :launcher -if not exist "%HOOK%" (echo TerraSharp: "%HOOK%" not found, run build.bat first & exit /b 1) +if not exist "%HOOK%" (echo TerraSharp: "%HOOK%" not found, keep the bin folder beside autoload.bat & exit /b 1) if not defined DOTNET_STARTUP_HOOKS ( set "DOTNET_STARTUP_HOOKS=%HOOK%" goto launch