OSDN Git Service

設定ファイルのパスの相対化に失敗することがあるのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / Config.cs
index bc883e9..6636163 100644 (file)
@@ -70,12 +70,6 @@ namespace KancolleSniffer
         }\r
     }\r
 \r
-    public class KancolleDbConfig\r
-    {\r
-        public bool On { get; set; }\r
-        public string Token { get; set; } = "";\r
-    }\r
-\r
     public class PushbulletConfig\r
     {\r
         public bool On { get; set; }\r
@@ -123,7 +117,9 @@ namespace KancolleSniffer
         All = (1 << 3) - 1,\r
         Pushbullet = 1 << 3,\r
         Push = 1 << 4,\r
-        Repeat = 1 << 5\r
+        Repeat = 1 << 5,\r
+        Cont = 1 << 6,\r
+        Preliminary = 1 << 7\r
     }\r
 \r
 \r
@@ -132,6 +128,7 @@ namespace KancolleSniffer
         public string Name { get; set; }\r
         public NotificationType Flags { get; set; }\r
         public int RepeatInterval { get; set; }\r
+        public int PreliminaryPeriod { get; set; }\r
     }\r
 \r
     public class NotificationConfig\r
@@ -142,18 +139,23 @@ namespace KancolleSniffer
         public int[] RepeatIntervals =\r
             Config.NotificationNames.Select(x => 0).ToArray();\r
 \r
+        public int[] PreliminaryPeriods =\r
+            Config.NotificationNames.Select(x => 0).ToArray();\r
+\r
         public NotificationSpec this[string name]\r
         {\r
             get => new NotificationSpec\r
             {\r
                 Name = name,\r
                 Flags = Settings[Config.NotificationIndex[name]],\r
-                RepeatInterval = RepeatIntervals[Config.NotificationIndex[name]]\r
+                RepeatInterval = RepeatIntervals[Config.NotificationIndex[name]],\r
+                PreliminaryPeriod = PreliminaryPeriods[Config.NotificationIndex[name]]\r
             };\r
             set\r
             {\r
                 Settings[Config.NotificationIndex[name]] = value.Flags;\r
                 RepeatIntervals[Config.NotificationIndex[name]] = value.RepeatInterval;\r
+                PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod;\r
             }\r
         }\r
     }\r
@@ -167,9 +169,25 @@ namespace KancolleSniffer
         public Size ListSize { get; set; }\r
     }\r
 \r
+    [Flags]\r
+    public enum Spoiler\r
+    {\r
+        ResultRank = 1,\r
+        AirBattleResult = 1 << 1,\r
+        BattleResult = 1 << 2,\r
+        All = (1 << 3) - 1\r
+    }\r
+\r
+    [Flags]\r
+    public enum TimerKind\r
+    {\r
+        Mission = 1,\r
+        NDock = 1 << 1\r
+    }\r
+\r
     public class Config\r
     {\r
-        private readonly string _baseDir = AppDomain.CurrentDomain.BaseDirectory;\r
+        private readonly string _baseDir = AppDomain.CurrentDomain.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar);\r
         private readonly string _configFileName;\r
 \r
         public Point Location { get; set; } = new Point(int.MinValue, int.MinValue);\r
@@ -180,6 +198,7 @@ namespace KancolleSniffer
         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
         public bool ShowBaloonTip { get; set; } = true;\r
         public bool PlaySound { get; set; } = true;\r
@@ -190,6 +209,7 @@ namespace KancolleSniffer
         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 SoundConfig Sounds { get; set; } = new SoundConfig();\r
         public bool DebugLogging { get; set; }\r
@@ -197,7 +217,6 @@ namespace KancolleSniffer
         public ProxyConfig Proxy { get; set; } = new ProxyConfig();\r
         public ShipListConfig ShipList { get; set; } = new ShipListConfig();\r
         public LogConfig Log { get; set; } = new LogConfig();\r
-        public KancolleDbConfig KancolleDb { get; set; } = new KancolleDbConfig();\r
         public PushbulletConfig Pushbullet { get; set; } = new PushbulletConfig();\r
         public PushoverConfig Pushover { get; set; } = new PushoverConfig();\r
 \r
@@ -239,6 +258,11 @@ namespace KancolleSniffer
                         ns[i] = ns[i] ^ NotificationType.Pushbullet | NotificationType.Push;\r
                 }\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
@@ -313,7 +337,7 @@ namespace KancolleSniffer
             if (!path.StartsWith(_baseDir))\r
                 return path;\r
             path = path.Substring(_baseDir.Length);\r
-            return path.StartsWith(Path.DirectorySeparatorChar.ToString()) ? path.Substring(1) : path;\r
+            return path.TrimStart(Path.DirectorySeparatorChar);\r
         }\r
 \r
         private string PrependBaseDir(string path) => Path.IsPathRooted(path) ? path : Path.Combine(_baseDir, path);\r