-
-
Notifications
You must be signed in to change notification settings - Fork 6
The Launcher
The Launcher is what your client will run to update the game. It requires an initial configuration in order to work.
I will refer to the Launcher scene in MHLab/Patch/Launcher/Scenes, but the configuration is similar for other clients (WPF, WinForms, etc).
To configure it, just find the LauncherData game object: it contains a LauncherData component. It should look like this:

Here you must set some information:
- Remote URL: the HTTP address where you uploaded files previously
- Launcher Executable Name: the name of your Launcher executable, with the extension. In the screenshot you can see an example related to Windows's exe.
- Game Executable Name: the name of your game executable, with the extension.
Other settings you see in the screenshot are just for UI management.
If you need to deeper customize settings, take a look at the
LauncherBase.csscript, inCreateSettingsmethod. TheLauncherSettingsinstance exposes multiple customizable settings you can tune to fit your needs.Launcher.csandLauncherUpdater.csscripts also expose a method to configure settings:OverrideSettings. You can customize settings only for Launcher or PreGame in this method.
The WPF integration of PATCH can be found at Assets\MHLab\Patch\Launcher as MHLab.Patch.Launcher.Wpf.7z archive.
Extract the project somewhere and open it with your IDE. If you own the Basic version, you will need to add the two DLLs (MHLab.Patch.Core.Client.dll and MHLab.Patch.Core.dll, contained in the archive) as dependencies of your project.
To customize the options of your WPF Launcher, you can set Remote URL and other settings in MainWindow.xaml.cs in CreateSettings method.
Launcher and other scenes are just samples: you're encouraged to customize them. Also the Launcher.cs script is just a minimal sample of what you can do with the PATCH's API: feel free to edit it.
The UI can be trivially customized with the Unity UI system (or with Visual Studio if you're using the WPF version).
When you are satisfied of your Launcher, it's time to build it as I explained here. Place built files in Updater folder in your PATCH's workspace then go to Admin Tool > Launcher.
Here just insert the Launcher archive name and the Compression level and hit Build Launcher update.
Run the command
.\MHLab.Patch.Admin.exe --patcherUpdate
When the process completes you will notice a new file in Updater folder: updater_index.json. It contains metadata for the Launcher update.
PATCH also generated a compressed archive (it is in the root folder of PATCH workspace) that contains your Launcher, ready to be distributed to the clients.
Just upload the whole Updater folder to your web server. That's it! :)
Assuming your remote root is
http://localhost/patch/, after the uploading we should be able to see theUpdaterfolder athttp://localhost/patch/Updaterand with the browser we should be able to navigate tohttp://localhost/patch/Updater/updater_index.json.
If you want to test the Launcher, just create a new folder and extract inside it the content of the Launcher compressed archive. Don't run your Launcher inside the Updater folder!
Run the extracted executable and check that everything is acting like you expect!
After the first run, your Launcher downloaded your game in the Game subfolder. From now on you can run directly your game: the PreGame scene will check if any update is available and - if so - it will run the Launcher for updates.
Some settings can be changed for an already compiled Launcher just by creating a settings.json file near to your Launcher executable and declaring options you want to override.
The content of the settings.json file should look like this:
{
"DebugMode": true,
"PatcherUpdaterSafeMode": true
}This is the list of the available options you can regulate:
-
DebugMode: enables the Debug Mode. You can find more information about it here. -
PatcherUpdaterSafeMode: enables the Launcher's Safe Mode. It's a way to force the Launcher to replace itself with an arbitrary package that you can define on your server. The replacing will happen without any further questioning or check from the Launcher. This has the purpose of offering a way to fix Launchers that cannot self-update because of fatal errors/bugs in the previous self-update. Find more here.
Having a settings.json file is optional. If the Launcher does not find it, default settings will be used.
You can also customize and expand settings, just read how to do it here.