|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | + |
| 5 | +namespace Hearthstone_Collection_Tracker.Internal.DataUpdaters |
| 6 | +{ |
| 7 | + public class DataUpdaterV032 : IDataUpdater |
| 8 | + { |
| 9 | + private static readonly Version _version = new Version(0, 3, 2); |
| 10 | + |
| 11 | + public Version Version |
| 12 | + { |
| 13 | + get |
| 14 | + { |
| 15 | + return _version; |
| 16 | + } |
| 17 | + } |
| 18 | + |
| 19 | + private string ConfigFilePath |
| 20 | + { |
| 21 | + get { return Path.Combine(HearthstoneCollectionTrackerPlugin.PluginDataDir, "config.xml"); } |
| 22 | + } |
| 23 | + |
| 24 | + public bool RequiresUpdate |
| 25 | + { |
| 26 | + get |
| 27 | + { |
| 28 | + var configFilePath = ConfigFilePath; |
| 29 | + if (!Directory.Exists(HearthstoneCollectionTrackerPlugin.PluginDataDir) || !File.Exists(configFilePath)) |
| 30 | + { |
| 31 | + return false; |
| 32 | + } |
| 33 | + |
| 34 | + try |
| 35 | + { |
| 36 | + var settings = Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Load(configFilePath); |
| 37 | + return settings.CurrentVersion < new ModuleVersion(_version); |
| 38 | + } |
| 39 | + catch (Exception ex) |
| 40 | + { |
| 41 | + return false; |
| 42 | + } |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + public void PerformUpdate() |
| 47 | + { |
| 48 | + var configFilePath = ConfigFilePath; |
| 49 | + var settings = Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Load(configFilePath); |
| 50 | + settings.CurrentVersion = new ModuleVersion(_version); |
| 51 | + Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Save(configFilePath, settings); |
| 52 | + } |
| 53 | + |
| 54 | + [Serializable] |
| 55 | + public class PluginSettings |
| 56 | + { |
| 57 | + public ModuleVersion CurrentVersion { get; set; } |
| 58 | + |
| 59 | + public string ActiveAccount { get; set; } |
| 60 | + |
| 61 | + public List<AccountSummary> Accounts { get; set; } |
| 62 | + |
| 63 | + public double CollectionWindowWidth { get; set; } |
| 64 | + |
| 65 | + public double CollectionWindowHeight { get; set; } |
| 66 | + |
| 67 | + public bool DefaultShowAllCards { get; set; } |
| 68 | + |
| 69 | + public bool NotifyNewDeckMissingCards { get; set; } |
| 70 | + |
| 71 | + public bool EnableDesiredCardsFeature { get; set; } |
| 72 | + } |
| 73 | + } |
| 74 | +} |
0 commit comments