コミットメタ情報

リビジョン03997ac63250b267597f7c3ee0904d0585bbb71c (tree)
日時2018-06-16 21:32:00
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

大破警告をリピート可能にする

変更サマリ

差分

--- a/KancolleSniffer.Test/NotificationManagerTest.cs
+++ b/KancolleSniffer.Test/NotificationManagerTest.cs
@@ -326,6 +326,59 @@ namespace KancolleSniffer.Test
326326 }
327327
328328 /// <summary>
329+ /// リピートを例外付きで中断・再開する
330+ /// </summary>
331+ [TestMethod]
332+ public void SuspendRepeatWithException()
333+ {
334+ var time = new TimeProvider();
335+ Message result = null;
336+ var manager =
337+ new NotificationManager((t, b, n) => { result = new Message {Title = t, Body = b, Name = n}; }, time.GetNow);
338+ var ensei = new Message {Title = "遠征が終わりました", Body = "第二艦隊 防空射撃演習", Name = "遠征終了"};
339+ var taiha = new Message {Title = "大破した艦娘がいます", Body = "摩耶改二", Name = "大破警告"};
340+ var elapsed = 0;
341+ while (true)
342+ {
343+ switch (elapsed)
344+ {
345+ case 0:
346+ manager.Enqueue("遠征終了", 1, "防空射撃演習", 10);
347+ manager.Flash();
348+ PAssert.That(() => ensei.Equals(result));
349+ break;
350+ case 1000:
351+ manager.Flash();
352+ manager.SuspendRepeat("大破警告");
353+ break;
354+ case 2000:
355+ manager.Enqueue("大破警告", "摩耶改二", 8);
356+ manager.Flash();
357+ PAssert.That(() => taiha.Equals(result));
358+ break;
359+ case 10000:
360+ manager.Flash();
361+ PAssert.That(() => taiha.Repeat.Equals(result));
362+ break;
363+ case 11000:
364+ manager.Flash();
365+ manager.ResumeRepeat();
366+ break;
367+ case 12000:
368+ manager.Flash();
369+ PAssert.That(() => ensei.Repeat.Equals(result));
370+ return;
371+ default:
372+ manager.Flash();
373+ PAssert.That(() => result == null, elapsed.ToString());
374+ break;
375+ }
376+ result = null;
377+ elapsed += 1000;
378+ }
379+ }
380+
381+ /// <summary>
329382 /// リピート中の特定の通知を止める
330383 /// </summary>
331384 [TestMethod]
--- a/KancolleSniffer/MainForm.cs
+++ b/KancolleSniffer/MainForm.cs
@@ -159,7 +159,7 @@ namespace KancolleSniffer
159159
160160 public void Stop(string key, int fleet) => _manager.StopRepeat(key, fleet);
161161
162- public void Suspend() => _manager.SuspendRepeat();
162+ public void Suspend(string exception = null) => _manager.SuspendRepeat(exception);
163163
164164 public void Resume() => _manager.ResumeRepeat();
165165 }
@@ -661,7 +661,7 @@ namespace KancolleSniffer
661661 {
662662 if (!_sniffer.BadlyDamagedShips.Any())
663663 return;
664- _notificationManager.Enqueue("大破警告", string.Join(" ", _sniffer.BadlyDamagedShips));
664+ SetNotification("大破警告", string.Join(" ", _sniffer.BadlyDamagedShips));
665665 _notificationManager.Flash();
666666 }
667667
--- a/KancolleSniffer/NotificationConfigDialog.cs
+++ b/KancolleSniffer/NotificationConfigDialog.cs
@@ -40,7 +40,6 @@ namespace KancolleSniffer
4040 {
4141 case "艦娘数超過":
4242 case "装備数超過":
43- case "大破警告":
4443 textBoxPreliminary.Visible = labelPreliminary.Visible = checkBoxPreliminary.Visible =
4544 textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible =
4645 checkBoxCont.Visible = false;
--- a/KancolleSniffer/NotificationManager.cs
+++ b/KancolleSniffer/NotificationManager.cs
@@ -78,9 +78,9 @@ namespace KancolleSniffer
7878 _notificationQueue.StopRepeat(key, fleet);
7979 }
8080
81- public void SuspendRepeat()
81+ public void SuspendRepeat(string exception = "")
8282 {
83- _notificationQueue.SuspendRepeat();
83+ _notificationQueue.SuspendRepeat(exception);
8484 }
8585
8686 public void ResumeRepeat()
@@ -278,6 +278,7 @@ namespace KancolleSniffer
278278 private readonly NotificationConfig _notificationConfig = new NotificationConfig();
279279 private DateTime _lastAlarm;
280280 private bool _suspend;
281+ private string _suspendException;
281282
282283 public NotificationQueue(Action<string, string, string> alarm, Func<DateTime> nowFunc = null)
283284 {
@@ -320,9 +321,10 @@ namespace KancolleSniffer
320321 private bool IsMatch(Notification n, string key) =>
321322 n.Key.Substring(0, 4) == key.Substring(0, 4) && n.Schedule != default;
322323
323- public void SuspendRepeat()
324+ public void SuspendRepeat(string exception = null)
324325 {
325326 _suspend = true;
327+ _suspendException = exception;
326328 }
327329
328330 public void ResumeRepeat()
@@ -336,7 +338,7 @@ namespace KancolleSniffer
336338 if (now - _lastAlarm < TimeSpan.FromSeconds(2))
337339 return;
338340 var first = _queue.FirstOrDefault(n => n.Schedule.CompareTo(now) <= 0 &&
339- !(_suspend && n.Schedule != default));
341+ !(n.Schedule != default && _suspend && n.Key != _suspendException));
340342 if (first == null)
341343 return;
342344 var message = _notificationConfig.GenerateMessage(first);
--- a/KancolleSniffer/Sniffer.cs
+++ b/KancolleSniffer/Sniffer.cs
@@ -45,7 +45,7 @@ namespace KancolleSniffer
4545 {
4646 void Stop(string key);
4747 void Stop(string key, int fleet);
48- void Suspend();
48+ void Suspend(string exception = null);
4949 void Resume();
5050 }
5151
@@ -170,7 +170,7 @@ namespace KancolleSniffer
170170 _cellInfo.Port();
171171 SaveState();
172172 RepeatingTimerController?.Resume();
173- foreach (var s in new[] {"遠征終了", "入渠終了", "疲労回復", "泊地修理"})
173+ foreach (var s in new[] {"遠征終了", "入渠終了", "疲労回復", "泊地修理", "大破警告"})
174174 RepeatingTimerController?.Stop(s);
175175 return Update.All;
176176 }
@@ -517,7 +517,7 @@ namespace KancolleSniffer
517517 _miscTextInfo.InspectMapStart(data);
518518 _questInfo.InspectMapStart(data);
519519 _cellInfo.InspectMapStart(data);
520- RepeatingTimerController?.Suspend();
520+ RepeatingTimerController?.Suspend("大破警告");
521521 return Update.Timer | Update.Ship | Update.Cell;
522522 }
523523 if (url.EndsWith("api_req_map/next"))
旧リポジトリブラウザで表示