Exemple #1
0
        private void DebugButton_Click(object sender, EventArgs e)
        {
            Process proc = Process.GetProcesses().Where(x => x.ProcessName == Config.ProcessName).FirstOrDefault();

            if (proc == null)
            {
                MetroMessageBox.Show(this, $"\nGenshin Impact must be running first.", "Process Error", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 135);
                return;
            }

            if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty)
            {
                MetroMessageBox.Show(this, $"\nMust first setup cooldown text/party location before debugging.", "Overlay Error", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 135);
                return;
            }

            OverlayWindow.IsDebug = true;

            int     sel             = Party.GetSelectedCharacter(proc.MainWindowHandle);
            Point   captureLocation = new Point(Config.CooldownTextLocation.X, Config.CooldownTextLocation.Y);
            Size    captureSize     = new Size(Config.CooldownTextSize.Width, Config.CooldownTextSize.Height);
            decimal currentCooldown = IMG.Capture(proc.MainWindowHandle, captureLocation, captureSize, true);

            string debugOut = $"\nParty Size (1 to 4): {Party.PartySize}\n" +
                              $"Selected Character (1 to 4): Slot#{sel + 1}\n" +
                              $"OCR Text Detected: {IMG.Text}\n" +
                              $"Assumed Cooldown: {currentCooldown}\n" +
                              $"Confidence: {IMG.Confidence * 100}% Required: {Config.OCRMinimumConfidence * 100}%";

            Clipboard.SetText(debugOut);
            MetroMessageBox.Show(this, debugOut +
                                 $"\nCheck the GenshinOverlay folder for OCR input/output images.", "OCR Debug", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 240);

            OverlayWindow.IsDebug = false;
        }
Exemple #2
0
        private void KeyHook_KeyUp(object sender, KeyHookEventArgs e)
        {
            if (OverlayWindow.GenshinHandle == IntPtr.Zero)
            {
                return;
            }
            if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty)
            {
                return;
            }
            if (e.Key == Keys.E)
            {
                if (Party.SelectedCharacter == -1 || Party.Characters[Party.SelectedCharacter].Cooldown > Config.CooldownMinimumReapply || Party.Characters[Party.SelectedCharacter].Processing)
                {
                    return;
                }
                int c = Party.SelectedCharacter;
                Party.Characters[c].Processing = true;

                new Thread(() => {
                    Thread.Sleep(100);
                    Point captureLocation = new Point(Config.CooldownTextLocation.X, Config.CooldownTextLocation.Y);
                    Size captureSize      = new Size(Config.CooldownTextSize.Width, Config.CooldownTextSize.Height);

                    decimal currentCooldown = IMG.Capture(OverlayWindow.CurrentHandle, captureLocation, captureSize);
                    while (c == Party.SelectedCharacter && currentCooldown == 0)
                    {
                        Thread.Sleep(100);
                        currentCooldown = IMG.Capture(OverlayWindow.CurrentHandle, captureLocation, captureSize);
                    }
                    if (c != Party.SelectedCharacter)
                    {
                        Party.Characters[c].Cooldown = 0;
                        Party.Characters[c].Max      = 0;
                    }
                    else
                    {
                        if (Config.CooldownOverride[c] > 0)
                        {
                            if (currentCooldown < Config.CooldownMinimumOverride)
                            {
                                Party.Characters[c].Cooldown = Config.CooldownOverride[c];
                                Party.Characters[c].Max      = Config.CooldownOverride[c];
                            }
                            else
                            {
                                Party.Characters[c].Cooldown = currentCooldown;
                                Party.Characters[c].Max      = currentCooldown;
                            }
                        }
                        else
                        {
                            Party.Characters[c].Cooldown = currentCooldown + Config.CooldownOffset;
                            Party.Characters[c].Max      = Party.Characters[c].Cooldown;
                        }
                    }
                    Party.Characters[c].Processing = false;
                }).Start();
            }
        }
        private void SkillKeyPressed()
        {
            if (Party.SelectedCharacter == -1 || Party.Characters[Party.SelectedCharacter].Cooldown > Config.CooldownMinimumReapply || Party.Characters[Party.SelectedCharacter].Processing)
            {
                return;
            }
            int c = Party.SelectedCharacter;

            Party.Characters[c].Processing = true;

            new Thread(() => {
                Thread.Sleep(Config.CooldownOCRRateInMs);
                Point captureLocation  = new Point(Config.CooldownTextLocation.X, Config.CooldownTextLocation.Y);
                Size captureSize       = new Size(Config.CooldownTextSize.Width, Config.CooldownTextSize.Height);
                Point captureLocation2 = new Point(Config.CooldownText2LocationX, Config.CooldownTextLocation.Y);

                IMG.OCRCapture ocr = new IMG.OCRCapture();
                IMG.Capture(OverlayWindow.CurrentHandle, captureLocation, captureSize, ref ocr);
                while (c == Party.SelectedCharacter && ocr.Cooldown == 0)
                {
                    Thread.Sleep(Config.CooldownOCRRateInMs);
                    IMG.Capture(OverlayWindow.CurrentHandle, captureLocation, captureSize, ref ocr);
                    if (ocr.Cooldown == 0 && Config.CooldownText2LocationX != 0)
                    {
                        IMG.Capture(OverlayWindow.CurrentHandle, captureLocation2, captureSize, ref ocr);
                    }
                }
                if (c != Party.SelectedCharacter)
                {
                    Party.Characters[c].Cooldown = 0;
                    Party.Characters[c].Max      = 0;
                }
                else
                {
                    if (Config.CooldownOverride[c] > 0)
                    {
                        if (ocr.Cooldown < Config.CooldownMinimumOverride)
                        {
                            Party.Characters[c].Cooldown = Config.CooldownOverride[c];
                            Party.Characters[c].Max      = Config.CooldownOverride[c];
                        }
                        else
                        {
                            Party.Characters[c].Cooldown = ocr.Cooldown;
                            Party.Characters[c].Max      = ocr.Cooldown;
                        }
                    }
                    else
                    {
                        Party.Characters[c].Cooldown = ocr.Cooldown + Config.CooldownOffset;
                        Party.Characters[c].Max      = Party.Characters[c].Cooldown;
                    }
                }
                Party.Characters[c].Processing = false;
            }).Start();
        }
