Example #1
0
 private void AddQuestNameConfirmBtn_Click(object sender, EventArgs e)
 {
     if (AddQuestNameResultsLB.Items.Count == 0)
     {
         return;
     }
     if (AddQuestNameResultsLB.SelectedItems.Count > 1)
     {
         return;
     }
     if (AddQuestNameResultsLB.SelectedItem is NamedResults thisCQ)
     {
         if (Program.questList.ContainsKey(thisCQ.DaybreakID))
         {
             _ = MessageBox.Show("This quest is already downloaded.",
                                 "Already Downloaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             try { NewQuest = new CollQuest(thisCQ.DaybreakID); }
             catch (Exception Err)
             {
                 ReturnedException = Err;
                 DialogResult      = DialogResult.Abort;
                 Close();
                 return;
             }
             FinalResult = DialogResult.OK;
             Close();
         }
     }
 }
Example #2
0
        /// <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;
            }
        }
Example #3
0
        private void CharQuestListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            CharQuestItemsCheckListBox.Items.Clear();
            if (CharQuestListBox.SelectedIndex == -1)
            {
                CharQuestItemsCheckListBox.Refresh();
                return;
            }
            if ((CharQuestListBox.SelectedIndex == 0) && (CharQuestListBox.SelectedItem is string))
            {
                CharQuestItemsCheckListBox.Refresh();
                return;
            }
            CollQuest  thisQuest = (CollQuest)CharQuestListBox.SelectedItem;
            Characters thisChar  = (Characters)CharListBox.SelectedItem;
            int        OldCount  = 0;

            if (thisChar == null)
            {
                CharQuestListBox.Items.Clear();
                _ = CharListBox.Focus();
                return;
            }
            if (thisChar.CharCollection.ContainsKey(thisQuest.DaybreakID))
            {
                OldCount = thisChar.CharCollection[thisQuest.DaybreakID].Count;
            }
            if (thisChar.CharCollection.ContainsKey(thisQuest.DaybreakID) && (OldCount != thisChar.CharCollection[thisQuest.DaybreakID].Count))
            {
                dirties[0] = true;
                UpdateDirtiesStatus();
            }
            foreach (long thisItemID in thisQuest.items)
            {
                QuestItem thisItem = Program.itemList[thisItemID];
                if (thisItem == null)
                {
                    try { thisItem = new QuestItem(thisItemID); }
                    catch (Exception Err)
                    {
                        BadEnd();
                        throw Err;
                    }
                    Program.itemList[thisItem.DaybreakID] = thisItem;
                    dirties[2] = true;
                    StatusStripDirtyIndicator.Text = FloppyString;
                }
                if (thisChar.IsComplete(thisQuest.DaybreakID))
                {
                    _ = CharQuestItemsCheckListBox.Items.Add(thisItem, true);
                }
                else
                {
                    _ = CharQuestItemsCheckListBox.Items.Add(thisItem, thisChar.CharCollection[thisQuest.DaybreakID].Contains(thisItemID));
                }
            }
            CharQuestItemsCheckListBox.Refresh();
        }
Example #4
0
        private void AddQuestIDSearch_Click(object sender, EventArgs e)
        {
            CollQuest TempQuest;

            if (string.IsNullOrWhiteSpace(AddQuestIDMTB.Text))
            {
                return;
            }
            if (!long.TryParse(AddQuestIDMTB.Text, out long NewDaybreakID))
            {
                return;
            }
            string    SearchURL = string.Concat(@"collection/?c:limit=30&c:show=category,name,level,id,reference_list&name=^", NewDaybreakID.ToString());
            XDocument RawQuest  = Program.GetThisURL(SearchURL);

            switch (short.Parse(RawQuest.Root.Attribute("returned").Value))
            {
            case 0:
                _ = MessageBox.Show($"No quests were found with the ID {NewDaybreakID}. Please try again.",
                                    "No Quests Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                AddQuestIDResetBtn.PerformClick();
                return;

            case 1:
                try { TempQuest = new CollQuest(NewDaybreakID); }
                catch (Exception Err)
                {
                    ReturnedException = Err;
                    FinalResult       = DialogResult.Abort;
                    Close();
                    return;
                }
                break;

            default:
                _ = MessageBox.Show($"Too many quests were found for the ID {NewDaybreakID} to be unique. Please try again.",
                                    "Too Many Quests Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                AddQuestIDResetBtn.PerformClick();
                return;
            }
            if (AddQuestIDResultsLB.Items.Count > 0)
            {
                AddQuestIDResultsLB.Items.Clear();
            }
            _ = AddQuestIDResultsLB.Items.Add(TempQuest);
            _ = AddQuestIDResultsLB.Focus();
            AddQuestIDResultsLB.SelectedIndex = 0;
        }
Example #5
0
 private void AddQuestIDConfirmAdd_Click(object sender, EventArgs e)
 {
     if (AddQuestIDResultsLB.Items.Count == 0)
     {
         return;
     }
     if (AddQuestIDResultsLB.Items.Count == 1)
     {
         if ((AddQuestIDResultsLB.SelectedItem == null) && (AddQuestIDResultsLB.Items[0] is CollQuest unselCQ))
         {
             DialogResult AddUnselected = MessageBox.Show($"Do you want to add the quest \"{unselCQ.QuestName}\"?",
                                                          "Add Unselected Quest", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (AddUnselected != DialogResult.Yes)
             {
                 return;
             }
             NewQuest    = unselCQ;
             FinalResult = DialogResult.OK;
             Close();
             return;
         }
         else if (AddQuestIDResultsLB.SelectedItem is CollQuest thisCQ)
         {
             NewQuest    = thisCQ;
             FinalResult = DialogResult.OK;
             Close();
             return;
         }
     }
     if (AddQuestIDResultsLB.Items.Count > 1)
     {
         if (AddQuestIDResultsLB.SelectedItem == null)
         {
             return;
         }
         if (AddQuestIDResultsLB.SelectedItem is CollQuest thisCQ)
         {
             NewQuest    = thisCQ;
             FinalResult = DialogResult.OK;
             Close();
         }
     }
 }