-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e08c694
commit d99a5dc
Showing
2 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
Hearthstone Collection Tracker/Internal/DataUpdaters/DataUpdaterV032.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Hearthstone_Collection_Tracker.Internal.DataUpdaters | ||
{ | ||
public class DataUpdaterV032 : IDataUpdater | ||
{ | ||
private static readonly Version _version = new Version(0, 3, 2); | ||
|
||
public Version Version | ||
{ | ||
get | ||
{ | ||
return _version; | ||
} | ||
} | ||
|
||
private string ConfigFilePath | ||
{ | ||
get { return Path.Combine(HearthstoneCollectionTrackerPlugin.PluginDataDir, "config.xml"); } | ||
} | ||
|
||
public bool RequiresUpdate | ||
{ | ||
get | ||
{ | ||
var configFilePath = ConfigFilePath; | ||
if (!Directory.Exists(HearthstoneCollectionTrackerPlugin.PluginDataDir) || !File.Exists(configFilePath)) | ||
{ | ||
return false; | ||
} | ||
|
||
try | ||
{ | ||
var settings = Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Load(configFilePath); | ||
return settings.CurrentVersion < new ModuleVersion(_version); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
public void PerformUpdate() | ||
{ | ||
var configFilePath = ConfigFilePath; | ||
var settings = Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Load(configFilePath); | ||
settings.CurrentVersion = new ModuleVersion(_version); | ||
Hearthstone_Deck_Tracker.XmlManager<PluginSettings>.Save(configFilePath, settings); | ||
} | ||
|
||
[Serializable] | ||
public class PluginSettings | ||
{ | ||
public ModuleVersion CurrentVersion { get; set; } | ||
|
||
public string ActiveAccount { get; set; } | ||
|
||
public List<AccountSummary> Accounts { get; set; } | ||
|
||
public double CollectionWindowWidth { get; set; } | ||
|
||
public double CollectionWindowHeight { get; set; } | ||
|
||
public bool DefaultShowAllCards { get; set; } | ||
|
||
public bool NotifyNewDeckMissingCards { get; set; } | ||
|
||
public bool EnableDesiredCardsFeature { get; set; } | ||
} | ||
} | ||
} |