예제 #1
0
        public static void initMainMenu()
        {
            current_item = "Bolingbroke"; // The current item of the list of police stations is updated to Bolingbroke, this fixes a bug where upon first loading the plugin, a user
                                          // Would have to switch to a different location before being able to teleport back to Bolingbroke.

            GoMenu      = new UIMenu("GoThere", "~b~LET'S MOVE!");
            StationList = new UIMenuListItem("~g~List of Stations: ", "", "Bolingbroke", "Davis", "Downtown Vinewood", "La Mesa", "LSIA", "Mission Row",
                                             "Paleto Bay", "Rockford Hills", "Sandy Shores", "Vespucci", "Vinewood Hills");


            menu_pool = new MenuPool();

            MenuProcessFiber = new GameFiber(ProcessLoop);


            menu_pool.Add(GoMenu);       // Add our menu to the menu pool
            GoMenu.AddItem(StationList); // Add a list of destinations -- maybe we want to hold destination OBJECTS. We shall see.
            GoMenu.OnItemSelect += OnItemSelect;
            GoMenu.OnListChange += OnListChange;

            if (customLocationsEnabled) // If custom locations are enabled
            {
                navigateToLocMenu = new UIMenuItem("Custom Locations");
                LocMenu           = new UIMenu("Custom Locations", "Teleport to custom locations.");                             // Initialize the locations menu
                menu_pool.Add(LocMenu);                                                                                          // Add the locations menu to the menu pool

                GoMenu.AddItem(navigateToLocMenu);                                                                               // Add the ui item to the main menu
                GoMenu.BindMenuToItem(LocMenu, navigateToLocMenu);                                                               // Bind the locations menu to the ui item
                LocMenu.ParentMenu = GoMenu;                                                                                     // Set the parent menu of the locations menu to be the main menu
                InstructionalButton removeButtonKeyButton = new InstructionalButton(removeKey.ToString(), "Remove Destination"); // Add instructional button showing users how to remove a dest.
                LocMenu.AddInstructionalButton(removeButtonKeyButton);
                RefreshCustomLocationsMenu();
            }
            GoMenu.RefreshIndex();                                                                               // Set the index at 0 by using the RefreshIndex method

            MenuProcessFiber.Start();                                                                            // Start process fiber

            Game.DisplayNotification("~r~[GoThere] \nGoThere v1.0 ~w~by ~b~Cavasi ~w~has loaded successfully!"); // Display a notification above the radar that the plugin loaded successfully

            GameFiber.Hibernate();                                                                               // Continue with our plugin. Prevent it from being unloaded
        }
예제 #2
0
파일: Main.cs 프로젝트: waffle-iron/bepmod
        public Main()
        {
            _menu = new UIMenu("BepMod", "~b~Bicycle Experiment Program");

            _menu.AddItem(new UIMenuItem("Spawn bicycle", "You know you want it!"));
            _menu.AddItem(new UIMenuItem("Load scenario", "Example scenario"));
            _menu.AddItem(new UIMenuCheckboxItem("Remove traffic", false, "All except for your bike"));
            _menu.AddItem(new UIMenuCheckboxItem("Hide radar and HUD", false, "For the full immersive experience"));
            _menu.RefreshIndex();

            _menu.OnItemSelect     += _menu_OnItemSelect;
            _menu.OnCheckboxChange += _menu_OnCheckboxChange;

            _menuPool.Add(_menu);

            UI.Notify("For the Bicycle Experiment Program press ~b~B");

            _button = new InstructionalButton("B", "Bicycle Experiment Program");
            _menu.AddInstructionalButton(_button);

            KeyDown += Main_KeyDown;
            Tick    += Main_Tick;
        }
예제 #3
0
파일: UIMenu.cs 프로젝트: Guad/RAGENativeUI
 public void RemoveInstructionalButton(InstructionalButton button)
 {
     _instructionalButtons.Remove(button);
 }
예제 #4
0
파일: UIMenu.cs 프로젝트: Guad/RAGENativeUI
 public void AddInstructionalButton(InstructionalButton button)
 {
     _instructionalButtons.Add(button);
 }
