Пример #1
0
        public MainMenu()
        {
            if (GetResourceMetadata(GetCurrentResourceName(), "client_debug_mode", 0).ToLower() == "true")
            {
                DebugMode = true;
            }
            else
            {
                DebugMode = false;
            }

            LanguageSupport = GetResourceMetadata(GetCurrentResourceName(), "language", 0);

            Dictionaries.LoadDic();
            Tick += NeonMenu.ProcessTask;

            MenuController.MenuToggleKey = Control.SelectCharacterMichael;
            MenuController.EnableMenuToggleKeyOnController = false;

            // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly.
            // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment.
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;

            // Creating the first menu.
            Menu Color = new Menu($"{Dictionaries.LangMain[0]}", "By Alsekwolf")
            {
                Visible = false
            };

            MenuController.AddMenu(Color);

            //Adding the paint sub menu
            {
                Paint = new PaintMenu();
                Menu     PaintMenu   = Paint.GetMenu();
                MenuItem PaintButton = new MenuItem($"{Dictionaries.LangMain[1]}", $"{Dictionaries.LangMain[2]}")
                {
                    Label = "→→→"
                };
                Color.AddMenuItem(PaintButton);
                MenuController.BindMenuItem(Color, PaintMenu, PaintButton);
            }

            //Adding the neon sub menu
            {
                Neon = new NeonMenu();
                Menu     NeonMenu   = Neon.GetMenu();
                MenuItem NeonButton = new MenuItem($"{Dictionaries.LangMain[3]}", $"{Dictionaries.LangMain[4]}")
                {
                    Label = "→→→"
                };
                Color.AddMenuItem(NeonButton);
                MenuController.BindMenuItem(Color, NeonMenu, NeonButton);
            }

            //Adding the misc sub menu //
            {
                Misc = new MiscMenu();
                Menu     MiscMenu   = Misc.GetMenu();
                MenuItem MiscButton = new MenuItem($"{Dictionaries.LangMain[5]}", $"{Dictionaries.LangMain[5]}")
                {
                    Label = "→→→"
                };
                Color.AddMenuItem(MiscButton);
                MenuController.BindMenuItem(Color, MiscMenu, MiscButton);
            }

            /*
             ########################################################
             #                   Event handlers
             ########################################################
             */

            Color.OnMenuClose += (_menu) =>
            {
                if (MainMenu.DebugMode == true)
                {
                    // Code in here gets triggered whenever the menu is closed.
                    Debug.WriteLine($"OnMenuClose: [{_menu}]");
                }
            };

            Color.OnMenuOpen += (_menu) =>
            {
                if (MainMenu.DebugMode == true)
                {
                    // Code in here gets triggered whenever the menu is opened.
                    Debug.WriteLine($"OnMenuOpen: [{_menu}]");
                }
            };
        }
Пример #2
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(buyCarriagesMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            Menu subMenuCartConfirmBuy = new Menu("Confirm Purcharse", "");

            MenuController.AddSubmenu(buyCarriagesMenu, subMenuCartConfirmBuy);

            MenuItem buttonCartConfirmYes = new MenuItem("", GetConfig.Langs["ConfirmBuyButtonDesc"])
            {
                RightIcon = MenuItem.Icon.SADDLE
            };

            subMenuCartConfirmBuy.AddMenuItem(buttonCartConfirmYes);
            MenuItem buttonCartConfirmNo = new MenuItem(GetConfig.Langs["CancelBuyButton"], GetConfig.Langs["CancelBuyButtonDesc"])
            {
                RightIcon = MenuItem.Icon.ARROW_LEFT
            };

            subMenuCartConfirmBuy.AddMenuItem(buttonCartConfirmNo);

            foreach (var cat in GetConfig.CartLists)
            {
                MenuItem _menuButton = new MenuItem(string.Format(GetConfig.Langs["ButtonCart"], GetConfig.Langs[cat.Key], cat.Value.ToString()), cat.Value.ToString())
                {
                    RightIcon = MenuItem.Icon.ARROW_RIGHT
                };
                buyCarriagesMenu.AddMenuItem(_menuButton);
                MenuController.BindMenuItem(buyCarriagesMenu, subMenuCartConfirmBuy, _menuButton);
            }

            buyCarriagesMenu.OnIndexChange += async(_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]");
                if (StablesShop.cartIsLoaded)
                {
                    await StablesShop.LoadCartPreview(_newIndex, StablesShop.CartPed);
                }
            };

            buyCarriagesMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                subMenuCartConfirmBuy.MenuTitle    = GetConfig.Langs[GetConfig.CartLists.ElementAt(_index).Key];
                subMenuCartConfirmBuy.MenuSubtitle = string.Format(GetConfig.Langs["subTitleConfirmBuy"], GetConfig.Langs[GetConfig.CartLists.ElementAt(_index).Key], GetConfig.CartLists.ElementAt(_index).Value.ToString());
                buttonCartConfirmYes.Label         = string.Format(GetConfig.Langs["ConfirmBuyButton"], GetConfig.CartLists.ElementAt(_index).Value.ToString());
                StablesShop.cIndex = _index;
            };

            subMenuCartConfirmBuy.OnItemSelect += (_menu, _item, _index) =>
            {
                if (_index == 0)
                {
                    StablesShop.ConfirmBuyCarriage();
                }
                else
                {
                    subMenuCartConfirmBuy.CloseMenu();
                }
            };

            buyCarriagesMenu.OnMenuOpen += (_menu) =>
            {
                StablesShop.BuyCartMode();
                StablesShop.LoadCartPreview(0, StablesShop.CartPed);
            };

            buyCarriagesMenu.OnMenuClose += (_menu) =>
            {
                StablesShop.ExitMyCartMode();
            };
        }
Пример #3
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(buyHorsesMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            #region MenuConfirm
            MenuController.AddSubmenu(buyHorsesMenu, subMenuConfirmBuy);

            MenuItem buttonConfirmYes = new MenuItem("", GetConfig.Langs["ConfirmBuyButtonDesc"])
            {
                RightIcon = MenuItem.Icon.SADDLE
            };
            subMenuConfirmBuy.AddMenuItem(buttonConfirmYes);
            MenuItem buttonConfirmNo = new MenuItem(GetConfig.Langs["CancelBuyButton"], GetConfig.Langs["CancelBuyButtonDesc"])
            {
                RightIcon = MenuItem.Icon.ARROW_LEFT
            };
            subMenuConfirmBuy.AddMenuItem(buttonConfirmNo);
            #endregion

            foreach (var cat in GetConfig.HorseLists)
            {
                List <string> hlist = new List <string>();

                foreach (var h in cat.Value)
                {
                    hlist.Add(GetConfig.Langs[h.Key]);
                }

                MenuListItem horseCategories = new MenuListItem(cat.Key, hlist, 0, "Horses");
                buyHorsesMenu.AddMenuItem(horseCategories);
                MenuController.BindMenuItem(buyHorsesMenu, subMenuConfirmBuy, horseCategories);
            }

            //Events
            buyHorsesMenu.OnMenuOpen += (_menu) =>
            {
                StablesShop.BuyHorseMode();
                StablesShop.LoadHorsePreview(0, 0, StablesShop.HorsePed);
            };

            buyHorsesMenu.OnMenuClose += (_menu) =>
            {
                StablesShop.ExitBuyHorseMode();
            };

            subMenuConfirmBuy.OnItemSelect += async(_menu, _item, _index) =>
            {
                Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]");

                if (_index == 0)
                {
                    StablesShop.ConfirmBuyHorse(subMenuConfirmBuy.MenuTitle);
                }
                else
                {
                    subMenuConfirmBuy.CloseMenu();
                }
            };

            buyHorsesMenu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) =>
            {
                Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]");
                StablesShop.iIndex             = _itemIndex;
                StablesShop.lIndex             = _listIndex;
                subMenuConfirmBuy.MenuTitle    = $"{GetConfig.HorseLists.ElementAt(_itemIndex).Key}";
                subMenuConfirmBuy.MenuSubtitle = string.Format(GetConfig.Langs["subTitleConfirmBuy"], GetConfig.Langs[GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Key], GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value.ToString());
                buttonConfirmYes.Label         = string.Format(GetConfig.Langs["ConfirmBuyButton"], GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value.ToString());

                StablesShop.horsecost  = GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Value;
                StablesShop.horsemodel = GetConfig.HorseLists.ElementAt(_itemIndex).Value.ElementAt(_listIndex).Key;
            };

            buyHorsesMenu.OnIndexChange += async(_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]");
                MenuListItem itemlist = (MenuListItem)_newItem;
                Debug.WriteLine(itemlist.ListIndex.ToString());
                if (StablesShop.horseIsLoaded)
                {
                    await StablesShop.LoadHorsePreview(itemlist.Index, itemlist.ListIndex, StablesShop.HorsePed);
                }
            };

            buyHorsesMenu.OnListIndexChange += async(_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]");
                if (StablesShop.horseIsLoaded)
                {
                    await StablesShop.LoadHorsePreview(_itemIndex, _newIndex, StablesShop.HorsePed);
                }
            };
        }
Пример #4
0
        public static void CreateMenu()
        {
            //Creating clothing Menu
            MenuController.AddMenu(ClothingMenu);

            #region clothing options menu
            List <MenuItem> listItems             = new List <MenuItem>();
            string[]        clothingCategoryNames = new string[12] {
                "Unused (head)", "Masks", "Unused (hair)", "Upper Body", "Lower Body", "Bags & Parachutes", "Shoes", "Scarfs & Chains", "Shirt & Accessory", "Body Armor & Accessory 2", "Badges & Logos", "Shirt Overlay & Jackets"
            };
            for (int i = 0; i < 12; i++)
            {
                if (i != 0 && i != 2)
                {
                    int currentVariationIndex        = Functions.IsEdidtingPed && Functions.CurrentCharacter.DrawableVariations.Clothes.ContainsKey(i) ? Functions.CurrentCharacter.DrawableVariations.Clothes[i].Key : GetPedDrawableVariation(Game.PlayerPed.Handle, i);
                    int currentVariationTextureIndex = Functions.IsEdidtingPed && Functions.CurrentCharacter.DrawableVariations.Clothes.ContainsKey(i) ? Functions.CurrentCharacter.DrawableVariations.Clothes[i].Value : GetPedTextureVariation(Game.PlayerPed.Handle, i);

                    //int maxDrawables = GetNumberOfPedDrawableVariations(Game.PlayerPed.Handle, i);
                    int maxDrawables = 16;

                    List <string> items = new List <string>();
                    for (int x = 0; x < maxDrawables; x++)
                    {
                        items.Add($"Drawable #{x} (of {maxDrawables})");
                    }

                    int maxTextures = GetNumberOfPedTextureVariations(Game.PlayerPed.Handle, i, currentVariationIndex);

                    MenuListItem listItem = new MenuListItem(clothingCategoryNames[i], items, currentVariationIndex, $"Select a drawable using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{currentVariationTextureIndex + 1} (of {maxTextures}).");
                    listItems.Add(listItem);
                    ClothingMenu.AddMenuItem(listItem);
                }
            }

            foreach (var listItem in listItems)
            {
                if (listItem.Text == "Masks" || listItem.Text == "Bags & Parachutes" || listItem.Text == "Scarfs & Chains" || listItem.Text == "Body Armor & Accessory 2" || listItem.Text == "Badges & Logos")
                {
                    listItem.Enabled     = false;
                    listItem.RightIcon   = MenuItem.Icon.LOCK;
                    listItem.Description =
                        "You can't customize this in the character creator, go to a shop after to do so.";
                }
            }
            #endregion

            #region clothes
            ClothingMenu.OnListIndexChange += (_menu, listItem, oldSelectionIndex, newSelectionIndex, realIndex) =>
            {
                int componentIndex = realIndex + 1;
                if (realIndex > 0)
                {
                    componentIndex += 1;
                }

                int textureIndex    = GetPedTextureVariation(Game.PlayerPed.Handle, componentIndex);
                int newTextureIndex = 0;
                SetPedComponentVariation(Game.PlayerPed.Handle, componentIndex, newSelectionIndex, newTextureIndex, 0);
                if (Functions.CurrentCharacter.DrawableVariations.Clothes == null)
                {
                    Functions.CurrentCharacter.DrawableVariations.Clothes = new Dictionary <int, KeyValuePair <int, int> >();
                }

                int maxTextures = GetNumberOfPedTextureVariations(Game.PlayerPed.Handle, componentIndex, newSelectionIndex);

                Functions.CurrentCharacter.DrawableVariations.Clothes[componentIndex] = new KeyValuePair <int, int>(newSelectionIndex, newTextureIndex);
                listItem.Description = $"Select a drawable using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{newTextureIndex + 1} (of {maxTextures}).";
            };

            ClothingMenu.OnListItemSelect += (sender, listItem, listIndex, realIndex) =>
            {
                int componentIndex = realIndex + 1; // skip face options as that f***s up with inheritance faces
                if (realIndex > 0)                  // skip hair features as that is done in the appeareance menu
                {
                    componentIndex += 1;
                }

                int textureIndex    = GetPedTextureVariation(Game.PlayerPed.Handle, componentIndex);
                int newTextureIndex = (GetNumberOfPedTextureVariations(Game.PlayerPed.Handle, componentIndex, listIndex) - 1) < (textureIndex + 1) ? 0 : textureIndex + 1;
                SetPedComponentVariation(Game.PlayerPed.Handle, componentIndex, listIndex, newTextureIndex, 0);
                if (Functions.CurrentCharacter.DrawableVariations.Clothes == null)
                {
                    Functions.CurrentCharacter.DrawableVariations.Clothes = new Dictionary <int, KeyValuePair <int, int> >();
                }

                int maxTextures = GetNumberOfPedTextureVariations(Game.PlayerPed.Handle, componentIndex, listIndex);

                Functions.CurrentCharacter.DrawableVariations.Clothes[componentIndex] = new KeyValuePair <int, int>(listIndex, newTextureIndex);
                listItem.Description = $"Select a drawable using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{newTextureIndex + 1} (of {maxTextures}).";
            };
            #endregion
        }
Пример #5
0
        public void CoffeeMenu()
        {
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
            Menu menu = new Menu("Coffee Break Menu");

            MenuController.AddMenu(menu);
            player = LocalPlayer.Character;

            MenuItem buyCoffee = new MenuItem("Buy Coffee", "Get a piping hot cup of coffee")
            {
                RightIcon = MenuItem.Icon.INV_DOLLAR
            };

            menu.AddMenuItem(buyCoffee);
            MenuItem clear = new MenuItem("Finish Up", "Finish your drink, you've got work to do!")
            {
                RightIcon = MenuItem.Icon.NONE
            };

            menu.AddMenuItem(clear);

            menu.OnItemSelect += delegate(Menu _menu, MenuItem _item, int _index)
            {
                if (_index == 0)                                                                                       //buy coffee
                {
                    coffeecup = CitizenFX.Core.Native.API.CreateObjectNoOffset(3696781377, 0, 0, 0, true, true, true); //Creates Coffee cup

                    CitizenFX.Core.Native.API.AttachEntityToEntity(coffeecup, CitizenFX.Core.Native.API.GetPlayerPed(-1), CitizenFX.Core.Native.API.GetPedBoneIndex(CitizenFX.Core.Native.API.GetPlayerPed(-1), 28422), 0, 0, 0, 0, 0, 0, true, true, false, false, 2, true);

                    AnimationFlags flags = AnimationFlags.Loop;
                    CitizenFX.Core.Native.API.RequestAnimDict("amb@world_human_drinking@coffee@male@idle_a");
                    player.Task.PlayAnimation("amb@world_human_drinking@coffee@male@idle_a", "idle_a", -1, -1, flags);

                    uint streetName = 0u;
                    uint crossing   = 0u;
                    CitizenFX.Core.Native.API.GetStreetNameAtCoord(LocalPlayer.Character.Position.X, LocalPlayer.Character.Position.Y, LocalPlayer.Character.Position.Z, ref streetName, ref crossing);

                    BaseScript.TriggerServerEvent("PostToDiscord", CitizenFX.Core.Native.API.GetPlayerName(CitizenFX.Core.Native.API.PlayerId()), CitizenFX.Core.Native.API.GetStreetNameFromHashKey(streetName), "REFRESHMENT BREAK");
                }
                if (_index == 1) //clear
                {
                    player.Task.ClearAnimation("amb@world_human_drinking@coffee@male@idle_a", "idle_a");
                    CitizenFX.Core.Native.API.DeleteEntity(ref coffeecup);

                    uint streetName = 0u;
                    uint crossing   = 0u;
                    CitizenFX.Core.Native.API.GetStreetNameAtCoord(LocalPlayer.Character.Position.X, LocalPlayer.Character.Position.Y, LocalPlayer.Character.Position.Z, ref streetName, ref crossing);

                    BaseScript.TriggerServerEvent("PostToDiscord", CitizenFX.Core.Native.API.GetPlayerName(CitizenFX.Core.Native.API.PlayerId()), CitizenFX.Core.Native.API.GetStreetNameFromHashKey(streetName), "ON PATROL");
                }
            };
            base.Tick += async delegate
            {
                await Task.FromResult(0);

                if (Game.IsControlJustReleased(1, Control.SelectCharacterFranklin)) //F5
                {
                    foreach (Vector3 pos in coffeeMachines)
                    {
                        playerPos = LocalPlayer.Character.Position;
                        float dist = World.GetDistance(pos, playerPos);

                        if (dist < 8f)
                        {
                            menu.Visible = !menu.Visible;
                        }
                    }
                }
            };
        }
