示例#1
0
        /// <summary>
        /// Append buffered output to displayed log (and possibly to a log file).
        /// </summary>
        private void UpdateLog(object sender, EventArgs eventArgs)
        {
            if (_scrolling)
            {
                return;
            }

            // Get buffered log output.
            string logLines;

            lock (_logBuffer)
            {
                if (_logBuffer.Length == 0)
                {
                    return;
                }
                logLines = _logBuffer.ToString();
                _logBuffer.Clear();
                _logEmpty = false;
            }

            // Add to log file.
            if (!string.IsNullOrEmpty(LogFile))
            {
                lock (LogLock)
                {
                    File.AppendAllText(LogFile, logLines);
                }
            }
            if (VisibleLogFile == null || !VisibleLogFile.Equals(LogFile))
            {
                return;
            }
            // Scroll if text box is already scrolled to bottom.
            int  previousLength = Math.Max(0, TextLength - 1);
            var  point          = GetPositionFromCharIndex(previousLength);
            bool autoScroll     = (ClientRectangle.Bottom >= point.Y);

            if (Focused)
            {
                StopButton.Focus(); // text box scrolls if it has focus!
            }
            var addLines = logLines.Replace("\r", "");

            if (addLines.EndsWith("\n"))
            {
                addLines = addLines.Substring(0, addLines.Length - 1);
            }
            AddLines(addLines.Split('\n'));

            if (autoScroll)
            {
                Select(Text.Length - 1, 0);
                ScrollToCaret();
            }
        }
        private void StartButton_Click(object sender, EventArgs e)
        {
            // Parse and store the number of replays to be played
            string inputText     = numReplays.Text;
            int    ReplaysToPlay = 1;

            if (!string.IsNullOrEmpty(inputText))
            {
                int.TryParse(inputText, out ReplaysToPlay);
                if (ReplaysToPlay < 1)
                {
                    ReplaysToPlay = 1;
                }
            }

            // Parse and store the hotkeys for recording/stopping
            RecordHotkey = ParseKeys(InputRecordHotkey.Text);
            StopHotkey   = ParseKeys(InputStopHotkey.Text);

            // Toggle the button states
            StartButton.Enabled       = false;
            StopButton.Enabled        = true;
            numReplays.Text           = ReplaysToPlay.ToString();
            numReplays.Enabled        = false;
            InputRecordHotkey.Enabled = false;
            InputStopHotkey.Enabled   = false;
            menuStrip.Enabled         = false;
            SGSettings.Enabled        = false;
            BBTagSettings.Enabled     = false;
            GGXrdSettings.Enabled     = false;

            // Start main loop
            switch (currentGame)
            {
            default:
                viewSG.StartLoop(ReplaysToPlay, SGLP, SGLK, SGMP, SGRight, RecordHotkey, StopHotkey, DisplayHitboxes.Checked, DisplayInputs.Checked, DisplayAttackData.Checked);
                break;

            case "Rivals of Aether":
                viewROA.StartLoop(ReplaysToPlay, ROAStart, ROAL, RecordHotkey, StopHotkey);
                break;

            case "BBTag":
                viewBBTag.StartLoop(ReplaysToPlay, BBTagUp, BBTagConfirm, BBTagGauge, BBTagWindow, RecordHotkey, StopHotkey, BBTagHideGauge.Checked, BBTagHideWindow.Checked);
                break;

            case "Guilty Gear Xrd Rev 2":
                viewGGXrd.StartLoop(ReplaysToPlay, GGXrdConfirm, GGXrdHUD, GGXrdWindow, GGXrdInputs, RecordHotkey, StopHotkey, GGXrdHideHUD.Checked, GGXrdHideWindow.Checked, GGXrdHideInputs.Checked);
                break;
            }

            StopButton.Focus();
        }
        private void StartButton_Click(object sender, EventArgs e)
        {
            // Parse and store the number of replays to be played
            string inputText     = numReplays.Text;
            int    ReplaysToPlay = 1;

            if (!string.IsNullOrEmpty(inputText))
            {
                int.TryParse(inputText, out ReplaysToPlay);
                if (ReplaysToPlay < 1)
                {
                    ReplaysToPlay = 1;
                }
            }

            // Parse and store the hotkeys for recording/stopping
            RecordHotkey = ParseKeys(InputRecordHotkey.Text);
            StopHotkey   = ParseKeys(InputStopHotkey.Text);

            // Toggle the button states
            StartButton.Enabled       = false;
            StopButton.Enabled        = true;
            numReplays.Text           = ReplaysToPlay.ToString();
            numReplays.Enabled        = false;
            InputRecordHotkey.Enabled = false;
            InputStopHotkey.Enabled   = false;
            DisplayHitboxes.Enabled   = false;
            DisplayInputs.Enabled     = false;
            DisplayAttackData.Enabled = false;
            menuStrip.Enabled         = false;

            // Start main loop
            switch (currentGame)
            {
            default:
                viewSG.StartLoop(ReplaysToPlay, SGLP, SGLK, SGMP, SGRight, RecordHotkey, StopHotkey, DisplayHitboxes.Checked, DisplayInputs.Checked, DisplayAttackData.Checked);
                break;

            case "Rivals of Aether":
                viewROA.StartLoop(ReplaysToPlay, ROAUp, ROADown, ROALeft, ROARight, ROAStart, ROAL, RecordHotkey, StopHotkey);
                break;
            }

            StopButton.Focus();
        }