//TODO // Logic for dealing with legacy config file semantics // Use difference of versions to determine what should be done private void ConvertLegacyConfig(Version currentVersion, Version configVersion) { var converted = false; var v0_3_21 = new Version(0, 3, 21, 0); if (configVersion == null) // Config was created prior to version tracking being introduced (v0.3.20) { // We previously assumed negative pixel coordinates were invalid, but in fact they can go negative // with multi-screen setups. Negative positions were being used to represent 'no specific position' // as a default. That means that when the windows are created for the first time, we let the operating // system decide where to place them. As we should not be using negative positions for this purpose, since // they are in fact a valid range of pixel positions, we now use nullable types instead. The default // 'no specific position' is now expressed when the positions are null. { //Note: Upgraded .HasValue AND .Value into GetValueOrDefault() if (Config.Instance.TrackerWindowLeft.GetValueOrDefault() < 0) { Config.Instance.Reset("TrackerWindowLeft"); converted = true; } if (Config.Instance.TrackerWindowTop.GetValueOrDefault() < 0) { Config.Instance.Reset("TrackerWindowTop"); converted = true; } if (Config.Instance.PlayerWindowLeft.GetValueOrDefault() < 0) { Config.Instance.Reset("PlayerWindowLeft"); converted = true; } if (Config.Instance.PlayerWindowTop.GetValueOrDefault() < 0) { Config.Instance.Reset("PlayerWindowTop"); converted = true; } if (Config.Instance.OpponentWindowLeft.GetValueOrDefault() < 0) { Config.Instance.Reset("OpponentWindowLeft"); converted = true; } if (Config.Instance.OpponentWindowTop.GetValueOrDefault() < 0) { Config.Instance.Reset("OpponentWindowTop"); converted = true; } if (Config.Instance.TimerWindowLeft.GetValueOrDefault() < 0) { Config.Instance.Reset("TimerWindowLeft"); converted = true; } if (Config.Instance.TimerWindowTop.GetValueOrDefault() < 0) { Config.Instance.Reset("TimerWindowTop"); converted = true; } } // Player and opponent window heights were previously set to zero as a default, and then // a bit of logic was used when creating the windows: if height == 0, then set height to 400. // This was a little pointless and also inconsistent with the way the default timer window // dimensions were implemented. Unfortunately we cannot make this consistent without // breaking legacy config files, where the height will still be stored as zero. So // we handle the changed semantics here. if (Config.Instance.PlayerWindowHeight == 0) { Config.Instance.Reset("PlayerWindowHeight"); converted = true; } if (Config.Instance.OpponentWindowHeight == 0) { Config.Instance.Reset("OpponentWindowHeight"); converted = true; } } else { if (configVersion <= v0_3_21) { // Config must be between v0.3.20 and v0.3.21 inclusive // It was still possible in 0.3.21 to see (-32000, -32000) window positions // under certain circumstances (GitHub issue #135). if (Config.Instance.TrackerWindowLeft == -32000) { Config.Instance.Reset("TrackerWindowLeft"); converted = true; } if (Config.Instance.TrackerWindowTop == -32000) { Config.Instance.Reset("TrackerWindowTop"); converted = true; } if (Config.Instance.PlayerWindowLeft == -32000) { Config.Instance.Reset("PlayerWindowLeft"); converted = true; } if (Config.Instance.PlayerWindowTop == -32000) { Config.Instance.Reset("PlayerWindowTop"); converted = true; } if (Config.Instance.OpponentWindowLeft == -32000) { Config.Instance.Reset("OpponentWindowLeft"); converted = true; } if (Config.Instance.OpponentWindowTop == -32000) { Config.Instance.Reset("OpponentWindowTop"); converted = true; } if (Config.Instance.TimerWindowLeft == -32000) { Config.Instance.Reset("TimerWindowLeft"); converted = true; } if (Config.Instance.TimerWindowTop == -32000) { Config.Instance.Reset("TimerWindowTop"); converted = true; } //player scaling used to be increased by a very minimal about to circumvent some problem, //should no longer be required. not sure is the increment is actually noticeable, but resetting can't hurt if (Config.Instance.OverlayOpponentScaling > 100) { Config.Instance.OverlayOpponentScaling = 100; converted = true; } if (Config.Instance.OverlayPlayerScaling > 100) { Config.Instance.OverlayPlayerScaling = 100; converted = true; } } if (configVersion <= new Version(0, 5, 1, 0)) { #pragma warning disable 612 Config.Instance.SaveConfigInAppData = Config.Instance.SaveInAppData; Config.Instance.SaveDataInAppData = Config.Instance.SaveInAppData; converted = true; #pragma warning restore 612 } } if (converted) { Config.SaveBackup(); Config.Save(); } if (configVersion != null && currentVersion > configVersion) { _updatedVersion = currentVersion; } }
// Logic for dealing with legacy config file semantics // Use difference of versions to determine what should be done private void ConvertLegacyConfig(Version currentVersion, Version configVersion) { var converted = false; var v0_3_21 = new Version(0, 3, 21, 0); if (configVersion == null) // Config was created prior to version tracking being introduced (v0.3.20) { Config.Instance.ResetAll(); Config.Instance.CreatedByVersion = currentVersion.ToString(); converted = true; } else { if (configVersion <= v0_3_21) { // Config must be between v0.3.20 and v0.3.21 inclusive // It was still possible in 0.3.21 to see (-32000, -32000) window positions // under certain circumstances (GitHub issue #135). if (Config.Instance.TrackerWindowLeft == -32000) { Config.Instance.Reset("TrackerWindowLeft"); converted = true; } if (Config.Instance.TrackerWindowTop == -32000) { Config.Instance.Reset("TrackerWindowTop"); converted = true; } if (Config.Instance.PlayerWindowLeft == -32000) { Config.Instance.Reset("PlayerWindowLeft"); converted = true; } if (Config.Instance.PlayerWindowTop == -32000) { Config.Instance.Reset("PlayerWindowTop"); converted = true; } if (Config.Instance.OpponentWindowLeft == -32000) { Config.Instance.Reset("OpponentWindowLeft"); converted = true; } if (Config.Instance.OpponentWindowTop == -32000) { Config.Instance.Reset("OpponentWindowTop"); converted = true; } if (Config.Instance.TimerWindowLeft == -32000) { Config.Instance.Reset("TimerWindowLeft"); converted = true; } if (Config.Instance.TimerWindowTop == -32000) { Config.Instance.Reset("TimerWindowTop"); converted = true; } //player scaling used to be increased by a very minimal about to circumvent some problem, //should no longer be required. not sure is the increment is actually noticeable, but resetting can't hurt if (Config.Instance.OverlayOpponentScaling > 100) { Config.Instance.OverlayOpponentScaling = 100; converted = true; } if (Config.Instance.OverlayPlayerScaling > 100) { Config.Instance.OverlayPlayerScaling = 100; converted = true; } } if (configVersion <= new Version(0, 5, 1, 0)) { #pragma warning disable 612 Config.Instance.SaveConfigInAppData = Config.Instance.SaveInAppData; Config.Instance.SaveDataInAppData = Config.Instance.SaveInAppData; converted = true; #pragma warning restore 612 } if (configVersion <= new Version(0, 6, 6, 0)) { if (Config.Instance.ExportClearX == 0.86) { Config.Instance.Reset("ExportClearX"); converted = true; } if (Config.Instance.ExportClearY == 0.16) { Config.Instance.Reset("ExportClearY"); converted = true; } if (Config.Instance.ExportClearCheckYFixed == 0.2) { Config.Instance.Reset("ExportClearCheckYFixed"); converted = true; } } if (configVersion <= new Version(0, 7, 6, 0)) { if (Config.Instance.ExportCard1X != 0.04) { Config.Instance.Reset("ExportCard1X"); converted = true; } if (Config.Instance.ExportCard2X != 0.2) { Config.Instance.Reset("ExportCard2X"); converted = true; } if (Config.Instance.ExportCardsY != 0.168) { Config.Instance.Reset("ExportCardsY"); converted = true; } } if (configVersion <= new Version(0, 9, 6, 0)) { if (!Config.Instance.PanelOrderPlayer.Contains("Fatigue Counter")) { Config.Instance.Reset("PanelOrderPlayer"); converted = true; } if (!Config.Instance.PanelOrderOpponent.Contains("Fatigue Counter")) { Config.Instance.Reset("PanelOrderOpponent"); converted = true; } } if (configVersion <= new Version(0, 10, 10, 0)) //button moved up with new expansion added to the list { Config.Instance.Reset("ExportAllSetsButtonY"); converted = true; } } if (converted) { Logger.WriteLine("changed config values", "ConvertLegacyConfig"); Config.SaveBackup(); Config.Save(); } if (configVersion != null && currentVersion > configVersion) { _updatedVersion = currentVersion; } }
// Logic for dealing with legacy config file semantics // Use difference of versions to determine what should be done private void ConvertLegacyConfig(Version currentVersion, Version configVersion) { var converted = false; var v0_3_21 = new Version(0, 3, 21, 0); if (configVersion == null) // Config was created prior to version tracking being introduced (v0.3.20) { Config.Instance.ResetAll(); Config.Instance.CreatedByVersion = currentVersion.ToString(); converted = true; } else { if (configVersion <= v0_3_21) { // Config must be between v0.3.20 and v0.3.21 inclusive // It was still possible in 0.3.21 to see (-32000, -32000) window positions // under certain circumstances (GitHub issue #135). if (Config.Instance.TrackerWindowLeft == -32000) { Config.Instance.Reset("TrackerWindowLeft"); converted = true; } if (Config.Instance.TrackerWindowTop == -32000) { Config.Instance.Reset("TrackerWindowTop"); converted = true; } if (Config.Instance.PlayerWindowLeft == -32000) { Config.Instance.Reset("PlayerWindowLeft"); converted = true; } if (Config.Instance.PlayerWindowTop == -32000) { Config.Instance.Reset("PlayerWindowTop"); converted = true; } if (Config.Instance.OpponentWindowLeft == -32000) { Config.Instance.Reset("OpponentWindowLeft"); converted = true; } if (Config.Instance.OpponentWindowTop == -32000) { Config.Instance.Reset("OpponentWindowTop"); converted = true; } if (Config.Instance.TimerWindowLeft == -32000) { Config.Instance.Reset("TimerWindowLeft"); converted = true; } if (Config.Instance.TimerWindowTop == -32000) { Config.Instance.Reset("TimerWindowTop"); converted = true; } //player scaling used to be increased by a very minimal about to circumvent some problem, //should no longer be required. not sure is the increment is actually noticeable, but resetting can't hurt if (Config.Instance.OverlayOpponentScaling > 100) { Config.Instance.OverlayOpponentScaling = 100; converted = true; } if (Config.Instance.OverlayPlayerScaling > 100) { Config.Instance.OverlayPlayerScaling = 100; converted = true; } } if (configVersion <= new Version(0, 5, 1, 0)) { #pragma warning disable 612 Config.Instance.SaveConfigInAppData = Config.Instance.SaveInAppData; Config.Instance.SaveDataInAppData = Config.Instance.SaveInAppData; converted = true; #pragma warning restore 612 } } if (converted) { Config.SaveBackup(); Config.Save(); } if (configVersion != null && currentVersion > configVersion) { _updatedVersion = currentVersion; } }