示例#1
0
        public bool calibrate(Bitmap screenshot)
        {
            Process[] p = Process.GetProcessesByName("ShooterGame");
            if (p.Length > 0)
            {
                ARKProcess = p[0];
            }

            if (screenshot == null)
            {
                return(false);
            }

            if (screenshot.Width == calibrationResolution[0] && screenshot.Height == calibrationResolution[1])
            {
                return(true);
            }

            //debugPanel.Controls.Clear();
            alphabet      = new Bitmap[255];
            hashMap       = new Dictionary <long, List <byte> >();
            statPositions = new Dictionary <string, Point>(9);

            Bitmap bmp;
            Bitmap origBitmap = Properties.Resources.ARKCalibration1080;


            //CalibrateFromImage(bmp, @"1234567890?,.;/:+=@|#%abcdeghijklm " + @"n opqrstuvwxyz&é'(§è!çà)-ABCDEFGHIJLMNOPQRSTUVWXYZ£µ$[]{}ñ<>/\f lK");

            //GenerateLetterImagesFromFont(18); // <-- function should have generated "clean" image from source font, but ARK scales down from original values and adds a glow, leading to greater inaccuracies

            // positions depend on screen resolution.
            int resolution = 0;

            Win32Stuff.Rect res = new Win32Stuff.Rect(); // Win32Stuff.GetWindowRect("ShooterGame");
            if (screenshot != null)
            {
                res.left   = 0;
                res.right  = screenshot.Width;
                res.top    = 0;
                res.bottom = screenshot.Height;
            }
            else
            {
                return(false); // error
            }
            if (res.Width == 1920 && res.Height == 1080)
            {
                resolution = 0;
            }
            else if (res.Width == 1680 && res.Height == 1050)
            {
                resolution = 1;
            }
            else if (res.Width == 1600 && res.Height == 900)
            {
                resolution = 2;
            }
            else
            {
                resolution = -1;
                return(false); // no supported resolution
            }


            switch (resolution)
            {
            case 0:
                // coords for 1920x1080
                statPositions["NameAndLevel"]   = new Point(1280, 170);
                statPositions["Health"]         = new Point(1355, 630);
                statPositions["Stamina"]        = new Point(1355, 665);
                statPositions["Oxygen"]         = new Point(1355, 705);
                statPositions["Food"]           = new Point(1355, 740);
                statPositions["Weight"]         = new Point(1355, 810);
                statPositions["Melee Damage"]   = new Point(1355, 845);
                statPositions["Movement Speed"] = new Point(1355, 885);
                statPositions["Torpor"]         = new Point(1355, 990);

                origBitmap = Properties.Resources.ARKCalibration1080;
                bmp        = removePixelsUnderThreshold(GetGreyScale(origBitmap), whiteThreshold);
                CalibrateFromImage(bmp, @"1234567890?,.;/:+=@|#%abcdeghijklm " + @"n opqrstuvwxyz&é'(§è!çà)-ABCDEFGHIJLMNOPQRSTUVWXYZ£µ$[]{}ñ<>/\f lK");
                break;

            case 1:
                // coords for 1680x1050
                // 1680/1920 = height-factor; 50 = translation
                // not yet correct x_1080 |--> (x_1080+60)*1680/1920
                //statPositions["NameAndLevel"] = new Point(1111, 200);
                //statPositions["Health"] = new Point(1183, 595);
                //statPositions["Stamina"] = new Point(1183, 630);
                //statPositions["Oxygen"] = new Point(1183, 665);
                //statPositions["Food"] = new Point(1183, 691);
                //statPositions["Weight"] = new Point(1183, 755);
                //statPositions["Melee Damage"] = new Point(1183, 788);
                //statPositions["Movement Speed"] = new Point(1183, 817);
                //statPositions["Torpor"] = new Point(1183, 912);

                // version without the "statName:"
                coordsAfterDot = true;
                statPositions["NameAndLevel"]   = new Point(1111, 200);
                statPositions["Health"]         = new Point(1260, 595);
                statPositions["Stamina"]        = new Point(1277, 630);
                statPositions["Oxygen"]         = new Point(1271, 665);
                statPositions["Food"]           = new Point(1249, 691);
                statPositions["Weight"]         = new Point(1264, 755);
                statPositions["Melee Damage"]   = new Point(1340, 788);
                statPositions["Movement Speed"] = new Point(1362, 817);
                statPositions["Torpor"]         = new Point(1260, 912);


                origBitmap = Properties.Resources.ARKCalibration1050;
                bmp        = removePixelsUnderThreshold(GetGreyScale(origBitmap), whiteThreshold);
                CalibrateFromImage(bmp, @"1234567890.,?;.:/=+ù%µ$* ABCDEFGHIJ-LMNOPQRSTUVWXYZabcdeghijklmnopqrstuvwxyz&#'()[]{}!@flK");     // £ missing
                break;

            case 2:
                // coords for 1600x960
                statPositions["NameAndLevel"]   = new Point(1130, 170);
                statPositions["Health"]         = new Point(1130, 550);
                statPositions["Stamina"]        = new Point(1130, 585);
                statPositions["Oxygen"]         = new Point(1130, 615);
                statPositions["Food"]           = new Point(1130, 645);
                statPositions["Weight"]         = new Point(1130, 705);
                statPositions["Melee Damage"]   = new Point(1130, 735);
                statPositions["Movement Speed"] = new Point(1130, 765);
                statPositions["Torpor"]         = new Point(1130, 855);
                break;
            }

            /*
             * for (int i = 0; i < 255; i++)
             * {
             *  bmp = alphabet[i];
             *  if (bmp == null)
             *      continue;
             *  AddBitmapToDebug(bmp);
             * }
             */
            calibrationResolution[0] = res.Width;
            calibrationResolution[1] = res.Height;

            /*
             * AddBitmapToDebug(alphabet['µ']);
             * AddBitmapToDebug(alphabet['%']);
             * AddBitmapToDebug(alphabet['$']);
             * AddBitmapToDebug(alphabet['A']);
             * AddBitmapToDebug(alphabet['J']);
             * AddBitmapToDebug(alphabet['µ']);
             * AddBitmapToDebug(alphabet['?']);
             * AddBitmapToDebug(alphabet['-']);
             * AddBitmapToDebug(alphabet['[']);
             * AddBitmapToDebug(alphabet['z']);
             * AddBitmapToDebug(alphabet['(']);
             * AddBitmapToDebug(alphabet[')']);
             * AddBitmapToDebug(alphabet['f']);
             * AddBitmapToDebug(alphabet['K']);
             *
             * foreach (char a in ":0123456789.%/")
             *  reducedAlphabet[a] = alphabet[a];
             */
            return(true);
        }
