Esempio n. 1
0
    public void AddMenuCook(UIMenu menu)
    {
        var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.");

        newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
        newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
        menu.AddItem(newitem);
        menu.OnItemSelect += (sender, item, index) =>
        {
            if (item == newitem)
            {
                string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
                Screen.ShowSubtitle(String.Format(output, dish));
            }
        };

        menu.OnIndexChange += (sender, index) =>
        {
            if (sender.MenuItems[index] == newitem)
            {
                newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None);
            }
        };

        var colorItem = new UIMenuItem("UIMenuItem with Colors", "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242));

        menu.AddItem(colorItem);

        var foods = new List <dynamic>
        {
            "Banana",
            "Apple",
            "Pizza",
            "Quartilicious",
            0xF00D,             // Dynamic!
        };

        var BlankItem = new UIMenuSeparatorItem();

        menu.AddItem(BlankItem);

        var colorListItem = new UIMenuListItem("Colored ListItem.. Really?", foods, 0, "~b~Look!!~r~I can be colored ~y~too!!~w~", Color.FromArgb(150, 185, 230, 185), Color.FromArgb(170, 174, 219, 242));

        menu.AddItem(colorListItem);


        var SliderProgress = new UIMenuSliderProgressItem("Slider Progress Item", 10, 0);

        menu.AddItem(SliderProgress);

        var Progress = new UIMenuProgressItem("Progress Item", "descriptiom", 10, 0, true);

        menu.AddItem(Progress);

        var listPanelItem1 = new UIMenuListItem("Change Color", new List <object> {
            "Example", "example2"
        }, 0);
        var ColorPanel = new UIMenuColorPanel("Color Panel Example", UIMenuColorPanel.ColorPanelType.Hair);

        // you can choose between hair palette or makeup palette
        menu.AddItem(listPanelItem1);
        listPanelItem1.AddPanel(ColorPanel);

        var listPanelItem2 = new UIMenuListItem("Change Percentage", new List <object> {
            "Example", "example2"
        }, 0);
        var PercentagePanel = new UIMenuPercentagePanel("Percentage Panel Example", "0%", "100%");

        // You can change every text in this Panel
        menu.AddItem(listPanelItem2);
        listPanelItem2.AddPanel(PercentagePanel);

        var listPanelItem3 = new UIMenuListItem("Change Grid Position", new List <object> {
            "Example", "example2"
        }, 0);
        var GridPanel = new UIMenuGridPanel("Up", "Left", "Right", "Down", new System.Drawing.PointF(.5f, .5f));

        // you can choose the text in every position and where to place the starting position of the cirlce
        // the other 2 grids panel available are not listed as they work the same way but in only 2 direction (horizontally or vertically)
        // and to use them you must stream the stream folder provided with NativeUI project
        menu.AddItem(listPanelItem3);
        listPanelItem3.AddPanel(GridPanel);

        var listPanelItem4 = new UIMenuListItem("Look at Statistics", new List <object> {
            "Example", "example2"
        }, 0);
        var statistics = new UIMenuStatisticsPanel();

        statistics.AddStatistics("Look at this!");
        statistics.AddStatistics("I'm a statistic too!");
        statistics.AddStatistics("Am i not?!");
        //you can add as menu statistics you want
        statistics.SetPercentage(0, 10f);
        statistics.SetPercentage(1, 50f);
        statistics.SetPercentage(2, 100f);
        //and you can get / set their percentage
        menu.AddItem(listPanelItem4);
        listPanelItem4.AddPanel(statistics);

        // THERE ARE NO EVENTS FOR PANELS.. WHEN YOU CHANGE WHAT IS CHANGABLE THE LISTITEM WILL DO WHATEVER YOU TELL HIM TO DO

        menu.OnListChange += (sender, item, index) =>
        {
            if (item == listPanelItem1)
            {
                Screen.ShowNotification("Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...");
                item.Description = "Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...";
                item.Parent.UpdateDescription();                 // this is neat.. this will update the description of the item without refresh index.. try it by changing color
            }
            else if (item == listPanelItem2)
            {
                Screen.ShowSubtitle("Percentage = " + (item.Panels[0] as UIMenuPercentagePanel).Percentage + "...");
            }
            else if (item == listPanelItem3)
            {
                Screen.ShowSubtitle("GridPosition = " + (item.Panels[0] as UIMenuGridPanel).CirclePosition + "...");
            }
        };
    }
Esempio n. 2
0
        private static void TapeMenu(UIMenu menu)
        {
            var newTape = menuPool.AddSubMenu(menu, "Create new tape");

            newTape.MouseControlsEnabled    = false;
            newTape.ControlDisablingEnabled = false;
            var length = new UIMenuSliderProgressItem("Tape Length", 35, 10);

            newTape.AddItem(length);

            var policeTape = new UIMenuItem(Main.tape1Name, $"Place {Main.tape1Name} tape down");

            newTape.AddItem(policeTape);

            var innerCordonTape = new UIMenuItem(Main.tape2Name, $"Place {Main.tape2Name} tape down");

            newTape.AddItem(innerCordonTape);

            var fireTape = new UIMenuItem(Main.tape3Name, $"Place {Main.tape3Name} tape down");

            newTape.AddItem(fireTape);

            var manageTapes = menuPool.AddSubMenu(menu, "Manage tapes");

            var moveTape = new UIMenuItem("Move Tape", "Move a nearby tape");

            manageTapes.AddItem(moveTape);

            var deleteTape = new UIMenuItem("Delete Tape", "Delete a nearby tape");

            manageTapes.AddItem(deleteTape);

            manageTapes.MouseControlsEnabled = false;

            manageTapes.OnItemSelect += (sender, item, index) =>
            {
                if (item == moveTape)
                {
                    Main.MoveTape();
                }
                else if (item == deleteTape)
                {
                    Main.DeleteTape();
                }
                Toggle();
            };

            newTape.OnItemSelect += (sender, item, index) =>
            {
                var rnd = new Random();
                if (item == policeTape)
                {
                    Main.startPosition = GetEntityCoords(PlayerPedId(), true);
                    Main.CalculateTape(rnd.Next(1, 20000), GetHashKey("p_clothtarp_s"), length.Value);
                }
                else if (item == fireTape)
                {
                    Main.startPosition = GetEntityCoords(PlayerPedId(), true);
                    Main.CalculateTape(rnd.Next(1, 20000), GetHashKey("prop_fire_tape"), length.Value);
                }
                else if (item == innerCordonTape)
                {
                    Main.startPosition = GetEntityCoords(PlayerPedId(), true);
                    Main.CalculateTape(rnd.Next(1, 20000), GetHashKey("prop_cordon_tape"), length.Value);
                }
                Toggle();
            };
        }