OSDN Git Service

バージョン9以前の設定ファイルの移行処理を削除する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 28 Feb 2020 12:26:02 +0000 (21:26 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sun, 30 Aug 2020 05:58:20 +0000 (14:58 +0900)
KancolleSniffer/Config.cs

index fc112ff..7e4afc2 100644 (file)
@@ -20,12 +20,13 @@ using System.Linq;
 using System.Xml.Serialization;\r
 // ReSharper disable MemberCanBePrivate.Global\r
 // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global\r
+// ReSharper disable FieldCanBeMadeReadOnly.Global\r
 \r
 namespace KancolleSniffer\r
 {\r
     public class ProxyConfig\r
     {\r
-        public const int DefaultListenPort = 8080;\r
+        private const int DefaultListenPort = 8080;\r
         public bool Auto { get; set; }\r
         public int Listen { get; set; }\r
         public bool UseUpstream { get; set; }\r
@@ -128,15 +129,6 @@ namespace KancolleSniffer
             get => Files[Config.NotificationIndex[name]];\r
             set => Files[Config.NotificationIndex[name]] = value;\r
         }\r
-\r
-        public void Upgrade()\r
-        {\r
-            var expected = Config.NotificationNames.Length;\r
-            if (Files.Length == expected)\r
-                return;\r
-            Array.Resize(ref Files, expected);\r
-            Files[expected - 1] = "ninmu.mp3";\r
-        }\r
     }\r
 \r
     [Flags]\r
@@ -147,7 +139,6 @@ namespace KancolleSniffer
         ShowBaloonTip = 1 << 1,\r
         PlaySound = 1 << 2,\r
         All = (1 << 3) - 1,\r
-        Pushbullet = 1 << 3,\r
         Push = 1 << 4,\r
         Repeat = 1 << 5,\r
         Cont = 1 << 6,\r
@@ -189,37 +180,6 @@ namespace KancolleSniffer
                 PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod;\r
             }\r
         }\r
-\r
-        public void Upgrade()\r
-        {\r
-            UpgradeSettings(ref Settings);\r
-            UpgradeParameterArray(ref RepeatIntervals);\r
-            UpgradeParameterArray(ref PreliminaryPeriods);\r
-        }\r
-\r
-        private void UpgradeSettings(ref NotificationType[] settings)\r
-        {\r
-            for (var i = 0; i < settings.Length; i++)\r
-            {\r
-                if ((settings[i] & NotificationType.Pushbullet) != 0)\r
-                    settings[i] = settings[i] ^ NotificationType.Pushbullet | NotificationType.Push;\r
-            }\r
-            var expected = Config.NotificationNames.Length;\r
-            if (expected == settings.Length)\r
-                return;\r
-            Array.Resize(ref settings, expected);\r
-            settings[expected - 1] = NotificationType.All;\r
-        }\r
-\r
-        private void UpgradeParameterArray(ref int[] array)\r
-        {\r
-            Array.Resize(ref array, Config.NotificationNames.Length);\r
-            for (var i = 0; i < array.Length; i++)\r
-            {\r
-                if (array[i] < 0)\r
-                    array[i] = 0;\r
-            }\r
-        }\r
     }\r
 \r
     public class LocationPerMachine\r
@@ -238,6 +198,7 @@ namespace KancolleSniffer
         AirBattleResult = 1 << 1,\r
         BattleResult = 1 << 2,\r
         NextCell = 1 << 3,\r
+        // ReSharper disable once UnusedMember.Global\r
         All = (1 << 4) - 1\r
     }\r
 \r
@@ -248,6 +209,7 @@ namespace KancolleSniffer
         NDock = 1 << 1\r
     }\r
 \r
+\r
     public class Config\r
     {\r
         public Point Location { get; set; } = new Point(int.MinValue, int.MinValue);\r
@@ -260,17 +222,12 @@ namespace KancolleSniffer
         public List<LocationPerMachine> LocationList { get; set; } = new List<LocationPerMachine>();\r
         public bool ShowHpInPercent { get; set; }\r
         public TimerKind ShowEndTime { get; set; }\r
-        public bool FlashWindow { get; set; } = true;\r
-        // ReSharper disable once IdentifierTypo\r
-        public bool ShowBaloonTip { get; set; } = true;\r
-        public bool PlaySound { get; set; } = true;\r
         public NotificationType NotificationFlags { get; set; } = NotificationType.All;\r
         public NotificationConfig Notifications { get; set; } = new NotificationConfig();\r
         public int MarginShips { get; set; } = 5;\r
         public int MarginEquips { get; set; } = 5;\r
         public List<int> NotifyConditions { get; set; }\r
         public List<int> ResetHours { get; set; }\r
-        public bool AlwaysShowResultRank { get; set; }\r
         public Spoiler Spoilers { get; set; }\r
         public bool UsePresetAkashi { get; set; }\r
         public bool WarnBadDamageWithDameCon { get; set; }\r
@@ -319,14 +276,6 @@ namespace KancolleSniffer
                     config = (Config)serializer.Deserialize(file);\r
                 foreach (var property in GetType().GetProperties())\r
                     property.SetValue(this, property.GetValue(config, null), null);\r
-                Notifications.Upgrade();\r
-                ComposeNotificationFlags();\r
-                Sounds.Upgrade();\r
-                if (AlwaysShowResultRank)\r
-                {\r
-                    Spoilers = Spoiler.All;\r
-                    AlwaysShowResultRank = false;\r
-                }\r
                 if (SaveLocationPerMachine)\r
                 {\r
                     foreach (var l in LocationList)\r
@@ -353,14 +302,6 @@ namespace KancolleSniffer
             ConvertPath(PrependBaseDir);\r
         }\r
 \r
-        private void ComposeNotificationFlags()\r
-        {\r
-            NotificationFlags = (NotificationFlags & ~NotificationType.All) |\r
-                                (FlashWindow ? NotificationType.FlashWindow : 0) |\r
-                                (ShowBaloonTip ? NotificationType.ShowBaloonTip : 0) |\r
-                                (PlaySound ? NotificationType.PlaySound : 0);\r
-        }\r
-\r
         public void Save()\r
         {\r
             if (SaveLocationPerMachine)\r
@@ -379,7 +320,6 @@ namespace KancolleSniffer
             {\r
                 LocationList = new List<LocationPerMachine>();\r
             }\r
-            DecomposeNotificationFlags();\r
             ConvertPath(StripBaseDir);\r
             var serializer = new XmlSerializer(typeof(Config));\r
             using (var file = File.CreateText(ConfigFile + ".tmp"))\r
@@ -389,13 +329,6 @@ namespace KancolleSniffer
             ConvertPath(PrependBaseDir);\r
         }\r
 \r
-        private void DecomposeNotificationFlags()\r
-        {\r
-            FlashWindow = (NotificationFlags & NotificationType.FlashWindow) != 0;\r
-            ShowBaloonTip = (NotificationFlags & NotificationType.ShowBaloonTip) != 0;\r
-            PlaySound = (NotificationFlags & NotificationType.PlaySound) != 0;\r
-        }\r
-\r
         private void ConvertPath(Func<string, string> func)\r
         {\r
             DebugLogFile = func(DebugLogFile);\r