ThizThizzyDizzy / nc-reactor-generator

A program to plan and generate reactors for Nuclearcraft (https://www.curseforge.com/minecraft/mc-mods/nuclearcraft-mod)
GNU General Public License v3.0
30 stars 6 forks source link

NCPF File formats (.ncpf.json?) #126

Closed ThizThizzyDizzy closed 1 year ago

ThizThizzyDizzy commented 1 year ago

As part of the rewrite, I'm considering separating NCPF from the current format (Config2) and allowing any format, (most notably JSON) to be used instead, so long as it holds the same data structure. How should this be best achieved to avoid confusion over file formats? (I'm thinking of .ncpf.json for JSON-encoded NCPF files, or some abbreviation like .jncpf)

thedeadferryman commented 1 year ago

I think the .ncpf.<format> would fit better if you want to make it support any format. Also if you want to have a binary format for NCPFs other than Config2 (which is, honestly speaking, quite a weird format), I could propose MessagePack or CBOR. These are both JSON-like formats in terms of data structure, yet these are binary.

ThizThizzyDizzy commented 1 year ago

Config2 was used because it's part of the library I was using at the time for window management/rendering, but I have since moved away from simplelibrary entirely

Another issue I thought of is encoding textures; they're done compactly in NCPF (#127) but how would this be done in JSON? Or would the JSON format be inherently textureless?

thedeadferryman commented 1 year ago

@ThizThizzyDizzy you can just encode texture BLOBs with base64, that's a common practice. However, are you sure you need textures at all in NCPFs? Like, we cannot open a NCPF in the plannerator if it contains addons not configured in the plannerator. So maybe just keep textures in plannerator config and remove from NCPF completely?

ThizThizzyDizzy commented 1 year ago

In current NCPF, Textures are not saved in saved reactors, as they have a partial configuration Textures, (and display names, and a few more things) are only saved in full configurations, (i.e. plannerator configurations, which is also NCPF)

ThizThizzyDizzy commented 1 year ago

By the NCPF spec, you don't have to use partial configs, so you could save a reactor with a full configuration if you wanted to The plannerator just doesn't do this for file size reasons

ThizThizzyDizzy commented 1 year ago

Oh, should things like textures and display names be treated the same way as the other definitions? (i.e. in the same list, perhaps being plannerator-specific fields)

ThizThizzyDizzy commented 1 year ago

I may extend this in the other direction as well, such as using .cfg.ncpf.json to refer to a plannerator configuration saved as JSON (This is relevant since I'm planning to save a bunch of different things, such as generator settings, within NCPF)

ThizThizzyDizzy commented 1 year ago

ncpf.json is the new default (and currently the only one supported)