X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FMainForm.cs;h=214d64e5b545f88cf93e59a81c453db82c363924;hb=484250b68f1620edc8331032939b69bf889e6f44;hp=0dd201c0a2a317c3639543a0ed36bc2f4278ce28;hpb=43431cf08203ccb0afa1800b96fba4002e509825;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/MainForm.cs b/KancolleSniffer/MainForm.cs index 0dd201c..214d64e 100644 --- a/KancolleSniffer/MainForm.cs +++ b/KancolleSniffer/MainForm.cs @@ -1,37 +1,33 @@ // Copyright (C) 2013, 2014, 2015 Kazuhiro Fujieda // -// This program is part of KancolleSniffer. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// KancolleSniffer is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// http://www.apache.org/licenses/LICENSE-2.0 // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, see . +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; -using System.Net; using System.Net.Sockets; using System.Runtime.InteropServices; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Codeplex.Data; using Microsoft.CSharp.RuntimeBinder; using Microsoft.Win32; -using Nekoxy; using static System.Math; using Timer = System.Windows.Forms.Timer; @@ -43,9 +39,10 @@ namespace KancolleSniffer private readonly Config _config = new Config(); private readonly ConfigDialog _configDialog; private int _currentFleet; + private bool _combinedFleet; private readonly Label[] _labelCheckFleets; private readonly ShipLabels _shipLabels; - private readonly ShipListForm _shipListForm; + private readonly ListForm _listForm; private readonly NoticeQueue _noticeQueue; private bool _started; private string _debugLogFile; @@ -53,6 +50,10 @@ namespace KancolleSniffer private LogServer _logServer; private int _prevProxyPort; private readonly SystemProxy _systemProxy = new SystemProxy(); + private readonly ErrorDialog _errorDialog = new ErrorDialog(); + private bool _missionFinishTimeMode; + private bool _ndockFinishTimeMode; + private readonly KancolleDb _kancolleDb = new KancolleDb(); public MainForm() { @@ -69,39 +70,81 @@ namespace KancolleSniffer SetupFleetClick(); _shipLabels = new ShipLabels(); _shipLabels.CreateAkashiTimers(panelShipInfo); - _shipLabels.CreateLabels(panelShipInfo, ShowShipOnShipList); - _shipLabels.CreateDamagedShipList(panelDamagedShipList, panelDamagedShipList_Click); - _shipLabels.CreateNDockLabels(panelDock); - _shipListForm = new ShipListForm(_sniffer, _config) {Owner = this}; + _shipLabels.CreateShipLabels(panelShipInfo, ShowShipOnShipList); + _shipLabels.CreateCombinedShipLabels(panelCombinedFleet, ShowShipOnShipList); + _shipLabels.CreateRepairList(panelRepairList, panelRepairList_Click); + _shipLabels.CreateNDockLabels(panelDock, labelNDock_Click); + labelPresetAkashiTimer.BackColor = ShipLabels.ColumnColors[1]; + _listForm = new ListForm(_sniffer, _config) {Owner = this}; _noticeQueue = new NoticeQueue(Ring); + _config.Load(); + PerformZoom(); + _sniffer.LoadState(); } - private void HttpProxy_AfterSessionComplete(Session session) + private void HttpProxy_AfterSessionComplete(HttpProxy.Session session) { - Invoke(new Action(ProcessRequest), session); + Invoke(new Action(ProcessRequest), session); } - private void ProcessRequest(Session session) + private void ProcessRequest(HttpProxy.Session session) { + var url = session.Request.PathAndQuery; + if (!url.Contains("kcsapi/")) + return; + var request = session.Request.BodyAsString; var response = session.Response.BodyAsString; if (response == null || !response.StartsWith("svdata=")) + { + WriteDebugLog(url, request, response); return; - response = response.Remove(0, "svdata=".Length); - var json = DynamicJson.Parse(response); - var request = session.Request.BodyAsString; + } + if (_config.KancolleDb.On) + _kancolleDb.Send(url, request, response); + response = UnescapeString(response.Remove(0, "svdata=".Length)); + WriteDebugLog(url, request, response); + try + { + UpdateInfo(_sniffer.Sniff(url, request, JsonParser.Parse(response))); + } + catch (RuntimeBinderException e) + { + if (_errorDialog.ShowDialog(this, + "このバージョンは現在の艦これに対応していません。\r\n新しいバージョンを利用してください。", e.ToString()) == DialogResult.Abort) + Application.Exit(); + } + catch (LogIOException e) + { + if (_errorDialog.ShowDialog(this, e.Message, e.InnerException.ToString()) == DialogResult.Abort) + Application.Exit(); + } + catch (Exception e) + { + if (_errorDialog.ShowDialog(this, "エラーが発生しました。", e.ToString()) == DialogResult.Abort) + Application.Exit(); + } + } + + private void WriteDebugLog(string url, string request, string response) + { if (_debugLogFile != null) { - File.AppendAllText(_debugLogFile, string.Format("url: {0}\nrequest: {1}\nresponse: {2}\n", - session.Request.PathAndQuery, request, json.ToString())); + File.AppendAllText(_debugLogFile, + $"url: {url}\nrequest: {request}\nresponse: {response ?? "(null)"}\n"); } + } + + private string UnescapeString(string s) + { try { - UpdateInfo(_sniffer.Sniff(session.Request.PathAndQuery, request, json)); + var rx = new Regex(@"\\[uU]([0-9A-Fa-f]{4})"); + return rx.Replace(s, + match => ((char)int.Parse(match.Value.Substring(2), NumberStyles.HexNumber)).ToString()); } - catch (RuntimeBinderException) + catch (ArgumentException) { - labelLogin.Visible = true; - labelLogin.Text = "現在の艦これに対応していません。\n新しいバージョンを利用してください。"; + return s; } } @@ -110,6 +153,7 @@ namespace KancolleSniffer if (update == Sniffer.Update.Start) { labelLogin.Visible = false; + labelGuide.Visible = false; _started = true; return; } @@ -133,51 +177,26 @@ namespace KancolleSniffer private void MainForm_Load(object sender, EventArgs e) { - _config.Load(); RestoreLocation(); if (_config.HideOnMinimized && WindowState == FormWindowState.Minimized) ShowInTaskbar = false; ApplyConfig(); ApplyDebugLogSetting(); ApplyLogSetting(); - _sniffer.LoadState(); ApplyProxySetting(); SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; + if (_config.KancolleDb.On) + _kancolleDb.Start(_config.KancolleDb.Token); } private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) { - if (e.Mode != PowerModes.Resume) + if (e.Mode != PowerModes.Resume || !_config.Proxy.Auto) return; Task.Run(() => { for (var i = 0; i < 5; Thread.Sleep(10000), i++) - { - WebResponse res = null; SystemProxy.Refresh(); - var system = WebRequest.GetSystemWebProxy(); - if (!system.GetProxy(new Uri("http://125.6.184.16/")).IsLoopback) - { - File.AppendAllText("wakeup.log", - $"[{DateTime.Now.ToString("g")}] proxy settings doesn't work.\r\n"); - continue; - } - try - { - var req = WebRequest.Create("http://kancollesniffer.osdn.jp/version"); - res = req.GetResponse(); - break; - } - catch - { - File.AppendAllText("wakeup.log", - $"[{DateTime.Now.ToString("g")}] failed to connect internet.\r\n"); - } - finally - { - res?.Close(); - } - } }); } @@ -191,6 +210,7 @@ namespace KancolleSniffer if (_config.Proxy.Auto) _systemProxy.RestoreSettings(); SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged; + _kancolleDb.Stop(); } private void ShutdownProxy() @@ -227,6 +247,19 @@ namespace KancolleSniffer ApplyConfig(); } + private void PerformZoom() + { + if (_config.Zoom == 100) + return; + var prev = CurrentAutoScaleDimensions; + foreach (var control in new Control[] {this, _listForm, labelLogin, labelGuide}) + control.Font = new Font(control.Font.FontFamily, control.Font.Size * _config.Zoom / 100); + ShipLabel.LatinFont = new Font("Tahoma", 8f * _config.Zoom / 100); + var cur = CurrentAutoScaleDimensions; + ShipLabel.ScaleFactor = new SizeF(ShipLabel.ScaleFactor.Width * cur.Width / prev.Width, + ShipLabel.ScaleFactor.Height * cur.Height / prev.Height); + } + private void RestoreLocation() { if (_config.Location.X == int.MinValue) @@ -239,10 +272,14 @@ namespace KancolleSniffer private void ApplyConfig() { - _shipListForm.TopMost = TopMost = _config.TopMost; + _listForm.TopMost = TopMost = _config.TopMost; _sniffer.Item.MarginShips = _config.MarginShips; _sniffer.Item.MarginEquips = _config.MarginEquips; _sniffer.Achievement.ResetHours = _config.ResetHours; + labelAkashiRepair.Visible = labelAkashiRepairTimer.Visible = + labelPresetAkashiTimer.Visible = _config.UsePresetAkashi; + if (_config.KancolleDb.On) + _kancolleDb.Start(_config.KancolleDb.Token); } public void ApplyDebugLogSetting() @@ -359,7 +396,17 @@ namespace KancolleSniffer private void timerMain_Tick(object sender, EventArgs e) { if (_started) - UpdateTimers(); + { + try + { + UpdateTimers(); + } + catch (Exception ex) + { + if (_errorDialog.ShowDialog(this, "エラーが発生しました。", ex.ToString()) == DialogResult.Abort) + Application.Exit(); + } + } if (_playLog == null || _configDialog.Visible) { labelPlayLog.Visible = false; @@ -383,29 +430,29 @@ namespace KancolleSniffer labelPlayLog.Visible = false; return; } - lines.Add(_playLog.Current.Substring(s.Count())); + lines.Add(_playLog.Current.Substring(s.Length)); } labelPlayLog.Visible = !labelPlayLog.Visible; - var json = DynamicJson.Parse(lines[2]); + var json = JsonParser.Parse(lines[2]); UpdateInfo(_sniffer.Sniff(lines[0], lines[1], json)); } private void ShowShipOnShipList(object sender, EventArgs ev) { - if (!_shipListForm.Visible) + if (!_listForm.Visible) return; var idx = (int)((Control)sender).Tag; var statuses = _sniffer.GetShipStatuses(_currentFleet); if (statuses.Length <= idx) return; - _shipListForm.ShowShip(statuses[idx].Id); + _listForm.ShowShip(statuses[idx].Id); } private void UpdateItemInfo() { UpdateNumOfShips(); UpdateNumOfEquips(); - labelNumOfBuckets.Text = _sniffer.Item.MaterialHistory[(int)Material.Bucket].Now.ToString("D"); + labelNumOfBuckets.Text = _sniffer.Material.MaterialHistory[(int)Material.Bucket].Now.ToString("D"); UpdateBucketHistory(); var ac = _sniffer.Achievement.Value; if (ac >= 10000) @@ -415,8 +462,8 @@ namespace KancolleSniffer "今月 " + _sniffer.Achievement.ValueOfMonth.ToString("F1") + "\n" + "EO " + _sniffer.ExMap.Achievement); UpdateMaterialHistry(); - if (_shipListForm.Visible) - _shipListForm.UpdateList(); + if (_listForm.Visible) + _listForm.UpdateList(); } private void UpdateNumOfShips() @@ -427,7 +474,7 @@ namespace KancolleSniffer if (item.RingShips) { var message = $"残り{_sniffer.Item.MaxShips - _sniffer.Item.NowShips:D}隻"; - _noticeQueue.Enqueue("艦娘が多すぎます", message, _config.MaxShipsSoundFile); + _noticeQueue.Enqueue("艦娘が多すぎます", message, _config.Sounds["艦娘数超過"]); item.RingShips = false; } } @@ -440,14 +487,14 @@ namespace KancolleSniffer if (item.RingEquips) { var message = $"残り{_sniffer.Item.MaxEquips - _sniffer.Item.NowEquips:D}個"; - _noticeQueue.Enqueue("装備が多すぎます", message, _config.MaxEquipsSoundFile); + _noticeQueue.Enqueue("装備が多すぎます", message, _config.Sounds["装備数超過"]); item.RingEquips = false; } } private void UpdateBucketHistory() { - var count = _sniffer.Item.MaterialHistory[(int)Material.Bucket]; + var count = _sniffer.Material.MaterialHistory[(int)Material.Bucket]; var day = count.Now - count.BegOfDay; var week = count.Now - count.BegOfWeek; if (day >= 1000) @@ -463,8 +510,8 @@ namespace KancolleSniffer var text = new[] {"燃料", "弾薬", "鋼材", "ボーキ"}; for (var i = 0; i < labels.Length; i++) { - var count = _sniffer.Item.MaterialHistory[i]; - var port = count.Now - _sniffer.Item.PrevPort[i]; + var count = _sniffer.Material.MaterialHistory[i]; + var port = count.Now - _sniffer.Material.PrevPort[i]; if (port >= 100000) port = 99999; var day = count.Now - count.BegOfDay; @@ -482,15 +529,21 @@ namespace KancolleSniffer UpdatePanelShipInfo(); NotifyDamagedShip(); UpdateChargeInfo(); - UpdateDamagedShipList(); - if (_shipListForm.Visible) - _shipListForm.UpdateList(); + UpdateRepairList(); + if (_listForm.Visible) + _listForm.UpdateList(); } private void UpdatePanelShipInfo() { var statuses = _sniffer.GetShipStatuses(_currentFleet); - _shipLabels.SetShipInfo(statuses); + _shipLabels.SetShipLabels(statuses); + if (_sniffer.CombinedFleetType == 0) + _combinedFleet = false; + labelFleet1.Text = _combinedFleet ? "連合" : "第一"; + panelCombinedFleet.Visible = _combinedFleet; + if (_combinedFleet) + _shipLabels.SetCombinedShipLabels(_sniffer.GetShipStatuses(0), _sniffer.GetShipStatuses(1)); UpdateAkashiTimer(); UpdateFighterPower(); UpdateLoS(); @@ -499,19 +552,22 @@ namespace KancolleSniffer private void NotifyDamagedShip() { - if (_sniffer.Battle.HasDamagedShip) - _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.Battle.DamagedShipNames), - _config.DamagedShipSoundFile); + if (_sniffer.BadlyDamagedShips.Any()) + _noticeQueue.Enqueue("大破した艦娘がいます", string.Join(" ", _sniffer.BadlyDamagedShips), + _config.Sounds["大破警告"]); } private void NotifyAkashiTimer() { - var msgs = _sniffer.GetAkashiTimerNotice(); + var akashi = _sniffer.AkashiTimer; + var msgs = akashi.GetNotice(); if (msgs.Length == 0) return; + if (!akashi.CheckReparing() && !(akashi.CheckPresetReparing() && _config.UsePresetAkashi)) + return; if (msgs[0].Proceeded == "20分経過しました。") { - _noticeQueue.Enqueue("泊地修理", msgs[0].Proceeded, _config.Akashi20MinSoundFile); + _noticeQueue.Enqueue("泊地修理", msgs[0].Proceeded, _config.Sounds["泊地修理20分経過"]); msgs[0].Proceeded = ""; // 修理完了がいるかもしれないので続ける } @@ -519,21 +575,26 @@ namespace KancolleSniffer for (var i = 0; i < fn.Length; i++) { if (msgs[i].Proceeded != "") - _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理進行:" + msgs[i].Proceeded, _config.AkashiProgressSoundFile); + _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理進行:" + msgs[i].Proceeded, _config.Sounds["泊地修理進行"]); if (msgs[i].Completed != "") - _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理完了:" + msgs[i].Completed, _config.AkashiCompleteSoundFile); + _noticeQueue.Enqueue("泊地修理 " + fn[i], "修理完了:" + msgs[i].Completed, _config.Sounds["泊地修理完了"]); } } public void UpdateFighterPower() { - labelFighterPower.Text = _sniffer.GetFighterPower(_currentFleet, true).ToString("D"); - toolTipFigherPower.SetToolTip(labelFighterPower, "熟練度抜き " + _sniffer.GetFighterPower(_currentFleet, false)); + var fp = _sniffer.GetFighterPower(_currentFleet); + labelFighterPower.Text = fp[0].ToString("D"); + var cr = _sniffer.GetContactTriggerRate(_currentFleet) * 100; + var text = "制空: " + (fp[0] == fp[1] ? $"{fp[0]}" : $"{fp[0]}~{fp[1]}") + + $" 触接: {cr:f1}"; + toolTipFighterPower.SetToolTip(labelFighterPower, text); + toolTipFighterPower.SetToolTip(labelFighterPowerCaption, text); } private void UpdateLoS() { - labelLoS.Text = _sniffer.GetFleetLineOfSights(_currentFleet).ToString("F1"); + labelLoS.Text = (Floor(_sniffer.GetFleetLineOfSights(_currentFleet) * 10) / 10.0).ToString("F1"); } private void UpdateBattleInfo() @@ -549,10 +610,7 @@ namespace KancolleSniffer var battle = _sniffer.Battle; var color = new[] {DefaultForeColor, DefaultForeColor, Color.Blue, Color.Green, Color.Orange, Color.Red}; labelFormation.Text = battle.Formation; - var enemyFp = battle.EnemyFighterPower; - labelEnemyFighterPower.Text = (enemyFp & BattleInfo.IncollectFighterPowerFlag) == 0 - ? enemyFp.ToString() - : (enemyFp & ~BattleInfo.IncollectFighterPowerFlag) + "+"; + labelEnemyFighterPower.Text = battle.EnemyFighterPower; labelFighterPower.ForeColor = color[battle.AirControlLevel + 1]; if (_config.AlwaysShowResultRank) ShowResultRank(); @@ -587,6 +645,13 @@ namespace KancolleSniffer _shipLabels.SetNDockLabels(_sniffer.NDock); } + + private void labelNDock_Click(object sender, EventArgs e) + { + _ndockFinishTimeMode = !_ndockFinishTimeMode; + UpdateTimers(); + } + private void UpdateMissionLabels() { foreach (var entry in @@ -595,6 +660,12 @@ namespace KancolleSniffer entry.label.Text = entry.Name; } + private void labelMission_Click(object sender, EventArgs e) + { + _missionFinishTimeMode = !_missionFinishTimeMode; + UpdateTimers(); + } + private void UpdateTimers() { foreach (var entry in @@ -603,21 +674,20 @@ namespace KancolleSniffer { entry.Timer.Update(); SetTimerColor(entry.label, entry.Timer); - var rest = entry.Timer.Rest; - entry.label.Text = rest.Days == 0 ? rest.ToString(@"hh\:mm\:ss") : rest.ToString(@"d\.hh\:mm"); + entry.label.Text = entry.Timer.ToString(_missionFinishTimeMode); if (!entry.Timer.NeedRing) continue; - _noticeQueue.Enqueue("遠征が終わりました", entry.Name, _config.MissionSoundFile); + _noticeQueue.Enqueue("遠征が終わりました", entry.Name, _config.Sounds["遠征終了"]); entry.Timer.NeedRing = false; } for (var i = 0; i < _sniffer.NDock.Length; i++) { var entry = _sniffer.NDock[i]; entry.Timer.Update(); - _shipLabels.SetNDockTimer(i, entry.Timer); + _shipLabels.SetNDockTimer(i, entry.Timer, _ndockFinishTimeMode); if (!entry.Timer.NeedRing) continue; - _noticeQueue.Enqueue("入渠が終わりました", entry.Name, _config.NDockSoundFile); + _noticeQueue.Enqueue("入渠が終わりました", entry.Name, _config.Sounds["入渠終了"]); entry.Timer.NeedRing = false; } var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4}; @@ -626,10 +696,11 @@ namespace KancolleSniffer var timer = _sniffer.KDock[i]; timer.Update(); SetTimerColor(kdock[i], timer); - kdock[i].Text = timer.Rest.ToString(@"hh\:mm\:ss"); + + kdock[i].Text = timer.EndTime == DateTime.MinValue ? "" : timer.Rest.ToString(@"hh\:mm\:ss"); if (!timer.NeedRing) continue; - _noticeQueue.Enqueue("建造が終わりました", $"第{i + 1:D}ドック", _config.KDockSoundFile); + _noticeQueue.Enqueue("建造が終わりました", $"第{i + 1:D}ドック", _config.Sounds["建造完了"]); timer.NeedRing = false; } UpdateCondTimers(); @@ -643,7 +714,17 @@ namespace KancolleSniffer private void UpdateCondTimers() { - var timer = _sniffer.GetConditionTimer(_currentFleet); + DateTime timer; + if (_combinedFleet) + { + var timer1 = _sniffer.GetConditionTimer(0); + var timer2 = _sniffer.GetConditionTimer(1); + timer = timer2 > timer1 ? timer2 : timer1; + } + else + { + timer = _sniffer.GetConditionTimer(_currentFleet); + } var now = DateTime.Now; if (timer == DateTime.MinValue) { @@ -670,20 +751,42 @@ namespace KancolleSniffer { if (!_config.NotifyConditions.Contains(notice[i])) return; - _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), _config.ConditionSoundFile); + _noticeQueue.Enqueue("疲労が回復しました", fn[i] + " cond" + notice[i].ToString("D"), _config.Sounds["疲労回復"]); } } private void UpdateAkashiTimer() { + if (_config.UsePresetAkashi) + UpdatePresetAkashiTimer(); _shipLabels.SetAkashiTimer(_sniffer.GetShipStatuses(_currentFleet), - _sniffer.GetAkashiTimers(_currentFleet)); + _sniffer.AkashiTimer.GetTimers(_currentFleet)); NotifyAkashiTimer(); } - private void UpdateDamagedShipList() + private void UpdatePresetAkashiTimer() + { + var akashi = _sniffer.AkashiTimer; + var span = akashi.PresetDeckTimer; + var color = span == TimeSpan.Zero && akashi.CheckPresetReparing() ? Color.Red : DefaultForeColor; + var text = span == TimeSpan.MinValue ? "" : span.ToString(@"mm\:ss"); + labelAkashiRepairTimer.ForeColor = color; + labelAkashiRepairTimer.Text = text; + if (akashi.CheckPresetReparing() && !akashi.CheckReparing(_currentFleet)) + { + labelPresetAkashiTimer.ForeColor = color; + labelPresetAkashiTimer.Text = text; + } + else + { + labelPresetAkashiTimer.ForeColor = DefaultForeColor; + labelPresetAkashiTimer.Text = ""; + } + } + + private void UpdateRepairList() { - _shipLabels.SetDamagedShipList(_sniffer.DamagedShipList); + _shipLabels.SetRepairList(_sniffer.RepairList); } private void UpdateQuestList() @@ -696,19 +799,12 @@ namespace KancolleSniffer var name = new[] {labelQuest1, labelQuest2, labelQuest3, labelQuest4, labelQuest5, labelQuest6}; var progress = new[] {labelProgress1, labelProgress2, labelProgress3, labelProgress4, labelProgress5, labelProgress6}; - var color = new[] - { - Color.FromArgb(60, 141, 76), Color.FromArgb(232, 57, 41), Color.FromArgb(136, 204, 120), - Color.FromArgb(52, 147, 185), Color.FromArgb(220, 198, 126), Color.FromArgb(168, 111, 76), - Color.FromArgb(200, 148, 231) - }; - var quests = _sniffer.Quests; for (var i = 0; i < name.Length; i++) { if (i < quests.Length) { - category[i].BackColor = color[quests[i].Category - 1]; + category[i].BackColor = quests[i].Color; name[i].Text = quests[i].Name; progress[i].Text = $"{quests[i].Progress:D}%"; } @@ -764,7 +860,7 @@ namespace KancolleSniffer if (_config.ShowBaloonTip) notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info); if (_config.PlaySound) - PlaySound(soundFile, _config.SoundVolume); + PlaySound(soundFile, _config.Sounds.Volume); } [DllImport("winmm.dll")] @@ -814,18 +910,35 @@ namespace KancolleSniffer private void labelFleet_Click(object sender, EventArgs e) { + if (!_started) + return; var fleet = (int)((Label)sender).Tag; if (_currentFleet == fleet) + { + if (fleet > 0) + return; + _combinedFleet = _sniffer.CombinedFleetType > 0 && !_combinedFleet; + UpdatePanelShipInfo(); return; + } + _combinedFleet = false; _currentFleet = fleet; foreach (var label in _labelCheckFleets) label.Visible = false; _labelCheckFleets[fleet].Visible = true; - if (!_started) - return; UpdatePanelShipInfo(); } + private void labelFleet1_MouseHover(object sender, EventArgs e) + { + labelFleet1.Text = _currentFleet == 0 && _sniffer.CombinedFleetType > 0 && !_combinedFleet ? "連合" : "第一"; + } + + private void labelFleet1_MouseLeave(object sender, EventArgs e) + { + labelFleet1.Text = _combinedFleet ? "連合" : "第一"; + } + private void labelBucketHistoryButton_Click(object sender, EventArgs e) { if (labelBucketHistory.Visible) @@ -874,34 +987,34 @@ namespace KancolleSniffer UpdateItemInfo(); } - private void labelDamgedShipListButton_Click(object sender, EventArgs e) + private void labelRepairListButton_Click(object sender, EventArgs e) { - if (panelDamagedShipList.Visible) + if (panelRepairList.Visible) { - panelDamagedShipList.Visible = false; - labelDamgedShipListButton.BackColor = DefaultBackColor; + panelRepairList.Visible = false; + labelRepairListButton.BackColor = DefaultBackColor; } else { - panelDamagedShipList.Visible = true; - panelDamagedShipList.BringToFront(); - labelDamgedShipListButton.BackColor = SystemColors.ActiveCaption; + panelRepairList.Visible = true; + panelRepairList.BringToFront(); + labelRepairListButton.BackColor = SystemColors.ActiveCaption; } } - private void panelDamagedShipList_Click(object sender, EventArgs e) + private void panelRepairList_Click(object sender, EventArgs e) { - panelDamagedShipList.Visible = false; - labelDamgedShipListButton.BackColor = DefaultBackColor; + panelRepairList.Visible = false; + labelRepairListButton.BackColor = DefaultBackColor; } private void ShipListToolStripMenuItem_Click(object sender, EventArgs e) { - _shipListForm.UpdateList(); - _shipListForm.Show(); - if (_shipListForm.WindowState == FormWindowState.Minimized) - _shipListForm.WindowState = FormWindowState.Normal; - _shipListForm.Activate(); + _listForm.UpdateList(); + _listForm.Show(); + if (_listForm.WindowState == FormWindowState.Minimized) + _listForm.WindowState = FormWindowState.Normal; + _listForm.Activate(); } private void LogToolStripMenuItem_Click(object sender, EventArgs e)