34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using Godot;
|
|
|
|
public partial class SessionHandler : Panel {
|
|
|
|
Options _Options;
|
|
Reference _Reference;
|
|
|
|
[Export] LineEdit UsernameBox;
|
|
[Export] LineEdit PasswordBox;
|
|
|
|
public override void _Ready() {
|
|
_Options = GetNode<Options>( "/root/Options" );
|
|
_Reference = GetNode<Reference>("/root/Reference");
|
|
_Reference.SessionHandler = this;
|
|
}
|
|
|
|
public async void onLogin() {
|
|
(bool, Account) User = await _Reference.MistoxNet.TryLogin( UsernameBox.Text, PasswordBox.Text );
|
|
if( User.Item1 ) {
|
|
_Reference.Alert.PerformAlert( "Login Success" );
|
|
_Options._SettingsFile.Game.UserName = User.Item2.UserName;
|
|
_Options._SettingsFile.Game.SessionToken = User.Item2.PasswordHash;
|
|
_Options._SettingsFile.Save();
|
|
GetParent<Control>().Visible = false;
|
|
} else {
|
|
_Reference.Alert.PerformAlert("Login Failed");
|
|
}
|
|
}
|
|
|
|
public void onRegister() {
|
|
OS.ShellOpen("https://www.mistox.net/account/register");
|
|
}
|
|
}
|