コミットメタ情報

リビジョンc28fffc2ead986856a297ab36e1c91b8c50056a2 (tree)
日時2018-03-25 20:22:16
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

HPの数字のクリックでパーセント表示を切り替えられるようにする

変更サマリ

差分

--- a/KancolleSniffer/BattleResultPanel.cs
+++ b/KancolleSniffer/BattleResultPanel.cs
@@ -28,7 +28,6 @@ namespace KancolleSniffer
2828 private readonly List<ShipLabel[]> _friendLabels = new List<ShipLabel[]>();
2929 private readonly List<ShipLabel[]> _enemyLabels = new List<ShipLabel[]>();
3030 private readonly List<Panel> _panelList = new List<Panel>();
31- private bool _hpPercent;
3231 private readonly List<ShipLabel> _hpLabels = new List<ShipLabel>();
3332 private readonly ResizableToolTip _toolTip = new ResizableToolTip {ShowAlways = true};
3433 private readonly BattleInfo.BattleResult[] _result = new BattleInfo.BattleResult[2];
@@ -48,13 +47,17 @@ namespace KancolleSniffer
4847 ResumeLayout();
4948 }
5049
51- public void SetShowHpPercent(bool hpPercent)
50+ public event Action HpLabelClick;
51+
52+ private void HpLabelClickHandler(object sender, EventArgs ev)
53+ {
54+ HpLabelClick?.Invoke();
55+ }
56+
57+ public void ToggleHpPercent()
5258 {
53- if (hpPercent == _hpPercent)
54- return;
5559 foreach (var label in _hpLabels)
5660 label.ToggleHpPercent();
57- _hpPercent = hpPercent;
5861 }
5962
6063 public void Update(Sniffer sniffer)
@@ -250,7 +253,7 @@ namespace KancolleSniffer
250253 _panelList[i].Width = panelWidth;
251254 _infomationPanel.Location = new Point(
252255 (int)Round(0 * ShipLabel.ScaleFactor.Width) + AutoScrollPosition.X,
253- (int)Round(20 * ShipLabel.ScaleFactor.Height) +AutoScrollPosition.Y);
256+ (int)Round(20 * ShipLabel.ScaleFactor.Height) + AutoScrollPosition.Y);
254257 _infomationPanel.Visible = true;
255258 }
256259
@@ -318,6 +321,7 @@ namespace KancolleSniffer
318321 };
319322 _friendLabels.Add(friend);
320323 _hpLabels.Add(friend[0]);
324+ friend[0].Click += HpLabelClickHandler;
321325 var enemy = new[]
322326 {
323327 new ShipLabel {Location = new Point(119, 2), AutoSize = true},
--- a/KancolleSniffer/ListForm.cs
+++ b/KancolleSniffer/ListForm.cs
@@ -44,6 +44,8 @@ namespace KancolleSniffer
4444 InitializeComponent();
4545 _sniffer = sniffer;
4646 _config = config;
47+ battleResultPanel.HpLabelClick += ToggleHpPercent;
48+ shipListPanel.HpLabelClick += ToggleHpPercent;
4749 var swipe = new SwipeScrollify();
4850 swipe.AddShipListPanel(shipListPanel);
4951 swipe.AddTreeView(itemTreeView);
@@ -115,7 +117,6 @@ namespace KancolleSniffer
115117
116118 public void UpdateBattleResult()
117119 {
118- battleResultPanel.SetShowHpPercent(shipListPanel.ShowHpInPercent);
119120 battleResultPanel.Spoiler = (_config.Spoilers & Spoiler.BattleResult) != 0;
120121 battleResultPanel.Update(_sniffer);
121122 }
@@ -174,7 +175,10 @@ namespace KancolleSniffer
174175 var config = _config.ShipList;
175176 checkBoxShipType.Checked = config.ShipType;
176177 if (config.ShowHpInPercent)
178+ {
177179 shipListPanel.ToggleHpPercent();
180+ battleResultPanel.ToggleHpPercent();
181+ }
178182 LoadShipGroupFromConfig();
179183 comboBoxGroup.SelectedItem = config.Mode ?? "全員";
180184 if (config.Location.X == int.MinValue)
@@ -198,7 +202,6 @@ namespace KancolleSniffer
198202 if (!Visible)
199203 return;
200204 var config = _config.ShipList;
201- config.ShowHpInPercent = shipListPanel.ShowHpInPercent;
202205 StoreShipGroupToConfig();
203206 var bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds;
204207 config.Location = bounds.Location;
@@ -358,7 +361,14 @@ namespace KancolleSniffer
358361
359362 private void labelHeaderHp_Click(object sender, EventArgs e)
360363 {
364+ ToggleHpPercent();
365+ }
366+
367+ private void ToggleHpPercent()
368+ {
369+ _config.ShipList.ShowHpInPercent = !_config.ShipList.ShowHpInPercent;
361370 shipListPanel.ToggleHpPercent();
371+ battleResultPanel.ToggleHpPercent();
362372 }
363373 }
364374 }
\ No newline at end of file
--- a/KancolleSniffer/MainFormLabels.cs
+++ b/KancolleSniffer/MainFormLabels.cs
@@ -15,7 +15,6 @@
1515 using System;
1616 using System.Collections.Generic;
1717 using System.Drawing;
18-using System.Linq;
1918 using System.Windows.Forms;
2019 using static System.Math;
2120
@@ -109,13 +108,20 @@ namespace KancolleSniffer
109108 label.Tag = i;
110109 label.Click += onClick;
111110 }
111+ var hpLabel = shipLabels[i][0];
112+ _hpLables.Add(hpLabel);
113+ hpLabel.Click += HpLabelClickHander;
112114 }
113- _hpLables.AddRange(shipLabels.Select(labels => labels[0]));
114115 headings[0].Cursor = Cursors.Hand;
115- headings[0].Click += (sender, ev) => ToggleHpPercent();
116+ headings[0].Click += HpLabelClickHander;
116117 parent.ResumeLayout();
117118 }
118119
120+ private void HpLabelClickHander(object sender, EventArgs ev)
121+ {
122+ ToggleHpPercent();
123+ }
124+
119125 public void ToggleHpPercent()
120126 {
121127 ShowHpInPercent = !ShowHpInPercent;
@@ -184,16 +190,13 @@ namespace KancolleSniffer
184190 label.Tag = i;
185191 label.Click += onClick;
186192 }
193+ var hpLavel = _combinedLabels[i][0];
194+ _hpLables.Add(hpLavel);
195+ hpLavel.Click += HpLabelClickHander;
187196 }
188- _hpLables.AddRange(_combinedLabels.Select(record => record[0]).ToArray());
189197 headings[0].Cursor = headings[2].Cursor = Cursors.Hand;
190- void HpToggle(object sender, EventArgs ev)
191- {
192- foreach (var label in _hpLables)
193- label.ToggleHpPercent();
194- }
195- headings[0].Click += HpToggle;
196- headings[2].Click += HpToggle;
198+ headings[0].Click += HpLabelClickHander;
199+ headings[2].Click += HpLabelClickHander;
197200 parent.ResumeLayout();
198201 }
199202
--- a/KancolleSniffer/ShipListPanel.cs
+++ b/KancolleSniffer/ShipListPanel.cs
@@ -36,7 +36,7 @@ namespace KancolleSniffer
3636 private readonly List<Panel> _repairPanelList = new List<Panel>();
3737 private readonly List<ShipLabel> _hpLabels = new List<ShipLabel>();
3838 private string _mode;
39- public bool ShowHpInPercent { get; private set; }
39+ private bool _hpPercent;
4040
4141 public const int GroupCount = 4;
4242 public HashSet<int>[] GroupSettings { get; } = new HashSet<int>[GroupCount];
@@ -334,9 +334,10 @@ namespace KancolleSniffer
334334 label.PresetColor =
335335 label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];
336336 }
337- if (ShowHpInPercent)
337+ if (_hpPercent)
338338 rpl[0].ToggleHpPercent();
339339 _hpLabels.Add(rpl[0]);
340+ rpl[0].Click += HpLabelClickHandler;
340341 }
341342
342343 private void CreateShipLabels(int i)
@@ -385,9 +386,10 @@ namespace KancolleSniffer
385386 label.PresetColor =
386387 label.BackColor = ShipLabel.ColumnColors[(i + 1) % 2];
387388 }
388- if (ShowHpInPercent)
389+ if (_hpPercent)
389390 labels[0].ToggleHpPercent();
390391 _hpLabels.Add(labels[0]);
392+ labels[0].Click += HpLabelClickHandler;
391393 }
392394
393395 private void SetShipLabels()
@@ -495,9 +497,16 @@ namespace KancolleSniffer
495497 panel.Visible = true;
496498 }
497499
500+ public event Action HpLabelClick;
501+
502+ private void HpLabelClickHandler(object sender, EventArgs ev)
503+ {
504+ HpLabelClick?.Invoke();
505+ }
506+
498507 public void ToggleHpPercent()
499508 {
500- ShowHpInPercent = !ShowHpInPercent;
509+ _hpPercent = !_hpPercent;
501510 foreach (var label in _hpLabels)
502511 label.ToggleHpPercent();
503512 }
旧リポジトリブラウザで表示