X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FConfig.cs;h=7f09eb1abcb74f7ca4c23ca6eec7fcf8d449c9e2;hb=HEAD;hp=e6030d1010ac53192dae7c634a6b26c6d728d301;hpb=d8ddb1892039bc72de1baf90ce8d7cd5a8afcaad;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/Config.cs b/KancolleSniffer/Config.cs index e6030d1..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,9 @@ namespace KancolleSniffer [Flags] public enum ShipCategory { + // ReSharper disable UnusedMember.Global None = 0, - BattleShip = 1 << 0, + BattleShip = 1, AircraftCarrier = 1 << 1, HeavyCruiser = 1 << 2, LightCruiser = 1 << 3, @@ -50,6 +56,7 @@ namespace KancolleSniffer Escort = 1 << 5, Submarine = 1 << 6, Assistant = 1 << 7, + // ReSharper restore UnusedMember.Global All = (1 << 8) - 1 } @@ -60,9 +67,11 @@ namespace KancolleSniffer public Size Size { get; set; } public string Mode { get; set; } public ShipCategory ShipCategories { get; set; } = ShipCategory.All; + public bool ShipType { get; set; } public bool ShowHpInPercent { get; set; } public ListForm.SortOrder SortOrder { get; set; } = ListForm.SortOrder.ExpToNext; public List> ShipGroup { get; set; } + public bool AutoBattleResult { get; set; } = true; public ShipListConfig() { @@ -102,7 +111,7 @@ namespace KancolleSniffer { public int Volume { get; set; } = 100; - public string[] Files { get; set; } = + public string[] Files = { "ensei.mp3", "nyuukyo.mp3", @@ -113,7 +122,8 @@ namespace KancolleSniffer "20min.mp3", "syuuri.mp3", "syuuri2.mp3", - "hirou.mp3" + "hirou.mp3", + "ninmu.mp3" }; public string this[string name] @@ -131,14 +141,12 @@ namespace KancolleSniffer ShowBaloonTip = 1 << 1, PlaySound = 1 << 2, All = (1 << 3) - 1, - Pushbullet = 1 << 3, Push = 1 << 4, Repeat = 1 << 5, Cont = 1 << 6, Preliminary = 1 << 7 } - public class NotificationSpec { public string Name { get; set; } @@ -174,17 +182,6 @@ namespace KancolleSniffer PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod; } } - - public void Normalization() - { - Settings = Settings.Select(s => - (s & NotificationType.Pushbullet) != 0 - ? s ^ NotificationType.Pushbullet | NotificationType.Push - : s) - .ToArray(); - RepeatIntervals = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray(); - PreliminaryPeriods = PreliminaryPeriods.Select(v => v < 0 ? 0 : v).ToArray(); - } } public class LocationPerMachine @@ -194,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] @@ -203,6 +201,7 @@ namespace KancolleSniffer AirBattleResult = 1 << 1, BattleResult = 1 << 2, NextCell = 1 << 3, + // ReSharper disable once UnusedMember.Global All = (1 << 4) - 1 } @@ -213,6 +212,7 @@ namespace KancolleSniffer NDock = 1 << 1 } + public class Config { public Point Location { get; set; } = new Point(int.MinValue, int.MinValue); @@ -220,28 +220,27 @@ 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; } public SoundConfig Sounds { get; set; } = new SoundConfig(); public bool DebugLogging { get; set; } 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(); @@ -249,7 +248,7 @@ namespace KancolleSniffer public static readonly string[] NotificationNames = { "遠征終了", "入渠終了", "建造完了", "艦娘数超過", "装備数超過", - "大破警告", "泊地修理20分経過", "泊地修理進行", "泊地修理完了", "疲労回復" + "大破警告", "泊地修理20分経過", "泊地修理進行", "泊地修理完了", "疲労回復", "任務達成" }; public static readonly Dictionary NotificationIndex = @@ -265,7 +264,7 @@ namespace KancolleSniffer ConvertPath(PrependBaseDir); } - public void InitializeValues() + private void InitializeValues() { NotifyConditions = new List(new[] {40, 49}); ResetHours = new List(new[] {2}); @@ -281,13 +280,6 @@ namespace KancolleSniffer config = (Config)serializer.Deserialize(file); foreach (var property in GetType().GetProperties()) property.SetValue(this, property.GetValue(config, null), null); - Notifications.Normalization(); - ComposeNotificationFlags(); - if (AlwaysShowResultRank) - { - Spoilers = Spoiler.All; - AlwaysShowResultRank = false; - } if (SaveLocationPerMachine) { foreach (var l in LocationList) @@ -298,6 +290,7 @@ namespace KancolleSniffer Zoom = l.Zoom; ShipList.Location = l.ListLocation; ShipList.Size = l.ListSize; + ListFormGroup = l.ListFromGroup; } } } @@ -308,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) @@ -332,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")) @@ -349,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);