OSDN Git Service

一覧ウィンドウに海域ゲージの情報を表示する
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Thu, 20 Aug 2015 10:47:21 +0000 (19:47 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 21 Aug 2015 05:22:09 +0000 (14:22 +0900)
KancolleSniffer.Test/SnifferTest.cs
KancolleSniffer/KancolleSniffer.csproj
KancolleSniffer/MiscTextInfo.cs [new file with mode: 0644]
KancolleSniffer/ShipListForm.Designer.cs
KancolleSniffer/ShipListForm.cs
KancolleSniffer/Sniffer.cs

index 1f74f89..1fe102d 100644 (file)
@@ -379,5 +379,28 @@ namespace KancolleSniffer.Test
             SniffLogFile(sniffer, "createitem_001");\r
             PAssert.That(() => sniffer.Item.NowEquips == 606);\r
         }\r
+\r
+        /// <summary>\r
+        /// 海域ゲージ情報を作成する\r
+        /// </summary>\r
+        [TestMethod]\r
+        public void MapInfo()\r
+        {\r
+            var sniffer = new Sniffer();\r
+            SniffLogFile(sniffer, "mapinfo_001");\r
+            PAssert.That(() => sniffer.MiscText ==\r
+                               "[海域ゲージ]\r\n" +\r
+                               "1-6 : 撃破 3/7\r\n5-5 : 撃破 0/5\r\n6-3 : 撃破 0/4\r\n" +\r
+                               "31-1 : HP 0/750\r\n31-2 : HP 0/1050\r\n31-3 : HP 0/2100\r\n31-4 : HP 0/3500\r\n31-5 : HP 1/2450\r\n",\r
+                "最初の海域ゲージ情報");\r
+            SniffLogFile(sniffer, "mapinfo_002");\r
+            PAssert.That(() => sniffer.MiscText == "", "戦闘から戻ったらクリア");\r
+            SniffLogFile(sniffer, "mapinfo_003");\r
+            PAssert.That(() => sniffer.MiscText ==\r
+                               "[海域ゲージ]\r\n" +\r
+                               "1-6 : 撃破 4/7\r\n5-5 : 撃破 0/5\r\n6-3 : 撃破 0/4\r\n" +\r
+                               "31-1 : HP 0/750\r\n31-2 : HP 0/1050\r\n31-3 : HP 0/2100\r\n31-4 : HP 0/3500\r\n31-5 : HP 1/2450\r\n",\r
+                "更新された海域ゲージ情報");\r
+        }\r
     }\r
 }
\ No newline at end of file
index b043be6..1a4c479 100644 (file)
@@ -80,6 +80,7 @@
     </Compile>\r
     <Compile Include="Logger.cs" />\r
     <Compile Include="LogServer.cs" />\r
+    <Compile Include="MiscTextInfo.cs" />\r
     <Compile Include="MissingData.cs" />\r
     <Compile Include="ShipLabels.cs" />\r
     <Compile Include="ShipListForm.cs">\r
diff --git a/KancolleSniffer/MiscTextInfo.cs b/KancolleSniffer/MiscTextInfo.cs
new file mode 100644 (file)
index 0000000..feb6011
--- /dev/null
@@ -0,0 +1,71 @@
+// Copyright (C) 2015 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+//\r
+// This program is part of KancolleSniffer.\r
+//\r
+// KancolleSniffer is free software: you can redistribute it and/or modify\r
+// it under the terms of the GNU General Public License as published by\r
+// the Free Software Foundation, either version 3 of the License, or\r
+// (at your option) any later version.\r
+//\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+//\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, see <http://www.gnu.org/licenses/>.\r
+\r
+using System.Collections.Generic;\r
+\r
+namespace KancolleSniffer\r
+{\r
+    public class MiscTextInfo\r
+    {\r
+         public string Text { get; private set; }\r
+        public bool ClearFlag { private get; set; }\r
+\r
+        public void ClearIfNeeded()\r
+        {\r
+            if (!ClearFlag)\r
+                return;\r
+            Text = "";\r
+            ClearFlag = false;\r
+        }\r
+\r
+        private readonly Dictionary<int, int> _required = new Dictionary<int, int>\r
+        {\r
+            {15, 4},\r
+            {16, 7},\r
+            {25, 4},\r
+            {35, 4},\r
+            {44, 4},\r
+            {45, 5},\r
+            {52, 4},\r
+            {53, 5},\r
+            {54, 5},\r
+            {55, 5},\r
+            {62, 3},\r
+            {63, 4}\r
+        };\r
+\r
+        public void InspectMapInfo(dynamic json)\r
+        {\r
+            Text = "[海域ゲージ]\r\n";\r
+            foreach (var entry in json)\r
+            {\r
+                var map = (int)entry.api_id;\r
+                if (entry.api_eventmap())\r
+                {\r
+                    var evmap = entry.api_eventmap;\r
+                    Text += $"{map / 10}-{map % 10} : HP {(int)evmap.api_now_maphp}/{(int)evmap.api_max_maphp}\r\n";\r
+                    continue;\r
+                }\r
+                if (!entry.api_defeat_count())\r
+                    continue;\r
+                int req;\r
+                var reqStr = _required.TryGetValue(map, out req) ? req.ToString() : "?";\r
+                Text += $"{map / 10}-{map % 10} : 撃破 {(int)entry.api_defeat_count}/{reqStr}\r\n";\r
+            }\r
+        }\r
+    }\r
+}
\ No newline at end of file
index 59a7a2c..607c21f 100644 (file)
@@ -65,6 +65,7 @@ namespace KancolleSniffer
             this.label10 = new System.Windows.Forms.Label();\r
             this.label11 = new System.Windows.Forms.Label();\r
             this.panelItemHeader = new System.Windows.Forms.Panel();\r
