/// <summary>Downloads all of the quests <paramref name="thisChar"/> has started it hasn't already been.</summary> /// <param name="thisChar">The character being examined.</param> private void CharGetAllQuests(Characters thisChar) { int oldQuestCount = Program.questList.Count, oldItemCount = Program.itemList.Count; Cursor.Current = Cursors.WaitCursor; List <long> NewItemsList = new List <long>(); ConcurrentBag <QuestItem> NewItemsBag = new ConcurrentBag <QuestItem>(); StatusStripProgressBar.Maximum = thisChar.CharCollection.Count; StatusStripProgressBar.Value = 0; StatusStripProgressBar.Visible = true; foreach (long thisColl in thisChar.CharCollection.Keys) { if (!Program.questList.ContainsKey(thisColl)) { CollQuest TempQuest; try { TempQuest = new CollQuest(thisColl); } catch (Exception Err) { BadEnd(); throw Err; } Program.questList[TempQuest.DaybreakID] = TempQuest; _ = Parallel.ForEach(TempQuest.items, thisItem => { QuestItem TempItem; if (!Program.itemList.ContainsKey(thisItem)) { try { TempItem = new QuestItem(thisItem); } catch (Exception Err) { BadEnd(); throw Err; } if (!NewItemsBag.Contains(TempItem)) { NewItemsBag.Add(TempItem); } } }); } StatusStripProgressBar.Value++; } if (NewItemsBag.Count > 0) { foreach (QuestItem ThisItem in NewItemsBag) { Program.itemList[ThisItem.DaybreakID] = ThisItem; } } Cursor.Current = Cursors.Default; StatusStripProgressBar.Visible = false; CharQuestListBox.Refresh(); dirties[2] = (oldItemCount != Program.itemList.Count) || dirties[2]; dirties[3] = (oldQuestCount != Program.questList.Count) || dirties[3]; if (dirties[2] || dirties[3]) { StatusStripDirtyIndicator.Text = FloppyString; } }
private void CharListBox_SelectedIndexChanged(object sender, EventArgs e) { CharQuestItemsCheckListBox.Items.Clear(); CharQuestListBox.Items.Clear(); if (CharListBox.SelectedIndex == -1) { return; } if (CharListBox.SelectedItem is string) { CharIntroTxtBox.Text = string.Empty; return; } Characters thisChar = CharListBox.SelectedItem as Characters; CharIntroTxtBox.Text = $"{thisChar.name} is a {thisChar.AdvLvl} {Program.AdvClasses[thisChar.AdvClass]}"; DialogResult GetAllQuests = DialogResult.Retry; int OldItemCount; foreach (long thisColl in thisChar.CharCollection.Keys) { OldItemCount = thisChar.CharCollection[thisColl].Count; if (thisChar.IsComplete(thisColl) && HideCompletedOnChar) { if (OldItemCount != thisChar.CharCollection[thisColl].Count) { dirties[0] = true; UpdateDirtiesStatus(); } continue; } else if (OldItemCount != thisChar.CharCollection[thisColl].Count) { dirties[0] = true; UpdateDirtiesStatus(); } if ((!Program.questList.ContainsKey(thisColl)) && (GetAllQuests == DialogResult.Retry)) { GetAllQuests = MessageBox.Show($"{thisChar.name} has one or more missing quests.\nWould you like to download the missing quests now?", "Missing Quests", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (!Program.questList.ContainsKey(thisColl) && (GetAllQuests == DialogResult.Yes)) { CharGetAllQuests(thisChar); CharQuestListBox.Items.Add(Program.questList[thisColl]); } else if (Program.questList.ContainsKey(thisColl)) { CharQuestListBox.Items.Add(Program.questList[thisColl]); } } CharQuestListBox.Refresh(); if (CharListBox.SelectedIndex == -1) { UpdChar.Enabled = false; DelChar.Enabled = false; } else { UpdChar.Enabled = thisChar.GetType() == typeof(Characters); DelChar.Enabled = thisChar.GetType() == typeof(Characters); } UpdChar.Refresh(); DelChar.Refresh(); CharQuestListBox.SelectedIndex = -1; }