示例#1
0
 /// <summary>
 /// Change player's cash
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void ChangeCash(MenuItem sender)
 {
     if (sender != null && sender.Data != null && sender.Data.GetType() == typeof(int))
     {
         int amount = (int)sender.Data;
         if (amount < 0)
         {
             if (Math.Abs(amount) >= Game.Player.Money)
             {
                 Game.Player.Money = 0;
             }
             else
             {
                 Game.Player.Money += amount;
             }
         }
         else
         {
             if (amount >= int.MaxValue - Game.Player.Money)
             {
                 Game.Player.Money = int.MaxValue;
             }
             else
             {
                 Game.Player.Money += amount;
             }
         }
     }
 }
示例#2
0
 /// <summary>
 /// Sets freeze
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetFreeze(MenuItem sender)
 {
     Freeze = sender.On;
     Config.DoAutoSave();
     Function.Call(Hash.CLEAR_OVERRIDE_WEATHER);
     Function.Call(Hash.CLEAR_WEATHER_TYPE_PERSIST);
     Function.Call(Hash.CLEAR_TIMECYCLE_MODIFIER);
 }
示例#3
0
            /// <summary>
            /// Cleans current vehicle
            /// </summary>
            /// <param name="sender">Source menu item</param>
            public static void Clean(MenuItem sender)
            {
                if (!CheckInVehicle()) return;

                Function.Call(Hash.SET_VEHICLE_DIRT_LEVEL, Game.Player.Character.CurrentVehicle.Handle, 0);

                Utils.ShowNotificationAboveMap(GlobalConst.Message.VEHICLE_CLEANED);
            }
示例#4
0
 /// <summary>
 /// Sets weather
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetWeather(MenuItem sender)
 {
     WeatherData wd = (sender.Data as WeatherData);
     Function.Call(Hash.CLEAR_OVERRIDE_WEATHER);
     Function.Call(Hash.CLEAR_WEATHER_TYPE_PERSIST);
     Function.Call(Hash.CLEAR_TIMECYCLE_MODIFIER);
     Function.Call(Hash.SET_WEATHER_TYPE_NOW, wd.InternalName);
     Function.Call(Hash.CLEAR_TIMECYCLE_MODIFIER);
     _weather = wd.InternalName;
     Utils.ShowNotificationAboveMap(string.Format(GlobalConst.Message.WEATHER_SET, wd.Name));
 }
示例#5
0
        /// <summary>
        /// Adds a menu item into menu
        /// </summary>
        /// <param name="parent">Parent menu</param>
        /// <param name="text">Text</param>
        /// <param name="toggle">Is toggle</param>
        /// <param name="on">Is on</param>
        /// <param name="subMenu">Sub menu</param>
        /// <param name="activateEventHandler">Activated event handler</param>
        /// <param name="highlightedEventHandler">Highlighted event handler</param>
        /// <param name="preActivateEventHandler">Pre-activated event handler</param>
        public static MenuItem AddMenuItem(Menu parent, string text, bool toggle = false, bool on = false, Menu subMenu = null, MenuItemEventHandler activateEventHandler = null, MenuItemEventHandler preActivateEventHandler = null, MenuItemEventHandler highlightedEventHandler = null, object data = null)
        {
            MenuItem mi = new MenuItem()
            {
                Text = text,
                IsToggle = toggle,
                On = on,
                SubMenu = subMenu
            };
            if (activateEventHandler != null) mi.Activated += activateEventHandler;
            if (preActivateEventHandler != null) mi.PreActivated += preActivateEventHandler;
            if (highlightedEventHandler != null) mi.Highlighted += highlightedEventHandler;
            mi.Data = data;
            parent.Add(mi);

            return mi;
        }