Пример #6
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        private void CreateMenu()
        {
            menu = new Menu(Game.Player.Name, "Banned Players Management");

            menu.InstructionalButtons.Add(Control.Jump, "Filter Options");
            menu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.Jump, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>(async(a, b) =>
            {
                if (banlist.Count > 1)
                {
                    string filterText = await GetUserInput("Filter List By Username (leave this empty to reset the filter!)");
                    if (string.IsNullOrEmpty(filterText))
                    {
                        Subtitle.Custom("Filters have been cleared.");
                        menu.ResetFilter();
                        UpdateBans();
                    }
                    else
                    {
                        menu.FilterMenuItems(item => item.ItemData is BanRecord br && br.playerName.ToLower().Contains(filterText.ToLower()));
                        Subtitle.Custom("Username filter has been applied.");
                    }
                }
                else
                {
                    Notify.Error("At least 2 players need to be banned in order to use the filter function.");
                }

                Log($"Button pressed: {a} {b}");
            }), true));

            bannedPlayer.AddMenuItem(new MenuItem("Player Name"));
            bannedPlayer.AddMenuItem(new MenuItem("Banned By"));
            bannedPlayer.AddMenuItem(new MenuItem("Banned Until"));
            bannedPlayer.AddMenuItem(new MenuItem("Player Identifiers"));
            bannedPlayer.AddMenuItem(new MenuItem("Banned For"));
            bannedPlayer.AddMenuItem(new MenuItem("~r~Unban", "~r~Warning, unbanning the player can NOT be undone. You will NOT be able to ban them again until they re-join the server. Are you absolutely sure you want to unban this player? ~s~Tip: Tempbanned players will automatically get unbanned if they log on to the server after their ban date has expired."));

            // should be enough for now to cover all possible identifiers.
            List <string> colors = new List <string>()
            {
                "~r~", "~g~", "~b~", "~o~", "~y~", "~p~", "~s~", "~t~",
            };

            bannedPlayer.OnMenuClose += (sender) =>
            {
                BaseScript.TriggerServerEvent("vMenu:RequestBanList", Game.Player.Handle);
                bannedPlayer.GetMenuItems()[5].Label = "";
                UpdateBans();
            };

            bannedPlayer.OnIndexChange += (sender, oldItem, newItem, oldIndex, newIndex) =>
            {
                bannedPlayer.GetMenuItems()[5].Label = "";
            };

            bannedPlayer.OnItemSelect += (sender, item, index) =>
            {
                if (index == 5 && IsAllowed(Permission.OPUnban))
                {
                    if (item.Label == "Are you sure?")
                    {
                        if (banlist.Contains(currentRecord))
                        {
                            UnbanPlayer(banlist.IndexOf(currentRecord));
                            bannedPlayer.GetMenuItems()[5].Label = "";
                            bannedPlayer.GoBack();
                        }
                        else
                        {
                            Notify.Error("Somehow you managed to click the unban button but this ban record you're apparently viewing does not even exist. Weird...");
                        }
                    }
                    else
                    {
                        item.Label = "Are you sure?";
                    }
                }
                else
                {
                    bannedPlayer.GetMenuItems()[5].Label = "";
                }
            };

            menu.OnItemSelect += (sender, item, index) =>
            {
                //if (index < banlist.Count)
                //{
                currentRecord = item.ItemData;

                bannedPlayer.MenuSubtitle = "Ban Record: ~y~" + currentRecord.playerName;
                var nameItem              = bannedPlayer.GetMenuItems()[0];
                var bannedByItem          = bannedPlayer.GetMenuItems()[1];
                var bannedUntilItem       = bannedPlayer.GetMenuItems()[2];
                var playerIdentifiersItem = bannedPlayer.GetMenuItems()[3];
                var banReasonItem         = bannedPlayer.GetMenuItems()[4];
                nameItem.Label           = currentRecord.playerName;
                nameItem.Description     = "Player name: ~y~" + currentRecord.playerName;
                bannedByItem.Label       = currentRecord.bannedBy;
                bannedByItem.Description = "Player banned by: ~y~" + currentRecord.bannedBy;
                if (currentRecord.bannedUntil.Date.Year == 3000)
                {
                    bannedUntilItem.Label = "Forever";
                }
                else
                {
                    bannedUntilItem.Label = currentRecord.bannedUntil.Date.ToString();
                }
                bannedUntilItem.Description       = "This player is banned until: " + currentRecord.bannedUntil.Date.ToString();
                playerIdentifiersItem.Description = "";

                int i = 0;
                foreach (string id in currentRecord.identifiers)
                {
                    // only (admins) people that can unban players are allowed to view IP's.
                    // this is just a slight 'safety' feature in case someone who doesn't know what they're doing
                    // gave builtin.everyone access to view the banlist.
                    if (id.StartsWith("ip:") && !IsAllowed(Permission.OPUnban))
                    {
                        playerIdentifiersItem.Description += $"{colors[i]}ip: (hidden) ";
                    }
                    else
                    {
                        playerIdentifiersItem.Description += $"{colors[i]}{id.Replace(":", ": ")} ";
                    }
                    i++;
                }
                banReasonItem.Description = "Banned for: " + currentRecord.banReason;

                var unbanPlayerBtn = bannedPlayer.GetMenuItems()[5];
                unbanPlayerBtn.Label = "";
                if (!IsAllowed(Permission.OPUnban))
                {
                    unbanPlayerBtn.Enabled     = false;
                    unbanPlayerBtn.Description = "You are not allowed to unban players. You are only allowed to view their ban record.";
                    unbanPlayerBtn.LeftIcon    = MenuItem.Icon.LOCK;
                }

                bannedPlayer.RefreshIndex();
                //}
            };
            MenuController.AddMenu(bannedPlayer);
        }
Пример #7
0
        /// <summary>
        /// Main OnTick task runs every game tick and handles all the menu stuff.
        /// </summary>
        /// <returns></returns>
        private async Task OnTick()
        {
            #region FirstTick
            // Only run this the first tick.
            if (firstTick)
            {
                firstTick = false;
                switch (GetSettingsInt(Setting.vmenu_pvp_mode))
                {
                case 1:
                    NetworkSetFriendlyFireOption(true);
                    SetCanAttackFriendly(Game.PlayerPed.Handle, true, false);
                    break;

                case 2:
                    NetworkSetFriendlyFireOption(false);
                    SetCanAttackFriendly(Game.PlayerPed.Handle, false, false);
                    break;

                case 0:
                default:
                    break;
                }
                // Clear all previous pause menu info/brief messages on resource start.
                ClearBrief();

                // Request the permissions data from the server.
                TriggerServerEvent("vMenu:RequestPermissions");

                // Wait until the data is received and the player's name is loaded correctly.
                while (!ConfigOptionsSetupComplete || !PermissionsSetupComplete || Game.Player.Name == "**Invalid**" || Game.Player.Name == "** Invalid **")
                {
                    await Delay(0);
                }
                if ((IsAllowed(Permission.Staff) && GetSettingsBool(Setting.vmenu_menu_staff_only)) || GetSettingsBool(Setting.vmenu_menu_staff_only) == false)
                {
                    if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1)
                    {
                        MenuToggleKey = (Control)GetSettingsInt(Setting.vmenu_menu_toggle_key);
                        //MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key);
                    }
                    if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1)
                    {
                        NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key);
                    }

                    // Create the main menu.
                    Menu           = new Menu(Game.Player.Name, "Main Menu");
                    PlayerSubmenu  = new Menu(Game.Player.Name, "Player Related Options");
                    VehicleSubmenu = new Menu(Game.Player.Name, "Vehicle Related Options");
                    WorldSubmenu   = new Menu(Game.Player.Name, "World Options");

                    // Add the main menu to the menu pool.
                    MenuController.AddMenu(Menu);
                    MenuController.MainMenu = Menu;

                    MenuController.AddSubmenu(Menu, PlayerSubmenu);
                    MenuController.AddSubmenu(Menu, VehicleSubmenu);
                    MenuController.AddSubmenu(Menu, WorldSubmenu);

                    // Create all (sub)menus.
                    CreateSubmenus();
                }
                else
                {
                    MenuController.MainMenu           = null;
                    MenuController.DisableMenuButtons = true;
                    MenuController.DontOpenAnyMenu    = true;
                    MenuController.MenuToggleKey      = (Control)(-1); // disables the menu toggle key
                }

                // Manage Stamina
                if (PlayerOptionsMenu != null && PlayerOptionsMenu.PlayerStamina && IsAllowed(Permission.POUnlimitedStamina))
                {
                    StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true);
                }
                else
                {
                    StatSetInt((uint)GetHashKey("MP0_STAMINA"), 0, true);
                }

                // Manage other stats, in order of appearance in the pause menu (stats) page.
                StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 100, true);        // Shooting
                StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true);                // Strength
                StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true);         // Stealth
                StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true);          // Flying
                StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true);         // Driving
                StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 100, true);           // Lung Capacity
                StatSetFloat((uint)GetHashKey("MP0_PLAYER_MENTAL_STATE"), 0f, true);    // Mental State
            }
            #endregion


            // If the setup (permissions) is done, and it's not the first tick, then do this:
            if (ConfigOptionsSetupComplete && !firstTick)
            {
                #region Handle Opening/Closing of the menu.


                var tmpMenu = GetOpenMenu();
                if (MpPedCustomizationMenu != null)
                {
                    bool IsOpen()
                    {
                        return
                            (MpPedCustomizationMenu.appearanceMenu.Visible ||
                             MpPedCustomizationMenu.faceShapeMenu.Visible ||
                             MpPedCustomizationMenu.createCharacterMenu.Visible ||
                             MpPedCustomizationMenu.inheritanceMenu.Visible ||
                             MpPedCustomizationMenu.propsMenu.Visible ||
                             MpPedCustomizationMenu.clothesMenu.Visible ||
                             MpPedCustomizationMenu.tattoosMenu.Visible);
                    }

                    if (IsOpen())
                    {
                        if (tmpMenu == MpPedCustomizationMenu.createCharacterMenu)
                        {
                            MpPedCustomization.DisableBackButton = true;
                        }
                        else
                        {
                            MpPedCustomization.DisableBackButton = false;
                        }
                        MpPedCustomization.DontCloseMenus = true;
                    }
                    else
                    {
                        MpPedCustomization.DisableBackButton = false;
                        MpPedCustomization.DontCloseMenus    = false;
                    }
                }

                if (Game.IsDisabledControlJustReleased(0, Control.PhoneCancel) && MpPedCustomization.DisableBackButton)
                {
                    await Delay(0);

                    Notify.Alert("You must save your ped first before exiting, or click the ~r~Exit Without Saving~s~ button.");
                }

                if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
                {
                    if (Game.IsControlJustPressed(0, (Control)NoClipKey) && IsAllowed(Permission.NoClip) && UpdateOnscreenKeyboard() != 0)
                    {
                        if (Game.PlayerPed.IsInVehicle())
                        {
                            Vehicle veh = GetVehicle();
                            if (veh != null && veh.Exists() && veh.Driver == Game.PlayerPed)
                            {
                                NoClipEnabled = !NoClipEnabled;
                            }
                            else
                            {
                                NoClipEnabled = false;
                                Notify.Error("This vehicle does not exist (somehow) or you need to be the driver of this vehicle to enable noclip!");
                            }
                        }
                        else
                        {
                            NoClipEnabled = !NoClipEnabled;
                        }
                        TriggerServerEvent("ex_logger:SendLogBot", new
                        {
                            source       = GetPlayerServerId(Game.Player.Handle),
                            channel      = 646040318214406154,
                            content      = $"**Zmieniono status __NoClip__:** {NoClipEnabled}",
                            scriptName   = "vMenu",
                            functionName = "NoClip",
                        });
                    }
                }

                #endregion

                // Menu toggle button.
                Game.DisableControlThisFrame(0, MenuToggleKey);
            }
        }
Пример #8
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        void CreateMenu()
        {
            #region Create menus and submenus
            // Create the menu.
            menu = new Menu("Saved Vehicles", "Manage Saved Vehicles");

            var saveVehicle = new MenuItem("Save Current Vehicle", "Save the vehicle you are currently sitting in.");
            menu.AddMenuItem(saveVehicle);
            saveVehicle.RightIcon = MenuItem.Icon.CAR;

            menu.OnItemSelect += (sender, item, index) =>
            {
                if (item == saveVehicle)
                {
                    if (Game.PlayerPed.IsInVehicle())
                    {
                        SaveVehicle();
                    }
                    else
                    {
                        Notify.Error("You are currently not in any vehicle. Please enter a vehicle before trying to save it.");
                    }
                }
            };

            for (int i = 0; i < array.brands.Count(); i++)
            {
                var categoryName = array.brands[i].brandName;

                var categoryMenu = new Menu("Saved Vehicles", categoryName);

                var categoryButton = new MenuItem(categoryName, $"All saved vehicles from the {categoryName} category.");

                subMenus.Add(categoryMenu);
                MenuController.AddSubmenu(menu, categoryMenu);
                menu.AddMenuItem(categoryButton);
                categoryButton.Label = "→→→";
                MenuController.BindMenuItem(menu, categoryMenu, categoryButton);

                categoryMenu.OnMenuClose += (sender) =>
                {
                    UpdateMenuAvailableCategories();
                };

                categoryMenu.OnItemSelect += (sender, item, index) =>
                {
                    UpdateSelectedVehicleMenu(item, sender);
                };
            }


            var unavailableModels = new MenuItem("Unavailable Saved Vehicles", "These vehicles are currently unavailable because the models are not present in the game. These vehicles are most likely not being streamed from the server.")
            {
                Label = "→→→"
            };

            MenuController.AddMenu(selectedVehicleMenu);
            var spawnVehicle   = new MenuItem("Spawn Vehicle", "Spawn this saved vehicle.");
            var renameVehicle  = new MenuItem("Rename Vehicle", "Rename your saved vehicle.");
            var replaceVehicle = new MenuItem("~r~Replace Vehicle", "Your saved vehicle will be replaced with the vehicle you are currently sitting in. ~r~Warning: this can NOT be undone!");
            var deleteVehicle  = new MenuItem("~r~Delete Vehicle", "~r~This will delete your saved vehicle. Warning: this can NOT be undone!");
            selectedVehicleMenu.AddMenuItem(spawnVehicle);
            selectedVehicleMenu.AddMenuItem(renameVehicle);
            selectedVehicleMenu.AddMenuItem(replaceVehicle);
            selectedVehicleMenu.AddMenuItem(deleteVehicle);

            selectedVehicleMenu.OnMenuOpen += (sender) =>
            {
                spawnVehicle.Label = "(" + GetDisplayNameFromVehicleModel(currentlySelectedVehicle.Value.model).ToLower() + ")";
            };

            selectedVehicleMenu.OnMenuClose += (sender) =>
            {
                selectedVehicleMenu.RefreshIndex();
                deleteButtonPressedCount = 0;
                deleteVehicle.Label      = "";
            };

            selectedVehicleMenu.OnItemSelect += async(sender, item, index) =>
            {
                if (item == spawnVehicle)
                {
                    if (MainMenu.VehicleSpawnerMenu != null)
                    {
                        if (IsAllowed(Permission.VSSpawnByName))
                        {
                            SpawnVehicle(currentlySelectedVehicle.Value.model, MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4));
                            Exports["vstancer"].LoadVStancerPreset();
                        }
                        else
                        {
                            if (CanSpawn)
                            {
                                SpawnVehicle(currentlySelectedVehicle.Value.model, MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4));
                                Exports["vstancer"].LoadVStancerPreset();
                                Spawned();
                                int tmpTimer = GetGameTimer();
                                while (GetGameTimer() - tmpTimer < 6000) // wait 30 _real_ seconds
                                {
                                    await Delay(0);

                                    float carCoolDownState = (GetGameTimer() - (float)tmpTimer) / 6000f;
                                    spawnVehicle.Enabled     = false;
                                    spawnVehicle.Description = $"Cooldown: {Math.Ceiling(6f - (6f * carCoolDownState))}";
                                }

                                spawnVehicle.Enabled     = true;
                                spawnVehicle.Description = "Spawn this saved vehicle.";
                            }
                            else
                            {
                                Notify.Info("Wait for the 6 second cooldown before spawning another car");
                            }

                            MainMenu.SavedVehiclesMenu.GetMenu().CounterPreText = null;
                        }
                    }
                    else
                    {
                        SpawnVehicle(currentlySelectedVehicle.Value.model, true, true, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4));
                    }
                }
                else if (item == renameVehicle)
                {
                    var newName = await GetUserInput(windowTitle : "Enter a new name for this vehicle.", maxInputLength : 30);

                    if (string.IsNullOrEmpty(newName))
                    {
                        Notify.Error(CommonErrors.InvalidInput);
                    }
                    else
                    {
                        if (StorageManager.SaveVehicleInfo("veh_" + newName, currentlySelectedVehicle.Value, false))
                        {
                            DeleteResourceKvp(currentlySelectedVehicle.Key);
                            while (!selectedVehicleMenu.Visible)
                            {
                                await Delay(0);
                            }

                            Notify.Success("Your vehicle has successfully been renamed.");
                            UpdateMenuAvailableCategories();
                            selectedVehicleMenu.GoBack();
                            currentlySelectedVehicle = new KeyValuePair <string, VehicleInfo>(); // clear the old info
                        }
                        else
                        {
                            Notify.Error("This name is already in use or something unknown failed. Contact the server owner if you believe something is wrong.");
                        }
                    }
                }
                else if (item == replaceVehicle)
                {
                    if (Game.PlayerPed.IsInVehicle())
                    {
                        SaveVehicle(currentlySelectedVehicle.Key.Substring(4));
                        selectedVehicleMenu.GoBack();
                        Notify.Success("Your saved vehicle has been replaced with your current vehicle.");
                    }
                    else
                    {
                        Notify.Error("You need to be in a vehicle before you can relplace your old vehicle.");
                    }
                }
                else if (item == deleteVehicle)
                {
                    if (deleteButtonPressedCount == 0)
                    {
                        deleteButtonPressedCount = 1;
                        item.Label = "Press again to confirm.";
                        Notify.Alert("Are you sure you want to delete this vehicle? Press the button again to confirm.");
                    }
                    else
                    {
                        deleteButtonPressedCount = 0;
                        item.Label = "";
                        DeleteResourceKvp(currentlySelectedVehicle.Key);
                        UpdateMenuAvailableCategories();
                        selectedVehicleMenu.GoBack();
                        Notify.Success("Your saved vehicle has been deleted.");
                    }
                }

                if (item != deleteVehicle) // if any other button is pressed, restore the delete vehicle button pressed count.
                {
                    deleteButtonPressedCount = 0;
                    deleteVehicle.Label      = "";
                }
            };

            #endregion
        }
