SetRightLabel() 공개 메소드

Set the right label.
public SetRightLabel ( string text ) : void
text string Text as label. Set it to "" to remove the label.
리턴 void
예제 #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
        private void RedrawLists(string type)
        {
            Clear();
            var typeList = _database.Select(pair => pair.Key).Cast<dynamic>().ToList();
            var typeItem = new UIMenuListItem("Ammo Type", typeList, typeList.FindIndex(n => n.ToString() == type), "Select an ammo type to purchase.");
            AddItem(typeItem);

            typeItem.OnListChanged += (list, newindex) =>
            {
                string newType = ((UIMenuListItem)MenuItems[0]).IndexToItem(((UIMenuListItem)MenuItems[0]).Index).ToString();
                RedrawLists(newType);
            };

            var weaponItem = new UIMenuListItem("Weapon", GetListForType(type), 0);
            AddItem(weaponItem);

            var buyRounds = new UIMenuItem("Rounds x 24");
            buyRounds.SetRightLabel("113$");
            var buyAllRounds = new UIMenuItem("Full Ammo");
            buyRounds.SetRightLabel("113$");

            buyRounds.Activated += (menu, item) =>
            {
                Game.Player.Character.Weapons.Give((WeaponHash)Enum.Parse(typeof(WeaponHash), ((UIMenuListItem)MenuItems[1]).IndexToItem(((UIMenuListItem)MenuItems[1]).Index).ToString()), 24, false, false);
            };

            buyAllRounds.Activated += (menu, item) =>
            {
                Game.Player.Character.Weapons.Give((WeaponHash)Enum.Parse(typeof(WeaponHash), ((UIMenuListItem)MenuItems[1]).IndexToItem(((UIMenuListItem)MenuItems[1]).Index).ToString()), 9999, false, false);
            };

            AddItem(buyRounds);
            AddItem(buyAllRounds);
        }
예제 #3
0
파일: MapEditor.cs 프로젝트: Guad/MapEditor
        private void RedrawSearchMenu(string searchQuery, ObjectTypes type = ObjectTypes.Prop)
        {
            _searchMenu.Clear();

            switch (type)
            {
                case ObjectTypes.Prop:
                    foreach (var u in ObjectDatabase.MainDb.Where(pair => ApplySearchQuery(searchQuery, pair.Key)))
                    {
                        var object1 = new UIMenuItem(u.Key);
                        if (ObjectDatabase.InvalidHashes.Contains(u.Value))
                            object1.SetRightLabel("~r~Invalid");
                        _searchMenu.AddItem(object1);
                    }
                    break;
                case ObjectTypes.Vehicle:
                    foreach (var u in ObjectDatabase.VehicleDb.Where(pair => ApplySearchQuery(searchQuery, pair.Key)))
                    {
                        var object1 = new UIMenuItem(u.Key);
                        _searchMenu.AddItem(object1);
                    }
                    break;
                case ObjectTypes.Ped:
                    foreach (var u in ObjectDatabase.PedDb.Where(pair => ApplySearchQuery(searchQuery, pair.Key)))
                    {
                        var object1 = new UIMenuItem(u.Key);
                        _searchMenu.AddItem(object1);
                    }
                    break;
            }
            _searchMenu.RefreshIndex();
        }
예제 #4
0
파일: MapEditor.cs 프로젝트: Guad/MapEditor
 private void RedrawObjectsMenu(ObjectTypes type = ObjectTypes.Prop)
 {
     _objectsMenu.Clear();
     switch (type)
     {
         case ObjectTypes.Prop:
             foreach (var u in ObjectDatabase.MainDb)
             {
                 var object1 = new UIMenuItem(u.Key);
                 if(ObjectDatabase.InvalidHashes.Contains(u.Value))
                     object1.SetRightLabel("~r~Invalid");
                 _objectsMenu.AddItem(object1);
             }
             break;
         case ObjectTypes.Vehicle:
             foreach (var u in ObjectDatabase.VehicleDb)
             {
                 var object1 = new UIMenuItem(u.Key);
                 _objectsMenu.AddItem(object1);
             }
             break;
         case ObjectTypes.Ped:
             foreach (var u in ObjectDatabase.PedDb)
             {
                 var object1 = new UIMenuItem(u.Key);
                 _objectsMenu.AddItem(object1);
             }
             break;
     }
     _objectsMenu.RefreshIndex();
 }