示例#6
0
 /// <summary>
 /// Creates an instance of a menu and adds initial items.
 /// </summary>
 /// <param name="title">Title of menu</param>
 /// <param name="location">Location of the menu</param>
 /// <param name="items">Menu items</param>
 public Menu(string title, Point location, MenuItem[] items)
 {
     _items = new List<MenuItem>(items);
     Title = title;
     Location = location;
 }
示例#7
0
 /// <summary>
 /// Creates an instance of menu and set initial values.
 /// </summary>
 /// <param name="title">Title of menu</param>
 /// <param name="location">Location of the menu</param>
 /// <param name="width">Width of the menu in pixel</param>
 /// <param name="itemHeight">Item height of the menu in pixel</param>
 /// <param name="screenWidth">Screen width in pixel</param>
 /// <param name="screenHeight">Screen height in pixel</param>
 /// <param name="itemPerPage">Item count per page</param>
 /// <param name="items">Menu items</param>
 public Menu(string title, Point location, int width, int itemHeight, int screenWidth, int screenHeight, int itemPerPage, MenuItem[] items)
 {
     Title = title;
     _width = width;
     _itemHeight = itemHeight;
     _screenHeight = screenHeight;
     _screenWidth = screenWidth;
     _itemPerPage = itemPerPage;
     _items = new List<MenuItem>(items);
     Location = location;
 }
示例#8
0
 /// <summary>
 /// Set skin to random drawable and texture
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void RandomSkin(MenuItem sender)
 {
     MenuStorage.Menus.Players.MSPs.Skin.Clear();
     for (int category = 0; category < SkinPropUtils.SKIN_CATEGORY_COUNT; category++)
     {
         List<SkinPropDetail> list = new List<SkinPropDetail>();
         int drawableCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS, Game.Player.Character.Handle, category);
         int textureCount = 0;
         if (drawableCount == 1)
         {
             textureCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_TEXTURE_VARIATIONS, Game.Player.Character.Handle, category, 0);
         }
         if (drawableCount > 1 || textureCount > 1)
         {
             for (int drawableIndex = 0; drawableIndex < drawableCount; drawableIndex++)
             {
                 textureCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_TEXTURE_VARIATIONS, Game.Player.Character.Handle, category, drawableIndex);
                 for (int textureIndex = 0; textureIndex < textureCount; textureIndex++)
                 {
                     list.Add(new SkinPropDetail() { Category = category, Drawable = drawableIndex, Texture = textureIndex });
                 }
             }
             if (list.Count > 0)
             {
                 SkinPropDetail detail = list[(new Random()).Next(list.Count)];
                 Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, detail.Category, detail.Drawable, detail.Texture, 0);
                 ChosenDrawables[detail.Category] = detail.Drawable;
                 ChosenTextures[detail.Category][detail.Drawable] = detail.Texture;
             }
         }
     }
     Script.Wait(SET_SKIN_WAIT_TIME);
     Utils.ShowNotificationAboveMap(GlobalConst.Message.PLAYER_RANDOM_SKIN);
 }
示例#9
0
 /// <summary>
 /// Creates an instance of a menu and adds initial items.
 /// </summary>
 /// <param name="title">Title of menu</param>
 /// <param name="x">X position of the menu</param>
 /// <param name="y">Y position of the menu</param>
 /// <param name="items">Menu items</param>
 public Menu(string title, int x, int y, MenuItem[] items)
     : this(title, new Point(x, y), items)
 {
 }
示例#10
0
 /// <summary>
 /// Set to Trevor
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetToTrevor(MenuItem sender)
 {
     SetModel(ModelStorage.MODEL_TREVOR);
 }
示例#11
0
 /// <summary>
 /// Set to Michael
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetToMichael(MenuItem sender)
 {
     SetModel(ModelStorage.MODEL_MICHAEL);
 }
示例#12
0
 /// <summary>
 /// Sets random cops
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetRandomCops(MenuItem sender)
 {
     RandomCops = sender.On;
     Config.DoAutoSave();
 }
