X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=KancolleSniffer%2FShipLabels.cs;h=ceb7371f92601c1a15e2a271c2f57c93f205b127;hb=2239ef207d5559e76b4262eb4015cde28ea63ced;hp=1732bde9fac65e7097b467250fe430030b0bfa4f;hpb=1f544e3cc1b6964daccd043d10d8063b65fd1b9c;p=kancollesniffer%2FKancolleSniffer.git diff --git a/KancolleSniffer/ShipLabels.cs b/KancolleSniffer/ShipLabels.cs index 1732bde..ceb7371 100644 --- a/KancolleSniffer/ShipLabels.cs +++ b/KancolleSniffer/ShipLabels.cs @@ -13,6 +13,7 @@ // limitations under the License. using System; +using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text.RegularExpressions; @@ -39,8 +40,6 @@ namespace KancolleSniffer private readonly ShipLabel[][] _labels = new ShipLabel[ShipInfo.MemberCount][]; private readonly ShipLabel[][] _combinedLabels = new ShipLabel[ShipInfo.MemberCount * 2][]; private readonly ShipLabel[] _akashiTimers = new ShipLabel[ShipInfo.MemberCount]; - private readonly ShipLabel[][] _repairList = new ShipLabel[16][]; - private Control _panelRepairList; private readonly ShipLabel[][] _ndockLabels = new ShipLabel[DockInfo.DockCount][]; public static Color[] ColumnColors = {SystemColors.Control, Color.FromArgb(255, 250, 250, 250)}; @@ -70,20 +69,20 @@ namespace KancolleSniffer new ShipLabel {Location = new Point(129, y), AutoSize = true, AnchorRight = true}, new ShipLabel { - Location = new Point(132, y), - Size = new Size(23, height), + Location = new Point(131, y), + Size = new Size(24, height), TextAlign = ContentAlignment.MiddleRight }, new ShipLabel { - Location = new Point(157, y), - Size = new Size(23, height), + Location = new Point(156, y), + Size = new Size(24, height), TextAlign = ContentAlignment.MiddleRight }, new ShipLabel { - Location = new Point(177, y), - Size = new Size(41, height), + Location = new Point(176, y), + Size = new Size(42, height), TextAlign = ContentAlignment.MiddleRight }, new ShipLabel {Location = new Point(2, y), AutoSize = true}, // 名前のZ-orderを下に @@ -151,8 +150,8 @@ namespace KancolleSniffer new ShipLabel {Location = new Point(x + 88, y), AutoSize = true, AnchorRight = true}, new ShipLabel { - Location = new Point(x + 86, y), - Size = new Size(23, height), + Location = new Point(x + 85, y), + Size = new Size(24, height), TextAlign = ContentAlignment.MiddleRight }, new ShipLabel {Location = new Point(x + 2, y), AutoSize = true}, // 名前のZ-orderを下に @@ -215,6 +214,20 @@ namespace KancolleSniffer parent.ResumeLayout(); } + public void AdjustAkashiTimers() + { + var scale = ShipLabel.ScaleFactor; + if (scale.Height < 1.2) + return; + for (var i = 0; i < _akashiTimers.Length; i++) + { + const int x = 55; + var y = 3 + 16 * (i + 1); + _akashiTimers[i].Location = new Point((int)Round(x * scale.Width) - 3, (int)Round(y * scale.Height)); + _akashiTimers[i].Size = new Size((int)Round(31 * scale.Width) + 1, (int)Round(12 * scale.Height)); + } + } + public void SetAkashiTimer(ShipStatus[] statuses, AkashiTimer.RepairSpan[] timers) { var shortest = -1; @@ -248,65 +261,12 @@ namespace KancolleSniffer continue; } if (i == shortest) - label.ForeColor = Color.Red; + label.ForeColor = CUDColor.Red; labelHp.ForeColor = Color.DimGray; labelHp.SetHp(stat.NowHp + timer.Diff, stat.MaxHp); } } - public void CreateRepairList(Control parent, EventHandler onClick) - { - parent.SuspendLayout(); - for (var i = 0; i < _repairList.Length; i++) - { - var y = 3 + i * 16; - const int height = 12; - parent.Controls.AddRange(_repairList[i] = new[] - { - new ShipLabel {Location = new Point(0, y), Size = new Size(11, height)}, - new ShipLabel {Location = new Point(119, y), Size = new Size(5, height - 1)}, - new ShipLabel {Location = new Point(75, y), AutoSize = true}, - new ShipLabel {Location = new Point(9, y), AutoSize = true}, - new ShipLabel {Location = new Point(0, y - 2), Size = new Size(parent.Width, height + 3)} - }); - foreach (var label in _repairList[i]) - { - label.Scale(); - label.PresetColor = label.BackColor = ColumnColors[(i + 1) % 2]; - label.Click += onClick; - } - } - _panelRepairList = parent; - parent.ResumeLayout(); - } - - public void SetRepairList(ShipStatus[] list) - { - const int fleet = 0, name = 3, time = 2, damage = 1; - var parent = _panelRepairList; - var num = Min(list.Length, _repairList.Length); - if (num == 0) - { - parent.Size = new Size(parent.Width, (int)Round(ShipLabel.ScaleFactor.Height * 19)); - var labels = _repairList[0]; - labels[fleet].Text = ""; - labels[name].SetName("なし"); - labels[time].Text = ""; - labels[damage].BackColor = labels[damage].PresetColor; - return; - } - parent.Size = new Size(parent.Width, (int)Round(ShipLabel.ScaleFactor.Height * (num * 16 + 3))); - for (var i = 0; i < num; i++) - { - var s = list[i]; - var labels = _repairList[i]; - labels[fleet].SetFleet(s); - labels[name].SetName(s, ShipNameWidth.RepairList); - labels[time].SetRepairTime(s); - labels[damage].BackColor = ShipLabel.DamageColor(s, labels[damage].PresetColor); - } - } - public void CreateNDockLabels(Control parent, EventHandler onClick) { for (var i = 0; i < _ndockLabels.Length; i++) @@ -340,12 +300,12 @@ namespace KancolleSniffer public void SetNDockTimer(int dock, RingTimer timer, bool finishTime) { var label = _ndockLabels[dock][0]; - label.ForeColor = timer.IsFinished ? Color.Red : Color.Black; + label.ForeColor = timer.IsFinished ? CUDColor.Red : Color.Black; label.Text = timer.ToString(finishTime); } } - [System.ComponentModel.DesignerCategory("Code")] + [DesignerCategory("Code")] public class ShipLabel : Label { public static SizeF ScaleFactor { get; set; } @@ -356,6 +316,12 @@ namespace KancolleSniffer private int _left; private SlotStatus _slotStatus; + public override Color BackColor + { + get => base.BackColor; + set => base.BackColor = value == DefaultBackColor ? PresetColor : value; + } + [Flags] private enum SlotStatus { @@ -449,9 +415,9 @@ namespace KancolleSniffer case ShipStatus.Damage.Sunk: return Color.CornflowerBlue; case ShipStatus.Damage.Badly: - return Color.Red; + return CUDColor.Red; case ShipStatus.Damage.Half: - return Color.Orange; + return CUDColor.Orange; case ShipStatus.Damage.Small: return Color.FromArgb(240, 240, 0); default: @@ -464,10 +430,12 @@ namespace KancolleSniffer var cond = status.Cond; Text = cond.ToString("D"); BackColor = cond >= 50 - ? Color.Yellow + ? CUDColor.Yellow : cond >= 30 ? PresetColor - : cond >= 20 ? Color.Orange : Color.Red; + : cond >= 20 + ? CUDColor.Orange + : CUDColor.Red; } public void SetLevel(ShipStatus status)