OSDN Git Service

艦種別表示を復活させる
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 30 Aug 2018 12:25:13 +0000 (21:25 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sat, 1 Sep 2018 07:29:58 +0000 (16:29 +0900)
KancolleSniffer/Config.cs
KancolleSniffer/ListForm.Designer.cs
KancolleSniffer/ListForm.cs
KancolleSniffer/View/ShipListPanel.cs

index e6030d1..fcd7e60 100644 (file)
@@ -60,6 +60,7 @@ namespace KancolleSniffer
         public Size Size { get; set; }\r
         public string Mode { get; set; }\r
         public ShipCategory ShipCategories { get; set; } = ShipCategory.All;\r
+        public bool ShipType;\r
         public bool ShowHpInPercent { get; set; }\r
         public ListForm.SortOrder SortOrder { get; set; } = ListForm.SortOrder.ExpToNext;\r
         public List<List<int>> ShipGroup { get; set; }\r
index 86ad7f7..b479ba1 100644 (file)
@@ -78,6 +78,7 @@ namespace KancolleSniffer
             this.labelFleet2 = new System.Windows.Forms.Label();\r
             this.labelFleet1 = new System.Windows.Forms.Label();\r
             this.panelSType = new System.Windows.Forms.Panel();\r
+            this.checkBoxSTypeDetails = new System.Windows.Forms.CheckBox();\r
             this.checkBoxSTypeAll = new System.Windows.Forms.CheckBox();\r
             this.checkBoxSTypeAuxiliary = new System.Windows.Forms.CheckBox();\r
             this.checkBoxSTypeSubmarine = new System.Windows.Forms.CheckBox();\r
@@ -88,13 +89,13 @@ namespace KancolleSniffer
             this.checkBoxSTypeAircraftCarrier = new System.Windows.Forms.CheckBox();\r
             this.checkBoxSTypeBattleShip = new System.Windows.Forms.CheckBox();\r
             this.labelSTypeButton = new System.Windows.Forms.Label();\r
+            this.labelSType = new System.Windows.Forms.Label();\r
             this.airBattleResultPanel = new KancolleSniffer.View.AirBattleResultPanel();\r
             this.battleResultPanel = new KancolleSniffer.View.BattleResultPanel();\r
             this.antiAirPanel = new KancolleSniffer.View.AntiAirPanel();\r
             this.fleetPanel = new KancolleSniffer.View.FleetPanel();\r
             this.itemTreeView = new KancolleSniffer.View.ItemTreeView();\r
             this.shipListPanel = new KancolleSniffer.View.ShipListPanel();\r
-            this.labelSType = new System.Windows.Forms.Label();\r
             this.contextMenuStripShipList.SuspendLayout();\r
             this.contextMenuStrip.SuspendLayout();\r
             this.panelGroupHeader.SuspendLayout();\r
@@ -410,6 +411,7 @@ namespace KancolleSniffer
             // panelSType\r
             // \r
             this.panelSType.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+            this.panelSType.Controls.Add(this.checkBoxSTypeDetails);\r
             this.panelSType.Controls.Add(this.checkBoxSTypeAll);\r
             this.panelSType.Controls.Add(this.checkBoxSTypeAuxiliary);\r
             this.panelSType.Controls.Add(this.checkBoxSTypeSubmarine);\r
@@ -426,6 +428,17 @@ namespace KancolleSniffer
             this.panelSType.Visible = false;\r
             this.panelSType.Click += new System.EventHandler(this.panelSType_Click);\r
             // \r
+            // checkBoxSTypeDetails\r
+            // \r
+            this.checkBoxSTypeDetails.AutoSize = true;\r
+            this.checkBoxSTypeDetails.Location = new System.Drawing.Point(49, 45);\r
+            this.checkBoxSTypeDetails.Name = "checkBoxSTypeDetails";\r
+            this.checkBoxSTypeDetails.Size = new System.Drawing.Size(48, 16);\r
+            this.checkBoxSTypeDetails.TabIndex = 9;\r
+            this.checkBoxSTypeDetails.Text = "種別";\r
+            this.checkBoxSTypeDetails.UseVisualStyleBackColor = true;\r
+            this.checkBoxSTypeDetails.Click += new System.EventHandler(this.checkBoxSTypeDetails_Click);\r
+            // \r
             // checkBoxSTypeAll\r
             // \r
             this.checkBoxSTypeAll.AutoSize = true;\r
@@ -535,6 +548,16 @@ namespace KancolleSniffer
             this.labelSTypeButton.TabIndex = 19;\r
             this.labelSTypeButton.Click += new System.EventHandler(this.labelSTypeButton_Click);\r
             // \r
+            // labelSType\r
+            // \r
+            this.labelSType.AutoSize = true;\r
+            this.labelSType.Location = new System.Drawing.Point(74, 8);\r
+            this.labelSType.Name = "labelSType";\r
+            this.labelSType.Size = new System.Drawing.Size(29, 12);\r
+            this.labelSType.TabIndex = 20;\r
+            this.labelSType.Text = "艦種";\r
+            this.labelSType.Click += new System.EventHandler(this.labelSTypeButton_Click);\r
+            // \r
             // airBattleResultPanel\r
             // \r
             this.airBattleResultPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \r
@@ -607,16 +630,6 @@ namespace KancolleSniffer
             this.shipListPanel.Size = new System.Drawing.Size(238, 263);\r
             this.shipListPanel.TabIndex = 0;\r
             // \r
-            // labelSType\r
-            // \r
-            this.labelSType.AutoSize = true;\r
-            this.labelSType.Location = new System.Drawing.Point(74, 8);\r
-            this.labelSType.Name = "labelSType";\r
-            this.labelSType.Size = new System.Drawing.Size(29, 12);\r
-            this.labelSType.TabIndex = 20;\r
-            this.labelSType.Text = "艦種";\r
-            this.labelSType.Click += new System.EventHandler(this.labelSTypeButton_Click);\r
-            // \r
             // ListForm\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
@@ -716,5 +729,6 @@ namespace KancolleSniffer
         private System.Windows.Forms.CheckBox checkBoxSTypeBattleShip;\r
         private System.Windows.Forms.Label labelSTypeButton;\r
         private System.Windows.Forms.Label labelSType;\r
+        private System.Windows.Forms.CheckBox checkBoxSTypeDetails;\r
     }\r
 }
