OSDN Git Service

メインウィンドウに7隻表示できるようにする
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Sat, 2 Dec 2017 07:47:20 +0000 (16:47 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Sat, 2 Dec 2017 11:27:12 +0000 (20:27 +0900)
KancolleSniffer/MainForm.Designer.cs
KancolleSniffer/MainForm.cs
KancolleSniffer/ShipLabels.cs

index 2d7290e..6f3e8f1 100644 (file)
@@ -165,6 +165,7 @@ namespace KancolleSniffer
             this.toolTipFighterPower = new System.Windows.Forms.ToolTip(this.components);\r
             this.toolTipLoS = new System.Windows.Forms.ToolTip(this.components);\r
             this.panelRepairList = new KancolleSniffer.RepairListForMain();\r
+            this.panel7Ships = new System.Windows.Forms.Panel();\r
             this.panelHeadquarters.SuspendLayout();\r
             this.panelShipInfo.SuspendLayout();\r
             this.panelBattleInfo.SuspendLayout();\r
@@ -304,6 +305,7 @@ namespace KancolleSniffer
             this.panelShipInfo.Controls.Add(this.labelPresetAkashiTimer);\r
             this.panelShipInfo.Controls.Add(this.labelGuide);\r
             this.panelShipInfo.Controls.Add(this.panelCombinedFleet);\r
+            this.panelShipInfo.Controls.Add(this.panel7Ships);\r
             this.panelShipInfo.Controls.Add(this.panelBattleInfo);\r
             this.panelShipInfo.Controls.Add(this.labelLoS);\r
             this.panelShipInfo.Controls.Add(this.labelLoSCaption);\r
@@ -1288,6 +1290,14 @@ namespace KancolleSniffer
             this.panelRepairList.Visible = false;\r
             this.panelRepairList.Click += new System.EventHandler(this.panelRepairList_Click);\r
             // \r
+            // panel7Ships\r
+            // \r
+            this.panel7Ships.Location = new System.Drawing.Point(0, 0);\r
+            this.panel7Ships.Name = "panel7Ships";\r
+            this.panel7Ships.Size = new System.Drawing.Size(220, 115);\r
+            this.panel7Ships.TabIndex = 0;\r
+            this.panel7Ships.Visible = false;\r
+            // \r
             // MainForm\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
@@ -1482,6 +1492,7 @@ namespace KancolleSniffer
         private System.Windows.Forms.ToolTip toolTipFighterPower;\r
         private System.Windows.Forms.ToolTip toolTipLoS;\r
         private RepairListForMain panelRepairList;\r
+        private System.Windows.Forms.Panel panel7Ships;\r
     }\r
 }\r
 \r
index a92d705..db1f285 100644 (file)
@@ -67,6 +67,8 @@ namespace KancolleSniffer
             _shipLabels = new ShipLabels();\r
             _shipLabels.CreateAkashiTimers(panelShipInfo);\r
             _shipLabels.CreateShipLabels(panelShipInfo, ShowShipOnShipList);\r
+            _shipLabels.CreateAkashiTimers7(panel7Ships);\r
+            _shipLabels.CreateShipLabels7(panel7Ships, ShowShipOnShipList);\r
             _shipLabels.CreateCombinedShipLabels(panelCombinedFleet, ShowShipOnShipList);\r
             _shipLabels.CreateNDockLabels(panelDock, labelNDock_Click);\r
             panelRepairList.CreateLabels(panelRepairList_Click);\r
