示例#1
0
        private static void WinOcrTest()
        {
            var rp = new RivenParser();
            var rc = new RivenCleaner();

            if (!Directory.Exists("riven_stuff"))
            {
                Directory.CreateDirectory("riven_stuff");
            }
            foreach (var error in Directory.GetFiles(@"C:\Users\david\OneDrive\Documents\WFChatParser\Test Runs\Riven Inputs").Select(f => new FileInfo(f)).Where(f => f.Name.EndsWith("13.png")))
            {
                using (var image = new Bitmap(error.FullName))
                {
                    Bitmap cropped = null;
                    if (image.Width == 4096)
                    {
                        cropped = rp.CropToRiven(image);
                        var ss    = new ScreenStateHandler();
                        var state = ss.GetScreenState(image);
                        if (state != ScreenState.RivenWindow)
                        {
                            System.Diagnostics.Debugger.Break();
                        }
                    }
                    else
                    {
                        cropped = image;
                    }
                    using (var cleaned = rc.CleanRiven(cropped))
                    {
                        cleaned.Save(Path.Combine("riven_stuff", error.Name));
                        var result = rp.ParseRivenTextFromImage(cleaned, null);
                        result.Polarity = rp.ParseRivenPolarityFromColorImage(cropped);
                        result.Rank     = rp.ParseRivenRankFromColorImage(cropped);
                        var sb = new StringBuilder();
                        sb.AppendLine(result.Name);
                        if (result.Modifiers != null)
                        {
                            foreach (var modi in result.Modifiers)
                            {
                                sb.AppendLine(modi.ToString());
                            }
                        }
                        sb.AppendLine(result.Drain.ToString());
                        sb.AppendLine(result.MasteryRank + " " + result.Rolls);
                        File.WriteAllText(Path.Combine("riven_stuff", error.Name.Replace(".png", ".txt")), sb.ToString());
                    }
                    cropped.Dispose();
                }
            }
        }
示例#2
0
        private static void TestRivenStuff()
        {
            var c  = new GameCapture();
            var rp = new RivenParser();
            var ss = new ScreenStateHandler();

            var image = "test.png";
            var b     = c.GetFullImage();

            b.Save("test.png");
            b.Dispose();

            var p       = new ChatParser();
            var results = p.ParseChatImage(new Bitmap(image), true, true, 27).Where(r => r is ChatMessageLineResult).Cast <ChatMessageLineResult>();

            var clean  = new ImageCleaner();
            var coords = new CoordinateList();

            results.SelectMany(r => r.ClickPoints).ToList().ForEach(i => coords.Add(i.X, i.Y));
            clean.SaveClickMarkers("test.png", "test_marked.png", coords);

            var mouse = new MouseHelper();

            var index = 0;
            var sw    = new Stopwatch();

            foreach (var clr in results.Where(r => r is ChatMessageLineResult).Cast <ChatMessageLineResult>())
            {
                foreach (var click in clr.ClickPoints)
                {
                    b = c.GetFullImage();
                    if (ss.IsChatOpen(b))
                    {
                        //Hover over riven
                        System.Threading.Thread.Sleep(17);
                        mouse.MoveTo(click.X, click.Y);

                        //Click riven
                        System.Threading.Thread.Sleep(17);
                        mouse.Click(click.X, click.Y);
                        System.Threading.Thread.Sleep(17);
                    }

                    //Move mouse out of the way
                    mouse.MoveTo(0, 0);
                    sw.Restart();
                    var tries = 0;
                    while (true)
                    {
                        try
                        {
                            var bitmap2 = c.GetFullImage();
                            if (ss.GetScreenState(bitmap2) == ScreenState.RivenWindow)
                            {
                                var crop = rp.CropToRiven(bitmap2);
                                crop.Save(index.ToString() + ".png");
                                crop.Dispose();
                                bitmap2.Dispose();
                                break;
                            }
                            bitmap2.Dispose();
                        }
                        catch { }
                        tries++;
                        if (tries > 15)
                        {
                            Console.WriteLine("Riven not detected! Abort!");
                            break;
                        }
                    }
                    Console.WriteLine("Got \"riven\" in " + sw.Elapsed.TotalSeconds + " seconds");

                    //Hover over exit
                    System.Threading.Thread.Sleep(33);
                    mouse.MoveTo(3816, 2013);

                    //Click exit
                    var bitmap = c.GetFullImage();
                    if (ss.GetScreenState(bitmap) == ScreenState.RivenWindow)
                    {
                        System.Threading.Thread.Sleep(17);
                        mouse.Click(3816, 2013);
                        System.Threading.Thread.Sleep(17);
                    }
                    bitmap.Dispose();

                    //Move mouse out of the way
                    System.Threading.Thread.Sleep(17);
                    mouse.MoveTo(0, 0);

                    System.Threading.Thread.Sleep(17);
                    index++;
                }
            }
            //c.Dispose();
        }