+            this.textBoxMiscText = new System.Windows.Forms.TextBox();\r
             this.equipPanel = new KancolleSniffer.EquipPanel();\r
             this.itemTreeView = new KancolleSniffer.ItemTreeView();\r
             this.panelShipList.SuspendLayout();\r
@@ -78,6 +79,7 @@ namespace KancolleSniffer
             | System.Windows.Forms.AnchorStyles.Left)));\r
             this.panelShipList.AutoScroll = true;\r
             this.panelShipList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+            this.panelShipList.Controls.Add(this.textBoxMiscText);\r
             this.panelShipList.Controls.Add(this.equipPanel);\r
             this.panelShipList.Controls.Add(this.itemTreeView);\r
             this.panelShipList.Location = new System.Drawing.Point(6, 23);\r
@@ -203,7 +205,8 @@ namespace KancolleSniffer
             "分類",\r
             "修復",\r
             "装備",\r
-            "艦隊"});\r
+            "艦隊",\r
+            "情報"});\r
             this.comboBoxGroup.Location = new System.Drawing.Point(6, 4);\r
             this.comboBoxGroup.Name = "comboBoxGroup";\r
             this.comboBoxGroup.Size = new System.Drawing.Size(48, 20);\r
@@ -264,6 +267,17 @@ namespace KancolleSniffer
             this.panelItemHeader.Size = new System.Drawing.Size(166, 19);\r
             this.panelItemHeader.TabIndex = 0;\r
             // \r
+            // textBoxMiscText\r
+            // \r
+            this.textBoxMiscText.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.textBoxMiscText.Location = new System.Drawing.Point(0, 0);\r
+            this.textBoxMiscText.Multiline = true;\r
+            this.textBoxMiscText.Name = "textBoxMiscText";\r
+            this.textBoxMiscText.ReadOnly = true;\r
+            this.textBoxMiscText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;\r
+            this.textBoxMiscText.Size = new System.Drawing.Size(236, 261);\r
+            this.textBoxMiscText.TabIndex = 0;\r
+            // \r
             // equipPanel\r
             // \r
             this.equipPanel.AutoScroll = true;\r
@@ -305,6 +319,7 @@ namespace KancolleSniffer
             this.Load += new System.EventHandler(this.ShipListForm_Load);\r
             this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ShipListForm_KeyPress);\r
             this.panelShipList.ResumeLayout(false);\r
+            this.panelShipList.PerformLayout();\r
             this.panelGroupHeader.ResumeLayout(false);\r
             this.panelGroupHeader.PerformLayout();\r
             this.panelRepairHeader.ResumeLayout(false);\r
@@ -337,5 +352,6 @@ namespace KancolleSniffer
         private System.Windows.Forms.Panel panelItemHeader;\r
         private EquipPanel equipPanel;\r
         private ItemTreeView itemTreeView;\r
+        private System.Windows.Forms.TextBox textBoxMiscText;\r
     }\r
 }