Пример #9
0
        /// <summary>
        /// Main OnTick task runs every game tick and handles all the menu stuff.
        /// </summary>
        /// <returns></returns>
        private async Task OnTick()
        {
            #region FirstTick
            // Only run this the first tick.
            if (firstTick)
            {
                firstTick = false;
                // Clear all previous pause menu info/brief messages on resource start.
                ClearBrief();

                // Request the permissions data from the server.
                TriggerServerEvent("vMenu:RequestPermissions");

                // Wait until the data is received and the player's name is loaded correctly.
                while (!ConfigOptionsSetupComplete || !PermissionsSetupComplete || Game.Player.Name == "**Invalid**" || Game.Player.Name == "** Invalid **")
                {
                    await Delay(0);
                }
                if ((IsAllowed(Permission.Staff) && GetSettingsBool(Setting.vmenu_menu_staff_only)) || GetSettingsBool(Setting.vmenu_menu_staff_only) == false)
                {
                    if (GetSettingsInt(Setting.vmenu_menu_toggle_key) != -1)
                    {
                        MenuToggleKey = (Control)GetSettingsInt(Setting.vmenu_menu_toggle_key);
                        //MenuToggleKey = GetSettingsInt(Setting.vmenu_menu_toggle_key);
                    }
                    if (GetSettingsInt(Setting.vmenu_noclip_toggle_key) != -1)
                    {
                        NoClipKey = GetSettingsInt(Setting.vmenu_noclip_toggle_key);
                    }
                    // Create the main menu.
                    Menu = new Menu(Game.Player.Name, "Main Menu");

                    // Add the main menu to the menu pool.
                    MenuController.AddMenu(Menu);
                    MenuController.MainMenu = Menu;

                    // Create all (sub)menus.
                    CreateSubmenus();
                }
                else
                {
                    MenuController.MainMenu           = null;
                    MenuController.DisableMenuButtons = true;
                    MenuController.DontOpenAnyMenu    = true;
                    MenuController.MenuToggleKey      = (Control)(-1); // disables the menu toggle key
                }

                // Manage Stamina
                if (PlayerOptionsMenu != null && PlayerOptionsMenu.PlayerStamina && IsAllowed(Permission.POUnlimitedStamina))
                {
                    StatSetInt((uint)GetHashKey("MP0_STAMINA"), 100, true);
                }
                else
                {
                    StatSetInt((uint)GetHashKey("MP0_STAMINA"), 0, true);
                }
                // Manage other stats.
                StatSetInt((uint)GetHashKey("MP0_STRENGTH"), 100, true);
                StatSetInt((uint)GetHashKey("MP0_LUNG_CAPACITY"), 80, true); // reduced because it was over powered
                StatSetInt((uint)GetHashKey("MP0_WHEELIE_ABILITY"), 100, true);
                StatSetInt((uint)GetHashKey("MP0_FLYING_ABILITY"), 100, true);
                StatSetInt((uint)GetHashKey("MP0_SHOOTING_ABILITY"), 50, true); // reduced because it was over powered
                StatSetInt((uint)GetHashKey("MP0_STEALTH_ABILITY"), 100, true);
            }
            #endregion


            // If the setup (permissions) is done, and it's not the first tick, then do this:
            if (ConfigOptionsSetupComplete && !firstTick)
            {
                #region Handle Opening/Closing of the menu.


                var tmpMenu = GetOpenMenu();
                if (MpPedCustomizationMenu != null)
                {
                    bool IsOpen()
                    {
                        return
                            (MpPedCustomizationMenu.appearanceMenu.Visible ||
                             MpPedCustomizationMenu.faceShapeMenu.Visible ||
                             MpPedCustomizationMenu.createCharacterMenu.Visible ||
                             MpPedCustomizationMenu.inheritanceMenu.Visible ||
                             MpPedCustomizationMenu.propsMenu.Visible ||
                             MpPedCustomizationMenu.clothesMenu.Visible ||
                             MpPedCustomizationMenu.tattoosMenu.Visible);
                    }

                    if (IsOpen())
                    {
                        if (tmpMenu == MpPedCustomizationMenu.createCharacterMenu)
                        {
                            MpPedCustomization.DisableBackButton = true;
                        }
                        else
                        {
                            MpPedCustomization.DisableBackButton = false;
                        }
                        MpPedCustomization.DontCloseMenus = true;
                    }
                    else
                    {
                        MpPedCustomization.DisableBackButton = false;
                        MpPedCustomization.DontCloseMenus    = false;
                    }
                }

                if (Game.IsDisabledControlJustReleased(0, Control.PhoneCancel) && MpPedCustomization.DisableBackButton)
                {
                    await Delay(0);

                    Notify.Alert("You must save your ped first before exiting, or click the ~r~Exit Without Saving~s~ button.");
                }

                if (Game.CurrentInputMode == InputMode.MouseAndKeyboard)
                {
                    if (!MenuController.IsAnyMenuOpen() || NoClipEnabled)
                    {
                        if (Game.IsControlJustPressed(0, (Control)NoClipKey) && IsAllowed(Permission.NoClip))
                        {
                            if (MenuController.IsAnyMenuOpen())
                            {
                                if (MenuController.GetCurrentMenu() != null && MenuController.GetCurrentMenu() != NoClipMenu)
                                {
                                    MenuController.CloseAllMenus();
                                }
                            }
                            if (Game.PlayerPed.IsInVehicle())
                            {
                                Vehicle veh = GetVehicle();
                                if (veh != null && veh.Exists() && !veh.IsDead && veh.Driver == Game.PlayerPed)
                                {
                                    NoClipEnabled = !NoClipEnabled;
                                    MenuController.DontOpenAnyMenu = NoClipEnabled;
                                }
                                else
                                {
                                    NoClipEnabled = false;
                                    MenuController.DontOpenAnyMenu = NoClipEnabled;
                                    Notify.Error("You need to be the driver of this vehicle to enable noclip!");
                                }
                            }
                            else
                            {
                                NoClipEnabled = !NoClipEnabled;
                                MenuController.DontOpenAnyMenu = NoClipEnabled;
                            }
                        }
                    }
                }

                if (NoClipEnabled)
                {
                    MenuController.DontOpenAnyMenu = true;
                }

                #endregion

                // Menu toggle button.
                Game.DisableControlThisFrame(0, MenuToggleKey);
            }
        }
Пример #10
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(buyMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            MenuController.AddSubmenu(buyMenu, buyMenuConfirm);

            for (var i = 1; i < 101; i++)
            {
                quantityList.Add($"{GetConfig.Langs["Quantity"]} #{i}");
            }

            MenuItem subMenuConfirmBuyBtnYes = new MenuItem("", " ")
            {
                RightIcon = MenuItem.Icon.TICK
            };
            MenuItem subMenuConfirmBuyBtnNo = new MenuItem(GetConfig.Langs["BuyConfirmButtonNo"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_LEFT
            };

            buyMenuConfirm.AddMenuItem(subMenuConfirmBuyBtnYes);
            buyMenuConfirm.AddMenuItem(subMenuConfirmBuyBtnNo);

            buyMenu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) =>
            {
                indexItem    = _itemIndex;
                quantityItem = _listIndex + 1;
                double totalPrice = double.Parse(GetConfig.Config["Stores"][StoreActions.LaststoreId]["ItemsBuy"][_itemIndex]["BuyPrice"].ToString()) * quantityItem;
                buyMenuConfirm.MenuTitle      = GetConfig.ItemsFromDB[GetConfig.Config["Stores"][StoreActions.LaststoreId]["ItemsBuy"][_itemIndex]["Name"].ToString()]["label"].ToString();
                subMenuConfirmBuyBtnYes.Label = string.Format(GetConfig.Langs["BuyConfirmButtonYes"], (_listIndex + 1).ToString(), GetConfig.ItemsFromDB[GetConfig.Config["Stores"][StoreActions.LaststoreId]["ItemsBuy"][_itemIndex]["Name"].ToString()]["label"].ToString(), totalPrice.ToString());
            };

            buyMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                StoreActions.CreateObjectOnTable(_newIndex, "ItemsBuy");
            };

            buyMenu.OnMenuOpen += (_menu) =>
            {
                buyMenu.ClearMenuItems();

                foreach (var item in GetConfig.Config["Stores"][StoreActions.LaststoreId]["ItemsBuy"])
                {
                    MenuListItem _itemToBuy = new MenuListItem(GetConfig.ItemsFromDB[item["Name"].ToString()]["label"].ToString() + $" ${item["BuyPrice"]}", quantityList, 0, "")
                    {
                    };

                    buyMenu.AddMenuItem(_itemToBuy);
                    MenuController.BindMenuItem(buyMenu, buyMenuConfirm, _itemToBuy);
                }

                StoreActions.CreateObjectOnTable(_menu.CurrentIndex, "ItemsBuy");
            };

            buyMenuConfirm.OnItemSelect += (_menu, _item, _index) =>
            {
                if (_index == 0)
                {
                    StoreActions.BuyItemStore(indexItem, quantityItem);
                    buyMenu.OpenMenu();
                    buyMenuConfirm.CloseMenu();
                }
                else
                {
                    buyMenu.OpenMenu();
                    buyMenuConfirm.CloseMenu();
                }
            };
        }
Пример #11
0
        /// <summary>
        /// Creates all the submenus of main menu
        /// </summary>
        /// <returns></returns>
        private void CreateSubmenus()
        {
            // Create the menu.
            Menu = new Menu("Enhanced camera", "Lead, chase and drone camera options");
            MenuController.AddMenu(Menu);

            #region checkbox items

            // Enabling angular drift cam
            leadCam = new MenuCheckboxItem("Enable lead camera", "Main camera, behaviour dependant on angular velocity of the car.", false);
            // Enabling chase cam
            chaseCam = new MenuCheckboxItem("Enable chase camera", "Locks to a target in front, switches to regular cam if target not in range.", false);
            // Enabling chase cam
            droneCam = new MenuCheckboxItem("Enable drone camera", "Free drone camera to spectate/fly around. Different modes available.", false);

            #endregion

            #region adding menu items
            // Checkboxes
            Menu.AddMenuItem(leadCam);
            Menu.AddMenuItem(chaseCam);
            Menu.AddMenuItem(droneCam);

            // Custom cam parameters menu
            CustomCamMenu = new CustomCam();
            Menu     customCamMenu = CustomCamMenu.GetMenu();
            MenuItem buttonCustom  = new MenuItem("Lead/chase cam parameters", "Tune parameters for lead and chase camera")
            {
                Label = "→→→"
            };
            AddMenu(Menu, customCamMenu, buttonCustom);

            // Drone cam parameters menu
            DroneCamMenu = new DroneCam();
            Menu     droneCamMenu = DroneCamMenu.GetMenu();
            MenuItem buttonDrone  = new MenuItem("Drone cam parameters", "Tune parameters for drone camera")
            {
                Label = "→→→"
            };
            AddMenu(Menu, droneCamMenu, buttonDrone);

            // Credits
            MenuItem credits = new MenuItem("Credits", "~g~Shrimp~s~ - idea and execution\n" +
                                            "~g~Tom Grobbe~s~ - MenuAPI used for GUI, code snippets for saving/loading\n" +
                                            "~g~QuadrupleTurbo~s~ - Help with ideas and testing\n" +
                                            "~y~No Name Drift~s~ and ~y~Velocity~s~ drift servers - playtesting and feedback\n")
            {
            };
            Menu.AddMenuItem(credits);

            #endregion

            #region handling menu changes

            // Handle checkbox changes
            Menu.OnCheckboxChange += (_menu, _item, _index, _checked) => {
                if (_item == leadCam)
                {
                    CustomCam.LeadCam    = _checked;
                    chaseCam.Checked     = false;
                    droneCam.Checked     = false;
                    CustomCam.ChaseCam   = false;
                    DroneCam.DroneCamVar = false;

                    if (!_checked)
                    {
                        ResetCameras();
                    }
                }
                if (_item == chaseCam)
                {
                    CustomCam.ChaseCam   = _checked;
                    leadCam.Checked      = false;
                    droneCam.Checked     = false;
                    CustomCam.LeadCam    = false;
                    DroneCam.DroneCamVar = false;

                    if (!_checked)
                    {
                        ResetCameras();
                    }
                    else
                    {
                        CustomCam.target = CustomCam.GetClosestVehicle(2000, CustomCam.maxAngle);
                    }
                }
                if (_item == droneCam)
                {
                    DroneCam.DroneCamVar = _checked;
                    chaseCam.Checked     = false;
                    leadCam.Checked      = false;
                    CustomCam.ChaseCam   = false;
                    CustomCam.LeadCam    = false;

                    if (!_checked)
                    {
                        ResetCameras();
                    }
                }
            };
            #endregion
        }
Пример #12
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(boostersMenu);

            boostersMenu.AddMenuItem(new MenuItem(GetConfig.Langs["GoldenTitle"], GetConfig.Langs["GoldenDesc"])
            {
                Enabled = true,
            });

            boostersMenu.AddMenuItem(gmode);

            boostersMenu.AddMenuItem(tmode);

            boostersMenu.AddMenuItem(nclip);

            boostersMenu.AddMenuItem(mclip);

            boostersMenu.AddMenuItem(new MenuItem(GetConfig.Langs["HorseTitle"], GetConfig.Langs["HorseDesc"])
            {
                Enabled = true,
            });

            boostersMenu.AddMenuItem(new MenuItem(GetConfig.Langs["VehicleTitle"], GetConfig.Langs["VehicleDesc"])
            {
                Enabled = true,
            });
            boostersMenu.AddMenuItem(new MenuItem(GetConfig.Langs["InfiniteAmmoOnTitle"], GetConfig.Langs["InfiniteAmmoOnDesc"])
            {
                Enabled = true,
            });

            boostersMenu.AddMenuItem(new MenuItem(GetConfig.Langs["InfiniteAmmoOffTitle"], GetConfig.Langs["InfiniteAmmoOffDesc"])
            {
                Enabled = true,
            });

            boostersMenu.OnItemSelect += async(_menu, _item, _index) =>
            {
                if (_index == 0)
                {
                    BoosterFunctions.Golden(MainMenu.args);
                }
                else if (_index == 5)
                {
                    dynamic ped = await UtilsFunctions.GetInput(GetConfig.Langs["HorseTitle"], GetConfig.Langs["HorseTitle"]);

                    MainMenu.args.Add(ped);
                    BoosterFunctions.Horse(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 6)
                {
                    dynamic veh = await UtilsFunctions.GetInput(GetConfig.Langs["VehicleTitle"], GetConfig.Langs["VehicleDesc"]);

                    MainMenu.args.Add(veh);
                    BoosterFunctions.Vehicle(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 7)
                {
                    BoosterFunctions.InfiniteAmmo(MainMenu.args);
                }
                else if (_index == 8)
                {
                    BoosterFunctions.InfiniteAmmoOff(MainMenu.args);
                }
            };

            boostersMenu.OnCheckboxChange += (_menu, _item, _index, _checked) =>
            {
                if (_index == 3)
                {
                    BoosterFunctions.SetClip(_checked);
                    if (_checked)
                    {
                        mclip.Checked = false;
                    }
                    ;
                }
                else if (_index == 4)
                {
                    BoosterFunctions.SetClip(_checked);
                    if (_checked)
                    {
                        nclip.Checked = false;
                    }
                    ;
                }
            };
        }
Пример #13
0
        public void ExampleMenu1()
        {
            // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly.
            // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment.
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;

            // Creating the first menu.
            Menu menu = new Menu("Map Menu", "by Firecul")
            {
                Visible = true
            };

            MenuController.AddMenu(menu);


            MenuCheckboxItem hideRadar = new MenuCheckboxItem("Hide Radar", "Hide the radar/minimap.", HideRadar);

            MenuCheckboxItem playerBlips = new MenuCheckboxItem("Show Player Blips", "Shows blips on the map for all players.", ShowPlayerBlips);

            // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it).
            MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Tick
            };

            MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Cross
            };

            MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false)
            {
                Style    = MenuCheckboxItem.CheckboxStyle.Cross,
                Enabled  = false,
                LeftIcon = MenuItem.Icon.LOCK
            };

            // Adding the checkboxes to the menu.
            menu.AddMenuItem(hideRadar);
            menu.AddMenuItem(playerBlips);
            menu.AddMenuItem(box);
            menu.AddMenuItem(box2);
            menu.AddMenuItem(box3);


            /* Instructional buttons setup for the second (submenu) menu.
             * submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!");
             * submenu.InstructionalButtons.Add(Control.CreatorLS, "Buttons");
             * submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool");
             * submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!");
             * submenu.InstructionalButtons.Add(Control.Cover, "This");
             * submenu.InstructionalButtons.Add(Control.Context, "Check"); */



            /*
             ########################################################
             #                   Event handlers
             ########################################################
             */


            menu.OnCheckboxChange += (_menu, _item, _index, _checked) =>
            {
                // Code in here gets executed whenever a checkbox is toggled.
                Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]");

                // If the align-menu checkbox is toggled, toggle the menu alignment.
                if (_item == box)
                {
                    if (_checked)
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
                    }
                    else
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left;
                    }
                }
                else if (_item == hideRadar)
                {
                    HideRadar = _checked;
                    if (!_checked)
                    {
                        DisplayRadar(true);
                    }
                }
                else if (_item == playerBlips)
                {
                    ShowPlayerBlips = _checked;
                }
            };

            menu.OnItemSelect += (_menu, _item, _index) =>
            {
                // Code in here would get executed whenever an item is pressed.
                Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]");
            };

            menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed.
                Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]");
            };

            menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed).
                Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]");
            };

            menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever a list item is pressed.
                Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]");
            };

            menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed).
                Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]");
            };

            menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever a slider item is pressed.
                Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]");
            };

            menu.OnMenuClose += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is closed.
                Debug.WriteLine($"OnMenuClose: [{_menu}]");
            };

            menu.OnMenuOpen += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is opened.
                Debug.WriteLine($"OnMenuOpen: [{_menu}]");
            };
        }
