SFML community forums

Help => General => Topic started by: LedLoaf on December 08, 2020, 07:54:07 pm

Title: Any use 'Tileson' before?
Post by: LedLoaf on December 08, 2020, 07:54:07 pm
I'm looking at this cool library that helps parse TileD map editor files.

I'm having one hell of a time trying to figure out how to grab the "Color" property and the values within it? It's sort of like properties within properties.

What I did was make a Tiled Project and added a "Text display" ("Hello World") and I'm trying to obtain the colors that it should parse, so I can set the fillColor of the text. I'm thinking this might have to do with me not being to familiar with std::any and casting around correctly with it (any_cast).

I have basically been doing anything I can with getProps("Color"/"Red"/Text"). When I look at the json file, it breaks down more at "text" so I thought maybe that was how I could get to color.

   {
                 "height":19,
                 "id":27,
                 "name":"TextObject",
                 "rotation":0,
                 "text":
                    {
                     "color":"#00ff00",
                     "text":"Test Map",
                     "wrap":true
                    },
                 "type":"",
                 "visible":true,
                 "width":83,
                 "x":100.625,
                 "y":60
                }],
 
and also trying getProperties() and even tried doing getProperties.get<tson::Colori>(). I'm assuming I'll have to read it into sf::Color as a Uint32? I'm really hoping someone has messed with this before. I'm sure it's really easy and I'm looking past the obvious.



Thanks.
https://github.com/SSBMTonberry/tileson#readme  is the library project and they have some short examples, which I've been trying to pick at in accomplishing this.

I'm going to continue to look at the examples again and hope for the best. Have a great day.

EDIT: The parameters in TileD are  just Color, which breaks down to Red, Green, Blue, Alpha variables.
Title: Re: Any use 'Tileson' before?
Post by: eXpl0it3r on December 09, 2020, 01:50:32 pm
I suggest to open a issue on the tileson repository, since the author will probably know how to deal with the given input.

Alternatively, you could also use JSON for Modern C++ (https://github.com/nlohmann/json) directly or use export as tmx and use tmxlite (https://github.com/fallahn/tmxlite) to parse it.
Title: Re: Any use 'Tileson' before?
Post by: LedLoaf on December 10, 2020, 02:49:53 am
 :-X I didn't even know you can do that.

Thanks!