mirror of
https://gitlab.com/nullmax17/PlombirLauncher.git
synced 2025-03-15 02:11:11 +03:00
54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using Avalonia.Controls;
|
||
|
using Avalonia.Interactivity;
|
||
|
using Avalonia.VisualTree;
|
||
|
using BlightFlame;
|
||
|
using CmlLib.Core.VersionMetadata;
|
||
|
using LauncherGUI.ViewModels;
|
||
|
|
||
|
namespace LauncherGUI.Views;
|
||
|
|
||
|
public partial class MainWindow : Window
|
||
|
{
|
||
|
|
||
|
public MainWindow()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
DataContext = new MainWindowViewModel();
|
||
|
if (DataContext == null) throw new NullReferenceException("Cant load MainWindow DataContext");
|
||
|
}
|
||
|
private async void OnLaunchMinecraftClick(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
|
||
|
var button = sender as Button;
|
||
|
if (button == null) return;
|
||
|
|
||
|
var root = button.GetVisualRoot() as MainWindow;
|
||
|
if (root == null) return;
|
||
|
|
||
|
var vm = DataContext as MainWindowViewModel;
|
||
|
LoadingWindow loading = new(vm.Usernick, vm.SelectedVersion);
|
||
|
loading.Show(root);
|
||
|
await loading.InitLoading();
|
||
|
loading.Close();
|
||
|
button.Content = "Minecraft launched";
|
||
|
await loading.RunMinecraft();
|
||
|
|
||
|
}
|
||
|
|
||
|
private void OnChooseVersionClick(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
|
||
|
var button = sender as Button;
|
||
|
if (button == null) return;
|
||
|
|
||
|
var root = button.GetVisualRoot() as MainWindow;
|
||
|
if (root == null) return;
|
||
|
|
||
|
VersionSelectorWindow selector = new(DataContext as MainWindowViewModel);
|
||
|
selector.Show(root);
|
||
|
}
|
||
|
|
||
|
}
|