PlombirLauncher/Launcher-UI/LauncherUtils.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2025-02-22 12:19:42 +03:00
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using LauncherGUI.ViewModels;
using LauncherGUI.Views;
2025-02-22 12:19:42 +03:00
namespace Plombir;
public class LauncherUtils
{
public async static Task CreateMinecraftInstance(MainWindowViewModel vm, Window windowCaller)
{
var licenseStatus = ConfigManager.ReadConfig("login-method");
2025-02-22 12:19:42 +03:00
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);
}
2025-02-22 12:19:42 +03:00
}