示例#1
0
        private static async Task OnTick()
        {
            try
            {
                if (Observer.CurrentMenu == InteractionMenu)
                {
                    (WalkingStyleItem as MenuItemHorNamedSelector).state = walkingStyleIndex;
                    (WalkingStyleItem as MenuItemHorNamedSelector).overrideDetailWith = walkingStyles[walkingStyleIndex].Replace("move_m@", "").Replace("move_f@", "").Replace("@", " ").Replace("_", " ").ToTitleCase();

                    ItemsFiltered = ItemsAll.Where(m => m.Item3.Invoke()).OrderBy(m => m.Item2.Title).OrderByDescending(m => m.Item1).Select(m => m.Item2).ToList();
                    if (!ItemsFiltered.SequenceEqual(InteractionMenu.menuItems) || IsDirty)
                    {
                        if (ItemsFiltered.Contains(InteractionMenu.SelectedItem))
                        {
                            int newSelectedIndex = ItemsFiltered.IndexOf(InteractionMenu.SelectedItem);
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = newSelectedIndex;
                        }
                        else if (InteractionMenu.SelectedIndex.IsBetween(0, ItemsFiltered.Count - 1))
                        {
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = InteractionMenu.SelectedIndex; // Simply refreshes selection
                        }
                        else
                        {
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = 0;
                        }

                        IsDirty = false;
                    }
                }

                Observer.Tick();

                if (ControlHelper.IsControlJustPressed(Control.InteractionMenu))
                {
                    if (Observer.CurrentMenu == null)
                    {
                        Observer.OpenMenu(InteractionMenu);
                    }
                    else
                    {
                        Observer.CloseMenu(true);
                    }
                    MenuController.PlaySound("NAV_UP_DOWN");
                }
            }
            catch (Exception ex)
            {
                Log.Error($"[INTERACTIONLISTMENU] Exception in OnTick; {ex.Message}");
            }

            await Task.FromResult(0);
        }
示例#2
0
        private async Task OnTick()
        {
            try
            {
                if (Observer.CurrentMenu == InteractionMenu)
                {
                    (WalkingStyleItem as MenuItemHorNamedSelector).State = walkingStyleIndex;
                    (WalkingStyleItem as MenuItemHorNamedSelector).overrideDetailWith = walkingStyles[walkingStyleIndex].Replace("move_m@", "").Replace("move_f@", "").Replace("@", " ").Replace("_", " ").ToTitleCase();

                    ItemsFiltered = ItemsAll.Where(m => m.Item3.Invoke()).OrderBy(m => m.Item2.Title).OrderByDescending(m => m.Item1).Select(m => m.Item2).ToList();
                    if (!ItemsFiltered.SequenceEqual(InteractionMenu.menuItems) || IsDirty)
                    {
                        if (ItemsFiltered.Contains(InteractionMenu.SelectedItem))
                        {
                            int newSelectedIndex = ItemsFiltered.IndexOf(InteractionMenu.SelectedItem);
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = newSelectedIndex;
                        }
                        else if (InteractionMenu.SelectedIndex.IsBetween(0, ItemsFiltered.Count - 1))
                        {
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = InteractionMenu.SelectedIndex; // Simply refreshes selection
                        }
                        else
                        {
                            InteractionMenu.menuItems     = ItemsFiltered;
                            InteractionMenu.SelectedIndex = 0;
                        }

                        IsDirty = false;
                    }
                }

                Observer.Tick();
                toggleMenuState();
            }
            catch (Exception ex)
            {
                Magicallity.Shared.Log.Error(ex);
            }

            //await Task.FromResult(0);
        }