예제 #5
0
            public ButtonMenu(InstructionalButton button) : base(Plugin.MenuTitle, "INSTRUCTIONAL BUTTONS: " + button.Text.ToUpper())
            {
                Plugin.Pool.Add(this);

                this.button = button;

                var text = new UIMenuItem("Text", "")
                {
                    Enabled = true
                }
                .WithTextEditing(() => buttonText,
                                 s =>
                {
                    buttonText         = s;
                    this.button.Button = s;
                    InstructionalButtons.Update();
                });

                var control = new UIMenuListScrollerItem <GameControl>("Control", "", (GameControl[])System.Enum.GetValues(typeof(GameControl)))
                {
                    Enabled      = false,
                    SelectedItem = buttonControl
                };

                control.IndexChanged += (s, o, n) =>
                {
                    buttonControl      = control.SelectedItem;
                    this.button.Button = control.SelectedItem;
                    InstructionalButtons.Update();
                };

                var rawId = new UIMenuNumericScrollerItem <uint>("Raw ID", "", 0, 2048, 1)
                {
                    Enabled = false,
                    Value   = buttonRawId
                }.WithTextEditing();

                rawId.IndexChanged += (s, o, n) =>
                {
                    buttonRawId        = rawId.Value;
                    this.button.Button = rawId.Value;
                    InstructionalButtons.Update();
                };

                var instructionalKey = new UIMenuListScrollerItem <InstructionalKey>("Instructional Key", "", ((InstructionalKey[])System.Enum.GetValues(typeof(InstructionalKey))).Distinct())
                {
                    Enabled      = false,
                    SelectedItem = buttonInstructionalKey
                };

                instructionalKey.IndexChanged += (s, o, n) =>
                {
                    buttonInstructionalKey = instructionalKey.SelectedItem;
                    this.button.Button     = instructionalKey.SelectedItem;
                    InstructionalButtons.Update();
                };

                var type = new UIMenuListScrollerItem <string>("Type", "", new[] { "Text", "Control", "Raw ID", "Instructional Key" });

                type.IndexChanged += (s, o, n) =>
                {
                    const int TextIdx = 0, ControlIdx = 1, RawIdIdx = 2, InstructionalKeyIdx = 3;

                    text.Enabled             = n == TextIdx;
                    control.Enabled          = n == ControlIdx;
                    rawId.Enabled            = n == RawIdIdx;
                    instructionalKey.Enabled = n == InstructionalKeyIdx;

                    this.button.Button = n switch
                    {
                        TextIdx => buttonText,
                        ControlIdx => buttonControl,
                        RawIdIdx => buttonRawId,
                        InstructionalKeyIdx => buttonInstructionalKey,
                        _ => buttonText
                    };
                    InstructionalButtons.Update();
                };

                var remove = new UIMenuItem("Remove");

                remove.Activated += (m, s) =>
                {
                    UIMenu     parentMenu = ParentMenu;
                    UIMenuItem parentItem = ParentItem;

                    Close();

                    parentMenu.ReleaseMenuFromItem(parentItem);
                    parentMenu.RemoveItemAt(parentMenu.MenuItems.IndexOf(parentItem));

                    Plugin.Pool.Remove(this);

                    parentMenu.InstructionalButtons.Buttons.Remove(button);
                    parentMenu.InstructionalButtons.Update();
                    foreach (UIMenu child in parentMenu.Children.Values)
                    {
                        child.InstructionalButtons.Buttons.Remove(this.button);
                        child.InstructionalButtons.Update();
                    }
                };

                AddItems(type, text, control, rawId, instructionalKey, remove);
            }
        }
예제 #6
0
        private void CreateMenuItems()
        {
            var bg = Util.NewColorsItem("Background", $"Modifies the ~b~{nameof(RAGENativeUI.Elements.InstructionalButtons)}.{nameof(RAGENativeUI.Elements.InstructionalButtons.BackgroundColor)}~s~ property.");

            bg.SelectedItem = HudColor.PanelLight;
            InstructionalButtons.BackgroundColor = HudColor.PanelLight.GetColor();
            bg.IndexChanged += (s, o, n) =>
            {
                Color c = bg.SelectedItem.GetColor();
                InstructionalButtons.BackgroundColor = c;
                InstructionalButtons.Update();
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.BackgroundColor = c;
                    child.InstructionalButtons.Update();
                }
            };

            var maxWidth = new UIMenuNumericScrollerItem <float>("Max Width", $"Modifies the ~b~{nameof(RAGENativeUI.Elements.InstructionalButtons)}.{nameof(RAGENativeUI.Elements.InstructionalButtons.MaxWidth)}~s~ property.",
                                                                 0.0f, 1.0f, 0.01f)
            {
                Formatter = v => v.ToString("0.00"),
            }.WithTextEditing();

            maxWidth.Value         = InstructionalButtons.MaxWidth;
            maxWidth.IndexChanged += (s, o, n) =>
            {
                float v = maxWidth.Value;
                InstructionalButtons.MaxWidth = v;
                InstructionalButtons.Update();
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.MaxWidth = v;
                    child.InstructionalButtons.Update();
                }
            };

            var addButton = new UIMenuItem("Add Button");

            addButton.Activated += (m, s) =>
            {
                var button     = new InstructionalButton("A", "Slot #" + slotId++);
                var buttonMenu = new ButtonMenu(button);
                buttonMenu.InstructionalButtons.BackgroundColor = bg.SelectedItem.GetColor();
                buttonMenu.InstructionalButtons.MaxWidth        = maxWidth.Value;
                buttonMenu.InstructionalButtons.Buttons.Clear();
                buttonMenu.InstructionalButtons.Buttons.AddRange(InstructionalButtons.Buttons);

                var bindItem = new UIMenuItem(button.Text);
                AddItem(bindItem);
                BindMenuToItem(buttonMenu, bindItem);

                InstructionalButtons.Buttons.Add(button);
                foreach (UIMenu child in Children.Values)
                {
                    child.InstructionalButtons.Buttons.Add(button);
                }
            };

            AddItems(bg, maxWidth, addButton);
            this.WithFastScrollingOn(maxWidth);
        }