リビジョン | de616ed821e7d48054aaaddeeecc0afe48b9fa75 (tree) |
---|---|
日時 | 2018-03-11 23:51:02 |
作者 | Kazuhiro Fujieda <fujieda@user...> |
コミッター | Kazuhiro Fujieda |
設定ファイルをこまめに保存する
@@ -96,7 +96,14 @@ namespace KancolleSniffer | ||
96 | 96 | else |
97 | 97 | { |
98 | 98 | SetHeaderSortOrder(); |
99 | - shipListPanel.Update(_sniffer, comboBoxGroup.Text, _config.ShipList.SortOrder, _config.ShipList.ShipType); | |
99 | + shipListPanel.Update(_sniffer, comboBoxGroup.Text, _config.ShipList.SortOrder, | |
100 | + _config.ShipList.ShipType); | |
101 | + } | |
102 | + if (shipListPanel.GroupUpdated) | |
103 | + { | |
104 | + StoreShipGroupToConfig(); | |
105 | + _config.Save(); | |
106 | + shipListPanel.GroupUpdated = false; | |
100 | 107 | } |
101 | 108 | } |
102 | 109 |
@@ -168,12 +175,7 @@ namespace KancolleSniffer | ||
168 | 175 | checkBoxShipType.Checked = config.ShipType; |
169 | 176 | if (config.ShowHpInPercent) |
170 | 177 | shipListPanel.ToggleHpPercent(); |
171 | - for (var i = 0; i < ShipListPanel.GroupCount; i++) | |
172 | - { | |
173 | - shipListPanel.GroupSettings[i] = i < config.ShipGroup.Count | |
174 | - ? new HashSet<int>(config.ShipGroup[i]) | |
175 | - : new HashSet<int>(); | |
176 | - } | |
178 | + LoadShipGroupFromConfig(); | |
177 | 179 | comboBoxGroup.SelectedItem = config.Mode ?? "全員"; |
178 | 180 | if (config.Location.X == int.MinValue) |
179 | 181 | return; |
@@ -183,6 +185,13 @@ namespace KancolleSniffer | ||
183 | 185 | Height = bounds.Height; |
184 | 186 | } |
185 | 187 | |
188 | + private void LoadShipGroupFromConfig() | |
189 | + { | |
190 | + var group = _config.ShipList.ShipGroup; | |
191 | + for (var i = 0; i < ShipListPanel.GroupCount; i++) | |
192 | + shipListPanel.GroupSettings[i] = i < group.Count ? new HashSet<int>(group[i]) : new HashSet<int>(); | |
193 | + } | |
194 | + | |
186 | 195 | private void ShipListForm_FormClosing(object sender, FormClosingEventArgs e) |
187 | 196 | { |
188 | 197 | e.Cancel = true; |
@@ -190,20 +199,29 @@ namespace KancolleSniffer | ||
190 | 199 | return; |
191 | 200 | var config = _config.ShipList; |
192 | 201 | config.ShowHpInPercent = shipListPanel.ShowHpInPercent; |
193 | - var all = _sniffer.ShipList.Select(s => s.Id).ToArray(); | |
194 | - config.ShipGroup.Clear(); | |
195 | - for (var i = 0; i < ShipListPanel.GroupCount; i++) | |
196 | - { | |
197 | - if (all.Length > 0) | |
198 | - shipListPanel.GroupSettings[i].IntersectWith(all); | |
199 | - config.ShipGroup.Add(shipListPanel.GroupSettings[i].ToList()); | |
200 | - } | |
202 | + StoreShipGroupToConfig(); | |
201 | 203 | var bounds = WindowState == FormWindowState.Normal ? Bounds : RestoreBounds; |
202 | 204 | config.Location = bounds.Location; |
203 | 205 | config.Size = bounds.Size; |
204 | 206 | config.Mode = (string)comboBoxGroup.SelectedItem; |
205 | 207 | if (e.CloseReason != CloseReason.FormOwnerClosing) |
208 | + { | |
206 | 209 | Hide(); |
210 | + _config.Save(); | |
211 | + } | |
212 | + } | |
213 | + | |
214 | + private void StoreShipGroupToConfig() | |
215 | + { | |
216 | + var all = _sniffer.ShipList.Select(s => s.Id).ToArray(); | |
217 | + var group = _config.ShipList.ShipGroup; | |
218 | + group.Clear(); | |
219 | + for (var i = 0; i < ShipListPanel.GroupCount; i++) | |
220 | + { | |
221 | + if (all.Length > 0) | |
222 | + shipListPanel.GroupSettings[i].IntersectWith(all); | |
223 | + group.Add(shipListPanel.GroupSettings[i].ToList()); | |
224 | + } | |
207 | 225 | } |
208 | 226 | |
209 | 227 | public void ShowShip(int id) |
@@ -386,6 +386,7 @@ namespace KancolleSniffer | ||
386 | 386 | { |
387 | 387 | if (_configDialog.ShowDialog(this) == DialogResult.OK) |
388 | 388 | { |
389 | + _config.Save(); | |
389 | 390 | ApplyConfig(); |
390 | 391 | StopRepeatingTimer(_configDialog.RepeatSettingsChanged); |
391 | 392 | } |
@@ -40,6 +40,7 @@ namespace KancolleSniffer | ||
40 | 40 | |
41 | 41 | public const int GroupCount = 4; |
42 | 42 | public HashSet<int>[] GroupSettings { get; } = new HashSet<int>[GroupCount]; |
43 | + public bool GroupUpdated { get; set; } | |
43 | 44 | |
44 | 45 | public ScrollBar ScrollBar { get; } |
45 | 46 |
@@ -293,6 +294,7 @@ namespace KancolleSniffer | ||
293 | 294 | { |
294 | 295 | GroupSettings[group].Remove(_shipList[idx + ScrollBar.Value].Id); |
295 | 296 | } |
297 | + GroupUpdated = true; | |
296 | 298 | } |
297 | 299 | |
298 | 300 | private void CreateRepairLabels(int i) |