OSDN Git Service

一覧の艦娘の分類をセカンダリに反映させるのに再起動が必要なのを直す
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / View / ShipListPanel / ShipListPanel.cs
index bf590c4..4cfb47d 100644 (file)
@@ -37,7 +37,12 @@ namespace KancolleSniffer.View.ShipListPanel
         private string _mode;\r
         private bool _hpPercent;\r
 \r
-        public HashSet<int>[] GroupSettings => _groupConfigLabels.GroupSettings;\r
+        public List<List<int>> GroupSettings\r
+        {\r
+            get => _groupConfigLabels.GroupSettings;\r
+            set => _groupConfigLabels.GroupSettings = value;\r
+        }\r
+\r
 \r
         public bool GroupUpdated\r
         {\r
@@ -118,7 +123,7 @@ namespace KancolleSniffer.View.ShipListPanel
         private void CreateShipList(Sniffer sniffer, ShipListConfig settings)\r
         {\r
             var ships = FilterByShipTypes(\r
-                _mode == "修復" ? sniffer.RepairList : _groupConfigLabels.FilterByGroup(sniffer.ShipList, _mode),\r
+                _mode == "修復" ? sniffer.RepairList : FilterByGroup(sniffer.ShipList, settings.ShipGroup, _mode),\r
                 settings.ShipCategories).ToArray();\r
             var order = _mode == "修復" ? ListForm.SortOrder.Repair : settings.SortOrder;\r
             if (!settings.ShipType)\r
@@ -134,6 +139,17 @@ namespace KancolleSniffer.View.ShipListPanel
                 }).Concat(ships).OrderBy(ship => ship, new CompareShip(true, order)).ToArray();\r
         }\r
 \r
+        private static IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships,\r
+            IReadOnlyList<List<int>> groups, string groupName)\r
+        {\r
+            var g = Array.FindIndex(new[] {"A", "B", "C", "D"}, x => x == groupName);\r
+            if (g == -1)\r
+                return ships;\r
+            if (groups.Count == 0)\r
+                return new ShipStatus[0];\r
+            return from s in ships where groups[g].Contains(s.Id) select s;\r
+        }\r
+\r
         private static readonly int[][] ShipTypeIds =\r
         {\r
             new[] // 戦艦\r