示例#3
0
        private static void TestScreenHandler()
        {
            var c  = new GameCapture();
            var ss = new ScreenStateHandler();

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\loading.png"))
            {
                var isLoading = ss.GetScreenState(b) == ScreenState.LoadingScreen;
                Console.WriteLine("Is loading: " + isLoading + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\loading_nobar.png"))
            {
                var isLoading = ss.GetScreenState(b) == ScreenState.LoadingScreen;
                Console.WriteLine("Is loading: " + isLoading + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\login.png"))
            {
                var isLogin = ss.GetScreenState(b) == ScreenState.LoginScreen;
                Console.WriteLine("Is login: "******" should be true");
            }

            Console.WriteLine("MISSING TEST DATA FOR NORMAL CLAIM REWARDS SCREEN");

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\plat_claim.png"))
            {
                var isPlat = ss.GetScreenState(b) == ScreenState.DailyRewardScreenPlat;
                Console.WriteLine("Is plat: " + isPlat + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\warframe_pilot1.png"))
            {
                var isPiloting = ss.GetScreenState(b) == ScreenState.ControllingWarframe;
                Console.WriteLine("Is piloting warframe1: " + isPiloting + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\warframe_pilot2.png"))
            {
                var isPiloting = ss.GetScreenState(b) == ScreenState.ControllingWarframe;
                Console.WriteLine("Is piloting warframe2: " + isPiloting + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\warframe_pilot3.png"))
            {
                var isPiloting = ss.GetScreenState(b) == ScreenState.ControllingWarframe;
                Console.WriteLine("Is piloting warframe3: " + isPiloting + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\main_menu.png"))
            {
                var isMainMenu = ss.GetScreenState(b) == ScreenState.MainMenu;
                Console.WriteLine("Is main menu: " + isMainMenu + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\main_menu2.png"))
            {
                var isMainMenu = ss.GetScreenState(b) == ScreenState.MainMenu;
                Console.WriteLine("Is main menu2: " + isMainMenu + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\profile_menu.png"))
            {
                var isProfileMenu = ss.GetScreenState(b) == ScreenState.ProfileMenu;
                Console.WriteLine("Is isProfileMenu: " + isProfileMenu + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\glyph_window.png"))
            {
                var isGlyphWindow = ss.GetScreenState(b) == ScreenState.GlyphWindow;
                Console.WriteLine("Is glyph window: " + isGlyphWindow + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\glyph_without_filters.png"))
            {
                var isNoFilters = !ss.GlyphFiltersPresent(b);
                Console.WriteLine("Is glyph filters empty: " + isNoFilters + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\glyph_with_filters.png"))
            {
                var isFilters = ss.GlyphFiltersPresent(b);
                Console.WriteLine("Is glyph filters: " + isFilters + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\chat_collapsed.png"))
            {
                var isChatCollapsed = ss.IsChatCollapsed(b);
                Console.WriteLine("Is chat closed: " + isChatCollapsed + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Notice Me Senpai\Screen States\chat_collapsed2.png"))
            {
                var isChatCollapsed = ss.IsChatCollapsed(b);
                Console.WriteLine("Is chat closed2: " + isChatCollapsed + " should be true");
            }

            using (Bitmap b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Test Runs\Inputs\chat.png"))
            {
                var isChat = ss.IsChatOpen(b);
                Console.WriteLine("Is chat open: " + isChat + " should be true");
            }

            using (var b = new Bitmap(@"C:\Users\david\OneDrive\Documents\WFChatParser\Test Runs\Inputs\riven.png"))
            {
                var isRiven = ss.GetScreenState(b) == ScreenState.RivenWindow;
                Console.WriteLine("Is riven: " + isRiven + " should be true");
            }
        }