mirror of
https://gitlab.com/nullmax17/PlombirLauncher.git
synced 2025-03-15 02:11:11 +03:00
28 lines
1.0 KiB
C#
28 lines
1.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using LauncherGUI.ViewModels;
|
|
using LauncherGUI.Views;
|
|
|
|
namespace Plombir;
|
|
|
|
public class LauncherUtils
|
|
{
|
|
public async static Task CreateMinecraftInstance(MainWindowViewModel vm, Window windowCaller)
|
|
{
|
|
if (vm.Usernick is null) throw new NullReferenceException("Failed to create minecraft instance! Nickname is null!");
|
|
if (vm.SelectedVersion is null) throw new NullReferenceException("Failed to create minecraft instance! Selected version is null!");
|
|
|
|
System.Console.WriteLine($"Creating minecraft instance for {vm.Usernick}, {vm.SelectedVersion} in {vm.RuntimeLocation}");
|
|
LoadingWindow loading = new(vm.Usernick, vm.SelectedVersion, vm.RuntimeLocation);
|
|
ConfigManager.WriteInConfig("last-version-launched", vm.SelectedVersion);
|
|
ConfigManager.WriteInConfig("nickname", vm.Usernick);
|
|
|
|
loading.Show();
|
|
await loading.InitLoading();
|
|
loading.Close();
|
|
await loading.RunMinecraft();
|
|
return;
|
|
}
|
|
}
|