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
[Flags]\r
public enum ShipCategory\r
{\r
- None = 0,\r
// ReSharper disable UnusedMember.Global\r
+ None = 0,\r
BattleShip = 1,\r
AircraftCarrier = 1 << 1,\r
HeavyCruiser = 1 << 2,\r
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
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
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
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
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
NDock = 1 << 1\r
}\r
\r
+\r
public class Config\r
{\r
public Point Location { get; set; } = new Point(int.MinValue, int.MinValue);\r
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 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
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
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
Zoom = l.Zoom;\r
ShipList.Location = l.ListLocation;\r
ShipList.Size = l.ListSize;\r
+ ListFormGroup = l.ListFromGroup;\r
}\r
}\r
}\r
}\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
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
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