Пример #14
0
        public ExampleMenu()
        {
            // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly.
            // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment.
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;

            // Creating the first menu.
            Menu menu = new Menu("Main Menu", "Subtitle")
            {
                Visible = true
            };

            MenuController.AddMenu(menu);

            // Adding a new button by directly creating one inline. You could also just store it and then add it but we don't need to do that in this example.
            menu.AddMenuItem(new MenuItem("Normal Button", "This is a simple button with a simple description. Scroll down for more button types!"));


            // Creating 3 sliders, showing off the 3 possible variations and custom colors.
            MenuSliderItem slider  = new MenuSliderItem("Slider", 0, 10, 5, false);
            MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true)
            {
                BarColor        = Color.FromArgb(255, 73, 233, 111),
                BackgroundColor = Color.FromArgb(255, 25, 100, 43)
            };
            MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true)
            {
                BarColor        = Color.FromArgb(255, 255, 0, 0),
                BackgroundColor = Color.FromArgb(255, 100, 0, 0),
                SliderLeftIcon  = MenuItem.Icon.MALE,
                SliderRightIcon = MenuItem.Icon.FEMALE
            };

            // adding the sliders to the menu.
            menu.AddMenuItem(slider);
            menu.AddMenuItem(slider2);
            menu.AddMenuItem(slider3);

            // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it).
            MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Tick
            };

            MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Cross
            };

            MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false)
            {
                Style    = MenuCheckboxItem.CheckboxStyle.Cross,
                Enabled  = false,
                LeftIcon = MenuItem.Icon.LOCK
            };

            // Adding the checkboxes to the menu.
            menu.AddMenuItem(box);
            menu.AddMenuItem(box2);
            menu.AddMenuItem(box3);

            // Dynamic list item
            string ChangeCallback(MenuDynamicListItem item, bool left)
            {
                if (left)
                {
                    return((int.Parse(item.CurrentItem) - 1).ToString());
                }
                return((int.Parse(item.CurrentItem) + 1).ToString());
            }

            MenuDynamicListItem dynList = new MenuDynamicListItem("Dynamic list item.", "0", new MenuDynamicListItem.ChangeItemCallback(ChangeCallback), "Description for this dynamic item. Pressing left will make the value smaller, pressing right will make the value bigger.");

            menu.AddMenuItem(dynList);

            // List items (first the 3 special variants, then a normal one)
            List <string> colorList = new List <string>();

            for (var i = 0; i < 64; i++)
            {
                colorList.Add($"Color #{i}");
            }
            MenuListItem hairColors = new MenuListItem("Hair Color", colorList, 0, "Hair color pallete.")
            {
                ShowColorPanel = true
            };

            // Also special
            List <string> makeupColorList = new List <string>();

            for (var i = 0; i < 64; i++)
            {
                makeupColorList.Add($"Color #{i}");
            }
            MenuListItem makeupColors = new MenuListItem("Makeup Color", makeupColorList, 0, "Makeup color pallete.")
            {
                ShowColorPanel      = true,
                ColorPanelColorType = MenuListItem.ColorPanelType.Makeup
            };

            // Also special
            List <string> opacityList = new List <string>();

            for (var i = 0; i < 11; i++)
            {
                opacityList.Add($"Opacity {i * 10}%");
            }
            MenuListItem opacity = new MenuListItem("Opacity Panel", opacityList, 0, "Set an opacity for something.")
            {
                ShowOpacityPanel = true
            };

            // Normal
            List <string> normalList = new List <string>()
            {
                "Item #1", "Item #2", "Item #3"
            };
            MenuListItem normalListItem = new MenuListItem("Normal List Item", normalList, 0, "And another simple description for yet another simple (list) item. Nothing special about this one.");

            // Adding the lists to the menu.
            menu.AddMenuItem(hairColors);
            menu.AddMenuItem(makeupColors);
            menu.AddMenuItem(opacity);
            menu.AddMenuItem(normalListItem);

            // Creating a submenu, adding it to the menus list, and creating and binding a button for it.
            Menu submenu = new Menu("Submenu", "Secondary Menu");

            MenuController.AddSubmenu(menu, submenu);

            MenuItem menuButton = new MenuItem("Submenu", "This button is bound to a submenu. Clicking it will take you to the submenu.")
            {
                Label = "→→→"
            };

            menu.AddMenuItem(menuButton);
            MenuController.BindMenuItem(menu, submenu, menuButton);

            // Adding items with sprites left & right to the submenu.
            for (var i = 0; i < 30; i++)
            {
                var tmpItem = new MenuItem($"Icon Sprite #{i}", "This menu item has a left and right sprite, and some also have a right label! Very cool huh?!");
                if (i % 4 == 0)
                {
                    tmpItem.Label = "Wowzers";
                }
                if (i % 7 == 0)
                {
                    tmpItem.Label = "Snailsome!";
                }
                tmpItem.LeftIcon  = (MenuItem.Icon)i;
                tmpItem.RightIcon = (MenuItem.Icon)i;

                submenu.AddMenuItem(tmpItem);
            }

            // Instructional buttons setup for the second (submenu) menu.
            submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!");
            submenu.InstructionalButtons.Add(Control.CreatorLS, "Buttons");
            submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool");
            submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!");
            submenu.InstructionalButtons.Add(Control.Cover, "This");
            submenu.InstructionalButtons.Add(Control.Context, "Check");

            // Create a third menu without a banner.
            Menu menu3 = new Menu(null, "Only a subtitle, no banner.");

            // you can use AddSubmenu or AddMenu, both will work but if you want to link this menu from another menu,
            // you should use AddSubmenu.
            MenuController.AddSubmenu(menu, menu3);
            MenuItem thirdSubmenuBtn = new MenuItem("Another submenu", "This is just a submenu without a banner. No big deal.")
            {
                Label = "→→→"
            };

            menu.AddMenuItem(thirdSubmenuBtn);
            MenuController.BindMenuItem(menu, menu3, thirdSubmenuBtn);
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!"));


            /*
             ########################################################
             #                   Event handlers
             ########################################################
             */


            menu.OnCheckboxChange += (_menu, _item, _index, _checked) =>
            {
                // Code in here gets executed whenever a checkbox is toggled.
                Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]");

                // If the align-menu checkbox is toggled, toggle the menu alignment.
                if (_item == box)
                {
                    if (_checked)
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
                    }
                    else
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left;
                    }
                }
            };

            menu.OnItemSelect += (_menu, _item, _index) =>
            {
                // Code in here would get executed whenever an item is pressed.
                Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]");
            };

            menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed.
                Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]");
            };

            menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed).
                Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]");
            };

            menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever a list item is pressed.
                Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]");
            };

            menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed).
                Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]");
            };

            menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever a slider item is pressed.
                Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]");
            };

            menu.OnMenuClose += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is closed.
                Debug.WriteLine($"OnMenuClose: [{_menu}]");
            };

            menu.OnMenuOpen += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is opened.
                Debug.WriteLine($"OnMenuOpen: [{_menu}]");
            };

            menu.OnDynamicListItemCurrentItemChange += (_menu, _dynamicListItem, _oldCurrentItem, _newCurrentItem) =>
            {
                // Code in here would get executed whenever the value of the current item of a dynamic list item changes.
                Debug.WriteLine($"OnDynamicListItemCurrentItemChange: [{_menu}, {_dynamicListItem}, {_oldCurrentItem}, {_newCurrentItem}]");
            };

            menu.OnDynamicListItemSelect += (_menu, _dynamicListItem, _currentItem) =>
            {
                // Code in here would get executed whenever a dynamic list item is pressed.
                Debug.WriteLine($"OnDynamicListItemSelect: [{_menu}, {_dynamicListItem}, {_currentItem}]");
            };
        }
Пример #15
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(myCartsMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            MenuController.AddSubmenu(myCartsMenu, subMenuManagmentCarts);

            MenuItem buttonSetDefaultCart = new MenuItem(GetConfig.Langs["ButtonSetDefaultHorse"], GetConfig.Langs["ButtonSetDefaultHorse"])
            {
                RightIcon = MenuItem.Icon.TICK
            };

            subMenuManagmentCarts.AddMenuItem(buttonSetDefaultCart);

            MenuItem buttonDeleteCart = new MenuItem(GetConfig.Langs["ButtonDeleteCart"], GetConfig.Langs["ButtonDeleteCart"])
            {
                RightIcon = MenuItem.Icon.LOCK
            };

            subMenuManagmentCarts.AddMenuItem(buttonDeleteCart);

            //Events

            myCartsMenu.OnMenuOpen += (_menu) => {
                myCartsMenu.ClearMenuItems();

                //MenuController.AddSubmenu(myCartsMenu, subMenuManagmentCarts);

                foreach (var mh in HorseManagment.MyCarts)
                {
                    var Icon = MenuItem.Icon.SADDLE;
                    if (mh.IsDefault())
                    {
                        Icon = MenuItem.Icon.TICK;
                    }

                    MenuItem buttonMyHorses = new MenuItem(mh.getHorseName(), GetConfig.Langs[mh.getHorseModel()])
                    {
                        RightIcon = Icon,
                    };

                    myCartsMenu.AddMenuItem(buttonMyHorses);
                    MenuController.BindMenuItem(myCartsMenu, subMenuManagmentCarts, buttonMyHorses);
                }
            };

            myCartsMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                StablesShop.indexCartSelected   = _index;
                subMenuManagmentCarts.MenuTitle = HorseManagment.MyCarts[_index].getHorseName();
                if (HorseManagment.MyCarts[_index].IsDefault())
                {
                    buttonSetDefaultCart.Enabled = false;
                }
                else
                {
                    buttonSetDefaultCart.Enabled = true;
                }
            };

            subMenuManagmentCarts.OnItemSelect += (_menu, _item, _index) =>
            {
                switch (_index)
                {
                case 0:
                    HorseManagment.MyCarts[StablesShop.indexCartSelected].setDefault(true);
                    MenuController.CloseAllMenus();
                    break;

                case 1:
                    StablesShop.DeleteMyCart(StablesShop.indexCartSelected);
                    MenuController.CloseAllMenus();
                    break;
                }
            };
        }
Пример #16
0
        public CallMenu()
        {
            ///////////////////////////////////////////////////////////////
            //////////////////////  [ First Screen ] //////////////////////
            ///////////////////////////////////////////////////////////////

            // Align the menu to the left side of the screen
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left;

            MenuController.MenuToggleKey = Control.VehicleBikeWings;

            // Create the first screen of the menu then add it to the menu controller
            Menu mainCallMenu = new Menu("Emergency Services", "What emergency service do you require?");

            MenuController.AddMenu(mainCallMenu);

            // Create the options for the first screen

            // Police
            mainCallMenu.AddMenuItem(new MenuItem("Police", "Request police assistance")
            {
                Enabled = true
            });

            // Ambulance
            mainCallMenu.AddMenuItem(new MenuItem("Ambulance", "Request EMS assistance")
            {
                Enabled = true
            });

            // Fire
            mainCallMenu.AddMenuItem(new MenuItem("Fire", "Request fire service assistance")
            {
                Enabled = true
            });

            // Events
            EventHandlers["EDS:OpenCallMenu"] += new Action(mainCallMenu.OpenMenu);

            mainCallMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                switch (_index)
                {
                case 0:
                    DisplayOnscreenKeyboard(0, "What is your emergency?", "", "", "", "", "", 128);
                    selectedService = DispatchNotificationType.POLICE;
                    Tick           += GetUserDispatchMessage;
                    break;

                case 1:
                    DisplayOnscreenKeyboard(0, "What is your emergency?", "", "", "", "", "", 128);
                    selectedService = DispatchNotificationType.AMBULANCE;
                    Tick           += GetUserDispatchMessage;
                    break;

                case 2:
                    DisplayOnscreenKeyboard(0, "What is your emergency?", "", "", "", "", "", 128);
                    selectedService = DispatchNotificationType.FIRE;
                    Tick           += GetUserDispatchMessage;
                    break;
                }
            };
        }
Пример #17
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(mainMenu);

            string keyPress = GetConfig.Config["key"].ToString();
            int    KeyInt   = Convert.ToInt32(keyPress, 16);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)KeyInt;

            //Administration
            MenuController.AddSubmenu(mainMenu, Administration.GetMenu());

            MenuItem subMenuAdministrationBtn = new MenuItem(GetConfig.Langs["MenuAdministrationTitle"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuAdministrationBtn);
            MenuController.BindMenuItem(mainMenu, Administration.GetMenu(), subMenuAdministrationBtn);

            //Boosters
            if (GetUserInfo.userGroup.Contains("admin"))
            {
                MenuController.AddSubmenu(mainMenu, Boosters.GetMenu());

                MenuItem subMenuBoostersBtn = new MenuItem(GetConfig.Langs["MenuBoostersTitle"], " ")
                {
                    RightIcon = MenuItem.Icon.ARROW_RIGHT
                };

                mainMenu.AddMenuItem(subMenuBoostersBtn);
                MenuController.BindMenuItem(mainMenu, Boosters.GetMenu(), subMenuBoostersBtn);
            }

            //Notifications
            MenuController.AddSubmenu(mainMenu, Notifications.GetMenu());

            MenuItem subMenuNotificationsBtn = new MenuItem(GetConfig.Langs["MenuNotificationsTitle"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuNotificationsBtn);
            MenuController.BindMenuItem(mainMenu, Notifications.GetMenu(), subMenuNotificationsBtn);

            //Teleports
            MenuController.AddSubmenu(mainMenu, Teleports.GetMenu());

            MenuItem subMenuTeleportsBtn = new MenuItem(GetConfig.Langs["MenuTeleportsTitle"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuTeleportsBtn);
            MenuController.BindMenuItem(mainMenu, Teleports.GetMenu(), subMenuTeleportsBtn);

            //Database
            if (GetUserInfo.userGroup.Contains("admin"))
            {
                MenuController.AddSubmenu(mainMenu, Database.GetMenu());

                MenuItem subMenuDatabaseBtn = new MenuItem(GetConfig.Langs["MenuDatabaseTitle"], " ")
                {
                    RightIcon = MenuItem.Icon.ARROW_RIGHT
                };

                mainMenu.AddMenuItem(subMenuDatabaseBtn);
                MenuController.BindMenuItem(mainMenu, Database.GetMenu(), subMenuDatabaseBtn);
            }
        }
Пример #18
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(manageAmmoMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            ////SubMenu Ammo Restock
            //MenuController.AddSubmenu(manageAmmoMenu, ManageAmmoMenu.GetMenu());
            //MenuItem restockAmmo = new MenuItem(GetConfig.Langs["MenuManageAmmo"], "")
            //{
            //    LeftIcon = MenuItem.Icon.ARROW_RIGHT
            //};

            //manageAmmoMenu.AddMenuItem(restockAmmo);
            //MenuController.BindMenuItem(manageAmmoMenu, ManageAmmoMenu.GetMenu(), restockAmmo);
            ////end

            manageAmmoMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                var myWp = GetConfig.PlayerWeapons.ElementAt(ManageWeaponsMenu.indexItem);
                var wpc  = GetConfig.Config["Weapons"].FirstOrDefault(x => x["HashName"].ToString().Contains(myWp["name"].ToString()));
                Dictionary <string, double> ammoType = new Dictionary <string, double>();

                foreach (JObject ammoc in wpc["AmmoHash"].Children <JObject>())
                {
                    foreach (JProperty ammo in ammoc.Properties())
                    {
                        ammoType.Add(ammo.Name, ammo.Value.ToObject <double>());
                    }
                }

                string AmmoType   = ammoType.ElementAt(_index).Key;
                string ammoSyntax = $"\"{AmmoType}\"";
                if (myWp["ammo"].Any(x => x.ToString().Contains(ammoSyntax)))
                {
                    int ammoQ = myWp["ammo"].FirstOrDefault(x => x.ToString().Contains(ammoSyntax)).ToObject <int>();
                    if (ammoQ < GetConfig.Config["AmmoLimit"][0][AmmoType].ToObject <int>())
                    {
                        int    ammoNeeded = GetConfig.Config["AmmoLimit"][0][AmmoType].ToObject <int>() - ammoQ;
                        double cost       = (double)ammoNeeded * ammoType.ElementAt(_index).Value;
                        ActionStore.RestockWeaponAmmo(myWp["id"].ToObject <int>(), cost, AmmoType, ammoNeeded);
                    }
                    else
                    {
                        //Nada
                    }
                }
                else
                {
                    double cost = GetConfig.Config["AmmoLimit"][0][AmmoType].ToObject <int>() * ammoType.ElementAt(_index).Value;
                    ActionStore.RestockWeaponAmmo(myWp["id"].ToObject <int>(), cost, AmmoType, GetConfig.Config["AmmoLimit"][0][AmmoType].ToObject <int>());
                }

                _item.Label   = "Comprado";
                _item.Enabled = false;
            };

            manageAmmoMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                //ActionStore.CreateObjectOnTable(_newIndex, "Manage", ActionStore.ObjectStore);
            };

            manageAmmoMenu.OnMenuOpen += (_menu) =>
            {
                var myWp = GetConfig.PlayerWeapons.ElementAt(ManageWeaponsMenu.indexItem);
                var wpc  = GetConfig.Config["Weapons"].FirstOrDefault(x => x["HashName"].ToString().Equals(myWp["name"].ToString()));

                foreach (JObject ammoc in wpc["AmmoHash"].Children <JObject>())
                {
                    foreach (JProperty ammo in ammoc.Properties())
                    {
                        string ammoSyntax = $"\"{ammo.Name}\"";
                        if (myWp["ammo"].Any(x => x.ToString().Contains(ammoSyntax)))
                        {
                            int ammoQ = myWp["ammo"].FirstOrDefault(x => x.ToString().Contains(ammoSyntax)).ToObject <int>();
                            if (ammoQ < GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <int>())
                            {
                                int      ammoNeeded     = GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <int>() - ammoQ;
                                double   cost           = (double)ammoNeeded * ammo.Value.ToObject <double>();
                                MenuItem _ammoToRestock = new MenuItem(GetConfig.Langs[ammo.Name] + " " + string.Format(GetConfig.Langs["ManageAmmoRestockBtnRestock"], ammoQ.ToString(), GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <string>(), cost.ToString()), "")
                                {
                                    Enabled = true
                                };

                                manageAmmoMenu.AddMenuItem(_ammoToRestock);
                            }
                            else
                            {
                                MenuItem _ammoToRestock = new MenuItem(GetConfig.Langs[ammo.Name] + " " + string.Format(GetConfig.Langs["ManageAmmoRestockBtnRestock"], ammoQ.ToString(), GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <string>(), "0"), "")
                                {
                                    Enabled = false
                                };

                                manageAmmoMenu.AddMenuItem(_ammoToRestock);
                            }
                        }
                        else
                        {
                            double   cost           = GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <double>() * ammo.Value.ToObject <double>();
                            MenuItem _ammoToRestock = new MenuItem(GetConfig.Langs[ammo.Name] + " " + string.Format(GetConfig.Langs["ManageAmmoRestockBtnRestock"], "0", GetConfig.Config["AmmoLimit"][0][ammo.Name].ToObject <string>(), cost.ToString()), "")
                            {
                                Enabled = true
                            };

                            manageAmmoMenu.AddMenuItem(_ammoToRestock);
                        }
                    }
                }
                //ActionStore.CreateObjectOnTable(_menu.CurrentIndex, "Manage", ActionStore.ObjectStore);
            };

            manageAmmoMenu.OnMenuClose += (_menu) =>
            {
                manageAmmoMenu.ClearMenuItems();
            };
        }
