using System.Runtime.InteropServices;\r
using System.Text;\r
using System.Text.RegularExpressions;\r
-using System.Threading;\r
using System.Threading.Tasks;\r
using System.Windows.Forms;\r
using Microsoft.CSharp.RuntimeBinder;\r
private bool _started;\r
private string _debugLogFile;\r
private IEnumerator<string> _playLog;\r
- private LogServer _logServer;\r
private int _prevProxyPort;\r
private readonly SystemProxy _systemProxy = new SystemProxy();\r
private readonly ErrorDialog _errorDialog = new ErrorDialog();\r
}\r
catch (LogIOException e)\r
{\r
+ // ReSharper disable once PossibleNullReferenceException\r
if (_errorDialog.ShowDialog(this, e.Message, e.InnerException.ToString()) == DialogResult.Abort)\r
Application.Exit();\r
}\r
{\r
if (e.Mode != PowerModes.Resume || !_config.Proxy.Auto)\r
return;\r
- Task.Run(() =>\r
- {\r
- for (var i = 0; i < 5; Thread.Sleep(10000), i++)\r
- SystemProxy.Refresh();\r
- });\r
+ SystemProxy.Refresh();\r
}\r
\r
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)\r
_config.Location = (WindowState == FormWindowState.Normal ? Bounds : RestoreBounds).Location;\r
_config.Save();\r
Task.Run(() => ShutdownProxy());\r
- _logServer?.Stop();\r
if (_config.Proxy.Auto)\r
_systemProxy.RestoreSettings();\r
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;\r
}\r
if (_config.Proxy.Auto && result)\r
{\r
- _systemProxy.SetAutoProxyUrl(HttpProxy.LocalPort == 8080\r
- ? ProxyConfig.AutoConfigUrl\r
- : ProxyConfig.AutoConfigUrlWithPort + HttpProxy.LocalPort);\r
+ _systemProxy.SetAutoProxyUrl($"http://localhost:{_config.Proxy.Listen}/proxy.pac");\r
}\r
_prevProxyPort = _config.Proxy.Listen;\r
return result;\r
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);\r
}\r
\r
- public bool ApplyLogSetting()\r
+ public void ApplyLogSetting()\r
{\r
- var result = true;\r
- if (_config.Log.ServerOn)\r
- {\r
- result = StartLogServer();\r
- }\r
- else\r
- {\r
- _logServer?.Stop();\r
- _logServer = null;\r
- }\r
+ LogServer.OutputDir = _config.Log.OutputDir;\r
_sniffer.EnableLog(_config.Log.On ? LogType.All : LogType.None);\r
_sniffer.MaterialLogInterval = _config.Log.MaterialLogInterval;\r
_sniffer.LogOutputDir = _config.Log.OutputDir;\r
- return result;\r
- }\r
-\r
- private bool StartLogServer()\r
- {\r
- var port = _config.Log.Listen;\r
- if (_logServer?.Port == port)\r
- return true;\r
- _logServer?.Stop();\r
- _logServer = null;\r
- try\r
- {\r
- _logServer = new LogServer(port);\r
- _logServer.Start();\r
- }\r
- catch (SocketException e) when (e.SocketErrorCode == SocketError.AddressAlreadyInUse)\r
- {\r
- if (WarnConflictPortNumber("閲覧サーバー", port, true) == DialogResult.No)\r
- return false;\r
- _logServer = new LogServer(0);\r
- _logServer.Start();\r
- _config.Log.Listen = _logServer.Port;\r
- }\r
- _logServer.OutputDir = _config.Log.OutputDir;\r
- return true;\r
}\r
\r
public static bool IsVisibleOnAnyScreen(Rectangle rect)\r
if (item.RingShips)\r
{\r
var message = $"残り{_sniffer.Item.MaxShips - _sniffer.Item.NowShips:D}隻";\r
- _noticeQueue.Enqueue("艦娘が多すぎます", message, _config.Sounds["艦娘数超過"]);\r
+ _noticeQueue.Enqueue("艦娘が多すぎます", message, "艦娘数超過");\r
item.RingShips = false;\r
}\r
}\r
if (item.RingEquips)\r
{\r
var message = $"残り{_sniffer.Item.MaxEquips - _sniffer.Item.NowEquips:D}個";\r
- _noticeQueue.Enqueue("装備が多すぎます", message, _config.Sounds["装備数超過"]);\r
+ _noticeQueue.Enqueue("装備が多すぎます", message, "装備数超過");\r
item.RingEquips = false;\r
}\r
}\r
private void NotifyDamagedShip()\r
{\r
if (_sniffer.BadlyDamagedShips.Any())\r
- _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.BadlyDamagedShips),\r
- _config.Sounds["大破警告"]);\r
+ _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.BadlyDamagedShips), "大破警告");\r
}\r
\r
private void NotifyAkashiTimer()\r
return;\r
if (msgs[0].Proceeded == "20分経過しました。")\r
{\r
- _noticeQueue.Enqueue("泊地修理", msgs[0].Proceeded, _config.Sounds["泊地修理20分経過"]);\r
+ _noticeQueue.Enqueue("泊地修理", msgs[0].Proceeded, "泊地修理20分経過");\r
msgs[0].Proceeded = "";\r
// 修理完了がいるかもしれないので続ける\r
}\r
for (var i = 0; i < fn.Length; i++)\r
{\r
if (msgs[i].Proceeded != "")\r
- _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理進行:" + msgs[i].Proceeded, _config.Sounds["泊地修理進行"]);\r
+ _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理進行:" + msgs[i].Proceeded, "泊地修理進行");\r
if (msgs[i].Completed != "")\r
- _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理完了:" + msgs[i].Completed, _config.Sounds["泊地修理完了"]);\r
+ _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理完了:" + msgs[i].Completed, "泊地修理完了");\r
}\r
}\r
\r
\r
private void UpdateLoS()\r
{\r
- labelLoS.Text = (Floor(_sniffer.GetFleetLineOfSights(_currentFleet) * 10) / 10.0).ToString("F1");\r
+ labelLoS.Text = RoundDown(_sniffer.GetFleetLineOfSights(_currentFleet, 1)).ToString("F1");\r
+ var text = $"係数3: {RoundDown(_sniffer.GetFleetLineOfSights(_currentFleet, 3)):F1}\r\n" +\r
+ $"係数4: {RoundDown(_sniffer.GetFleetLineOfSights(_currentFleet, 4)):F1}";\r
+ toolTipLoS.SetToolTip(labelLoS, text);\r
+ toolTipLoS.SetToolTip(labelLoSCaption, text);\r
+ }\r
+\r
+ private double RoundDown(double number)\r
+ {\r
+ return Floor(number * 10) / 10.0;\r
}\r
\r
private void UpdateBattleInfo()\r
labelEnemyFighterPower.Text = "";\r
labelFighterPower.ForeColor = DefaultForeColor;\r
labelResultRank.Text = "判定";\r
- panelBattleInfo.Visible = _sniffer.Battle.InBattle;\r
- if (!_sniffer.Battle.InBattle)\r
+ panelBattleInfo.Visible = _sniffer.Battle.BattleState != BattleState.None;\r
+ if (_sniffer.Battle.BattleState == BattleState.None)\r
return;\r
panelBattleInfo.BringToFront();\r
var battle = _sniffer.Battle;\r
labelFighterPower.ForeColor = color[battle.AirControlLevel + 1];\r
if (_config.AlwaysShowResultRank)\r
ShowResultRank();\r
+ if (_sniffer.Battle.BattleState == BattleState.Day)\r
+ _listForm.UpdateAirBattleResult();\r
}\r
\r
private void ShowResultRank()\r
entry.label.Text = entry.Timer.ToString(_missionFinishTimeMode);\r
if (!entry.Timer.NeedRing)\r
continue;\r
- _noticeQueue.Enqueue("遠征が終わりました", entry.Name, _config.Sounds["遠征終了"]);\r
+ _noticeQueue.Enqueue("遠征が終わりました", entry.Name, "遠征終了");\r
entry.Timer.NeedRing = false;\r
}\r
for (var i = 0; i < _sniffer.NDock.Length; i++)\r
_shipLabels.SetNDockTimer(i, entry.Timer, _ndockFinishTimeMode);\r
if (!entry.Timer.NeedRing)\r
continue;\r
- _noticeQueue.Enqueue("入渠が終わりました", entry.Name, _config.Sounds["入渠終了"]);\r
+ _noticeQueue.Enqueue("入渠が終わりました", entry.Name, "入渠終了");\r
entry.Timer.NeedRing = false;\r
}\r
var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};\r
kdock[i].Text = timer.EndTime == DateTime.MinValue ? "" : timer.Rest.ToString(@"hh\:mm\:ss");\r
if (!timer.NeedRing)\r
continue;\r
- _noticeQueue.Enqueue("建造が終わりました", $"第{i + 1:D}ドック", _config.Sounds["建造完了"]);\r
+ _noticeQueue.Enqueue("建造が終わりました", $"第{i + 1:D}ドック", "建造完了");\r
timer.NeedRing = false;\r
}\r
UpdateCondTimers();\r
{\r
if (!_config.NotifyConditions.Contains(notice[i]))\r
return;\r
- _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), _config.Sounds["疲労回復"]);\r
+ _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), "疲労回復");\r
}\r
}\r
\r
_ring(notice.Item1, notice.Item2, notice.Item3);\r
}\r
\r
- public void Enqueue(string title, string message, string soundFile)\r
+ public void Enqueue(string title, string message, string name)\r
{\r
if (_timer.Enabled)\r
{\r
- _queue.Enqueue(new Tuple<string, string, string>(title, message, soundFile));\r
+ _queue.Enqueue(new Tuple<string, string, string>(title, message, name));\r
}\r
else\r
{\r
- _ring(title, message, soundFile);\r
+ _ring(title, message, name);\r
_timer.Start();\r
}\r
}\r
}\r
\r
- private void Ring(string baloonTitle, string baloonMessage, string soundFile)\r
+ private void Ring(string baloonTitle, string baloonMessage, string name)\r
{\r
- if (_config.FlashWindow)\r
+ if (_config.FlashWindow && (_config.Notifications[name] & NotificationType.FlashWindow) != 0)\r
Win32API.FlashWindow(Handle);\r
- if (_config.ShowBaloonTip)\r
+ if (_config.ShowBaloonTip && (_config.Notifications[name] & NotificationType.ShowBaloonTip) != 0)\r
notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);\r
- if (_config.PlaySound)\r
- PlaySound(soundFile, _config.Sounds.Volume);\r
+ if (_config.PlaySound && (_config.Notifications[name] & NotificationType.PlaySound) != 0)\r
+ PlaySound(_config.Sounds[name], _config.Sounds.Volume);\r
}\r
\r
[DllImport("winmm.dll")]\r
\r
private void LogToolStripMenuItem_Click(object sender, EventArgs e)\r
{\r
- Process.Start("http://localhost:" + _config.Log.Listen + "/");\r
+ Process.Start("http://localhost:" + _config.Proxy.Listen + "/");\r
}\r
\r
private void CaptureToolStripMenuItem_Click(object sender, EventArgs e)\r