mirror of
https://gitlab.com/2009scape/Saradomin-Launcher.git
synced 2026-08-01 14:19:14 -06:00
48 lines
No EOL
1.5 KiB
C#
48 lines
No EOL
1.5 KiB
C#
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using Avalonia;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
using Saradomin.Utilities;
|
|
|
|
namespace Saradomin.Services
|
|
{
|
|
public class ClientLaunchService : IClientLaunchService
|
|
{
|
|
private readonly ISettingsService _settingsService;
|
|
private readonly IClientUpdateService _clientUpdateService;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public ClientLaunchService(ISettingsService settingsService,
|
|
IClientUpdateService clientUpdateService)
|
|
{
|
|
_settingsService = settingsService;
|
|
_clientUpdateService = clientUpdateService;
|
|
}
|
|
|
|
public async Task LaunchClient()
|
|
{
|
|
var proc = new Process
|
|
{
|
|
StartInfo = new(_settingsService.Launcher.JavaExecutableLocation)
|
|
{
|
|
Arguments = $"-jar {_clientUpdateService.PreferredTargetFilePath}",
|
|
WorkingDirectory = CrossPlatform.Locate2009scapeHome(),
|
|
UseShellExecute = true,
|
|
WindowStyle = ProcessWindowStyle.Hidden
|
|
}
|
|
};
|
|
|
|
proc.Start();
|
|
|
|
if (_settingsService.Launcher.ExitAfterLaunchingClient)
|
|
{
|
|
(Application.Current!.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)!.Shutdown();
|
|
return;
|
|
}
|
|
|
|
await proc.WaitForExitAsync();
|
|
}
|
|
}
|
|
} |