private void UpdateList() { _txtTitle.Text(Utils.Format(TxtTitle, ShowPotions ? TxtPotions : TxtScrolls)); _txtTitle.Measure(); _txtTitle.X = PixelScene.Align(PixelScene.uiCamera, (WIDTH - _txtTitle.Width) / 2); _items.Clear(); var content = _list.Content(); content.Clear(); _list.ScrollTo(0, 0); float pos = 0; HashSet <Type> known; if (ShowPotions) { known = Potion.GetKnown; } else { known = Scroll.GetKnown; } foreach (var itemClass in known) { var item = new ListItem(itemClass); item.SetRect(0, pos, WIDTH, ItemHeight); content.Add(item); _items.Add(item); pos += item.Height; } HashSet <Type> unknown; if (ShowPotions) { unknown = Potion.GetUnknown; } else { unknown = Scroll.GetUnknown; } foreach (var itemClass in unknown) { var item = new ListItem(itemClass); item.SetRect(0, pos, WIDTH, ItemHeight); content.Add(item); _items.Add(item); pos += item.Height; } content.SetSize(WIDTH, pos); }
/// <summary> /// Scrolls the widget to the specified position /// </summary> /// <param name="direction"> "x" or "y" for horizontal/vertical scrolling </param> /// <param name="position"> Position (in pixels) to scroll to </param> public void ScrollTo(string direction, int?position) { ScrollPane scrollPane = ScrollPane; scrollPane.ScrollTo(direction, position); }