Пример #19
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(playersListMenu);

            playersListMenu.OnMenuOpen += (_menu) =>
            {
                playersListMenu.ClearMenuItems();
                idPlayers.Clear();
                foreach (var i in API.GetActivePlayers())
                {
                    string name = API.GetPlayerName(i).ToString();
                    string id   = API.GetPlayerServerId(i).ToString();
                    idPlayers.Add(i);
                    MenuController.AddSubmenu(playersListMenu, playersOptionsMenu);

                    MenuItem playerNameButton = new MenuItem(name, $"{name},{id}")
                    {
                        RightIcon = MenuItem.Icon.ARROW_RIGHT
                    };
                    playersListMenu.AddMenuItem(playerNameButton);
                    MenuController.BindMenuItem(playersListMenu, playersOptionsMenu, playerNameButton);
                }
            };

            playersListMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                indexPlayer = _index;
                playersOptionsMenu.MenuTitle = API.GetPlayerName(idPlayers.ElementAt(indexPlayer)) + "," + API.GetPlayerServerId((idPlayers.ElementAt(indexPlayer)));
            };

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitle"], GetConfig.Langs["SpectateDesc"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SpectateTitleOff"], GetConfig.Langs["SpectateDescOff"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["ReviveTitle"], GetConfig.Langs["ReviveDesc"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["HealTitle"], GetConfig.Langs["HealDesc"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["TpToPlayerTitle"], GetConfig.Langs["TpToPlayerDesc"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["BringPlayerTitle"], GetConfig.Langs["BringPlayerDesc"])
            {
                Enabled = true,
            });

            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FreezeTitle"], GetConfig.Langs["FreezeDesc"])
            {
                Enabled = true,
            });
            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["KickPlayerTitle"], GetConfig.Langs["KickPlayerDesc"])
            {
                Enabled = true,
            });
            playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerDesc"])
            {
                Enabled = true,
            });
            if (GetUserInfo.userGroup.Contains("admin"))
            {
                playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["SlapTitle"], GetConfig.Langs["SlapDesc"])
                {
                    Enabled = true,
                });
                playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["LightningTitle"], GetConfig.Langs["LightningDesc"])
                {
                    Enabled = true,
                });
                playersOptionsMenu.AddMenuItem(new MenuItem(GetConfig.Langs["FireTitle"], GetConfig.Langs["FireDesc"])
                {
                    Enabled = true,
                });
            }



            playersOptionsMenu.OnItemSelect += async(_menu, _item, _index) =>
            {
                if (_index == 0)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.Spectate(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 1)
                {
                    AdministrationFunctions.SpectateOff(MainMenu.args);
                }
                else if (_index == 2)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.Revive(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 3)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.Heal(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 4)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    TeleportsFunctions.TpToPlayer(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 5)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    TeleportsFunctions.TpBring(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 6)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.StopPlayer(MainMenu.args);
                    MainMenu.args.Clear();
                }

                else if (_index == 7)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.Kick(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 8)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic time = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerTime"]);

                    MainMenu.args.Add(time);
                    dynamic reason = await UtilsFunctions.GetInput(GetConfig.Langs["BanPlayerTitle"], GetConfig.Langs["BanPlayerReason"]);

                    MainMenu.args.Add(reason);
                    AdministrationFunctions.Ban(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 9)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.Slap(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 10)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.ThorToId(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 11)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    AdministrationFunctions.FireToId(MainMenu.args);
                    MainMenu.args.Clear();
                }
            };
        }
Пример #20
0
        public static void CreateMenu()
        {
            //Creating props Menu
            MenuController.AddMenu(PropsMenu);

            #region props options menu
            string[] propNames = new string[5] {
                "Hats & Helmets", "Glasses", "Misc Props", "Watches", "Bracelets"
            };
            for (int x = 0; x < 5; x++)
            {
                int propId = x;
                if (x > 2)
                {
                    propId += 3;
                }

                int currentProp        = Functions.IsEdidtingPed && Functions.CurrentCharacter.PropVariations.Props.ContainsKey(propId) ? Functions.CurrentCharacter.PropVariations.Props[propId].Key : GetPedPropIndex(Game.PlayerPed.Handle, propId);
                int currentPropTexture = Functions.IsEdidtingPed && Functions.CurrentCharacter.PropVariations.Props.ContainsKey(propId) ? Functions.CurrentCharacter.PropVariations.Props[propId].Value : GetPedPropTextureIndex(Game.PlayerPed.Handle, propId);

                List <string> propsList = new List <string>();
                for (int i = 0; i < GetNumberOfPedPropDrawableVariations(Game.PlayerPed.Handle, propId); i++)
                //for (int i = 0; i < 11; i++)
                {
                    propsList.Add($"Prop #{i} (of {GetNumberOfPedPropDrawableVariations(Game.PlayerPed.Handle, propId)})");
                }
                propsList.Add("No Prop");

                if (GetPedPropIndex(Game.PlayerPed.Handle, propId) != -1)
                {
                    int          maxPropTextures = GetNumberOfPedPropTextureVariations(Game.PlayerPed.Handle, propId, currentProp);
                    MenuListItem propListItem    = new MenuListItem($"{propNames[x]}", propsList, currentProp, $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{currentPropTexture + 1} (of {maxPropTextures}).");
                    PropsMenu.AddMenuItem(propListItem);
                }
                else
                {
                    MenuListItem propListItem = new MenuListItem($"{propNames[x]}", propsList, currentProp, "Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures.");
                    PropsMenu.AddMenuItem(propListItem);
                }
            }
            #endregion

            #region props
            PropsMenu.OnListIndexChange += (_menu, listItem, oldSelectionIndex, newSelectionIndex, realIndex) =>
            {
                int propIndex = realIndex;
                if (realIndex == 3)
                {
                    propIndex = 6;
                }
                if (realIndex == 4)
                {
                    propIndex = 7;
                }

                int textureIndex = 0;
                if (newSelectionIndex >= GetNumberOfPedPropDrawableVariations(Game.PlayerPed.Handle, propIndex))
                {
                    SetPedPropIndex(Game.PlayerPed.Handle, propIndex, -1, -1, false);
                    ClearPedProp(Game.PlayerPed.Handle, propIndex);
                    if (Functions.CurrentCharacter.PropVariations.Props == null)
                    {
                        Functions.CurrentCharacter.PropVariations.Props = new Dictionary <int, KeyValuePair <int, int> >();
                    }
                    Functions.CurrentCharacter.PropVariations.Props[propIndex] = new KeyValuePair <int, int>(-1, -1);
                    listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures.";
                }
                else
                {
                    SetPedPropIndex(Game.PlayerPed.Handle, propIndex, newSelectionIndex, textureIndex, true);
                    if (Functions.CurrentCharacter.PropVariations.Props == null)
                    {
                        Functions.CurrentCharacter.PropVariations.Props = new Dictionary <int, KeyValuePair <int, int> >();
                    }
                    Functions.CurrentCharacter.PropVariations.Props[propIndex] = new KeyValuePair <int, int>(newSelectionIndex, textureIndex);
                    if (GetPedPropIndex(Game.PlayerPed.Handle, propIndex) == -1)
                    {
                        listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures.";
                    }
                    else
                    {
                        int maxPropTextures = GetNumberOfPedPropTextureVariations(Game.PlayerPed.Handle, propIndex, newSelectionIndex);
                        listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{textureIndex + 1} (of {maxPropTextures}).";
                    }
                }
            };

            PropsMenu.OnListItemSelect += (sender, listItem, listIndex, realIndex) =>
            {
                int propIndex = realIndex;
                if (realIndex == 3)
                {
                    propIndex = 6;
                }
                if (realIndex == 4)
                {
                    propIndex = 7;
                }

                int textureIndex    = GetPedPropTextureIndex(Game.PlayerPed.Handle, propIndex);
                int newTextureIndex = (GetNumberOfPedPropTextureVariations(Game.PlayerPed.Handle, propIndex, listIndex) - 1) < (textureIndex + 1) ? 0 : textureIndex + 1;
                if (textureIndex >= GetNumberOfPedPropDrawableVariations(Game.PlayerPed.Handle, propIndex))
                {
                    SetPedPropIndex(Game.PlayerPed.Handle, propIndex, -1, -1, false);
                    ClearPedProp(Game.PlayerPed.Handle, propIndex);
                    if (Functions.CurrentCharacter.PropVariations.Props == null)
                    {
                        Functions.CurrentCharacter.PropVariations.Props = new Dictionary <int, KeyValuePair <int, int> >();
                    }
                    Functions.CurrentCharacter.PropVariations.Props[propIndex] = new KeyValuePair <int, int>(-1, -1);
                    listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures.";
                }
                else
                {
                    SetPedPropIndex(Game.PlayerPed.Handle, propIndex, listIndex, newTextureIndex, true);
                    if (Functions.CurrentCharacter.PropVariations.Props == null)
                    {
                        Functions.CurrentCharacter.PropVariations.Props = new Dictionary <int, KeyValuePair <int, int> >();
                    }
                    Functions.CurrentCharacter.PropVariations.Props[propIndex] = new KeyValuePair <int, int>(listIndex, newTextureIndex);
                    if (GetPedPropIndex(Game.PlayerPed.Handle, propIndex) == -1)
                    {
                        listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures.";
                    }
                    else
                    {
                        int maxPropTextures = GetNumberOfPedPropTextureVariations(Game.PlayerPed.Handle, propIndex, listIndex);
                        listItem.Description = $"Select a prop using the arrow keys and press ~o~enter~s~ to cycle through all available textures. Currently selected texture: #{newTextureIndex + 1} (of {maxPropTextures}).";
                    }
                }
                //PropsMenu.UpdateScaleform();
            };
            #endregion
        }
Пример #21
0
        public static void CreateMenu()
        {
            //Creating face features Menu
            MenuController.AddMenu(FaceFeaturesMenu);

            #region face features menu
            foreach (MenuSliderItem item in FaceFeaturesMenu.GetMenuItems())
            {
                if (Functions.IsEdidtingPed)
                {
                    if (Functions.CurrentCharacter.FaceShapeFeatures.features == null)
                    {
                        Functions.CurrentCharacter.FaceShapeFeatures.features = new Dictionary <int, float>();
                    }
                    else
                    {
                        if (Functions.CurrentCharacter.FaceShapeFeatures.features.ContainsKey(item.Index))
                        {
                            item.Position = (int)(Functions.CurrentCharacter.FaceShapeFeatures.features[item.Index] * 10f) + 10;
                            SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, Functions.CurrentCharacter.FaceShapeFeatures.features[item.Index]);
                        }
                        else
                        {
                            item.Position = 10;
                            SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, 0f);
                        }
                    }
                }
                else
                {
                    item.Position = 10;
                    SetPedFaceFeature(Game.PlayerPed.Handle, item.Index, 0f);
                }
            }
            #endregion

            #region face shape data

            /*
             * Nose_Width
             * Nose_Peak_Hight
             * Nose_Peak_Lenght
             * Nose_Bone_High
             * Nose_Peak_Lowering
             * Nose_Bone_Twist
             * EyeBrown_High
             * EyeBrown_Forward
             * Cheeks_Bone_High
             * Cheeks_Bone_Width
             * Cheeks_Width
             * Eyes_Openning
             * Lips_Thickness
             * Jaw_Bone_Width 'Bone size to sides
             * Jaw_Bone_Back_Lenght 'Bone size to back
             * Chimp_Bone_Lowering 'Go Down
             * Chimp_Bone_Lenght 'Go forward
             * Chimp_Bone_Width
             * Chimp_Hole
             * Neck_Thikness
             */

            List <float> faceFeaturesValuesList = new List <float>()
            {
                -1.0f,   // 0
                -0.9f,   // 1
                -0.8f,   // 2
                -0.7f,   // 3
                -0.6f,   // 4
                -0.5f,   // 5
                -0.4f,   // 6
                -0.3f,   // 7
                -0.2f,   // 8
                -0.1f,   // 9
                0.0f,    // 10
                0.1f,    // 11
                0.2f,    // 12
                0.3f,    // 13
                0.4f,    // 14
                0.5f,    // 15
                0.6f,    // 16
                0.7f,    // 17
                0.8f,    // 18
                0.9f,    // 19
                1.0f     // 20
            };

            var faceFeaturesNamesList = new string[20]
            {
                "Nose Width",               // 0
                "Noes Peak Height",         // 1
                "Nose Peak Length",         // 2
                "Nose Bone Height",         // 3
                "Nose Peak Lowering",       // 4
                "Nose Bone Twist",          // 5
                "Eyebrows Height",          // 6
                "Eyebrows Depth",           // 7
                "Cheekbones Height",        // 8
                "Cheekbones Width",         // 9
                "Cheeks Width",             // 10
                "Eyes Opening",             // 11
                "Lips Thickness",           // 12
                "Jaw Bone Width",           // 13
                "Jaw Bone Depth/Length",    // 14
                "Chin Height",              // 15
                "Chin Depth/Length",        // 16
                "Chin Width",               // 17
                "Chin Hole Size",           // 18
                "Neck Thickness"            // 19
            };

            for (int i = 0; i < 20; i++)
            {
                MenuSliderItem faceFeature = new MenuSliderItem(faceFeaturesNamesList[i], $"Set the {faceFeaturesNamesList[i]} face feature value.", 0, 20, 10, true);
                FaceFeaturesMenu.AddMenuItem(faceFeature);
            }

            FaceFeaturesMenu.OnSliderPositionChange += (sender, sliderItem, oldPosition, newPosition, itemIndex) =>
            {
                if (Functions.CurrentCharacter.FaceShapeFeatures.features == null)
                {
                    Functions.CurrentCharacter.FaceShapeFeatures.features = new Dictionary <int, float>();
                }
                float value = faceFeaturesValuesList[newPosition];
                Functions.CurrentCharacter.FaceShapeFeatures.features[itemIndex] = value;
                SetPedFaceFeature(Game.PlayerPed.Handle, itemIndex, value);
            };

            #endregion
        }
Пример #22
0
        /// <summary>
        /// OnTick to run the menu functions.
        /// </summary>
        /// <returns></returns>
        private async Task OnTick()
        {
            // Setup is not done or cf is null.
            if (!setupDone)
            {
                Setup();

                // wait for setup in MainMenu (permissions and addons) to be done before adding the noclip menu.
                while (!MainMenu.ConfigOptionsSetupComplete || !MainMenu.PermissionsSetupComplete)
                {
                    await Delay(0);
                }
                // Add the noclip menu
                MenuController.AddMenu(noclipMenu);
            }
            // Setup is done.
            else
            {
                if (noclipMenu == null)
                {
                    await Delay(0);
                }
                else
                {
                    while (MainMenu.NoClipEnabled)
                    {
                        noclipMenu.InstructionalButtons[Control.Sprint] = $"Change speed ({speeds[currentSpeed]})";
                        var noclipEntity = Game.PlayerPed.IsInVehicle() ? GetVehicle().Handle : Game.PlayerPed.Handle;

                        if (noclipMenu.Visible == false)
                        {
                            noclipMenu.OpenMenu();
                        }
                        FreezeEntityPosition(noclipEntity, true);
                        SetEntityInvincible(noclipEntity, true);

                        Vector3 newPos = GetEntityCoords(noclipEntity, true);
                        Game.DisableControlThisFrame(0, Control.MoveUpOnly);
                        Game.DisableControlThisFrame(0, Control.MoveUp);
                        Game.DisableControlThisFrame(0, Control.MoveUpDown);
                        Game.DisableControlThisFrame(0, Control.MoveDown);
                        Game.DisableControlThisFrame(0, Control.MoveDownOnly);
                        Game.DisableControlThisFrame(0, Control.MoveLeft);
                        Game.DisableControlThisFrame(0, Control.MoveLeftOnly);
                        Game.DisableControlThisFrame(0, Control.MoveLeftRight);
                        Game.DisableControlThisFrame(0, Control.MoveRight);
                        Game.DisableControlThisFrame(0, Control.MoveRightOnly);
                        Game.DisableControlThisFrame(0, Control.Cover);
                        Game.DisableControlThisFrame(0, Control.MultiplayerInfo);

                        //var xoff = 0.0f;
                        var yoff = 0.0f;
                        var zoff = 0.0f;

                        if (Game.CurrentInputMode == InputMode.MouseAndKeyboard && UpdateOnscreenKeyboard() != 0)
                        {
                            if (Game.IsControlJustPressed(0, Control.Sprint))
                            {
                                currentSpeed++;
                                if (currentSpeed == speeds.Count)
                                {
                                    currentSpeed = 0;
                                }
                                noclipMenu.GetMenuItems()[0].Label = speeds[currentSpeed];
                            }

                            if (Game.IsDisabledControlPressed(0, Control.MoveUpOnly))
                            {
                                yoff = 0.5f;
                            }
                            if (Game.IsDisabledControlPressed(0, Control.MoveDownOnly))
                            {
                                yoff = -0.5f;
                            }
                            if (Game.IsDisabledControlPressed(0, Control.MoveLeftOnly))
                            {
                                SetEntityHeading(Game.PlayerPed.Handle, GetEntityHeading(Game.PlayerPed.Handle) + 3f);
                            }
                            if (Game.IsDisabledControlPressed(0, Control.MoveRightOnly))
                            {
                                SetEntityHeading(Game.PlayerPed.Handle, GetEntityHeading(Game.PlayerPed.Handle) - 3f);
                            }
                            if (Game.IsDisabledControlPressed(0, Control.Cover))
                            {
                                zoff = 0.21f;
                            }
                            if (Game.IsDisabledControlPressed(0, Control.MultiplayerInfo))
                            {
                                zoff = -0.21f;
                            }
                        }
                        float moveSpeed = (float)currentSpeed;
                        if (currentSpeed > speeds.Count / 2)
                        {
                            moveSpeed *= 1.8f;
                        }
                        newPos = GetOffsetFromEntityInWorldCoords(noclipEntity, 0f, yoff * (moveSpeed + 0.3f), zoff * (moveSpeed + 0.3f));

                        var heading = GetEntityHeading(noclipEntity);
                        SetEntityVelocity(noclipEntity, 0f, 0f, 0f);
                        SetEntityRotation(noclipEntity, 0f, 0f, 0f, 0, false);
                        SetEntityHeading(noclipEntity, heading);

                        //if (!((yoff > -0.01f && yoff < 0.01f) && (zoff > -0.01f && zoff < 0.01f)))
                        {
                            SetEntityCollision(noclipEntity, false, false);
                            SetEntityCoordsNoOffset(noclipEntity, newPos.X, newPos.Y, newPos.Z, true, true, true);
                        }

                        // After the next game tick, reset the entity properties.
                        await Delay(0);

                        FreezeEntityPosition(noclipEntity, false);
                        SetEntityInvincible(noclipEntity, false);
                        SetEntityCollision(noclipEntity, true, true);
                    }

                    if (noclipMenu.Visible && !MainMenu.NoClipEnabled)
                    {
                        noclipMenu.CloseMenu();
                    }
                }
            }
        }
