コード例 #1
1
    public PIMenu()
    {
        Tick += OnTick;
        KeyDown += OnKeyDown;

        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@brave");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@confident");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@drunk");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@drunk@verydrunk");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@fat@a");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@shadyped@a");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@hurry@a");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@injured");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@intimidation@1h");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@quick");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@sad@a");
        Function.Call(Hash.REQUEST_CLIP_SET, "move_m@tool_belt@a");

        MenuColor = Color.Blue;

        MainMenu = new UIMenu(Game.Player.Name.ToString(), "INTERACTION MENU", new Point(0, 0));
        MenuPool.Add(MainMenu);
        GlobalMenuBanner = new UIResRectangle();
        GlobalMenuBanner.Color = MenuColor;
        MainMenu.SetBannerType(GlobalMenuBanner);
        MainMenu.Title.Font = GTA.Font.ChaletComprimeCologne;
        MainMenu.Title.Scale = 0.86f;
        MainMenu.Subtitle.Color = MenuColor;

        var QuickGPSList = new List<dynamic>
        {
            "None",
            "Ammu-Nation",
            "Convenience Store",
            "Mod Shop",
            "Clothes Store",
        };

        MainMenu.AddItem(QuickGPSItem = new UIMenuListItem("Quick GPS", QuickGPSList, 0, "Select to place your waypoint at a set location."));

        QuickGPSItem.Activated += (UIMenu sender, UIMenuItem selecteditem) =>
        {
            var tmpList = (UIMenuListItem)selecteditem;
            switch (tmpList.Index)
            {
                case 0:
                    Function.Call(Hash.SET_WAYPOINT_OFF);
                    break;
                case 1:
                    Vector3 NearestAmmunation = PointsOfInterest.GetClosestPoi(Game.Player.Character.Position, PointsOfInterest.Type.AmmuNation);
                    Function.Call(Hash.SET_NEW_WAYPOINT, NearestAmmunation.X, NearestAmmunation.Y);
                    break;
            }
        };

        InventoryMenu = new UIMenu(Game.Player.Name.ToString(), "INVENTORY", new Point(0, 0));
        MenuPool.Add(InventoryMenu);
        InventoryMenu.SetBannerType(GlobalMenuBanner);
        InventoryMenu.Title.Font = GTA.Font.ChaletComprimeCologne;
        InventoryMenu.Title.Scale = 0.86f;
        InventoryMenu.Subtitle.Color = MenuColor;

        var InventoryMenuItem = new UIMenuItem("Inventory", "Your inventory which contains clothing, ammo, and much more.");

        MainMenu.AddItem(InventoryMenuItem);

        MainMenu.BindMenuToItem(InventoryMenu, InventoryMenuItem);

        var PlayerMoodsList = new List<dynamic>
        {
            "None",
            "Normal",
            "Happy",
            "Angry",
            "Injured",
            "Stressed",
        };

        MainMenu.AddItem(PlayerMoodItem = new UIMenuListItem("Player Mood", PlayerMoodsList, 0, "Sets your character's facial expression."));

        var WalkStyleList = new List<dynamic>
        {
            "Normal",
            "Brave",
            "Confident",
            "Drunk",
            "Fat",
            "Gangster",
            "Hurry",
            "Injured",
            "Intimidated",
            "Quick ",
            "Sad",
            "Tough Guy"
        };

        MainMenu.AddItem(WalkStyleItem = new UIMenuListItem("Walk Style", WalkStyleList, 0, "Sets your Character's walking style."));

        var AimingStyleList = new List<dynamic>
        {
            "None",
            "Gangster",
            "Cowboy",
        };

        MainMenu.AddItem(AimingStyleItem = new UIMenuListItem("Aiming Style", AimingStyleList, 0, "Sets your Character's pistol aiming style."));

        PassiveModeItem = new UIMenuItem("Enable Passive Mode", "Passive Mode will prevent damage and wanted levels from police.");

        MainMenu.AddItem(PassiveModeItem);

        MenuOptionsMenu = new UIMenu(Game.Player.Name.ToString(), "MENU OPTIONS", new Point(0, 0));
        MenuPool.Add(MenuOptionsMenu);
        MenuOptionsMenu.SetBannerType(GlobalMenuBanner);
        MenuOptionsMenu.Title.Font = GTA.Font.ChaletComprimeCologne;
        MenuOptionsMenu.Title.Scale = 0.86f;
        MenuOptionsMenu.Subtitle.Color = MenuColor;

        var MenuOptionsMenuItem = new UIMenuItem("Menu Options", "");

        MainMenu.AddItem(MenuOptionsMenuItem);

        MainMenu.BindMenuToItem(MenuOptionsMenu, MenuOptionsMenuItem);

        AboutMenu = new UIMenu(Game.Player.Name.ToString(), "ABOUT", new Point(0, 0));
        MenuPool.Add(AboutMenu);
        AboutMenu.SetBannerType(GlobalMenuBanner);
        AboutMenu.Title.Font = GTA.Font.ChaletComprimeCologne;
        AboutMenu.Title.Scale = 0.86f;
        AboutMenu.Subtitle.Color = MenuColor;

        var AboutOptionsMenuItem = new UIMenuItem("About", "");

        MenuOptionsMenu.BindMenuToItem(AboutMenu, AboutOptionsMenuItem);

        var MenuColorList = new List<dynamic>
        {
            "Blue",
            "Red",
            "Green",
            "Orange",
            "Purple",
            "Yellow",
        };

        MenuOptionsMenu.AddItem(MenuColorItem = new UIMenuListItem("Color", MenuColorList, 0, "Select interaction menu's color theme."));

        MenuOptionsMenu.AddItem(AboutOptionsMenuItem);

        var VersionItem = new UIMenuItem("Version");
        var AuthorItem = new UIMenuItem("Author");

        AboutMenu.AddItem(VersionItem);
        AboutMenu.AddItem(AuthorItem);

        VersionItem.SetRightLabel("1.0");
        AuthorItem.SetRightLabel("jedijosh920 & Guadmaz");

        MainMenu.OnItemSelect += (UIMenu sender, UIMenuItem selectedItem, int index) =>
        {
            switch (index)
            {
                case 5:
                    if (!IsPassiveMode)
                    {
                        Game.Player.Character.IsInvincible = true;
                        Game.Player.Character.Alpha = 200;
                        Function.Call(Hash.SET_POLICE_IGNORE_PLAYER, Game.Player, true);
                        Function.Call(Hash.SET_WANTED_LEVEL_MULTIPLIER, 0.0f);
                        PassiveModeItem.Text = "Disable Passive Mode";
                        IsPassiveMode = true;
                    }

                    else if (IsPassiveMode)
                    {
                        Game.Player.Character.ResetAlpha();
                        Function.Call(Hash.SET_POLICE_IGNORE_PLAYER, Game.Player, false);
                        Function.Call(Hash.SET_WANTED_LEVEL_MULTIPLIER, 1.0f);
                        PassiveModeItem.Text = "Enable Passive Mode";
                        IsPassiveMode = false;
                    }
                    break;
            }
        };

        MenuOptionsMenu.OnListChange += (UIMenu sender, UIMenuListItem listItem, int newIndex) =>
        {
            if (listItem == MenuColorItem)
            {
                switch (newIndex)
                {
                    case 0:
                        MenuColor = Color.Blue;
                        break;
                    case 1:
                        MenuColor = Color.Red;
                        break;
                    case 2:
                        MenuColor = Color.Green;
                        break;
                    case 3:
                        MenuColor = Color.Orange;
                        break;
                    case 4:
                        MenuColor = Color.Purple;
                        break;
                    case 5:
                        MenuColor = Color.Yellow;
                        break;
                }
            }

            if (listItem == WalkStyleItem)
            {
                switch (newIndex)
                {
                    case 0:
                        Game.Player.Character.Task.ClearAll();
                        Function.Call(Hash.RESET_PED_MOVEMENT_CLIPSET, Game.Player.Character, 0x3E800000);
                        break;
                    case 1:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@brave", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 2:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@confident", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 3:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@drunk@verydrunk", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 4:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@fat@a", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 5:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@shadyped@a", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 6:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@hurry@a", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 7:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@injured", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 8:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@intimidation@1h", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 9:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@quick", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 10:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@sad@a", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                    case 11:
                        Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, Game.Player.Character, "move_m@tool_belt@a", 0x3E800000);
                        Game.Player.Character.Task.ClearAll();
                        break;
                }
            }

            if (listItem == PlayerMoodItem)
            {
                switch (newIndex)
                {
                    case 0:
                        Function.Call(Hash.CLEAR_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character);
                        break;
                    case 1:
                        Function.Call(Hash.SET_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character, "mood_normal_1", 0);
                        break;
                    case 2:
                        Function.Call(Hash.SET_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character, "mood_happy_1", 0);
                        break;
                    case 3:
                        Function.Call(Hash.SET_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character, "Mood_Angry_1", 0);
                        break;
                    case 4:
                        Function.Call(Hash.SET_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character, "Mood_Injured_1", 0);
                        break;
                    case 5:
                        Function.Call(Hash.SET_FACIAL_IDLE_ANIM_OVERRIDE, Game.Player.Character, "Mood_Stressed_1", 0);
                        break;
                }
            }

            if (listItem == AimingStyleItem)
            {
                switch (newIndex)
                {
                    case 0:
                        Function.Call(Hash.SET_WEAPON_ANIMATION_OVERRIDE, Game.Player.Character, Function.Call<int>(Hash.GET_HASH_KEY, "default"));
                        break;
                    case 1:
                        Function.Call(Hash.SET_WEAPON_ANIMATION_OVERRIDE, Game.Player.Character, Function.Call<int>(Hash.GET_HASH_KEY, "Gang1H"));
                        break;
                    case 2:
                        Function.Call(Hash.SET_WEAPON_ANIMATION_OVERRIDE, Game.Player.Character, Function.Call<int>(Hash.GET_HASH_KEY, "Hillbilly"));
                        break;
                }
            }
        };

        var menu = new AmmoMenu();
        var ammoItem = new UIMenuItem("Ammo");
        InventoryMenu.AddItem(ammoItem);
        InventoryMenu.BindMenuToItem(menu, ammoItem);
        MenuPool.Add(menu);

        MainMenu.RefreshIndex();
        InventoryMenu.RefreshIndex();
    }
コード例 #2
0
        /// <summary>
        /// List item, with left/right arrows that switches the current menu depending on the current <see cref="UIMenu"/> item.
        /// The menus list and the menus names list must have the same items count.
        /// </summary>
        /// <param name="text">Item label.</param>
        /// <param name="menus">List that contains your <see cref="UIMenu"/>s.</param>
        /// <param name="menusNames">List that contains a name for each <see cref="UIMenu"/> in the same order</param>
        /// <param name="index">Index in the list. If unsure user 0.</param>
        /// <param name="description">Description for this item.</param>
        public UIMenuSwitchMenusItem(string text, List<UIMenu> menus, List<string> menusNames, int index, string description)
            : base(text, new List<dynamic>(menusNames), index, description)
        {
            if (menus.Count != menusNames.Count)
                throw new ArgumentException("The UIMenu list and the names strings list must have the same items count", "menus, menusNames");

            _menus = new List<UIMenu>(menus);
            _currentMenu = IndexToMenu(index);
        }
コード例 #3
0
ファイル: SimpleUI.cs プロジェクト: mcmtroffaes/ChangingRoom
 /// <summary>
 /// Add checkbox to menu.
 /// </summary>
 /// <param name="menu">Parent menu.</param>
 /// <param name="item">The checkbox item.</param>
 /// <param name="OnSelect">What to do when item is selected.</param>
 /// <param name="OnHover">What to do when item is hovered.</param>
 /// <param name="OnChange">What to do when checkbox selection is changed.</param>
 public void AddCheckboxItem(
     UIMenu menu, UIMenuCheckboxItem item,
     Action OnSelect = null, Action OnHover = null, Action<bool> OnChange = null)
 {
     AddItem(menu, item, OnSelect: OnSelect, OnHover: OnHover);
     if (OnChange != null)
         menu.OnCheckboxChange += (sender, item2, checked_) =>
         {
             if (item == item2) OnChange(checked_);
         };
 }
コード例 #4
0
ファイル: MenuExample.cs プロジェクト: nuegen/NativeUI
    public void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
    {
        if (sender != mainMenu || selectedItem != cookItem) return; // We only want to detect changes from our menu and our button.
        // You can also detect the button by using index
        string dish = dishesListItem.IndexToItem(dishesListItem.Index).ToString();
        bool ketchup = ketchupCheckbox.Checked;

        string output = ketchup
            ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup."
            : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
        UI.ShowSubtitle(String.Format(output, dish));
    }
コード例 #5
0
ファイル: MenuExample.cs プロジェクト: isti37/NativeUI
 public void AddMenuKetchup(UIMenu menu)
 {
     var newitem = new UIMenuCheckboxItem("Add ketchup?", ketchup, "Do you wish to add ketchup?");
     menu.AddItem(newitem);
     menu.OnCheckboxChange += (sender, item, checked_) =>
     {
         if (item == newitem)
         {
             ketchup = checked_;
             UI.Notify("~r~Ketchup status: ~b~" + ketchup);
         }
     };
 }
コード例 #6
0
ファイル: SimpleUI.cs プロジェクト: mcmtroffaes/ChangingRoom
 /// <summary>
 /// Add item to menu.
 /// </summary>
 /// <param name="menu">Parent menu.</param>
 /// <param name="item">The item.</param>
 /// <param name="OnSelect">What to do when item is selected.</param>
 /// <param name="OnHover">What to do if item is hovered.</param>
 public void AddItem(
     UIMenu menu, UIMenuItem item,
     Action OnSelect = null, Action OnHover = null)
 {
     menu.AddItem(item);
     if (OnSelect != null)
         menu.OnItemSelect += (sender, item2, index) =>
         {
             if (item == item2) OnSelect();
         };
     if (OnHover != null)
         menu.OnIndexChange += (sender, index) =>
         {
             if (sender.MenuItems[index] == item) OnHover();
         };
 }
コード例 #7
0
ファイル: MenuExample.cs プロジェクト: isti37/NativeUI
    public MenuExample()
    {
        _menuPool = new MenuPool();
        var mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");
        _menuPool.Add(mainMenu);
        AddMenuKetchup(mainMenu);
        AddMenuFoods(mainMenu);
        AddMenuCook(mainMenu);
        AddMenuAnotherMenu(mainMenu);
        _menuPool.RefreshIndex();

        Tick += (o, e) => _menuPool.ProcessMenus();
        KeyDown += (o, e) =>
        {
            if (e.KeyCode == Keys.F5 && !_menuPool.IsAnyMenuOpen()) // Our menu on/off switch
                mainMenu.Visible = !mainMenu.Visible;
        };
    }
コード例 #8
0
ファイル: MenuExample.cs プロジェクト: isti37/NativeUI
 public void AddMenuCook(UIMenu menu)
 {
     var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.");
     newitem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
     newitem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
     menu.AddItem(newitem);
     menu.OnItemSelect += (sender, item, index) =>
     {
         if (item == newitem)
         {
             string output = ketchup ? "You have ordered ~b~{0}~w~ ~r~with~w~ ketchup." : "You have ordered ~b~{0}~w~ ~r~without~w~ ketchup.";
             UI.ShowSubtitle(String.Format(output, dish));
         }
     };
     menu.OnIndexChange += (sender, index) =>
     {
         if (sender.MenuItems[index] == newitem)
             newitem.SetLeftBadge(UIMenuItem.BadgeStyle.None);
     };
 }
コード例 #9
0
ファイル: MenuExample.cs プロジェクト: nuegen/NativeUI
    public MenuExample()
    {
        Tick += OnTick;
        KeyDown += OnKeyDown;
        _menuPool = new MenuPool();

        mainMenu = new UIMenu("Native UI", "~b~NATIVEUI SHOWCASE");
        _menuPool.Add(mainMenu);

        mainMenu.AddItem(ketchupCheckbox = new UIMenuCheckboxItem("Add ketchup?", false, "Do you wish to add ketchup?"));
        var foods = new List<dynamic>
        {
            "Banana",
            "Apple",
            "Pizza",
            "Quartilicious",
            0xF00D, // Dynamic!
        };
        mainMenu.AddItem(dishesListItem = new UIMenuListItem("Food", foods, 0));
        mainMenu.AddItem(cookItem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup."));

        var menuItem = new UIMenuItem("Go to another menu.");
        mainMenu.AddItem(menuItem);
        cookItem.SetLeftBadge(UIMenuItem.BadgeStyle.Star);
        cookItem.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
        mainMenu.RefreshIndex();

        mainMenu.OnItemSelect += OnItemSelect;
        mainMenu.OnListChange += OnListChange;
        mainMenu.OnCheckboxChange += OnCheckboxChange;
        mainMenu.OnIndexChange += OnItemChange;

        newMenu = new UIMenu("Native UI", "~r~NATIVEUI SHOWCASE");
        _menuPool.Add(newMenu);
        for (int i = 0; i < 20; i++)
        {
            newMenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));
        }
        newMenu.RefreshIndex();
        mainMenu.BindMenuToItem(newMenu, menuItem);
    }
コード例 #10
0
ファイル: MenuExample.cs プロジェクト: isti37/NativeUI
    public void AddMenuFoods(UIMenu menu)
    {
        var foods = new List<dynamic>
        {
            "Banana",
            "Apple",
            "Pizza",
            "Quartilicious",
            0xF00D, // Dynamic!
        };
        var newitem = new UIMenuListItem("Food", foods, 0);
        menu.AddItem(newitem);
        menu.OnListChange += (sender, item, index) =>
        {
            if (item == newitem)
            {
                dish = item.IndexToItem(index).ToString();
                UI.Notify("Preparing ~b~" + dish + "~w~...");
            }

        };
    }
コード例 #11
0
 public static void OnItemChange(UIMenu sender, int index)
 {
     sender.MenuItems[index].SetLeftBadge(UIMenuItem.BadgeStyle.None);
     Logger.DebugLog("ItemChange");
 }
コード例 #12
0
 public void AddStorymodeModelToMenu(UIMenu menu)
 {
     var submenu = AddSubMenu(menu, "Change Model");
     foreach (var pedItem in ChangingRoomPeds.peds)
         AddCategoryToMenu(submenu, pedItem.Item1, pedItem.Item2);
 }
