Esempio n. 1
0
 private static Composite SwitchToTabViaArrowKeys(StashIndexDelegate stashIndexDelegate)
 {
     // Need to ensure that the all stash tab list is not visible. If its visible then arrow keys wont change tab
     return(new Sequence(
                //new Action(delegate
                //{
                //    var viewAllTabsButton = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashButton;
                //    var dropdownMenu = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashPanel;
                //    var allTabsButton = viewAllTabsButton.GetClientRect();
                //    if (dropdownMenu.IsVisible)
                //    {
                //        Thread.Sleep(40);
                //        Mouse.SetCursorPosAndLeftOrRightClickInRectRandomly(allTabsButton, Latency);
                //        Thread.Sleep(100);
                //    }
                //    return RunStatus.Success;
                //}),
                new Action(delegate(object context)
     {
         var indexOfCurrentVisibleTab = GetIndexOfCurrentVisibleTab();
         var tabIndex = stashIndexDelegate(context);
         var difference = tabIndex - indexOfCurrentVisibleTab;
         var tabIsToTheLeft = difference < 0;
         var retry = 0;
         while (GetIndexOfCurrentVisibleTab() != tabIndex && retry < 3)
         {
             for (var i = 0; i < Math.Abs(difference); i++)
             {
                 Input.KeyDown(tabIsToTheLeft ? Keys.Left : Keys.Right);
                 Input.KeyUp(tabIsToTheLeft ? Keys.Left : Keys.Right);
                 Thread.Sleep(30);
             }
             Thread.Sleep(30);
             retry++;
         }
         if (GetIndexOfCurrentVisibleTab() == tabIndex)
         {
             return RunStatus.Success;
         }
         return RunStatus.Failure;
     })));
 }
Esempio n. 2
0
        public static Composite SwitchToTab(StashIndexDelegate stashIndexDelegate)
        {
            return(new DecoratorContinue(delegate(object context)
            {
                visibleStashIndex = GetIndexOfCurrentVisibleTab();
                var tabIndex = stashIndexDelegate(context);
                WillBot.LogMessageCombo($"Switching to stash tab index: {tabIndex} from index {visibleStashIndex}");
                travelDistance = Math.Abs(tabIndex - visibleStashIndex);
                if (travelDistance == 0)
                {
                    WillBot.LogMessageCombo("Already on correct stash tab");
                    return false;
                }
                return true;
            }, new Sequence(

                                             //new Decorator(delegate (object context)
                                             //    {
                                             //        var tabIndex = stashIndexDelegate(context);
                                             //        travelDistance = Math.Abs(tabIndex - visibleStashIndex);
                                             //        if (travelDistance > 3)
                                             //        {
                                             //            WillBot.LogMessageCombo("Switching with dropdown menu");
                                             //            return true;
                                             //        }
                                             //        WillBot.LogMessageCombo("Switching with arrow keys");
                                             //        return false;


                                             //    }, SwitchToTabViaDropdownMenu(stashIndexDelegate)),
                                             SwitchToTabViaArrowKeys(stashIndexDelegate),
                                             new Action(delegate
            {
                Thread.Sleep(500);
                return RunStatus.Success;
            }))
                                         ));
        }
Esempio n. 3
0
        private static Composite SwitchToTabViaDropdownMenu(StashIndexDelegate stashIndexDelegate)
        {
            return(new Action(delegate(object context)
            {
                var tabIndex = stashIndexDelegate(context);
                var viewAllTabsButton = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashButton;
                var dropdownMenu = GameController.Game.IngameState.IngameUi.StashElement.ViewAllStashPanel;
                var allTabsButton = viewAllTabsButton.GetClientRect();
                var slider = stashcount > MAXSHOWN_SIDEBARSTASHTABS;
                if (!dropdownMenu.IsVisible)
                {
                    Thread.Sleep(100);
                    Mouse.SetCursorPosAndLeftOrRightClick(allTabsButton, Latency);
                    ControlTimer.Restart();
                    while (ControlTimer.ElapsedMilliseconds < 1500 && !dropdownMenu.IsVisible)
                    {
                        //WillBot.LogMessageCombo("Waiting for dropdownmenu visible. Waited for {0}", ControlTimer.ElapsedMilliseconds);
                        Thread.Sleep(50);
                    }
                    //wait for the dropdown menu to become visible
                    if (!dropdownMenu.IsVisible)
                    {
                        WillBot.basePlugin.LogError($"Error in opening DropdownMenu.", 5);
                        return RunStatus.Failure;
                    }
                }
                RectangleF tabPos;
                // Make sure that we are scrolled to the top in the menu.
                if (slider)
                {
                    for (int i = 0; i < stashcount - MAXSHOWN_SIDEBARSTASHTABS + 1; ++i)
                    {
                        Input.KeyDown(Keys.Left);
                        Thread.Sleep(1);
                        Input.KeyUp(Keys.Left);
                        Thread.Sleep(1);
                    }
                }
                //get clickposition of tab label
                for (int i = 0; i <= tabIndex; i++)
                {
                    Input.KeyDown(Keys.Right);
                    Thread.Sleep(2);
                    Input.KeyUp(Keys.Right);
                    Thread.Sleep(2);
                }
                //enter-key Method  (There is a bug where the stash rect does not highlight (not possible to enter press))
                //Input.KeyDown(Keys.Enter);
                //Thread.Sleep(1);
                //Input.KeyUp(Keys.Enter);
                //Thread.Sleep(1);

                //reset Sliderposition
                if (slider)
                {
                    if (!dropdownMenu.IsVisible)
                    {
                        //opening DropdownMenu
                        Input.SetCursorPos(allTabsButton.Center);
                        Thread.Sleep(10);
                        Input.MouseMove();
                        Input.LeftDown();
                        Thread.Sleep(1);
                        Input.LeftUp();
                        Thread.Sleep(10);
                        // wait for the dropdown menu to become visible.
                        for (int count = 0; !dropdownMenu.IsVisible && count <= 20; ++count)
                        {
                            Thread.Sleep(50);
                        }
                        if (!dropdownMenu.IsVisible)
                        {
                            WillBot.basePlugin.LogError($"Error in Scrolling back to the top.", 5);
                            return RunStatus.Failure;
                        }
                    }
                    //"scrolling" back up
                    for (int i = 0; i < stashcount - MAXSHOWN_SIDEBARSTASHTABS + 1; ++i)
                    {
                        Input.KeyDown(Keys.Left);
                        Thread.Sleep(1);
                        Input.KeyUp(Keys.Left);
                        Thread.Sleep(1);
                    }
                }
                if (GetIndexOfCurrentVisibleTab() == tabIndex)
                {
                    WillBot.LogMessageCombo("Switched to correct tab via drop down");
                    return RunStatus.Success;
                }
                return RunStatus.Failure;
            }));
        }