diff --git a/src/ParkitectNexus.Client.Base/App.cs b/src/ParkitectNexus.Client.Base/App.cs index edb27e7..cb5bbf7 100644 --- a/src/ParkitectNexus.Client.Base/App.cs +++ b/src/ParkitectNexus.Client.Base/App.cs @@ -42,7 +42,7 @@ public App(IPresenterFactory presenterFactory, IParkitect parkitect, IQueueableT public static UIImageProvider Images { get; } = new UIImageProvider(); - + public bool Initialize(ToolkitType type) { _log.Open(Path.Combine(AppData.Path, "ParkitectNexusLauncher.log")); @@ -76,7 +76,7 @@ public bool Initialize(ToolkitType type) if (!_parkitect.DetectInstallationPath()) { if ( - !MessageDialog.Confirm("We couldn't detect Parkitect on your machine.\nPlease point me to it!", + !MessageDialog.Confirm("We couldn't automatically detect Parkitect on your machine!\nPlease press OK and manually select the installation folder of Parkitect.", Command.Ok)) { _window.Dispose(); @@ -125,7 +125,6 @@ public void HandleUrl(INexusUrl url) } } - // TODO: Replace with simple TCP server configuration private async void CheckForIpcFile() { var ipcPath = Path.Combine(AppData.Path, "ipc.dat"); diff --git a/src/ParkitectNexus.Client.Base/Pages/AssetsPageView.cs b/src/ParkitectNexus.Client.Base/Pages/AssetsPageView.cs index ab48a7b..daaac88 100644 --- a/src/ParkitectNexus.Client.Base/Pages/AssetsPageView.cs +++ b/src/ParkitectNexus.Client.Base/Pages/AssetsPageView.cs @@ -41,12 +41,14 @@ public AssetsPageView(IParkitect parkitect, AssetType type, IPresenter parent, s private void Assets_AssetRemoved(object sender, AssetEventArgs e) { - RefreshTiles(); + if (e.Asset.Type == _type) + RefreshTiles(); } private void Assets_AssetAdded(object sender, AssetEventArgs e) { - RefreshTiles(); + if (e.Asset.Type == _type) + RefreshTiles(); } protected virtual void PopulateViewBoxWithTitle(VBox vBox, IAsset asset) diff --git a/src/ParkitectNexus.Client.Base/Tiles/LoadableDataTileView.cs b/src/ParkitectNexus.Client.Base/Tiles/LoadableDataTileView.cs index 36fcbf5..060318a 100644 --- a/src/ParkitectNexus.Client.Base/Tiles/LoadableDataTileView.cs +++ b/src/ParkitectNexus.Client.Base/Tiles/LoadableDataTileView.cs @@ -46,6 +46,7 @@ protected virtual void ClearTiles() foreach (var r in _rows) r.Clear(); + _buttons.Clear(); _rows.Clear(); _box.Clear(); PushNewRow(); @@ -70,14 +71,13 @@ public async void RefreshTiles() await Task.Delay(1); } - // Clear controls - ClearTiles(); - - Spinner spinner = null; Application.Invoke(() => { + // Clear controls + ClearTiles(); + Content = spinner = new Spinner { @@ -139,7 +139,7 @@ public async void RefreshTiles() } finally { - _tokenSource.Dispose(); + _tokenSource?.Dispose(); _tokenSource = null; } } @@ -148,7 +148,7 @@ public void HandleSizeUpdate(float width) { if (CalculateButtonsPerRow(width) == _buttonsPerRow) return; - + _buttonsPerRow = CalculateButtonsPerRow(width); var i = 0; diff --git a/src/ParkitectNexus.Client.Win32/Program.cs b/src/ParkitectNexus.Client.Win32/Program.cs index 7b0284e..2ef1108 100644 --- a/src/ParkitectNexus.Client.Win32/Program.cs +++ b/src/ParkitectNexus.Client.Win32/Program.cs @@ -31,7 +31,7 @@ public static void Main(string[] args) { // No matter if the application crashes, we must release the mutex when the app closes. Wrap the app // logic in a try-finally block. -#if RELEASE +#if !DEBUG try { #endif @@ -67,7 +67,7 @@ public static void Main(string[] args) } app.Run(); -#if RELEASE +#if !DEBUG } catch (Exception e) { diff --git a/src/ParkitectNexus.Data/Reporting/CrashReporterFactory.cs b/src/ParkitectNexus.Data/Reporting/CrashReporterFactory.cs index 2e2fa90..438d122 100644 --- a/src/ParkitectNexus.Data/Reporting/CrashReporterFactory.cs +++ b/src/ParkitectNexus.Data/Reporting/CrashReporterFactory.cs @@ -58,6 +58,8 @@ private object Generate(string action, IParkitect parkitect, Exception exception return new WindowsCrashReport(parkitect, action, exception, _log); case SupportedOperatingSystem.MacOSX: return new MacOSXCrashReport(parkitect, action, exception, _log); + case SupportedOperatingSystem.Linux: + return new LinuxCrashReport(parkitect, action, exception, _log); default: throw new Exception("unsupported operating system " + os); } diff --git a/src/ParkitectNexus.Data/Reporting/LinuxCrashReport.cs b/src/ParkitectNexus.Data/Reporting/LinuxCrashReport.cs new file mode 100644 index 0000000..2448edc --- /dev/null +++ b/src/ParkitectNexus.Data/Reporting/LinuxCrashReport.cs @@ -0,0 +1,86 @@ +// ParkitectNexusClient +// Copyright 2016 Parkitect, Tim Potze + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using Newtonsoft.Json; +using ParkitectNexus.Data.Assets; +using ParkitectNexus.Data.Assets.Modding; +using ParkitectNexus.Data.Game; +using ParkitectNexus.Data.Utilities; + +namespace ParkitectNexus.Data.Reporting +{ + [JsonObject(MemberSerialization.OptIn)] + public class LinuxCrashReport + { + private readonly ILogger _logger; + private readonly IParkitect _parkitect; + + public LinuxCrashReport(IParkitect parkitect, string action, Exception exception, ILogger logger) + { + if (parkitect == null) throw new ArgumentNullException(nameof(parkitect)); + if (exception == null) throw new ArgumentNullException(nameof(exception)); + + _logger = logger; + _parkitect = parkitect; + Action = action; + Exception = exception; + } + + [JsonProperty] + public string Action { get; } + + [JsonProperty] + public Exception Exception { get; } + + [JsonProperty] + public string OS => "Unknown (Linux)"; + + [JsonProperty] + public int ProcessBits => IntPtr.Size*8; + + [JsonProperty] + public IEnumerable Mods + { + get + { + try + { + return _parkitect.Assets[AssetType.Mod].OfType().Select( + m => $"{m}(Enabled: ???, Directory: {m.InstallationPath})"); + } + catch + { + return new[] {"Failed to list"}; + } + } + } + + [JsonProperty] + public string Log + { + get + { + try + { + if (!_logger.IsOpened) + return "not opened"; + + var path = _logger.LoggingPath; + _logger.Close(); + var result = File.ReadAllText(path); + _logger.Open(path); + return result; + } + catch (Exception e) + { + return "failed to open: " + e.Message; + } + } + } + } +} diff --git a/src/ParkitectNexus.Data/Reporting/MacOSXCrashReport.cs b/src/ParkitectNexus.Data/Reporting/MacOSXCrashReport.cs index 77b4955..cfcdb9d 100644 --- a/src/ParkitectNexus.Data/Reporting/MacOSXCrashReport.cs +++ b/src/ParkitectNexus.Data/Reporting/MacOSXCrashReport.cs @@ -114,4 +114,104 @@ public string Log } } } -} \ No newline at end of file + [JsonObject(MemberSerialization.OptIn)] + public class LinuxCrashReport + { + private readonly ILogger _logger; + private readonly IParkitect _parkitect; + + public MacOSXCrashReport(IParkitect parkitect, string action, Exception exception, ILogger logger) + { + if (parkitect == null) throw new ArgumentNullException(nameof(parkitect)); + if (exception == null) throw new ArgumentNullException(nameof(exception)); + + _logger = logger; + _parkitect = parkitect; + Action = action; + Exception = exception; + } + + [JsonProperty] + public string Action { get; } + + [JsonProperty] + public Exception Exception { get; } + + [JsonProperty] + public string OS + { + get + { + try + { + var process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "w_vers", + Arguments = "-productVersion", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; + + string result = ""; + process.Start(); + while (!process.StandardOutput.EndOfStream) + { + result += process.StandardOutput.ReadLine(); + } + return result; + } + catch + { + return "Unknown (MacOSX)"; + } + } + } + + [JsonProperty] + public int ProcessBits => IntPtr.Size * 8; + + [JsonProperty] + public IEnumerable Mods + { + get + { + try + { + return _parkitect.Assets[AssetType.Mod].OfType().Select( + m => $"{m}(Enabled: ???, Directory: {m.InstallationPath})"); + } + catch + { + return new[] { "Failed to list" }; + } + } + } + + [JsonProperty] + public string Log + { + get + { + try + { + if (!_logger.IsOpened) + return "not opened"; + + var path = _logger.LoggingPath; + _logger.Close(); + var result = File.ReadAllText(path); + _logger.Open(path); + return result; + } + catch (Exception e) + { + return "failed to open: " + e.Message; + } + } + } + } +} diff --git a/src/ParkitectNexus.Data/Updating/UpdateManager.cs b/src/ParkitectNexus.Data/Updating/UpdateManager.cs index 645f960..98a5f31 100644 --- a/src/ParkitectNexus.Data/Updating/UpdateManager.cs +++ b/src/ParkitectNexus.Data/Updating/UpdateManager.cs @@ -65,9 +65,6 @@ public UpdateInfo CheckForUpdates() { var newestVersion = new Version(updateInfo.Version); - currentVersion = new Version(currentVersion.Major, currentVersion.Minor, currentVersion.Build); - newestVersion = new Version(newestVersion.Major, newestVersion.Minor, newestVersion.Build); - _log.WriteLine($"Server reported newest version is v{updateInfo.Version}."); if (newestVersion > currentVersion) {