Пример #23
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(playersListDatabaseMenu);


            playersListDatabaseMenu.OnMenuOpen += (_menu) =>
            {
                playersListDatabaseMenu.ClearMenuItems();
                idPlayers.Clear();
                foreach (var i in API.GetActivePlayers())
                {
                    string name = API.GetPlayerName(i).ToString();
                    string id   = API.GetPlayerServerId(i).ToString();
                    idPlayers.Add(i);
                    MenuController.AddSubmenu(playersListDatabaseMenu, playersOptionsDatabaseMenu);

                    MenuItem playerNameDatabaseButton = new MenuItem(name, $"{name},{id}")
                    {
                        RightIcon = MenuItem.Icon.ARROW_RIGHT
                    };
                    playersListDatabaseMenu.AddMenuItem(playerNameDatabaseButton);
                    MenuController.BindMenuItem(playersListDatabaseMenu, playersOptionsDatabaseMenu, playerNameDatabaseButton);
                }
            };
            playersListDatabaseMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                indexPlayer = _index;
                playersOptionsDatabaseMenu.MenuTitle = API.GetPlayerName(idPlayers.ElementAt(indexPlayer)) + "," + API.GetPlayerServerId((idPlayers.ElementAt(indexPlayer)));
            };

            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddMoneyTitle"], GetConfig.Langs["AddMoneyDesc"])
            {
                Enabled = true,
            });
            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["DelMoneyDesc"])
            {
                Enabled = true,
            });
            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["AddXpDesc"])
            {
                Enabled = true,
            });
            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelXpTitle"], GetConfig.Langs["DelXpDesc"])
            {
                Enabled = true,
            });
            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddItemTitle"], GetConfig.Langs["AddItemDesc"])
            {
                Enabled = true,
            });
            playersOptionsDatabaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddWeaponTitle"], GetConfig.Langs["AddWeaponDesc"])
            {
                Enabled = true,
            });



            MenuController.AddSubmenu(playersOptionsDatabaseMenu, Inventory.Inventory.GetMenu());

            MenuItem subMenuInventoryBtn = new MenuItem(GetConfig.Langs["InventoryTitle"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            playersOptionsDatabaseMenu.AddMenuItem(subMenuInventoryBtn);
            MenuController.BindMenuItem(playersOptionsDatabaseMenu, Inventory.Inventory.GetMenu(), subMenuInventoryBtn);


            playersOptionsDatabaseMenu.OnItemSelect += async(_menu, _item, _index) =>
            {
                if (_index == 0)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]);

                    MainMenu.args.Add(type);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddMoney(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 1)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]);

                    MainMenu.args.Add(type);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.RemoveMoney(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 2)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddXp(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 3)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.RemoveXp(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 4)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic item = await UtilsFunctions.GetInput(GetConfig.Langs["ItemName"], GetConfig.Langs["ItemName"]);

                    MainMenu.args.Add(item);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddItem(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 5)
                {
                    MainMenu.args.Add(API.GetPlayerServerId(idPlayers.ElementAt(indexPlayer)));
                    dynamic weaponName = await UtilsFunctions.GetInput(GetConfig.Langs["WeaponName"], GetConfig.Langs["WeaponName"]);

                    dynamic ammoName = await UtilsFunctions.GetInput(GetConfig.Langs["Weaponammo"], GetConfig.Langs["Weaponammo"]);

                    dynamic ammoQuantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(weaponName);
                    MainMenu.args.Add(ammoName);
                    MainMenu.args.Add(ammoQuantity);
                    DatabaseFunctions.AddWeapon(MainMenu.args);
                    MainMenu.args.Clear();
                }
            };
        }
Пример #24
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(databaseMenu);

            MenuController.AddSubmenu(databaseMenu, Players.PlayersDatabase.GetMenu());

            MenuItem subMenuPlayersDatabaseBtn = new MenuItem(GetConfig.Langs["PlayersListTitle"], " ")
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            databaseMenu.AddMenuItem(subMenuPlayersDatabaseBtn);
            MenuController.BindMenuItem(databaseMenu, Players.PlayersDatabase.GetMenu(), subMenuPlayersDatabaseBtn);

            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddMoneyTitle"], GetConfig.Langs["AddMoneyDesc"])
            {
                Enabled = true,
            });
            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["DelMoneyDesc"])
            {
                Enabled = true,
            });
            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["AddXpDesc"])
            {
                Enabled = true,
            });
            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["DelXpTitle"], GetConfig.Langs["DelXpDesc"])
            {
                Enabled = true,
            });

            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddItemTitle"], GetConfig.Langs["AddItemDesc"])
            {
                Enabled = true,
            });
            databaseMenu.AddMenuItem(new MenuItem(GetConfig.Langs["AddWeaponTitle"], GetConfig.Langs["AddWeaponDesc"])
            {
                Enabled = true,
            });

            databaseMenu.OnItemSelect += async(_menu, _item, _index) =>
            {
                if (_index == 1)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddMoneyTitle"], GetConfig.Langs["ID"]);

                    MainMenu.args.Add(idPlayer);
                    dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]);

                    MainMenu.args.Add(type);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddMoney(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 2)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["DelMoneyTitle"], GetConfig.Langs["ID"]);

                    MainMenu.args.Add(idPlayer);
                    dynamic type = await UtilsFunctions.GetInput(GetConfig.Langs["TypeOfMoneyTitle"], GetConfig.Langs["TypeOfMoneyDesc"]);

                    MainMenu.args.Add(type);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.RemoveMoney(MainMenu.args);
                    MainMenu.args.Clear();
                }
                if (_index == 3)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["ID"]);

                    MainMenu.args.Add(idPlayer);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddXp(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 4)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["AddXpTitle"], GetConfig.Langs["ID"]);

                    MainMenu.args.Add(idPlayer);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.RemoveXp(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 5)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["ID"], GetConfig.Langs["ID"]);

                    MainMenu.args.Add(idPlayer);
                    dynamic item = await UtilsFunctions.GetInput(GetConfig.Langs["ItemName"], GetConfig.Langs["ItemName"]);

                    MainMenu.args.Add(item);
                    dynamic quantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(quantity);
                    DatabaseFunctions.AddItem(MainMenu.args);
                    MainMenu.args.Clear();
                }
                else if (_index == 6)
                {
                    dynamic idPlayer = await UtilsFunctions.GetInput(GetConfig.Langs["ID"], GetConfig.Langs["ID"]);

                    dynamic weaponName = await UtilsFunctions.GetInput(GetConfig.Langs["WeaponName"], GetConfig.Langs["WeaponName"]);

                    dynamic ammoName = await UtilsFunctions.GetInput(GetConfig.Langs["Weaponammo"], GetConfig.Langs["Weaponammo"]);

                    dynamic ammoQuantity = await UtilsFunctions.GetInput(GetConfig.Langs["Quantity"], GetConfig.Langs["Quantity"]);

                    MainMenu.args.Add(idPlayer);
                    MainMenu.args.Add(weaponName);
                    MainMenu.args.Add(ammoName);
                    MainMenu.args.Add(ammoQuantity);
                    DatabaseFunctions.AddWeapon(MainMenu.args);
                    MainMenu.args.Clear();
                }
            };
        }
Пример #25
0
        public ExampleMenu()
        {
#if FIVEM
            // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly.
            // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment.
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
#endif

            // Creating the first menu.
            Menu menu = new Menu("Main Menu", "Subtitle");
            MenuController.AddMenu(menu);

            // Adding a new button by directly creating one inline. You could also just store it and then add it but we don't need to do that in this example.
            menu.AddMenuItem(new MenuItem("Normal Button", "This is a simple button with a simple description. Scroll down for more button types!")
            {
                Enabled  = false,
                LeftIcon = MenuItem.Icon.TICK
            });

#if FIVEM
            // Creating 3 sliders, showing off the 3 possible variations and custom colors.
            MenuSliderItem slider  = new MenuSliderItem("Slider", 0, 10, 5, false);
            MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true)
            {
                BarColor        = System.Drawing.Color.FromArgb(255, 73, 233, 111),
                BackgroundColor = System.Drawing.Color.FromArgb(255, 25, 100, 43)
            };
            MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true)
            {
                BarColor        = System.Drawing.Color.FromArgb(255, 255, 0, 0),
                BackgroundColor = System.Drawing.Color.FromArgb(255, 100, 0, 0),

                SliderLeftIcon  = MenuItem.Icon.MALE,
                SliderRightIcon = MenuItem.Icon.FEMALE
            };
            // adding the sliders to the menu.
            menu.AddMenuItem(slider);
            menu.AddMenuItem(slider2);
            menu.AddMenuItem(slider3);
#endif

#if FIVEM
            // Creating 3 checkboxs, 2 different styles and one has a locked icon and it's 'not enabled' (not enabled meaning you can't toggle it).
            MenuCheckboxItem box = new MenuCheckboxItem("Checkbox - Style 1 (click me!)", "This checkbox can toggle the menu position! Try it out.", !menu.LeftAligned)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Cross
            };
#endif
            MenuCheckboxItem box2 = new MenuCheckboxItem("Checkbox - Style 2", "This checkbox does nothing right now.", true)
            {
                Style = MenuCheckboxItem.CheckboxStyle.Tick
            };

            MenuCheckboxItem box3 = new MenuCheckboxItem("Checkbox (unchecked + locked)", "Make this menu right aligned. If you set this to false, then the menu will move to the left.", false)
            {
                Enabled  = false,
                LeftIcon = MenuItem.Icon.LOCK
            };

            // Adding the checkboxes to the menu.
#if FIVEM
            menu.AddMenuItem(box);
#endif
            menu.AddMenuItem(box2);
            menu.AddMenuItem(box3);

            // Dynamic list item
            string ChangeCallback(MenuDynamicListItem item, bool left)
            {
                if (left)
                {
                    return((int.Parse(item.CurrentItem) - 1).ToString());
                }
                return((int.Parse(item.CurrentItem) + 1).ToString());
            }

            MenuDynamicListItem dynList = new MenuDynamicListItem("Dynamic list item.", "0", new MenuDynamicListItem.ChangeItemCallback(ChangeCallback), "Description for this dynamic item. Pressing left will make the value smaller, pressing right will make the value bigger.");
            menu.AddMenuItem(dynList);
#if FIVEM
            // List items (first the 3 special variants, then a normal one)
            List <string> colorList = new List <string>();
            for (var i = 0; i < 64; i++)
            {
                colorList.Add($"Color #{i}");
            }
            MenuListItem hairColors = new MenuListItem("Hair Color", colorList, 0, "Hair color pallete.")
            {
                ShowColorPanel = true
            };

            // Also special
            List <string> makeupColorList = new List <string>();
            for (var i = 0; i < 64; i++)
            {
                makeupColorList.Add($"Color #{i}");
            }
            MenuListItem makeupColors = new MenuListItem("Makeup Color", makeupColorList, 0, "Makeup color pallete.")
            {
                ShowColorPanel      = true,
                ColorPanelColorType = MenuListItem.ColorPanelType.Makeup
            };

            // Also special
            List <string> opacityList = new List <string>();
            for (var i = 0; i < 11; i++)
            {
                opacityList.Add($"Opacity {i * 10}%");
            }
            MenuListItem opacity = new MenuListItem("Opacity Panel", opacityList, 0, "Set an opacity for something.")
            {
                ShowOpacityPanel = true
            };

            menu.AddMenuItem(hairColors);
            menu.AddMenuItem(makeupColors);
            menu.AddMenuItem(opacity);
#endif
            // Normal
            List <string> normalList = new List <string>()
            {
                "Item #1", "Item #2", "Item #3"
            };
            MenuListItem normalListItem = new MenuListItem("Normal List Item", normalList, 0, "And another simple description for yet another simple (list) item. Nothing special about this one.");

            // Adding the lists to the menu.
            menu.AddMenuItem(normalListItem);

            // Creating a submenu, adding it to the menus list, and creating and binding a button for it.
            Menu submenu = new Menu("Submenu", "Secondary Menu");
            MenuController.AddSubmenu(menu, submenu);

            MenuItem menuButton = new MenuItem("Submenu", "This button is bound to a submenu. Clicking it will take you to the submenu.")
            {
#if FIVEM
                Label = "→→→"
#endif
#if REDM
                RightIcon = MenuItem.Icon.ARROW_RIGHT
#endif
            };
            menu.AddMenuItem(menuButton);
            MenuController.BindMenuItem(menu, submenu, menuButton);

            // Adding items with sprites left & right to the submenu.
            for (var i = 0; i < Enum.GetValues(typeof(MenuItem.Icon)).Length; i++)
            {
                var tmpItem = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite. Press ~r~HOME~s~ to toggle the 'enabled' state on these items.")
                {
                    Label = $"(#{i})",
#if FIVEM
#endif
                    RightIcon = (MenuItem.Icon)i,
                    LeftIcon  = (MenuItem.Icon)i
                };

                //var tmpItem2 = new MenuItem($"Icon.{Enum.GetName(typeof(MenuItem.Icon), ((MenuItem.Icon)i))}", "This menu item has a left and right sprite, and it's ~h~disabled~h~.");
                //tmpItem2.LeftIcon = (MenuItem.Icon)i;
                //tmpItem2.RightIcon = (MenuItem.Icon)i;
                //tmpItem2.Enabled = false;

                submenu.AddMenuItem(tmpItem);
                //submenu.AddMenuItem(tmpItem2);
            }
            submenu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.FrontendSocialClubSecondary, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((m, c) =>
            {
                m.GetMenuItems().ForEach(a => a.Enabled = !a.Enabled);
            }), true));

#if FIVEM
            // Instructional buttons setup for the second (submenu) menu.
            submenu.InstructionalButtons.Add(Control.CharacterWheel, "Right?!");
            submenu.InstructionalButtons.Add(Control.CursorScrollDown, "Cool");
            submenu.InstructionalButtons.Add(Control.CreatorDelete, "Out!");
            submenu.InstructionalButtons.Add(Control.Cover, "This");
            submenu.InstructionalButtons.Add(Control.Context, "Check");
#endif

            // Create a third menu without a banner.
            Menu menu3 = new Menu(null, "Only a subtitle, no banner.");

            // you can use AddSubmenu or AddMenu, both will work but if you want to link this menu from another menu,
            // you should use AddSubmenu.
            MenuController.AddSubmenu(menu, menu3);
            MenuItem thirdSubmenuBtn = new MenuItem("Another submenu", "This is just a submenu without a banner. No big deal. This also has a very long description to test multiple lines and see if they work properly. Let's find out if it works as intended.")
            {
#if FIVEM
                Label = "→→→"
#endif

#if REDM
                RightIcon = MenuItem.Icon.ARROW_RIGHT
#endif
            };
            menu.AddMenuItem(thirdSubmenuBtn);
            MenuController.BindMenuItem(menu, menu3, thirdSubmenuBtn);
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!"));
            menu3.AddMenuItem(new MenuItem("Nothing here!")
            {
                LeftIcon = MenuItem.Icon.TICK
            });

            for (var i = 0; i < 10; i++)
            {
                menu.AddMenuItem(new MenuItem($"Item #{i + 1}.", "With an invisible description."));
            }


#if FIVEM
            // Create menu with weapon stats panel
            Menu menu4 = new Menu("Weapon Stats", "Weapon Stats Panel")
            {
                ShowWeaponStatsPanel = true
            };
            menu4.AddMenuItem(new MenuItem("dummy item", "You should add at least one item when using weapon stat panels"));
            menu4.SetWeaponStats(0.2f, 0.4f, 0.7f, 0.8f);
            menu4.SetWeaponComponentStats(0.4f, 0f, -0.05f, 0.1f);
            MenuController.AddSubmenu(menu, menu4);
            MenuItem weaponStats = new MenuItem("Weapon stats", "Demo menu for weapon stats components");
            menu.AddMenuItem(weaponStats);
            MenuController.BindMenuItem(menu, menu4, weaponStats);

            // Create menu with vehicle stats panel
            Menu menu5 = new Menu("Vehicle Stats", "Vehicle Stats Panel")
            {
                ShowVehicleStatsPanel = true
            };
            menu5.AddMenuItem(new MenuItem("dummy item", "You should add at least one item when using vehicle stat panels"));
            menu5.SetVehicleStats(0.2f, 0.2f, 0.3f, 0.8f);
            menu5.SetVehicleUpgradeStats(0.4f, -0.025f, 0.05f, 0.1f);
            MenuController.AddSubmenu(menu, menu5);
            MenuItem vehicleStats = new MenuItem("Vehicle stats", "Demo menu for vehicle stats components");
            menu.AddMenuItem(vehicleStats);
            MenuController.BindMenuItem(menu, menu5, vehicleStats);
#endif

            /*
             ########################################################
             #                   Event handlers
             ########################################################
             */


            menu.OnCheckboxChange += (_menu, _item, _index, _checked) =>
            {
                // Code in here gets executed whenever a checkbox is toggled.
                Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]");
#if FIVEM
                // If the align-menu checkbox is toggled, toggle the menu alignment.
                if (_item == box)
                {
                    if (_checked)
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;
                    }
                    else
                    {
                        MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Left;
                    }
                }
#endif
            };

            menu.OnItemSelect += (_menu, _item, _index) =>
            {
                // Code in here would get executed whenever an item is pressed.
                Debug.WriteLine($"OnItemSelect: [{_menu}, {_item}, {_index}]");
            };

            menu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) =>
            {
                // Code in here would get executed whenever the up or down key is pressed and the index of the menu is changed.
                Debug.WriteLine($"OnIndexChange: [{_menu}, {_oldItem}, {_newItem}, {_oldIndex}, {_newIndex}]");
            };

            menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed).
                Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]");
            };

            menu.OnListItemSelect += (_menu, _listItem, _listIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever a list item is pressed.
                Debug.WriteLine($"OnListItemSelect: [{_menu}, {_listItem}, {_listIndex}, {_itemIndex}]");
            };

#if FIVEM
            menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever the position of a slider is changed (when left/right key is pressed).
                Debug.WriteLine($"OnSliderPositionChange: [{_menu}, {_sliderItem}, {_oldPosition}, {_newPosition}, {_itemIndex}]");
            };

            menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) =>
            {
                // Code in here would get executed whenever a slider item is pressed.
                Debug.WriteLine($"OnSliderItemSelect: [{_menu}, {_sliderItem}, {_sliderPosition}, {_itemIndex}]");
            };
