mirror of
https://gitlab.com/nullmax17/PlombirLauncher.git
synced 2025-03-14 18:01:12 +03:00
43 lines
1.3 KiB
C#
43 lines
1.3 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)
|
|
{
|
|
var licenseStatus = ConfigManager.ReadConfig("login-method");
|
|
|
|
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);
|
|
|
|
SaveCurrentVariablesToConfig(vm);
|
|
|
|
loading.Show();
|
|
await loading.InitLoading();
|
|
loading.Close();
|
|
|
|
if (licenseStatus == "microsoft") await loading.RunMinecraft(true);
|
|
else await loading.RunMinecraft(false);
|
|
|
|
return;
|
|
}
|
|
|
|
private static async Task CreateLicensedMinecraftInstance()
|
|
{
|
|
|
|
}
|
|
|
|
private static void SaveCurrentVariablesToConfig(MainWindowViewModel vm)
|
|
{
|
|
ConfigManager.WriteInConfig("last-version-launched", vm.SelectedVersion);
|
|
}
|
|
}
|