-
Notifications
You must be signed in to change notification settings - Fork 47
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
df3374b
commit 18776ef
Showing
3 changed files
with
78 additions
and
2 deletions.
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
75 changes: 75 additions & 0 deletions
75
Hearthstone Collection Tracker/Internal/DataUpdaters/DataUpdaterV031.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,75 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
namespace Hearthstone_Collection_Tracker.Internal.DataUpdaters | ||
{ | ||
public class DataUpdaterV031 : IDataUpdater | ||
{ | ||
private static readonly Version _version = new Version(0, 3, 1); | ||
|
||
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); | ||
settings.EnableDesiredCardsFeature = true; | ||
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; } | ||
} | ||
} | ||
} |
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