Skip to content

Commit

Permalink
Support parse from the memory reading
Browse files Browse the repository at this point in the history
Add shortcuts to popular derivations from the memory reading.
  • Loading branch information
Viir committed Feb 27, 2020
1 parent 25eebec commit b6eb860
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 20 deletions.
141 changes: 122 additions & 19 deletions implement/alternate-ui/elm-app/src/EveOnline/MemoryReading.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module EveOnline.MemoryReading exposing
( ChatUserEntry
( AgentConversationWindow
, ChatUserEntry
, ChatWindow
, ChatWindowStack
, ChildOfNodeWithDisplayRegion(..)
Expand All @@ -21,6 +22,7 @@ module EveOnline.MemoryReading exposing
, InventoryItemsView(..)
, InventoryWindow
, InventoryWindowCapacityGauge
, MarketOrdersWindow
, MaybeVisible(..)
, MessageBox
, ModuleButtonTooltip
Expand All @@ -31,6 +33,7 @@ module EveOnline.MemoryReading exposing
, ParsedUserInterface
, ProbeScanResult
, ProbeScannerWindow
, SelectedItemWindow
, ShipManeuverType(..)
, ShipUI
, ShipUIIndication
Expand Down Expand Up @@ -80,11 +83,14 @@ type alias ParsedUserInterface =
, infoPanelLocationInfo : MaybeVisible InfoPanelLocationInfo
, infoPanelRoute : MaybeVisible InfoPanelRoute
, overviewWindow : MaybeVisible OverviewWindow
, selectedItemWindow : MaybeVisible SelectedItemWindow
, dronesWindow : MaybeVisible DronesWindow
, probeScannerWindow : MaybeVisible ProbeScannerWindow
, stationWindow : MaybeVisible StationWindow
, inventoryWindows : List InventoryWindow
, chatWindowStacks : List ChatWindowStack
, agentConversationWindows : List AgentConversationWindow
, marketOrdersWindow : MaybeVisible MarketOrdersWindow
, moduleButtonTooltip : MaybeVisible ModuleButtonTooltip
, neocom : MaybeVisible Neocom
, messageBoxes : List MessageBox
Expand Down Expand Up @@ -151,13 +157,16 @@ type alias ShipUI =


type alias ShipUIIndication =
{ maneuverType : MaybeVisible ShipManeuverType
{ uiNode : UITreeNodeWithDisplayRegion
, maneuverType : MaybeVisible ShipManeuverType
}


type alias ShipUIModule =
{ uiNode : UITreeNodeWithDisplayRegion
, slotUINode : UITreeNodeWithDisplayRegion
, isActive : Maybe Bool
, isHiliteVisible : Bool
}


Expand Down Expand Up @@ -223,6 +232,17 @@ type alias OverviewWindowEntry =
}


type alias SelectedItemWindow =
{ uiNode : UITreeNodeWithDisplayRegion
, orbitButton : Maybe UITreeNodeWithDisplayRegion
}


type alias MarketOrdersWindow =
{ uiNode : UITreeNodeWithDisplayRegion
}


type alias ColorComponents =
{ a : Int, r : Int, g : Int, b : Int }

Expand Down Expand Up @@ -345,6 +365,11 @@ type alias NeocomClock =
}


type alias AgentConversationWindow =
{ uiNode : UITreeNodeWithDisplayRegion
}


type alias Expander =
{ uiNode : UITreeNodeWithDisplayRegion
, texturePath : Maybe String
Expand Down Expand Up @@ -377,12 +402,15 @@ parseUserInterfaceFromUITree uiTree =
, infoPanelLocationInfo = parseInfoPanelLocationInfoFromUITreeRoot uiTree
, infoPanelRoute = parseInfoPanelRouteFromUITreeRoot uiTree
, overviewWindow = parseOverviewWindowFromUITreeRoot uiTree
, selectedItemWindow = parseSelectedItemWindowFromUITreeRoot uiTree
, dronesWindow = parseDronesWindowFromUITreeRoot uiTree
, probeScannerWindow = parseProbeScannerWindowFromUITreeRoot uiTree
, stationWindow = parseStationWindowFromUITreeRoot uiTree
, inventoryWindows = parseInventoryWindowsFromUITreeRoot uiTree
, moduleButtonTooltip = parseModuleButtonTooltipFromUITreeRoot uiTree
, chatWindowStacks = parseChatWindowStacksFromUITreeRoot uiTree
, agentConversationWindows = parseAgentConversationWindowsFromUITreeRoot uiTree
, marketOrdersWindow = parseMarketOrdersWindowFromUITreeRoot uiTree
, neocom = parseNeocomFromUITreeRoot uiTree
, messageBoxes = parseMessageBoxesFromUITreeRoot uiTree
}
Expand Down Expand Up @@ -602,29 +630,44 @@ parseShipUIFromUITreeRoot uiTreeRoot =
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "SpeedGauge")
|> List.head

