So, implementing
toString and
getValueFromString methods totally solved the problem with having
QVariant near animation classes.
QTreeView uses
QString for data manipulation, so when you input something, you get
QVariant which contains
QString with stuff you just wrote. This is converted to
std::string and passed to virtual function in
IProperty<Class> which then calls function in
Property<T, Class> which then converts from
std::string to
T.
One interesting problem to solve was checking the input data. That's because if you do this:
auto i = std::stoi("bla-bla");
you get an exception. So, I created a quick function which checks if the string contains data which can be converted to following types:
bool, int, float, string (he-he), etc.
And if you input wrong stuff, you get a nice error message instead of program crash.
I've also worked on the game itself (finally!). I connected meta stuff to main project and quickly thrown away old JSON loading code in favor of meta-deserialization! It worked pretty well. I'm now very glad that I did all that stuff instead of sticking to the easiest solution.
Now only animations use JSON but I'll start to convert most of the component data from Lua to JSON. What's interesting is that I can do it gradually (converting component data to JSON one by one), so I won't stop working on other stuff in meanwhile!
I've also came up with a bunch of cool ideas which will be easy to implement (mostly dialogues and cutscenes) and I won't spoil anything. Oh, and I'll soon start working on cutscene system, so expect some silly test cutscenes soon.
And by the way, I have question about reusing your own code in your projects. How do you do it?
Often I feel that I need to use LogManager, ResourceManager or Meta stuff in other quick/test projects and I end up just copying the code from main project so I don't break some stuff in it accidentally (by changing code shared among different projects). This approach is obviously not the right way to do stuff... So, what's your approach? Where do you store your code which you reuse in different projects? Do you just include them in all your projects or do you make shared libs?