francisdb / vpxtool

Terminal based frontend and utilities for Visual Pinball
Apache License 2.0
18 stars 5 forks source link

Feature request: Ability to access individual json attributes in gamedata.json #306

Open jueank opened 6 months ago

jueank commented 6 months ago

I would like to be able to query individual json attributes from gamedata.json. E.g. 'bg_fov_fullscreen'. As a (potential later) extension, it would be nice if vpxtool allows setting attribute values. Both could potentially be generalized to all json files within a .vpx file.

francisdb commented 6 months ago

One option is writing/editing the [tablename].ini next to each table that updates those values. But I get the idea. Just curious, what is your use case?

jueank commented 6 months ago

I'm currently thinking about writing a small tool that uses vpxtool to retrieve glass_top_height and glass_bottom_height from gamedata.json of multiple .vpx files automatically. The intention is to calculate and set ViewCabWindowTop and ViewCabWindowBot, which are stored in [TableOverride] in the corresponding ini file per table. The calculation of ViewCabWindowTop and ViewCabWindowBot should be based on a target angle for the playfield, given by the user and batch automated for multiple .vpx files at once. I wanted to have this as a feature in vpinball (you voted for it); see here: https://github.com/vpinball/vpinball/issues/1295 - but I don't want to wait any longer and I'm therefore looking for an alternate or intermediate solution. I'm still at the beginning of my investigation; I'm not even sure if glass_top_height and glass_bottom_height are really used for the calculation of the visual playfield z position & slope (I read it somewhere, but my first investigation doesn't prove it). Still, I thought that reading and setting attribute values from internal json data is a useful functionality for vpxtool. That's why I made the feature request.

jueank commented 4 months ago

Any chance, this feature (or this: https://github.com/francisdb/vpxtool/issues/305) will be implemented? I would now rather like to extract the table height from gamedata.json instead of the other mentioned values above. So any way to do that elegantly (instead of being forced to extract the whole VPX file & resulting folder structure) would be nice.

francisdb commented 4 months ago

Just wondering what the best cli experience would be. What do you think about this?

vpxtool gamedata show test.vpx
# {...}
vpxtool gamedata show bg_fov_fullscreen test.vpx
# 30.0
francisdb commented 4 months ago

If you are on a unix system I could just implement the first and you would call

vpxtool gamedata show test.vpx | jq .bg_fov_fullscreen
30.0
jueank commented 4 months ago

Thanks for the quick reply. I happen to be on windows. gamedata.json ist mostly flat, but the other json files within VPX are not. So, asking for access to individual json attributes will only work for a limited set of cases. Therefore, a more robust and simple approach would be to just add the capability to extract files as a whole. I can then happily parse the file myself. So, your first proposal would be sufficient (and much more than I hoped for)

francisdb commented 4 months ago

Can you get going with https://github.com/francisdb/vpxtool/releases/tag/v0.13.8 ?

It has vpxtool gamedata show test.vpx and that should be MUCH faster than extracting the whole table.