private void entryTypeDropdown_SelectedIndexChanged(object sender, EventArgs e) { ComboBox dropDown = sender as ComboBox; if (dropDown != null) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { try { ExtraDropType type = (ExtraDropType)dropDown.SelectedItem; entry.SetType(type); } catch (InvalidCastException) { MessageBox.Show( "Error attempting to change type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { monstersListBox.Items.Add(entry.NewMonster()); } }
/// <summary> /// Handler for when the user leaves focus on the monster id text box. Now we actually update the UI. /// </summary> private void monstersIdTextBox_Leave(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null && monstersListBox.SelectedItem != null && monstersListBox.SelectedIndex >= 0) { // This ensures the list updates as well. monstersListBox.Items[monstersListBox.SelectedIndex] = entry.Monsters[monstersListBox.SelectedIndex]; } }
/// <summary> /// Handler for when the user leaves focus on the entry name text box. Now we actually update the UI. This is /// simply to be consistent with the monster and item textbox behaviours. /// </summary> private void entryNameTextBox_Leave(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { // Needed to update the name in the ListBox as well. entriesListBox.Items[entriesListBox.SelectedIndex] = entry; } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null && monstersListBox.SelectedItem != null && monstersListBox.SelectedIndex >= 0) { entry.DeleteMonster(monstersListBox.SelectedIndex); // This ensures the list updates as well. monstersListBox.Items.RemoveAt(monstersListBox.SelectedIndex); } }
private void deleteToolStripMenuItem1_Click(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { entry.DeleteItem(dropItemsListBox.SelectedIndex); // This ensures the list updates as well. dropItemsListBox.Items.RemoveAt(dropItemsListBox.SelectedIndex); entryDropItemsGroup.Text = string.Format("Drop Items ({0}/256)", entry.DropItems.Count); } }
/// <summary> /// Handler for when the user leaves focus on the drop item probability text box. Now we actually update the UI. /// </summary> private void dropItemsProbabilityTextBox_Leave(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { ExtraDropItem item = dropItemsListBox.SelectedItem as ExtraDropItem; if (item != null && dropItemsListBox.SelectedItem != null && dropItemsListBox.SelectedIndex >= 0) { // This ensures the list updates as well. dropItemsListBox.Items[dropItemsListBox.SelectedIndex] = item; } } }
/// <summary> /// Handler for when the entry name text box is editted. Here, we will only update the entry name in the entry /// and not the UI. This is simply to be consistent with the monster and item textbox behaviours. /// </summary> private void entryNameTextBox_TextChanged(object sender, EventArgs e) { TextBox textBox = sender as TextBox; if (textBox != null) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { string name = textBox.Text; entry.SetName(name); } } }
private void entriesListBox_SelectedIndexChanged(object sender, EventArgs e) { ListBox listBox = sender as ListBox; if (listBox != null) { ExtraDropEntry entry = listBox.SelectedItem as ExtraDropEntry; if (entry != null) { // Name. entryNameTextBox.Text = entry.Name; // Type. entryTypeDropdown.SelectedItem = entry.Type; // Drop num probabilities. entryDrop0Textbox.Text = entry.GetDropProbability(0).ToString("0.0###############"); entryDrop1Textbox.Text = entry.GetDropProbability(1).ToString("0.0###############"); entryDrop2Textbox.Text = entry.GetDropProbability(2).ToString("0.0###############"); entryDrop3Textbox.Text = entry.GetDropProbability(3).ToString("0.0###############"); entryDrop4Textbox.Text = entry.GetDropProbability(4).ToString("0.0###############"); entryDrop5Textbox.Text = entry.GetDropProbability(5).ToString("0.0###############"); entryDrop6Textbox.Text = entry.GetDropProbability(6).ToString("0.0###############"); entryDrop7Textbox.Text = entry.GetDropProbability(7).ToString("0.0###############"); // Monsters. monstersListBox.Items.Clear(); monstersIdTextBox.Clear(); foreach (int monsterId in entry.Monsters) { monstersListBox.Items.Add(monsterId); } // Drop Items. dropItemsListBox.Items.Clear(); dropItemsIdTextBox.Clear(); dropItemsProbabilityTextBox.Clear(); foreach (ExtraDropItem item in entry.DropItems) { dropItemsListBox.Items.Add(item); } entryDropItemsGroup.Text = string.Format("Drop Items ({0}/256)", entry.DropItems.Count); } } }
/// <summary> /// Handler for when the monster id text box is editted. Here, we will only update the item id in the entry /// and not the UI. This is because updating the UI forces the id to get formatted, which makes it hard to type. /// </summary> private void monstersIdTextBox_TextChanged(object sender, EventArgs e) { TextBox textBox = sender as TextBox; if (textBox != null) { // We'll only update the id if it is actually a valid int. This is because numbers tend to take more // than one keystrokes to type and can be easily typed incorrectly. int monsterId; if (int.TryParse(textBox.Text, out monsterId)) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { entry.EditMonster(monstersListBox.SelectedIndex, monsterId); } } } }
/// <summary> /// Handler to handle all drop num textbox TextChanged events. /// </summary> /// <param name="sender">The textbox that sent the event.</param> /// <param name="i">The drop num to change.</param> private void dropNumTextbox_TextChanged(object sender, int i) { TextBox textBox = sender as TextBox; if (textBox != null) { // We'll only update the probability if it is actually a valid float. This is because numbers tend to // take more than one keystrokes to type and can be easily typed incorrectly. float probability; if (float.TryParse(textBox.Text, out probability)) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { entry.SetDropProbability(i, probability); } } } }
private void newToolStripMenuItem1_Click(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { try { dropItemsListBox.Items.Add(entry.NewItem()); entryDropItemsGroup.Text = string.Format("Drop Items ({0}/256)", entry.DropItems.Count); } catch (OverflowException) { MessageBox.Show( "Cannot have more than 256 drop items.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } } }
/// <summary> /// Handler for when the drop item probability text box is editted. Here, we will only update the probability in /// the entry and not the UI. This is because updating the UI forces the probability to get formatted, which /// makes it hard to type. /// </summary> private void dropItemsProbabilityTextBox_TextChanged(object sender, EventArgs e) { TextBox textBox = sender as TextBox; if (textBox != null) { // We'll only update the id if it is actually a valid int. This is because numbers tend to take more // than one keystrokes to type and can be easily typed incorrectly. float probability; if (float.TryParse(textBox.Text, out probability)) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { ExtraDropItem item = dropItemsListBox.SelectedItem as ExtraDropItem; if (item != null) { entry.EditItemProbability(dropItemsListBox.SelectedIndex, probability); } } } } }
/// <summary> /// Handler for Menu->Tools->Check Probabilities. This will verify whether the probabilities add up to 1. /// </summary> private void checkProbabilitiesToolStripMenuItem_Click(object sender, EventArgs e) { ExtraDropEntry entry = entriesListBox.SelectedItem as ExtraDropEntry; if (entry != null) { bool allClear = true; if (!entry.IsDropNumProbabilitiesCorrect()) { allClear = false; DialogResult result = MessageBox.Show( "The drop num probabilities of the current entry does not add up to 1.0.\n" + "Would you like to fix this automatically?", "Drop Num Probabilities", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ); if (result == DialogResult.Yes) { entry.FixDropNumProbabilities(); // Force refres drop num probabilities. entryDrop0Textbox.Text = entry.GetDropProbability(0).ToString("0.0###############"); entryDrop1Textbox.Text = entry.GetDropProbability(1).ToString("0.0###############"); entryDrop2Textbox.Text = entry.GetDropProbability(2).ToString("0.0###############"); entryDrop3Textbox.Text = entry.GetDropProbability(3).ToString("0.0###############"); entryDrop4Textbox.Text = entry.GetDropProbability(4).ToString("0.0###############"); entryDrop5Textbox.Text = entry.GetDropProbability(5).ToString("0.0###############"); entryDrop6Textbox.Text = entry.GetDropProbability(6).ToString("0.0###############"); entryDrop7Textbox.Text = entry.GetDropProbability(7).ToString("0.0###############"); } } if (!entry.IsDropItemsProbabilitiesCorrect()) { allClear = false; DialogResult result = MessageBox.Show( "The drop items probabilities of the current entry does not add up to 1.0.\n" + "Would you like to fix this automatically?", "Drop Items Probabilities", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ); if (result == DialogResult.Yes) { entry.FixDropItemsProbabilities(); // Refresh drop items probabilities. dropItemsListBox.Items.Clear(); dropItemsIdTextBox.Clear(); dropItemsProbabilityTextBox.Clear(); foreach (ExtraDropItem item in entry.DropItems) { dropItemsListBox.Items.Add(item); } } } if (allClear) { MessageBox.Show( "No problems found.", "All Clear!", MessageBoxButtons.OK, MessageBoxIcon.None ); } } }