public static void ExportSingleItem(StreamWriter exportFile, GDStashItem item, int indentLevel, string duplicateCount) { indentLevel++; string itemName; if (item.Tier == 1) { itemName = item.Name + " - Empowered"; } if (item.Tier == 2) { itemName = item.Name + " - Mythical"; } else { itemName = item.Name; } if (Settings.Default.ExportUseIndent) { for (int i = 0; i < indentLevel; i++) { exportFile.Write(" "); } } exportFile.WriteLine(string.Format(Settings.Default.ExportFormat, itemName, item.Category, item.SubCategory, item.LevelRequirement, duplicateCount, item.Url)); }
internal void Read(GDBlockReader gdbr, GDStash parentStash = null, bool isCharacterBag = false) { GDBlock b = new GDBlock(); gdbr.read_block_start(ref b); if (!isCharacterBag) { width = gdbr.read_int(); height = gdbr.read_int(); } else { gdbr.read_byte(); } uint numItems = gdbr.read_int(); ParentStash = parentStash; Items = new List <GDStashItem>((int)numItems); for (int i = 0; i < numItems; i++) { GDStashItem item = new GDStashItem(); item.Read(gdbr); item.ParentStashBag = this; if (!string.IsNullOrEmpty(item.SubCategory)) { string subcat = item.SubCategory.ToLower(); if (!(subcat.Contains("potion") || subcat.Contains("consumable") || subcat.Contains("questitem"))) { Items.Add(item); } } else if (string.IsNullOrEmpty(item.SubCategory)) { Items.Add(item); } } gdbr.read_block_end(ref b); }
//sloppy-ish recursion, but meh public static void ExportGroup(StreamWriter exportFile, CollectionViewGroup exportGroup, int indentLevel) { if (Settings.Default.ExportUseIndent) { for (int i = 0; i < indentLevel; i++) { exportFile.Write(" "); } } exportFile.WriteLine(string.Format(Settings.Default.ExportGroupFormat, exportGroup.Name, exportGroup.ItemCount, "\r\n")); string lastItemName = string.Empty; bool hasOnlyItems = exportGroup.Items.Where(i => i is CollectionViewGroup).Count() == 0; // LINQ Any has issues when casting to CVG so use where and count if (hasOnlyItems) { List <GDStashItem> itemList = exportGroup.Items.Cast <GDStashItem>().ToList(); ExportItems(exportFile, itemList, indentLevel); } else { foreach (object obj in exportGroup.Items) { CollectionViewGroup group = obj as CollectionViewGroup; if (group != null) { ExportGroup(exportFile, group, indentLevel + 1); } else // edge case for ungrouped items; this should never be possible { GDStashItem item = obj as GDStashItem; if (item != null && !string.IsNullOrEmpty(item.Name)) { string itemName; if (item.Tier == 1) { itemName = item.Name + " - Empowered"; } if (item.Tier == 2) { itemName = item.Name + " - Mythical"; } else { itemName = item.Name; } if ((!Settings.Default.ExportShouldIgnoreDuplicates) || (Settings.Default.ExportShouldIgnoreDuplicates && lastItemName != itemName)) { ExportSingleItem(exportFile, item, indentLevel, string.Empty); } lastItemName = itemName; } } } } if (!string.IsNullOrEmpty(Settings.Default.ExportGroupFooterFormat)) { if (Settings.Default.ExportUseIndent) { for (int i = 0; i < indentLevel; i++) { exportFile.Write(" "); } } exportFile.WriteLine(string.Format(Settings.Default.ExportGroupFooterFormat, exportGroup.Name, exportGroup.ItemCount, "\r\n")); } }