Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Any use 'Tileson' before?  (Read 2198 times)

0 Members and 1 Guest are viewing this topic.

LedLoaf

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Any use 'Tileson' before?
« 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.
« Last Edit: December 08, 2020, 07:56:18 pm by LedLoaf »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Any use 'Tileson' before?
« Reply #1 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++ directly or use export as tmx and use tmxlite to parse it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

LedLoaf

  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Email
Re: Any use 'Tileson' before?
« Reply #2 on: December 10, 2020, 02:49:53 am »
 :-X I didn't even know you can do that.

Thanks!

 

anything