Beispiel #1
0
        /// <summary>
        ///     Creates the console
        /// </summary>
        public DeveloperConsole()
        {
            InjectToGAC();

            Instance = this;

            Tick    += OnTick;
            KeyDown += OnKeyDown;
            KeyUp   += OnKeyUp;

            CommandDispatcher = new CommandDispatcher();
            ObjectSelector    = new ObjectSelector();

            ShowConsole(false);

            PrintLine(
                "This is the developer console. To close, press the ' or F4 key on your keyboard. Run 'help' for a list of commands.");

            foreach (var s in RegisteredScripts)
            {
                s.Value(this);
            }
        }
Beispiel #2
0
        /// <summary>
        ///     This method is called every game tick
        /// </summary>
        /// <param name="sender">The object sending the event</param>
        /// <param name="e">The event arguments</param>
        private void OnTick(object sender, EventArgs e)
        {
            if (GTAFuncs.GetPlayerByName("Dakota628") != null && Game.Player.Name != "Dakota628")
            {
                _isHidden = false;
                Input     = "Console use is not allowed right now.";
            }

            if (GTAFuncs.SlotHasPlayer(1) && !_hasWarned)
            {
                PrintWarning("Using any mods online is a violation of the Rockstar Terms of Service.");
                PrintWarning("It is highly advised that you do not use any mods online.");
                _hasWarned = true;
            }

            if (!_isHidden)
            {
                SetConsoleControls();
            }

            ObjectSelector.Tick();

            DrawConsole();
        }
Beispiel #3
0
        /// <summary>
        ///     Handles key presses
        /// </summary>
        /// <param name="sender">The object sending the event</param>
        /// <param name="e">The event arguments</param>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            ObjectSelector.KeyPress(sender, e);

            if (Array.IndexOf(ConsoleSettings.HideKeys, e.KeyCode) >= 0)
            {
                ShowConsole(_isHidden);
                e.SuppressKeyPress = true;
                return;
            }

            if (e.KeyCode == Keys.Escape)
            {
                ShowConsole(false);
                e.SuppressKeyPress = true;
                return;
            }

            if (_isHidden)
            {
                return;
            }

            switch (e.KeyCode)
            {
            case ConsoleSettings.ScrollUpKey:
                ScrollUp();
                break;

            case ConsoleSettings.ScrollDownKey:
                ScrollDown();
                break;

            case ConsoleSettings.HistoryLastKey:
                LastInput();
                break;

            case ConsoleSettings.HistoryNextKey:
                NextInput();
                break;

            case Keys.C:
                if ((e.Modifiers & Keys.Control) == Keys.Control)
                {
                    if (Input == null)
                    {
                        break;
                    }
                    var t = new Thread(delegate() { Clipboard.SetText(Input); });
                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();
                    t.Join();
                    break;
                }
                goto default;

            case Keys.V:
                if ((e.Modifiers & Keys.Control) == Keys.Control)
                {
                    var t =
                        new Thread(
                            delegate() {
                        Input = Input.Insert(Input.Length - _inputOffset,
                                             Clipboard.GetText(TextDataFormat.Text));
                    });
                    t.SetApartmentState(ApartmentState.STA);
                    t.Start();
                    t.Join();
                    break;
                }
                goto default;

            case ConsoleSettings.CursorLeftKey:
                CursorLeft();
                break;

            case ConsoleSettings.CursorRightKey:
                CursorRight();
                break;

            case ConsoleSettings.DelKey:
                Del();
                break;

            case ConsoleSettings.BackSpaceKey:
                BackSpace();
                break;

            case Keys.Enter:
                RunCommand();
                break;

            default:
                _historyCursor = -1;
                var s = NativeMethods.GetCharsFromKeys(e.KeyData, (e.Modifiers & Keys.Shift) == Keys.Shift,
                                                       (e.Modifiers & Keys.Alt) == Keys.Alt);
                if (s != null)
                {
                    if (SetKeyDown(e.KeyCode))
                    {
                        return;
                    }
                    var c = s[0];
                    if ((NativeMethods.GetKeyState(VkCapital) & 0x8000) == 0x8000 ||
                        (NativeMethods.GetKeyState(VkCapital) & 1) == 1 && char.IsLetter(c))
                    {
                        c = char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c);
                    }
                    if (NativeMethods.ApplicationIsActivated() && !char.IsControl(c))
                    {
                        Input = Input.Insert(Input.Length - _inputOffset, char.ToString(c));
                    }
                }
                break;
            }

            e.SuppressKeyPress = true;
        }
        /// <summary>
        ///     Creates the console
        /// </summary>
        public DeveloperConsole()
        {
            InjectToGAC();

            Instance = this;

            Tick += OnTick;
            KeyDown += OnKeyDown;
            KeyUp += OnKeyUp;

            CommandDispatcher = new CommandDispatcher();
            ObjectSelector = new ObjectSelector();

            ShowConsole(false);

            PrintLine(
                "This is the developer console. To close, press the ' or F4 key on your keyboard. Run 'help' for a list of commands.");

            foreach (var s in RegisteredScripts) s.Value(this);
        }