示例#13
0
 /// <summary>
 /// Removes the specified menu item
 /// </summary>
 /// <param name="menuItem">Menu item object</param>
 public void Remove(MenuItem menuItem)
 {
     if (_items.Contains(menuItem))
     {
         _items.Remove(menuItem);
         EnsurePage();
         EnsureSelectedIndexInCurrentPage();
     }
 }
示例#14
0
 /// <summary>
 /// Set skin to random drawable and texture
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void RandomProps(MenuItem sender)
 {
     MenuStorage.Menus.Players.MSPs.Prop.Clear();
     for (int category = 0; category < SkinPropUtils.PROP_CATEGORY_COUNT; category++)
     {
         List<SkinPropDetail> list = new List<SkinPropDetail>();
         int drawableCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS, Game.Player.Character.Handle, category);
         if (drawableCount > 0)
         {
             list.Add(new SkinPropDetail() { Category = category, Drawable = -1 });
             for (int drawableIndex = 0; drawableIndex < drawableCount; drawableIndex++)
             {
                 int textureCount = Function.Call<int>((Hash)0xA6E7F1CEB523E171, Game.Player.Character.Handle, category, drawableIndex);
                 for (int textureIndex = 0; textureIndex < textureCount; textureIndex++)
                 {
                     list.Add(new SkinPropDetail() { Category = category, Drawable = drawableIndex, Texture = textureIndex });
                 }
             }
             if (list.Count > 0)
             {
                 SkinPropDetail detailRandom = list[(new Random()).Next(list.Count)];
                 Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, detailRandom.Category, detailRandom.Drawable, detailRandom.Texture, 0);
             }
         }
     }
     Script.Wait(SET_PROP_WAIT_TIME);
     Utils.ShowNotificationAboveMap(GlobalConst.Message.PLAYER_RANDOM_PROPS);
 }
示例#15
0
 /// <summary>
 /// Set prop drawable
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetPropDrawable(MenuItem sender)
 {
     SkinPropDetail detail = (SkinPropDetail)sender.Data;
     int currentProp = Function.Call<int>(Hash.GET_PED_PROP_INDEX, Game.Player.Character.Handle, detail.Category);
     if (currentProp != detail.Drawable)
     {
         Function.Call(Hash.CLEAR_PED_PROP, Game.Player.Character.Handle, detail.Category);
         if (detail.Drawable != -1)
         {
             Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, detail.Category, detail.Drawable, ChosenTextures[detail.Category][detail.Drawable], 0);
             Script.Wait(SET_PROP_WAIT_TIME);
         }
         ChosenDrawables[detail.Category] = detail.Drawable + 1;
     }
 }
示例#16
0
 /// <summary>
 /// Generates the prop selector menu
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void GeneratePropSelectorMenu(MenuItem sender)
 {
     SkinPropDetail detail = (SkinPropDetail)sender.Data;
     MenuStorage.Menus.Players.MSPs.Props.Drawable.Clear();
     for (int i = -1; i < detail.DrawableCount; i++)
     {
         MenuItem mi = null;
         int textureCount = 0;
         if (i == -1)
         {
             mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Props.Drawable, string.Format(MenuText.Player.ModelSkinProps.PropCategories.PropsSelector.I01_NOTHING));
         }
         else
         {
             textureCount = Function.Call<int>((Hash)0xA6E7F1CEB523E171, Game.Player.Character.Handle, detail.Category, i);
             mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Props.Drawable, string.Format(MenuText.Player.ModelSkinProps.PropCategories.PropsSelector.I02_PROP, i, textureCount),
                 false, false, (textureCount > 1 ? MenuStorage.Menus.Players.MSPs.Props.Texture : null), GeneratePropTextureSelectorMenu);
         }
         mi.Data = new SkinPropDetail() { Drawable = i, Category = detail.Category, TextureCount = textureCount };
         mi.Highlighted += SetPropDrawable;
     }
     MenuStorage.Menus.Players.MSPs.Props.Drawable.SelectedIndex = ChosenDrawables[detail.Category];
 }