示例#2
0
        // figure out the current resolution and positions
        // return true if the calibration was successful
        public bool calibrate(Bitmap screenshot)
        {
            Process[] p = Process.GetProcessesByName("ShooterGame");
            if (p.Length > 0)
                ARKProcess = p[0];

            if (screenshot == null)
                return false;

            if (screenshot.Width == calibrationResolution[0] && screenshot.Height == calibrationResolution[1])
                return true;

            //debugPanel.Controls.Clear();
            //alphabet = new Bitmap[3,255];
            hashMap = new Dictionary<long, List<byte>>();
            statPositions = new Dictionary<string, Point>(9);

            // positions depend on screen resolution.
            int resolution = 0;
            Win32Stuff.Rect res = new Win32Stuff.Rect(); // Win32Stuff.GetWindowRect("ShooterGame");
            if (screenshot != null)
            {
                res.left = 0;
                res.right = screenshot.Width;
                res.top = 0;
                res.bottom = screenshot.Height;
            }
            else
                return false; // error

            if (res.Width == 1920 && res.Height == 1080)
                resolution = 0;
            else if (res.Width == 1680 && res.Height == 1050)
                resolution = 1;
            else if (res.Width == 1600 && res.Height == 900)
                resolution = 2;
            else
            {
                resolution = -1;
                return false; // no supported resolution
            }

            if (currentResolution == resolution)
                return true;

            switch (resolution)
            {
                case 0:
                    // coords for 1920x1080
                    statPositions["NameAndLevel"] = new Point(1280, 170);
                    statPositions["Health"] = new Point(1355, 630);
                    statPositions["Stamina"] = new Point(1355, 665);
                    statPositions["Oxygen"] = new Point(1355, 705);
                    statPositions["Food"] = new Point(1355, 740);
                    statPositions["Weight"] = new Point(1355, 810);
                    statPositions["Melee Damage"] = new Point(1355, 845);
                    statPositions["Movement Speed"] = new Point(1355, 885);
                    statPositions["Torpor"] = new Point(1355, 990);
                    statPositions["CurrentWeight"] = new Point(805, 231); // central version of weight, gives "temporary maximum", useful for determining baby %age
                    statPositions["Imprinting"] = new Point(1260, 594);
                    break;

                case 1:
                    // coords for 1680x1050
                    // 1680/1920 = height-factor; 50 = translation
                    // not yet correct x_1080 |--> (x_1080+60)*1680/1920
                    //statPositions["NameAndLevel"] = new Point(1111, 200);
                    //statPositions["Health"] = new Point(1183, 595);
                    //statPositions["Stamina"] = new Point(1183, 630);
                    //statPositions["Oxygen"] = new Point(1183, 665);
                    //statPositions["Food"] = new Point(1183, 691);
                    //statPositions["Weight"] = new Point(1183, 755);
                    //statPositions["Melee Damage"] = new Point(1183, 788);
                    //statPositions["Movement Speed"] = new Point(1183, 817);
                    //statPositions["Torpor"] = new Point(1183, 912);

                    // version without the "statName:"
                    coordsAfterDot = true;
                    statPositions["NameAndLevel"] = new Point(1111, 200);
                    statPositions["Health"] = new Point(1260, 595);
                    statPositions["Stamina"] = new Point(1277, 630);
                    statPositions["Oxygen"] = new Point(1271, 665);
                    statPositions["Food"] = new Point(1249, 691);
                    statPositions["Weight"] = new Point(1264, 755);
                    statPositions["Melee Damage"] = new Point(1340, 788);
                    statPositions["Movement Speed"] = new Point(1362, 817);
                    statPositions["Torpor"] = new Point(1260, 912);
                    statPositions["CurrentWeight"] = new Point(1, 1); // not correct, TODO
                    break;

                case 2:
                    // coords for 1600x960
                    statPositions["NameAndLevel"] = new Point(1130, 170);
                    statPositions["Health"] = new Point(1130, 550);
                    statPositions["Stamina"] = new Point(1130, 585);
                    statPositions["Oxygen"] = new Point(1130, 615);
                    statPositions["Food"] = new Point(1130, 645);
                    statPositions["Weight"] = new Point(1130, 705);
                    statPositions["Melee Damage"] = new Point(1130, 735);
                    statPositions["Movement Speed"] = new Point(1130, 765);
                    statPositions["Torpor"] = new Point(1130, 855);
                    statPositions["CurrentWeight"] = new Point(1, 1); // not correct, TODO
                    break;
            }
            calibrationResolution[0] = res.Width;
            calibrationResolution[1] = res.Height;

            currentResolution = resolution;

            /*
            AddBitmapToDebug(alphabet['µ']);
            AddBitmapToDebug(alphabet['%']);
            AddBitmapToDebug(alphabet['$']);
            AddBitmapToDebug(alphabet['A']);
            AddBitmapToDebug(alphabet['J']);
            AddBitmapToDebug(alphabet['µ']);
            AddBitmapToDebug(alphabet['?']);
            AddBitmapToDebug(alphabet['-']);
            AddBitmapToDebug(alphabet['[']);
            AddBitmapToDebug(alphabet['z']);
            AddBitmapToDebug(alphabet['(']);
            AddBitmapToDebug(alphabet[')']);
            AddBitmapToDebug(alphabet['f']);
            AddBitmapToDebug(alphabet['K']);

            */

            for (int l = 0; l < alphabet.GetLength(0); l++)
                foreach (char a in ":0123456789.,%/")
                    reducedAlphabet[l, a] = alphabet[l, a];

            return true;
        }
