static bool PopulateItem(ItemDataXML data) { if (data.IsValid && data.IsEnabled && !data.HasItemProxy && data.MinCSPrice > 0 && data.ItemID != Item.MobSpawn) { return(true); } return(false); }
static void PopulateItems(string name) { var shopMenuTraverse = Traverse.Create(shopMenuInstance); var invTabPaneTraverse = shopMenuTraverse.Field("tabsPane"); var mainWin = invTabPaneTraverse.Field("mainWin").GetValue <Window>(); var itemsTab = mainWin.FindChild("itemsTab"); var blocksTab = mainWin.FindChild("blocksTab"); var tabHighLight = invTabPaneTraverse.Field("tabHighLight").GetValue <Window>(); var invPaneTraverse = invTabPaneTraverse.Field("invPane"); var inv = invTabPaneTraverse.Field("inventory").GetValue <ITMInventory>(); var slotID = invTabPaneTraverse.Field("slotID"); slotID.SetValue(0); invTabPaneTraverse.Field("currentPage").SetValue(0); invTabPaneTraverse.Field("pageCountWin").Property("Text").SetValue("1"); invTabPaneTraverse.Field("morePages").SetValue(false); invTabPaneTraverse.Field("pageCountContainerWin").GetValue <Window>().IsVisible = false; inv.Clear(); ItemInvType invType; int startIndex; if ((tabHighLight.Parent as Window).Name == "itemsTab") { startIndex = Globals1.BlockData.Length; invType = (ItemInvType)((byte)(invTabPaneTraverse.Field("itemsTabID").GetValue <int>() + 8)); } else { startIndex = 0; invType = (ItemInvType)((byte)(invTabPaneTraverse.Field("blocksTabID").GetValue <int>() + 1)); } for (int i = startIndex; i < (int)Globals1.ItemData.Length && slotID.GetValue <int>() < inv.PackSize; i++) { ItemDataXML itemData = Globals1.ItemData[i]; if (PopulateItem(itemData) && Globals1.ItemTypeData[i].Inv == invType) { if (data.SearchText == "" || itemData.Name.ToLowerInvariant().Contains(data.SearchText.ToLowerInvariant()) || itemData.Name.ToLowerInvariant() == data.SearchText.ToLowerInvariant()) { InventoryItem inventoryItem = new InventoryItem(itemData.ItemID, 1); slotID.SetValue(slotID.GetValue <int>() + 1); inv.Items.Add(inventoryItem); } } } invPaneTraverse.Method("RefreshInventoryWindowItems").GetValue(); }