diff --git a/EDEngineer/App.config b/EDEngineer/App.config index 78090aac..1d838c9b 100644 --- a/EDEngineer/App.config +++ b/EDEngineer/App.config @@ -29,7 +29,7 @@ True - 1.0.0.12 + 1.0.0.13 0 diff --git a/EDEngineer/Converters/AllFiltersToHeaderConverter.cs b/EDEngineer/Converters/AllFiltersToHeaderConverter.cs index 9f43d993..9d14f109 100644 --- a/EDEngineer/Converters/AllFiltersToHeaderConverter.cs +++ b/EDEngineer/Converters/AllFiltersToHeaderConverter.cs @@ -5,7 +5,6 @@ using System.Text; using System.Windows.Data; using EDEngineer.Filters; -using EDEngineer.Models; namespace EDEngineer.Converters { diff --git a/EDEngineer/EDEngineer.csproj b/EDEngineer/EDEngineer.csproj index d58b0096..2ba9ce60 100644 --- a/EDEngineer/EDEngineer.csproj +++ b/EDEngineer/EDEngineer.csproj @@ -153,6 +153,7 @@ + ReleaseNotesWindow.xaml @@ -234,6 +235,7 @@ + PreserveNewest diff --git a/EDEngineer/MainWindowViewModel.cs b/EDEngineer/MainWindowViewModel.cs index 1099214c..e094826e 100644 --- a/EDEngineer/MainWindowViewModel.cs +++ b/EDEngineer/MainWindowViewModel.cs @@ -125,7 +125,11 @@ internal void LoadState(bool forcePickFolder = false) private void ApplyEventsToSate(IEnumerable allLogs) { - var entries = allLogs.Select(l => JsonConvert.DeserializeObject(l, journalEntryConverter)) + var entries = allLogs.Select(l => JsonConvert.DeserializeObject(l, new JsonSerializerSettings() + { + Converters = new List() { journalEntryConverter }, + Error = (o, e) => e.ErrorContext.Handled = true + })) .Where(e => e?.Relevant == true) .OrderBy(e => e.TimeStamp) .ToList(); diff --git a/EDEngineer/Models/Entry.cs b/EDEngineer/Models/Entry.cs index c3e81019..8e2874e4 100644 --- a/EDEngineer/Models/Entry.cs +++ b/EDEngineer/Models/Entry.cs @@ -1,6 +1,4 @@ -using System; -using System.ComponentModel; -using System.Linq; +using System.ComponentModel; using System.Runtime.CompilerServices; using EDEngineer.Properties; using EDEngineer.Utils; diff --git a/EDEngineer/Models/JournalEvent.cs b/EDEngineer/Models/JournalEvent.cs index 73208a7e..f7a357ab 100644 --- a/EDEngineer/Models/JournalEvent.cs +++ b/EDEngineer/Models/JournalEvent.cs @@ -5,6 +5,8 @@ namespace EDEngineer.Models public enum JournalEvent { ManualUserChange, + CrewAssign, + CrewHire, Fileheader, LoadGame, Rank, diff --git a/EDEngineer/Models/ReleaseNote.cs b/EDEngineer/Models/ReleaseNote.cs new file mode 100644 index 00000000..37779236 --- /dev/null +++ b/EDEngineer/Models/ReleaseNote.cs @@ -0,0 +1,8 @@ +namespace EDEngineer.Models +{ + public class ReleaseNote + { + public string Version { get; set; } + public string Content { get; set; } + } +} \ No newline at end of file diff --git a/EDEngineer/Models/State.cs b/EDEngineer/Models/State.cs index dbd9434b..2b7c9d3c 100644 --- a/EDEngineer/Models/State.cs +++ b/EDEngineer/Models/State.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using EDEngineer.Utils; using EDEngineer.Utils.Collections; namespace EDEngineer.Models diff --git a/EDEngineer/Properties/Settings.Designer.cs b/EDEngineer/Properties/Settings.Designer.cs index 3a871f12..a3c7281e 100644 --- a/EDEngineer/Properties/Settings.Designer.cs +++ b/EDEngineer/Properties/Settings.Designer.cs @@ -94,7 +94,7 @@ public bool UpgradeRequired { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("1.0.0.12")] + [global::System.Configuration.DefaultSettingValueAttribute("1.0.0.13")] public string Version { get { return ((string)(this["Version"])); diff --git a/EDEngineer/Properties/Settings.settings b/EDEngineer/Properties/Settings.settings index 385f93ee..84f3e72e 100644 --- a/EDEngineer/Properties/Settings.settings +++ b/EDEngineer/Properties/Settings.settings @@ -21,7 +21,7 @@ True - 1.0.0.12 + 1.0.0.13 0 diff --git a/EDEngineer/ReleaseNotesWindow.xaml b/EDEngineer/ReleaseNotesWindow.xaml index 4e30e74b..c68b686e 100644 --- a/EDEngineer/ReleaseNotesWindow.xaml +++ b/EDEngineer/ReleaseNotesWindow.xaml @@ -19,14 +19,14 @@ Grid.Row="0"> - + - diff --git a/EDEngineer/ReleaseNotesWindow.xaml.cs b/EDEngineer/ReleaseNotesWindow.xaml.cs index ad621dfd..c762374b 100644 --- a/EDEngineer/ReleaseNotesWindow.xaml.cs +++ b/EDEngineer/ReleaseNotesWindow.xaml.cs @@ -1,7 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Windows; -using MahApps.Metro.Controls; +using EDEngineer.Models; namespace EDEngineer { @@ -10,7 +9,7 @@ namespace EDEngineer /// public partial class ReleaseNotesWindow { - public ReleaseNotesWindow(IEnumerable> list, string title) + public ReleaseNotesWindow(IEnumerable list, string title) { InitializeComponent(); Title = title; diff --git a/EDEngineer/Resources/Data/releaseNotes.json b/EDEngineer/Resources/Data/releaseNotes.json new file mode 100644 index 00000000..74f3030a --- /dev/null +++ b/EDEngineer/Resources/Data/releaseNotes.json @@ -0,0 +1,51 @@ +[ + { + "Version": "1.0.0.13", + "Content": "Fixed issue which would make the application crash when it would read invalid json outputted by the game" + }, + { + "Version": "1.0.0.12", + "Content": "Fixed issue with release notes not showing up" + }, + { + "Version": "1.0.0.11", + "Content": "* Working release notes (don't panic if you see \"current version 1.0.0.0\", that's only the first time)\r\n* Favorited blueprints have their ingredients display a little star in your cargo list\r\n* New craftable filter for when only commodities are missing\r\n* Autoselect text when overriding cargo's count (protip: use TAB key to change currently editing entry)\r\n* New filter for ingredients (tick an ingredient to only see blueprints that require it)\r\n* Handle Material Discovery events (issue in Elite Dangerous itself, but I tried to handle it here as best as I could)" + }, + { + "Version": "1.0.0.10", + "Content": "Fixed a bug in the monitoring of file with a temporary solution until I find what's wrong with .NET's FileSystemWatcher" + }, + { + "Version": "1.0.0.9", + "Content": "* Improve the refresh rate of the data\r\n* Fixed a bug where if you had the zero as hidden, the acquisition of a material would make the application crash" + }, + { + "Version": "1.0.0.8", + "Content": "Fix an issue which could make some blueprints not visible in the list" + }, + { + "Version": "1.0.0.7", + "Content": "Take synthesis logs into account (they were not before, so if you do synthesis please check your materials)" + }, + { + "Version": "1.0.0.6", + "Content": "Added new release notes popup when an update has been installed." + }, + { + "Version": "1.0.0.5", + "Content": "* Fixed crash when parsing logs for entries that report material collection without size reported (probably old logs)\r\n* Unlocking the window now make it like a real \"normal\" window (minimize, maximize, appears in taskbar, etc...)\r\n\r\nUnknown materials added:\r\n* uncutfocuscrystals\r\n* fedcorecomposites\r\n* unknownenergysource" + }, + { + "Version": "1.0.0.4", + "Content": "* Move/Resize window\r\n* Editable counters" + }, + { + "Version": "1.0.0.3", + "Content": "Added missing data:\r\n* Pattern Alpha Obelisk Data\r\n* Pattern Beta Obelisk Data\r\n* Pattern Epsilon Obelisk Data\r\n* Pattern Gamma Obelisk Data\r\n* Pattern Delta Obelisk Data\r\n\r\nAdded missing material:\r\n* Proprietary Composites" + }, + { + "Version": "1.0.0.2", + "Content": "2.2 blueprints added" + } +] + diff --git a/EDEngineer/Utils/JournalEntryConverter.cs b/EDEngineer/Utils/JournalEntryConverter.cs index b10d75c1..7a762a1a 100644 --- a/EDEngineer/Utils/JournalEntryConverter.cs +++ b/EDEngineer/Utils/JournalEntryConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Windows.Forms; @@ -34,7 +33,18 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist JsonSerializer serializer) { reader.DateParseHandling = DateParseHandling.None; - var data = JObject.Load(reader); + + JObject data; + + try + { + data = JObject.Load(reader); + } + catch(JsonReaderException) + { + // malformed json outputted by the game, nothing we can do here + return new JournalEntry(); + } var entry = new JournalEntry { @@ -42,20 +52,25 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist OriginalJson = data.ToString() }; - JournalEvent journalEvent; + JournalEvent? journalEvent; try { - journalEvent = data["event"].ToObject(serializer); + journalEvent = data["event"]?.ToObject(serializer); } - catch (JsonSerializationException) + catch (Exception) + { + return entry; + } + + if (!journalEvent.HasValue) { return entry; } try { - entry.JournalOperation = ExtractOperation(data, journalEvent); + entry.JournalOperation = ExtractOperation(data, journalEvent.Value); } catch (Exception e) { @@ -67,7 +82,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (entry.JournalOperation != null) { - entry.JournalOperation.JournalEvent = journalEvent; + entry.JournalOperation.JournalEvent = journalEvent.Value; } return entry; diff --git a/EDEngineer/Utils/System/IOManager.cs b/EDEngineer/Utils/System/IOManager.cs index 82db7a61..6934ac5d 100644 --- a/EDEngineer/Utils/System/IOManager.cs +++ b/EDEngineer/Utils/System/IOManager.cs @@ -132,6 +132,7 @@ var file in public static string RetrieveLogDirectory(bool forcePickFolder, string currentLogDirectory) { + return @"C:\Users\Max\Documents\download"; string logDirectory = null; if (!forcePickFolder) @@ -214,6 +215,15 @@ public static string GetBlueprintsJson() } } + public static string GetReleaseNotesJson() + { + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EDEngineer.Resources.Data.releaseNotes.json")) + using (var reader = new StreamReader(stream)) + { + return reader.ReadToEnd(); + } + } + public static string GetEntryDatasJson() { using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EDEngineer.Resources.Data.entryData.json")) diff --git a/EDEngineer/Utils/System/ReleaseNotesManager.cs b/EDEngineer/Utils/System/ReleaseNotesManager.cs index 615f027b..a9c5c426 100644 --- a/EDEngineer/Utils/System/ReleaseNotesManager.cs +++ b/EDEngineer/Utils/System/ReleaseNotesManager.cs @@ -1,12 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Net; -using System.Net.Http; -using System.Text; -using System.Windows.Forms; +using EDEngineer.Models; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace EDEngineer.Utils.System { @@ -22,31 +18,7 @@ public static void ShowReleaseNotes(string oldVersionString, string newVersionSt var newVersion = Version.Parse(newVersionString); - string releasesJson = null; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Add("User-Agent", "EDEngineer"); - var response = client.GetAsync("https://api.github.com/repos/msarilar/EDEngineer/releases").Result; - - if (response.StatusCode == HttpStatusCode.OK) - { - releasesJson = response.Content.ReadAsStringAsync().Result; - } - } - - if (releasesJson == null) - { - return; - } - - var releases = (JArray)JsonConvert.DeserializeObject(releasesJson); - - var releaseNotes = - from release in releases - let releaseVersionString = (string)release["tag_name"] - let releaseVersion = Version.Parse(releaseVersionString) - orderby releaseVersion descending - select Tuple.Create(releaseVersionString, (string) release["body"]); + var releaseNotes = JsonConvert.DeserializeObject>(IOManager.GetReleaseNotesJson()); var list = releaseNotes.ToList(); if (list.Any())