\ No newline at end of file
index 4d07098..bd5d01b 100644 (file)
@@ -54,9 +54,10 @@ namespace KancolleSniffer
 \r
         public void UpdateList()\r
         {\r
-            panelItemHeader.Visible = InItemList || InEquip;\r
+            panelItemHeader.Visible = InItemList || InEquip || InMiscText;\r
             itemTreeView.Visible = InItemList;\r
             equipPanel.Visible = InEquip;\r
+            textBoxMiscText.Visible = InMiscText;\r
             if (InItemList)\r
             {\r
                 HideShipLabels();\r
@@ -67,6 +68,11 @@ namespace KancolleSniffer
                 HideShipLabels();\r
                 equipPanel.UpdateEquip(_sniffer);\r
             }\r
+            else if (InMiscText)\r
+            {\r
+                HideShipLabels();\r
+                textBoxMiscText.Text = _sniffer.MiscText;\r
+            }\r
             else\r
             {\r
                 CreateShipList();\r
@@ -412,6 +418,8 @@ namespace KancolleSniffer
 \r
         private bool InEquip => comboBoxGroup.Text == "艦隊";\r
 \r
+        private bool InMiscText => comboBoxGroup.Text == "情報";\r
+\r
         private void ShipListForm_Load(object sender, EventArgs e)\r
         {\r
             panelShipList.Width = (int)Round(PanelWidth * ShipLabel.ScaleFactor.Width) + 3 +\r
@@ -496,7 +504,7 @@ namespace KancolleSniffer
 \r
         private void ShipListForm_KeyPress(object sender, KeyPressEventArgs e)\r
         {\r
-            var g = Array.FindIndex(new[] {'Z', 'A', 'B', 'C', 'D', 'G', 'R', 'W', 'X'},\r
+            var g = Array.FindIndex(new[] {'Z', 'A', 'B', 'C', 'D', 'G', 'R', 'W', 'X', 'I'},\r
                 x => x == char.ToUpper(e.KeyChar));\r
             if (g == -1)\r
                 return;\r
index 3b255ba..9cedd26 100644 (file)
@@ -36,6 +36,7 @@ namespace KancolleSniffer
         private readonly BattleInfo _battleInfo;\r
         private readonly Logger _logger;\r
         private readonly ExMapInfo _exMapInfo = new ExMapInfo();\r
+        private readonly MiscTextInfo _miscTextInfo = new MiscTextInfo();\r
         private readonly Status _status = new Status();\r
         private bool _saveState;\r
         private readonly List<IHaveState> _haveState;\r
@@ -52,7 +53,7 @@ namespace KancolleSniffer
             Mission = 32,\r
             QuestList = 64,\r
             Battle = 128,\r
-            All = 255\r
+            All = 255,\r
         }\r
 \r
         public Sniffer()\r
@@ -118,6 +119,7 @@ namespace KancolleSniffer
                 _battleInfo.InBattle = false;\r
                 _battleInfo.HasDamagedShip = false;\r
                 _shipInfo.ClearEscapedShips();\r
+                _miscTextInfo.ClearIfNeeded();\r
                 SaveState();\r
                 return Update.All;\r
             }\r
@@ -283,6 +285,7 @@ namespace KancolleSniffer
             if (url.EndsWith("api_req_practice/battle_result"))\r
             {\r
                 _battleInfo.InspectPracticeResult(json);\r
+\r
                 return Update.Ship;\r
             }\r
             if (IsCombinedBattleAPI(url))\r
@@ -308,6 +311,7 @@ namespace KancolleSniffer
                 _conditionTimer.InvalidateCond();\r
                 _exMapInfo.InspectMapStart(data);\r
                 _logger.InspectMapStart(data);\r
+                _miscTextInfo.ClearFlag = true;\r
                 return Update.Timer;\r
             }\r
             if (url.EndsWith("api_req_map/next"))\r
@@ -325,7 +329,8 @@ namespace KancolleSniffer
             if (url.EndsWith("api_get_member/mapinfo"))\r
             {\r
                 _exMapInfo.InspectMapInfo(data);\r
-                return Update.None;\r
+                _miscTextInfo.InspectMapInfo(data);\r
+                return Update.Item;\r
             }\r
             return Update.None;\r
         }\r
@@ -394,6 +399,8 @@ namespace KancolleSniffer
 \r
         public ExMapInfo ExMap => _exMapInfo;\r
 \r
+        public string MiscText => _miscTextInfo.Text;\r
+\r
         public void SetLogWriter(Action<string, string, string> writer, Func<DateTime> nowFunc)\r
         {\r
             _logger.SetWriter(writer, nowFunc);\r