示例#17
0
 /// <summary>
 /// Clear all props
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void ClearProps(MenuItem sender)
 {
     Function.Call(Hash.CLEAR_ALL_PED_PROPS, Game.Player.Character.Handle);
 }
示例#18
0
 /// <summary>
 /// Sets to specified Model
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetToModel(MenuItem sender)
 {
     if (sender.Data == null) return;
     SetModel(sender.Data as ModelData);
 }
示例#19
0
 /// <summary>
 /// Adds a menu item into this menu.
 /// </summary>
 /// <param name="item">Menu item</param>
 public void Add(MenuItem item)
 {
     if (item != null) _items.Add(item);
     item.Index = _items.Count - 1;
     item.Parent = this;
     EnsurePage();
     EnsureSelectedIndexInCurrentPage();
 }
示例#20
0
 /// <summary>
 /// Sets restricted zones
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetRestrictedZones(MenuItem sender)
 {
     RestrictedZones = sender.On;
     Config.DoAutoSave();
 }
示例#21
0
 /// <summary>
 /// Adds many menu items into this menu.
 /// </summary>
 /// <param name="items">Menu items</param>
 public void Add(MenuItem[] items)
 {
     _items.AddRange(items);
     for (int i = 0; i < _items.Count; i++)
     {
         _items[i].Index = i;
     }
     EnsurePage();
     EnsureSelectedIndexInCurrentPage();
 }
示例#22
0
 /// <summary>
 /// Sets moon gravity
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetMoonGravity(MenuItem sender)
 {
     MoonGravity = sender.On;
     Config.DoAutoSave();
 }
示例#23
0
 /// <summary>
 /// Set prop drawable texture
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetPropDrawableTexture(MenuItem sender)
 {
     SkinPropDetail detail = (SkinPropDetail)sender.Data;
     int currentProp = Function.Call<int>(Hash.GET_PED_PROP_INDEX, Game.Player.Character.Handle, detail.Category);
     int currentTexture = Function.Call<int>(Hash.GET_PED_PROP_TEXTURE_INDEX, Game.Player.Character.Handle, detail.Category, currentProp);
     if (currentProp != detail.Drawable || currentTexture != detail.Texture)
     {
         Function.Call(Hash.SET_PED_PROP_INDEX, Game.Player.Character.Handle, detail.Category, detail.Drawable, detail.Texture, 0);
         ChosenDrawables[detail.Category] = detail.Drawable + 1;
         ChosenTextures[detail.Category][detail.Drawable] = detail.Texture;
         Script.Wait(SET_PROP_WAIT_TIME);
     }
 }
示例#24
0
 /// <summary>
 /// Sets to a random model
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetToRandomModel(MenuItem sender)
 {
     ModelData Model = null;
     Random rnd = new Random();
     if (rnd.NextDouble() < (double)ModelStorage.MODEL_ANIMALS.Length / ModelStorage.MODEL_NPCS.Length)
     {
         Model = ModelStorage.MODEL_ANIMALS[rnd.Next(ModelStorage.MODEL_ANIMALS.Length)];
     }
     else
     {
         Model = ModelStorage.MODEL_NPCS[rnd.Next(ModelStorage.MODEL_NPCS.Length)];
     }
     SetModel(Model);
 }
示例#25
0
 /// <summary>
 /// Sets random trains
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetRandomTrains(MenuItem sender)
 {
     RandomTrains = sender.On;
     Config.DoAutoSave();
     Function.Call(Hash.SET_RANDOM_TRAINS, sender.On);
 }
