private void ListBox_OnChange(UIElement element) { if (ListBox.SelectedIndex == -1) { return; } if (LastSelected != null) { LastSelected.Deselect(); LastSelected = null; } HIT.HITVM.Get().PlaySoundEvent(Model.UISounds.Click); var item = ListBox.Items[ListBox.SelectedIndex]; var label = (UIHintListItem)item.Columns[0]; if (label.Category) { label.Expanded = !label.Expanded; RenderCategories(); } else { ShowHint(label.Hint); LastSelected = label; label.Select(); } }
public UIHintWindow() : base(UIDialogStyle.Close, true) { Caption = "Hints"; SetSize(800, 600); CloseButton.OnButtonClick += (btn) => { UIScreen.RemoveDialog(this); }; Opacity = 1f; InnerBackground = new UIImage(GetTexture((ulong)0x7A400000001)).With9Slice(13, 13, 13, 13); InnerBackground.Position = new Vector2(15, 45); InnerBackground.SetSize(240, 530); AddAt(3, InnerBackground); AllHints = FSOFacade.Hints.LoadAllHints(); var cats = AllHints.GroupBy(x => x.Category).OrderBy(x => x.FirstOrDefault(y => y.CatOrder != null)?.CatOrder ?? 0); int index = 0; foreach (var cat in cats) { var item = new UIHintListItem(true, cat.FirstOrDefault().Category, 0); item.ChildItems = new List <UIHintListItem>(); foreach (var hint in cat) { var subitem = new UIHintListItem(false, hint.Title, index++); subitem.Hint = hint; item.ChildItems.Add(subitem); } Categories.Add(item); } ListBox = new UIListBox() { Position = new Vector2(15 + 7, 45 + 6) }; ListBox.SetSize(227, 530 - 12); ListBox.RowHeight = 24; ListBox.Columns = new UIListBoxColumnCollection(); ListBox.Columns.Add(new UIListBoxColumn() { Width = 227 }); ListBox.SelectionFillColor = new Color(250, 200, 140); ListBox.OnChange += ListBox_OnChange; Add(ListBox); ResultsSlider = new UISlider(); ResultsSlider.Orientation = 1; ResultsSlider.Texture = GetTexture(0x31000000001); ResultsSlider.MinValue = 0; ResultsSlider.MaxValue = 2; ResultsSlider.X = 260; ResultsSlider.Y = 51; ResultsSlider.SetSize(0, 514f); Add(ResultsSlider); SliderUpButton = new UIButton(GetTexture(0x31200000001)); SliderUpButton.Position = new Vector2(257, 44); Add(SliderUpButton); SliderDownButton = new UIButton(GetTexture(0x31100000001)); SliderDownButton.Position = new Vector2(257, 566); Add(SliderDownButton); ResultsSlider.AttachButtons(SliderUpButton, SliderDownButton, 1f); ListBox.AttachSlider(ResultsSlider); Icon = new UIImage(); Icon.Position = new Vector2(290, 65); Icon.SetSize(0, 0); Add(Icon); Title = new UILabel(); Title.Position = Icon.Position = new Vector2(290, 40); Title.Size = new Vector2(492, 15); Title.CaptionStyle = TextStyle.DefaultTitle; Title.CaptionStyle = Title.CaptionStyle.Clone(); Title.CaptionStyle.Color = Color.White; Title.CaptionStyle.Size = 14; Title.CaptionStyle.Shadow = true; Title.Alignment = TextAlignment.Center | TextAlignment.Middle; Add(Title); RenderCategories(); }