X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FConfig.cs;h=7f09eb1abcb74f7ca4c23ca6eec7fcf8d449c9e2;hb=HEAD;hp=56d9e9ad11b9c4af7fed6f4bddf42e485871dd30;hpb=01d20dda5b1a04ea92f8ecbea5b6cbc58152b2a0;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/Config.cs b/KancolleSniffer/Config.cs index 56d9e9a..7f09eb1 100644 --- a/KancolleSniffer/Config.cs +++ b/KancolleSniffer/Config.cs @@ -18,12 +18,17 @@ using System.Drawing; using System.IO; using System.Linq; using System.Xml.Serialization; +using KancolleSniffer.Forms; + +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global +// ReSharper disable FieldCanBeMadeReadOnly.Global namespace KancolleSniffer { public class ProxyConfig { - public const int DefaultListenPort = 8080; + private const int DefaultListenPort = 8080; public bool Auto { get; set; } public int Listen { get; set; } public bool UseUpstream { get; set; } @@ -41,8 +46,8 @@ namespace KancolleSniffer [Flags] public enum ShipCategory { - None = 0, // ReSharper disable UnusedMember.Global + None = 0, BattleShip = 1, AircraftCarrier = 1 << 1, HeavyCruiser = 1 << 2, @@ -126,15 +131,6 @@ namespace KancolleSniffer get => Files[Config.NotificationIndex[name]]; set => Files[Config.NotificationIndex[name]] = value; } - - public void Upgrade() - { - var expected = Config.NotificationNames.Length; - if (Files.Length == expected) - return; - Array.Resize(ref Files, expected); - Files[expected - 1] = "ninmu.mp3"; - } } [Flags] @@ -145,7 +141,6 @@ namespace KancolleSniffer ShowBaloonTip = 1 << 1, PlaySound = 1 << 2, All = (1 << 3) - 1, - Pushbullet = 1 << 3, Push = 1 << 4, Repeat = 1 << 5, Cont = 1 << 6, @@ -187,37 +182,6 @@ namespace KancolleSniffer PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod; } } - - public void Upgrade() - { - UpgradeSettings(ref Settings); - UpgradeParameterArray(ref RepeatIntervals); - UpgradeParameterArray(ref PreliminaryPeriods); - } - - private void UpgradeSettings(ref NotificationType[] settings) - { - for (var i = 0; i < settings.Length; i++) - { - if ((settings[i] & NotificationType.Pushbullet) != 0) - settings[i] = settings[i] ^ NotificationType.Pushbullet | NotificationType.Push; - } - var expected = Config.NotificationNames.Length; - if (expected == settings.Length) - return; - Array.Resize(ref settings, expected); - settings[expected - 1] = NotificationType.All; - } - - private void UpgradeParameterArray(ref int[] array) - { - Array.Resize(ref array, Config.NotificationNames.Length); - for (var i = 0; i < array.Length; i++) - { - if (array[i] < 0) - array[i] = 0; - } - } } public class LocationPerMachine @@ -227,6 +191,7 @@ namespace KancolleSniffer public int Zoom { get; set; } = 100; public Point ListLocation { get; set; } public Size ListSize { get; set; } + public List ListFromGroup { get; set; } } [Flags] @@ -236,6 +201,7 @@ namespace KancolleSniffer AirBattleResult = 1 << 1, BattleResult = 1 << 2, NextCell = 1 << 3, + // ReSharper disable once UnusedMember.Global All = (1 << 4) - 1 } @@ -246,6 +212,7 @@ namespace KancolleSniffer NDock = 1 << 1 } + public class Config { public Point Location { get; set; } = new Point(int.MinValue, int.MinValue); @@ -253,22 +220,18 @@ namespace KancolleSniffer public bool HideOnMinimized { get; set; } public bool ExitSilently { get; set; } public int Zoom { get; set; } = 100; + public string Shape { get; set; } = "縦長"; public int QuestLines { get; set; } = 6; public bool SaveLocationPerMachine { get; set; } public List LocationList { get; set; } = new List(); public bool ShowHpInPercent { get; set; } public TimerKind ShowEndTime { get; set; } - public bool FlashWindow { get; set; } = true; - // ReSharper disable once IdentifierTypo - public bool ShowBaloonTip { get; set; } = true; - public bool PlaySound { get; set; } = true; public NotificationType NotificationFlags { get; set; } = NotificationType.All; public NotificationConfig Notifications { get; set; } = new NotificationConfig(); public int MarginShips { get; set; } = 5; public int MarginEquips { get; set; } = 5; public List NotifyConditions { get; set; } public List ResetHours { get; set; } - public bool AlwaysShowResultRank { get; set; } public Spoiler Spoilers { get; set; } public bool UsePresetAkashi { get; set; } public bool WarnBadDamageWithDameCon { get; set; } @@ -277,6 +240,7 @@ namespace KancolleSniffer public string DebugLogFile { get; set; } = "log.txt"; public ProxyConfig Proxy { get; set; } = new ProxyConfig(); public ShipListConfig ShipList { get; set; } = new ShipListConfig(); + public List ListFormGroup { get; set; } = new List(); public LogConfig Log { get; set; } = new LogConfig(); public PushbulletConfig Pushbullet { get; set; } = new PushbulletConfig(); public PushoverConfig Pushover { get; set; } = new PushoverConfig(); @@ -300,7 +264,7 @@ namespace KancolleSniffer ConvertPath(PrependBaseDir); } - public void InitializeValues() + private void InitializeValues() { NotifyConditions = new List(new[] {40, 49}); ResetHours = new List(new[] {2}); @@ -316,14 +280,6 @@ namespace KancolleSniffer config = (Config)serializer.Deserialize(file); foreach (var property in GetType().GetProperties()) property.SetValue(this, property.GetValue(config, null), null); - Notifications.Upgrade(); - ComposeNotificationFlags(); - Sounds.Upgrade(); - if (AlwaysShowResultRank) - { - Spoilers = Spoiler.All; - AlwaysShowResultRank = false; - } if (SaveLocationPerMachine) { foreach (var l in LocationList) @@ -334,6 +290,7 @@ namespace KancolleSniffer Zoom = l.Zoom; ShipList.Location = l.ListLocation; ShipList.Size = l.ListSize; + ListFormGroup = l.ListFromGroup; } } } @@ -344,19 +301,12 @@ namespace KancolleSniffer } catch (InvalidOperationException ex) { + File.Delete(ConfigFile); throw new Exception(FileName + "が壊れています。", ex); } ConvertPath(PrependBaseDir); } - private void ComposeNotificationFlags() - { - NotificationFlags = (NotificationFlags & ~NotificationType.All) | - (FlashWindow ? NotificationType.FlashWindow : 0) | - (ShowBaloonTip ? NotificationType.ShowBaloonTip : 0) | - (PlaySound ? NotificationType.PlaySound : 0); - } - public void Save() { if (SaveLocationPerMachine) @@ -368,14 +318,14 @@ namespace KancolleSniffer Location = Location, Zoom = Zoom, ListLocation = ShipList.Location, - ListSize = ShipList.Size + ListSize = ShipList.Size, + ListFromGroup = ListFormGroup }); } else { LocationList = new List(); } - DecomposeNotificationFlags(); ConvertPath(StripBaseDir); var serializer = new XmlSerializer(typeof(Config)); using (var file = File.CreateText(ConfigFile + ".tmp")) @@ -385,13 +335,6 @@ namespace KancolleSniffer ConvertPath(PrependBaseDir); } - private void DecomposeNotificationFlags() - { - FlashWindow = (NotificationFlags & NotificationType.FlashWindow) != 0; - ShowBaloonTip = (NotificationFlags & NotificationType.ShowBaloonTip) != 0; - PlaySound = (NotificationFlags & NotificationType.PlaySound) != 0; - } - private void ConvertPath(Func func) { DebugLogFile = func(DebugLogFile);