2025-02-22 12:19:42 +03:00
|
|
|
using System;
|
2025-02-21 16:09:06 +03:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using LauncherGUI.ViewModels;
|
|
|
|
using LauncherGUI.Views;
|
|
|
|
|
2025-02-22 12:19:42 +03:00
|
|
|
namespace Plombir;
|
2025-02-21 16:09:06 +03:00
|
|
|
|
|
|
|
public class LauncherUtils
|
|
|
|
{
|
|
|
|
public async static Task CreateMinecraftInstance(MainWindowViewModel vm, Window windowCaller)
|
|
|
|
{
|
2025-02-26 16:04:13 +03:00
|
|
|
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!");
|
|
|
|
|
2025-02-21 16:09:06 +03:00
|
|
|
System.Console.WriteLine($"Creating minecraft instance for {vm.Usernick}, {vm.SelectedVersion} in {vm.RuntimeLocation}");
|
2025-02-26 16:04:13 +03:00
|
|
|
LoadingWindow loading = new(vm);
|
|
|
|
|
|
|
|
SaveCurrentVariablesToConfig(vm);
|
2025-02-21 16:09:06 +03:00
|
|
|
|
|
|
|
loading.Show();
|
|
|
|
await loading.InitLoading();
|
|
|
|
loading.Close();
|
2025-02-26 16:04:13 +03:00
|
|
|
|
|
|
|
if (licenseStatus == "microsoft") await loading.RunMinecraft(true);
|
|
|
|
else await loading.RunMinecraft(false);
|
|
|
|
|
2025-02-21 16:09:06 +03:00
|
|
|
return;
|
|
|
|
}
|
2025-02-25 22:42:41 +03:00
|
|
|
|
|
|
|
private static async Task CreateLicensedMinecraftInstance()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2025-02-26 16:04:13 +03:00
|
|
|
|
|
|
|
private static void SaveCurrentVariablesToConfig(MainWindowViewModel vm)
|
|
|
|
{
|
|
|
|
ConfigManager.WriteInConfig("last-version-launched", vm.SelectedVersion);
|
|
|
|
}
|
2025-02-22 12:19:42 +03:00
|
|
|
}
|