Esempio n. 1
0
        public BanMenu(Client client, PlayerMenu parent) : base($"Ban {parent.Player.Name}", parent)
        {
            var reason = new MenuItem(client, this, "Ban Reason")
            {
                SubLabel = "None Specified"
            };

            reason.Activate += async() => {
                _reason = await UiHelper.PromptTextInput("", controller : client.Menu);

                reason.SubLabel = _reason.Length > 16 ? $"{_reason.Substring( 0, 16 )}..." : _reason;
            };
            Add(reason);

            var length = new MenuItemSpinnerInt(client, this, "Ban Duration", 60, 1, 8192, 1, true);

            Add(length);

            var lengthUnit = new MenuItemSpinnerList <string>(client, this, "Ban Duration (Units)", Units.Keys.ToList(), 0, true);

            Add(lengthUnit);

            var perma = new MenuItemCheckbox(client, this, "Permanent Ban");

            perma.Activate += () => {
                _perma = !_perma;
                lengthUnit.IsVisible = length.IsVisible = _perma;
                return(Task.FromResult(0));
            };
            Add(perma);

            var submit = new MenuItem(client, this, "Execute Ban");

            submit.Activate += () => {
                var time = _perma ? int.MinValue : Units.ElementAt((int)lengthUnit.Value).Value *(int)length.Value;
                client.Menu.CurrentMenu = parent.Parent;
                parent.Ban(_reason, time);
                return(Task.FromResult(0));
            };
            Add(submit);
        }
Esempio n. 2
0
        public VehicleMenu(Client client, Menu parent) : base("Vehicle Menu", parent)
        {
            Add(new MenuItemSubMenu(client, this, new VehicleSpawnMenu(client, this), "Spawn Vehicle"));

            var invincible = new MenuItemCheckbox(client, this, "Invincible", IsInvincible)
            {
                IsChecked = () => IsInvincible
            };

            invincible.Activate += () => {
                IsInvincible = !IsInvincible;
                return(Task.FromResult(0));
            };
            Add(invincible);

            var invisible = new MenuItemCheckbox(client, this, "Invisible", IsInvisible)
            {
                IsChecked = () => IsInvisible
            };

            invisible.Activate += () => {
                IsInvisible = !IsInvisible;
                return(Task.FromResult(0));
            };
            Add(invisible);

            var vehicleColors = new List <VehicleColor>();

            foreach (VehicleColor color in Enum.GetValues(typeof(VehicleColor)))
            {
                vehicleColors.Add(color);
            }

            var primary = new MenuItemSpinnerList <VehicleColor>(client, this, "Primary Color",
                                                                 new List <VehicleColor>(vehicleColors), 0, true);

            primary.ValueUpdate += (idx) => {
                var color = primary.Data.ElementAt((int)idx);
                if (Game.PlayerPed.CurrentVehicle != null)
                {
                    Game.PlayerPed.CurrentVehicle.Mods.PrimaryColor = color;
                }
                return(idx);
            };
            Add(primary);

            var secondary = new MenuItemSpinnerList <VehicleColor>(client, this, "Secondary Color",
                                                                   new List <VehicleColor>(vehicleColors), 0, true);

            secondary.ValueUpdate += (idx) => {
                var color = secondary.Data.ElementAt((int)idx);
                if (Game.PlayerPed.CurrentVehicle != null)
                {
                    Game.PlayerPed.CurrentVehicle.Mods.SecondaryColor = color;
                }
                return(idx);
            };
            Add(secondary);

            var pearl = new MenuItemSpinnerList <VehicleColor>(client, this, "Pearlescent Color",
                                                               new List <VehicleColor>(vehicleColors), 0, true);

            pearl.ValueUpdate += (idx) => {
                var color = pearl.Data.ElementAt((int)idx);
                if (Game.PlayerPed.CurrentVehicle != null)
                {
                    Game.PlayerPed.CurrentVehicle.Mods.PearlescentColor = color;
                }
                return(idx);
            };
            Add(pearl);

            var license = new MenuItem(client, this, "License Plate");

            license.Activate += async() => {
                var text = await UiHelper.PromptTextInput(Game.PlayerPed.CurrentVehicle?.Mods.LicensePlate, 8, client.Menu);

                if (Game.PlayerPed.CurrentVehicle != null)
                {
                    Game.PlayerPed.CurrentVehicle.Mods.LicensePlate = text;
                }
            };
            Add(license);

            var styles = new List <LicensePlateStyle>();

            foreach (LicensePlateStyle s in Enum.GetValues(typeof(LicensePlateStyle)))
            {
                styles.Add(s);
            }
            var plateStyle = new MenuItemSpinnerList <LicensePlateStyle>(client, this, "License Plate Style", styles, 0, true);

            plateStyle.ValueUpdate += (idx) => {
                var style = plateStyle.Data.ElementAt((int)idx);
                if (Game.PlayerPed.CurrentVehicle != null)
                {
                    Game.PlayerPed.CurrentVehicle.Mods.LicensePlateStyle = style;
                }
                return(idx);
            };
            Add(plateStyle);

            var hasNeon = new MenuItemCheckbox(client, this, "Neon Lights", HasNeon);

            hasNeon.IsChecked = () => HasNeon;
            hasNeon.Activate += () => {
                HasNeon = !HasNeon;
                return(Task.FromResult(0));
            };
            Add(hasNeon);

            var neonR = new MenuItemSpinnerInt(client, this, "Neon Color (Red)", NeonColor.R, 0, 255, 1, true);

            neonR.ValueUpdate += (val) => {
                NeonColor = Color.FromArgb(val, NeonColor.G, NeonColor.B);
                return(val);
            };
            Add(neonR);

            var neonG = new MenuItemSpinnerInt(client, this, "Neon Color (Green)", NeonColor.G, 0, 255, 1, true);

            neonG.ValueUpdate += (val) => {
                NeonColor = Color.FromArgb(NeonColor.R, val, NeonColor.B);
                return(val);
            };
            Add(neonG);

            var neonB = new MenuItemSpinnerInt(client, this, "Neon Color (Blue)", NeonColor.B, 0, 255, 1, true);

            neonB.ValueUpdate += (val) => {
                NeonColor = Color.FromArgb(NeonColor.R, NeonColor.G, val);
                return(val);
            };
            Add(neonB);

            Add(new MenuItemVehicleLivery(client, this));

            client.RegisterTickHandler(OnTick);
        }