fonsleenaars / tqdb

Python parser for the Titan Quest Anniversary Edition, Ragnarok, Atlantis, Eternal Ember DLC database.
https://tq-db.net
MIT License
50 stars 15 forks source link

How to connect json data with sprite image? #78

Closed chefranov closed 4 years ago

chefranov commented 5 years ago

I found json file with properties of items on your site and I am going to use on my page. I read file via vue and fetch Screenshot_1 And now I want to show image of item, which addon and loot table but I don't know how it connect. Could you help me? And one more moment, json is too big (about 15mb) is it real divide on files by type? Is it possible to create json file with better structure (link to image, type of addon, loot table and etc inside item object)?

fonsleenaars commented 5 years ago

Nice, hope that works out!

As it stands, no, the JSON file is formatted in such a way that almost everything is done through the unique tags that the game files define. The website (tq-db.net) is a React wrapper around that data set that sorts out how the sprite and JSON data combine together, since I didn't really think that should be a part of the data.

However, data from this parser has more than just the JSON and sprite output, it also has a CSS sheet, that maps the unique tags to the respective position ON the spritesheet, so with those three things you should get what you're looking for.

chefranov commented 5 years ago

I have problem with images. I saw sprite on your site, but I don't know coordinates for each item. Can you help? my interpretation https://titanquest.org.ua/files/db/

fonsleenaars commented 5 years ago

You're missing the CSS file. If you run the parser you will get a sprite.png and sprite.css file.

sprite.png sprite.css.txt

I had to rename the CSS file to TXT because GitHub doesn't allow the upload.

The CSS file is all coordinates.

chefranov commented 5 years ago

Thank you! Can give a new version of json with data? Recently TQ was updated, I think items properties were also updated. And in your json I found some items with name is "placeholder". What is it? Screenshot_6 And russian version of file has properties in english (name of monsters and skills) Screenshot_7

fonsleenaars commented 5 years ago

I can't right now, the last version I pushed to this parser was for Atlantis and some other updates and there's a lot of data in the game files that seems to not be ready yet, but was picked up.

I filtered them manually on the website until I have a fix.

I'll use this ticket to mark off when those issues have been fixed, or if you want to contribute you can always feel free to open up a PR for them

chefranov commented 5 years ago

Images works!! Screenshot_9

How do you detect version of game (IT, Atlantis, Ragnarok)?

fonsleenaars commented 5 years ago

The tags on the items:

xTag = Immortal Throne x2Tag = Ragnarok x3Tag = Atlantis

chefranov commented 5 years ago

One more question, how work loot table of item in your json?

chefranov commented 5 years ago

How can I detect this information (chest or equiped) in your JSON file? Screenshot at Aug 02 11-14-32

Now I almost all implimented in my design https://titanquest.org.ua/items/

chefranov commented 4 years ago

Could you share with me new sprite.css and sprite.png?

chefranov commented 4 years ago

@fonsleenaars any updates?

fonsleenaars commented 4 years ago

I got it running again over Christmas, I'll see if I can push it, alongside some new instructions to get it running yourself, that way you can get your own files. Going to get reaquainted with the code this morning because it feels like a year since I last touched it 😅

chefranov commented 4 years ago

@fonsleenaars will be cool if it will work on windows and we can run it ourselves

fonsleenaars commented 4 years ago

@chefranov I run it on Windows myself so that should be easy enough. I don't work in python daily anymore so I'll just need to brush up a bit.

fonsleenaars commented 4 years ago

Alrighty, I managed to get the latest build running. I'll push some new instructions tomorrow with some bumps in dependencies, you should be able to generate the output yourself after that.

chefranov commented 4 years ago

@fonsleenaars we will wait for updates

chefranov commented 4 years ago

and if is it possible could you describe your json structure?

fonsleenaars commented 4 years ago

and if is it possible could you describe your json structure?

You'll have to figure out the JSON structure yourself, it's generated by the python code so you can browse through the parsers to see what the output is.

It mostly sticks to a mapping of properties in the DBR to similar/identical properties on the parsed content, just without all of the noise.