|
@@ -19,6 +19,8 @@ using Avalonia.Controls;
|
|
|
using Avalonia.Threading;
|
|
|
using System.Net;
|
|
|
using System.IO.Compression;
|
|
|
+using ReactiveUI.Validation.Extensions;
|
|
|
+using Microsoft.CodeAnalysis.CSharp.Syntax;
|
|
|
|
|
|
namespace VeloeMinecraftLauncher.ViewModels
|
|
|
{
|
|
@@ -55,6 +57,11 @@ namespace VeloeMinecraftLauncher.ViewModels
|
|
|
OpenErrorWindow(ex);
|
|
|
}
|
|
|
|
|
|
+ this.ValidationRule(
|
|
|
+ viewModel => viewModel.Username,
|
|
|
+ value => { return !string.IsNullOrEmpty(value); },
|
|
|
+ "Empty username.");
|
|
|
+
|
|
|
UpdateUpdater();
|
|
|
|
|
|
try
|
|
@@ -251,7 +258,11 @@ namespace VeloeMinecraftLauncher.ViewModels
|
|
|
public string Username
|
|
|
{
|
|
|
get => username;
|
|
|
- set => this.RaiseAndSetIfChanged(ref username, value);
|
|
|
+ set
|
|
|
+ {
|
|
|
+ this.RaiseAndSetIfChanged(ref username, value);
|
|
|
+ this.RaisePropertyChanged(nameof(IsStartButtonEnabled));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public string ConsoleText
|
|
@@ -293,7 +304,16 @@ namespace VeloeMinecraftLauncher.ViewModels
|
|
|
public bool IsNoGameRunning
|
|
|
{
|
|
|
get => isNoGameRunning;
|
|
|
- set => this.RaiseAndSetIfChanged(ref isNoGameRunning, value);
|
|
|
+ set
|
|
|
+ {
|
|
|
+ this.RaiseAndSetIfChanged(ref isNoGameRunning, value);
|
|
|
+ this.RaisePropertyChanged(nameof(IsStartButtonEnabled));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool IsStartButtonEnabled
|
|
|
+ {
|
|
|
+ get => IsNoGameRunning && !string.IsNullOrEmpty(Username);
|
|
|
}
|
|
|
|
|
|
public bool IsUpdateAvailable
|
|
@@ -589,7 +609,10 @@ namespace VeloeMinecraftLauncher.ViewModels
|
|
|
|
|
|
StartButtonOutput = "";
|
|
|
IsNoGameRunning = true;
|
|
|
- ((Process)sendingProcess).Dispose();
|
|
|
+ if (((Process)sendingProcess).ExitCode != 0)
|
|
|
+ OpenErrorWindow(new Exception("Minecraft process exited with an error.\nCheck log in game folder or in launcher console."));
|
|
|
+
|
|
|
+ ((Process)sendingProcess).Dispose();
|
|
|
}
|
|
|
|
|
|
|