コード例 #13
0
 public void AddFreemodeAppearanceToMenu(UIMenu menu)
 {
     var old_data = new Dictionary<SlotKey, SlotValue>();
     // undress character (used when Character or Barber menus are opened)
     Action Undress = () =>
     {
         var ped = Game.Player.Character;
         old_data = ped_data.FreemodeUndress(ped);
     };
     // redress character (when these menus are closed)
     Action Redress = () =>
     {
         var ped = Game.Player.Character;
         ped_data.FreemodeRedress(ped, old_data);
         old_data.Clear();
     };
     var topmenu = AddSubMenu(menu, "Appearance");
     var charmenu = AddSubMenu(topmenu, "Character", OnSelect: Undress, OnClose: Redress);
     var barbmenu = AddSubMenu(topmenu, "Barber", OnSelect: Undress, OnClose: Redress);
     var clo1menu = AddSubMenu(topmenu, "Clothing");
     var clo2menu = AddSubMenu(topmenu, "Clothing Extra");
     // we use parent blend to change face
     //AddSlotToMenu(charmenu, "Face", new SlotKey(SlotType.CompVar, 0));
     AddSlotToMenu(barbmenu, "Haircut", new SlotKey(SlotType.CompVar, 2));
     AddSlotToMenu(barbmenu, "Beard", new SlotKey(SlotType.HeadOverlay, 1));
     AddSlotToMenu(barbmenu, "Eyebrows", new SlotKey(SlotType.HeadOverlay, 2));
     AddSlotToMenu(barbmenu, "Makeup", new SlotKey(SlotType.HeadOverlay, 4));
     AddSlotToMenu(barbmenu, "Blush", new SlotKey(SlotType.HeadOverlay, 5));
     AddSlotToMenu(barbmenu, "Lipstick", new SlotKey(SlotType.HeadOverlay, 8));
     AddSlotToMenu(barbmenu, "Chest Hair", new SlotKey(SlotType.HeadOverlay, 10));
     AddSlotToMenu(barbmenu, "Eyes", new SlotKey(SlotType.Eye, 0));
     AddSlotToMenu(charmenu, "Heritage", new SlotKey(SlotType.Parent, 0));
     AddSlotToMenu(charmenu, "Blemishes", new SlotKey(SlotType.HeadOverlay, 0));
     AddSlotToMenu(charmenu, "Ageing", new SlotKey(SlotType.HeadOverlay, 3));
     AddSlotToMenu(charmenu, "Complexion", new SlotKey(SlotType.HeadOverlay, 6));
     AddSlotToMenu(charmenu, "Sun Damage", new SlotKey(SlotType.HeadOverlay, 7));
     AddSlotToMenu(charmenu, "Moles", new SlotKey(SlotType.HeadOverlay, 9));
     AddSlotToMenu(charmenu, "Body Blemishes", new SlotKey(SlotType.HeadOverlay, 11));
     AddSlotToMenu(charmenu, "Add Body Blemishes", new SlotKey(SlotType.HeadOverlay, 12));
     AddSlotToMenu(clo1menu, "Hands", new SlotKey(SlotType.CompVar, 3));
     AddSlotToMenu(clo1menu, "Shirt", new SlotKey(SlotType.CompVar, 11));
     AddSlotToMenu(clo1menu, "Extra Shirt", new SlotKey(SlotType.CompVar, 8));
     AddSlotToMenu(clo1menu, "Pants", new SlotKey(SlotType.CompVar, 4));
     AddSlotToMenu(clo1menu, "Shoes", new SlotKey(SlotType.CompVar, 6));
     AddSlotToMenu(clo2menu, "Hat", new SlotKey(SlotType.Prop, 0));
     AddSlotToMenu(clo2menu, "Mask", new SlotKey(SlotType.CompVar, 1));
     AddSlotToMenu(clo2menu, "Glasses", new SlotKey(SlotType.Prop, 1));
     AddSlotToMenu(clo2menu, "Earrings", new SlotKey(SlotType.Prop, 2));
     AddSlotToMenu(clo2menu, "Tie & Scarf", new SlotKey(SlotType.CompVar, 7));
     AddSlotToMenu(clo2menu, "Watch", new SlotKey(SlotType.Prop, 6));
     AddSlotToMenu(clo2menu, "Bangle", new SlotKey(SlotType.Prop, 7));
     AddSlotToMenu(clo2menu, "Parachute", new SlotKey(SlotType.CompVar, 5));
     AddSlotToMenu(clo2menu, "Armour", new SlotKey(SlotType.CompVar, 9));
     AddSlotToMenu(clo2menu, "Decal", new SlotKey(SlotType.CompVar, 10));
 }
