Пример #1
0
        public NativeMenu AddSubMenu(string menuTitle, string menuDescription, string itemText, string itemDescription, NativeMenu parent)
        {
            var item = new NativeMenuItemBase(itemText, itemDescription);
            var menu = new NativeMenu(menuTitle, menuDescription, parent.BannerType)
            {
                AcceleratedScrolling = parent.AcceleratedScrolling,
                DescriptionColor     = parent.DescriptionColor,
                AllowClickOut        = parent.AllowClickOut,
                MaxDrawableItems     = parent.MaxDrawableItems,
                MenuWidth            = parent.MenuWidth,
                NavigationMode       = parent.NavigationMode,
                OffsetX  = parent.OffsetX,
                OffsetY  = parent.OffsetY,
                SoundSet = parent.SoundSet
            };

            menu.MenuBack += (nativeMenu, eventArgs) =>
            {
                parent.SupressAudioNextCall();
                parent.Visible = true;
            };

            parent.MenuItems.Add(item);
            item.Selected += (sender, args) =>
            {
                parent.SupressAudioNextCall();
                parent.Visible = false;
                menu.Visible   = true;
            };
            AddMenu(menu);
            return(menu);
        }
Пример #2
0
 public void AddMenu(NativeMenu menu)
 {
     if (_menus.Contains(menu))
     {
         return;
     }
     _menus.Add(menu);
 }
Пример #3
0
 public void RemoveMenu(NativeMenu menu)
 {
     if (!_menus.Contains(menu))
     {
         return;
     }
     _menus.Remove(menu);
 }
Пример #4
0
        public void Draw(PointF position, SizeF size, bool selected, bool hover, bool hover2, ref bool overridenCursor)
        {
            if (selected)
            {
                foreach (var button in CustomButtons)
                {
                    Game.DisableControlThisFrame(2, button.Key);
                    if (Game.IsDisabledControlJustPressed(2, button.Key))
                    {
                        OnButtonDown(this, new NativeMenuItemButtonEventArgs(this, button.Key));
                    }
                    else if (Game.IsDisabledControlJustReleased(2, button.Key))
                    {
                        OnButtonUp(this, new NativeMenuItemButtonEventArgs(this, button.Key));
                    }
                    else if (Game.IsDisabledControlPressed(2, button.Key))
                    {
                        OnButtonHeld(this, new NativeMenuItemButtonEventArgs(this, button.Key));
                    }
                }
            }

            var pos = new PointF(position.X + NativeMenu.DescriptionXOffset,
                                 position.Y + NativeMenu.DescriptionYOffset);

            if (selected || hover)
            {
                NativeFunctions.DrawSprite("commonmenu", "gradient_nav",
                                           new PointF(size.Width / 2 + position.X, size.Height / 2 + position.Y), size, 0,
                                           selected ? Color.White : NativeMenu.HighlightColor());

                if (selected && hover2 && InteractionCursor != CursorSprite.None)
                {
                    Function.Call(Hash._0x8DB8CFFD58B62552, (int)InteractionCursor);  // SET_CURSOR_SPRITE
                    overridenCursor = true;
                }
            }

            var offset = DrawShopIcon(pos, selected, ShopIcon, new SizeF(50, 50));

            NativeFunctions.DrawText(Text, pos + new SizeF(offset, 0f), NativeMenu.DescriptionTextScale,
                                     Enabled ? selected ? Color.FromArgb(255, 45, 45, 45) : Color.White : Color.Gray, 1, Font.ChaletLondon,
                                     false, false);
            DrawValue(position + size, selected);
        }
Пример #5
0
        public override void OnNavLeftRight(NativeMenu sender, int menuItemIndex, int leftRight)
        {
            var value = (object[])Value;

            if (value == null)
            {
                return;
            }

            CurrentIndex += leftRight;

            if (CurrentIndex < 0)
            {
                CurrentIndex = value.Length - 1;
            }
            else if (CurrentIndex >= value.Length)
            {
                CurrentIndex = 0;
            }

            CurrentValue = value[CurrentIndex].ToString();

            OnChangedIndex(sender, new NativeMenuItemNavigateIndexEventArgs(this, menuItemIndex, CurrentIndex));
        }
 public override void OnNavLeftRight(NativeMenu sender, int menuItemIndex, int leftRight)
 {
     ChangedIndex?.Invoke(sender, new NativeMenuItemUnmanagedNavigateIndexEventArgs(this, menuItemIndex, leftRight));
 }
Пример #7
0
 public virtual void OnNavLeftRight(NativeMenu sender, int menuItemIndex, int leftRight)
 {
 }
Пример #8
0
 public virtual void OnSelected(NativeMenu sender, NativeMenuItemEventArgs e)
 {
     Selected?.Invoke(sender, e);
 }
Пример #9
0
 protected virtual void OnChangedIndex(NativeMenu sender, NativeMenuItemNavigateIndexEventArgs e)
 {
     ChangedIndex?.Invoke(sender, e);
 }
Пример #10
0
 protected virtual void OnCheck(NativeMenu sender, NativeMenuItemCheckboxEventArgs e)
 {
     Check?.Invoke(sender, e);
 }
Пример #11
0
 public override void OnSelected(NativeMenu sender, NativeMenuItemEventArgs e)
 {
     Checked = !Checked;
     OnCheck(sender, new NativeMenuItemCheckboxEventArgs(this, e.MenuItemIndex, Checked));
 }