@@ -458,6 +460,7 @@ namespace KancolleSniffer
         private void UpdatePanelShipInfo()\r
         {\r
             var statuses = _sniffer.GetShipStatuses(_currentFleet);\r
+            panel7Ships.Visible = statuses.Length == 7;\r
             _shipLabels.SetShipLabels(statuses);\r
             if (_sniffer.CombinedFleetType == 0)\r
                 _combinedFleet = false;\r
@@ -714,7 +717,8 @@ namespace KancolleSniffer
         {\r
             if (_config.UsePresetAkashi)\r
                 UpdatePresetAkashiTimer();\r
-            _shipLabels.SetAkashiTimer(_sniffer.GetShipStatuses(_currentFleet),\r
+            var statuses = _sniffer.GetShipStatuses(_currentFleet);\r
+            _shipLabels.SetAkashiTimer(statuses,\r
                 _sniffer.AkashiTimer.GetTimers(_currentFleet));\r
             NotifyAkashiTimer();\r
         }\r
index 5b9c2de..925c29e 100644 (file)
@@ -38,17 +38,29 @@ namespace KancolleSniffer
 \r
     public class ShipLabels\r
     {\r
-        private readonly ShipLabel[][] _labels = new ShipLabel[ShipInfo.MemberCount][];\r
+        private readonly ShipLabel[][] _shiplabels = new ShipLabel[ShipInfo.MemberCount][];\r
+        private readonly ShipLabel[][] _shipLabels7 = new ShipLabel[7][];\r
         private readonly ShipLabel[][] _combinedLabels = new ShipLabel[ShipInfo.MemberCount * 2][];\r
         private readonly ShipLabel[] _akashiTimers = new ShipLabel[ShipInfo.MemberCount];\r
+        private readonly ShipLabel[] _akashiTimers7 = new ShipLabel[ShipInfo.MemberCount];\r
         private readonly ShipLabel[][] _ndockLabels = new ShipLabel[DockInfo.DockCount][];\r
         public static Color[] ColumnColors = {SystemColors.Control, Color.FromArgb(255, 250, 250, 250)};\r
         private readonly List<ShipLabel> _hpLables = new List<ShipLabel>();\r
 \r
         public void CreateShipLabels(Control parent, EventHandler onClick)\r
         {\r
+            CreateShipLabels(parent, onClick, _shiplabels, 16);\r
+        }\r
+\r
+        public void CreateShipLabels7(Control parent, EventHandler onClick)\r
+        {\r
+            CreateShipLabels(parent, onClick, _shipLabels7, 14);\r
+        }\r
+\r
+        public void CreateShipLabels(Control parent, EventHandler onClick, ShipLabel[][] shipLabels, int lineHeight)\r
+        {\r
             parent.SuspendLayout();\r
-            const int top = 3, height = 12, lh = 16;\r
+            const int top = 3, height = 12;\r
             ShipLabel[] headings;\r
             parent.Controls.AddRange(headings = new[]\r
             {\r
@@ -56,17 +68,17 @@ namespace KancolleSniffer
                 new ShipLabel {Location = new Point(128, top), Text = "cond", AutoSize = true},\r
                 new ShipLabel {Location = new Point(163, top), Text = "Lv", AutoSize = true},\r
                 new ShipLabel {Location = new Point(194, top), Text = "Exp", AutoSize = true},\r
-                new ShipLabel {Location = new Point(0, 1), Size = new Size(parent.Width, lh - 1)}\r
+                new ShipLabel {Location = new Point(0, 1), Size = new Size(parent.Width, lineHeight - 1)}\r
             });\r
             foreach (var label in headings)\r
             {\r
                 label.Scale();\r
                 label.BackColor = ColumnColors[1];\r
             }\r
-            for (var i = 0; i < _labels.Length; i++)\r
+            for (var i = 0; i < shipLabels.Length; i++)\r
             {\r
-                var y = top + lh * (i + 1);\r
-                parent.Controls.AddRange(_labels[i] = new[]\r
+                var y = top + lineHeight * (i + 1);\r
+                parent.Controls.AddRange(shipLabels[i] = new[]\r
                 {\r
                     new ShipLabel {Location = new Point(129, y), AutoSize = true, AnchorRight = true},\r
                     new ShipLabel\r
@@ -88,9 +100,9 @@ namespace KancolleSniffer
                         TextAlign = ContentAlignment.MiddleRight\r
                     },\r
                     new ShipLabel {Location = new Point(2, y), AutoSize = true}, // 名前のZ-orderを下に\r
-                    new ShipLabel {Location = new Point(0, y - 2), Size = new Size(parent.Width, lh - 1)}\r
+                    new ShipLabel {Location = new Point(0, y - 2), Size = new Size(parent.Width, lineHeight - 1)}\r
                 });\r
-                foreach (var label in _labels[i])\r
+                foreach (var label in shipLabels[i])\r
                 {\r
                     label.Scale();\r
                     label.PresetColor = label.BackColor = ColumnColors[i % 2];\r
@@ -98,7 +110,7 @@ namespace KancolleSniffer
                     label.Click += onClick;\r
                 }\r
             }\r
-            _hpLables.AddRange(_labels.Select(record => record[0]));\r
+            _hpLables.AddRange(shipLabels.Select(labels => labels[0]));\r
             headings[0].Cursor = Cursors.Hand;\r
             headings[0].Click += (sender, ev) =>\r
             {\r
@@ -110,9 +122,14 @@ namespace KancolleSniffer
 \r
         public void SetShipLabels(ShipStatus[] statuses)\r
         {\r
-            for (var i = 0; i < _labels.Length; i++)\r
+            SetShipLabels(statuses, statuses.Length == 7 ? _shipLabels7 : _shiplabels);\r
+        }\r
+\r
+        public void SetShipLabels(ShipStatus[] statuses, ShipLabel[][] shipLabels)\r
+        {\r
+            for (var i = 0; i < shipLabels.Length; i++)\r
             {\r
-                var labels = _labels[i];\r
+                var labels = shipLabels[i];\r
                 var s = i < statuses.Length ? statuses[i] : null;\r
                 labels[0].SetHp(s);\r
                 labels[1].SetCond(s);\r
@@ -193,14 +210,24 @@ namespace KancolleSniffer
 \r
         public void CreateAkashiTimers(Control parent)\r
         {\r
+            CreateAkashiTimers(parent, _akashiTimers, 16);\r
+        }\r
+\r
+        public void CreateAkashiTimers7(Control parent)\r
+        {\r
+            CreateAkashiTimers(parent, _akashiTimers7, 14);\r
+        }\r
+\r
+        public void CreateAkashiTimers(Control parent, ShipLabel[] timerLabels, int lineHeight)\r
+        {\r
             parent.SuspendLayout();\r
-            for (var i = 0; i < _akashiTimers.Length; i++)\r
+            for (var i = 0; i < timerLabels.Length; i++)\r
             {\r
                 const int x = 55;\r
-                var y = 3 + 16 * (i + 1);\r
+                var y = 3 + lineHeight * (i + 1);\r
                 ShipLabel label;\r
                 parent.Controls.Add(\r
-                    label = _akashiTimers[i] =\r
+                    label = timerLabels[i] =\r
                         new ShipLabel\r
                         {\r
                             Location = new Point(x, y),\r
@@ -209,27 +236,46 @@ namespace KancolleSniffer
                         });\r
                 label.BackColor = ColumnColors[i % 2];\r
             }\r
-            foreach (var label in _akashiTimers)\r
+            foreach (var label in timerLabels)\r
                 label.Scale();\r
             parent.ResumeLayout();\r
         }\r
 \r
         public void AdjustAkashiTimers()\r
         {\r
+            AdjustAkashiTimers(_akashiTimers, 16);\r
+            AdjustAkashiTimers(_akashiTimers7, 14);\r
+        }\r
+\r
+        public void AdjustAkashiTimers(ShipLabel[] timers, int lineHeight)\r
+        {\r
             var scale = ShipLabel.ScaleFactor;\r
             if (scale.Height < 1.2)\r
                 return;\r
-            for (var i = 0; i < _akashiTimers.Length; i++)\r
+            for (var i = 0; i < timers.Length; i++)\r
             {\r
                 const int x = 55;\r
-                var y = 3 + 16 * (i + 1);\r
-                _akashiTimers[i].Location = new Point((int)Round(x * scale.Width) - 3, (int)Round(y * scale.Height));\r
-                _akashiTimers[i].Size = new Size((int)Round(31 * scale.Width) + 1, (int)Round(12 * scale.Height));\r
+                var y = 3 + lineHeight * (i + 1);\r
+                timers[i].Location = new Point((int)Round(x * scale.Width) - 3, (int)Round(y * scale.Height));\r
+                timers[i].Size = new Size((int)Round(31 * scale.Width) + 1, (int)Round(12 * scale.Height));\r
             }\r
         }\r
 \r
         public void SetAkashiTimer(ShipStatus[] statuses, AkashiTimer.RepairSpan[] timers)\r
         {\r
+            if (statuses.Length == 7)\r
+            {\r
+                SetAkashiTimer(statuses, timers, _akashiTimers7, _shipLabels7);\r
+            }\r
+            else\r
+            {\r
+\r
+                SetAkashiTimer(statuses, timers, _akashiTimers, _shiplabels);\r
+            }\r
+        }\r
+\r
+        public void SetAkashiTimer(ShipStatus[] statuses, AkashiTimer.RepairSpan[] timers, ShipLabel[] timerLabels, ShipLabel[][] shipLabels)\r
+        {\r
             var shortest = -1;\r
             for (var i = 0; i < timers.Length; i++)\r
             {\r
@@ -238,11 +284,11 @@ namespace KancolleSniffer
                 if (shortest == -1 || timers[i].Span < timers[shortest].Span)\r
                     shortest = i;\r
             }\r
-            for (var i = 0; i < _akashiTimers.Length; i++)\r
+            for (var i = 0; i < timerLabels.Length; i++)\r
             {\r
-                var label = _akashiTimers[i];\r
-                var labelHp = _labels[i][0];\r
-                var labelName = _labels[i][4];\r
+                var label = timerLabels[i];\r
+                var labelHp = shipLabels[i][0];\r
+                var labelName = shipLabels[i][4];\r
                 if (i >= timers.Length || timers[i].Span == TimeSpan.MinValue)\r
                 {\r
                     label.Visible = false;\r