コード例 #14
0
        public override void Draw()
        {
            base.Draw();

            if (!Focused)
            {
                DrawSprite("minimap_sea_2_0", "minimap_sea_2_0", new Point(BottomRight.X - 1024, TopLeft.Y), new Size(1024, 1024));

                if (Game.IsControlJustPressed(Control.Attack))
                {
                    Focused           = true;
                    _justOpened_mouse = true;
                    _justOpened_kb    = true;
                    Audio.PlaySoundFrontend("accept", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                }
            }
            else
            {
                Game.EnableControlThisFrame(Control.CursorX);
                Game.EnableControlThisFrame(Control.CursorY);
                var res    = UIMenu.GetScreenResolutionMantainRatio();
                var mouseX = Function.Call <float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.CursorX) * res.Width;
                var mouseY = Function.Call <float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.CursorY) * res.Height;
                var center = new Point((int)(res.Width / 2), (int)(res.Height / 2));


                if (Math.Abs(mouseX - _lastMouseInput.X) > 1f || Math.Abs(mouseY - _lastMouseInput.Y) > 1f)
                {
                    _wasMouseInput = true;
                }

                if (Game.IsControlJustPressed(Control.CursorAccept))
                {
                    _isHeldDown       = true;
                    _heldDownPoint    = new PointF(mouseX, mouseY);
                    _mapPosAtHelddown = Position;
                    _holdDownTime     = DateTime.Now;
                }
                else if (Game.IsControlJustReleased(Control.CursorAccept))
                {
                    if (_justOpened_mouse)
                    {
                        _justOpened_mouse = false;
                        _justOpened_kb    = false;
                    }
                    else
                    {
                        Position = _mapPosAtHelddown +
                                   new SizeF((_heldDownPoint.X - mouseX) / Zoom, (_heldDownPoint.Y - mouseY) / Zoom);
                        _isHeldDown = false;

                        if (DateTime.Now.Subtract(_holdDownTime).TotalMilliseconds < 100)
                        {
                            if (Function.Call <bool>(Hash.IS_WAYPOINT_ACTIVE))
                            {
                                Function.Call(Hash.SET_WAYPOINT_OFF);
                                Audio.PlaySoundFrontend("CANCEL", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            }
                            else
                            {
                                var wpyPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                                var ourShit = new SizeF(mouseX - wpyPos.X, mouseY - wpyPos.Y);
                                var realPos = Map2DToWorld3d(wpyPos, wpyPos + ourShit);
                                Function.Call(Hash.SET_NEW_WAYPOINT, realPos.X, realPos.Y * -1f);
                                Audio.PlaySoundFrontend("WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                            }
                        }
                    }
                }

                if (Game.IsControlJustReleased(Control.FrontendAccept))
                {
                    if (_justOpened_kb)
                    {
                        _justOpened_kb    = false;
                        _justOpened_mouse = false;
                    }
                    else
                    {
                        if (Function.Call <bool>(Hash.IS_WAYPOINT_ACTIVE))
                        {
                            Function.Call(Hash.SET_WAYPOINT_OFF);
                            Audio.PlaySoundFrontend("CANCEL", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                        }
                        else
                        {
                            var wpyPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                            var ourShit = new SizeF(center.X - wpyPos.X, center.Y - wpyPos.Y);
                            var realPos = Map2DToWorld3d(wpyPos, wpyPos + ourShit);
                            Function.Call(Hash.SET_NEW_WAYPOINT, realPos.X, realPos.Y * -1f);
                            Audio.PlaySoundFrontend("WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                        }
                    }
                }

                if (_isHeldDown)
                {
                    Position = _mapPosAtHelddown + new SizeF((_heldDownPoint.X - mouseX) / Zoom, (_heldDownPoint.Y - mouseY) / Zoom);
                }

                var newPos  = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                var newSize = new SizeF(1024.5f * Zoom, 1024.5f * Zoom);

                DrawSprite("minimap_sea_0_0", "minimap_sea_0_0", newPos, newSize);
                DrawSprite("minimap_sea_0_1", "minimap_sea_0_1", newPos + new SizeF(1024 * Zoom, 0), newSize);

                DrawSprite("minimap_sea_1_0", "minimap_sea_1_0", newPos + new SizeF(0, 1024 * Zoom), newSize);
                DrawSprite("minimap_sea_1_1", "minimap_sea_1_1", newPos + new SizeF(1024 * Zoom, 1024 * Zoom), newSize);

                DrawSprite("minimap_sea_2_0", "minimap_sea_2_0", newPos + new SizeF(0, 2048 * Zoom), newSize);
                DrawSprite("minimap_sea_2_1", "minimap_sea_2_1", newPos + new SizeF(1024 * Zoom, 2048 * Zoom), newSize);

                _crosshair.Size     = new Size(256, 3);
                _crosshair.Position = center + new Size(10, 0);
                _crosshair.Heading  = 0;
                _crosshair.Draw();

                _crosshair.Position = center - new Size(266, 0);
                _crosshair.Heading  = 180;
                _crosshair.Draw();

                _crosshair.Size     = new Size(3, 256);
                _crosshair.Heading  = 90;
                _crosshair.Position = center + new Size(0, 10);
                _crosshair.Draw();

                _crosshair.Position = center - new Size(0, 266);
                _crosshair.Heading  = 270;
                _crosshair.Draw();

                const float playerScale = 0.8f;

                Ped PlayerChar = Game.Player.Character;
                Util.Util.DxDrawTexture(0, BLIP_PATH + "player.png",
                                        newPos.X + World3DToMap2D(PlayerChar.Position).Width,
                                        newPos.Y + World3DToMap2D(PlayerChar.Position).Height, 32 * playerScale, 32 * playerScale,
                                        -PlayerChar.Rotation.Z, 255, 255, 255, 255, true);



                var blipList  = new List <string>();
                var localCopy = new List <IStreamedItem>(Main.NetEntityHandler.ClientMap.Values);

                foreach (var blip in Util.Util.GetAllBlips())
                {
                    if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                    {
                        var blipInfo = Main.NetEntityHandler.EntityToStreamedItem(blip.Handle) as RemoteBlip;

                        float scale = 1f;

                        if (blipInfo != null)
                        {
                            scale = blipInfo.Scale;
                        }

                        var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                        var pos   = newPos + World3DToMap2D(blip.Position);
                        var siz   = new Size((int)(scale * 32), (int)(scale * 32));
                        var col   = GetBlipcolor(blip.Color, blip.Alpha);

                        if (pos.X > 0 && pos.Y > 0 && pos.X < res.Width && pos.Y < res.Height)
                        {
                            Util.Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A, true);
                        }

                        var len      = scale * 32;
                        var halfLen  = len / 2;
                        var hoverPos = new PointF(mouseX, mouseY);

                        if (!_wasMouseInput)
                        {
                            hoverPos = center;
                        }

                        if (!string.IsNullOrEmpty(blipInfo?.Name) && hoverPos.X > pos.X - halfLen && hoverPos.Y > pos.Y - halfLen && hoverPos.X < pos.X + halfLen && hoverPos.Y < pos.Y + halfLen)                     // hovering over blip
                        {
                            var labelPos = pos - new Size(-32, 14);

                            new Sprite("mplobby", "mp_arrowsmall", new Point((int)labelPos.X - 19, (int)labelPos.Y - 15),
                                       new Size(20, 60), 180f, Color.Black).Draw();
                            new UIResRectangle(new Point((int)labelPos.X, (int)labelPos.Y), new Size(15 + StringMeasurer.MeasureString(blipInfo.Name), 30), Color.Black).Draw();
                            new UIResText(blipInfo.Name, new Point((int)labelPos.X + 5, (int)labelPos.Y), 0.35f).Draw();
                        }
                    }
                }

                foreach (var blip in localCopy.Where(item => item is RemoteBlip && !item.StreamedIn && (item.Dimension == Main.LocalDimension || item.Dimension == 0)).Cast <RemoteBlip>()) // draw the unstreamed blips
                {
                    if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                    {
                        var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                        var pos   = newPos + World3DToMap2D(blip.Position.ToVector());
                        var scale = blip.Scale;
                        var siz   = new Size((int)(scale * 32), (int)(scale * 32));
                        var col   = GetBlipcolor((BlipColor)blip.Color, blip.Alpha);

                        if (pos.X > 0 && pos.Y > 0 && pos.X < res.Width && pos.Y < res.Height)
                        {
                            Util.Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A, true);
                        }
                    }
                }

                foreach (var opp in Main.NetEntityHandler.ClientMap.Where(item => item.Value is SyncPed && (item.Value.Dimension == Main.LocalDimension || item.Value.Dimension == 0)).Select(pair => pair.Value).Cast <SyncPed>())
                {
                    if (opp.Character?.AttachedBlip == null || string.IsNullOrWhiteSpace(opp.Name) || opp.Character.AttachedBlip.Alpha == 0)
                    {
                        continue;
                    }

                    var blip = opp.Character.AttachedBlip;

                    var pos = newPos + World3DToMap2D(blip.Position) - new Size(-32, 14);

                    new Sprite("mplobby", "mp_arrowsmall", new Point((int)pos.X - 19, (int)pos.Y - 15) + offsetP,
                               new Size(20, 60) + offsetS, 180f, Color.Black).Draw();
                    new UIResRectangle(new Point((int)pos.X, (int)pos.Y), new Size(15 + StringMeasurer.MeasureString(opp.Name), 30), Color.Black).Draw();
                    new UIResText(opp.Name, new Point((int)pos.X + 5, (int)pos.Y), 0.35f).Draw();
                }



                var p1        = new PointF(center.X - Position.X * Zoom, center.Y - Position.Y * Zoom);
                var p2        = new SizeF(center.X - p1.X, center.Y - p1.Y);
                var centerPos = Map2DToWorld3d(p1, p1 + p2);

                centerPos = new Vector2(centerPos.X, centerPos.Y * -1f);

                var zone = World.GetZoneDisplayName(centerPos);

                if (!string.IsNullOrEmpty(zone))
                {
                    new UIResRectangle(new Point(30, (int)res.Height - 50),
                                       new Size(15 + StringMeasurer.MeasureString(zone), 30), Color.Black).Draw();
                    new UIResText(zone, new Point(35, (int)res.Height - 50), 0.35f).Draw();
                }

                /*
                 *
                 * foreach (var blipHandle in Main.NetEntityHandler.Blips)
                 *  {
                 *      var blip = new Blip(blipHandle);
                 *      if (!blip.Exists()) continue;
                 *
                 *      if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                 *      {
                 *          var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                 *          var pos = newPos + World3DToMap2D(blip.Position) - new Size(16, 16);
                 *          var siz = new Size(32, 32);
                 *          var col = GetBlipcolor(blip.Color, blip.Alpha);
                 *          var ident = fname +
                 *                      (blipList.Count(k => k == fname) > 0
                 *                          ? blipList.Count(k => k == fname).ToString()
                 *                          : "");
                 *          Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A);
                 *          blipList.Add(((int)blip.Sprite) + ".png");
                 *      }
                 *  }
                 *
                 *
                 * foreach (var blipHandle in Main.BlipCleanup)
                 * {
                 *  var blip = new Blip(blipHandle);
                 *  if (!blip.Exists()) continue;
                 *
                 *  if (File.Exists(BLIP_PATH + ((int)blip.Sprite) + ".png"))
                 *  {
                 *      var fname = BLIP_PATH + ((int)blip.Sprite) + ".png";
                 *      var pos = newPos + World3DToMap2D(blip.Position) - new Size(16, 16);
                 *      var siz = new Size(32, 32);
                 *      var col = GetBlipcolor(blip.Color, blip.Alpha);
                 *      var ident = fname +
                 *                  (blipList.Count(k => k == fname) > 0
                 *                      ? blipList.Count(k => k == fname).ToString()
                 *                      : "");
                 *      Util.DxDrawTexture(blipList.Count, fname, pos.X, pos.Y, siz.Width, siz.Height, 0f, col.R, col.G, col.B, col.A);
                 *      blipList.Add(((int)blip.Sprite) + ".png");
                 *  }
                 * }*/
            }
        }
コード例 #15
0
ファイル: Main.cs プロジェクト: nheisterkamp/bepmod
        public Main()
        {
            Log("Main.Main()");

            _logger = new Logger(_smartEye);

            scenarios.Add(new Scenario1());
            // scenarios.Add(new Scenario2());

            menu = new UIMenu("BepMod", "");

            foreach (Scenario scenario in scenarios)
            {
                scenariosCount++;

                UIMenu scenarioSubMenu = menuPool.AddSubMenu(
                    menu,
                    String.Format("Scenario {0}", scenariosCount.ToString())
                    );

                scenarioSubMenu.AddItem(new UIMenuItem(
                                            "Run",
                                            ""
                                            ));

                int pointIndex    = 0;
                int scenarioIndex = scenariosCount - 1;

                scenarioSubMenu.OnItemSelect += (UIMenu sender, UIMenuItem item, int index) =>
                {
                    Log("Dingen: " + index.ToString());
                    if (index == 0)
                    {
                        RunScenario(scenarioIndex);
                        menu.Visible            = false;
                        scenarioSubMenu.Visible = false;
                    }
                };

                var pointsList = new List <dynamic> {
                };
                for (int i = 0; i < scenario.Points.Length; i++)
                {
                    pointsList.Add(String.Format("Point {0}", i));
                }

                UIMenuListItem pointMenuListItem = new UIMenuListItem("Teleport", pointsList, 0);
                scenarioSubMenu.AddItem(pointMenuListItem);
                scenarioSubMenu.OnItemSelect += (sender, item, index) =>
                {
                    if (index == 1)
                    {
                        Vector3 position = scenario.Points[pointIndex];
                        UI.Notify("Teleport to: " + position.ToString());
                        Game.Player.Character.Position = position;
                    }
                };

                scenarioSubMenu.OnListChange += (sender, item, index) =>
                {
                    if (item == pointMenuListItem)
                    {
                        pointIndex = index;
                    }
                };
            }
            Log("Loaded " + scenariosCount.ToString() + " scenario(s)");

            menu.AddItem(new UIMenuItem("Stop running scenario", ""));

            var debugLevels = new List <dynamic> {
                "None",
                "Gaze",
                "Info",
                "Verbose",
                "Full"
            };

            UIMenuListItem debugLevelMenuItem = new UIMenuListItem("Debug level", debugLevels, debugLevel);

            menu.AddItem(debugLevelMenuItem);

            menu.OnListChange += (sender, item, index) =>
            {
                if (item == debugLevelMenuItem)
                {
                    debugLevel = index;
                    ClearMessages();
                }
            };

            menu.RefreshIndex();

            menu.OnItemSelect     += Menu_OnItemSelect;
            menu.OnCheckboxChange += Menu_OnCheckboxChange;

            menuPool.Add(menu);

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

            menu.AddInstructionalButton(new InstructionalButton("B", "BepMod menu"));
            menu.AddInstructionalButton(new InstructionalButton("N", "Save location"));
            menu.AddInstructionalButton(new InstructionalButton("I", "Load scenario"));

            KeyDown += DoKeyDown;
            Tick    += MainTick;
            Aborted += MainAborted;

            Game.Player.Character.IsInvincible = true;

            if (Game.IsScreenFadedOut)
            {
                Game.FadeScreenIn(0);
            }
        }
コード例 #16
0
 public static void PrettifyMenu(ref UIMenu menu)
 {
     menu.Title.Caption = Game.Player.Name;
     menu.SetBannerType(GlobalMenuBanner);
     menu.Title.Font = GTA.Font.ChaletComprimeCologne;
     menu.Title.Scale = 0.86f;
     menu.Subtitle.Color = MenuColor;
 }
コード例 #17
0
ファイル: SimpleUI.cs プロジェクト: mcmtroffaes/ChangingRoom
 /// <summary>
 /// Add list to menu.
 /// </summary>
 /// <param name="menu">Parent menu.</param>
 /// <param name="listitem">The list.</param>
 /// <param name="OnSelect">What to do when list is selected.</param>
 /// <param name="OnHover">What to do when list is hovered.</param>
 /// <param name="OnChange">What to do when list selection is changed.</param>
 public void AddListItem(
     UIMenu menu, UIMenuListItem listitem,
     Action OnSelect = null, Action OnHover = null, Action<int> OnChange = null)
 {
     AddItem(menu, listitem, OnSelect: OnSelect, OnHover: OnHover);
     if (OnChange != null)
         menu.OnListChange += (sender, item, index) =>
         {
             if (item == listitem) OnChange(index);
         };
 }
コード例 #18
0
ファイル: SimpleUI.cs プロジェクト: mcmtroffaes/ChangingRoom
 /// <summary>
 /// Add submenu to an existing menu.
 /// </summary>
 /// <param name="menu">The parent menu.</param>
 /// <param name="text">Text used for the item to be added to the parent menu.</param>
 /// <param name="OnSelect">What to do when submenu is openend.</param>
 /// <param name="OnClose">What to do when submenu is closed.</param>
 /// <param name="OnHover">What to do when submenu is hovered.</param>
 /// <returns></returns>
 public UIMenu AddSubMenu(
     UIMenu menu, string text,
     Action OnSelect = null, Action OnClose = null, Action OnHover = null)
 {
     var submenu = pool.AddSubMenu(menu, text);
     if (OnSelect != null)
         submenu.ParentMenu.OnItemSelect += (sender, item, index) =>
         {
             if (item == submenu.ParentItem) OnSelect();
         };
     if (OnClose != null)
         submenu.OnMenuClose += (sender) =>
         {
             OnClose();
         };
     if (OnHover != null)
         submenu.ParentMenu.OnIndexChange += (sender, index) =>
         {
             if (sender.MenuItems[index] == submenu.ParentItem) OnHover();
         };
     return submenu;
 }
コード例 #19
0
ファイル: UIMenu.cs プロジェクト: firehot/hogwarts
 public void Start()
 {
     _instance = this;
 }
コード例 #20
0
        public static void Main()
        {
            menuProcessFiber = new GameFiber(MenuProcess);
            _MenuPool        = new MenuPool();
            mainMenu         = new UIMenu("Officer Status Menu", "" + Globals.Unit);
            mainMenu.SetMenuWidthOffset(10);
            serviceMenu = new UIMenu("Service Status Menu", "" + Globals.Unit);
            serviceMenu.SetMenuWidthOffset(10);
            generalMenu = new UIMenu("General Status Menu", "" + Globals.Unit);
            generalMenu.SetMenuWidthOffset(10);
            backupMenu = new UIMenu("Backup Status Menu", "" + Globals.Unit);
            backupMenu.SetMenuWidthOffset(10);

            _MenuPool.Add(mainMenu);
            _MenuPool.Add(serviceMenu);
            _MenuPool.Add(generalMenu);
            _MenuPool.Add(backupMenu);

            serviceMenu.AddItem(menu10_5Item  = new UIMenuItem(">>10-5", "~g~Break"));
            serviceMenu.AddItem(menu10_6Item  = new UIMenuItem(">>10-6", "~g~Busy"));
            serviceMenu.AddItem(menu10_7Item  = new UIMenuItem(">>10-7", "~g~Out of Service"));
            serviceMenu.AddItem(menu10_8Item  = new UIMenuItem(">>10-8", "~g~Available for Calls"));
            serviceMenu.AddItem(menu10_41Item = new UIMenuItem(">>10-41", "~g~Beginning Tour of Duty"));
            serviceMenu.AddItem(menu10_42Item = new UIMenuItem(">>10-42", "~g~Ending Tour of Duty"));

            generalMenu.AddItem(menu10_11List       = new UIMenuListItem(">>10-11", "~g~Traffic Stop", List10_11));
            generalMenu.AddItem(menu10_15Item       = new UIMenuItem(">>10-15", "~g~Suspect in Custody, Returning to Station"));
            generalMenu.AddItem(menu10_19Item       = new UIMenuItem(">>10-19", "~g~Returning to Station"));
            generalMenu.AddItem(menu10_23Item       = new UIMenuItem(">>10-23", "~g~Arrived on Scene"));
            generalMenu.AddItem(menuCode5Item       = new UIMenuItem(">>Code 5", "~g~Felony Stop"));
            generalMenu.AddItem(menuAffirmativeItem = new UIMenuItem(">>Affirmative"));
            generalMenu.AddItem(menuNegativeItem    = new UIMenuItem(">>Negative"));

            backupMenu.AddItem(menu10_32List = new UIMenuListItem(">>10-32", "~g~General Backup", List10_32));
            backupMenu.AddItem(menu10_51Item = new UIMenuItem(">>10-51", "~g~Request a Tow Truck"));
            backupMenu.AddItem(menu10_52Item = new UIMenuItem(">>10-52", "~g~Request an EMS"));
            backupMenu.AddItem(menu10_53Item = new UIMenuItem(">>10-53", "~g~Request Fire Department"));

            mainMenu.AddItem(menuGeneralItem = new UIMenuItem("General Statuses"));
            mainMenu.BindMenuToItem(generalMenu, menuGeneralItem);
            generalMenu.ParentMenu           = mainMenu;
            mainMenu.AddItem(menuServiceItem = new UIMenuItem("Service Statuses"));
            mainMenu.BindMenuToItem(serviceMenu, menuServiceItem);
            serviceMenu.ParentMenu          = mainMenu;
            mainMenu.AddItem(menuBackupItem = new UIMenuItem("Backup Statuses"));
            mainMenu.BindMenuToItem(backupMenu, menuBackupItem);
            backupMenu.ParentMenu          = mainMenu;
            mainMenu.AddItem(menu10_99Item = new UIMenuItem("Panic"));
            menu10_99Item.BackColor        = Color.Red;

            mainMenu.RefreshIndex();
            serviceMenu.RefreshIndex();
            generalMenu.RefreshIndex();
            backupMenu.RefreshIndex();

            mainMenu.OnItemSelect    += OnItemSelect;
            generalMenu.OnItemSelect += OnItemSelect;
            serviceMenu.OnItemSelect += OnItemSelect;
            backupMenu.OnItemSelect  += OnItemSelect;

            mainMenu.AllowCameraMovement     = true;
            mainMenu.MouseControlsEnabled    = false;
            serviceMenu.AllowCameraMovement  = true;
            serviceMenu.MouseControlsEnabled = false;
            generalMenu.AllowCameraMovement  = true;
            generalMenu.MouseControlsEnabled = false;
            backupMenu.AllowCameraMovement   = true;
            backupMenu.MouseControlsEnabled  = false;

            menuProcessFiber.Start();
            Game.Console.Print(Globals.PluginName + ": Menus Initialised");
        }
コード例 #21
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        private void CreateMenu()
        {
            // Create the menu.
            menu = new UIMenu("BigFam Crew", "Misc Settings", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };

            UIMenu teleportMenu = new UIMenu("BigFam Crew", "Teleport Locations", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            UIMenuItem teleportMenuBtn = new UIMenuItem("Teleport Locations", "Teleport to pre-configured locations, added by the server owner.");

            menu.BindMenuToItem(teleportMenu, teleportMenuBtn);
            MainMenu.Mp.Add(teleportMenu);

            // Create the menu items.
            UIMenuItem         tptowp       = new UIMenuItem("Teleport To Waypoint", "Teleport to the waypoint on your map.");
            UIMenuCheckboxItem speedKmh     = new UIMenuCheckboxItem("Show Speed KM/H", ShowSpeedoKmh, "Show a speedometer on your screen indicating your speed in KM/h.");
            UIMenuCheckboxItem speedMph     = new UIMenuCheckboxItem("Show Speed MPH", ShowSpeedoMph, "Show a speedometer on your screen indicating your speed in MPH.");
            UIMenuCheckboxItem coords       = new UIMenuCheckboxItem("Show Coordinates", ShowCoordinates, "Show your current coordinates at the top of your screen.");
            UIMenuCheckboxItem hideRadar    = new UIMenuCheckboxItem("Hide Radar", HideRadar, "Hide the radar/minimap.");
            UIMenuCheckboxItem hideHud      = new UIMenuCheckboxItem("Hide Hud", HideHud, "Hide all hud elements.");
            UIMenuCheckboxItem showLocation = new UIMenuCheckboxItem("Location Display", ShowLocation, "Shows your current location and heading, as well as the nearest cross road. Just like PLD.");
            UIMenuItem         saveSettings = new UIMenuItem("Save Personal Settings", "Save your current settings. All saving is done on the client side, if you re-install windows you will lose your settings. Settings are shared across all servers using vMenu.");

            saveSettings.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
            UIMenuCheckboxItem joinQuitNotifs = new UIMenuCheckboxItem("Join / Quit Notifications", JoinQuitNotifications, "Receive notifications when someone joins or leaves the server.");
            UIMenuCheckboxItem deathNotifs    = new UIMenuCheckboxItem("Death Notifications", DeathNotifications, "Receive notifications when someone dies or gets killed.");
            UIMenuCheckboxItem nightVision    = new UIMenuCheckboxItem("Toggle Night Vision", false, "Enable or disable night vision.");
            UIMenuCheckboxItem thermalVision  = new UIMenuCheckboxItem("Toggle Thermal Vision", false, "Enable or disable thermal vision.");

            UIMenuItem         clearArea = new UIMenuItem("Clear Area", "Clears the area around your player (100 meters) of everything! Damage, dirt, peds, props, vehicles, etc. Everything gets cleaned up and reset.");
            UIMenuCheckboxItem lockCamX  = new UIMenuCheckboxItem("Lock Camera Horizontal Rotation", false, "Locks your camera horizontal rotation. Could be useful in helicopters I guess.");
            UIMenuCheckboxItem lockCamY  = new UIMenuCheckboxItem("Lock Camera Vertical Rotation", false, "Locks your camera vertical rotation. Could be useful in helicopters I guess.");

            UIMenu connectionSubmenu = new UIMenu(GetPlayerName(PlayerId()), "Connection Options", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            UIMenuItem connectionSubmenuBtn = new UIMenuItem("Connection Options", "Server connection/game quit options.");
            UIMenuItem quitSession          = new UIMenuItem("Quit Session", "Leaves you connected to the server, but quits the network session. " +
                                                             "Use this if you need to have addons streamed but want to use the rockstar editor.");
            UIMenuItem quitGame             = new UIMenuItem("Quit Game", "Exits the game after 5 seconds.");
            UIMenuItem disconnectFromServer = new UIMenuItem("Disconnect From Server", "Disconnects you from the server and returns you to the serverlist. " +
                                                             "~r~This feature is not recommended, quit the game instead for a better experience.");

            connectionSubmenu.AddItem(quitSession);
            connectionSubmenu.AddItem(quitGame);
            connectionSubmenu.AddItem(disconnectFromServer);

            UIMenuCheckboxItem locationBlips = new UIMenuCheckboxItem("Location Blips", ShowLocationBlips, "Shows blips on the map for some common locations.");
            UIMenuCheckboxItem playerBlips   = new UIMenuCheckboxItem("Show Player Blips", ShowPlayerBlips, "Shows blips on the map for all players.");

            MainMenu.Mp.Add(connectionSubmenu);
            connectionSubmenu.RefreshIndex();
            connectionSubmenu.UpdateScaleform();
            menu.BindMenuToItem(connectionSubmenu, connectionSubmenuBtn);

            connectionSubmenu.OnItemSelect += (sender, item, index) =>
            {
                if (item == quitGame)
                {
                    cf.QuitGame();
                }
                else if (item == quitSession)
                {
                    cf.QuitSession();
                }
                else if (item == disconnectFromServer)
                {
                    BaseScript.TriggerServerEvent("vMenu:DisconnectSelf");
                }
            };

            // Add menu items to the menu.
            if (cf.IsAllowed(Permission.MSTeleportToWp))
            {
                menu.AddItem(tptowp);
            }

            // Always allowed
            // menu.AddItem(speedKmh);
            // menu.AddItem(speedMph);
            if (cf.IsAllowed(Permission.MSConnectionMenu))
            {
                menu.AddItem(connectionSubmenuBtn);
                connectionSubmenuBtn.SetRightLabel("→→→");
            }
            if (cf.IsAllowed(Permission.MSShowCoordinates))
            {
                menu.AddItem(coords);
            }
            if (cf.IsAllowed(Permission.MSShowLocation))
            {
                menu.AddItem(showLocation);
            }
            if (cf.IsAllowed(Permission.MSJoinQuitNotifs))
            {
                menu.AddItem(deathNotifs);
            }
            if (cf.IsAllowed(Permission.MSDeathNotifs))
            {
                menu.AddItem(joinQuitNotifs);
            }
            if (cf.IsAllowed(Permission.MSNightVision))
            {
                menu.AddItem(nightVision);
            }
            if (cf.IsAllowed(Permission.MSThermalVision))
            {
                menu.AddItem(thermalVision);
            }
            if (cf.IsAllowed(Permission.MSLocationBlips))
            {
                menu.AddItem(locationBlips);
                ToggleBlips(ShowLocationBlips);
            }
            if (cf.IsAllowed(Permission.MSPlayerBlips))
            {
                menu.AddItem(playerBlips);
            }
            if (cf.IsAllowed(Permission.MSTeleportLocations))
            {
                menu.AddItem(teleportMenuBtn);
                teleportMenuBtn.SetRightLabel("→→→");

                string json = LoadResourceFile(GetCurrentResourceName(), "config/locations.json");
                if (string.IsNullOrEmpty(json))
                {
                    Notify.Error("An error occurred while loading the locations file.");
                }
                else
                {
                    try
                    {
                        Newtonsoft.Json.Linq.JObject data = JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>(json);
                        foreach (Newtonsoft.Json.Linq.JToken teleport in data["teleports"])
                        {
                            string     name        = teleport["name"].ToString();
                            float      heading     = (float)teleport["heading"];
                            Vector3    coordinates = new Vector3((float)teleport["coordinates"]["x"], (float)teleport["coordinates"]["y"], (float)teleport["coordinates"]["z"]);
                            UIMenuItem tpBtn       = new UIMenuItem(name, $"Teleport to X: {(int)coordinates.X} Y: {(int)coordinates.Y} Z: {(int)coordinates.Z} HEADING: {(int)heading}.");
                            teleportMenu.AddItem(tpBtn);
                            tpLocations.Add(coordinates);
                            tpLocationsHeading.Add(heading);
                        }
                        teleportMenu.OnItemSelect += async(sender, item, index) =>
                        {
                            await cf.TeleportToCoords(tpLocations[index], true);

                            SetEntityHeading(PlayerPedId(), tpLocationsHeading[index]);
                        };
                    }
                    catch (JsonReaderException ex)
                    {
                        Debug.Write($"\n[vMenu] An error occurred whie loading the teleport locations!\nReport the following error details to the server owner:\n{ex.Message}.\n");
                    }
                }
            }
            if (cf.IsAllowed(Permission.MSClearArea))
            {
                menu.AddItem(clearArea);
            }

            // Always allowed
            // menu.AddItem(hideRadar);
            menu.AddItem(hideHud);
            menu.AddItem(lockCamX);
            // menu.AddItem(lockCamY);
            menu.AddItem(saveSettings);

            // Handle checkbox changes.
            menu.OnCheckboxChange += (sender, item, _checked) =>
            {
                if (item == speedKmh)
                {
                    ShowSpeedoKmh = _checked;
                }
                else if (item == speedMph)
                {
                    ShowSpeedoMph = _checked;
                }
                else if (item == coords)
                {
                    ShowCoordinates = _checked;
                }
                else if (item == hideHud)
                {
                    HideHud = _checked;
                }
                else if (item == hideRadar)
                {
                    HideRadar = _checked;
                    if (!_checked)
                    {
                        DisplayRadar(true);
                    }
                }
                else if (item == showLocation)
                {
                    ShowLocation = _checked;
                }
                else if (item == deathNotifs)
                {
                    DeathNotifications = _checked;
                }
                else if (item == joinQuitNotifs)
                {
                    JoinQuitNotifications = _checked;
                }
                else if (item == nightVision)
                {
                    SetNightvision(_checked);
                }
                else if (item == thermalVision)
                {
                    SetSeethrough(_checked);
                }
                else if (item == lockCamX)
                {
                    LockCameraX = _checked;
                }
                else if (item == lockCamY)
                {
                    LockCameraY = _checked;
                }
                else if (item == locationBlips)
                {
                    ToggleBlips(_checked);
                    ShowLocationBlips = _checked;
                }
                else if (item == playerBlips)
                {
                    ShowPlayerBlips = _checked;
                }
            };

            // Handle button presses.
            menu.OnItemSelect += (sender, item, index) =>
            {
                // Teleport to waypoint.
                if (item == tptowp)
                {
                    cf.TeleportToWp();
                }
                // save settings
                else if (item == saveSettings)
                {
                    UserDefaults.SaveSettings();
                }
                // clear area
                else if (item == clearArea)
                {
                    var pos = Game.PlayerPed.Position;
                    ClearAreaOfEverything(pos.X, pos.Y, pos.Z, 100f, false, false, false, false);
                }
            };
        }
コード例 #22
0
ファイル: MenuExample.cs プロジェクト: nuegen/NativeUI
 public void OnListChange(UIMenu sender, UIMenuListItem list, int index)
 {
     if (sender != mainMenu || list != dishesListItem) return; // We only want to detect changes from our menu.
     string dish = list.IndexToItem(index).ToString();
     UI.Notify("Preparing ~b~" + dish +"~w~...");
 }
コード例 #23
0
        public ClothesStoreManager()
        {
            Instance = this;
            SetupBlips();
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
            DrawMarkers();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
            Tick += new Func <Task>(async delegate
            {
                if (ClothesManager.Instance.modelSet)
                {
                    _menuOpen     = false;
                    _currentStore = null;
                    foreach (ClothesStore store in Stores)
                    {
                        var distance = API.Vdist(store.X, store.Y, store.Z, Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z);
                        if (distance < 5)
                        {
                            _currentStore = store;
                            _menuOpen     = true;
                        }
                    }

                    if (Housing.Manager.Instance.CurrentHouse != null)
                    {
                        _currentStore = new ClothesStore(Housing.Manager.Instance.CurrentHouse.Position.X, Housing.Manager.Instance.CurrentHouse.Position.Y, Housing.Manager.Instance.CurrentHouse.Position.Z, "Home", ClothesStoreTypes.Clothes);
                    }

                    if (_menuOpen && !_menuCreated)
                    {
                        _menuCreated = true;
                        switch (_currentStore.Type)
                        {
                        case ClothesStoreTypes.Clothes:
                            Menu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(InteractionMenu.Instance._interactionMenu, "Clothing Store", "Open the clothing store and choose your clothing.", new PointF(5, Screen.Height / 2));
                            //var test10 = new ComponentUI(menu, "10", 9, ComponentTypes.Tasks);//Vests
                            //var test11 = new ComponentUI(menu, "11", 10, ComponentTypes.Textures);// Decals
                            var Hats       = new PropUI(Menu, "Hats", 0, PropTypes.Hats);
                            var Gloves     = new ComponentUI(Menu, "Gloves", 3, ComponentTypes.Torso);               //Arms/Gloves
                            var Overshirts = new ComponentUI(Menu, "Overshirts", 11, ComponentTypes.Torso2);         //Overshirt
                            var Pants      = new ComponentUI(Menu, "Pants", 4, ComponentTypes.Legs);                 // Pants
                            var Backpack   = new ComponentUI(Menu, "Parachutes,Backpacks", 5, ComponentTypes.Hands); // Parachute/Backpack
                            var Shoes      = new ComponentUI(Menu, "Shoes", 6, ComponentTypes.Feet);                 // Shoes
                            var UnderShirt = new ComponentUI(Menu, "Undershirt", 8, ComponentTypes.Acessories);      // Parachute/Backpack

                            var removeUndershirt = new UIMenuItem("Remove Undershirt");
                            var removeHat        = new UIMenuItem("Remove Hat");

                            Menu.AddItem(removeUndershirt);
                            Menu.AddItem(removeHat);

                            Menu.OnItemSelect += (sender, item, index) =>
                            {
                                if (item == removeHat)
                                {
                                    ClothesManager.Instance.SetProp(PropTypes.Hats, -1, 0);
                                    ClothesManager.Instance.SaveProps();
                                }
                                else if (item == removeUndershirt)
                                {
                                    ClothesManager.Instance.SetComponents(ComponentTypes.Acessories, -1, 0, 0);
                                    ClothesManager.Instance.SaveComponents();
                                }
                            };

                            InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                            break;

                        case ClothesStoreTypes.Jewlery:
                            Menu          = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(InteractionMenu.Instance._interactionMenu, "Jewlery & Acessories Store", "Open the jewlery store and choose your acessories.", new PointF(5, Screen.Height / 2));
                            var Necklaces = new ComponentUI(Menu, "Necklaces,Ties,Chains", 7, ComponentTypes.Eyes);     // Neck
                            var Glasses   = new PropUI(Menu, "Glasses", 1, PropTypes.Glasses);
                            var EarRings  = new PropUI(Menu, "Ear Rings/Ear Pieces", 2, PropTypes.Ears);
                            InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                            break;

                        case ClothesStoreTypes.Barbor:
                            Menu          = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(InteractionMenu.Instance._interactionMenu, "Barbor Shop", "Open the barbor shop to change your hair.", new PointF(5, Screen.Height / 2));
                            var Hair      = new ComponentUI(Menu, "Hair", 2, ComponentTypes.Hair);                // Hair
                            var Beards    = new HeadOverlayUI(Menu, "Beards", 1, HeadOverlayTypes.Beards);        // Parachute/Backpack
                            var Eyebrows  = new HeadOverlayUI(Menu, "Eyebrows", 2, HeadOverlayTypes.Eyebrows);    // Parachute/Backpack
                            var Chesthair = new HeadOverlayUI(Menu, "Chesthair", 10, HeadOverlayTypes.Chesthair); // Parachute/Backpack
                            break;

                        case ClothesStoreTypes.Plastic:
                            Menu              = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(InteractionMenu.Instance._interactionMenu, "Plastic Surgeon", "Open the plastic surgeons officer to change your body.", new PointF(5, Screen.Height / 2));
                            var Models        = new ModelMenu(Menu, "Models");
                            var Face          = new ComponentUI(Menu, "Face", 0, ComponentTypes.Face);                        // fACE
                            var Aging         = new HeadOverlayUI(Menu, "Aging", 3, HeadOverlayTypes.Aging);                  // Parachute/Backpack
                            var Makeup        = new HeadOverlayUI(Menu, "Makeup", 4, HeadOverlayTypes.Makeup);                // Parachute/Backpack
                            var Blush         = new HeadOverlayUI(Menu, "Blush", 5, HeadOverlayTypes.Blush);                  // Parachute/Backpack
                            var Complexion    = new HeadOverlayUI(Menu, "Complexion", 6, HeadOverlayTypes.Complexion);        // Parachute/Backpack
                            var Sundamage     = new HeadOverlayUI(Menu, "Sundamage", 7, HeadOverlayTypes.Sundamage);          // Parachute/Backpack
                            var Lipstick      = new HeadOverlayUI(Menu, "Lipstick", 8, HeadOverlayTypes.Lipstick);            // Parachute/Backpack
                            var Moles         = new HeadOverlayUI(Menu, "Moles", 9, HeadOverlayTypes.Moles);                  // Parachute/Backpack
                            var Blemishes     = new HeadOverlayUI(Menu, "Blemishes", 0, HeadOverlayTypes.Blemishes);          // Parachute/Backpack
                            var Bodyblemishes = new HeadOverlayUI(Menu, "Bodyblemishes", 11, HeadOverlayTypes.BodyBlemishes); // Parachute/Backpack
                            break;

                        case ClothesStoreTypes.Mask:
                            Menu     = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(InteractionMenu.Instance._interactionMenu, "Mask Store", "Open the mask store to buy a mask.", new PointF(5, Screen.Height / 2));
                            var Head = new ComponentUI(Menu, "Masks", 1, ComponentTypes.Head);     // mASK
                            break;

                        case ClothesStoreTypes.Tattoo:
                            var Tattoos = new TatooUI(InteractionMenu.Instance._interactionMenu, "Tattoos");     // mASK
                            break;
                        }
                        InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                        _menuIndex = InteractionMenu.Instance._interactionMenu.MenuItems.Count - 1;
                    }
                    else if (!_menuOpen && _menuCreated)
                    {
                        _menuCreated = false;
                        InteractionMenu.Instance._interactionMenu.RemoveItemAt(_menuIndex);
                        InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                    }
                }
                await Delay(1000);
            });
        }
コード例 #24
0
ファイル: MenuExample.cs プロジェクト: nuegen/NativeUI
 public void OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkbox, bool Checked)
 {
     if (sender != mainMenu || checkbox != ketchupCheckbox) return; // We only want to detect changes from our menu.
     UI.Notify("~r~Ketchup status: ~b~" + Checked);
 }
コード例 #25
0
 public void AddCategoryToMenu(UIMenu menu, string name, PedHash[] models)
 {
     var submenu = AddSubMenu(menu, name);
     foreach (PedHash model in models)
     {
         var subitem = new UIMenuItem(model.ToString());
         submenu.AddItem(subitem);
     }
     submenu.OnItemSelect += (sender, item, index) =>
     {
         ped_data.ChangePlayerModel(_pedhash[item.Text]);
     };
 }
コード例 #26
0
ファイル: MenuExample.cs プロジェクト: nuegen/NativeUI
 public void OnItemChange(UIMenu sender, int index)
 {
     sender.MenuItems[index].SetLeftBadge(UIMenuItem.BadgeStyle.None);
 }
コード例 #27
0
 public void AddSlotToMenu(UIMenu menu, string text, SlotKey slot_key)
 {
     var submenu = AddSubMenu(menu, text);
     var index_names = PedData.GetIndexNames(slot_key.typ);
     var listitem1 = new UIMenuListItem(index_names[0], UI_LIST, 0);
     var listitem2 = new UIMenuListItem(index_names[1], UI_LIST, 0);
     var listitem3 = new UIMenuListItem(index_names[2], UI_LIST, 0);
     var listitem4 = new UIMenuListItem(index_names[3], UI_LIST, 0);
     var randomitem = new UIMenuItem("Random");
     var clearitem = new UIMenuItem("Clear");
     submenu.AddItem(listitem1);
     submenu.AddItem(listitem2);
     submenu.AddItem(listitem3);
     submenu.AddItem(listitem4);
     submenu.AddItem(randomitem);
     submenu.AddItem(clearitem);
     // when the menu is selected, we only want submenu to be
     // enabled if its model and/or texture can be changed
     menu.ParentMenu.OnItemSelect += (sender, item, index) =>
     {
         if (item == menu.ParentItem)
         {
             var ped = Game.Player.Character;
             submenu.ParentItem.Enabled = (
                 (PedData.GetNumIndex1(ped, slot_key) >= 2) ||
                 (PedData.GetNumIndex2(ped, slot_key, 0) >= 2) ||
                 (PedData.GetNumIndex3(ped, slot_key, 0, 0) >= 2) ||
                 (PedData.GetNumIndex4(ped, slot_key, 0, 0, 0) >= 2));
         }
     };
     // when submenu is selected, display correct indices for model and texture
     // and enable those entries of this submenu
     // (model, texture, ...) where something can be changed
     submenu.ParentMenu.OnItemSelect += (sender, item, index) =>
     {
         if (item == submenu.ParentItem)
         {
             var ped = Game.Player.Character;
             var slot_value = ped_data.GetSlotValue(slot_key);
             listitem1.Index = slot_value.index1;
             listitem1.Enabled = (PedData.GetNumIndex1(ped, slot_key) >= 2);
             listitem2.Index = slot_value.index2;
             listitem2.Enabled = (ped_data.GetNumIndex2(ped, slot_key) >= 2);
             listitem3.Index = slot_value.index3;
             listitem3.Enabled = (ped_data.GetNumIndex3(ped, slot_key) >= 2);
             listitem4.Index = slot_value.index4;
             listitem4.Enabled = (ped_data.GetNumIndex4(ped, slot_key) >= 2);
         }
     };
     submenu.OnListChange += (sender, item, index) =>
     {
         if (item == listitem1 || item == listitem2 || item == listitem3 || item == listitem4)
         {
             var ped = Game.Player.Character;
             var slot_value = ped_data.GetSlotValue(slot_key);
             var numIndex1 = PedData.GetNumIndex1(ped, slot_key);
             var numIndex2 = ped_data.GetNumIndex2(ped, slot_key);
             var numIndex3 = ped_data.GetNumIndex3(ped, slot_key);
             var numIndex4 = ped_data.GetNumIndex4(ped, slot_key);
             // we need to ensure that the new id is valid as the menu has more items than number of ids supported by the game
             int maxid;
             if (item == listitem1)
                 maxid = numIndex1;
             else if (item == listitem2)
                 maxid = numIndex2;
             else if (item == listitem3)
                 maxid = numIndex3;
             else // if (item == listitem4)
                 maxid = numIndex4;
             maxid = Math.Min(maxid - 1, UI_LIST_MAX);
             System.Diagnostics.Debug.Assert(maxid >= 0);
             System.Diagnostics.Debug.Assert(maxid <= UI_LIST_MAX - 1);
             if (index > maxid)
             {
                 // wrap the index depending on whether user scrolled forward or backward
                 index = (index == UI_LIST_MAX - 1) ? maxid : 0;
                 item.Index = index;
             }
             if (item == listitem1)
                 slot_value.index1 = index;
             else if (item == listitem2)
                 slot_value.index2 = index;
             else if (item == listitem3)
                 slot_value.index3 = index;
             else // if (item == listitem4)
                 slot_value.index4 = index;
             // correct listitem2 if index2 is out of range
             var newNumIndex2 = PedData.GetNumIndex2(ped, slot_key, slot_value.index1);
             if (slot_value.index2 >= newNumIndex2) slot_value.index2 = newNumIndex2 - 1;
             listitem2.Index = slot_value.index2;
             listitem2.Enabled = (newNumIndex2 >= 2);
             // correct listitem3 if index3 is out of range
             var newNumIndex3 = PedData.GetNumIndex3(ped, slot_key, slot_value.index1, slot_value.index2);
             if (slot_value.index3 >= newNumIndex3) slot_value.index3 = newNumIndex3 - 1;
             listitem3.Index = slot_value.index3;
             listitem3.Enabled = (newNumIndex3 >= 2);
             // correct listitem3 if index3 is out of range
             var newNumIndex4 = PedData.GetNumIndex4(ped, slot_key, slot_value.index1, slot_value.index2, slot_value.index3);
             if (slot_value.index4 >= newNumIndex4) slot_value.index4 = newNumIndex4 - 1;
             listitem4.Index = slot_value.index4;
             listitem4.Enabled = (newNumIndex4 >= 2);
             // set slot value
             ped_data.SetSlotValue(ped, slot_key, slot_value);
         }
     };
     submenu.OnItemSelect += (sender, item, index) =>
     {
         if (item == clearitem)
         {
             var ped = Game.Player.Character;
             ped_data.ClearSlot(ped, slot_key);
             // update menu items
             var slot_value = ped_data.GetSlotValue(slot_key);
             listitem1.Index = slot_value.index1;
             listitem2.Index = slot_value.index2;
             listitem3.Index = slot_value.index3;
             listitem4.Index = slot_value.index4;
             listitem1.Enabled = (PedData.GetNumIndex1(ped, slot_key) >= 2);
             listitem2.Enabled = (ped_data.GetNumIndex2(ped, slot_key) >= 2);
             listitem3.Enabled = (ped_data.GetNumIndex3(ped, slot_key) >= 2);
             listitem4.Enabled = (ped_data.GetNumIndex4(ped, slot_key) >= 2);
         }
         else if (item == randomitem)
         {
             var ped = Game.Player.Character;
             var slot_value = ped_data.GetSlotValue(slot_key);
             slot_value.index1 = rnd.Next(PedData.GetNumIndex1(ped, slot_key));
             slot_value.index2 = rnd.Next(PedData.GetNumIndex2(ped, slot_key, slot_value.index1));
             slot_value.index3 = rnd.Next(PedData.GetNumIndex3(ped, slot_key, slot_value.index1, slot_value.index2));
             slot_value.index4 = rnd.Next(PedData.GetNumIndex4(ped, slot_key, slot_value.index1, slot_value.index2, slot_value.index3));
             ped_data.SetSlotValue(ped, slot_key, slot_value);
             listitem1.Index = slot_value.index1;
             listitem2.Index = slot_value.index2;
             listitem3.Index = slot_value.index3;
             listitem4.Index = slot_value.index4;
             listitem1.Enabled = (PedData.GetNumIndex1(ped, slot_key) >= 2);
             listitem2.Enabled = (ped_data.GetNumIndex2(ped, slot_key) >= 2);
             listitem3.Enabled = (ped_data.GetNumIndex3(ped, slot_key) >= 2);
             listitem4.Enabled = (ped_data.GetNumIndex4(ped, slot_key) >= 2);
         }
     };
 }
コード例 #28
0
        private async Task GarageCheck()
        {
            while (true)
            {
                _menuOpen = false;
                var playerPos = API.GetEntityCoords(Game.PlayerPed.Handle, true);
                foreach (var pos in Posistions)
                {
                    var dist = API.Vdist(playerPos.X, playerPos.Y, playerPos.Z, pos.X, pos.Y, pos.Z);
                    if (!MenuRestricted && dist < 1.5f || Game.PlayerPed.IsInPoliceVehicle && Game.PlayerPed.CurrentVehicle.GetPedOnSeat(VehicleSeat.Driver) == Game.PlayerPed)
                    {
                        _menuOpen = true;
                    }
                }
                if (_menuOpen && !_menuCreated)
                {
                    _menu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                        InteractionMenu.Instance._interactionMenu, "Police Computer", "Access your police computer.", new PointF(5, Screen.Height / 2));
                    var _paperworkMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                        _menu, "Paperwork", "Warrants, Arrests, Bolos", new PointF(5, Screen.Height / 2));
                    var bookingButton       = new UIMenuItem("Submit Crime Paperwork", "Submit your booking paperwork.");
                    var ticketButton        = new UIMenuItem("Submit Ticket Paperwork", "Submit your ticket paperwork.");
                    var warrantButton       = new UIMenuItem("Submit Warrant", "Submit your warrant paperwork.");
                    var removeWarrantButton = new UIMenuItem("Remove Warrant", "Submit your warrant paperwork.");
                    var boloButton          = new UIMenuItem("Submit Bolo", "Submit your bolo paperwork.");
                    var removeBoloButton    = new UIMenuItem("Remove Bolo", "Submit your bolo paperwork.");

                    var _searchMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                        _menu, "Database", "Search Warrants, Civlians, Vehicles, Arrests", new PointF(5, Screen.Height / 2));
                    var warrantSearchButton            = new UIMenuItem("Search For Warrants By Name", "Search the NCIC Database for a matching person for warrants.");
                    var boloSearchButton               = new UIMenuItem("Search For Warrants By Plate", "Search the NCIC Database for a matching bolo.");
                    var civlianSearchButton            = new UIMenuItem("Search For Civlian By Name", "Search the NCIC Database for a matching person for criminal information.");
                    var bankStatementSearchButton      = new UIMenuItem("Request Bank Statement From Banks", "Request bank statement from the banks. Requires a warrant.");
                    var plateVehicleSearchButton       = new UIMenuItem("Search For Vehicle By Plate", "Search the DMV Database for a vehicle with a matching plate number.");
                    var ownerVehicleSearchSearchButton = new UIMenuItem("Search For Vehicle By Owner", "Search the DMV Database for a vehicle with a matching registered owner.");
                    var modelVehicleSearchButton       = new UIMenuItem("Search For BOLO By Make/Model", "Search the DMV Database for a vehicle with a make/model.");



                    #region Charges
                    var chargesMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(_paperworkMenu,
                                                                                                     "Charges", new PointF(5, Screen.Height / 2));

                    var clearButton       = new UIMenuItem("Clear All Charges");
                    var showChargesButton = new UIMenuItem("Show Charges");

                    chargesMenu.AddItem(clearButton);
                    chargesMenu.AddItem(showChargesButton);

                    chargesMenu.OnItemSelect += (sender, item, index) =>
                    {
                        if (item == clearButton)
                        {
                            ChargesManager.Instance.ClearCharges();
                        }
                        else if (item == showChargesButton)
                        {
                            var info = ChargesManager.Instance.GetCharges();
                            Utility.Instance.SendChatMessage("[Charges]", "FINE:" + info.TotalFine + " TIME:" + info.TotalTime + "  " + info.Charges, 0, 0, 180);
                        }
                    };

                    var felonyMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(chargesMenu,
                                                                                                    "Felonys", new PointF(5, Screen.Height / 2));
                    var misdmeanorMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(chargesMenu,
                                                                                                        "Misdemeanors", new PointF(5, Screen.Height / 2));
                    var trafficMenu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(chargesMenu,
                                                                                                     "Traffic", new PointF(5, Screen.Height / 2));

                    foreach (var charge in ChargesManager.Instance.Charges.Where(x => x.Type == ChargeTypes.Felony))
                    {
                        var button = new UIMenuItem(charge.Title, charge.Title);
                        felonyMenu.AddItem(button);
                        felonyMenu.OnItemSelect += (sender, item, index) =>
                        {
                            if (item == button)
                            {
                                ChargesManager.Instance.AddCharge(charge);
                            }
                        };
                    }

                    foreach (var charge in ChargesManager.Instance.Charges.Where(x => x.Type == ChargeTypes.Misdemeanors))
                    {
                        var button = new UIMenuItem(charge.Title, charge.Title);
                        misdmeanorMenu.AddItem(button);
                        misdmeanorMenu.OnItemSelect += (sender, item, index) =>
                        {
                            if (item == button)
                            {
                                ChargesManager.Instance.AddCharge(charge);
                            }
                        };
                    }

                    foreach (var charge in ChargesManager.Instance.Charges.Where(x => x.Type == ChargeTypes.Traffic))
                    {
                        var button = new UIMenuItem(charge.Title, charge.Title);
                        trafficMenu.AddItem(button);
                        trafficMenu.OnItemSelect += (sender, item, index) =>
                        {
                            if (item == button)
                            {
                                ChargesManager.Instance.AddCharge(charge);
                            }
                        };
                    }

                    #endregion


                    _paperworkMenu.AddItem(bookingButton);
                    _paperworkMenu.AddItem(ticketButton);
                    _paperworkMenu.AddItem(warrantButton);
                    _paperworkMenu.AddItem(removeWarrantButton);
                    _paperworkMenu.AddItem(boloButton);
                    _paperworkMenu.AddItem(removeBoloButton);
                    _paperworkMenu.OnItemSelect += (sender, selectedItem, index) =>
                    {
                        InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                        if (selectedItem == bookingButton)
                        {
                            BookingPaperworkFunctionality();
                        }
                        else if (selectedItem == ticketButton)
                        {
                            TicketPaperworkFunctionality();
                        }
                        else if (selectedItem == warrantButton)
                        {
                            WarrantPaperworkFunctionality();
                        }
                        else if (selectedItem == removeWarrantButton)
                        {
                            WarrantRemovalPaperworkFunctionality();
                        }
                        else if (selectedItem == boloButton)
                        {
                            BoloPaperworkFunctionality();
                        }
                        else if (selectedItem == removeBoloButton)
                        {
                            BoloRemovalPaperworkFunctionality();
                        }
                    };

                    _searchMenu.AddItem(civlianSearchButton);
                    _searchMenu.AddItem(bankStatementSearchButton);
                    _searchMenu.AddItem(plateVehicleSearchButton);
                    _searchMenu.AddItem(ownerVehicleSearchSearchButton);
                    _searchMenu.AddItem(modelVehicleSearchButton);
                    _searchMenu.AddItem(warrantSearchButton);
                    _searchMenu.AddItem(boloSearchButton);
                    _searchMenu.OnItemSelect += (sender, selectedItem, index) =>
                    {
                        InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                        if (selectedItem == ownerVehicleSearchSearchButton)
                        {
                            InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                            OwnerVehicleSearchFunctionality();
                        }
                        else if (selectedItem == plateVehicleSearchButton)
                        {
                            PlateVehicleSearchFunctionality();
                        }
                        else if (selectedItem == bankStatementSearchButton)
                        {
                            BankStatementFunctionality();
                        }
                        else if (selectedItem == modelVehicleSearchButton)
                        {
                            ModelVehicleSearchFunctionality();
                        }
                        else if (selectedItem == boloSearchButton)
                        {
                            BoloSearchFunctionality();
                        }
                        else if (selectedItem == warrantSearchButton)
                        {
                            WarrantSearchFunctio();
                        }
                        else if (selectedItem == civlianSearchButton)
                        {
                            CivilianSearchFunctionality();
                        }
                    };

                    _menuCreated = true;
                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                else if (!_menuOpen && _menuCreated)
                {
                    _menuCreated = false;
                    if (_menu.Visible)
                    {
                        _menu.Visible = false;
                        InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                        InteractionMenu.Instance._interactionMenu.Visible = true;
                    }

                    var i = 0;
                    foreach (var item in InteractionMenu.Instance._interactionMenu.MenuItems)
                    {
                        if (item == _menu.ParentItem)
                        {
                            InteractionMenu.Instance._interactionMenu.RemoveItemAt(i);
                            break;
                        }
                        i++;
                    }
                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                await Delay(0);
            }
        }
コード例 #29
0
 public override UIMenu Menu()
 {
     var menuMain = new UIMenu("Changing Room", "Main Menu");
     AddStorymodeToMenu(menuMain);
     AddFreemodeToMenu(menuMain);
     AddActorActionToMenu(menuMain, "Save Actor", SaveActor, ExistsActor);
     AddActorActionToMenu(menuMain, "Load Actor", LoadActor, ExistsActor);
     return menuMain;
 }
コード例 #30
0
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            SizeF res    = UIMenu.GetScreenResolutionMantainRatio();
            int   middle = Convert.ToInt32(res.Width / 2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size(Convert.ToInt32(res.Width), 450 + (_items.Count * 40)),
                       0f, Color.FromArgb(200, 255, 255, 255)).Draw();

            new UIResText("race completed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, UIResText.Alignment.Centered).Draw();

            new UIResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw();

            new UIResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();

            for (int i = 0; i < _items.Count; i++)
            {
                new UIResText(_items[i].Item1, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Left).Draw();
                new UIResText(_items[i].Item2, new Point(_items[i].Item3 == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                if (_items[i].Item3 == TickboxState.None)
                {
                    continue;
                }
                string spriteName = "shop_box_blank";
                switch (_items[i].Item3)
                {
                case TickboxState.Tick:
                    spriteName = "shop_box_tick";
                    break;

                case TickboxState.Cross:
                    spriteName = "shop_box_cross";
                    break;
                }
                new Sprite("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48)).Draw();
            }
            new UIResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

            new UIResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
            new UIResText(_completionRate + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();

            string medalSprite = "bronzemedal";

            switch (_medal)
            {
            case Medal.Silver:
                medalSprite = "silvermedal";
                break;

            case Medal.Gold:
                medalSprite = "goldmedal";
                break;
            }

            new Sprite("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * _items.Count)), new Size(32, 32)).Draw();

            var scaleform = new Scaleform(0);

            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, Function.Call <string>(Hash._0x0499D7B09FC9B407, 2, (int)Control.FrontendAccept, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();
            if (Game.IsControlJustPressed(0, Control.FrontendAccept))
            {
                Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET");
                ContinueHit();
            }
        }
コード例 #31
0
 public static void BootOnItemSelect(UIMenu sender, UIMenuItem SelectedItem, int index)
 {
     if (sender != DoorMainMenu)
     {
         return;                         // We only want to detect changes from our menu.
     }
     // You can also detect the button by using index
     else if (SelectedItem == toggleBoot)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[5].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[5].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[5].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[5].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no boot!", 2500);
             }
         });
     }
     else if (SelectedItem == toggleBonnet)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[4].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[4].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[4].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[4].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no bonnet!", 2500);
             }
         });
     }
     else if (SelectedItem == togglelf)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[2].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[2].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[2].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[2].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no rear driverside door!", 2500);
             }
         });
     }
     else if (SelectedItem == togglerf)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[3].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[3].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[3].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[3].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no rear passengerside door!", 2500);
             }
         });
     }
     else if (SelectedItem == togglefp)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[1].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[1].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[1].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[1].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no front passengerside door!", 2500);
             }
         });
     }
     else if (SelectedItem == togglefd)
     {
         GameFiber.StartNew(delegate // Start a new fiber if the code sleeps or waits and we don't want to block the MenusProcessFiber
         {
             try
             {
                 if (Game.LocalPlayer.Character.LastVehicle.Doors[0].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[0].Close(false);
                 }
                 if (!Game.LocalPlayer.Character.LastVehicle.Doors[0].IsOpen)
                 {
                     Game.LocalPlayer.Character.LastVehicle.Doors[0].Open(false);
                 }
             }
             catch (Rage.Exceptions.InvalidHandleableException)
             {
                 Game.DisplaySubtitle("Closest vehicle has no front driverside door!", 2500);
             }
         });
     }
 }
