private static void Main()
        {
            var instructional = new InstructionalButtons();
            var spawnCarGroup = new InstructionalButtonGroup("Spawn Car", ModifierKey.GetInstructionalKey(), InstructionalKey.SymbolPlus, SpawnCarKey.GetInstructionalKey());

            instructional.Buttons.Add(spawnCarGroup);

            while (true)
            {
                GameFiber.Yield();

                if (HasInputJustChanged)
                {
                    var(modifier, key) = IsUsingController ? (ModifierButton.GetInstructionalKey(), SpawnCarButton.GetInstructionalKey()) :
                                         (ModifierKey.GetInstructionalKey(), SpawnCarKey.GetInstructionalKey());
                    spawnCarGroup.Buttons[0] = modifier;
                    spawnCarGroup.Buttons[2] = key;
                    instructional.Update();
                }

                instructional.Draw();

                bool spawn = IsUsingController ? (ModifierButton == ControllerButtons.None || Game.IsControllerButtonDownRightNow(ModifierButton)) && Game.IsControllerButtonDown(SpawnCarButton) :
                             (ModifierKey == Keys.None || Game.IsKeyDownRightNow(ModifierKey)) && Game.IsKeyDown(SpawnCarKey);

                if (spawn)
                {
                    GameFiber.StartNew(() => new Vehicle(m => m.IsCar, Game.LocalPlayer.Character.GetOffsetPositionFront(5.0f)).Dismiss());
                }
            }
        }
Esempio n. 2
0
        public TabView(string title)
        {
            Title = title;
            Tabs  = new List <TabItem>();

            Index             = 0;
            Name              = Game.LocalPlayer.Name;
            TemporarilyHidden = false;
            CanLeave          = true;
            PauseGame         = false;

            MoneySubtitle = "";

            InstructionalButtons = new InstructionalButtons();
            InstructionalButtons.Buttons.Add(new InstructionalButton(GameControl.FrontendAccept, "Select"));
            InstructionalButtons.Buttons.Add(new InstructionalButton(GameControl.CellphoneCancel, "Back"));
            InstructionalButtons.Buttons.Add(new InstructionalButtonGroup("Browse", GameControl.FrontendLb, GameControl.FrontendRb));
        }
        internal ClientPresetsMenu(ClientPresetsScript script, string name = Globals.ScriptName, string subtitle = "Client Presets Menu") : base(name, subtitle)
        {
            _script = script;

            _script.Presets.PresetsCollectionChanged += new EventHandler((sender, args) => Update());

            Update();

            AddTextEntry("VSTANCER_ENTER_PRESET_NAME", "Enter a name for the preset");

            OnItemSelect += ItemSelect;
            InstructionalButtons.Add(Control.PhoneExtraOption, GetLabelText("ITEM_SAVE"));
            InstructionalButtons.Add(Control.PhoneOption, GetLabelText("ITEM_DEL"));

            // Disable Controls binded on the same key
            ButtonPressHandlers.Add(new ButtonPressHandler(Control.SelectWeapon, ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((sender, control) =>
            {
            }), true));

            ButtonPressHandlers.Add(new ButtonPressHandler(Control.VehicleExit, ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((sender, control) =>
            {
            }), true));

            ButtonPressHandlers.Add(new ButtonPressHandler(Control.PhoneExtraOption, ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>(async(sender, control) =>
            {
                string presetName = await _script.GetPresetNameFromUser("VSTANCER_ENTER_PRESET_NAME", "");

                if (string.IsNullOrEmpty(presetName))
                {
                    return;
                }

                SavePresetEvent?.Invoke(this, presetName.Trim());
            }), true));

            ButtonPressHandlers.Add(new ButtonPressHandler(Control.PhoneOption, ControlPressCheckType.JUST_RELEASED, new Action <Menu, Control>((sender, control) =>
            {
                if (GetMenuItems().Count > 0)
                {
                    string presetName = GetMenuItems()[CurrentIndex].ItemData;
                    DeletePresetEvent?.Invoke(this, presetName);
                }
            }), true));
        }