mirror of
https://gitlab.com/nullmax17/PlombirLauncher.git
synced 2025-03-14 18:01:12 +03:00
Licensed auth WIP
Slowly adding methods and variables to build licensed minecraft instance
This commit is contained in:
parent
1e725f5933
commit
45ffb1dfbb
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using CmlLib.Core;
|
||||
using CmlLib.Core.Auth;
|
||||
using XboxAuthNet.Game.Msal;
|
||||
@ -43,6 +42,7 @@ static public class Utils
|
||||
Console.WriteLine(deviceCode.Message);
|
||||
return Task.CompletedTask;
|
||||
}));
|
||||
authenticator.AddMsalOAuth(app, msal => msal.Silent());
|
||||
authenticator.AddXboxAuthForJE(xbox => xbox.Basic());
|
||||
authenticator.AddJEAuthenticator();
|
||||
return await authenticator.ExecuteForLauncherAsync();
|
||||
|
@ -24,4 +24,9 @@ public class LauncherUtils
|
||||
await loading.RunMinecraft();
|
||||
return;
|
||||
}
|
||||
|
||||
private static async Task CreateLicensedMinecraftInstance()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,21 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
|
||||
private string? _runtimeLocation = ConfigManager.ReadConfig("runtime-path");
|
||||
public string? RuntimeLocation { get => _runtimeLocation; set { _runtimeLocation = value; OnPropertyChanged(nameof(RuntimeLocation)); } }
|
||||
|
||||
// Session information
|
||||
private string? _loginMethod = ConfigManager.ReadConfig("login-method");
|
||||
public string? LoginMethod { get => _loginMethod; set { _loginMethod = value; OnPropertyChanged(nameof(LoginMethod)); } }
|
||||
|
||||
private string? _accsessToken = ConfigManager.ReadConfig("accsess-token");
|
||||
public string? AccsesToken { get => _accsessToken; set { _accsessToken = value; OnPropertyChanged(nameof(AccsesToken)); } }
|
||||
|
||||
private string? _clientToken = ConfigManager.ReadConfig("client-token");
|
||||
public string? ClientToken { get => _clientToken; set { _clientToken = value; OnPropertyChanged(nameof(ClientToken)); } }
|
||||
|
||||
private string? _uuid = ConfigManager.ReadConfig("uuid");
|
||||
public string? UUID { get => _uuid; set { _uuid = value; OnPropertyChanged(nameof(UUID)); } }
|
||||
|
||||
// Tweaks managment
|
||||
private string? _tweaksVersion = ConfigManager.ReadConfig("tweaks-version");
|
||||
public string? TweaksVersion { get => _tweaksVersion; set { _tweaksVersion = value; OnPropertyChanged(nameof(TweaksVersion)); } }
|
||||
}
|
||||
|
@ -85,7 +85,12 @@ public partial class MainWindow : Window
|
||||
|
||||
private void OnAccountSettingsPressed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//todo: account managment window
|
||||
if (sender is not Image img) return;
|
||||
|
||||
if (img.GetVisualRoot() is not MainWindow root) return;
|
||||
|
||||
SessionManagmentWindow sessionManager = new(DataContext as MainWindowViewModel);
|
||||
sessionManager.Show(root);
|
||||
}
|
||||
|
||||
}
|
||||
|
144
Launcher-UI/Views/SessionManagmentWindow.axaml
Normal file
144
Launcher-UI/Views/SessionManagmentWindow.axaml
Normal file
@ -0,0 +1,144 @@
|
||||
<Window
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="500"
|
||||
d:DesignHeight="400"
|
||||
x:Class="LauncherGUI.Views.SessionManagmentWindow"
|
||||
Icon="/Assets/Sprites/icon.png"
|
||||
Title="Account manager"
|
||||
RequestedThemeVariant="Dark"
|
||||
Width="500"
|
||||
Height="400"
|
||||
MinWidth="500"
|
||||
MinHeight="400"
|
||||
MaxWidth="500"
|
||||
MaxHeight="400"
|
||||
Background="#353535"
|
||||
>
|
||||
|
||||
<StackPanel>
|
||||
<Border
|
||||
Width="500"
|
||||
Background="#94a285"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
<StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Text="Current session info"
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Text="Session nickname: "
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
/>
|
||||
<TextBlock x:Name="currentNickname" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Text="Session login method: "
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
/>
|
||||
<TextBlock x:Name="loginMethod" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
<!-- This is quite junky, but It should look simillar. -->
|
||||
<Border
|
||||
Width="500"
|
||||
Background="#504254"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
<TextBlock
|
||||
Text="OFFLINE METHOD"
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Width="500"
|
||||
Background="#504254"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
|
||||
<TextBlock
|
||||
Text="Insert username:"
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
/>
|
||||
<TextBox
|
||||
x:Name="inputNickname"
|
||||
Width="200"
|
||||
HorizontalAlignment="Left"
|
||||
/>
|
||||
|
||||
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Width="500"
|
||||
Background="#542434"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
|
||||
<TextBlock
|
||||
Text="LICENSED METHOD"
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
HorizontalAlignment="Center"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
<Border
|
||||
Width="500"
|
||||
Background="#542434"
|
||||
Padding="10"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Center"
|
||||
>
|
||||
<Image
|
||||
Height="30"
|
||||
Width="30"
|
||||
Source="/Assets/Sprites/microsoft-logo.png"
|
||||
Stretch="Uniform"
|
||||
/>
|
||||
|
||||
<Button
|
||||
Content="Login with Microsoft"
|
||||
Click="OnMicrosoftLoginClick"
|
||||
/>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
|
||||
<Button
|
||||
FontFamily="{StaticResource QuicksandFont}"
|
||||
Content="Save"
|
||||
HorizontalAlignment="Center"
|
||||
Click="OnSaveButtonClick"
|
||||
/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
</Window>
|
40
Launcher-UI/Views/SessionManagmentWindow.axaml.cs
Normal file
40
Launcher-UI/Views/SessionManagmentWindow.axaml.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LauncherGUI.ViewModels;
|
||||
|
||||
namespace LauncherGUI.Views;
|
||||
using Plombir;
|
||||
|
||||
public partial class SessionManagmentWindow : Window
|
||||
{
|
||||
private MainWindowViewModel _mainWindowVM;
|
||||
public SessionManagmentWindow(MainWindowViewModel mainWindowVM)
|
||||
{
|
||||
InitializeComponent();
|
||||
_mainWindowVM = mainWindowVM;
|
||||
inputNickname.Text = _mainWindowVM.Usernick; // setting default nickname.
|
||||
currentNickname.Text = _mainWindowVM.Usernick;
|
||||
loginMethod.Text = _mainWindowVM.LoginMethod;
|
||||
}
|
||||
|
||||
private void OnSaveButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is not Button button) return;
|
||||
|
||||
_mainWindowVM.Usernick = inputNickname.Text;
|
||||
Console.WriteLine($"Changing nickname to {inputNickname.Text}");
|
||||
|
||||
button.Content = "Saved!";
|
||||
}
|
||||
|
||||
async private void OnMicrosoftLoginClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var session = await Utils.GetLicensedSession();
|
||||
_mainWindowVM.LoginMethod = "microsoft";
|
||||
_mainWindowVM.Usernick = session.Username;
|
||||
_mainWindowVM.UUID = session.UUID;
|
||||
_mainWindowVM.AccsesToken = session.AccessToken;
|
||||
_mainWindowVM.ClientToken = session.ClientToken;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user