private void PopulateSortView() { if (DefaultSorts == null) { DefaultSorts = new Sort[] { new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortItemID")) { Tooltip = HeroText("SortName.ItemID") }, (x, y) => x.type.CompareTo(y.type)), new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortValue")) { Tooltip = HeroText("SortName.Value") }, (x, y) => x.value.CompareTo(y.value)), new Sort(new UIImage(HEROsMod.instance.GetTexture("Images/sortAZ")) { Tooltip = HeroText("SortName.Alphabetical") }, (x, y) => x.Name.CompareTo(y.Name)), }; } List <Sort> sorts = DefaultSorts.ToList(); if (SelectedCategory != null) { if (SelectedCategory.ParentCategory != null) { foreach (var item in SelectedCategory.ParentCategory.Sorts) { sorts.Add(item); } } foreach (var item in SelectedCategory.Sorts) { sorts.Add(item); } } AvailableSorts = sorts.ToArray(); _sortView.RemoveAllChildren(); _sortView.X = _spacer.X + _spacer.Width; float xPos = 0; for (int i = 0; i < AvailableSorts.Length; i++) { UIImage button = AvailableSorts[i].button; button.Width = 20; int x = i / 1; int y = i % 1; button.X = Spacing + x * (button.Width + Spacing); button.Y = Spacing + y * (button.Height + Spacing); xPos = button.X + button.Width + Spacing; _sortView.AddChild(button); } _sortView.Width = xPos; }
private void PopulateSortView() { List <Sort> sorts = DefaultSorts.ToList(); if (SelectedCategory != null) { if (SelectedCategory.ParentCategory != null) { foreach (var item in SelectedCategory.ParentCategory.Sorts) { sorts.Add(item); } } foreach (var item in SelectedCategory.Sorts) { sorts.Add(item); } } AvailableSorts = sorts.ToArray(); _sortView.RemoveAllChildren(); _sortView.X = _spacer.X + _spacer.Width; float xPos = 0; for (int i = 0; i < AvailableSorts.Length; i++) { UIImage button = AvailableSorts[i].button; button.Width = 20; int x = i / 1; int y = i % 1; button.X = Spacing + x * (button.Width + Spacing); button.Y = Spacing + y * (button.Height + Spacing); xPos = button.X + button.Width + Spacing; _sortView.AddChild(button); } _sortView.Width = xPos; }