In your resource system you should use a variable who accepts any kind of function type to load the resources. (It's what I was trying to say earlier)
And, you should use a simplified system for your callback system, and get rid of the context, to do something lie this :
//Store a function pointer to a member function and pass an objet to call the function later.
Function <void(MyAppli&, Vector2f)> (&function, &object);
//Create and store the signal and the slot.
System::connect<Function<void(MyAppli&, Vector2f)>>("IsMouseInsideRect", func);
//Call the
The interest is that the second parameter of the connect method can be any kind of function objects who call a pointer to a function.
I had juste to write a class who store a pointer to a non member function wich call a pointer to any king a function. (I had to do this because we can't store the adress of object members functions.)
This class can also store the value of the arguments if it's necessary.
To call the signal, you just have to write the kind of the function pointer in <> :
System::emit<Function<void(MyAppli&, Vector2f)>>("IsMouseInsideRect", mousePos);
The class system use the type erasure to store a generic pointer to the slot, and to cast the generic pointer into the slot type at the execution when we need to call it.
The same mecanism can be applied for actions, you can create an action, passing them a slot, and, link the slot to one or more sf::event throw the action, I've event set a map who link to sf::even, one event to trigger the action, and another event to terminate the action, but, I need to still improve the code, the template syntax is a bit barabare, and I need to redefine the operator || and && like you do in your class action map :
moveAction = new Action<Slot<void, Function<void(MyAppli&, sf::Keyboard::Key, sf::Time)>>> (slot2, false);
sf::Event endEvent1, endEvent2, endEvent3, endEvent4;
sf::Event event1, event2, event3, event4;
event1.type = sf::Event::KeyPressed;
event1.key.code = sf::Keyboard::Key::Z;
event2.type = sf::Event::KeyPressed;
event2.key.code = sf::Keyboard::Key::Q;
event3.type = sf::Event::KeyPressed;
event3.key.code = sf::Keyboard::Key::S;
event4.type = sf::Event::KeyPressed;
event4.key.code = sf::Keyboard::Key::D;
endEvent1.type = sf::Event::KeyReleased;
endEvent1.key.code = sf::Keyboard::Key::Z;
endEvent2.type = sf::Event::KeyReleased;
endEvent2.key.code = sf::Keyboard::Key::Q;
endEvent3.type = sf::Event::KeyReleased;
endEvent3.key.code = sf::Keyboard::Key::S;
endEvent4.type = sf::Event::KeyReleased;
endEvent4.key.code = sf::Keyboard::Key::D;
moveAction->linkEvents(event1, endEvent1);
moveAction->linkEvents(event2, endEvent2);
moveAction->linkEvents(event3, endEvent3);
moveAction->linkEvents(event4, endEvent4);
To call the slot you just need to call the process method of the action class (and you can pass some params if it's necessary) :
if (event.type == sf::Event::KeyPressed || event.type == sf::Event::KeyReleased) {
moveAction->pushEvent(event);
View view = getWindow().getView();
moveAction->process(event.key.code,realTime.restart());
But except that 2 defaults that I've still to improve (the template writting and the redefinition of the operator && and ||) I find that this code is perfect.
A macro should do the trick.
But I think you can easely simplify the action mecanism and the resource loading mecanism of the thor library by this way, because, if we can pass any kind of fonction pointer to the resource system, you don't have to redefine the key for loading the resource, and, you don't need to pass by class such contexts to access to the window. (It's often the cause of many crashes and environnement problems, then I prefer pass the render windw to a function)
To finish my discution, I think I'll even do a placeholder system, to replace some arguments before calling the slot. (and not always the whole argument list)
If I an find a way to pass references into a tuple, it would be nice too. (But I think that the lvalues and std::forwad should solve the problem)
PS : The new c++11 functionnalities seems to be powerfull!