#endif

            menu.OnMenuClose += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is closed.
                Debug.WriteLine($"OnMenuClose: [{_menu}]");
            };

            menu.OnMenuOpen += (_menu) =>
            {
                // Code in here gets triggered whenever the menu is opened.
                Debug.WriteLine($"OnMenuOpen: [{_menu}]");
            };

            menu.OnDynamicListItemCurrentItemChange += (_menu, _dynamicListItem, _oldCurrentItem, _newCurrentItem) =>
            {
                // Code in here would get executed whenever the value of the current item of a dynamic list item changes.
                Debug.WriteLine($"OnDynamicListItemCurrentItemChange: [{_menu}, {_dynamicListItem}, {_oldCurrentItem}, {_newCurrentItem}]");
            };

            menu.OnDynamicListItemSelect += (_menu, _dynamicListItem, _currentItem) =>
            {
                // Code in here would get executed whenever a dynamic list item is pressed.
                Debug.WriteLine($"OnDynamicListItemSelect: [{_menu}, {_dynamicListItem}, {_currentItem}]");
            };

            //DelayedConstructor();
        }

        //private async void DelayedConstructor()
        //{
        //    await Delay(1000);
        //    MenuController.MainMenu.OpenMenu();
        //}
    }
}
Пример #26
0
        internal void ShowMenu(int locationIndex)
        {
            PlayerData playerData = Utilities.GetPlayerData();

            int     rayHandle;
            bool    _Hit           = false;
            Vector3 _endCoords     = new Vector3();;
            Vector3 _surfaceNormal = new Vector3();;
            int     _entityHit     = 0;


            MenuItem     menuButton_SelectVehicle = new MenuItem("Select Car");
            MenuListItem menuListItem_Liveries    = new MenuListItem("Livery", new List <string>(), 0);
            MenuListItem menuListItem_Colors      = new MenuListItem("Color", new List <string>(), 0);
            MenuItem     menuButton_Extras        = new MenuItem("Extras");
            MenuItem     menuItem_DeleteVehicle   = new MenuItem("Delete vehicle");

            try
            {
                menu = new Menu("Garage");
                MenuController.AddMenu(menu);

                Menu menu_SelectVehicle = new Menu("Select Vehicle");
                Menu menu_Extras        = new Menu("Select Extras");

                // Do all the dynamic stuff in "OnMenuOpen" so it runs again when player returns from submenu
                menu.OnMenuOpen += (_menu) =>
                {
                    Common.IsMenuOpen = true;

                    menu.ClearMenuItems();

                    menuListItem_Liveries = new MenuListItem("Livery", new List <string>(), 0);
                    menuListItem_Colors   = new MenuListItem("Color", new List <string>(), 0);

                    menuButton_SelectVehicle = new MenuItem("Select Car")
                    {
                        Label = "→→→"
                    };
                    menu.AddMenuItem(menuButton_SelectVehicle);
                    MenuController.AddSubmenu(menu, menu_SelectVehicle);
                    MenuController.BindMenuItem(menu, menu_SelectVehicle, menuButton_SelectVehicle);

                    // Check if any object is blocking the spawn area. Currently only 1 raycast across the area. Enough? Probably.
                    rayHandle = CastRayPointToPoint(SpawnLocations[locationIndex].X - 2, SpawnLocations[locationIndex].Y - 2, SpawnLocations[locationIndex].Z, SpawnLocations[locationIndex].X + 2, SpawnLocations[locationIndex].Y + 3, SpawnLocations[locationIndex].Z + 1, -1, 0, 0);
                    GetRaycastResult(rayHandle, ref _Hit, ref _endCoords, ref _surfaceNormal, ref _entityHit);

                    // Check if the vehicle currently in the spawn area has liveries and add them to the menu
                    int liveryCount = GetVehicleLiveryCount(_entityHit);

                    if (_Hit && liveryCount > 1)
                    {
                        for (int i = 0; i < liveryCount; i++)
                        {
                            menuListItem_Liveries.ListItems.Add((i + 1) + "/" + liveryCount);
                        }
                        menuListItem_Liveries.ListIndex   = GetVehicleLivery(_entityHit);
                        menuListItem_Liveries.Enabled     = true;
                        menuListItem_Liveries.Description = null;
                    }
                    else
                    {
                        menuListItem_Liveries.Enabled     = false;
                        menuListItem_Liveries.Description = "No additional liveries found";
                    }
                    menu.AddMenuItem(menuListItem_Liveries);


                    // Check if the entity in the spawn area is a vehicle and add color options to the menu

                    if (_Hit || GetEntityType(_entityHit) == 2)
                    {
                        int defaultPrimary   = 0;
                        int defaultSecondary = 0;
                        GetVehicleColours(_entityHit, ref defaultPrimary, ref defaultSecondary);
                        Colors["Default"] = defaultPrimary;
                        foreach (var entry in Colors)
                        {
                            menuListItem_Colors.ListItems.Add(entry.Key);
                        }
                        menuListItem_Colors.Enabled     = true;
                        menuListItem_Colors.Description = "Not all liveries support colors";
                    }
                    else
                    {
                        menuListItem_Colors.Enabled     = false;
                        menuListItem_Colors.Description = "No vehicle found";
                    }
                    menu.AddMenuItem(menuListItem_Colors);


                    // Check if the vehicle in the spawn area has extras and show the menu button
                    menuButton_Extras = new MenuItem("Extras")
                    {
                        Label = "→→→"
                    };
                    if (_Hit && DoesExtraExist(_entityHit, 1))
                    {
                        menuButton_Extras.Enabled     = true;
                        menuButton_Extras.Description = null;
                        MenuController.AddSubmenu(menu, menu_Extras);
                        MenuController.BindMenuItem(menu, menu_Extras, menuButton_Extras);
                    }
                    else
                    {
                        menuButton_Extras.Enabled     = false;
                        menuButton_Extras.Description = "No extras found";
                    }
                    menu.AddMenuItem(menuButton_Extras);

                    // Check if the entity in the spawn area is a vehicle and show the delete button
                    menuItem_DeleteVehicle = new MenuItem("Delete vehicle");
                    menu.AddMenuItem(menuItem_DeleteVehicle);

                    if (!_Hit || GetEntityType(_entityHit) != 2)
                    {
                        menuItem_DeleteVehicle.Enabled     = false;
                        menuItem_DeleteVehicle.Description = "No vehicle to delete";
                    }
                    else
                    {
                        menuItem_DeleteVehicle.Enabled     = true;
                        menuItem_DeleteVehicle.Description = null;
                    }
                };

                // Select Vehicle Submenu
                menu_SelectVehicle.OnMenuOpen += (_menu) =>
                {
                    Common.IsMenuOpen = true;

                    menu_SelectVehicle.ClearMenuItems();

                    foreach (Vehicle _Vehicle in Vehicles)
                    {
                        bool _isAllowed = false;

                        if (_Vehicle.IsAvailableForEveryone)
                        {
                            _isAllowed = true;
                        }
                        else if (_Vehicle.UseRanks)
                        {
                            if (_Vehicle.AvailableForRanks.Contains(playerData.Rank))
                            {
                                _isAllowed = true;
                            }
                        }
                        else if (!_Vehicle.UseRanks)
                        {
                            if (_Vehicle.AvailableForDepartments.Contains(playerData.DepartmentID))
                            {
                                _isAllowed = true;
                            }
                        }

                        if (_isAllowed)
                        {
                            MenuItem _menuButton = new MenuItem(_Vehicle.Name);
                            _menuButton.ItemData = _Vehicle.Model;
                            menu_SelectVehicle.AddMenuItem(_menuButton);
                        }
                    }
                };

                menu_Extras.OnMenuOpen += (_menu) =>
                {
                    Common.IsMenuOpen = true;

                    menu_Extras.ClearMenuItems();

                    // Max extras in GTA V is 14
                    for (int i = 1; i <= 14; i++)
                    {
                        if (DoesExtraExist(_entityHit, i))
                        {
                            menu_Extras.AddMenuItem(new MenuCheckboxItem("Extra " + i, IsVehicleExtraTurnedOn(_entityHit, i))
                            {
                                Style = MenuCheckboxItem.CheckboxStyle.Tick
                            });
                        }
                    }
                };


                menu.OnItemSelect += (_menu, _item, _index) =>
                {
                    if (_item == menuItem_DeleteVehicle)
                    {
                        SetEntityAsMissionEntity(_entityHit, true, true); // Can only delete vehicle if it is a mission entity!
                        DeleteVehicle(ref _entityHit);
                        _item.Enabled                     = false;
                        _item.Description                 = "Vehicle deleted";
                        menuButton_Extras.Enabled         = false;
                        menuButton_Extras.Description     = "No extras found";
                        menuListItem_Liveries.Enabled     = false;
                        menuListItem_Liveries.Description = "No additional liveries found";
                        menuListItem_Colors.Enabled       = false;
                        menuListItem_Colors.Description   = "No vehicle found";
                    }
                };

                menu_SelectVehicle.OnItemSelect += (_menu, _item, _index) =>
                {
                    // Check again if something is blocking
                    rayHandle = CastRayPointToPoint(SpawnLocations[locationIndex].X - 2, SpawnLocations[locationIndex].Y - 2, SpawnLocations[locationIndex].Z, SpawnLocations[locationIndex].X + 2, SpawnLocations[locationIndex].Y + 2, SpawnLocations[locationIndex].Z + 1, -1, 0, 0);
                    GetRaycastResult(rayHandle, ref _Hit, ref _endCoords, ref _surfaceNormal, ref _entityHit);

                    // Delete previously spawned vehicle if it is still in the spawn area
                    if (LastSpawnedVehicle == _entityHit)
                    {
                        DeleteVehicle(ref LastSpawnedVehicle);
                    }

                    // Check once again if something is blocking; Maybe there was more than 1 vehicle
                    rayHandle = CastRayPointToPoint(SpawnLocations[locationIndex].X - 2, SpawnLocations[locationIndex].Y - 2, SpawnLocations[locationIndex].Z, SpawnLocations[locationIndex].X + 2, SpawnLocations[locationIndex].Y + 2, SpawnLocations[locationIndex].Z + 1, -1, 0, 0);
                    GetRaycastResult(rayHandle, ref _Hit, ref _endCoords, ref _surfaceNormal, ref _entityHit);

                    if (!_Hit)
                    {
                        _ = SpawnVehicle(locationIndex, _item.ItemData);
                    }
                    else
                    {
                        Common.DisplayNotification("Something is blocking the spawn area");
                    }
                };

                menu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
                {
                    if (_listItem == menuListItem_Liveries)
                    {
                        SetVehicleLivery(_entityHit, _newIndex);
                    }
                    else if (_listItem == menuListItem_Colors)
                    {
                        int newColor = Colors.ElementAt(_newIndex).Value;
                        if (newColor != 999)
                        {
                            SetVehicleColours(_entityHit, newColor, newColor);
                        }
                        else
                        {
                            ClearVehicleCustomPrimaryColour(_entityHit);
                        }
                    }
                };

                menu_Extras.OnCheckboxChange += (_menu, _item, _index, _checked) =>
                {
                    SetVehicleExtra(_entityHit, _index + 1, !_checked);
                };


                menu.OnMenuClose += (_menu) =>
                {
                    Common.IsMenuOpen = false;
                };

                menu_SelectVehicle.OnMenuClose += (_menu) =>
                {
                    Common.IsMenuOpen = false;
                };

                menu.OpenMenu();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
Пример #27
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(faceMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            //Tipo de tamaños del 1 al 10
            List <string> sizeType = new List <string>();

            for (float i = 1; i < 11; i++) //Recuerda un +1 a la lista ya que empezamos desde el (INT I = 1)
            {
                sizeType.Add(GetConfig.Langs["TypeValues"] + i);
            }

            MenuListItem mListHead = new MenuListItem(GetConfig.Langs["FaceSize"], sizeType, 4, GetConfig.Langs["FaceSizeDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListHead);                                                                                      // Lo añadimos al menu

            //Altura cejas
            MenuListItem mListEyeBrowH = new MenuListItem(GetConfig.Langs["EyebrowHeight"], sizeType, 4, GetConfig.Langs["EyebrowHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeBrowH);                                                                                                // Lo añadimos al menu
            //Anchura cejas
            MenuListItem mListEyeBrowW = new MenuListItem(GetConfig.Langs["EyebrowWidth"], sizeType, 4, GetConfig.Langs["EyebrowWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeBrowW);                                                                                                // Lo añadimos al menu
            //Profundida cejas
            MenuListItem mListEyeBrowD = new MenuListItem(GetConfig.Langs["EyebrowDepth"], sizeType, 4, GetConfig.Langs["EyebrowDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeBrowD);                                                                                                // Lo añadimos al menu

            //Altura Orejas
            MenuListItem mListEarsH = new MenuListItem(GetConfig.Langs["EarsHeight"], sizeType, 4, GetConfig.Langs["EarsHeightDesc"]);     // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEarsH);                                                                                              // Lo añadimos al menu
            //Anchura Orejas
            MenuListItem mListEarsW = new MenuListItem(GetConfig.Langs["EarsAngle"], sizeType, 4, GetConfig.Langs["EarsAngleDesc"]);       // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEarsW);                                                                                              // Lo añadimos al menu
            //Tamaño Orejas
            MenuListItem mListEarsD = new MenuListItem(GetConfig.Langs["EarsSize"], sizeType, 4, GetConfig.Langs["EarsSizeDesc"]);         // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEarsD);                                                                                              // Lo añadimos al menu
            //Tamaño Lobulo de la oreja
            MenuListItem mListEarsL = new MenuListItem(GetConfig.Langs["EarsLobeSize"], sizeType, 4, GetConfig.Langs["EarsLobeSizeDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEarsL);                                                                                              // Lo añadimos al menu

            //Altura de los parpados
            MenuListItem mListEyeLidH = new MenuListItem(GetConfig.Langs["EyelidsHeight"], sizeType, 4, GetConfig.Langs["EyelidsHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeLidH);                                                                                                // Lo añadimos al menu
            //Ancho de los parpados
            MenuListItem mListEyeLidW = new MenuListItem(GetConfig.Langs["EyelidsWidth"], sizeType, 4, GetConfig.Langs["EyelidsWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeLidW);                                                                                                // Lo añadimos al menu

            //Profundida de los ojos
            MenuListItem mListEyeD = new MenuListItem(GetConfig.Langs["EyeDepth"], sizeType, 4, GetConfig.Langs["EyeDepthDesc"]);             // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeD);                                                                                                  // Lo añadimos al menu
            //Angulo de los ojos
            MenuListItem mListEyeAng = new MenuListItem(GetConfig.Langs["EyeAngle"], sizeType, 4, GetConfig.Langs["EyeAngleDesc"]);           // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeAng);                                                                                                // Lo añadimos al menu
            //Distancia de los ojos
            MenuListItem mListEyeDis = new MenuListItem(GetConfig.Langs["EyeSeparation"], sizeType, 4, GetConfig.Langs["EyeSeparationDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeDis);                                                                                                // Lo añadimos al menu
            //Altura de los ojos
            MenuListItem mListEyeH = new MenuListItem(GetConfig.Langs["EyeHeight"], sizeType, 4, GetConfig.Langs["EyeHeightDesc"]);           // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListEyeH);                                                                                                  // Lo añadimos al menu


            MenuListItem mListNoseW = new MenuListItem(GetConfig.Langs["NoseWidth"], sizeType, 4, GetConfig.Langs["NoseWidthDesc"]);                     // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseW);                                                                                                            // Lo añadimos al menu

            MenuListItem mListNoseS = new MenuListItem(GetConfig.Langs["NoseSize"], sizeType, 4, GetConfig.Langs["NoseSizeDesc"]);                       // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseS);                                                                                                            // Lo añadimos al menu

            MenuListItem mListNoseH = new MenuListItem(GetConfig.Langs["NoseHeight"], sizeType, 4, GetConfig.Langs["NoseHeigthDesc"]);                   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseH);                                                                                                            // Lo añadimos al menu

            MenuListItem mListNoseAng = new MenuListItem(GetConfig.Langs["NoseAngle"], sizeType, 4, GetConfig.Langs["NoseAngleDesc"]);                   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseAng);                                                                                                          // Lo añadimos al menu

            MenuListItem mListNoseC = new MenuListItem(GetConfig.Langs["NoseCurvature"], sizeType, 4, GetConfig.Langs["NoseCurvatureDesc"]);             // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseC);                                                                                                            // Lo añadimos al menu

            MenuListItem mListNoseDis = new MenuListItem(GetConfig.Langs["NostrilsSeparation"], sizeType, 4, GetConfig.Langs["NostrilsSeparationDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListNoseDis);                                                                                                          // Lo añadimos al menu


            MenuListItem mListCheekBonesH = new MenuListItem(GetConfig.Langs["CheekbonesHeight"], sizeType, 4, GetConfig.Langs["CheekbonesHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListCheekBonesH);                                                                                                      // Lo añadimos al menu

            MenuListItem mListCheekBonesW = new MenuListItem(GetConfig.Langs["CheekbonesWidth"], sizeType, 4, GetConfig.Langs["CheekbonesWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListCheekBonesW);                                                                                                      // Lo añadimos al menu

            MenuListItem mListCheekBonesD = new MenuListItem(GetConfig.Langs["CheekbonesDepth"], sizeType, 4, GetConfig.Langs["CheekbonesDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListCheekBonesD);                                                                                                      // Lo añadimos al menu


            MenuListItem mListMouthW = new MenuListItem(GetConfig.Langs["MouthWidth"], sizeType, 4, GetConfig.Langs["MouthWidthDesc"]);         // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListMouthW);                                                                                                  // Lo añadimos al menu

            MenuListItem mListMouthD = new MenuListItem(GetConfig.Langs["MouthDepth"], sizeType, 4, GetConfig.Langs["MouthDepthDesc"]);         // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListMouthD);                                                                                                  // Lo añadimos al menu

            MenuListItem mListMouthX = new MenuListItem(GetConfig.Langs["MouthDeviation"], sizeType, 4, GetConfig.Langs["MouthDeviationDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListMouthX);                                                                                                  // Lo añadimos al menu

            MenuListItem mListMouthY = new MenuListItem(GetConfig.Langs["MouthHeight"], sizeType, 4, GetConfig.Langs["MouthHeightDesc"]);       // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListMouthY);                                                                                                  // Lo añadimos al menu


            MenuListItem mListULiphH = new MenuListItem(GetConfig.Langs["UpperLipHeight"], sizeType, 4, GetConfig.Langs["UpperLipHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListULiphH);                                                                                                  // Lo añadimos al menu
            MenuListItem mListULiphW = new MenuListItem(GetConfig.Langs["UpperLipWidth"], sizeType, 4, GetConfig.Langs["UpperLipWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListULiphW);                                                                                                  // Lo añadimos al menu
            MenuListItem mListULiphD = new MenuListItem(GetConfig.Langs["UpperLipDepth"], sizeType, 4, GetConfig.Langs["UpperLipDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListULiphD);                                                                                                  // Lo añadimos al menu
            MenuListItem mListLLiphH = new MenuListItem(GetConfig.Langs["LowerLipHeight"], sizeType, 4, GetConfig.Langs["LowerLipHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListLLiphH);                                                                                                  // Lo añadimos al menu
            MenuListItem mListLLiphW = new MenuListItem(GetConfig.Langs["LowerLipWidth"], sizeType, 4, GetConfig.Langs["LowerLipWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListLLiphW);                                                                                                  // Lo añadimos al menu
            MenuListItem mListLLiphD = new MenuListItem(GetConfig.Langs["LowerLipDepth"], sizeType, 4, GetConfig.Langs["LowerLipDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListLLiphD);                                                                                                  // Lo añadimos al menu


            MenuListItem mListJawH = new MenuListItem(GetConfig.Langs["MandibleHeight"], sizeType, 4, GetConfig.Langs["MandibleHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListJawH);                                                                                                  // Lo añadimos al menu

            MenuListItem mListJawW = new MenuListItem(GetConfig.Langs["MandibleWidth"], sizeType, 4, GetConfig.Langs["MandibleWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListJawW);                                                                                                  // Lo añadimos al menu

            MenuListItem mListJawD = new MenuListItem(GetConfig.Langs["MandibleDepth"], sizeType, 4, GetConfig.Langs["MandibleDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListJawD);                                                                                                  // Lo añadimos al menu


            MenuListItem mListChinH = new MenuListItem(GetConfig.Langs["ChinHeight"], sizeType, 4, GetConfig.Langs["ChinHeightDesc"]); // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListChinH);                                                                                          // Lo añadimos al menu

            MenuListItem mListChinW = new MenuListItem(GetConfig.Langs["ChinWidth"], sizeType, 4, GetConfig.Langs["ChinWidthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListChinW);                                                                                          // Lo añadimos al menu

            MenuListItem mListChinD = new MenuListItem(GetConfig.Langs["ChinDepth"], sizeType, 4, GetConfig.Langs["ChinDepthDesc"]);   // Añadimos la lista al boton

            faceMenu.AddMenuItem(mListChinD);                                                                                          //Lo añadimos al menu



            faceMenu.OnMenuOpen += (_menu) => {
            };

            faceMenu.OnMenuClose += (_menu) =>
            {
            };

            faceMenu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                CreatePlayer.SetPlayerFaceBlend(_itemIndex, _newIndex);
            };
        }
Пример #28
0
        private static void SetupMenu()
        {
            if (setupDone)
            {
                return;
            }
            setupDone = true;
            MenuController.AddMenu(mainMenu);

            MenuController.EnableMenuToggleKeyOnController = false;
            MenuController.MenuToggleKey = (Control)0;

            //SkinMenu
            MenuController.AddSubmenu(mainMenu, SkinMenu.GetMenu());

            MenuItem subMenuSkinBtn = new MenuItem(GetConfig.Langs["TitleSkinMenu"], GetConfig.Langs["SubTitleSkinMenu"])
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuSkinBtn);
            MenuController.BindMenuItem(mainMenu, SkinMenu.GetMenu(), subMenuSkinBtn);

            //FaceMenu
            MenuController.AddSubmenu(mainMenu, FaceMenu.GetMenu());

            MenuItem subMenuFaceBtn = new MenuItem(GetConfig.Langs["TitleFaceMenu"], GetConfig.Langs["SubTitleFaceMenu"])
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuFaceBtn);
            MenuController.BindMenuItem(mainMenu, FaceMenu.GetMenu(), subMenuFaceBtn);

            //ClothesMenu
            MenuController.AddSubmenu(mainMenu, ClothesMenu.GetMenu());

            MenuItem subMenuClothesBtn = new MenuItem(GetConfig.Langs["TitleClothesMenu"], GetConfig.Langs["SubTitleClothesMenu"])
            {
                RightIcon = MenuItem.Icon.ARROW_RIGHT
            };

            mainMenu.AddMenuItem(subMenuClothesBtn);
            MenuController.BindMenuItem(mainMenu, ClothesMenu.GetMenu(), subMenuClothesBtn);

            List <string> scaleValues = new List <string>();

            foreach (float sc in Utils.SkinsUtils.SCALE_LIST)
            {
                scaleValues.Add(GetConfig.Langs["Scale"] + sc.ToString());
            }

            MenuListItem ScaleBtn = new MenuListItem(GetConfig.Langs["ScaleList"], scaleValues, 4, GetConfig.Langs["ScaleDesc"])
            {
                RightIcon = MenuItem.Icon.STAR
            };

            mainMenu.AddMenuItem(ScaleBtn);

            //Finish Button
            MenuItem FinishBtn = new MenuItem(GetConfig.Langs["FinishBtnMainMenu"], GetConfig.Langs["SubFinishBtnMainMenu"])
            {
                RightIcon = MenuItem.Icon.TICK
            };

            mainMenu.AddMenuItem(FinishBtn);

            //Events
            mainMenu.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                if (_itemIndex == 3)
                {
                    CreateCharacter.changeScale(SkinsUtils.SCALE_LIST[_newIndex]);
                }
            };

            mainMenu.OnMenuClose += (_menu) =>
            {
                if (CreateCharacter.isInCharCreation)
                {
                    CreateCharacter.CloseSecureMenu();
                }
            };

            mainMenu.OnItemSelect += (_menu, _item, _index) =>
            {
                // Code in here would get executed whenever an item is pressed.
                if (_index == 4)
                {
                    CreateCharacter.isInCharCreation = false;
                    CreateCharacter.SaveChanges();
                    mainMenu.CloseMenu();
                }
            };
        }
Пример #29
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        private void CreateMenu()
        {
            string menuTitle = "Saved Vehicles";

            #region Create menus and submenus
            // Create the menu.
            menu = new Menu(menuTitle, "Manage Saved Vehicles");

            MenuItem saveVehicle = new MenuItem("Save Current Vehicle", "Save the vehicle you are currently sitting in.");
            menu.AddMenuItem(saveVehicle);
            saveVehicle.LeftIcon = MenuItem.Icon.CAR;

            menu.OnItemSelect += (sender, item, index) =>
            {
                if (item == saveVehicle)
                {
                    if (Game.PlayerPed.IsInVehicle())
                    {
                        SaveVehicle();
                    }
                    else
                    {
                        Notify.Error("You are currently not in any vehicle. Please enter a vehicle before trying to save it.");
                    }
                }
            };

            for (int i = 0; i < 23; i++)
            {
                Menu categoryMenu = new Menu("Saved Vehicles", GetLabelText($"VEH_CLASS_{i}"));

                MenuItem categoryButton = new MenuItem(GetLabelText($"VEH_CLASS_{i}"), $"All saved vehicles from the {(GetLabelText($"VEH_CLASS_{i}"))} category.");
                subMenus.Add(categoryMenu);
                MenuController.AddSubmenu(menu, categoryMenu);
                menu.AddMenuItem(categoryButton);
                categoryButton.Label = "→→→";
                MenuController.BindMenuItem(menu, categoryMenu, categoryButton);

                categoryMenu.OnMenuClose += (sender) =>
                {
                    UpdateMenuAvailableCategories();
                };

                categoryMenu.OnItemSelect += (sender, item, index) =>
                {
                    UpdateSelectedVehicleMenu(item, sender);
                };
            }

            MenuItem unavailableModels = new MenuItem("Unavailable Saved Vehicles", "These vehicles are currently unavailable because the models are not present in the game. These vehicles are most likely not being streamed from the server.")
            {
                Label = "→→→"
            };

            menu.AddMenuItem(unavailableModels);
            MenuController.BindMenuItem(menu, unavailableVehiclesMenu, unavailableModels);
            MenuController.AddSubmenu(menu, unavailableVehiclesMenu);


            MenuController.AddMenu(selectedVehicleMenu);
            MenuItem spawnVehicle   = new MenuItem("Spawn Vehicle", "Spawn this saved vehicle.");
            MenuItem renameVehicle  = new MenuItem("Rename Vehicle", "Rename your saved vehicle.");
            MenuItem replaceVehicle = new MenuItem("~r~Replace Vehicle", "Your saved vehicle will be replaced with the vehicle you are currently sitting in. ~r~Warning: this can NOT be undone!");
            MenuItem deleteVehicle  = new MenuItem("~r~Delete Vehicle", "~r~This will delete your saved vehicle. Warning: this can NOT be undone!");
            selectedVehicleMenu.AddMenuItem(spawnVehicle);
            selectedVehicleMenu.AddMenuItem(renameVehicle);
            selectedVehicleMenu.AddMenuItem(replaceVehicle);
            selectedVehicleMenu.AddMenuItem(deleteVehicle);

            selectedVehicleMenu.OnMenuOpen += (sender) =>
            {
                spawnVehicle.Label = "(" + GetDisplayNameFromVehicleModel(currentlySelectedVehicle.Value.model).ToLower() + ")";
            };

            selectedVehicleMenu.OnMenuClose += (sender) =>
            {
                selectedVehicleMenu.RefreshIndex();
                deleteButtonPressedCount = 0;
                deleteVehicle.Label      = "";
            };

            selectedVehicleMenu.OnItemSelect += async(sender, item, index) =>
            {
                if (item == spawnVehicle)
                {
                    if (MainMenu.VehicleSpawnerMenu != null)
                    {
                        SpawnVehicle(currentlySelectedVehicle.Value.model, MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4));
                        TriggerServerEvent("vMenu:DamonLog", $"{Game.Player.Name} Spawned {GetDisplayNameFromVehicleModel(currentlySelectedVehicle.Value.model)}");
                    }
                    else
                    {
                        SpawnVehicle(currentlySelectedVehicle.Value.model, true, true, false, vehicleInfo: currentlySelectedVehicle.Value, saveName: currentlySelectedVehicle.Key.Substring(4));
                        TriggerServerEvent("vMenu:DamonLog", $"{Game.Player.Name} Spawned {GetDisplayNameFromVehicleModel(currentlySelectedVehicle.Value.model)}");
                    }
                }
                else if (item == renameVehicle)
                {
                    string newName = await GetUserInput(windowTitle : "Enter a new name for this vehicle.", maxInputLength : 30);

                    if (string.IsNullOrEmpty(newName))
                    {
                        Notify.Error(CommonErrors.InvalidInput);
                    }
                    else
                    {
                        if (StorageManager.SaveVehicleInfo("veh_" + newName, currentlySelectedVehicle.Value, false))
                        {
                            DeleteResourceKvp(currentlySelectedVehicle.Key);
                            while (!selectedVehicleMenu.Visible)
                            {
                                await BaseScript.Delay(0);
                            }
                            Notify.Success("Your vehicle has successfully been renamed.");
                            UpdateMenuAvailableCategories();
                            selectedVehicleMenu.GoBack();
                            currentlySelectedVehicle = new KeyValuePair <string, VehicleInfo>(); // clear the old info
                        }
                        else
                        {
                            Notify.Error("This name is already in use or something unknown failed. Contact the server owner if you believe something is wrong.");
                        }
                    }
                }
                else if (item == replaceVehicle)
                {
                    if (Game.PlayerPed.IsInVehicle())
                    {
                        SaveVehicle(currentlySelectedVehicle.Key.Substring(4));
                        selectedVehicleMenu.GoBack();
                        Notify.Success("Your saved vehicle has been replaced with your current vehicle.");
                    }
                    else
                    {
                        Notify.Error("You need to be in a vehicle before you can relplace your old vehicle.");
                    }
                }
                else if (item == deleteVehicle)
                {
                    if (deleteButtonPressedCount == 0)
                    {
                        deleteButtonPressedCount = 1;
                        item.Label = "Press again to confirm.";
                        Notify.Alert("Are you sure you want to delete this vehicle? Press the button again to confirm.");
                    }
                    else
                    {
                        deleteButtonPressedCount = 0;
                        item.Label = "";
                        DeleteResourceKvp(currentlySelectedVehicle.Key);
                        UpdateMenuAvailableCategories();
                        selectedVehicleMenu.GoBack();
                        Notify.Success("Your saved vehicle has been deleted.");
                    }
                }
                if (item != deleteVehicle) // if any other button is pressed, restore the delete vehicle button pressed count.
                {
                    deleteButtonPressedCount = 0;
                    deleteVehicle.Label      = "";
                }
            };
            unavailableVehiclesMenu.InstructionalButtons.Add(Control.FrontendDelete, "Delete Vehicle!");

            unavailableVehiclesMenu.ButtonPressHandlers.Add(new Menu.ButtonPressHandler(Control.FrontendDelete, Menu.ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((m, c) =>
            {
                if (m.Size > 0)
                {
                    int index = m.CurrentIndex;
                    if (index < m.Size)
                    {
                        MenuItem item = m.GetMenuItems().Find(i => i.Index == index);
                        if (item != null && (item.ItemData is KeyValuePair <string, VehicleInfo> sd))
                        {
                            if (item.Label == "~r~Are you sure?")
                            {
                                Log("Unavailable saved vehicle deleted, data: " + JsonConvert.SerializeObject(sd));
                                DeleteResourceKvp(sd.Key);
                                unavailableVehiclesMenu.GoBack();
                                UpdateMenuAvailableCategories();
                            }
                            else
                            {
                                item.Label = "~r~Are you sure?";
                            }
                        }
                        else
                        {
                            Notify.Error("Somehow this vehicle could not be found.");
                        }
                    }
                    else
                    {
                        Notify.Error("You somehow managed to trigger deletion of a menu item that doesn't exist, how...?");
                    }
                }
Пример #30
0
        public MainMenu()
        {
            MenuController.MenuToggleKey = Control.SelectCharacterMichael;
            MenuController.EnableMenuToggleKeyOnController = false;

            // Setting the menu alignment to be right aligned. This can be changed at any time and it'll update instantly.
            // To test this, checkout one of the checkbox items in this example menu. Clicking it will toggle the menu alignment.
            MenuController.MenuAlignment = MenuController.MenuAlignmentOption.Right;

            // Creating the first menu.
            Menu Color = new Menu("Color Menu", "By Alsekwolf")
            {
                Visible = true
            };

            MenuController.AddMenu(Color);



            /*
             ########################################################
             #                   Paint
             */
            //Box for applying primary paint
            MenuCheckboxItem paintPrimary = new MenuCheckboxItem("Apply primary RGB", "This will make your paint apply as you change it")
            {
                Style = MenuCheckboxItem.CheckboxStyle.Tick
            };

            Color.AddMenuItem(paintPrimary);
            //Box for applying primary paint
            //Box for applying secondary paint
            MenuCheckboxItem paintSecondary = new MenuCheckboxItem("Apply secondary RGB", "This will make your paint apply as you change it")
            {
                Style = MenuCheckboxItem.CheckboxStyle.Tick
            };

            Color.AddMenuItem(paintSecondary);
            //Box for applying secondary paint



            //List for color Red
            var RedColorList = new List <string> {
                "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", "253", "254", "255"
            };
            MenuListItem RedColor = new MenuListItem("Red", RedColorList, 0, "Set the red in RGB.");

            Color.AddMenuItem(RedColor);
            //List for color Red

            //List for color Blue
            var BlueColorList = new List <string> {
                "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", "253", "254", "255"
            };
            MenuListItem BlueColor = new MenuListItem("Blue", BlueColorList, 0, "Set the blue in RGB.");

            Color.AddMenuItem(BlueColor);
            //List for color Blue

            //List for color Green
            var GreenColorList = new List <string> {
                "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", "250", "251", "252", "253", "254", "255"
            };
            MenuListItem GreenColor = new MenuListItem("Green", GreenColorList, 0, "Set the Green in RGB.");

            Color.AddMenuItem(GreenColor);
            //List for color Green

            /*
             *       Paint
             ########################################################
             */

            //Adding the misc sub menu
            {
                Misc = new MiscMenu();
                Menu     MiscMenu   = Misc.GetMenu();
                MenuItem MiscButton = new MenuItem("Miscellaneous & Credits", "Miscellaneous stuff")
                {
                    Label = "→→→"
                };
                Color.AddMenuItem(MiscButton);
                MenuController.BindMenuItem(Color, MiscMenu, MiscButton);
            }

            /*
             ########################################################
             #                   Event handlers
             ########################################################
             */

            Color.OnListIndexChange += (_menu, _listItem, _oldIndex, _newIndex, _itemIndex) =>
            {
                // Code in here would get executed whenever the selected value of a list item changes (when left/right key is pressed).
                if (DebugMode == true)
                {
                    Debug.WriteLine($"OnListIndexChange: [{_menu}, {_listItem}, {_oldIndex}, {_newIndex}, {_itemIndex}]");
                }

                if (_listItem == RedColor)
                {
                    // Get the selected value.
                    var value = RedColorList[_newIndex];
                    // Convert the value to a float and set it as a public variable.
                    RedRGB = int.Parse(value);

                    if (ApplyColorPrimary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomPrimaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (ApplyColorSecondary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomSecondaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (MainMenu.DebugMode == true)
                    {
                        Debug.Write($"{RedRGB}");
                    }
                    else
                    {
                        return;
                    }
                }

                if (_listItem == BlueColor)
                {
                    // Get the selected value.
                    var value = BlueColorList[_newIndex];
                    // Convert the value to a float and set it as a public variable.
                    BlueRGB = int.Parse(value);
                    if (ApplyColorPrimary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomPrimaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (ApplyColorSecondary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomSecondaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (DebugMode == true)
                    {
                        Debug.Write($"{BlueRGB}");
                    }
                    else
                    {
                        return;
                    }
                }

                if (_listItem == GreenColor)
                {
                    // Get the selected value.
                    var value = GreenColorList[_newIndex];
                    // Convert the value to a float and set it as a public variable.
                    GreenRGB = int.Parse(value);

                    if (ApplyColorPrimary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomPrimaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (ApplyColorSecondary == true)
                    {
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomSecondaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    if (DebugMode == true)
                    {
                        Debug.Write($"{GreenRGB}");
                    }
                    else
                    {
                        return;
                    }
                }
            };


            Color.OnCheckboxChange += (_menu, _item, _index, _checked) =>
            {
                // Code in here gets executed whenever a checkbox is toggled.
                if (DebugMode == true)
                {
                    Debug.WriteLine($"OnCheckboxChange: [{_menu}, {_item}, {_index}, {_checked}]");
                }
                if (_item == paintPrimary)
                {
                    if (_checked)
                    {
                        ApplyColorPrimary = true;
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomPrimaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    else
                    {
                        ApplyColorPrimary = false;
                    }
                }

                if (_item == paintSecondary)
                {
                    if (_checked)
                    {
                        ApplyColorSecondary = true;
                        var PlayerVehicle = GetPlayersLastVehicle();
                        SetVehicleCustomSecondaryColour(PlayerVehicle, RedRGB, BlueRGB, GreenRGB);
                    }
                    else
                    {
                        ApplyColorSecondary = false;
                    }
                }
            };


            Color.OnMenuClose += (_menu) =>
            {
                if (MainMenu.DebugMode == true)
                {
                    // Code in here gets triggered whenever the menu is closed.
                    Debug.WriteLine($"OnMenuClose: [{_menu}]");
                }
            };

            Color.OnMenuOpen += (_menu) =>
            {
                if (MainMenu.DebugMode == true)
                {
                    // Code in here gets triggered whenever the menu is opened.
                    Debug.WriteLine($"OnMenuOpen: [{_menu}]");
                }
            };
        }