예제 #5
0
파일: MapEditor.cs 프로젝트: Guad/MapEditor
        private void RedrawObjectInfoMenu(Entity ent, bool refreshIndex)
        {
            if(ent == null) return;
            string name = "";

            if (Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, ent.Handle))
            {
                name = ObjectDatabase.MainDb.ContainsValue(ent.Model.Hash) ? ObjectDatabase.MainDb.First(x => x.Value == ent.Model.Hash).Key.ToUpper() : "Unknown Prop";
            }
            if (Function.Call<bool>(Hash.IS_ENTITY_A_VEHICLE, ent.Handle))
                name = ObjectDatabase.VehicleDb.ContainsValue(ent.Model.Hash) ? ObjectDatabase.VehicleDb.First(x => x.Value == ent.Model.Hash).Key.ToUpper() : "Unknown Vehicle";
            if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, ent.Handle))
                name = ObjectDatabase.PedDb.ContainsValue(ent.Model.Hash) ? ObjectDatabase.PedDb.First(x => x.Value == ent.Model.Hash).Key.ToUpper() : "Unknown Ped";

            _objectInfoMenu.Subtitle.Caption = "~b~" + name;
            _objectInfoMenu.Clear();

            var posXitem = new UIMenuListItem(Translation.Translate("Position X"), _possiblePositions, (int)(Math.Round((ent.Position.X * 100) + _possibleRange)));
            var posYitem = new UIMenuListItem(Translation.Translate("Position Y"), _possiblePositions, (int)(Math.Round((ent.Position.Y * 100) + _possibleRange)));
            var posZitem = new UIMenuListItem(Translation.Translate("Position Z"), _possiblePositions, (int)(Math.Round((ent.Position.Z * 100) + _possibleRange)));

            var itemRot = ent.Quaternion.ToEuler();

            var rotXitem = new UIMenuListItem(Translation.Translate("Pitch"), _possibleRoll, (int)Math.Round((itemRot.Y * 100 * -1) + 36000));
            var rotYitem = new UIMenuListItem(Translation.Translate("Roll"), _possibleRoll, (int)Math.Round((itemRot.X * 100) + 36000));
            var rotZitem = new UIMenuListItem(Translation.Translate("Yaw"), _possibleRoll, (int)Math.Round((itemRot.Z * 100) + 36000));

            var dynamic = new UIMenuCheckboxItem(Translation.Translate("Dynamic"), !PropStreamer.StaticProps.Contains(ent.Handle));
            dynamic.CheckboxEvent += (ite, checkd) =>
            {
                if (checkd && PropStreamer.StaticProps.Contains(ent.Handle)) { PropStreamer.StaticProps.Remove(ent.Handle);}
                else if (!checkd && !PropStreamer.StaticProps.Contains(ent.Handle)) PropStreamer.StaticProps.Add(ent.Handle);

                ent.FreezePosition = PropStreamer.StaticProps.Contains(ent.Handle);
            };

            var ident = new UIMenuItem("Identification", "Optional identification for easier access during scripting.");
            if (PropStreamer.Identifications.ContainsKey(ent.Handle))
                ident.SetRightLabel(PropStreamer.Identifications[ent.Handle]);

            ident.Activated += (sender, item) =>
            {
                if (PropStreamer.Identifications.ContainsKey(ent.Handle))
                {
                    var newLabel = Game.GetUserInput(PropStreamer.Identifications[ent.Handle], 20);
                    if (PropStreamer.Identifications.ContainsValue(newLabel))
                    {
                        UI.Notify(Translation.Translate("~r~~h~Map Editor~h~~w~~n~The identification must be unique!"));
                        return;
                    }

                    if (newLabel.Length > 0 && (Regex.IsMatch(newLabel, @"^\d") || newLabel.StartsWith(".") || newLabel.StartsWith(",") || newLabel.StartsWith("\\")))
                    {
                        UI.Notify(Translation.Translate("~r~~h~Map Editor~h~~w~~n~This identification is invalid!"));
                        return;
                    }

                    PropStreamer.Identifications[ent.Handle] = newLabel;
                    ident.SetRightLabel(newLabel);
                }
                else
                {
                    var newLabel = Game.GetUserInput(20);
                    if (PropStreamer.Identifications.ContainsValue(newLabel))
                    {
                        UI.Notify(Translation.Translate("~r~~h~Map Editor~h~~w~~n~The identification must be unique!"));
                        return;
                    }
                    if (newLabel.Length > 0 && (Regex.IsMatch(newLabel, @"^\d") || newLabel.StartsWith(".") || newLabel.StartsWith(",") || newLabel.StartsWith("\\")))
                    {
                        UI.Notify(Translation.Translate("~r~~h~Map Editor~h~~w~~n~This identification is invalid!"));
                        return;
                    }
                    PropStreamer.Identifications.Add(ent.Handle, newLabel);
                    ident.SetRightLabel(newLabel);
                }
            };

            _objectInfoMenu.AddItem(posXitem);
            _objectInfoMenu.AddItem(posYitem);
            _objectInfoMenu.AddItem(posZitem);
            _objectInfoMenu.AddItem(rotXitem);
            _objectInfoMenu.AddItem(rotYitem);
            _objectInfoMenu.AddItem(rotZitem);
            _objectInfoMenu.AddItem(dynamic);
            _objectInfoMenu.AddItem(ident);

            if (Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, ent.Handle))
            {
                var doorItem = new UIMenuCheckboxItem("Door", PropStreamer.Doors.Contains(ent.Handle), Translation.Translate("This option overrides the \"Dynamic\" setting."));
                doorItem.CheckboxEvent += (sender, @checked) =>
                {
                    if (@checked)
                    {
                        PropStreamer.Doors.Add(ent.Handle);
                        Function.Call(Hash.SET_ENTITY_DYNAMIC, ent.Handle, false);
                        ent.FreezePosition = false;
                    }
                    else
                    {
                        PropStreamer.Doors.Remove(ent.Handle);
                        var isDynamic = !PropStreamer.StaticProps.Contains(ent.Handle);
                        Function.Call(Hash.SET_ENTITY_DYNAMIC, ent.Handle, isDynamic);
                        ent.FreezePosition = !isDynamic;
                    }
                };
                _objectInfoMenu.AddItem(doorItem);
            }

            if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, ent.Handle))
            {
                List<dynamic> actions = new List<dynamic> {"None", "Any - Walk", "Any - Warp", "Wander"};
                actions.AddRange(ObjectDatabase.ScrenarioDatabase.Keys);
                var scenarioItem = new UIMenuListItem(Translation.Translate("Idle Action"), actions, actions.IndexOf(PropStreamer.ActiveScenarios[ent.Handle]));
                scenarioItem.OnListChanged += (item, index) =>
                {
                    PropStreamer.ActiveScenarios[ent.Handle] = item.IndexToItem(index).ToString();
                    _changesMade++;
                };
                scenarioItem.Activated += (item, index) =>
                {
                    if (PropStreamer.ActiveScenarios[ent.Handle] == "None")
                    {
                        ((Ped)ent).Task.ClearAll();
                        return;
                    }
                    if (PropStreamer.ActiveScenarios[ent.Handle] == "Any - Walk" || PropStreamer.ActiveScenarios[ent.Handle] == "Any")
                    {
                        Function.Call(Hash.TASK_USE_NEAREST_SCENARIO_TO_COORD, ent.Handle, ent.Position.X, ent.Position.Y, ent.Position.Z, 100f, -1);
                        return;
                    }
                    if (PropStreamer.ActiveScenarios[ent.Handle] == "Any - Warp")
                    {
                        Function.Call(Hash.TASK_USE_NEAREST_SCENARIO_TO_COORD_WARP, ent.Handle, ent.Position.X, ent.Position.Y, ent.Position.Z, 100f, -1);
                        return;
                    }
                    if (PropStreamer.ActiveScenarios[ent.Handle] == "Wander")
                    {
                        Function.Call(Hash.TASK_WANDER_STANDARD, ent.Handle, 0, 0);
                        return;
                    }
                    string scenario = ObjectDatabase.ScrenarioDatabase[PropStreamer.ActiveScenarios[ent.Handle]];
                    if (Function.Call<bool>(Hash.IS_PED_USING_SCENARIO, ent.Handle, scenario))
                        ((Ped) ent).Task.ClearAll();
                    else
                    {
                        Function.Call(Hash.TASK_START_SCENARIO_IN_PLACE, ent.Handle, scenario, 0, 0);
                    }
                };
                _objectInfoMenu.AddItem(scenarioItem);

                List<dynamic> rels = new List<dynamic> { "Ballas", "Grove"};
                Enum.GetNames(typeof(Relationship)).ToList().ForEach(rel => rels.Add(rel));
                var relItem = new UIMenuListItem(Translation.Translate("Relationship"), rels, rels.IndexOf(PropStreamer.ActiveRelationships[ent.Handle]));
                relItem.OnListChanged += (item, index) =>
                {
                    PropStreamer.ActiveRelationships[ent.Handle] = item.IndexToItem(index).ToString();
                    _changesMade++;
                };
                relItem.Activated += (item, index) =>
                {
                    ObjectDatabase.SetPedRelationshipGroup((Ped) ent, PropStreamer.ActiveRelationships[ent.Handle]);
                };
                _objectInfoMenu.AddItem(relItem);

                List<dynamic> weps = new List<dynamic>();
                Enum.GetNames(typeof(WeaponHash)).ToList().ForEach(rel => weps.Add(rel));
                var wepItem = new UIMenuListItem(Translation.Translate("Weapon"), weps, weps.IndexOf(PropStreamer.ActiveWeapons[ent.Handle].ToString()));
                wepItem.OnListChanged += (item, index) =>
                {
                    PropStreamer.ActiveWeapons[ent.Handle] = Enum.Parse(typeof(WeaponHash), item.IndexToItem(index).ToString());
                    _changesMade++;
                };
                wepItem.Activated += (item, index) =>
                {
                    ((Ped)ent).Weapons.RemoveAll();
                    if(PropStreamer.ActiveWeapons[ent.Handle] == WeaponHash.Unarmed) return;
                    ((Ped) ent).Weapons.Give(PropStreamer.ActiveWeapons[ent.Handle], 999, true, true);
                };
                _objectInfoMenu.AddItem(wepItem);
            }

            if (Function.Call<bool>(Hash.IS_ENTITY_A_VEHICLE, ent.Handle))
            {
                var sirentBool = new UIMenuCheckboxItem(Translation.Translate("Siren"), PropStreamer.ActiveSirens.Contains(ent.Handle));
                sirentBool.CheckboxEvent += (item, check) =>
                {
                    if (check && !PropStreamer.ActiveSirens.Contains(ent.Handle)) PropStreamer.ActiveSirens.Add(ent.Handle);
                    else if (!check && PropStreamer.ActiveSirens.Contains(ent.Handle)) PropStreamer.ActiveSirens.Remove(ent.Handle);
                    ((Vehicle) ent).SirenActive = check;
                    _changesMade++;
                };
                _objectInfoMenu.AddItem(sirentBool);
            }

            if (PropStreamer.IsPickup(ent.Handle))
            {
                var pickup = PropStreamer.GetPickup(ent.Handle);
                var amountList = new UIMenuItem(Translation.Translate("Amount"));
                amountList.SetRightLabel(pickup.Amount.ToString());
                amountList.Activated += (sender, item) =>
                {
                    string playerInput = Game.GetUserInput(10);
                    int newValue;
                    if (!int.TryParse(playerInput, out newValue) || newValue < -1)
                    {
                        UI.Notify("~r~~h~Map Editor~h~~n~~w~" +
                                  Translation.Translate("Input was not in the correct format."));
                        return;
                    }
                    pickup.SetAmount(newValue);
                    amountList.SetRightLabel(pickup.Amount.ToString());
                    _selectedProp = new Prop(pickup.ObjectHandle);
                    if (_settings.SnapCameraToSelectedObject)
                        _mainCamera.PointAt(_selectedProp);
                };
                _objectInfoMenu.AddItem(amountList);

                var pickupTypesList =
                    Enum.GetValues(typeof (ObjectDatabase.PickupHash)).Cast<ObjectDatabase.PickupHash>().ToList();
                var itemIndex = pickupTypesList.IndexOf((ObjectDatabase.PickupHash) pickup.PickupHash);

                var pickupTypeItem = new UIMenuListItem("Type", pickupTypesList.Select(s => (dynamic)(s.ToString())).ToList(), itemIndex);
                pickupTypeItem.OnListChanged += (sender, index) =>
                {
                    pickup.SetPickupHash((int)pickupTypesList[index]);
                    _selectedProp = new Prop(pickup.ObjectHandle);
                    if (_settings.SnapCameraToSelectedObject)
                        _mainCamera.PointAt(_selectedProp);
                };
                _objectInfoMenu.AddItem(pickupTypeItem);

                var timeoutTime = new UIMenuItem("Regeneration Time");
                timeoutTime.SetRightLabel(pickup.Timeout.ToString());

                timeoutTime.Activated += (sender, item) =>
                {
                    string playerInput = Game.GetUserInput(10);
                    int newValue;
                    if (!int.TryParse(playerInput, out newValue) || newValue < 0)
                    {
                        UI.Notify("~r~~h~Map Editor~h~~n~~w~" +
                                  Translation.Translate("Input was not in the correct format."));
                        return;
                    }
                    pickup.Timeout = newValue;
                    timeoutTime.SetRightLabel((newValue).ToString());
                };

                _objectInfoMenu.AddItem(timeoutTime);
            }

            posXitem.Activated +=
                (sender, item) =>
                    SetObjectVector(ent, posXitem, GetSafeFloat(Game.GetUserInput(ent.Position.X.ToString(CultureInfo.InvariantCulture), 10), ent.Position.X), ent.Position.Y, ent.Position.Z);
            posYitem.Activated +=
                (sender, item) =>
                    SetObjectVector(ent, posYitem, ent.Position.X, GetSafeFloat(Game.GetUserInput(ent.Position.Y.ToString(CultureInfo.InvariantCulture), 10), ent.Position.Y), ent.Position.Z);
            posZitem.Activated +=
                (sender, item) =>
                    SetObjectVector(ent, posZitem, ent.Position.X, ent.Position.Y, GetSafeFloat(Game.GetUserInput(ent.Position.Z.ToString(CultureInfo.InvariantCulture), 10), ent.Position.Z));

            posXitem.OnListChanged += (item, index) =>
            {
                if (!IsProp(ent) )
                    ent.Position = new Vector3((float) item.IndexToItem(index), ent.Position.Y, ent.Position.Z);
                else
                    ent.PositionNoOffset = new Vector3((float)item.IndexToItem(index), ent.Position.Y, ent.Position.Z);

                if (PropStreamer.IsPickup(ent.Handle))
                {
                    PropStreamer.GetPickup(ent.Handle).UpdatePos();
                }

                _changesMade++;
            };
            posYitem.OnListChanged += (item, index) =>
            {
                if (!IsProp(ent))
                    ent.Position = new Vector3(ent.Position.X, (float) item.IndexToItem(index), ent.Position.Z);
                else
                    ent.PositionNoOffset = new Vector3(ent.Position.X, (float)item.IndexToItem(index), ent.Position.Z);

                if (PropStreamer.IsPickup(ent.Handle))
                {
                    PropStreamer.GetPickup(ent.Handle).UpdatePos();
                }
                _changesMade++;
            };
            posZitem.OnListChanged += (item, index) =>
            {
                if (!IsProp(ent) )
                    ent.Position = new Vector3(ent.Position.X, ent.Position.Y, (float)item.IndexToItem(index));
                else
                    ent.PositionNoOffset = new Vector3(ent.Position.X, ent.Position.Y, (float)item.IndexToItem(index));

                if (PropStreamer.IsPickup(ent.Handle))
                {
                    PropStreamer.GetPickup(ent.Handle).UpdatePos();
                }
                _changesMade++;
            };

            rotXitem.Activated +=
                (sender, item) =>
                {
                    var rot = ent.Quaternion.ToEuler();
                    SetObjectRotation(ent,
                        GetSafeFloat(Game.GetUserInput(rot.X.ToString(CultureInfo.InvariantCulture).Limit(10), 10),
                            rot.X), rot.Y, rot.Z);
                };
            rotYitem.Activated +=
                (sender, item) =>
                {
                    var rot = ent.Quaternion.ToEuler();
                    SetObjectRotation(ent, rot.X,
                        GetSafeFloat(Game.GetUserInput(rot.Y.ToString(CultureInfo.InvariantCulture).Limit(10), 10),
                            rot.Y), rot.Z);
                };
            rotZitem.Activated +=
                (sender, item) =>
                {
                    var rot = ent.Quaternion.ToEuler();
                    SetObjectRotation(ent, rot.X, rot.Y,
                        GetSafeFloat(Game.GetUserInput(rot.Z.ToString(CultureInfo.InvariantCulture).Limit(10), 10),
                            rot.Z));
                };

            rotYitem.OnListChanged += (item, index) =>
            {
                var change = (float)item.IndexToItem(index);
                ent.Quaternion = new Vector3(change, ent.Rotation.Y, ent.Rotation.Z).ToQuaternion();
                _changesMade++;
            };

            rotZitem.OnListChanged += (item, index) =>
            {
                var change = (float) item.IndexToItem(index);
                ent.Quaternion = new Vector3(ent.Rotation.X, ent.Rotation.Y, change).ToQuaternion();
                _changesMade++;
            };

            rotXitem.OnListChanged += (item, index) =>
            {
                var change = (float)item.IndexToItem(index);
                ent.Quaternion = new Vector3(ent.Rotation.X, change, ent.Rotation.Z).ToQuaternion();
                _changesMade++;
            };

            if (refreshIndex)
                _objectInfoMenu.RefreshIndex();
        }