コード例 #32
0
        private async Task GarageCheck()
        {
            while (true)
            {
                _menuOpen = false;
                foreach (var pos in Posistions)
                {
                    var dist = API.Vdist(Game.PlayerPed.Position.X, Game.PlayerPed.Position.Y, Game.PlayerPed.Position.Z, pos.X, pos.Y, pos.Z);
                    if (dist < 6f && !MenuRestricted)
                    {
                        _menuOpen = true;
                    }
                }

                if (_menuOpen && !_menuCreated)
                {
                    _menu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                        InteractionMenu.Instance._interactionMenu, "Police Garage", "Pull out your police vehicles.", new PointF(5, Screen.Height / 2));
                    var putawayButton = new UIMenuItem("Put away car");
                    _menu.AddItem(putawayButton);

                    _menu.OnItemSelect += (sender, selectedItem, index) =>
                    {
                        if (selectedItem == putawayButton)
                        {
                            if (Game.PlayerPed.IsInVehicle() && Game.PlayerPed.CurrentVehicle.Handle == _policeCar &&
                                VehicleManager.Instance.OwnsCar(_policeCar) &&
                                _carIsOut)
                            {
                                API.DeleteVehicle(ref _policeCar);
                            }
                        }
                    };
                    var buttons = new List <UIMenuItem>();
                    foreach (var item in Vehicles)
                    {
                        var button = new UIMenuItem(item);
                        buttons.Add(button);
                        _menu.AddItem(button);
                        _menu.OnItemSelect += (sender, selectedItem, index) =>
                        {
                            if (selectedItem == button)
                            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
                                Utility.Instance.SpawnCar(selectedItem.Text, delegate(int i)
                                {
                                    _carIsOut = true;
                                    API.SetVehicleNumberPlateText(i, "POLICE");
                                    API.ToggleVehicleMod(i, 18, true);
                                    _policeCar = i;
                                    API.DecorSetInt(_policeCar, "PIRP_VehicleOwner", Game.Player.ServerId);
                                    API.TaskWarpPedIntoVehicle(Game.PlayerPed.Handle, i, -1);
                                });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
                            }
                        };
                    }

                    _menuCreated = true;
                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                else if (!_menuOpen && _menuCreated)
                {
                    _menuCreated = false;
                    if (_menu.Visible)
                    {
                        _menu.Visible = false;
                        InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                        InteractionMenu.Instance._interactionMenu.Visible = true;
                    }

                    var i = 0;
                    foreach (var item in InteractionMenu.Instance._interactionMenu.MenuItems)
                    {
                        if (item == _menu.ParentItem)
                        {
                            InteractionMenu.Instance._interactionMenu.RemoveItemAt(i);
                            break;
                        }

                        i++;
                    }

                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                await Delay(1000);
            }
        }