Exemple #4
0
        private void OCRDebug(bool isMulti)
        {
            if (OverlayWindow.IsDebug)
            {
                OverlayWindow.IsDebug = false;
                return;
            }
            Process proc = Process.GetProcesses().Where(x => x.ProcessName == Config.ProcessName).FirstOrDefault();

            if (proc == null)
            {
                MetroMessageBox.Show(this, $"\nGenshin Impact must be running first.", "Process Error", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 135);
                return;
            }

            if (Config.CooldownTextLocation == Point.Empty || Config.PartyNumLocations["4 #1"] == Point.Empty)
            {
                MetroMessageBox.Show(this, $"\nMust first setup cooldown text/party location before debugging.", "Overlay Error", MessageBoxButtons.OK, Theme, MessageBoxDefaultButton.Button1, 135);
                return;
            }

            new Thread(() => {
                OverlayWindow.IsDebug = true;
                Stopwatch sw          = new Stopwatch();
                sw.Start();
                int sel = Party.GetSelectedCharacter(proc.MainWindowHandle);
                Point captureLocation = new Point(Config.CooldownTextLocation.X, Config.CooldownTextLocation.Y);
                Size captureSize      = new Size(Config.CooldownTextSize.Width, Config.CooldownTextSize.Height);

                IMG.OCRCapture ocr = new IMG.OCRCapture();
                IMG.Capture(proc.MainWindowHandle, captureLocation, captureSize, ref ocr, true);
                long time = sw.ElapsedMilliseconds;
                if (!isMulti || (isMulti && ocr.Cooldown > 0))
                {
                    this.UI(() => {
                        DebugText.Text = $"Party Size (1 to 4): {Party.PartySize}\r\n" +
                                         $"Selected Character (1 to 4): Slot#{sel + 1}\r\n" +
                                         $"OCR Text Detected: {ocr.Text}\r\n" +
                                         $"Parsed Cooldown: {ocr.Cooldown}\r\n" +
                                         $"Confidence: {ocr.Confidence * 100}% Required: {Config.OCRMinimumConfidence * 100}%\r\n" +
                                         $"Iteration #{ocr.Iterations} ({time}ms @ {Config.CooldownOCRRateInMs}ms rate)";
                    });
                }
                else
                {
                    while (ocr.Cooldown == 0 && ocr.Iterations < 1000 && OverlayWindow.IsDebug)
                    {
                        Thread.Sleep(Config.CooldownOCRRateInMs);
                        IMG.Capture(proc.MainWindowHandle, captureLocation, captureSize, ref ocr, false);

                        this.UI(() => {
                            DebugText.Text = $"Party Size (1 to 4): {Party.PartySize}\r\n" +
                                             $"Selected Character (1 to 4): Slot#{sel + 1}\r\n" +
                                             $"OCR Text Detected: {ocr.Text}\r\n" +
                                             $"Parsed Cooldown: {ocr.Cooldown}\r\n" +
                                             $"Confidence: {ocr.Confidence * 100}% Required: {Config.OCRMinimumConfidence * 100}%\r\n" +
                                             $"Iteration #{ocr.Iterations} ({sw.ElapsedMilliseconds}ms @ {Config.CooldownOCRRateInMs}ms rate)";
                        });
                    }
                }
                sw.Stop();

                OverlayWindow.IsDebug = false;
            }).Start();
        }