示例#3
0
        // figure out the current resolution and positions
        // return true if the calibration was successful
        public bool calibrate(Bitmap screenshot)
        {
            Process[] p = Process.GetProcessesByName("ShooterGame");
            if (p.Length > 0)
            {
                ARKProcess = p[0];
            }

            if (screenshot == null)
            {
                return(false);
            }

            if (screenshot.Width == calibrationResolution[0] && screenshot.Height == calibrationResolution[1])
            {
                return(true);
            }

            //debugPanel.Controls.Clear();
            //alphabet = new Bitmap[3,255];
            hashMap       = new Dictionary <long, List <byte> >();
            statPositions = new Dictionary <string, Point>(9);

            // positions depend on screen resolution.
            int resolution = 0;

            Win32Stuff.Rect res = new Win32Stuff.Rect(); // Win32Stuff.GetWindowRect("ShooterGame");
            if (screenshot != null)
            {
                res.left   = 0;
                res.right  = screenshot.Width;
                res.top    = 0;
                res.bottom = screenshot.Height;
            }
            else
            {
                return(false); // error
            }
            if (res.Width == 1920 && res.Height == 1080)
            {
                resolution = 0;
            }
            else if (res.Width == 1680 && res.Height == 1050)
            {
                resolution = 1;
            }
            else if (res.Width == 1600 && res.Height == 900)
            {
                resolution = 2;
            }
            else
            {
                resolution = -1;
                return(false); // no supported resolution
            }

            if (currentResolution == resolution)
            {
                return(true);
            }

            switch (resolution)
            {
            case 0:
                // coords for 1920x1080
                statPositions["NameAndLevel"]   = new Point(1280, 170);
                statPositions["Health"]         = new Point(1355, 630);
                statPositions["Stamina"]        = new Point(1355, 665);
                statPositions["Oxygen"]         = new Point(1355, 705);
                statPositions["Food"]           = new Point(1355, 740);
                statPositions["Weight"]         = new Point(1355, 810);
                statPositions["Melee Damage"]   = new Point(1355, 845);
                statPositions["Movement Speed"] = new Point(1355, 885);
                statPositions["Torpor"]         = new Point(1355, 990);
                statPositions["CurrentWeight"]  = new Point(805, 231);    // central version of weight, gives "temporary maximum", useful for determining baby %age
                statPositions["Imprinting"]     = new Point(1260, 594);
                break;

            case 1:
                // coords for 1680x1050
                // 1680/1920 = height-factor; 50 = translation
                // not yet correct x_1080 |--> (x_1080+60)*1680/1920
                //statPositions["NameAndLevel"] = new Point(1111, 200);
                //statPositions["Health"] = new Point(1183, 595);
                //statPositions["Stamina"] = new Point(1183, 630);
                //statPositions["Oxygen"] = new Point(1183, 665);
                //statPositions["Food"] = new Point(1183, 691);
                //statPositions["Weight"] = new Point(1183, 755);
                //statPositions["Melee Damage"] = new Point(1183, 788);
                //statPositions["Movement Speed"] = new Point(1183, 817);
                //statPositions["Torpor"] = new Point(1183, 912);

                // version without the "statName:"
                coordsAfterDot = true;
                statPositions["NameAndLevel"]   = new Point(1111, 200);
                statPositions["Health"]         = new Point(1260, 595);
                statPositions["Stamina"]        = new Point(1277, 630);
                statPositions["Oxygen"]         = new Point(1271, 665);
                statPositions["Food"]           = new Point(1249, 691);
                statPositions["Weight"]         = new Point(1264, 755);
                statPositions["Melee Damage"]   = new Point(1340, 788);
                statPositions["Movement Speed"] = new Point(1362, 817);
                statPositions["Torpor"]         = new Point(1260, 912);
                statPositions["CurrentWeight"]  = new Point(1, 1);    // not correct, TODO
                break;

            case 2:
                // coords for 1600x960
                statPositions["NameAndLevel"]   = new Point(1130, 170);
                statPositions["Health"]         = new Point(1130, 550);
                statPositions["Stamina"]        = new Point(1130, 585);
                statPositions["Oxygen"]         = new Point(1130, 615);
                statPositions["Food"]           = new Point(1130, 645);
                statPositions["Weight"]         = new Point(1130, 705);
                statPositions["Melee Damage"]   = new Point(1130, 735);
                statPositions["Movement Speed"] = new Point(1130, 765);
                statPositions["Torpor"]         = new Point(1130, 855);
                statPositions["CurrentWeight"]  = new Point(1, 1);    // not correct, TODO
                break;
            }
            calibrationResolution[0] = res.Width;
            calibrationResolution[1] = res.Height;

            currentResolution = resolution;

            /*
             * AddBitmapToDebug(alphabet['µ']);
             * AddBitmapToDebug(alphabet['%']);
             * AddBitmapToDebug(alphabet['$']);
             * AddBitmapToDebug(alphabet['A']);
             * AddBitmapToDebug(alphabet['J']);
             * AddBitmapToDebug(alphabet['µ']);
             * AddBitmapToDebug(alphabet['?']);
             * AddBitmapToDebug(alphabet['-']);
             * AddBitmapToDebug(alphabet['[']);
             * AddBitmapToDebug(alphabet['z']);
             * AddBitmapToDebug(alphabet['(']);
             * AddBitmapToDebug(alphabet[')']);
             * AddBitmapToDebug(alphabet['f']);
             * AddBitmapToDebug(alphabet['K']);
             *
             */

            for (int l = 0; l < alphabet.GetLength(0); l++)
            {
                foreach (char a in ":0123456789.,%/")
                {
                    reducedAlphabet[l, a] = alphabet[l, a];
                }
            }

            return(true);
        }