コード例 #33
0
        public void Draw()
        {
            if (!Visible)
            {
                return;
            }

            var res    = UIMenu.GetScreenResolutionMantainRatio();
            var middle = Convert.ToInt32(res.Width / 2);

            new Sprite("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size(Convert.ToInt32(res.Width), 450 + (_items.Count * 40)),
                       0f, Color.FromArgb(200, 255, 255, 255)).Draw();

            new ResText("mission passed", new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Font.Pricedown, ResText.Alignment.Centered).Draw();

            new ResText(Title, new Point(middle, 230), 0.5f, Color.White, Font.ChaletLondon, ResText.Alignment.Centered).Draw();
            new ResRectangle(new Point(middle - 300, 290), new Size(600, 2), Color.White).Draw();

            for (var i = 0; i < _items.Count; i++)
            {
                new ResText(_items[i].Label, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, ResText.Alignment.Left).Draw();
                new ResText(_items[i].Status, new Point(_items[i].TickState == TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Font.ChaletLondon, ResText.Alignment.Right).Draw();
                if (_items[i].TickState == TickboxState.None)
                {
                    continue;
                }
                var spriteName = "shop_box_blank";
                if (_items[i].TickState == TickboxState.Tick)
                {
                    spriteName = "shop_box_tick";
                }
                else if (_items[i].TickState == TickboxState.Cross)
                {
                    spriteName = "shop_box_cross";
                }

                new Sprite("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48)).Draw();
            }
            new ResRectangle(new Point(middle - 300, 300 + (40 * _items.Count)), new Size(600, 2), Color.White).Draw();

            new ResText("Completion", new Point(middle - 150, 320 + (40 * _items.Count)), 0.4f).Draw();
            new ResText(_completeValue + "%", new Point(middle + 150, 320 + (40 * _items.Count)), 0.4f, Color.White, Font.ChaletLondon, ResText.Alignment.Right).Draw();

            var medalSprite = "bronzemedal";

            if (_medal == Medal.Silver)
            {
                medalSprite = "silvermedal";
            }
            else if (_medal == Medal.Gold)
            {
                medalSprite = "goldmedal";
            }

            new Sprite("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * _items.Count)), new Size(32, 32)).Draw();

            var scaleform = new Scaleform(0);

            scaleform.Load("instructional_buttons");
            scaleform.CallFunction("CLEAR_ALL");
            scaleform.CallFunction("TOGGLE_MOUSE_BUTTONS", 0);
            scaleform.CallFunction("CREATE_CONTAINER");

            scaleform.CallFunction("SET_DATA_SLOT", 0, NativeFunction.Natives.x0499D7B09FC9B407 <string>(2, 201, 0), "Continue");
            scaleform.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);
            scaleform.Render2D();

            if (!Game.IsKeyDown(Keys.Enter))
            {
                return;
            }
            NativeFunction.Natives.PLAY_SOUND_FRONTEND(-1, "SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET", 0); // Doesn't work
            //Game.PlaySound("SELECT", "HUD_FRONTEND_DEFAULT_SOUNDSET"); -- todo figure this out
            ContinueHit();
        }
コード例 #34
0
ファイル: MenuExample.cs プロジェクト: isti37/NativeUI
 public void AddMenuAnotherMenu(UIMenu menu)
 {
     var submenu = _menuPool.AddSubMenu(menu, "Another Menu");
     for (int i = 0; i < 20; i++)
         submenu.AddItem(new UIMenuItem("PageFiller", "Sample description that takes more than one line. Moreso, it takes way more than two lines since it's so long. Wow, check out this length!"));
 }
コード例 #35
0
        public void UpdateMenu()
        {
            if (MenuPool != null)
            {
                MenuPool.RemoveAllMenus();
            }

            MenuPool = new MenuPool();
            MainMenu = new UIMenu("Ptfx Menu");

            if (updateAvailable)
            {
                var item = new UIMenuItem("Update PTFX Database", "Database Update Available");
                MainMenu.AddMenuItem(item);
                MainMenu.OnItemSelect += (sender, selectedItem, index) =>
                {
                    if (selectedItem.Text == "Update PTFX Database")
                    {
                        WriteData();
                        UpdateMenu();
                        Notification.Show("PTFX Database Updated");
                    }
                };
            }

            MainMenu.OnMenuOpen += sender => { Game.Player.Character.IsVisible = false; };

            MenuPool.AddMenu(MainMenu);

            MainMenu.TitleColor                 = Color.FromArgb(255, 255, 255, 255);
            MainMenu.TitleBackgroundColor       = Color.FromArgb(240, 0, 0, 0);
            MainMenu.TitleUnderlineColor        = Color.FromArgb(255, 255, 90, 90);
            MainMenu.DefaultBoxColor            = Color.FromArgb(160, 0, 0, 0);
            MainMenu.DefaultTextColor           = Color.FromArgb(230, 255, 255, 255);
            MainMenu.HighlightedBoxColor        = Color.FromArgb(130, 237, 90, 90);
            MainMenu.HighlightedItemTextColor   = Color.FromArgb(255, 255, 255, 255);
            MainMenu.DescriptionBoxColor        = Color.FromArgb(255, 0, 0, 0);
            MainMenu.DescriptionTextColor       = Color.FromArgb(255, 255, 255, 255);
            MainMenu.SubsectionDefaultBoxColor  = Color.FromArgb(160, 0, 0, 0);
            MainMenu.SubsectionDefaultTextColor = Color.FromArgb(180, 255, 255, 255);

            MenuPool.SubmenuItemIndication = "  ~r~>";

            var     serializer = new JavaScriptSerializer();
            var     json       = File.ReadAllText(dataPath);
            dynamic res        = serializer.DeserializeObject(json);

            foreach (var i in res)
            {
                var subMenu     = new UIMenu(i["DictionaryName"]);
                var effectNames = ((IEnumerable)i["EffectNames"]).Cast <string>().ToList();
                foreach (var e in effectNames)
                {
                    var item = new UIMenuItem(e, i["DictionaryName"]);
                    subMenu.AddMenuItem(item);

                    subMenu.OnItemSelect += (sender, selectedItem, index) =>
                    {
                        World.RemoveAllParticleEffectsInRange(Game.Player.Character.Position, 10);
                        Game.Player.Character.RemoveParticleEffects();

                        var asset = new ParticleEffectAsset(selectedItem.Description);
                        asset.Request();

                        while (!asset.IsLoaded)
                        {
                            Wait(0);
                        }

                        var particle = World.CreateParticleEffectNonLooped(asset, selectedItem.Text,
                                                                           Game.Player.Character.Position, default, particlesSize);
コード例 #36
0
        private UIMenuDynamicListItem AddDynamicFloatList(UIMenu menu, string name, float defaultValue, float value, float maxEditing)
        {
            var newitem = new UIMenuDynamicListItem(name, value.ToString("F3"), (sender, direction) =>
            {
                var newvalue = value;
                float min    = defaultValue - maxEditing;
                float max    = defaultValue + maxEditing;

                //newvalue = (float)Math.Round(newvalue, 3);
                //min = (float)Math.Round(min, 3);
                //max = (float)Math.Round(max, 3);

                if (direction == UIMenuDynamicListItem.ChangeDirection.Left)
                {
                    newvalue -= editingFactor;
                }
                else if (direction == UIMenuDynamicListItem.ChangeDirection.Right)
                {
                    newvalue += editingFactor;
                }
                else
                {
                    return(value.ToString("F3"));
                }

                if (newvalue < min)
                {
                    CitizenFX.Core.UI.Screen.ShowNotification($"~o~Warning~w~: Min ~b~{name}~w~ value allowed is {min} for this vehicle");
                }
                else if (newvalue > max)
                {
                    CitizenFX.Core.UI.Screen.ShowNotification($"~o~Warning~w~: Max ~b~{name}~w~ value allowed is {max} for this vehicle");
                }
                else
                {
                    value = newvalue;
                    if (sender == frontRotationGUI)
                    {
                        currentPreset.SetRotationFront(value);
                    }
                    else if (sender == rearRotationGUI)
                    {
                        currentPreset.SetRotationRear(value);
                    }
                    else if (sender == frontOffsetGUI)
                    {
                        currentPreset.SetOffsetFront(-value);
                    }
                    else if (sender == rearOffsetGUI)
                    {
                        currentPreset.SetOffsetRear(-value);
                    }

                    // Force one single refresh to update rendering at correct position after reset
                    if (value == defaultValue)
                    {
                        RefreshVehicleUsingPreset(currentVehicle, currentPreset);
                    }

                    if (debug)
                    {
                        Debug.WriteLine($"{ScriptName}: Edited {sender.Text} => value:{value}");
                    }
                }
                return(value.ToString("F3"));
            });

            menu.AddItem(newitem);
            return(newitem);
        }
コード例 #37
0
 private void SettingsMenu_OnMenuClose(UIMenu sender)
 {
     RadarZoomSettings.SaveSettings();
 }
コード例 #38
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        private void CreateMenu()
        {
            string menuTitle = "Saved Vehicles";

            #region Create menus and submenus
            // Create the menu.
            menu = new UIMenu(menuTitle, "Manage Saved Vehicles", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            // Create submenus.
            UIMenu savedVehicles = new UIMenu(menuTitle, "Spawn Saved Vehicle", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            UIMenu deleteSavedVehicles = new UIMenu(menuTitle, "~r~Delete Saved Vehicle", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            #endregion

            #region Create, add and bind buttons to the menus.
            // Create menu buttons.
            UIMenuItem saveVeh = new UIMenuItem("Save Current Vehicle", "Save the vehicle you are currently in.");
            saveVeh.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
            UIMenuItem savedVehiclesBtn = new UIMenuItem("Spawn Saved Vehicle", "Select a vehicle from your saved vehicles list.");
            savedVehiclesBtn.SetRightLabel("→→→");
            UIMenuItem deleteSavedVehiclesBtn = new UIMenuItem("~r~Delete Saved Vehicle", "~r~Delete ~s~a saved vehicle.");
            deleteSavedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert);
            deleteSavedVehiclesBtn.SetRightLabel("→→→");

            // Add buttons to the menu.
            menu.AddItem(saveVeh);
            menu.AddItem(savedVehiclesBtn);
            menu.AddItem(deleteSavedVehiclesBtn);

            // Bind submenus to menu items.
            if (cf.IsAllowed(Permission.SVSpawn))
            {
                menu.BindMenuToItem(savedVehicles, savedVehiclesBtn);
            }
            else
            {
                savedVehiclesBtn.Enabled = false;
                savedVehiclesBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Lock);
                savedVehiclesBtn.Description = "This option has been disabled by the server owner.";
            }
            menu.BindMenuToItem(deleteSavedVehicles, deleteSavedVehiclesBtn);
            #endregion

            #region Button pressed events
            // Handle button presses.
            menu.OnItemSelect += (sender, item, index) =>
            {
                // Save the current vehicle.
                if (item == saveVeh)
                {
                    cf.SaveVehicle();
                }

                // Open and refresh the "spawn saved vehicle from list" submenu.
                else if (item == savedVehiclesBtn)
                {
                    // Remove all old items.
                    savedVehicles.MenuItems.Clear();

                    // Get all saved vehicles.
                    SavedVehiclesDict = cf.GetSavedVehiclesDictionary();

                    // Loop through all saved vehicles and create a button for it, then add that button to the submenu.
                    foreach (KeyValuePair <string, Dictionary <string, string> > savedVehicle in SavedVehiclesDict)
                    {
                        UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Click to spawn this saved vehicle.");
                        vehBtn.SetRightLabel($"({savedVehicle.Value["name"]})");
                        savedVehicles.AddItem(vehBtn);
                    }

                    // When a vehicle is selected...
                    savedVehicles.OnItemSelect += (sender2, item2, index2) =>
                    {
                        // Get the vehicle info.
                        var vehInfo = SavedVehiclesDict["veh_" + item2.Text];

                        // Get the model hash.
                        var model = vehInfo["model"];

                        // Spawn a vehicle using the hash, and pass on the vehicleInfo dictionary containing all saved vehicle mods.
                        cf.SpawnVehicle((uint)Int64.Parse(model), MainMenu.VehicleSpawnerMenu.SpawnInVehicle, MainMenu.VehicleSpawnerMenu.ReplaceVehicle, vehicleInfo: vehInfo);
                    };

                    // Refresh the index of the page.
                    savedVehicles.RefreshIndex();
                    // Update the scaleform.
                    savedVehicles.UpdateScaleform();
                }
                // Delete saved vehicle.
                else if (item == deleteSavedVehiclesBtn)
                {
                    deleteSavedVehicles.MenuItems.Clear();

                    SavedVehiclesDict = cf.GetSavedVehiclesDictionary();

                    foreach (KeyValuePair <string, Dictionary <string, string> > savedVehicle in SavedVehiclesDict)
                    {
                        UIMenuItem vehBtn = new UIMenuItem(savedVehicle.Key.Substring(4), "Are you sure you want to delete this saved vehicle? This action cannot be undone!");
                        vehBtn.SetLeftBadge(UIMenuItem.BadgeStyle.Alert);
                        vehBtn.SetRightLabel($"({savedVehicle.Value["name"]})");
                        deleteSavedVehicles.AddItem(vehBtn);
                    }
                    deleteSavedVehicles.OnItemSelect += (sender2, item2, index2) =>
                    {
                        var vehDictName = "veh_" + item2.Text;
                        new StorageManager().DeleteSavedDictionary(vehDictName);
                        deleteSavedVehicles.GoBack();
                    };
                }
            };
            #endregion

            // Add the submenus to the menu pool.
            MainMenu.Mp.Add(savedVehicles);
            MainMenu.Mp.Add(deleteSavedVehicles);
        }
コード例 #39
0
        private static void OnItemSelect(UIMenu sender, UIMenuItem selectedItem, int index)
        {
            Statuses     statuses     = new Statuses();
            TS10_11Funcs ts10_11Funcs = new TS10_11Funcs();

            if (sender == generalMenu && selectedItem == menu10_11List)
            {
            }
            else
            {
                _MenuPool.CloseAllMenus();
            }
            if (sender == mainMenu)
            {
                if (selectedItem == menu10_99Item)
                {
                    statuses.ShowMe10_99();
                }
            }
            if (sender == generalMenu)
            {
                if (selectedItem == menu10_11List)
                {
                    string selectedListItem = menu10_11List.SelectedItem.ToString();
                    if (selectedListItem == "Occupied x1")
                    {
                        ts10_11Funcs.ShowMe10_11O1();
                    }
                    if (selectedListItem == "Occupied x2")
                    {
                        ts10_11Funcs.ShowMe10_11O2();
                    }
                    if (selectedListItem == "Occupied x3")
                    {
                        ts10_11Funcs.ShowMe10_11O3();
                    }
                    if (selectedListItem == "Occupied x4")
                    {
                        ts10_11Funcs.ShowMe10_11O4();
                    }
                }
                else if (selectedItem == menu10_15Item)
                {
                    statuses.ShowMe10_15();
                }
                else if (selectedItem == menu10_19Item)
                {
                    statuses.ShowMe10_19();
                }
                else if (selectedItem == menu10_23Item)
                {
                    statuses.ShowMe10_23();
                }
                else if (selectedItem == menuCode5Item)
                {
                    statuses.ShowMeCode5();
                }
                else if (selectedItem == menuAffirmativeItem)
                {
                    statuses.Affirmative();
                }
                else if (selectedItem == menuNegativeItem)
                {
                    statuses.Negative();
                }
            }
            if (sender == serviceMenu)
            {
                if (selectedItem == menu10_5Item)
                {
                    statuses.ShowMe10_5();
                }
                else if (selectedItem == menu10_6Item)
                {
                    statuses.ShowMe10_6();
                }
                else if (selectedItem == menu10_7Item)
                {
                    statuses.ShowMe10_7();
                }
                else if (selectedItem == menu10_8Item)
                {
                    statuses.ShowMe10_8();
                }
                else if (selectedItem == menu10_41Item)
                {
                    statuses.ShowMe10_41();
                }
                else if (selectedItem == menu10_42Item)
                {
                    statuses.ShowMe10_42();
                }
            }
            if (sender == backupMenu)
            {
                if (selectedItem == menu10_32List)
                {
                    string selectedListItem = menu10_32List.SelectedItem.ToString();
                    if (selectedListItem == "Code 2")
                    {
                        statuses.Requesting10_32C2();
                    }
                    else if (selectedListItem == "Code 3")
                    {
                        statuses.Requesting10_32C3();
                    }
                    else if (selectedListItem == "Female")
                    {
                        statuses.Requesting10_32F();
                    }
                }
                else if (selectedItem == menu10_51Item)
                {
                    statuses.Requesting10_51();
                }
                else if (selectedItem == menu10_52Item)
                {
                    statuses.Requesting10_52();
                }
                else if (selectedItem == menu10_53Item)
                {
                    statuses.Requesting10_53();
                }
            }
        }
コード例 #40
0
        /// <summary>
        /// Creates the menu.
        /// </summary>
        private void CreateMenu()
        {
            #region create menu and menu items
            // Create the menu.
            menu = new UIMenu(GetPlayerName(PlayerId()), "Player Options", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };

            // Create all checkboxes.
            UIMenuCheckboxItem playerGodModeCheckbox         = new UIMenuCheckboxItem("Godmode", PlayerGodMode, "Makes you invincible.");
            UIMenuCheckboxItem invisibleCheckbox             = new UIMenuCheckboxItem("Invisible", PlayerInvisible, "Makes you invisible to yourself and others.");
            UIMenuCheckboxItem unlimitedStaminaCheckbox      = new UIMenuCheckboxItem("Unlimited Stamina", PlayerStamina, "Allows you to run forever without slowing down or taking damage.");
            UIMenuCheckboxItem fastRunCheckbox               = new UIMenuCheckboxItem("Fast Run", false, "Get ~g~Snail~s~ powers and run very fast!");
            UIMenuCheckboxItem fastSwimCheckbox              = new UIMenuCheckboxItem("Fast Swim", false, "Get ~g~Snail 2.0~s~ powers and swim super fast!");
            UIMenuCheckboxItem superJumpCheckbox             = new UIMenuCheckboxItem("Super Jump", PlayerSuperJump, "Get ~g~Snail 3.0~s~ powers and jump like a champ!");
            UIMenuCheckboxItem noRagdollCheckbox             = new UIMenuCheckboxItem("No Ragdoll", PlayerNoRagdoll, "Disables player ragdoll, makes you not fall off your bike anymore.");
            UIMenuCheckboxItem neverWantedCheckbox           = new UIMenuCheckboxItem("Never Wanted", PlayerNeverWanted, "Disables all wanted levels.");
            UIMenuCheckboxItem everyoneIgnoresPlayerCheckbox = new UIMenuCheckboxItem("Everyone Ignore Player", PlayerIsIgnored, "Everyone will leave you alone.");
            UIMenuCheckboxItem playerFrozenCheckbox          = new UIMenuCheckboxItem("Freeze Player", PlayerFrozen, "Freezes your current location, why would you do this...?");

            // Wanted level options
            List <dynamic> wantedLevelList = new List <dynamic> {
                "No Wanted Level", 1, 2, 3, 4, 5
            };
            UIMenuListItem setWantedLevel = new UIMenuListItem("Set Wanted Level", wantedLevelList, GetPlayerWantedLevel(PlayerId()), "Set your wanted level by selecting a value, and pressing enter.");

            // Player options
            List <dynamic> playerOptionsList = new List <dynamic> {
                "Max Health", "Max Armor", "Clean Player Clothes", "Player Dry", "Player Wet", "~r~Commit Suicide", "Drive To Waypoint", "Drive Around Randomly"
            };
            UIMenuListItem playerFunctions = new UIMenuListItem("Player Functions", playerOptionsList, 0, "Select an option and press enter to run/stop it.");

            // Scenarios (list can be found in the PedScenarios class)
            UIMenuListItem playerScenarios = new UIMenuListItem("Player Scenarios", PedScenarios.Scenarios, 0, "Select a scenario and hit enter to start it. Selecting another scenario will override the current scenario. If you're already playing the selected scenario, selecting it again will stop the scenario.");
            UIMenuItem     stopScenario    = new UIMenuItem("Force Stop Scenario", "This will force a playing scenario to stop immediately, without waiting for it to finish it's 'stopping' animation.");
            #endregion

            #region add items to menu based on permissions
            // Add all checkboxes to the menu. (keeping permissions in mind)
            if (cf.IsAllowed(Permission.POGod))
            {
                menu.AddItem(playerGodModeCheckbox);
            }
            if (cf.IsAllowed(Permission.POInvisible))
            {
                menu.AddItem(invisibleCheckbox);
            }

            // Always allowed.
            menu.AddItem(unlimitedStaminaCheckbox);

            if (cf.IsAllowed(Permission.POFastRun))
            {
                menu.AddItem(fastRunCheckbox);
            }
            if (cf.IsAllowed(Permission.POFastSwim))
            {
                menu.AddItem(fastSwimCheckbox);
            }
            if (cf.IsAllowed(Permission.POSuperjump))
            {
                menu.AddItem(superJumpCheckbox);
            }
            if (cf.IsAllowed(Permission.PONoRagdoll))
            {
                menu.AddItem(noRagdollCheckbox);
            }
            if (cf.IsAllowed(Permission.PONeverWanted))
            {
                menu.AddItem(neverWantedCheckbox);
            }
            if (cf.IsAllowed(Permission.POSetWanted))
            {
                menu.AddItem(setWantedLevel);
            }
            if (cf.IsAllowed(Permission.POIgnored))
            {
                menu.AddItem(everyoneIgnoresPlayerCheckbox);
            }
            if (cf.IsAllowed(Permission.POFunctions))
            {
                menu.AddItem(playerFunctions);
            }
            if (cf.IsAllowed(Permission.POFreeze))
            {
                menu.AddItem(playerFrozenCheckbox);
            }
            if (cf.IsAllowed(Permission.POScenarios))
            {
                menu.AddItem(playerScenarios);
                menu.AddItem(stopScenario);
            }
            #endregion

            #region handle all events
            // Checkbox changes.
            menu.OnCheckboxChange += (sender, item, _checked) =>
            {
                // God Mode toggled.
                if (item == playerGodModeCheckbox)
                {
                    PlayerGodMode = _checked;
                }
                // Invisibility toggled.
                else if (item == invisibleCheckbox)
                {
                    PlayerInvisible = _checked;
                }
                // Unlimited Stamina toggled.
                else if (item == unlimitedStaminaCheckbox)
                {
                    PlayerStamina = _checked;
                }
                // Fast run toggled.
                else if (item == fastRunCheckbox)
                {
                    PlayerFastRun = _checked;
                    SetRunSprintMultiplierForPlayer(PlayerId(), (_checked ? 1.49f : 1f));
                }
                // Fast swim toggled.
                else if (item == fastSwimCheckbox)
                {
                    PlayerFastSwim = _checked;
                    SetSwimMultiplierForPlayer(PlayerId(), (_checked ? 1.49f : 1f));
                }
                // Super jump toggled.
                else if (item == superJumpCheckbox)
                {
                    PlayerSuperJump = _checked;
                }
                // No ragdoll toggled.
                else if (item == noRagdollCheckbox)
                {
                    PlayerNoRagdoll = _checked;
                }
                // Never wanted toggled.
                else if (item == neverWantedCheckbox)
                {
                    PlayerNeverWanted = _checked;
                }
                // Everyone ignores player toggled.
                else if (item == everyoneIgnoresPlayerCheckbox)
                {
                    PlayerIsIgnored = _checked;
                }
                // Freeze player toggled.
                else if (item == playerFrozenCheckbox)
                {
                    PlayerFrozen = _checked;
                    if (!_checked)
                    {
                        FreezeEntityPosition(PlayerPedId(), false);
                    }
                }
            };

            // List selections
            menu.OnListSelect += (sender, listItem, index) =>
            {
                // Set wanted Level
                if (listItem == setWantedLevel)
                {
                    SetPlayerWantedLevel(PlayerId(), index, false);
                    SetPlayerWantedLevelNow(PlayerId(), false);
                }
                // Player options (healing, cleaning, armor, dry/wet, etc)
                else if (listItem == playerFunctions)
                {
                    switch (index)
                    {
                    // Max Health
                    case 0:
                        SetEntityHealth(PlayerPedId(), GetEntityMaxHealth(PlayerPedId()));
                        Subtitle.Info("Max ~g~health ~s~applied.", prefix: "Info:");
                        break;

                    // Max Armor
                    case 1:
                        SetPedArmour(PlayerPedId(), GetPlayerMaxArmour(PlayerId()));
                        Subtitle.Info("Max ~b~armor ~s~applied.", prefix: "Info:");
                        break;

                    // Clean Player Clothes
                    case 2:
                        ClearPedBloodDamage(PlayerPedId());
                        Subtitle.Info("Cleaned player clothes.", prefix: "Info:");
                        break;

                    // Make Player Dry
                    case 3:
                        ClearPedWetness(PlayerPedId());
                        Subtitle.Info("Player clothes are now ~c~dry~s~.", prefix: "Info:");
                        break;

                    // Make Player Wet
                    case 4:
                        SetPedWetnessHeight(PlayerPedId(), 2f);
                        SetPedWetnessEnabledThisFrame(PlayerPedId());
                        Subtitle.Info("Player clothes are now ~b~wet~s~.", prefix: "Info:");
                        break;

                    // Kill Player
                    case 5:
                        cf.CommitSuicide();
                        //SetEntityHealth(PlayerPedId(), 0);
                        //Subtitle.Info("You ~r~killed ~s~yourself.", prefix: "Info:");
                        break;

                    // Drive To Waypoint
                    case 6:
                        if (!Game.IsWaypointActive)
                        {
                            Subtitle.Error("You need to set a ~p~waypoint ~s~first!", prefix: "Error:");
                        }
                        else if (IsPedInAnyVehicle(PlayerPedId(), false))
                        {
                            try
                            {
                                cf.DriveToWp();
                            }
                            catch (NotImplementedException e)
                            {
                                cf.Log("\n\r[vMenu] Exception: " + e.Message + "\r\n");
                                Notify.Error(CommonErrors.UnknownError, placeholderValue: "This function is not implemented yet.");
                            }
                        }
                        else
                        {
                            Subtitle.Error("You need a ~r~vehicle ~s~first!", prefix: "Error:");
                        }
                        break;

                    // Drive Around Randomly (wander)
                    case 7:
                        if (IsPedInAnyVehicle(PlayerPedId(), false))
                        {
                            try
                            {
                                cf.DriveWander();
                            }
                            catch (NotImplementedException e)
                            {
                                cf.Log("\n\r[vMenu] Exception: " + e.Message + "\r\n");
                                Notify.Error(CommonErrors.UnknownError, placeholderValue: "This function is not implemented yet.");
                            }
                        }
                        else
                        {
                            Subtitle.Error("You need a ~r~vehicle ~s~first!", prefix: "Error:");
                        }
                        break;

                    default:
                        break;
                    }
                }
                // Player Scenarios
                else if (listItem == playerScenarios)
                {
                    cf.PlayScenario(PedScenarios.ScenarioNames[PedScenarios.Scenarios[index]]);
                }
            };

            // button presses
            menu.OnItemSelect += (sender, item, index) =>
            {
                // Force Stop Scenario button
                if (item == stopScenario)
                {
                    // Play a new scenario named "forcestop" (this scenario doesn't exist, but the "Play" function checks
                    // for the string "forcestop", if that's provided as th scenario name then it will forcefully clear the player task.
                    cf.PlayScenario("forcestop");
                }
            };
            #endregion
        }
コード例 #41
0
    public void AddMenuCook(UIMenu menu)
    {
        var newitem = new UIMenuItem("Cook!", "Cook the dish with the appropiate ingredients and ketchup.");

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

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

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

        menu.AddItem(colorItem);

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

        var BlankItem = new UIMenuSeparatorItem();

        menu.AddItem(BlankItem);

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

        menu.AddItem(colorListItem);


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

        menu.AddItem(SliderProgress);

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

        menu.AddItem(Progress);

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

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

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

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

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

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

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

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

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

        menu.OnListChange += (sender, item, index) =>
        {
            if (item == listPanelItem1)
            {
                Screen.ShowNotification("Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...");
                item.Description = "Selected color " + ((item.Panels[0] as UIMenuColorPanel).CurrentSelection + 1) + "...";
                item.Parent.UpdateDescription();                 // this is neat.. this will update the description of the item without refresh index.. try it by changing color
            }
            else if (item == listPanelItem2)
            {
                Screen.ShowSubtitle("Percentage = " + (item.Panels[0] as UIMenuPercentagePanel).Percentage + "...");
            }
            else if (item == listPanelItem3)
            {
                Screen.ShowSubtitle("GridPosition = " + (item.Panels[0] as UIMenuGridPanel).CirclePosition + "...");
            }
        };
    }
コード例 #42
0
        protected virtual void Draw()
        {
            SizeF res    = UIMenu.GetScreenResolutionMantainRatio();
            int   middle = (int)(res.Width / 2);

            Sprite.Draw("mpentry", "mp_modenotselected_gradient", new Point(0, 10), new Size((int)res.Width, 450 + (Items.Count * 40)), 0.0f, Color.FromArgb(200, 255, 255, 255));

            ResText.Draw(Title, new Point(middle, 100), 2.5f, Color.FromArgb(255, 199, 168, 87), Common.EFont.Pricedown, true);

            ResText.Draw(Subtitle, new Point(middle, 230), 0.5f, Color.White, Common.EFont.ChaletLondon, true);
            ResRectangle.Draw(new Point(middle - 300, 290), new Size(600, 2), Color.White);

            for (int i = 0; i < Items.Count; i++)
            {
                MissionPassedScreenItem item = Items[i];

                ResText.Draw(item.Label, new Point(middle - 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, false);
                ResText.Draw(item.Status, new Point(item.Tickbox == MissionPassedScreenItem.TickboxState.None ? middle + 265 : middle + 230, 300 + (40 * i)), 0.35f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);

                if (item.Tickbox == MissionPassedScreenItem.TickboxState.None)
                {
                    continue;
                }

                string spriteName;
                if (item.Tickbox == MissionPassedScreenItem.TickboxState.Tick)
                {
                    spriteName = "shop_box_tick";
                }
                else if (item.Tickbox == MissionPassedScreenItem.TickboxState.Cross)
                {
                    spriteName = "shop_box_cross";
                }
                else
                {
                    spriteName = "shop_box_blank";
                }

                Sprite.Draw("commonmenu", spriteName, new Point(middle + 230, 290 + (40 * i)), new Size(48, 48), 0.0f, Color.White);
            }

            ResRectangle.Draw(new Point(middle - 300, 300 + (40 * Items.Count)), new Size(600, 2), Color.White);

            ResText.Draw("Completion", new Point(middle - 150, 320 + (40 * Items.Count)), 0.4f, Color.White, Common.EFont.ChaletLondon, false);
            ResText.Draw(CompletionPercentage + "%", new Point(middle + 150, 320 + (40 * Items.Count)), 0.4f, Color.White, Common.EFont.ChaletLondon, ResText.Alignment.Right, false, false, Size.Empty);

            string medalSprite;

            if (Medal == MedalType.Silver)
            {
                medalSprite = "silvermedal";
            }
            else if (Medal == MedalType.Gold)
            {
                medalSprite = "goldmedal";
            }
            else
            {
                medalSprite = "bronzemedal";
            }

            Sprite.Draw("mpmissionend", medalSprite, new Point(middle + 150, 320 + (40 * Items.Count)), new Size(32, 32), 0.0f, Color.White);

            InstructionalButtons.Draw();
        }
コード例 #43
0
ファイル: Main.cs プロジェクト: nheisterkamp/bepmod
 private void Menu_OnCheckboxChange(UIMenu sender, UIMenuCheckboxItem checkboxItem, bool Checked)
 {
     int index = sender.MenuItems.IndexOf(checkboxItem);
 }
コード例 #44
0
        void InitMenu()
        {
            // First initialize an instance of a MenuPool.
            // A MenuPool object will manage all the interconnected
            // menus that you add to it.
            _menuPool = new MenuPool();

            // Initialize a menu, with name "Main Menu"
            mainMenu = new UIMenu("Main Menu");
            // Add mainMenu to _menuPool
            _menuPool.AddMenu(mainMenu);

            // Let's set the colors of the menu before adding other menus
            // so that submenus will also have the same color scheme.
            // Requires a reference to System.Drawing
            mainMenu.TitleColor                 = Color.FromArgb(255, 237, 90, 90);
            mainMenu.TitleBackgroundColor       = Color.FromArgb(240, 0, 0, 0);
            mainMenu.TitleUnderlineColor        = Color.FromArgb(255, 237, 90, 90);
            mainMenu.DefaultBoxColor            = Color.FromArgb(160, 0, 0, 0);
            mainMenu.DefaultTextColor           = Color.FromArgb(230, 255, 255, 255);
            mainMenu.HighlightedBoxColor        = Color.FromArgb(130, 237, 90, 90);
            mainMenu.HighlightedItemTextColor   = Color.FromArgb(255, 255, 255, 255);
            mainMenu.DescriptionBoxColor        = Color.FromArgb(255, 0, 0, 0);
            mainMenu.DescriptionTextColor       = Color.FromArgb(255, 255, 255, 255);
            mainMenu.SubsectionDefaultBoxColor  = Color.FromArgb(160, 0, 0, 0);
            mainMenu.SubsectionDefaultTextColor = Color.FromArgb(180, 255, 255, 255);

            // A string attached to the end of submenu's menu item text
            // to indicate that the item leads to a submenu.
            _menuPool.SubmenuItemIndication = "  ~r~>";

            #region SUBMENU_SETUP

            // Initialize another menu, with name "Submenu"
            subMenu = new UIMenu("Submenu");
            // Add subMenu to _menuPool as a child menu of mainMenu.
            // This will create a menu item in mainMenu with the name "Go to Submenu",
            // and selecting it will bring you to the submenu.
            _menuPool.AddSubMenu(subMenu, mainMenu, "Go to Submenu");

            // Initialize an item called "Submenu Item 1"
            // and add it to the submenu.
            submenuItem1 = new UIMenuItem("Submenu Item 1");
            subMenu.AddMenuItem(submenuItem1);

            // Same as above
            submenuItem2 = new UIMenuItem("Submenu Item 2");
            subMenu.AddMenuItem(submenuItem2);

            #endregion

            // A UIMenuSubsectionItem is essentially just a splitter.
            subsectionItem = new UIMenuSubsectionItem("--- Splitter ---");
            // Add subsectionItem to the mainMenu.
            // It will appear after the subMenu item,
            // since this is the order we are affecting mainMenu.
            mainMenu.AddMenuItem(subsectionItem);

            // Just adding some more items to mainMenu.
            // Second param is the default value.
            // Third param is a description that appears at the bottom
            // of the menu.
            // UIMenuNumberValueItem is just like UIMenuItem but with "<" and ">"
            // wrapped around the value.

            itemSelectFunction = new UIMenuItem("Select me!", null, "Select me to show a subtitle.");
            mainMenu.AddMenuItem(itemSelectFunction);

            itemBoolControl = new UIMenuItem("Bool Item", testBool, "This item controls a bool.");
            mainMenu.AddMenuItem(itemBoolControl);

            itemIntegerControl = new UIMenuNumberValueItem("Integer Item", testInt, "This item controls an integer.");
            mainMenu.AddMenuItem(itemIntegerControl);

            itemFloatControl = new UIMenuNumberValueItem("Float Item", testFloat, "This item controls a float.");
            mainMenu.AddMenuItem(itemFloatControl);

            itemEnumControl = new UIMenuNumberValueItem("Enum Item", testEnum, "This item controls an enum.");
            mainMenu.AddMenuItem(itemEnumControl);

            subsectionItem2 = new UIMenuSubsectionItem("--- List Stuff ---");
            mainMenu.AddMenuItem(subsectionItem2);

            // the 3rd param must be of type List<dynamic>
            // or you will get a compile time error.
            itemListControl = new UIMenuListItem("List Item", "This item can output an object from a list.", testListString);
            mainMenu.AddMenuItem(itemListControl);

            itemListControlAdvanced = new UIMenuListItem("People", "A list of people", testListAdvanced);
            mainMenu.AddMenuItem(itemListControlAdvanced);

            itemAddPerson = new UIMenuItem("Add a person");
            mainMenu.AddMenuItem(itemAddPerson);

            itemRemoveLastPerson = new UIMenuItem("Remove last person");
            mainMenu.AddMenuItem(itemRemoveLastPerson);

            // Now let's create some events.
            // All events are in the UIMenu class.
            // You can create a specific or anonymous method.

            // Let's subscribe mainMenu's OnItemSelect event to an anonymous method.
            // This method will be executed whenever you press Enter, Numpad5, or
            // the Select button on a gamepad while mainMenu is open.
            mainMenu.OnItemSelect += (sender, selectedItem, index) =>
            {
                // Check which item is selected.
                if (selectedItem == itemSelectFunction)
                {
                    UI.ShowSubtitle("Hi! I'm testing SimpleUI's OnItemSelect event!");
                }
                else if (selectedItem == itemBoolControl)
                {
                    // ControlBoolValue is an easy way to let a menu item control
                    // a specific bool with one line of code.
                    // In this example, we will control the var "testBool" with
                    // the "itemBoolControl" menu item.
                    mainMenu.ControlBoolValue(ref testBool, itemBoolControl);
                }
                else if (selectedItem == itemAddPerson)
                {
                    string fname = Game.GetUserInput("FirstName", 999);
                    if (String.IsNullOrWhiteSpace(fname))
                    {
                        return;
                    }

                    string lname = Game.GetUserInput("LastName", 999);
                    if (String.IsNullOrWhiteSpace(lname))
                    {
                        return;
                    }

                    string input = Game.GetUserInput("ID", 999);
                    if (String.IsNullOrWhiteSpace(lname))
                    {
                        return;
                    }

                    int  id;
                    bool idParsed = int.TryParse(input, out id);

                    if (!idParsed)
                    {
                        return;
                    }

                    testListAdvanced.Add(new Person(fname, lname, id));

                    // Call this after modifying your list or you may
                    // get an out of bounds error.
                    itemListControlAdvanced.SaveListUpdateFromOutOfBounds();

                    UI.ShowSubtitle(fname + " " + lname + " added to list!");
                }
                else if (selectedItem == itemRemoveLastPerson)
                {
                    if (testListAdvanced.Count > 1)
                    {
                        UI.ShowSubtitle(testListAdvanced[testListAdvanced.Count - 1].ToString() + " removed from list!");

                        // Don't want to use LINQ for just this one line..
                        testListAdvanced.RemoveAt(testListAdvanced.Count - 1);

                        itemListControlAdvanced.SaveListUpdateFromOutOfBounds();
                    }
                    else
                    {
                        UI.ShowSubtitle("There is only one person left!");
                    }
                }
            };

            // Let's subscribe subMenu's WhileItemHighlight event to an anonymous method
            // This method will be executed continuously while subMenu is open.
            subMenu.WhileItemHighlight += (sender, selectedItem, index) =>
            {
                // Check which item is selected.
                if (selectedItem == submenuItem1)
                {
                    UI.ShowSubtitle("Highlighting subMenu's Item 1");
                }
                else if (selectedItem == submenuItem2)
                {
                    UI.ShowSubtitle("Highlighting subMenu's Item 2");
                }
            };

            // Let's subscribe mainMenu's OnItemLeftRight event to the method
            // "MainMenu_OnItemLeftRight"
            // This method will then be executed whenever you press left or right
            // while mainMenu is open.
            mainMenu.OnItemLeftRight += MainMenu_OnItemLeftRight;

            // That's it for this example setup!
            // SimpleUI also supports scrolling, so you can add as many items
            // or submenus as you'd like.
            // SimpleUI also supports dynamic hiding/showing of menu items,
            // and Dispose methods for items and menus, allowing easy modification
            // after the initial setup. Explore using Intellisense!
        }
コード例 #45
0
ファイル: UIMenu.cs プロジェクト: gavar/GJ-UGUNS
	public void Awake () { instance = this; }
コード例 #46
0
 /// <summary>
 /// Activates this item.
 /// </summary>
 /// <param name="menu">The <see cref="UIMenu"/> that is calling this method, or <c>null</c> if no menu is involved.</param>
 public void Activate(UIMenu menu = null)
 {
     menu?.ItemSelect(this, menu.MenuItems.IndexOf(this));
     ItemActivate(menu);
 }
コード例 #47
0
        private async Task Logic()
        {
            while (true)
            {
                if (Utility.Instance.GetDistanceBetweenVector3s(_bulkBuyPos, Game.PlayerPed.Position) < 5 && !Game.PlayerPed.IsInVehicle())
                {
                    _menuOpen = true;
                    _bulkMenu = true;
                }
                else if (Utility.Instance.GetDistanceBetweenVector3s(_singleBuyPos, Game.PlayerPed.Position) < 5 && !Game.PlayerPed.IsInVehicle())
                {
                    _menuOpen = true;
                    _bulkMenu = false;
                }
                else
                {
                    _menuOpen = false;
                }

                if (_menuOpen && !_menuCreated)
                {
                    if (_bulkMenu)
                    {
                        _menu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                            InteractionMenu.Instance._interactionMenu, Convert.ToString(Type), "Buy bulk " + Convert.ToString(Type) + " from here.", new PointF(5, Screen.Height / 2));
                        var buyButton = new UIMenuItem("Buy Bulk Package ~r~(" + ItemInfo[Type].BuyBulkPrice + ")");
                        _menu.AddItem(buyButton);
                        _menu.OnItemSelect += (sender, selectedItem, index) =>
                        {
                            if (selectedItem == buyButton)
                            {
                                if (Police.Instance.CopCount >= 1)
                                {
                                    TriggerServerEvent("BuyItemByName", "Bundle of " + Convert.ToString(Type));
                                    if (_random.Next(0, 3) == 1)
                                    {
                                        TriggerEvent("911CallClientAnonymous",
                                                     _buyingBulkMessages[_random.Next(0, _buyingBulkMessages.Count)]);
                                    }
                                }
                                else
                                {
                                    Utility.Instance.SendChatMessage("[Drugs]", "Not enough cops on.", 255, 0, 0);
                                }
                            }
                        };
                    }
                    else
                    {
                        _menu = InteractionMenu.Instance._interactionMenuPool.AddSubMenuOffset(
                            InteractionMenu.Instance._interactionMenu, Convert.ToString(Type), "Buy bulk " + Convert.ToString(Type) + " from here.", new PointF(5, Screen.Height / 2));
                        var sellBulk  = new UIMenuItem("Sell Bulk Package" + "~g~(" + ItemInfo[Type].SellBulkPrice + ")");
                        var buySingle = new UIMenuItem("Buy Single" + "~r~(" + ItemInfo[Type].BuySinglePrice + ")");
                        _menu.AddItem(sellBulk);
                        _menu.AddItem(buySingle);
                        _menu.OnItemSelect += (sender, selectedItem, index) =>
                        {
                            if (selectedItem == sellBulk)
                            {
                                Sell();
                                async Task Sell()
                                {
                                    Game.PlayerPed.IsPositionFrozen = true;
                                    await Delay(6000);

                                    Game.PlayerPed.IsPositionFrozen = false;
                                    TriggerServerEvent("SellItemByName", "Bundle of " + Convert.ToString(Type));
                                    if (_random.Next(0, 3) == 1)
                                    {
                                        TriggerEvent("911CallClientAnonymous", _sellingBulkMessages[_random.Next(0, _sellingBulkMessages.Count)]);
                                    }
                                }
                            }
                            if (selectedItem == buySingle)
                            {
                                TriggerServerEvent("BuyItemByName", Convert.ToString(Type));
                            }
                        };
                    }
                    _menuCreated = true;
                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                else if (!_menuOpen && _menuCreated)
                {
                    _menuCreated = false;
                    if (_menu.Visible)
                    {
                        _menu.Visible = false;
                        InteractionMenu.Instance._interactionMenuPool.CloseAllMenus();
                        InteractionMenu.Instance._interactionMenu.Visible = true;
                    }

                    var i = 0;
                    foreach (var item in InteractionMenu.Instance._interactionMenu.MenuItems)
                    {
                        if (item == _menu.ParentItem)
                        {
                            InteractionMenu.Instance._interactionMenu.RemoveItemAt(i);
                            break;
                        }
                        i++;
                    }
                    InteractionMenu.Instance._interactionMenuPool.RefreshIndex();
                }
                await Delay(1000);
            }
        }
コード例 #48
0
 internal virtual void ItemActivate(UIMenu sender)
 {
     Activated?.Invoke(sender, this);
 }
コード例 #49
0
 public void AddActorActionToMenu(UIMenu menu, String name, Action<UIMenuItem, int> action, Func<int, bool> ticked)
 {
     var submenu = AddSubMenu(menu, name);
     for (int i = 0; i < 10; i++)
     {
         var subsubmenu = AddSubMenu(submenu, String.Format("Actors {0}-{1}", 1 + i * 10, 10 + i * 10));
         for (int j = 0; j < 10; j++)
         {
             var slot = 1 + j + i * 10;
             var slotitem = new UIMenuItem(String.Format("Actor {0}", slot));
             subsubmenu.AddItem(slotitem);
             if (ticked(slot)) slotitem.SetLeftBadge(UIMenuItem.BadgeStyle.Tick);
             subsubmenu.OnItemSelect += (sender, item, index) =>
             {
                 if (item == slotitem) action(slotitem, slot);
             };
         }
     }
 }
コード例 #50
0
        public virtual void Draw(float x, float y, float width, float height)
        {
            float rectWidth  = width;
            float rectHeight = height;
            float rectX      = x + rectWidth * 0.5f;
            float rectY      = y + rectHeight * 0.5f;

            if (Selected && CanDrawNavBar)
            {
                UIMenu.DrawSprite(UIMenu.CommonTxd, UIMenu.NavBarTextureName,
                                  rectX, rectY,
                                  rectWidth, rectHeight,
                                  HighlightedBackColor);
            }
            else if (BackColor != Color.Empty)
            {
                UIMenu.DrawRect(rectX, rectY,
                                rectWidth, rectHeight,
                                BackColor);
            }

            if (Hovered && !Selected)
            {
                Color hoveredColor = Color.FromArgb(25, 255, 255, 255);
                UIMenu.DrawRect(rectX, rectY - 0.00138888f * 0.5f,
                                rectWidth, rectHeight - 0.00138888f,
                                hoveredColor);
            }

            if (LeftBadgeInfo != null)
            {
                DrawBadge(LeftBadgeInfo, true, x, y, width, height, out leftBadgeOffset);
            }
            else
            {
                leftBadgeOffset = 0.0f;
            }

            if (RightBadgeInfo != null)
            {
                DrawBadge(RightBadgeInfo, false, x, y, width, height, out rightBadgeOffset);
            }
            else
            {
                rightBadgeOffset = 0.0f;
            }

            if (!string.IsNullOrEmpty(Text))
            {
                SetTextCommandOptions();
                TextCommands.Display(Text, x + 0.0046875f + leftBadgeOffset, y + 0.00277776f);
            }

            if (!string.IsNullOrEmpty(RightLabel))
            {
                SetTextCommandOptions(false);
                float labelWidth = TextCommands.GetWidth(RightLabel);

                float labelX = x + width - 0.00390625f - labelWidth - rightBadgeOffset;
                float labelY = y + 0.00277776f;

                SetTextCommandOptions(false);
                TextCommands.Display(RightLabel, labelX, labelY);
            }
        }
コード例 #51
0
 public void AddClearAppearanceToMenu(UIMenu menu)
 {
     Action Clear = () =>
     {
         var ped = Game.Player.Character;
         foreach (SlotType slot_type in Enum.GetValues(typeof(SlotType)))
             for (int slot_id = 0; slot_id < PedData.GetNumId(slot_type); slot_id++)
             {
                 var slot_key = new SlotKey(slot_type, slot_id);
                 ped_data.ClearSlot(ped, slot_key);
             }
     };
     var clearitem = new UIMenuItem("Clear Appearance");
     AddItem(menu, clearitem, OnSelect: Clear);
 }
コード例 #52
0
ファイル: UIMenuInput.cs プロジェクト: NivMizzle/NotTheFace
 public void SetMenu(UIMenu menu)
 {
     this.menu = menu;
 }
コード例 #53
0
 public void AddFreemodeModelToMenu(UIMenu menu)
 {
     Action ChangeMale = () => ped_data.ChangePlayerModel(PedHash.FreemodeMale01);
     Action ChangeFemale = () => ped_data.ChangePlayerModel(PedHash.FreemodeFemale01);
     var male = new UIMenuItem("Male");
     var female = new UIMenuItem("Female");
     AddItem(menu, male, OnSelect: ChangeMale);
     AddItem(menu, female, OnSelect: ChangeFemale);
 }
コード例 #54
0
 private void OnQuickEditMenuOpened(UIMenu sender, UIMenuItem selectedItem)
 {
     // Sequences may have been changed by other menus, need to refresh before showing
     SequenceQuickEdit.Menu.RefreshData();
     SequenceQuickEdit.Menu.RefreshIndex();
 }
コード例 #55
0
 public void AddStorymodeAppearanceToMenu(UIMenu menu)
 {
     var topmenu = AddSubMenu(menu, "Appearance");
     var charmenu = AddSubMenu(topmenu, "Character");
     var barbmenu = AddSubMenu(topmenu, "Barber");
     var clo1menu = AddSubMenu(topmenu, "Clothing");
     var clo2menu = AddSubMenu(topmenu, "Clothing Extra");
     AddSlotToMenu(charmenu, "Face", new SlotKey(SlotType.CompVar, 0));
     AddSlotToMenu(charmenu, "Eyes", new SlotKey(SlotType.CompVar, 7));
     AddSlotToMenu(barbmenu, "Haircut", new SlotKey(SlotType.CompVar, 2));
     AddSlotToMenu(barbmenu, "Beard", new SlotKey(SlotType.CompVar, 1));
     AddSlotToMenu(clo1menu, "Hands", new SlotKey(SlotType.CompVar, 5));
     AddSlotToMenu(clo1menu, "Shirt", new SlotKey(SlotType.CompVar, 3));
     AddSlotToMenu(clo1menu, "Pants", new SlotKey(SlotType.CompVar, 4));
     AddSlotToMenu(clo1menu, "Shoes", new SlotKey(SlotType.CompVar, 6));
     AddSlotToMenu(clo2menu, "Hat", new SlotKey(SlotType.Prop, 0));
     AddSlotToMenu(clo2menu, "Glasses", new SlotKey(SlotType.Prop, 1));
     AddSlotToMenu(clo2menu, "Earrings", new SlotKey(SlotType.Prop, 2));
     AddSlotToMenu(clo2menu, "Watch", new SlotKey(SlotType.Prop, 6));
     AddSlotToMenu(clo2menu, "Bangle", new SlotKey(SlotType.Prop, 7));
     AddSlotToMenu(clo2menu, "Accessory", new SlotKey(SlotType.CompVar, 8));
     AddSlotToMenu(clo2menu, "Item", new SlotKey(SlotType.CompVar, 9));
     AddSlotToMenu(clo2menu, "Decal", new SlotKey(SlotType.CompVar, 10));
     AddSlotToMenu(clo2menu, "Collar", new SlotKey(SlotType.CompVar, 11));
 }
コード例 #56
0
 private void onSirenSubmenuActivated(UIMenu sender, UIMenuItem selectedItem)
 {
     sender.Visible = false;
     SirenSwitcherItem.SwitchMenuItem.CurrentMenu.Visible = true;
 }
コード例 #57
0
 public void AddStorymodeToMenu(UIMenu menu)
 {
     var submenu = AddSubMenu(menu, "Story Mode");
     AddStorymodeModelToMenu(submenu);
     AddStorymodeAppearanceToMenu(submenu);
     AddClearAppearanceToMenu(submenu);
 }
コード例 #58
0
ファイル: TabView.cs プロジェクト: lardumofficial/NativeUI
        public void Update()
        {
            if (!Visible || TemporarilyHidden)
            {
                return;
            }
            ShowInstructionalButtons();
            Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);
            Function.Call(Hash._SHOW_CURSOR_THIS_FRAME);


            var res  = UIMenu.GetScreenResolutionMaintainRatio();
            var safe = new PointF(300, 180);

            if (!HideTabs)
            {
                new UIResText(Title, new PointF(safe.X, safe.Y - 80), 1f, UnknownColors.White, Font.ChaletComprimeCologne,
                              UIResText.Alignment.Left)
                {
                    DropShadow = true,
                }.Draw();

                if (Photo == null)
                {
                    new Sprite("char_multiplayer", "char_multiplayer",
                               new PointF((int)res.Width - safe.X - 64, safe.Y - 80), new SizeF(64, 64)).Draw();
                }
                else
                {
                    Photo.Position = new PointF((int)res.Width - safe.X - 100, safe.Y - 80);
                    Photo.Size     = new SizeF(64, 64);
                    Photo.Draw();
                }

                new UIResText(Name, new PointF((int)res.Width - safe.X - 70, safe.Y - 95), 0.7f, UnknownColors.White,
                              Font.ChaletComprimeCologne, UIResText.Alignment.Right)
                {
                    DropShadow = true,
                }.Draw();

                string t = Money;
                if (string.IsNullOrEmpty(Money))
                {
                    t = DateTime.Now.ToString();
                }


                new UIResText(t, new PointF((int)res.Width - safe.X - 70, safe.Y - 60), 0.4f, UnknownColors.White,
                              Font.ChaletComprimeCologne, UIResText.Alignment.Right)
                {
                    DropShadow = true,
                }.Draw();

                string subt = MoneySubtitle;
                if (string.IsNullOrEmpty(MoneySubtitle))
                {
                    subt = "";
                }

                new UIResText(subt, new PointF((int)res.Width - safe.X - 70, safe.Y - 40), 0.4f, UnknownColors.White,
                              Font.ChaletComprimeCologne, UIResText.Alignment.Right)
                {
                    DropShadow = true,
                }.Draw();

                for (int i = 0; i < Tabs.Count; i++)
                {
                    var activeSize = res.Width - 2 * safe.X;
                    activeSize -= 4 * 5;
                    int tabWidth = (int)activeSize / Tabs.Count;

                    Game.EnableControlThisFrame(0, Control.CursorX);
                    Game.EnableControlThisFrame(0, Control.CursorY);

                    var hovering = UIMenu.IsMouseInBounds(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)),
                                                          new SizeF(tabWidth, 40));

                    var tabColor = Tabs[i].Active
                        ? UnknownColors.White
                        : hovering?Color.FromArgb(100, 50, 50, 50) : UnknownColors.Black;

                    new UIResRectangle(safe.AddPoints(new PointF((tabWidth + 5) * i, 0)), new SizeF(tabWidth, 40),
                                       Color.FromArgb(Tabs[i].Active ? 255 : 200, tabColor)).Draw();

                    new UIResText(Tabs[i].Title.ToUpper(), safe.AddPoints(new PointF((tabWidth / 2) + (tabWidth + 5) * i, 5)),
                                  0.35f,
                                  Tabs[i].Active ? UnknownColors.Black : UnknownColors.White, Font.ChaletLondon, UIResText.Alignment.Centered)
                    .Draw();

                    if (Tabs[i].Active)
                    {
                        new UIResRectangle(safe.SubtractPoints(new PointF(-((tabWidth + 5) * i), 10)),
                                           new SizeF(tabWidth, 10), UnknownColors.DodgerBlue).Draw();
                    }

                    if (hovering && Game.IsControlJustPressed(0, Control.CursorAccept) && !Tabs[i].Active)
                    {
                        Tabs[Index].Active  = false;
                        Tabs[Index].Focused = false;
                        Tabs[Index].Visible = false;
                        Index = (1000 - (1000 % Tabs.Count) + i) % Tabs.Count;
                        Tabs[Index].Active     = true;
                        Tabs[Index].Focused    = true;
                        Tabs[Index].Visible    = true;
                        Tabs[Index].JustOpened = true;

                        if (Tabs[Index].CanBeFocused)
                        {
                            FocusLevel = 1;
                        }
                        else
                        {
                            FocusLevel = 0;
                        }

                        Function.Call(Hash.PLAY_SOUND_FRONTEND, -1, "NAV_UP_DOWN", "HUD_FRONTEND_DEFAULT_SOUNDSET", 1);
                    }
                }
            }
            Tabs[Index].Draw();

            _sc.CallFunction("DRAW_INSTRUCTIONAL_BUTTONS", -1);

            _sc.Render2D();
        }
コード例 #59
0
ファイル: NativeMenuItem.cs プロジェクト: Guad/RAGENativeUI
 internal virtual void ItemActivate(UIMenu sender)
 {
     Activated.Invoke(sender, this);
 }
コード例 #60
0
ファイル: PlayerAppearance.cs プロジェクト: sadboilogan/vMenu
        /// <summary>
        /// Creates the menu(s).
        /// </summary>
        private void CreateMenu()
        {
            // Create the menu.
            menu = new UIMenu(GetPlayerName(PlayerId()), "Player Appearance", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };

            //Create the submenus.
            spawnSavedPedMenu = new UIMenu("Saved Peds", "Spawn a saved ped", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            deleteSavedPedMenu = new UIMenu("Saved Peds", "Delete a saved ped", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };
            pedTextures = new UIMenu("Ped Customization", "Customize your ped", true)
            {
                ScaleWithSafezone       = false,
                MouseControlsEnabled    = false,
                MouseEdgeEnabled        = false,
                ControlDisablingEnabled = false
            };

            // Add the (submenus) to the menu pool.
            MainMenu.Mp.Add(pedTextures);
            MainMenu.Mp.Add(spawnSavedPedMenu);
            MainMenu.Mp.Add(deleteSavedPedMenu);

            // Create the menu items.
            UIMenuItem pedCustomization = new UIMenuItem("Ped Customization", "Modify your ped's appearance.");

            pedCustomization.SetRightLabel("→→→");
            UIMenuItem savePed = new UIMenuItem("Save Current Ped", "Save your current ped and clothes.");

            savePed.SetRightBadge(UIMenuItem.BadgeStyle.Tick);
            UIMenuItem spawnSavedPed = new UIMenuItem("Spawn Saved Ped", "Spawn one of your saved peds.");

            spawnSavedPed.SetRightLabel("→→→");
            UIMenuItem deleteSavedPed = new UIMenuItem("Delete Saved Ped", "Delete one of your saved peds.");

            deleteSavedPed.SetRightLabel("→→→");
            deleteSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Alert);

            // Add items to the mneu.
            menu.AddItem(pedCustomization);
            menu.AddItem(savePed);
            menu.AddItem(spawnSavedPed);
            menu.AddItem(deleteSavedPed);

            // Bind items to the submenus.
            if (cf.IsAllowed(Permission.PACustomize))
            {
                menu.BindMenuToItem(pedTextures, pedCustomization);
            }
            else
            {
                pedCustomization.Enabled = false;
                pedCustomization.SetLeftBadge(UIMenuItem.BadgeStyle.Lock);
                pedCustomization.Description = "This option has been disabled by the server owner.";
            }


            if (cf.IsAllowed(Permission.PASpawnSaved))
            {
                menu.BindMenuToItem(spawnSavedPedMenu, spawnSavedPed);
            }
            else
            {
                spawnSavedPed.Enabled = false;
                spawnSavedPed.SetLeftBadge(UIMenuItem.BadgeStyle.Lock);
                spawnSavedPed.Description = "This option has been disabled by the server owner.";
            }

            menu.BindMenuToItem(deleteSavedPedMenu, deleteSavedPed);

            // Handle button presses.
            menu.OnItemSelect += (sender, item, index) =>
            {
                if (item == pedCustomization)
                {
                    RefreshCustomizationMenu();
                }
                else if (item == spawnSavedPed)
                {
                    RefreshSpawnSavedPedMenu();
                }
                else if (item == deleteSavedPed)
                {
                    RefreshDeleteSavedPedMenu();
                }
                else if (item == savePed)
                {
                    cf.SavePed();
                }
            };

            // Loop through all the modelNames and create lists of max 50 ped names each.
            for (int i = 0; i < (modelNames.Count / 50) + 1; i++)
            {
                List <dynamic> pedList = new List <dynamic>();
                for (int ii = 0; ii < 50; ii++)
                {
                    int index = ((i * 50) + ii);
                    if (index >= modelNames.Count)
                    {
                        break;
                    }
                    int max = ((modelNames.Count / 50) != i) ? 50 : modelNames.Count % 50;
                    pedList.Add(modelNames[index] + $" ({(ii + 1).ToString()}/{max.ToString()})");
                }
                UIMenuListItem pedl = new UIMenuListItem("Peds #" + (i + 1).ToString(), pedList, 0);

                menu.AddItem(pedl);
                if (!cf.IsAllowed(Permission.PASpawnNew))
                {
                    pedl.Enabled = false;
                    pedl.SetLeftBadge(UIMenuItem.BadgeStyle.Lock);
                    pedl.Description = "This option has been disabled by the server owner.";
                }
            }

            // Handle list selections.
            menu.OnListSelect += (sender, item, index) =>
            {
                int    i         = ((sender.CurrentSelection - 4) * 50) + index;
                string modelName = modelNames[i];
                if (cf.IsAllowed(Permission.PASpawnNew))
                {
                    cf.SetPlayerSkin(modelName);
                }
            };
        }