示例#26
0
 /// <summary>
 /// Generates the skin categories menu
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void GenerateSkinCategoriesMenu(MenuItem sender)
 {
     GetCurrentSkinSet();
     MenuStorage.Menus.Players.MSPs.Skin.Clear();
     int count = 0;
     for (int i = 0; i < SkinPropUtils.SKIN_CATEGORY_COUNT; i++)
     {
         int drawableCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS, Game.Player.Character.Handle, i);
         int textureCount = 0;
         if (drawableCount == 1)
         {
             textureCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_TEXTURE_VARIATIONS, Game.Player.Character.Handle, i, 0);
         }
         if (drawableCount > 1 || textureCount > 1)
         {
             count++;
             MenuItem mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Skin, string.Format(MenuText.Player.ModelSkinProps.SkinCategories.I01_SLOT, i + 1,
                 SkinPropUtils.GetSkinCategoryDesc(i), drawableCount), false, false, MenuStorage.Menus.Players.MSPs.Skins.Drawable, GenerateSkinDrawableSelectorMenu);
             mi.Data = new SkinPropDetail() { Category = i, DrawableCount = drawableCount };
         }
     }
     if (count == 0)
     {
         MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Skin, MenuText.Player.ModelSkinProps.SkinCategories.I02_NO_AVAILABLE_SLOT);
     }
 }
示例#27
0
 /// <summary>
 /// Sets garbage trucks
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetGarbageTrucks(MenuItem sender)
 {
     GarbageTrucks = sender.On;
     Config.DoAutoSave();
     Function.Call(Hash.SET_GARBAGE_TRUCKS, sender.On);
 }
示例#28
0
 /// <summary>
 /// Generates the skin drawable selector menu
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void GenerateSkinDrawableSelectorMenu(MenuItem sender)
 {
     SkinPropDetail detail = (SkinPropDetail)sender.Data;
     MenuStorage.Menus.Players.MSPs.Skins.Drawable.Clear();
     for (int i = 0; i < detail.DrawableCount; i++)
     {
         int textureCount = Function.Call<int>(Hash.GET_NUMBER_OF_PED_TEXTURE_VARIATIONS, Game.Player.Character.Handle, detail.Category, i);
         MenuItem mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Skins.Drawable, string.Format(MenuText.Player.ModelSkinProps.SkinCategories.DrawableSelector.I01_DRAWABLE, i, textureCount),
             false, false, (textureCount > 1 ? MenuStorage.Menus.Players.MSPs.Skins.Texture : null), GenerateSkinTextureSelectorMenu);
         mi.Data = new SkinPropDetail() { Drawable = i, Category = detail.Category, TextureCount = textureCount };
         mi.Highlighted += SetSkinDrawable;
     }
     MenuStorage.Menus.Players.MSPs.Skins.Drawable.SelectedIndex = ChosenDrawables[detail.Category];
 }
示例#29
0
 /// <summary>
 /// Sets random boats
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void SetRandomBoats(MenuItem sender)
 {
     RandomBoats = sender.On;
     Config.DoAutoSave();
     Function.Call(Hash.SET_RANDOM_BOATS, sender.On);
 }
示例#30
0
 /// <summary>
 /// Generates the skin texture selector menu
 /// </summary>
 /// <param name="sender">Source menu item</param>
 public static void GenerateSkinTextureSelectorMenu(MenuItem sender)
 {
     SkinPropDetail detail = (SkinPropDetail)sender.Data;
     MenuStorage.Menus.Players.MSPs.Skins.Texture.Clear();
     for (int i = 0; i < detail.TextureCount; i++)
     {
         MenuItem mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Players.MSPs.Skins.Texture, string.Format(MenuText.Player.ModelSkinProps.SkinCategories.DrawableSelector.TextureSelector.I01_TEXTURE, i));
         mi.Data = new SkinPropDetail() { Drawable = detail.Drawable, Texture = i, Category = detail.Category };
         mi.Highlighted += SetSkinDrawableTexture;
     }
     MenuStorage.Menus.Players.MSPs.Skins.Texture.SelectedIndex = ChosenTextures[detail.Category][detail.Drawable];
 }