maybeIndicationElement =
shipUINode.uiNode
|> listDescendantsInUITreeNode
|> List.filter (getNameFromDictEntries >> Maybe.map (String.toLower >> String.contains "indicationcontainer") >> Maybe.withDefault False)
maybeIndicationNode =
shipUINode
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> getNameFromDictEntries >> Maybe.map (String.toLower >> String.contains "indicationcontainer") >> Maybe.withDefault False)
|> List.head

indication =
maybeIndicationElement
maybeIndicationNode
|> Maybe.map (parseShipUIIndication >> CanSee)
|> Maybe.withDefault CanNotSeeIt

modules =
shipUINode
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "ModuleButton")
|> List.map
(\moduleNode ->
{ uiNode = moduleNode
, isActive =
moduleNode.uiNode.dictEntriesOfInterest
|> Dict.get "ramp_active"
|> Maybe.andThen (Json.Decode.decodeValue Json.Decode.bool >> Result.toMaybe)
}
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "ShipSlot")
|> List.filterMap
(\slotNode ->
slotNode
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "ModuleButton")
|> List.head
|> Maybe.map
(\moduleNode ->
{ uiNode = moduleNode
, slotUINode = slotNode
, isActive =
moduleNode.uiNode.dictEntriesOfInterest
|> Dict.get "ramp_active"
|> Maybe.andThen (Json.Decode.decodeValue Json.Decode.bool >> Result.toMaybe)
, isHiliteVisible =
slotNode
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "Sprite")
|> List.filter (.uiNode >> getNameFromDictEntries >> (==) (Just "hilite"))
|> List.isEmpty
|> not
}
)
)

getLastValuePercentFromGaugeName gaugeName =
Expand Down Expand Up @@ -690,11 +733,11 @@ parseTarget targetNode =
}


parseShipUIIndication : UITreeNode -> ShipUIIndication
parseShipUIIndication : UITreeNodeWithDisplayRegion -> ShipUIIndication
parseShipUIIndication indicationUINode =
let
displayTexts =
indicationUINode |> getAllContainedDisplayTexts
indicationUINode.uiNode |> getAllContainedDisplayTexts

maneuverType =
[ ( "Warp", ManeuverWarp )
Expand All @@ -713,7 +756,7 @@ parseShipUIIndication indicationUINode =
|> List.head
|> canNotSeeItFromMaybeNothing
in
{ maneuverType = maneuverType }
{ uiNode = indicationUINode, maneuverType = maneuverType }


parseOverviewWindowFromUITreeRoot : UITreeNodeWithDisplayRegion -> MaybeVisible OverviewWindow
Expand Down Expand Up @@ -866,6 +909,36 @@ parseOverviewEntryDistanceInMetersFromText distanceDisplayTextBeforeTrim =
Err ("Text did not match expected number format: '" ++ distanceDisplayText ++ "'")


parseSelectedItemWindowFromUITreeRoot : UITreeNodeWithDisplayRegion -> MaybeVisible SelectedItemWindow
parseSelectedItemWindowFromUITreeRoot uiTreeRoot =
uiTreeRoot
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "ActiveItem")
|> List.head
|> Maybe.map parseSelectedItemWindow
|> canNotSeeItFromMaybeNothing


parseSelectedItemWindow : UITreeNodeWithDisplayRegion -> SelectedItemWindow
parseSelectedItemWindow windowNode =
let
actionButtonFromTexturePathEnding texturePathEnding =
windowNode
|> listDescendantsWithDisplayRegion
|> List.filter
(.uiNode
>> getTexturePathFromDictEntries
>> Maybe.map (String.toLower >> String.endsWith (String.toLower texturePathEnding))
>> Maybe.withDefault False
)
|> List.head

orbitButton =
actionButtonFromTexturePathEnding "44_32_21.png"
in
{ uiNode = windowNode, orbitButton = orbitButton }


parseDronesWindowFromUITreeRoot : UITreeNodeWithDisplayRegion -> MaybeVisible DronesWindow
parseDronesWindowFromUITreeRoot uiTreeRoot =
case
Expand Down Expand Up @@ -1320,6 +1393,36 @@ parseChatUserEntry chatUserUiNode =
}


parseAgentConversationWindowsFromUITreeRoot : UITreeNodeWithDisplayRegion -> List AgentConversationWindow
parseAgentConversationWindowsFromUITreeRoot uiTreeRoot =
uiTreeRoot
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "AgentDialogueWindow")
|> List.map parseAgentConversationWindow


parseAgentConversationWindow : UITreeNodeWithDisplayRegion -> AgentConversationWindow
parseAgentConversationWindow windowUINode =
{ uiNode = windowUINode
}


parseMarketOrdersWindowFromUITreeRoot : UITreeNodeWithDisplayRegion -> MaybeVisible MarketOrdersWindow
parseMarketOrdersWindowFromUITreeRoot uiTreeRoot =
uiTreeRoot
|> listDescendantsWithDisplayRegion
|> List.filter (.uiNode >> .pythonObjectTypeName >> (==) "MarketOrdersWnd")
|> List.head
|> Maybe.map parseMarketOrdersWindow
|> canNotSeeItFromMaybeNothing


