Closed sillychipmunk closed 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
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 ;)
@Viir tested against a real memory reading. Partial json follows
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
@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.")
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.
dropping it ; )
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