OSDN Git Service

バージョン12.11の準備
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / Config.cs
index e6030d1..7f09eb1 100644 (file)
@@ -18,12 +18,17 @@ using System.Drawing;
 using System.IO;\r
 using System.Linq;\r
 using System.Xml.Serialization;\r
+using KancolleSniffer.Forms;\r
+\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
@@ -41,8 +46,9 @@ namespace KancolleSniffer
     [Flags]\r
     public enum ShipCategory\r
     {\r
+        // ReSharper disable UnusedMember.Global\r
         None = 0,\r
-        BattleShip = 1 << 0,\r
+        BattleShip = 1,\r
         AircraftCarrier = 1 << 1,\r
         HeavyCruiser = 1 << 2,\r
         LightCruiser = 1 << 3,\r
@@ -50,6 +56,7 @@ namespace KancolleSniffer
         Escort = 1 << 5,\r
         Submarine = 1 << 6,\r
         Assistant = 1 << 7,\r
+        // ReSharper restore UnusedMember.Global\r
         All = (1 << 8) - 1\r
     }\r
 \r
@@ -60,9 +67,11 @@ namespace KancolleSniffer
         public Size Size { get; set; }\r
         public string Mode { get; set; }\r
         public ShipCategory ShipCategories { get; set; } = ShipCategory.All;\r
+        public bool ShipType { get; set; }\r
         public bool ShowHpInPercent { get; set; }\r
         public ListForm.SortOrder SortOrder { get; set; } = ListForm.SortOrder.ExpToNext;\r
         public List<List<int>> ShipGroup { get; set; }\r
+        public bool AutoBattleResult { get; set; } = true;\r
 \r
         public ShipListConfig()\r
         {\r
@@ -102,7 +111,7 @@ namespace KancolleSniffer
     {\r
         public int Volume { get; set; } = 100;\r
 \r
-        public string[] Files { get; set; } =\r
+        public string[] Files =\r
         {\r
             "ensei.mp3",\r
             "nyuukyo.mp3",\r
@@ -113,7 +122,8 @@ namespace KancolleSniffer
             "20min.mp3",\r
             "syuuri.mp3",\r
             "syuuri2.mp3",\r
-            "hirou.mp3"\r
+            "hirou.mp3",\r
+            "ninmu.mp3"\r
         };\r
 \r
         public string this[string name]\r
@@ -131,14 +141,12 @@ 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
         Preliminary = 1 << 7\r
     }\r
 \r
-\r
     public class NotificationSpec\r
     {\r
         public string Name { get; set; }\r
@@ -174,17 +182,6 @@ namespace KancolleSniffer
                 PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod;\r
             }\r
         }\r
-\r
-        public void Normalization()\r
-        {\r
-            Settings = Settings.Select(s =>\r
-                    (s & NotificationType.Pushbullet) != 0\r
-                        ? s ^ NotificationType.Pushbullet | NotificationType.Push\r
-                        : s)\r
-                .ToArray();\r
-            RepeatIntervals = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray();\r
-            PreliminaryPeriods = PreliminaryPeriods.Select(v => v < 0 ? 0 : v).ToArray();\r
-        }\r
     }\r
 \r
     public class LocationPerMachine\r
@@ -194,6 +191,7 @@ namespace KancolleSniffer
         public int Zoom { get; set; } = 100;\r
         public Point ListLocation { get; set; }\r
         public Size ListSize { get; set; }\r
+        public List<ShipListConfig> ListFromGroup { get; set; }\r
     }\r
 \r
     [Flags]\r
@@ -203,6 +201,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
@@ -213,6 +212,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
@@ -220,28 +220,27 @@ namespace KancolleSniffer
         public bool HideOnMinimized { get; set; }\r
         public bool ExitSilently { get; set; }\r
         public int Zoom { get; set; } = 100;\r
+        public string Shape { get; set; } = "縦長";\r
+        public int QuestLines { get; set; } = 6;\r
         public bool SaveLocationPerMachine { get; set; }\r
         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
         public SoundConfig Sounds { get; set; } = new SoundConfig();\r
         public bool DebugLogging { get; set; }\r
         public string DebugLogFile { get; set; } = "log.txt";\r
         public ProxyConfig Proxy { get; set; } = new ProxyConfig();\r
         public ShipListConfig ShipList { get; set; } = new ShipListConfig();\r
+        public List<ShipListConfig> ListFormGroup { get; set; } = new List<ShipListConfig>();\r
         public LogConfig Log { get; set; } = new LogConfig();\r
         public PushbulletConfig Pushbullet { get; set; } = new PushbulletConfig();\r
         public PushoverConfig Pushover { get; set; } = new PushoverConfig();\r
@@ -249,7 +248,7 @@ namespace KancolleSniffer
         public static readonly string[] NotificationNames =\r
         {\r
             "遠征終了", "入渠終了", "建造完了", "艦娘数超過", "装備数超過",\r
-            "大破警告", "泊地修理20分経過", "泊地修理進行", "泊地修理完了", "疲労回復"\r
+            "大破警告", "泊地修理20分経過", "泊地修理進行", "泊地修理完了", "疲労回復", "任務達成"\r
         };\r
 \r
         public static readonly Dictionary<string, int> NotificationIndex =\r
@@ -265,7 +264,7 @@ namespace KancolleSniffer
             ConvertPath(PrependBaseDir);\r
         }\r
 \r
-        public void InitializeValues()\r
+        private void InitializeValues()\r
         {\r
             NotifyConditions = new List<int>(new[] {40, 49});\r
             ResetHours = new List<int>(new[] {2});\r
@@ -281,13 +280,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.Normalization();\r
-                ComposeNotificationFlags();\r
-                if (AlwaysShowResultRank)\r
-                {\r
-                    Spoilers = Spoiler.All;\r
-                    AlwaysShowResultRank = false;\r
-                }\r
                 if (SaveLocationPerMachine)\r
                 {\r
                     foreach (var l in LocationList)\r
@@ -298,6 +290,7 @@ namespace KancolleSniffer
                         Zoom = l.Zoom;\r
                         ShipList.Location = l.ListLocation;\r
                         ShipList.Size = l.ListSize;\r
+                        ListFormGroup = l.ListFromGroup;\r
                     }\r
                 }\r
             }\r
@@ -308,19 +301,12 @@ namespace KancolleSniffer
             }\r
             catch (InvalidOperationException ex)\r
             {\r
+                File.Delete(ConfigFile);\r
                 throw new Exception(FileName + "が壊れています。", ex);\r
             }\r
             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
@@ -332,14 +318,14 @@ namespace KancolleSniffer
                     Location = Location,\r
                     Zoom = Zoom,\r
                     ListLocation = ShipList.Location,\r
-                    ListSize = ShipList.Size\r
+                    ListSize = ShipList.Size,\r
+                    ListFromGroup = ListFormGroup\r
                 });\r
             }\r
             else\r
             {\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
@@ -349,13 +335,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