Issues with latest version and `useContextMenuCascade`

The latest version broke this reload function for some reason. No clue why.

It right click and open the context menu but do not select anything in the menu. It just keeps right clicking.

image

Every other use of useContextMenuCascade seems to be fine except for this one.

reload : BotDecisionContext -> SeeUndockingComplete -> DecisionPathNode
reload context seeUndockingComplete =
    case seeUndockingComplete |> shipUIModulesToActivateOnTarget |> List.head of
        Nothing ->
            askForHelpToGetUnstuck

        Just weaponToReload ->
            case getDescendantWithDisplayText "25" weaponToReload.uiNode of
                Nothing ->
                    describeBranch "Lets reload."
                        (useContextMenuCascade
                            ( "Weapons", weaponToReload.uiNode )
                            (useMenuEntryWithTextContaining "Reload all" menuCascadeCompleted)
                            context
                        )

                Just _ ->
                    waitForProgressInGame

It seems like such an easy fix but I cannot find what is wrong.

even (useMenuEntryWithTextEqual "Reload all" menuCascadeCompleted) fails
Also added EveOnline.AppFrameworkSeparatingMemory.setMillisecondsToNextReadingFromGameBase 3333 to see if the delay would help but it does not change anything.

Reverting back to the older version fixed the issue.

The only difference is instead of context we use context.readingFromGameClient

reload : BotDecisionContext -> SeeUndockingComplete -> DecisionPathNode
reload context seeUndockingComplete =
    case seeUndockingComplete |> shipUIModulesToActivateOnTarget |> List.head of
        Nothing ->
            askForHelpToGetUnstuck

        Just weaponToReload ->
            case getDescendantWithDisplayText "25" weaponToReload.uiNode of
                Nothing ->
                    describeBranch "Lets reload."
                        (useContextMenuCascade
                            ( "Weapons", weaponToReload.uiNode )
                            (useMenuEntryWithTextContaining "Reload All" menuCascadeCompleted)
                            context.readingFromGameClient
                        )

                Just _ ->
                    waitForProgressInGame

Seems like there is an issue with how ‘useContextMenuCascade’ is implemented in the newest version vs the older one.

This one works (the older one):

useContextMenuCascade :
    ( String, UIElement )
    -> UseContextMenuCascadeNode
    -> ReadingFromGameClient
    -> DecisionPathNode
useContextMenuCascade ( initialUIElementName, initialUIElement ) useContextMenu readingFromGameClient =
    let
        occludingRegionsWithSafetyMargin =
            readingFromGameClient.contextMenus
                |> List.map (.uiNode >> .totalDisplayRegion >> growRegionOnAllSides 2)

        regionsRemainingAfterOcclusion =
            subtractRegionsFromRegion
                { minuend = initialUIElement.totalDisplayRegion, subtrahend = occludingRegionsWithSafetyMargin }
    in
    case
        regionsRemainingAfterOcclusion
            |> List.filter (\region -> 3 < region.width && 3 < region.height)
            |> List.sortBy (\region -> negate (min region.width region.height))
            |> List.head
    of
        Nothing ->
            Common.DecisionTree.describeBranch
                ("All of "
                    ++ initialUIElementName
                    ++ " is occluded by context menus."
                )
                (Common.DecisionTree.endDecisionPath
                    (actWithoutFurtherReadings
                        ( "Click somewhere else to get rid of the occluding elements."
                        , Common.EffectOnWindow.effectsMouseClickAtLocation Common.EffectOnWindow.MouseButtonRight { x = 4, y = 4 }
                        )
                    )
                )

        Just preferredRegion ->
            { actionsAlreadyDecided =
                ( "Open context menu on " ++ initialUIElementName
                , preferredRegion
                    |> centerFromDisplayRegion
                    |> Common.EffectOnWindow.effectsMouseClickAtLocation Common.EffectOnWindow.MouseButtonRight
                )
            , actionsDependingOnNewReadings = useContextMenu |> unpackContextMenuTreeToListOfActionsDependingOnReadings
            }
                |> Act
                |> Common.DecisionTree.endDecisionPath

After more testing, I was able to make it work by modifying this line:
if not cascadeFirstElementIsCloseToInitialUIElement then

into

if cascadeFirstElementIsCloseToInitialUIElement then

Still not sure what it is doing but its progress.

Fixed it for now by commenting out:

let
                           cascadeFirstElementIsCloseToInitialUIElement =
                               cornersFromDisplayRegion cascadeFirstElement.uiNode.totalDisplayRegion
                                   |> List.any
                                       (\corner ->
                                           doesPointIntersectRegion corner
                                               (initialUIElement.totalDisplayRegion |> growRegionOnAllSides 10)
                                       )
                       in
                       if not cascadeFirstElementIsCloseToInitialUIElement then
                           beginCascade

All of them are working now.