/// <summary> /// Nudges the entry up or down the list of loot entries. Along with the floor number to operate on (1-10) and the index of the item to move, use true for up and false for down. /// </summary> /// <param name="floorIndex">0 based index of the current floor (0 to 9)</param> /// <param name="up">true for up, false for down</param> public void NudgeEntry(int floorIndex, int indexToMove, bool up) { bool down = !up; Console.WriteLine(string.Format("Nudging entry {0}, on floor {1} {2}", indexToMove, floorIndex + 1, up ? "upward" : "downward")); if ((up && indexToMove == 0) || (down && indexToMove + 1 == entryList[floorIndex].Count)) { Console.WriteLine("OutOfBounds check succeeded - returning"); return; } else { Console.WriteLine(string.Format("OutOfBounds check failed - details:\n" + "\tup? : {0}\n" + "\tindexToMove : {1}\n" + "\tAmount of loot at current floor : {2}\n" + "\t(down && indexToMove == entryList[floorIndex].Count) : {3}\n" + "\t(up && indexToMove == 0) : {4}\n" + "\t(up && indexToMove == 0) || (down && indexToMove == entryList[floorIndex].Count) : {5}", up, indexToMove, entryList[floorIndex].Count, (down && indexToMove == entryList[floorIndex].Count), (up && indexToMove == 0), (up && indexToMove == 0) || (down && indexToMove == entryList[floorIndex].Count)) ); } LootEntry item = entryList[floorIndex][indexToMove]; entryList[floorIndex].RemoveAt(indexToMove); entryList[floorIndex].Insert(indexToMove + (up ? -1 : 1), item); }
public LootEntry GetEntry() { LootEntry entry; if (Type == "CHESTGENHOOK") { entry = new LootEntry(Id, Meta); } else { entry = new LootEntry(Id, Meta, Chance, MinAmt, MaxAmt); } return(entry); }
public LootEntry GetEntry() { LootEntry entry; if (numericUpDown_Chance.Text == "") { entry = new LootEntry(Id, Meta); } else { entry = new LootEntry(Id, Meta, Chance, MinAmt, MaxAmt); } return(entry); }
public PromptEdit(LootEntry entryToDisplay) { InitializeComponent(); if (entryToDisplay.Type == "ITEM") { // TODO: Simplify setting and getting text from boxes - perhaps by using mapping or config - too advanced ATM textBoxOriginal_ID.Text = Id = entryToDisplay.GetID(); // ID textBoxOriginal_Meta.Text = (Meta = entryToDisplay.GetMeta()).ToString(); // Meta textBoxOriginal_Chance.Text = (Chance = entryToDisplay.GetChance()).ToString(); // % Chance textBoxOriginal_Min.Text = (MinAmt = entryToDisplay.GetMinAmt()).ToString(); // Min amt textBoxOriginal_Max.Text = (MaxAmt = entryToDisplay.GetMaxAmt()).ToString(); // Max amt } else { textBoxEdit_ID.Text = textBoxOriginal_ID.Text = entryToDisplay.GetID(); textBoxOriginal_Meta.Text = (Meta = entryToDisplay.GetMeta()).ToString(); // Meta numericUpDown_Chance.Enabled = false; numericUpDown_Min.Enabled = false; numericUpDown_Max.Enabled = false; } }
// Executed when a dynamically generated ListView's item is double clicked protected void ListView_DoubleClicked(object sender, EventArgs e) { var senderListView = (ListView)sender; if (senderListView.Items.Count != 0) { // Horizontal axis in grid (Columns) int editFloorIndex = tabControlFloors.SelectedIndex; // Current floor List <LootEntry> editFloorLoot = lootTable.GetFloorLoot(editFloorIndex); // Current floor's loot // Vertical axis in grid (Items in columns) int editEntryIndex = senderListView.SelectedItems[0].Index; // Current entry index LootEntry editEntry = editFloorLoot[editEntryIndex]; // Current entry Console.WriteLine("ListView item double clicked:\n - Item index:\t" + senderListView.SelectedItems[0].Index.ToString() + "\n - Page index:\t" + tabControlFloors.SelectedIndex); // TODO: Comment this shit (edit dialog logic) UPPPPPPPPPPPPPPPP PromptEdit dialog = new PromptEdit(editEntry); dialog.StartPosition = FormStartPosition.CenterParent; dialog.Text = string.Format("Editing loot entry - Floor {0} - Entry {1}", editFloorIndex + 1, editEntryIndex + 1); if (dialog.ShowDialog(FormLootEditor.ActiveForm) == DialogResult.OK) { LootEntry editedEntry; if (editEntry.Type == "ITEM") { editedEntry = new LootEntry(dialog.Id, dialog.Meta, dialog.Chance, dialog.MinAmt, dialog.MaxAmt); } else { editedEntry = new LootEntry(dialog.Id, dialog.Meta); } lootTable.UpdateEntry(editedEntry, editFloorIndex, editEntryIndex); PopulateLists(); } } }
public void UpdateEntry(LootEntry changedEntry, int floorNum, int entryNum) { entryList[floorNum][entryNum] = changedEntry; }
public void AddEntry(int floorNumber, LootEntry entry) { entryList[floorNumber].Add(entry); }