parseMarketOrdersWindow : UITreeNodeWithDisplayRegion -> MarketOrdersWindow
parseMarketOrdersWindow windowUINode =
{ uiNode = windowUINode
}


parseNeocomFromUITreeRoot : UITreeNodeWithDisplayRegion -> MaybeVisible Neocom
parseNeocomFromUITreeRoot uiTreeRoot =
case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ renderTreeNodeFromParsedUserInterface maybeInputRoute uiNodesWithDisplayRegion p
, fieldValueSummary = always "..."
, fieldValueChildren = treeNodeChildrenFromOverviewWindow viewConfig
}
, parsedUserInterface.selectedItemWindow
|> fieldFromMaybeVisibleInstance
{ fieldName = "selectedItemWindow"
, fieldValueSummary = always "..."
, fieldValueChildren = treeNodeChildrenFromSelectedItemWindow viewConfig
}
, parsedUserInterface.dronesWindow
|> fieldFromMaybeVisibleInstance
{ fieldName = "dronesWindow"
Expand Down Expand Up @@ -179,6 +185,17 @@ renderTreeNodeFromParsedUserInterface maybeInputRoute uiNodesWithDisplayRegion p
{ fieldName = "chatWindowStacks"
, fieldValueChildren = treeNodeChildrenFromChatWindowStack viewConfig
}
, parsedUserInterface.agentConversationWindows
|> fieldFromListInstance
{ fieldName = "agentConversationWindows"
, fieldValueChildren = treeNodeChildrenFromAgentConversationWindow viewConfig
}
, parsedUserInterface.marketOrdersWindow
|> fieldFromMaybeVisibleInstance
{ fieldName = "marketOrdersWindow"
, fieldValueSummary = always "..."
, fieldValueChildren = treeNodeChildrenFromMarketOrdersWindow viewConfig
}
, parsedUserInterface.moduleButtonTooltip
|> fieldFromMaybeVisibleInstance
{ fieldName = "moduleButtonTooltip"
Expand Down Expand Up @@ -265,7 +282,13 @@ treeNodeChildrenFromParsedUserInterfaceShipUIModule viewConfig parsedUserInterfa
treeNodeChildrenFromRecordWithUINode
viewConfig
parsedUserInterfaceShipUIModule.uiNode
[ parsedUserInterfaceShipUIModule.isActive |> fieldFromMaybeBool "isActive"
[ { fieldName = "slotUINode"
, fieldValueSummary = "..."
, fieldValueChildren =
always [ treeViewNodeFromUINode viewConfig parsedUserInterfaceShipUIModule.slotUINode ]
}
, parsedUserInterfaceShipUIModule.isActive |> fieldFromMaybeBool "isActive"
, parsedUserInterfaceShipUIModule.isHiliteVisible |> fieldFromBool "isHiliteVisible"
]


Expand Down Expand Up @@ -652,6 +675,39 @@ treeNodeChildrenFromModuleButtonTooltip viewConfig moduleButtonTooltip =
[]


treeNodeChildrenFromAgentConversationWindow :
ViewConfig event
-> EveOnline.MemoryReading.AgentConversationWindow
-> List (TreeViewNode event ParsedUITreeViewPathNode)
treeNodeChildrenFromAgentConversationWindow viewConfig agentConversationWindow =
treeNodeChildrenFromRecordWithUINode
viewConfig
agentConversationWindow.uiNode
[]


treeNodeChildrenFromSelectedItemWindow :
ViewConfig event
-> EveOnline.MemoryReading.SelectedItemWindow
-> List (TreeViewNode event ParsedUITreeViewPathNode)
treeNodeChildrenFromSelectedItemWindow viewConfig selectedItemWindow =
treeNodeChildrenFromRecordWithUINode
viewConfig
selectedItemWindow.uiNode
[]


treeNodeChildrenFromMarketOrdersWindow :
ViewConfig event
-> EveOnline.MemoryReading.MarketOrdersWindow
-> List (TreeViewNode event ParsedUITreeViewPathNode)
treeNodeChildrenFromMarketOrdersWindow viewConfig marketOrdersWindow =
treeNodeChildrenFromRecordWithUINode
viewConfig
marketOrdersWindow.uiNode
[]


treeNodeChildrenFromNeocom :
ViewConfig event
-> EveOnline.MemoryReading.Neocom
Expand Down Expand Up @@ -947,6 +1003,17 @@ fieldFromListInstance listField list =
}


fieldFromBool :
String
-> Bool
-> { fieldName : String, fieldValueSummary : String, fieldValueChildren : () -> List (TreeViewNode event ParsedUITreeViewPathNode) }
fieldFromBool fieldName fieldValue =
{ fieldName = fieldName
, fieldValueSummary = Json.Encode.bool fieldValue |> Json.Encode.encode 0
, fieldValueChildren = always []
}


fieldFromMaybeBool :
String
-> Maybe Bool
Expand Down

0 comments on commit b6eb860

Please sign in to comment.