private void Delete_Click(object sender, EventArgs e) { var selectedItem = (KeyValuePair <int, InventorySortInfo>)listBoxInventoryOptions.SelectedItem; if (selectedItem.Key >= ItemSortStatus.SaddlebagInventoryIndex) { DialogResult dr = MessageBox.Show( $"Are you sure you want to delete {selectedItem.Value.Name}?", "Really Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dr != DialogResult.Yes) { return; } } else { DialogResult dr = MessageBox.Show( $"Are you REALLY sure you want to delete the Player Inventory from being sorted?{Environment.NewLine}This is probably going to break things... don't blame me.", Strings.WarningCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Hand); if (dr != DialogResult.Yes) { return; } } if (AutoRetainerSortSettings.Instance.InventoryOptions.Remove(selectedItem.Key)) { AutoRetainerSort.LogSuccess($"We've removed {selectedItem.Value.Name} from the list. Good bye, so long!"); } else { AutoRetainerSort.LogCritical($"Something went wrong with trying to remove {selectedItem.Value.Name} from the list... Index: {selectedItem.Key.ToString()}"); } AutoRetainerSortSettings.Instance.Save(); ResetBindingSource(); }
private void AddNewItem_Click(object sender, EventArgs e) { var toAddIds = new HashSet <uint>(); using (AddNewItemForm newItemForm = new AddNewItemForm()) { DialogResult dr = newItemForm.ShowDialog(this); if (dr != DialogResult.OK) { return; } SearchResult selectedItem = newItemForm.SelectedSearchResult; if (selectedItem == null || selectedItem.RawItemId == 0) { return; } if (newItemForm.ModifierNone) { toAddIds.Add(selectedItem.RawItemId); } else if (newItemForm.ModifierHQ) { toAddIds.Add(selectedItem.RawItemId + QualityOffset); } else if (newItemForm.ModifierCollectable) { toAddIds.Add(selectedItem.RawItemId + CollectableOffset); } else { return; } if (newItemForm.IncludeHQ) { toAddIds.Add(selectedItem.RawItemId + QualityOffset); } if (newItemForm.IncludeCollectable) { toAddIds.Add(selectedItem.RawItemId + CollectableOffset); } } foreach (uint toAddId in toAddIds) { ItemSortInfo sortInfo = ItemSortStatus.GetSortInfo(toAddId); var shouldAdd = true; foreach (var indexInfoPair in AutoRetainerSortSettings.Instance.InventoryOptions) { if (indexInfoPair.Key == _index) { continue; } if (!indexInfoPair.Value.ContainsItem(sortInfo)) { continue; } if (sortInfo.ItemInfo.Unique) { continue; } DialogResult dr = MessageBox.Show( string.Format(Strings.AddNewItem_AlreadyExists_Warning, indexInfoPair.Value.Name, sortInfo.Name, indexInfoPair.Value.Name, _sortInfo.Name), Strings.WarningCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { indexInfoPair.Value.SpecificItems.Remove(sortInfo); } else { shouldAdd = false; break; } } if (!shouldAdd) { continue; } AutoRetainerSort.LogSuccess($"Added {sortInfo.Name} to {_sortInfo.Name}!"); _bsItems.Add(sortInfo); } AutoRetainerSortSettings.Instance.Save(); }
private void AutoSetup_Click(object sender, EventArgs e) { if (!AutoRetainerSortSettings.Instance.InventoryOptions.ContainsKey(ItemSortStatus.PlayerInventoryIndex)) { DialogResult dr = MessageBox.Show( "It looks like you don't have the player inventory added to the indexes... somehow. Do you want me to re-add that for you?", "Um.", MessageBoxButtons.YesNo, MessageBoxIcon.Warning ); if (dr == DialogResult.Yes) { AutoRetainerSortSettings.Instance.InventoryOptions.Add(ItemSortStatus.PlayerInventoryIndex, new InventorySortInfo("Player Inventory")); } } if (!AutoRetainerSortSettings.Instance.InventoryOptions.ContainsKey(ItemSortStatus.SaddlebagInventoryIndex)) { DialogResult dr = MessageBox.Show( "It looks like you don't have the chocobo saddlebag added to the indexes. Do you want me to re-add that for you?", "Hey Listen!", MessageBoxButtons.YesNo, MessageBoxIcon.Information ); if (dr == DialogResult.Yes) { AutoRetainerSortSettings.Instance.InventoryOptions.Add(ItemSortStatus.SaddlebagInventoryIndex, new InventorySortInfo("Chocobo Saddlebag")); } } MessageBox.Show( Strings.AutoSetup_CacheAdvice, "Careful!", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult warningResult = MessageBox.Show( Strings.AutoSetup_OverwriteWarning, "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (warningResult == DialogResult.No) { return; } bool conflictUnsorted = MessageBox.Show( Strings.AutoSetup_ConflictQuestion, "Conflict?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; var newInventorySetup = AutoRetainerSortSettings.Instance.InventoryOptions; foreach (InventorySortInfo inventorySortInfo in newInventorySetup.Values) { inventorySortInfo.SortTypes.Clear(); } var orderedRetainerList = RetainerList.Instance.OrderedRetainerList; for (var i = 0; i < orderedRetainerList.Length; i++) { if (newInventorySetup.ContainsKey(i)) { continue; } RetainerInfo retInfo = orderedRetainerList[i]; if (!retInfo.Active) { continue; } newInventorySetup.Add(i, new InventorySortInfo(retInfo.Name)); } AutoRetainerSortSettings.Instance.InventoryOptions = newInventorySetup; ItemSortStatus.UpdateFromCache(orderedRetainerList); var sortTypeCounts = new Dictionary <SortType, Dictionary <int, int> >(); foreach (SortType sortType in Enum.GetValues(typeof(SortType)).Cast <SortType>()) { sortTypeCounts[sortType] = new Dictionary <int, int>(); } foreach (CachedInventory cachedInventory in ItemSortStatus.GetAllInventories()) { foreach (SortType sortType in cachedInventory.ItemCounts.Select(x => ItemSortStatus.GetSortInfo(x.Key).SortType)) { var indexCountDic = sortTypeCounts[sortType]; if (indexCountDic.ContainsKey(cachedInventory.Index)) { indexCountDic[cachedInventory.Index]++; } else { indexCountDic.Add(cachedInventory.Index, 1); } } } foreach (var typeDicPair in sortTypeCounts) { SortType sortType = typeDicPair.Key; int indexCount = typeDicPair.Value.Keys.Count; if (indexCount == 0) { continue; } if (indexCount > 1 && conflictUnsorted) { continue; } int desiredIndex = typeDicPair.Value.OrderByDescending(x => x.Value).First().Key; AutoRetainerSortSettings.Instance.InventoryOptions[desiredIndex].SortTypes.Add(new SortTypeWithCount(sortType)); } ResetBindingSource(); AutoRetainerSortSettings.Instance.Save(); AutoRetainerSort.LogSuccess("Auto-Setup done!"); }