예제 #6
0
파일: MapEditor.cs 프로젝트: Guad/MapEditor
        private void RedrawMetadataMenu()
        {
            _metadataMenu.Clear();

            var saveItem = new UIMenuItem(Translation.Translate("Save Map"));

            saveItem.Activated += (sender, item) =>
            {
                SaveMap(PropStreamer.CurrentMapMetadata.Filename, MapSerializer.Format.NormalXml);
                _metadataMenu.Visible = false;
            };

            if (string.IsNullOrWhiteSpace(PropStreamer.CurrentMapMetadata.Filename))
            {
                saveItem.Enabled = false;
            }

            {
                var filenameItem = new UIMenuItem(Translation.Translate("File Path"));

                if (string.IsNullOrWhiteSpace(PropStreamer.CurrentMapMetadata.Filename))
                    filenameItem.SetRightBadge(UIMenuItem.BadgeStyle.Alert);
                else
                    filenameItem.SetRightLabel(GetSafeShortReverseString(PropStreamer.CurrentMapMetadata.Filename, 20));

                filenameItem.Activated += (sender, item) =>
                {
                    var newName = Game.GetUserInput(PropStreamer.CurrentMapMetadata.Filename ?? "", 255);
                    if (string.IsNullOrWhiteSpace(newName)) return;
                    if (!newName.EndsWith(".xml")) newName += ".xml";
                    PropStreamer.CurrentMapMetadata.Filename = newName;
                    saveItem.Enabled = true;

                    filenameItem.SetRightBadge(UIMenuItem.BadgeStyle.None);
                    filenameItem.SetRightLabel(GetSafeShortReverseString(newName, 20));
                };

                _metadataMenu.AddItem(filenameItem);
            }

            {
                var filenameItem = new UIMenuItem(Translation.Translate("Map Name"));

                if (!string.IsNullOrWhiteSpace(PropStreamer.CurrentMapMetadata.Name))
                    filenameItem.SetRightLabel(GetSafeShortString(PropStreamer.CurrentMapMetadata.Name, 20));

                filenameItem.Activated += (sender, item) =>
                {
                    var newName = Game.GetUserInput(PropStreamer.CurrentMapMetadata.Name ?? "", 30);
                    if (string.IsNullOrWhiteSpace(newName)) return;
                    PropStreamer.CurrentMapMetadata.Name = newName;

                    filenameItem.SetRightLabel(GetSafeShortString(newName, 20));
                };

                _metadataMenu.AddItem(filenameItem);
            }

            {
                var filenameItem = new UIMenuItem(Translation.Translate("Author"));

                if (!string.IsNullOrWhiteSpace(PropStreamer.CurrentMapMetadata.Creator))
                    filenameItem.SetRightLabel(GetSafeShortString(PropStreamer.CurrentMapMetadata.Creator, 20));

                filenameItem.Activated += (sender, item) =>
                {
                    var newName = Game.GetUserInput(PropStreamer.CurrentMapMetadata.Creator ?? "", 30);
                    if (string.IsNullOrWhiteSpace(newName)) return;
                    PropStreamer.CurrentMapMetadata.Creator = newName;

                    filenameItem.SetRightLabel(GetSafeShortString(newName, 20));
                };

                _metadataMenu.AddItem(filenameItem);
            }

            {
                var filenameItem = new UIMenuItem(Translation.Translate("Description"));

                if (!string.IsNullOrWhiteSpace(PropStreamer.CurrentMapMetadata.Description))
                    filenameItem.Description = PropStreamer.CurrentMapMetadata.Description;

                filenameItem.Activated += (sender, item) =>
                {
                    var newName = Game.GetUserInput(PropStreamer.CurrentMapMetadata.Description ?? "", 255);
                    if (string.IsNullOrWhiteSpace(newName)) return;
                    PropStreamer.CurrentMapMetadata.Description = newName;
                    filenameItem.Description = newName;
                };

                _metadataMenu.AddItem(filenameItem);
            }

            _metadataMenu.AddItem(saveItem);
            _metadataMenu.RefreshIndex();

            if (saveItem.Enabled)
                _metadataMenu.CurrentSelection = 4; // TODO: Change this when adding items.
        }