/// <summary> /// Called whenever an item is clicked in the NPC's drops panel. First we check to see if the drop is /// a drop with a range of quantities. Next, we check if it is a drop with multiple possible quantities. /// Third, we check to see if the drop is a rare drop table drop. If the drop meets any of those /// criteria, we show the special form for handling those instances. Otherwise we just log the drop. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void dropsListView_ItemActivate(object sender, EventArgs e) { if (hasDropFormOpen) { return; } ListView listView = (ListView)sender; ListViewItem listViewItem = listView.SelectedItems[0]; Drop dropToLog = (Drop)listViewItem.Tag; if (dropToLog.IsRangeOfDrops) { AddDropRangeForm addDropRangeFrom = new AddDropRangeForm(); addDropRangeFrom.dropLabel.Text = dropToLog.Name; addDropRangeFrom.rangeTextBox.KeyDown += RangeTextBox_KeyDown; addDropRangeFrom.addDropButton.Click += AddDropButton_Click; addDropRangeFrom.rangeTextBox.Tag = dropToLog; addDropRangeFrom.addDropButton.Tag = dropToLog; addDropRangeFrom.Show(this); hasDropFormOpen = true; } else if (dropToLog.HasMultipleQuantities) { AddDropMultipleForm addDropMultipleForm = new AddDropMultipleForm(); addDropMultipleForm.dropLabel.Text = dropToLog.Name; foreach (int quantityOption in dropToLog.MultipleQuantities) { addDropMultipleForm.quantityOptionsListBox.Items.Add(quantityOption); } addDropMultipleForm.quantityOptionsListBox.Text = dropToLog.MultipleQuantities[0].ToString(); addDropMultipleForm.quantityOptionsListBox.Tag = dropToLog; addDropMultipleForm.addDropButton.Click += AddMultipleRangeDropButton_Click; addDropMultipleForm.Show(this); hasDropFormOpen = true; } else if (dropToLog.Name.Equals("RareDropTable")) { AddRareDropForm addRareDropForm = new AddRareDropForm(); addRareDropForm.rareDropsOptionList.Items.AddRange(osrsDropContainers.RareDropTable.Cast <object>().ToArray()); addRareDropForm.addRareDropButton.Click += AddRareDropButton_Click; addRareDropForm.Show(this); hasDropFormOpen = true; } else { osrsDropContainers.LogDrop(dropToLog); } }
/// <summary> /// Called when a drop is added with a custom range. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddDropButton_Click(object sender, EventArgs e) { Button button = (Button)sender; AddDropRangeForm form = (AddDropRangeForm)button.TopLevelControl; Drop drop = (Drop)button.Tag; int quantity = 1; if (Int32.TryParse(form.rangeTextBox.Text, out quantity)) { if (quantity < drop.RangeLowBound || quantity > drop.RangeHighBound) { return; } drop.Quantity = quantity; osrsDropContainers.LogDrop(drop); form.Close(); hasDropFormOpen = false; } }