Arcitectus / Sanderling

APIs and libraries to read information directly from the EVE Online game client.
https://forum.botlab.org
Apache License 2.0
258 stars 117 forks source link

feat: add Cli app for frontend #88

Closed sillychipmunk closed 2 months ago

sillychipmunk commented 2 months ago

EDIT: this is equally as much to learn from. Might not lead anywhere. Im trying to figure out one thing by doing something else (figuring out how coordinates are calculated from offsets, by outputting the ui tree to json and learning sanderling and the elm code).

Allow to output UI with coords to json in a cli app

install elm posix cli

npm install -g @albertdahlin/elm-posix

run with

elm-cli run src/Frontend/Cli.elm .\eve-online-memory-reading.json > result.json

sillychipmunk commented 2 months ago

@Viir do you have any suggestions on how we can transform the Dict.Dict String UITreeNodeWithDisplayRegion to json ? other than .. like .. construct the json manually 🤣 EDIT: figured it out, but its just a random output of spaces of non connected json ;) EDIT2: encode to json

sillychipmunk commented 2 months ago

now its proper. And as all elm when you have written it, you know it will not crash if it compiles ;) might not do WHAT you want. But it does what you SAID it should do ;)

sillychipmunk commented 2 months ago

@Viir tested against a real memory reading. Partial json follows

image

sillychipmunk commented 2 months ago

in practice what i want is a true json representation of the whole UI structure, so this is just an example that proves its possible to read the file and run it from the "until now" elm browser only code pipeline

EDIT: im considering updating the original json with correct coordinates, or adding new fields or objects to the python adresses. Only problem is what to decode it into from json string, which could allow for updating and then encoding back to string

Viir commented 2 months ago

@sillychipmunk

@Viir do you have any suggestions on how we can transform the Dict.Dict String UITreeNodeWithDisplayRegion to json ?

In case you have not seen it, there is automation to generate these transformation functions for a given Elm type.

The documentation on generating the JSON converters is at https://github.com/pine-vm/pine/blob/6c1bde4e5f558e151362c322c3f73e501a3015c4/guide/how-to-use-elm-compilation-interfaces.md#compilationinterfacegeneratejsonconverters-elm-module

How about using an encoder like this?

module CompilationInterface.GenerateJsonConverters exposing (..)

import Dict
import EveOnline.ParseUserInterface
import Json.Decode
import Json.Encode

jsonEncodeUITreeNodeWithDisplayRegion :
    Dict.Dict String EveOnline.ParseUserInterface.UITreeNodeWithDisplayRegion
    -> Json.Encode.Value
jsonEncodeUITreeNodeWithDisplayRegion =
    always (Json.Encode.string "The compiler replaces this function.")
sillychipmunk commented 2 months ago

Ah yeah @Viir I guess it would work if we were running this under pine-vm or similar environment as the elm app ;) but sadly this is a standalone cli tool mainly used to piggy back the types and logic from the elm project, to create a type of output readable by a totally external process. Actually, the only reason I do this is to calculate the x and y positions. because that depends on parent elements etc. Tried your approach, but it outputs the string as we all would expect ;) EDIT: I will however read the linked README a more thoroughly @ EDIT2: Nope, won't work.

sillychipmunk commented 2 months ago

dropping it ; )