public static void RefreshItems() { if (StoragePlayer.IsStorageCrafting()) { CraftingGUI.RefreshItems(); return; } items.Clear(); didMatCheck.Clear(); TEStorageHeart heart = GetHeart(); if (heart == null) { return; } InitLangStuff(); InitSortButtons(); InitFilterButtons(); SortMode sortMode = (SortMode)sortButtons.Choice; FilterMode filterMode = (FilterMode)filterButtons.Choice; items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text)); for (int k = 0; k < items.Count; k++) { didMatCheck.Add(false); } }
void Start() { // Clear foreach (Transform child in transform) { Destroy(child.gameObject); } // Find all item resources var items = Resources.LoadAll("Items", typeof(BaseItem)); var sort = new ItemSorter(); System.Array.Sort <Object>(items, sort); int count = 0; int max = 8; foreach (var item in items) { if (count < max) { bool success = AddListing(item as BaseItem); if (success) { count++; } } } }
public override void RefreshItems(TEStorageCenter center = null) { if (Main.player[Main.myPlayer].GetModPlayer <StoragePlayer>().tileType == typeof(TCraftingStorageAccess)) { MagicStorageTwo.Instance.guiM?.CraftingGUI.RefreshItems(); } if (StoragePlayer.IsOnlyStorageCrafting()) { return; } items.Clear(); TEStorageHeart heart = center as TEStorageHeart ?? GetHeart(); if (heart == null) { return; } InitLangStuff(); InitSortButtons(); InitFilterButtons(); SortMode sortMode = (SortMode)sortButtons.Choice; FilterMode filterMode = (FilterMode)filterButtons.Choice; items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, modSearchBar.Text, nameSearchBar.Text)); }
public void RefreshItems() { items = ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text); UpdateCounter(); slotZone.UpdateScrollBar((items.Count + columns - 1) / columns); }
public static List <ItemModel> LoadItems(string skuId) { string sql = @"SELECT MarketId, CurrencyCode, UnitPrice, ValidFrom, ValidUntil FROM csv WHERE CatalogEntryCode = @skuId"; List <ItemModel> items = DataAccess.GetData <ItemModel>(sql, skuId); return(ItemSorter.SortItems(items)); }
/// <summary> /// Initialises a new instance of the <see cref="ChannelBrowser" /> class. /// </summary> /// <param name="marshal">The associated marshal.</param> public ChannelBrowser(IRCMarshal marshal) { this.InitializeComponent(); this.items = new List <ListViewItem>(); this.marshal = marshal; this.sorter = new ItemSorter(); this.channelListView.Columns[1].Tag = typeof(int); this.ChannelListView_Resize(this, EventArgs.Empty); }
public void SingleItem() { var list = new List <ISortableItem> { new Item(1, 1, 2, 2), new Item(2, 3, 2, 4), new Item(3, 3, 2, 4), new Item(4, 3, 2, 4), new Item(5, 3, 2, 4), }; IItemSorter sorter = new ItemSorter(); var sorted = sorter.SortInventory(list, 10); PrintInventory(sorted); }
private void RefreshRecipes() { Recipe[] temp = ItemSorter.SortAndFilter(Main.recipe, sortMode, filterMode, modFilter, nameFilter); if (recipeButtons.choice == 0) { recipes = temp.AsParallel().AsOrdered().Where(recipe => IsAvailable(recipe)).ToList(); recipeAvailable = temp.Select(recipe => true).ToList(); } else { recipes = temp.ToList(); recipeAvailable = temp.AsParallel().AsOrdered().Select(recipe => IsAvailable(recipe)).ToList(); } recipeZone.UpdateScrollBar((recipes.Count + columns - 1) / columns); }
public static int ItemCount(int itemType) { int count = 0; List <Item> countList = new List <Item>(); TEStorageHeart heart = GetHeart(); if (heart == null) { return(-1); } countList.Clear(); countList.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), SortMode.Default, FilterMode.All, SubFilterMode.All, "", "")); foreach (Item sItem in countList) { if (sItem.type == itemType) { count += sItem.stack; } } return(count); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update100; //Runtime.CurrentInstructionCount; //Runtime.MaxInstructionCount; itemManager = new ItemManager(GridTerminalSystem); oreSorter = new ItemSorter <IMyTerminalBlock, IMyCargoContainer>( itemManager, src => !(src is IMyAssembler) && !(src is IMyGasGenerator) && !(src is IMyRefinery) && !(src is IMyReactor), Utils.isMetal, "Metal Containers", true ); componentSorter = new ItemSorter <IMyTerminalBlock, IMyCargoContainer>( itemManager, src => src.CubeGrid == Me.CubeGrid && !(src is IMyAssembler), Utils.isComponent, "Component Containers", true ); }
private void RefreshItems() { itemCounts.Clear(); foreach (int key in RecipeGroup.recipeGroups.Keys) { recipeGroupCounts[key] = 0; } items = ItemSorter.SortAndFilter(heart.GetStoredItems(), SortMode.Id, FilterMode.All, "", ""); foreach (Item item in items) { if (!item.material) { continue; } if (itemCounts.ContainsKey(item.netID)) { itemCounts[item.netID] += item.stack; } else { itemCounts[item.netID] = item.stack; } foreach (KeyValuePair <int, RecipeGroup> pair in RecipeGroup.recipeGroups) { if (pair.Value.ContainsItem(item.type)) { recipeGroupCounts[pair.Key] += item.stack; } } } }
public static void RefreshItems() { if (StoragePlayer.IsStorageCrafting()) { CraftingGUI.RefreshItems(); return; } items.Clear(); didMatCheck.Clear(); TEStorageHeart heart = GetHeart(); if (heart == null) { return; } InitLangStuff(); InitSortButtons(); InitFilterButtons(); InitSubFilterButtons(); SortMode sortMode; switch (sortButtons.Choice) { case 0: sortMode = SortMode.Default; break; case 1: sortMode = SortMode.Id; break; case 2: sortMode = SortMode.Name; break; case 3: sortMode = SortMode.Quantity; break; default: sortMode = SortMode.Default; break; } switch (filterButtons.Choice) { case 0: filterMode = FilterMode.All; break; case 1: filterMode = FilterMode.Weapons; break; case 2: filterMode = FilterMode.Tools; break; case 3: filterMode = FilterMode.Equipment; break; case 4: filterMode = FilterMode.Potions; break; case 5: filterMode = FilterMode.Placeables; break; case 6: filterMode = FilterMode.Misc; break; default: filterMode = FilterMode.All; break; } if (filterMode != oldFilterMode) { UpdateSubFilterButtons(); oldFilterMode = filterMode; } SubFilterMode subFilterMode; subFilterMode = (SubFilterMode)subFilterButtons.Choice; items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, subFilterMode, searchBar2.Text, searchBar.Text)); numItemsShown = items.Count; for (int k = 0; k < items.Count; k++) { didMatCheck.Add(false); } }
public static void RefreshItems() { items.Clear(); TEStorageHeart heart = GetHeart(); if (heart == null) { return; } InitSortButtons(); InitFilterButtons(); SortMode sortMode; switch (sortButtons.Choice) { case 0: sortMode = SortMode.Default; break; case 1: sortMode = SortMode.Id; break; case 2: sortMode = SortMode.Name; break; case 3: sortMode = SortMode.Quantity; break; default: sortMode = SortMode.Default; break; } FilterMode filterMode; switch (filterButtons.Choice) { case 0: filterMode = FilterMode.All; break; case 1: filterMode = FilterMode.Weapons; break; case 2: filterMode = FilterMode.Tools; break; case 3: filterMode = FilterMode.Equipment; break; case 4: filterMode = FilterMode.Potions; break; case 5: filterMode = FilterMode.Placeables; break; case 6: filterMode = FilterMode.Misc; break; default: filterMode = FilterMode.All; break; } items.AddRange(ItemSorter.SortAndFilter(heart.GetStoredItems(), sortMode, filterMode, searchBar2.Text, searchBar.Text)); }
internal protected virtual bool ResolveItemsTo(FtMetaSequence sequence, FtMetaFieldList fieldList, FtMetaSequenceList sequenceList, out string errorDescription) { ItemSorter.Rec[] sorterRecArray = new ItemSorter.Rec[itemList.Count + fieldIndices.Length]; SequenceItemReadElement[] sortedItemElements; for (int i = 0; i < itemList.Count; i++) { SequenceItemReadElement itemElement = itemList[i]; sorterRecArray[i].Target = itemElement; sorterRecArray[i].Implicit = i; sorterRecArray[i].Explicit = itemElement.ExplicitIndex; } int elementallyDefinedItemCount = itemList.Count; for (int i = 0; i < fieldIndices.Length; i++) { SequenceItemReadElement itemElement = new SequenceItemReadElement(); // Add FieldIndex to element as if it were read from an attribute. int fieldIndex = fieldIndices[i]; string attributeName = SequenceItemPropertyIdFormatter.ToAttributeName(FtMetaSequenceItem.PropertyId.FieldIndex); string attributeValue = FtStandardText.Get(fieldIndex); if (!itemElement.TryAddOrIgnoreAttribute(attributeName, attributeValue, out errorDescription)) { throw FtInternalException.Create(InternalError.SequenceReadElement_ResolveItemsTo_TryAddOrIgnoreAttribute, errorDescription); // program error } else { int implicitIndex = elementallyDefinedItemCount + i; sorterRecArray[implicitIndex].Target = itemElement; sorterRecArray[implicitIndex].Implicit = implicitIndex; sorterRecArray[implicitIndex].Explicit = -1; } } int duplicateExplicitIndex; if (!ItemSorter.TrySort(sorterRecArray, out sortedItemElements, out duplicateExplicitIndex)) { errorDescription = string.Format(Properties.Resources.SequenceReadElement_ResolveItemsTo_DuplicateExplicitIndex, duplicateExplicitIndex); return(false); } else { errorDescription = ""; bool result = true; for (int i = 0; i < sortedItemElements.Length; i++) { SequenceItemReadElement itemElement = sortedItemElements[i]; FtMetaSequenceItem item = sequence.ItemList.New(); if (!itemElement.ResolveTo(item, fieldList, sequenceList, out errorDescription)) { result = false; break; } } return(result); } }
private void DeployObjects() { var itemSorter = new ItemSorter(); int k = 0; foreach (TileData tile in from i in Data.Maps.SelectMany(x => x.Tiles) where i.HasItemsList select i) { tile.FirstObject = Data.ObjectIDs[k++]; foreach (var item in tile.GetItems(Data)) itemSorter.CreateItem(item, tile); //last actuator is active one thus revers => first actuator is active one now tile.Actuators.Reverse(); } }
private bool SortByCommands(CommandIterator[] commands) { if (commands == null || commands.Length == 0) { return(false); } CommandIterator.IteratorType type = commands[0].Type; //sorting may only be performed on rows or columsn. 'Unknown' is not allowed. if (type == CommandIterator.IteratorType.Unknown) { return(false); } //sorting may only be performed on items of a consistent type (rows or columns) if (!Array.TrueForAll(commands, c => c.Type == type)) { return(false); } //collect all of the possible values in command order List <string>[] commandValueKeys = new List <string> [commands.Length]; CommandIterator[] emptySet = new CommandIterator[0]; for (int i = 0; i < commands.Length; i++) { //we can't compare a separator if (commands[i].Selection == CommandIterator.SelectionType.Separator) { commandValueKeys[i] = null; } else { bool hasDefaultMember; Dictionary <string, object> tmp = this.GetSelectionMembers(emptySet, commands[i], out hasDefaultMember); List <string> sortedKeys = new List <string>(tmp.Keys); commandValueKeys[i] = sortedKeys; } } ItemSorter sorter = (left, right) => { for (int i = 0; i < commands.Length; i++) { //we can't compare a separator if (commands[i].Selection == CommandIterator.SelectionType.Separator) { continue; } List <string> valueKeys = commandValueKeys[i]; int leftIdx = 0; int rightIdx = 0; switch (commands[i].Selection) { case CommandIterator.SelectionType.Axis: string leftSegment = ((Segment)left.EmbedRequirements.GetMemberKeyValue(commands[i]).Value).DimensionInfo.Id; string rightSegment = ((Segment)right.EmbedRequirements.GetMemberKeyValue(commands[i]).Value).DimensionInfo.Id; leftIdx = valueKeys.IndexOf(leftSegment); rightIdx = valueKeys.IndexOf(rightSegment); break; case CommandIterator.SelectionType.Element: leftIdx = valueKeys.IndexOf(left.EmbedRequirements.ElementKey); rightIdx = valueKeys.IndexOf(right.EmbedRequirements.ElementKey); break; case CommandIterator.SelectionType.Period: leftIdx = valueKeys.IndexOf(left.EmbedRequirements.PeriodLabel); rightIdx = valueKeys.IndexOf(right.EmbedRequirements.PeriodLabel); break; case CommandIterator.SelectionType.Unit: leftIdx = valueKeys.IndexOf(left.EmbedRequirements.UnitCode); rightIdx = valueKeys.IndexOf(right.EmbedRequirements.UnitCode); break; } if (leftIdx < rightIdx) { return(-1); } if (leftIdx > rightIdx) { return(1); } } return(0); }; if (type == CommandIterator.IteratorType.Column) { this.InstanceReport.Columns.Sort((left, right) => sorter(left, right)); } else { this.InstanceReport.Rows.Sort((left, right) => sorter(left, right)); } return(true); }