• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修订版449ccebc82a489b7fe2561d7592637bddb52f021 (tree)
时间2020-09-16 19:30:12
作者Kazuhiro Fujieda <fujieda@user...>
CommiterKazuhiro Fujieda

Log Message

一覧の艦娘の分類をセカンダリに反映させるのに再起動が必要なのを直す

更改概述

差异

--- a/KancolleSniffer/Forms/ListForm.cs
+++ b/KancolleSniffer/Forms/ListForm.cs
@@ -103,7 +103,48 @@ namespace KancolleSniffer.Forms
103103 shipListPanel.ToggleHpPercent();
104104 battleResultPanel.ToggleHpPercent();
105105 }
106- LoadShipGroupFromConfig();
106+ }
107+
108+ private ShipListConfig GetConfig()
109+ {
110+ if (_isMaster)
111+ {
112+ SetGroup();
113+ return _config.ShipList;
114+ }
115+ if (_config.ListFormGroup.Count == 0)
116+ return CreateSecondaryConfig();
117+ var config = _config.ListFormGroup[0];
118+ _config.ListFormGroup.RemoveAt(0);
119+ config.ShipGroup = _config.ShipList.ShipGroup;
120+ return config;
121+ }
122+
123+ private ShipListConfig CreateSecondaryConfig()
124+ {
125+ var src = _config.ShipList;
126+ var config = new ShipListConfig
127+ {
128+ Mode = src.Mode,
129+ ShipCategories = src.ShipCategories,
130+ ShipType = src.ShipType,
131+ ShowHpInPercent = src.ShowHpInPercent,
132+ SortOrder = src.SortOrder,
133+ Location = src.Location,
134+ Size = src.Size,
135+ ShipGroup = src.ShipGroup
136+ };
137+ if (config.Mode == "分類" || string.IsNullOrEmpty(config.Mode))
138+ config.Mode = "全艦";
139+ return config;
140+ }
141+
142+ private void SetGroup()
143+ {
144+ var groups = _config.ShipList.ShipGroup;
145+ for (var i = groups.Count; i < GroupConfigLabels.GroupCount; i++)
146+ groups.Add(new List<int>());
147+ shipListPanel.GroupSettings = groups;
107148 }
108149
109150 public void UpdateList()
@@ -135,12 +176,25 @@ namespace KancolleSniffer.Forms
135176 }
136177 if (shipListPanel.GroupUpdated)
137178 {
138- StoreShipGroupToConfig();
179+ PurifyShipGroup();
139180 _config.Save();
140181 shipListPanel.GroupUpdated = false;
141182 }
142183 }
143184
185+ private void PurifyShipGroup()
186+ {
187+ var all = _sniffer.ShipList.Select(s => s.Id).ToArray();
188+ if (all.Length == 0)
189+ return;
190+ foreach (var g in _config.ShipList.ShipGroup)
191+ {
192+ var filtered = g.Intersect(all).ToArray();
193+ g.Clear();
194+ g.AddRange(filtered);
195+ }
196+ }
197+
144198 private void SetHeaderVisibility()
145199 {
146200 static void Set(Control header, bool visible)
@@ -287,43 +341,8 @@ namespace KancolleSniffer.Forms
287341
288342 private void SetMinimumSize()
289343 {
290- MinimumSize = new Size(Width - Scaler.ScaleWidth(24) - SystemInformation.VerticalScrollBarWidth * (_config.Zoom - 100) / 100, 0);
291- }
292-
293- private ShipListConfig GetConfig()
294- {
295- if (_isMaster)
296- return _config.ShipList;
297- if (_config.ListFormGroup.Count == 0)
298- return CreateSecondaryConfig();
299- var config = _config.ListFormGroup[0];
300- _config.ListFormGroup.RemoveAt(0);
301- return config;
302- }
303-
304- private ShipListConfig CreateSecondaryConfig()
305- {
306- var src = _config.ShipList;
307- var config = new ShipListConfig
308- {
309- Mode = src.Mode,
310- ShipCategories = src.ShipCategories,
311- ShipType = src.ShipType,
312- ShowHpInPercent = src.ShowHpInPercent,
313- SortOrder = src.SortOrder,
314- Location = src.Location,
315- Size = src.Size
316- };
317- if (config.Mode == "分類" || string.IsNullOrEmpty(config.Mode))
318- config.Mode = "全艦";
319- return config;
320- }
321-
322- private void LoadShipGroupFromConfig()
323- {
324- var group = _config.ShipList.ShipGroup;
325- for (var i = 0; i < GroupConfigLabels.GroupCount; i++)
326- shipListPanel.GroupSettings[i] = i < group.Count ? new HashSet<int>(group[i]) : new HashSet<int>();
344+ MinimumSize = new Size(Width - Scaler.ScaleWidth(24) -
345+ SystemInformation.VerticalScrollBarWidth * (_config.Zoom - 100) / 100, 0);
327346 }
328347
329348 private void SetCheckBoxSTypeState()
@@ -354,7 +373,7 @@ namespace KancolleSniffer.Forms
354373
355374 private void SaveMasterState()
356375 {
357- StoreShipGroupToConfig();
376+ PurifyShipGroup();
358377 _listConfig.Visible = Visible && WindowState == FormWindowState.Normal;
359378 SaveBounds(_listConfig); // 最小化時は以前のサイズを記録する
360379 }
@@ -366,6 +385,7 @@ namespace KancolleSniffer.Forms
366385 if (WindowState != FormWindowState.Normal) // 最小化時は次回復旧しない
367386 return;
368387 _listConfig.Visible = true;
388+ _listConfig.ShipGroup = null;
369389 _config.ListFormGroup.Add(_listConfig);
370390 SaveBounds(_listConfig);
371391 }
@@ -419,19 +439,6 @@ namespace KancolleSniffer.Forms
419439 Owner = null;
420440 }
421441
422- private void StoreShipGroupToConfig()
423- {
424- var all = _sniffer.ShipList.Select(s => s.Id).ToArray();
425- var group = _config.ShipList.ShipGroup;
426- group.Clear();
427- for (var i = 0; i < GroupConfigLabels.GroupCount; i++)
428- {
429- if (all.Length > 0)
430- shipListPanel.GroupSettings[i].IntersectWith(all);
431- group.Add(shipListPanel.GroupSettings[i].ToList());
432- }
433- }
434-
435442 public void ShowShip(int id)
436443 {
437444 if (!Visible)
@@ -627,7 +634,8 @@ namespace KancolleSniffer.Forms
627634
628635 private void ListForm_ResizeEnd(object sender, EventArgs e)
629636 {
630- foreach (var panel in new IPanelResize[] {shipListPanel, antiAirPanel, airBattleResultPanel, battleResultPanel, fleetPanel})
637+ foreach (var panel in new IPanelResize[]
638+ {shipListPanel, antiAirPanel, airBattleResultPanel, battleResultPanel, fleetPanel})
631639 {
632640 if (panel.Visible)
633641 panel.ApplyResize();
--- a/KancolleSniffer/View/ShipListPanel/GroupConfigLabels.cs
+++ b/KancolleSniffer/View/ShipListPanel/GroupConfigLabels.cs
@@ -18,7 +18,6 @@ using System.Drawing;
1818 using System.Linq;
1919 using System.Windows.Forms;
2020 using KancolleSniffer.Forms;
21-using KancolleSniffer.Model;
2221
2322 // ReSharper disable CoVariantArrayConversion
2423
@@ -31,7 +30,7 @@ namespace KancolleSniffer.View.ShipListPanel
3130 private readonly List<ShipLabels> _labelList = new List<ShipLabels>();
3231
3332 public const int GroupCount = 4;
34- public HashSet<int>[] GroupSettings { get; } = new HashSet<int>[GroupCount];
33+ public List<List<int>> GroupSettings { get; set; }
3534 public bool GroupUpdated { get; set; }
3635
3736 public GroupConfigLabels(ShipListPanel shipListPanel)
@@ -123,13 +122,5 @@ namespace KancolleSniffer.View.ShipListPanel
123122 {
124123 _labelList[i].BackPanel.Visible = false;
125124 }
126-
127- public IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships, string group)
128- {
129- var g = Array.FindIndex(new[] {"A", "B", "C", "D"}, x => x == group);
130- if (g == -1)
131- return ships;
132- return from s in ships where GroupSettings[g].Contains(s.Id) select s;
133- }
134125 }
135126 }
\ No newline at end of file
--- a/KancolleSniffer/View/ShipListPanel/ShipListPanel.cs
+++ b/KancolleSniffer/View/ShipListPanel/ShipListPanel.cs
@@ -37,7 +37,12 @@ namespace KancolleSniffer.View.ShipListPanel
3737 private string _mode;
3838 private bool _hpPercent;
3939
40- public HashSet<int>[] GroupSettings => _groupConfigLabels.GroupSettings;
40+ public List<List<int>> GroupSettings
41+ {
42+ get => _groupConfigLabels.GroupSettings;
43+ set => _groupConfigLabels.GroupSettings = value;
44+ }
45+
4146
4247 public bool GroupUpdated
4348 {
@@ -118,7 +123,7 @@ namespace KancolleSniffer.View.ShipListPanel
118123 private void CreateShipList(Sniffer sniffer, ShipListConfig settings)
119124 {
120125 var ships = FilterByShipTypes(
121- _mode == "修復" ? sniffer.RepairList : _groupConfigLabels.FilterByGroup(sniffer.ShipList, _mode),
126+ _mode == "修復" ? sniffer.RepairList : FilterByGroup(sniffer.ShipList, settings.ShipGroup, _mode),
122127 settings.ShipCategories).ToArray();
123128 var order = _mode == "修復" ? ListForm.SortOrder.Repair : settings.SortOrder;
124129 if (!settings.ShipType)
@@ -134,6 +139,17 @@ namespace KancolleSniffer.View.ShipListPanel
134139 }).Concat(ships).OrderBy(ship => ship, new CompareShip(true, order)).ToArray();
135140 }
136141
142+ private static IEnumerable<ShipStatus> FilterByGroup(IEnumerable<ShipStatus> ships,
143+ IReadOnlyList<List<int>> groups, string groupName)
144+ {
145+ var g = Array.FindIndex(new[] {"A", "B", "C", "D"}, x => x == groupName);
146+ if (g == -1)
147+ return ships;
148+ if (groups.Count == 0)
149+ return new ShipStatus[0];
150+ return from s in ships where groups[g].Contains(s.Id) select s;
151+ }
152+
137153 private static readonly int[][] ShipTypeIds =
138154 {
139155 new[] // 戦艦