\ No newline at end of file
index 48a79a4..e306441 100644 (file)
@@ -219,6 +219,7 @@ namespace KancolleSniffer
             for (var type = 0; type < _shipTypeCheckBoxes.Length; type++)\r
                 _shipTypeCheckBoxes[type].Checked = ((int)_config.ShipList.ShipCategories & (1 << type)) != 0;\r
             checkBoxSTypeAll.Checked = _config.ShipList.ShipCategories == ShipCategory.All;\r
+            checkBoxSTypeDetails.Checked = _config.ShipList.ShipType;\r
         }\r
 \r
         private void ShipListForm_FormClosing(object sender, FormClosingEventArgs e)\r
@@ -425,5 +426,12 @@ namespace KancolleSniffer
             panelSType.Visible = visible;\r
             labelSTypeButton.BackColor = visible ? CustomColors.ActiveButtonColor : DefaultBackColor;\r
         }\r
+\r
+        private void checkBoxSTypeDetails_Click(object sender, EventArgs e)\r
+        {\r
+            _config.ShipList.ShipType = checkBoxSTypeDetails.Checked;\r
+            UpdateList();\r
+            SetActiveControl();\r
+        }\r
     }\r
 }
\ No newline at end of file
index 541cc20..61cb579 100644 (file)
@@ -108,9 +108,19 @@ namespace KancolleSniffer.View
         {\r
             var ships = FilterByShipTypes(\r
                 _mode == "修復" ? sniffer.RepairList : FilterByGroup(sniffer.ShipList, _mode),\r
-                config.ShipCategories);\r
+                config.ShipCategories).ToArray();\r
             var order = _mode == "修復" ? ListForm.SortOrder.Repair : config.SortOrder;\r
-            _shipList = ships.OrderBy(s => s, new CompareShip(false, order)).ToArray();\r
+            if (!config.ShipType)\r
+            {\r
+                _shipList = ships.OrderBy(s => s, new CompareShip(false, order)).ToArray();\r
+                return;\r
+            }\r
+            _shipList = ships.Select(ship => new {Id = ship.Spec.ShipType, Name = ship.Spec.ShipTypeName})\r
+                .Distinct().Select(type => new ShipStatus\r
+                {\r
+                    Spec = new ShipSpec { Name = type.Name, ShipType = type.Id},\r
+                    Level = 1000,\r
+                }).Concat(ships).OrderBy(ship => ship, new CompareShip(true, order)).ToArray();\r
         }\r
 \r
         private IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships, string group)\r
@@ -121,7 +131,7 @@ namespace KancolleSniffer.View
             return from s in ships where GroupSettings[g].Contains(s.Id) select s;\r
         }\r
 \r
-        private readonly int[][] _shipTypeIds =\r
+        private static readonly int[][] ShipTypeIds =\r
         {\r
             new[] // 戦艦\r
             {\r
@@ -169,11 +179,22 @@ namespace KancolleSniffer.View
             }\r
         };\r
 \r
+        private static readonly int[] ShipTypeSortIds = CreateShipTypeSortIds();\r
+\r
+        private static int[] CreateShipTypeSortIds()\r
+        {\r
+            var ids = ShipTypeIds.SelectMany(x => x).ToArray();\r
+            var res = new int[ids.Max() + 1];\r
+            for (var i = 0; i < ids.Length; i++)\r
+                res[ids[i]] = i;\r
+            return res;\r
+        }\r
+\r
         private IEnumerable<ShipStatus> FilterByShipTypes(IEnumerable<ShipStatus> ships, ShipCategory shipTypes)\r
         {\r
-            var ids = Enumerable.Range(0, _shipTypeIds.Length)\r
+            var ids = Enumerable.Range(0, ShipTypeIds.Length)\r
                 .Where(type => ((int)shipTypes & (1 << type)) != 0)\r
-                .SelectMany(type => _shipTypeIds[type]).ToArray();\r
+                .SelectMany(type => ShipTypeIds[type]).ToArray();\r
             return ships.Where(ship => ids.Contains(ship.Spec.ShipType));\r
         }\r
 \r
@@ -197,7 +218,7 @@ namespace KancolleSniffer.View
                 if (_shipType)\r
                 {\r
                     if (a.Spec.ShipType != b.Spec.ShipType)\r
-                        return a.Spec.ShipType - b.Spec.ShipType;\r
+                        return ShipTypeSortIds[a.Spec.ShipType] - ShipTypeSortIds[b.Spec.ShipType];\r
                     if (a.Level != b.Level)\r
                     {\r
                         if (a.Level == 1000)\r
@@ -480,6 +501,7 @@ namespace KancolleSniffer.View
             if (s.Level == 1000) // 艦種の表示\r
             {\r
                 SetShipType(i);\r
+                panel.Visible = true;\r
                 return;\r
             }\r
             labels[0].SetHp(s);\r
@@ -502,7 +524,6 @@ namespace KancolleSniffer.View
             labels[4].SetName(null);\r
             labels[5].SetFleet(null);\r
             labels[5].Text = s.Name;\r
-            _labelPanelList[i].Visible = true;\r
         }\r
 \r
         private void SetGrouping(int i)\r