|
@@ -74,7 +74,7 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
//check launcher update
|
|
|
_logger.Information("Checking launcher versions updates.");
|
|
|
_latestLauncherInfo = Downloader.DownloadAndDeserializeJsonData<LatestLauncherVersion>("https://files.veloe.link/launcher/update/versions.json");
|
|
|
- if (_latestLauncherInfo is not null)
|
|
|
+ if (_latestLauncherInfo is not null && _latestLauncherInfo.Latest is not null)
|
|
|
{
|
|
|
_logger.Information("Launcher version on server: {0}", _latestLauncherInfo.Latest);
|
|
|
_logger.Information("Launcher version: {0}", Assembly.GetExecutingAssembly().GetName().Version);
|
|
@@ -84,8 +84,9 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
_logger.Debug("Update available!");
|
|
|
IsUpdateAvailable = true;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+ else
|
|
|
+ _logger.Warning("Can't get latest verion info! Skipping...");
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -204,6 +205,7 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
|
|
|
LatestLauncherVersion _latestLauncherInfo;
|
|
|
DownloadedVersion _downloadedVersion;
|
|
|
+ DownloadedVersion _startedVersion;
|
|
|
|
|
|
ObservableCollection<DownloadedVersion> _downloadedVersions;
|
|
|
|
|
@@ -350,7 +352,6 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
int version = 0;
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(DownloadedVersion.path))
|
|
@@ -466,6 +467,7 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
minecraft.EnableRaisingEvents = true;
|
|
|
|
|
|
IsNoGameRunning = false;
|
|
|
+ _startedVersion = DownloadedVersion;
|
|
|
minecraft.Start();
|
|
|
|
|
|
minecraft.Exited += ProcessExited;
|
|
@@ -546,13 +548,22 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
void ProcessExited(object? sendingProcess, EventArgs e)
|
|
|
{
|
|
|
((Process)sendingProcess).Exited -= ProcessExited;
|
|
|
+ ((Process)sendingProcess).OutputDataReceived -= OutputHandler;
|
|
|
+ ((Process)sendingProcess).ErrorDataReceived -= OutputHandler;
|
|
|
+ ((Process)sendingProcess).CancelOutputRead();
|
|
|
+ ((Process)sendingProcess).CancelErrorRead();
|
|
|
|
|
|
_logger.Debug("Exit code: {0}", ((Process)sendingProcess).ExitCode);
|
|
|
-
|
|
|
+
|
|
|
StartButtonOutput = "";
|
|
|
IsNoGameRunning = true;
|
|
|
- if (((Process)sendingProcess).ExitCode != 0)
|
|
|
- OpenErrorWindow(new Exception("Minecraft process exited with an error.\nCheck log in game folder or in launcher console."));
|
|
|
+ if (((Process)sendingProcess).ExitCode is not (0 or 2))
|
|
|
+ OpenErrorWindow(new JavaProcessException($"Minecraft process exited with an error code {((Process)sendingProcess).ExitCode}.\nCheck log in game folder or launcher console.", $"{Settings.minecraftForlderPath}versions/{_startedVersion.version}/crash-reports"));
|
|
|
+ else if (((Process)sendingProcess).ExitCode is 2)
|
|
|
+ {
|
|
|
+ OpenErrorWindow(new Exception("JVM exited on the startup (Exit code 2). Check your Java installation. Get more info in the laucher console."));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
((Process)sendingProcess).Dispose();
|
|
|
}
|
|
@@ -805,34 +816,4 @@ public class MainWindowViewModel : ViewModelBase
|
|
|
|
|
|
return panel;
|
|
|
}
|
|
|
-
|
|
|
- private void OpenErrorWindow(Exception ex)
|
|
|
- {
|
|
|
- var message = ex.Message;
|
|
|
- var stackTrace = ex.StackTrace;
|
|
|
- Settings.logger.Error(ex.Message);
|
|
|
- Settings.logger.Error(ex.StackTrace);
|
|
|
- Exception innerException = ex.InnerException;
|
|
|
- while (innerException is not null)
|
|
|
- {
|
|
|
- message += "\n" + innerException.Message;
|
|
|
- stackTrace += "\n" + innerException.StackTrace;
|
|
|
- Settings.logger.Error(innerException.Message);
|
|
|
- Settings.logger.Error(innerException.StackTrace);
|
|
|
- innerException = innerException.InnerException;
|
|
|
- }
|
|
|
-
|
|
|
- Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
- {
|
|
|
- if (Avalonia.Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
|
- {
|
|
|
- var ErrorMessageViewModel = new ErrorWindowViewModel(message, stackTrace);
|
|
|
- var ErrorMessage = new ErrorWindow()
|
|
|
- {
|
|
|
- DataContext = ErrorMessageViewModel
|
|
|
- };
|
|
|
- ErrorMessage.ShowDialog(desktop.MainWindow);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
}
|